[llvm-commits] [llvm] r152869 - in /llvm/trunk: lib/Target/ARM/ARMFastISel.cpp test/CodeGen/ARM/fast-isel-cmp-imm.ll
Chad Rosier
mcrosier at apple.com
Thu Mar 15 15:54:20 PDT 2012
Author: mcrosier
Date: Thu Mar 15 17:54:20 2012
New Revision: 152869
URL: http://llvm.org/viewvc/llvm-project?rev=152869&view=rev
Log:
[fast-isel] Address Eli's comments for r152847. Specifically, add a test case
and still allow immediate encoding, just not with cmn.
rdar://11038907
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=152869&r1=152868&r2=152869&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMFastISel.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Thu Mar 15 17:54:20 2012
@@ -1384,16 +1384,15 @@
SrcVT == MVT::i1) {
const APInt &CIVal = ConstInt->getValue();
Imm = (isZExt) ? (int)CIVal.getZExtValue() : (int)CIVal.getSExtValue();
- // We can't encode LONG_MIN (i.e., 0x80000000) as an immediate because
- // there is no way to represent 2147483648 as a signed 32-bit int.
- if (Imm != (int)0x80000000) {
- if (Imm < 0) {
- isNegativeImm = true;
- Imm = -Imm;
- }
- UseImm = isThumb2 ? (ARM_AM::getT2SOImmVal(Imm) != -1) :
- (ARM_AM::getSOImmVal(Imm) != -1);
+ // For INT_MIN/LONG_MIN (i.e., 0x80000000) we need to use a cmp, rather
+ // then a cmn, because there is no way to represent 2147483648 as a
+ // signed 32-bit int.
+ if (Imm < 0 && Imm != (int)0x80000000) {
+ isNegativeImm = true;
+ Imm = -Imm;
}
+ UseImm = isThumb2 ? (ARM_AM::getT2SOImmVal(Imm) != -1) :
+ (ARM_AM::getSOImmVal(Imm) != -1);
}
} else if (const ConstantFP *ConstFP = dyn_cast<ConstantFP>(Src2Value)) {
if (SrcVT == MVT::f32 || SrcVT == MVT::f64)
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=152869&r1=152868&r2=152869&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/fast-isel-cmp-imm.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/fast-isel-cmp-imm.ll Thu Mar 15 17:54:20 2012
@@ -229,3 +229,22 @@
if.end: ; preds = %if.then, %entry
ret void
}
+
+; rdar://11038907
+; When comparing LONG_MIN/INT_MIN use a cmp instruction.
+define void @t13() nounwind ssp {
+entry:
+; ARM: t13
+; THUMB: t13
+ %cmp = icmp slt i32 -123, -2147483648
+; ARM: cmp r{{[0-9]}}, #-2147483648
+; THUMB: cmp.w r{{[0-9]}}, #-2147483648
+ br i1 %cmp, label %if.then, label %if.end
+
+if.then: ; preds = %entry
+ ret void
+
+if.end: ; preds = %entry
+ ret void
+}
+
More information about the llvm-commits
mailing list