[AArch64] Fix bad register class constraint in fast-isel for TST instruction.
authorQuentin Colombet <qcolombet@apple.com>
Thu, 30 Apr 2015 22:27:20 +0000 (22:27 +0000)
committerQuentin Colombet <qcolombet@apple.com>
Thu, 30 Apr 2015 22:27:20 +0000 (22:27 +0000)
rdar://problem/20748715

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236273 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AArch64/AArch64FastISel.cpp
test/CodeGen/AArch64/arm64-fast-isel.ll

index c3f6859f510d6840396ef2564bd0eaf782793323..837a31f303fb08061091aef6d8c71b9fa111d556 100644 (file)
@@ -2679,8 +2679,11 @@ bool AArch64FastISel::selectSelect(const Instruction *I) {
       return false;
     bool CondIsKill = hasTrivialKill(Cond);
 
+    const MCInstrDesc &II = TII.get(AArch64::ANDSWri);
+    CondReg = constrainOperandRegClass(II, CondReg, 1);
+
     // Emit a TST instruction (ANDS wzr, reg, #imm).
-    BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(AArch64::ANDSWri),
+    BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II,
             AArch64::WZR)
         .addReg(CondReg, getKillRegState(CondIsKill))
         .addImm(AArch64_AM::encodeLogicalImmediate(1, 32));
index a4d08f9016a02befba8c9eeb4b1c4f66c1083ef7..a1d51a54cd466c520cb50d26577a77ac1c1a0259 100644 (file)
@@ -91,3 +91,13 @@ define void @t6() nounwind {
 }
 
 declare void @llvm.trap() nounwind
+
+define void @ands(i32* %addr) {
+; CHECK-LABEL: ands:
+; CHECK: tst [[COND:w[0-9]+]], #0x1
+; CHECK-NEXT: csel [[COND]],
+entry:
+  %cond91 = select i1 undef, i32 1, i32 2
+  store i32 %cond91, i32* %addr, align 4
+  ret void
+}