diff options
| author | Juergen Ributzka <juergen@apple.com> | 2014-10-27 19:16:48 +0000 |
|---|---|---|
| committer | Juergen Ributzka <juergen@apple.com> | 2014-10-27 19:16:48 +0000 |
| commit | eae91040d8cc4afbf4dce66acbfd32ad1e2b8975 (patch) | |
| tree | 19884371260c02fd14d8dfc91aa083de2c1c8a18 /llvm | |
| parent | f920a0aa262ad975beb06e5c3fc9408d7797ffcb (diff) | |
| download | bcm5719-llvm-eae91040d8cc4afbf4dce66acbfd32ad1e2b8975.tar.gz bcm5719-llvm-eae91040d8cc4afbf4dce66acbfd32ad1e2b8975.zip | |
[FastISel][AArch64] Don't fold the 'and' instruction into the 'tbz/tbnz' instruction if it is in a different basic block.
This fixes a bug where the input register was not defined for the 'tbz/tbnz'
instruction. This happened, because we folded the 'and' instruction from a
different basic block.
This fixes rdar://problem/18784013.
llvm-svn: 220704
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Target/AArch64/AArch64FastISel.cpp | 4 | ||||
| -rw-r--r-- | llvm/test/CodeGen/AArch64/fast-isel-tbz.ll | 16 |
2 files changed, 18 insertions, 2 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64FastISel.cpp b/llvm/lib/Target/AArch64/AArch64FastISel.cpp index 1e4499b8d53..d6269284801 100644 --- a/llvm/lib/Target/AArch64/AArch64FastISel.cpp +++ b/llvm/lib/Target/AArch64/AArch64FastISel.cpp @@ -2118,7 +2118,7 @@ bool AArch64FastISel::emitCompareAndBranch(const BranchInst *BI) { return false; if (const auto *AI = dyn_cast<BinaryOperator>(LHS)) - if (AI->getOpcode() == Instruction::And) { + if (AI->getOpcode() == Instruction::And && isValueAvailable(AI)) { const Value *AndLHS = AI->getOperand(0); const Value *AndRHS = AI->getOperand(1); @@ -2165,7 +2165,7 @@ bool AArch64FastISel::emitCompareAndBranch(const BranchInst *BI) { bool Is64Bit = BW == 64; if (TestBit < 32 && TestBit >= 0) Is64Bit = false; - + unsigned Opc = OpcTable[IsBitTest][IsCmpNE][Is64Bit]; const MCInstrDesc &II = TII.get(Opc); diff --git a/llvm/test/CodeGen/AArch64/fast-isel-tbz.ll b/llvm/test/CodeGen/AArch64/fast-isel-tbz.ll index 9fd10cb7a47..d7f46b2cfde 100644 --- a/llvm/test/CodeGen/AArch64/fast-isel-tbz.ll +++ b/llvm/test/CodeGen/AArch64/fast-isel-tbz.ll @@ -121,5 +121,21 @@ bb2: ret i32 0 } +; Test that we don't fold the 'and' instruction into the compare. +define i32 @icmp_eq_and_i32(i32 %a, i1 %c) { +; CHECK-LABEL: icmp_eq_and_i32 +; CHECK: and [[REG:w[0-9]+]], w0, #0x4 +; CHECK-NEXT: cbz [[REG]], {{LBB.+_3}} + %1 = and i32 %a, 4 + br i1 %c, label %bb0, label %bb2 +bb0: + %2 = icmp eq i32 %1, 0 + br i1 %2, label %bb1, label %bb2, !prof !0 +bb1: + ret i32 1 +bb2: + ret i32 0 +} + !0 = metadata !{metadata !"branch_weights", i32 0, i32 2147483647} !1 = metadata !{metadata !"branch_weights", i32 2147483647, i32 0} |

