[llvm-commits] [llvm] r144258 - in /llvm/trunk: lib/Target/ARM/ARMFastISel.cpp test/CodeGen/ARM/fast-isel-cmp-imm.ll
Chad Rosier
mcrosier at apple.com
Wed Nov 9 17:30:39 PST 2011
Author: mcrosier
Date: Wed Nov 9 19:30:39 2011
New Revision: 144258
URL: http://llvm.org/viewvc/llvm-project?rev=144258&view=rev
Log:
For immediate encodings of icmp, zero or sign extend first. Then
determine if the value is negative and flip the sign accordingly.
rdar://10422026
Modified:
llvm/trunk/lib/Target/ARM/ARMFastISel.cpp
llvm/trunk/test/CodeGen/ARM/fast-isel-cmp-imm.ll
Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFastISel.cpp?rev=144258&r1=144257&r2=144258&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMFastISel.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Wed Nov 9 19:30:39 2011
@@ -1216,7 +1216,6 @@
// Check to see if the 2nd operand is a constant that we can encode directly
// in the compare.
- uint64_t Imm;
int EncodedImm = 0;
bool EncodeImm = false;
bool isNegativeImm = false;
@@ -1224,10 +1223,11 @@
if (SrcVT == MVT::i32 || SrcVT == MVT::i16 || SrcVT == MVT::i8 ||
SrcVT == MVT::i1) {
const APInt &CIVal = ConstInt->getValue();
-
- isNegativeImm = CIVal.isNegative();
- Imm = (isNegativeImm) ? (-CIVal).getZExtValue() : CIVal.getZExtValue();
- EncodedImm = (int)Imm;
+ EncodedImm = (isZExt) ? (int)CIVal.getZExtValue() : (int)CIVal.getSExtValue();
+ if (EncodedImm < 0) {
+ isNegativeImm = true;
+ EncodedImm = -EncodedImm;
+ }
EncodeImm = isThumb2 ? (ARM_AM::getT2SOImmVal(EncodedImm) != -1) :
(ARM_AM::getSOImmVal(EncodedImm) != -1);
}
Modified: llvm/trunk/test/CodeGen/ARM/fast-isel-cmp-imm.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fast-isel-cmp-imm.ll?rev=144258&r1=144257&r2=144258&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/fast-isel-cmp-imm.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/fast-isel-cmp-imm.ll Wed Nov 9 19:30:39 2011
@@ -212,3 +212,20 @@
if.end: ; preds = %if.then, %entry
ret void
}
+
+define void @t12(i8 %a) uwtable ssp {
+entry:
+; ARM: t12
+; THUMB: t12
+ %cmp = icmp ugt i8 %a, -113
+; ARM: cmp r{{[0-9]}}, #143
+; THUMB: cmp r{{[0-9]}}, #143
+ br i1 %cmp, label %if.then, label %if.end
+
+if.then: ; preds = %entry
+ tail call void @foo()
+ br label %if.end
+
+if.end: ; preds = %if.then, %entry
+ ret void
+}
More information about the llvm-commits
mailing list