Summary: Thanks to Vitaly Buka for helping catch this.
Reviewers: rengolin, jmolloy, efriedma, vitalybuka
Subscribers: llvm-commits, aemerson
Differential Revision: https://reviews.llvm.org/D31242
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298512
91177308-0d34-0410-b5e6-
96231b3b80d8
// t2_so_imm_neg - Match an immediate that is a negation of a t2_so_imm.
def t2_so_imm_neg_asmoperand : AsmOperandClass { let Name = "T2SOImmNeg"; }
def t2_so_imm_neg : Operand<i32>, PatLeaf<(imm), [{
- int64_t Value = -(int)N->getZExtValue();
+ int64_t Value = N->getZExtValue();
+ if (Value == 1LL<<31) return false; // INT_MIN cannot be negated
+ Value = -(int)Value;
return Value && ARM_AM::getT2SOImmVal(Value) != -1;
}], t2_so_imm_neg_XFORM> {
let ParserMatchClass = t2_so_imm_neg_asmoperand;
ret i32 %1
}
+define i32 @test2(i32 %X) {
+entry:
+; CHECK-LABEL: test2:
+; CHECK: lsls r1, r1, #31
+; CHECK-NEXT: adds
+ %tmp1 = sub i32 %X, 2147483648
+ ret i32 %tmp1
+}
+