From: Chad Rosier Date: Thu, 15 Mar 2012 21:40:23 +0000 (+0000) Subject: [fast-isel] Don't try to encode LONG_MIN using cmn instructions. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=530b19b70212f02cffa971256501e77284c320a0;p=oota-llvm.git [fast-isel] Don't try to encode LONG_MIN using cmn instructions. rdar://11038907 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152847 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/ARM/ARMFastISel.cpp b/lib/Target/ARM/ARMFastISel.cpp index 71de52fcaaa..4651a3ac929 100644 --- a/lib/Target/ARM/ARMFastISel.cpp +++ b/lib/Target/ARM/ARMFastISel.cpp @@ -1384,12 +1384,16 @@ bool ARMFastISel::ARMEmitCmp(const Value *Src1Value, const Value *Src2Value, SrcVT == MVT::i1) { const APInt &CIVal = ConstInt->getValue(); Imm = (isZExt) ? (int)CIVal.getZExtValue() : (int)CIVal.getSExtValue(); - if (Imm < 0) { - isNegativeImm = true; - Imm = -Imm; + // 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); } - UseImm = isThumb2 ? (ARM_AM::getT2SOImmVal(Imm) != -1) : - (ARM_AM::getSOImmVal(Imm) != -1); } } else if (const ConstantFP *ConstFP = dyn_cast(Src2Value)) { if (SrcVT == MVT::f32 || SrcVT == MVT::f64)