<html>
<head>
<base href="https://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_NEW "
title="NEW --- - x64 backend creates unnecessary setcc instructions"
href="https://llvm.org/bugs/show_bug.cgi?id=31164">31164</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>x64 backend creates unnecessary setcc instructions
</td>
</tr>
<tr>
<th>Product</th>
<td>tools
</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>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>llc
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>erik@arbat.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>An i1 phi is cleverly placed in the processor status word, but then when we
want to branch on it, it is materialized in a setcc-testb-je sequence instead
of just a jne instruction.
Input .ll:
define i64 @foo(i64, i64, i64) {
%4 = icmp eq i64 %0, 0
br i1 %4, label %left, label %right
left:
%l = icmp eq i64 %1, 1
br label %join
right:
%r = icmp eq i64 %1, %2
br label %join
join:
%lr = phi i1 [%l, %left], [%r, %right]
%iszero = icmp eq i1 %lr, 0
br i1 %iszero, label %left2, label %right2
left2:
ret i64 %2
right2:
ret i64 %0
}
Output x64
foo: # @foo
.cfi_startproc
# BB#0:
testq %rdi, %rdi
je .LBB0_1
# BB#2: # %right
cmpq %rdx, %rsi
jmp .LBB0_3
.LBB0_1: # %left
cmpq $1, %rsi
.LBB0_3: # %join
sete %al
testb %al, %al
je .LBB0_4
# BB#5: # %right2
movq %rdi, %rax
retq
.LBB0_4: # %left2
movq %rdx, %rax
retq
See <a href="http://pastebin.com/UinMkFr1">http://pastebin.com/UinMkFr1</a> and <a href="http://pastebin.com/Su1b1mxj">http://pastebin.com/Su1b1mxj</a> for syntax
coloured versions.
The sete and testb instructions are superfluous.</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>