aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorJuergen Ributzka <juergen@apple.com>2015-08-06 22:44:15 +0000
committerJuergen Ributzka <juergen@apple.com>2015-08-06 22:44:15 +0000
commitf09c7a3d0f958c82ecc0c27fc42b1c80cc4d70bb (patch)
tree99de08fb3fdce60aa8dcc5e2cd5e9fe0ed4d0eac /llvm/lib
parent96ad05ec5e7555ab9ecf4adf9dcd055feb7b3425 (diff)
downloadllvm-f09c7a3d0f958c82ecc0c27fc42b1c80cc4d70bb.zip
llvm-f09c7a3d0f958c82ecc0c27fc42b1c80cc4d70bb.tar.gz
llvm-f09c7a3d0f958c82ecc0c27fc42b1c80cc4d70bb.tar.bz2
[AArch64][FastISel] Always use AND before checking the branch flag.
When we are not emitting the condition for the branch, because the condition is in another BB or SDAG did the selection for us, then we have to mask the flag in the register with AND. This is required when the condition comes from a truncate, because SDAG only truncates down to a legal size of i32. This fixes rdar://problem/22161062. llvm-svn: 244291
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/AArch64/AArch64FastISel.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64FastISel.cpp b/llvm/lib/Target/AArch64/AArch64FastISel.cpp
index 280e5fc..ab24fe4 100644
--- a/llvm/lib/Target/AArch64/AArch64FastISel.cpp
+++ b/llvm/lib/Target/AArch64/AArch64FastISel.cpp
@@ -2413,7 +2413,11 @@ bool AArch64FastISel::selectBranch(const Instruction *I) {
// Regardless, the compare has been done in the predecessor block,
// and it left a value for us in a virtual register. Ergo, we test
// the one-bit value left in the virtual register.
- emitICmp_ri(MVT::i32, CondReg, CondRegIsKill, 0);
+ //
+ // FIXME: Optimize this with TBZW/TBZNW.
+ unsigned ANDReg = emitAnd_ri(MVT::i32, CondReg, CondRegIsKill, 1);
+ assert(ANDReg && "Unexpected AND instruction emission failure.");
+ emitICmp_ri(MVT::i32, ANDReg, /*IsKill=*/true, 0);
if (FuncInfo.MBB->isLayoutSuccessor(TBB)) {
std::swap(TBB, FBB);