<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_ASSIGNED "
title="ASSIGNED --- - [AArch64] Prefer tbz/tbnz before cmp+br in AND expression"
href="http://llvm.org/bugs/show_bug.cgi?id=21600">21600</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[AArch64] Prefer tbz/tbnz before cmp+br in AND expression
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>ASSIGNED
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: AArch64
</td>
</tr>
<tr>
<th>Assignee</th>
<td>mcrosier@codeaurora.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mcrosier@codeaurora.org
</td>
</tr>
<tr>
<th>CC</th>
<td>kevinqindev@gmail.com, llvmbugs@cs.uiuc.edu, t.p.northover@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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
}</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>