From: Quentin Colombet Date: Thu, 30 Apr 2015 22:27:20 +0000 (+0000) Subject: [AArch64] Fix bad register class constraint in fast-isel for TST instruction. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=329fa890ba5b2e7c0857118baae9cae68e26fccc;p=platform%2Fupstream%2Fllvm.git [AArch64] Fix bad register class constraint in fast-isel for TST instruction. rdar://problem/20748715 llvm-svn: 236273 --- diff --git a/llvm/lib/Target/AArch64/AArch64FastISel.cpp b/llvm/lib/Target/AArch64/AArch64FastISel.cpp index c3f6859..837a31f 100644 --- a/llvm/lib/Target/AArch64/AArch64FastISel.cpp +++ b/llvm/lib/Target/AArch64/AArch64FastISel.cpp @@ -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)); diff --git a/llvm/test/CodeGen/AArch64/arm64-fast-isel.ll b/llvm/test/CodeGen/AArch64/arm64-fast-isel.ll index a4d08f9..a1d51a5 100644 --- a/llvm/test/CodeGen/AArch64/arm64-fast-isel.ll +++ b/llvm/test/CodeGen/AArch64/arm64-fast-isel.ll @@ -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 +}