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: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected]
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs