[LLVMbugs] [Bug 21600] New: [AArch64] Prefer tbz/tbnz before cmp+br in AND expression
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Nov 18 12:01:38 PST 2014
http://llvm.org/bugs/show_bug.cgi?id=21600
Bug ID: 21600
Summary: [AArch64] Prefer tbz/tbnz before cmp+br in AND
expression
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: ASSIGNED
Severity: normal
Priority: P
Component: Backend: AArch64
Assignee: mcrosier at codeaurora.org
Reporter: mcrosier at codeaurora.org
CC: kevinqindev at gmail.com, llvmbugs at cs.uiuc.edu,
t.p.northover at gmail.com
Classification: Unclassified
Given the following IR,
%cmp0 = icmp slt i64 %a, 0
%cmp1 = icmp eq i32 %b, 1
%and = and i1 %cmp0, %cmp1
br i1 %and, label %if.then, label %if.end
the following assembly is generated:
tbz x0, #63, .LBB0_3
cmp w1, #1
b.ne .LBB0_3
bl t
.LBB0_3: // %if.end
However, if we commute the 'and' operands as such,
%cmp0 = icmp slt i64 %a, 0
%cmp1 = icmp eq i32 %b, 1
%and = and i1 %cmp1, %cmp0
br i1 %and, label %if.then, label %if.end
the following assembly is generated:
cmp w1, #1
b.ne .LBB1_3
tbz x0, #63, .LBB1_3
bl t
.LBB1_3: // %if.end
We should prefer the former code sequence by commuting the 'and' operands.
Complete test cases:
----------------------------------------------------------------------------
; RUN: llc -O1 -march=aarch64 < %s | FileCheck %s
declare void @t()
define void @test1(i64 %a, i32 %b) {
entry:
%cmp0 = icmp slt i64 %a, 0
%cmp1 = icmp eq i32 %b, 1
%and = and i1 %cmp0, %cmp1
br i1 %and, label %if.then, label %if.end
if.then:
call void @t()
br label %if.end
if.end:
ret void
}
define void @test2(i64 %a, i32 %b) {
entry:
%cmp0 = icmp slt i64 %a, 0
%cmp1 = icmp eq i32 %b, 1
%and = and i1 %cmp1, %cmp0
br i1 %and, label %if.then, label %if.end
if.then:
call void @t()
br label %if.end
if.end:
ret void
}
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141118/23a33ddf/attachment.html>
More information about the llvm-bugs
mailing list