summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2004-11-04 19:43:18 +0000
committerNate Begeman <natebegeman@mac.com>2004-11-04 19:43:18 +0000
commit28dd2fc240749d77d4251b4a29b8cace2a65460c (patch)
treeb750a669e78abd4029bb60ff0919613283bafb2b
parent3c7d7ee76136bf0041693fc939e155f34a197b2b (diff)
downloadllvm-28dd2fc240749d77d4251b4a29b8cace2a65460c.tar.gz
llvm-28dd2fc240749d77d4251b4a29b8cace2a65460c.tar.bz2
llvm-28dd2fc240749d77d4251b4a29b8cace2a65460c.tar.xz
Thanks to sabre for pointing out that we were incorrectly codegen'ing
int test(int x) { return 32768 - x; } Fixed by teaching the function that checks a constant's validity to be used as an immediate argument about subtract-from instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17476 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/PowerPC/PPC32ISelSimple.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Target/PowerPC/PPC32ISelSimple.cpp b/lib/Target/PowerPC/PPC32ISelSimple.cpp
index d0406c7e40..5314dada04 100644
--- a/lib/Target/PowerPC/PPC32ISelSimple.cpp
+++ b/lib/Target/PowerPC/PPC32ISelSimple.cpp
@@ -536,8 +536,11 @@ bool PPC32ISel::canUseAsImmediateForOpcode(ConstantInt *CI, unsigned Opcode,
else
return false;
}
+
+ // Treat subfic like addi for the purposes of constant validation
+ if (Opcode == 5) Opcode = 0;
- // ADDI, Compare, and non-indexed Load take SIMM
+ // addi, subfic, compare, and non-indexed load take SIMM
bool cond1 = (Opcode < 2)
&& ((int32_t)CI->getRawValue() <= 32767)
&& ((int32_t)CI->getRawValue() >= -32768);