[llvm] r220712 - [FastISel][AArch64] Optimize compare-and-branch for i1 to use 'tbz'.
Juergen Ributzka
juergen at apple.com
Mon Oct 27 12:46:23 PDT 2014
Author: ributzka
Date: Mon Oct 27 14:46:23 2014
New Revision: 220712
URL: http://llvm.org/viewvc/llvm-project?rev=220712&view=rev
Log:
[FastISel][AArch64] Optimize compare-and-branch for i1 to use 'tbz'.
Minor enhancement to use 'tbz' for i1 compare-and-branch to get rid of an 'and'
instruction.
This fixes rdar://problem/18784953.
Modified:
llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp
llvm/trunk/test/CodeGen/AArch64/fast-isel-cbz.ll
Modified: llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp?rev=220712&r1=220711&r2=220712&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64FastISel.cpp Mon Oct 27 14:46:23 2014
@@ -2132,6 +2132,10 @@ bool AArch64FastISel::emitCompareAndBran
LHS = AndLHS;
}
}
+
+ if (VT == MVT::i1)
+ TestBit = 0;
+
IsCmpNE = Predicate == CmpInst::ICMP_NE;
} else if (Predicate == CmpInst::ICMP_SLT) {
if (!isa<Constant>(RHS))
Modified: llvm/trunk/test/CodeGen/AArch64/fast-isel-cbz.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/fast-isel-cbz.ll?rev=220712&r1=220711&r2=220712&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/fast-isel-cbz.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/fast-isel-cbz.ll Mon Oct 27 14:46:23 2014
@@ -2,8 +2,7 @@
define i32 @icmp_eq_i1(i1 %a) {
; CHECK-LABEL: icmp_eq_i1
-; CHECK: and [[REG:w[0-9]+]], w0, #0x1
-; CHECK: cbz [[REG]], {{LBB.+_2}}
+; CHECK: tbz w0, #0, {{LBB.+_2}}
%1 = icmp eq i1 %a, 0
br i1 %1, label %bb1, label %bb2
bb2:
More information about the llvm-commits
mailing list