<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - LLVM is unable to combine multiple equivalent UCOMISDrr instructions"
href="https://bugs.llvm.org/show_bug.cgi?id=43088">43088</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>LLVM is unable to combine multiple equivalent UCOMISDrr instructions
</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>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>simonas+llvm.org@kazlauskas.me
</td>
</tr>
<tr>
<th>CC</th>
<td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
</td>
</tr></table>
<p>
<div>
<pre>Given code like this (keep in mind that this applies to most code examples
where there are multiple `fcmp` instructions with the same arguments but
differing comparison code):
define i8 @test(double, double) unnamed_addr #0 {
start:
%2 = fcmp ole double %0, %1
%3 = fcmp oge double %0, %1
%spec.select1.i = select i1 %3, i8 1, i8 2
%not..i = xor i1 %3, true
%spec.select.i = sext i1 %not..i to i8
%_0.0.i = select i1 %2, i8 %spec.select.i, i8 %spec.select1.i
ret i8 %_0.0.i
}
which returns -1, 0, 1, or 2 depending on whether the comparison between the
two arguments is less-than, equal, greater-than or either-is-nan. On x86 this
information is made available by a single execution of the `UCOMISD`
instruction.
However this IR ends up being built into something like:
bb.0.start:
successors: %bb.1(0x40000000), %bb.2(0x40000000); %bb.1(50.00%),
%bb.2(50.00%)
liveins: $xmm0, $xmm1
%1:fr64 = COPY $xmm1
%0:fr64 = COPY $xmm0
UCOMISDrr %0:fr64, %1:fr64, implicit-def $eflags
%2:gr8 = SETAEr implicit $eflags
%3:gr8 = MOV8ri 2
%4:gr8 = SUB8rr %3:gr8(tied-def 0), %2:gr8, implicit-def dead $eflags
%5:gr8 = DEC8r %2:gr8(tied-def 0), implicit-def dead $eflags
UCOMISDrr %1:fr64, %0:fr64, implicit-def $eflags
JAE_1 %bb.2, implicit $eflags
bb.1.start:
; predecessors: %bb.0
successors: %bb.2(0x80000000); %bb.2(100.00%)
bb.2.start:
; predecessors: %bb.0, %bb.1
%6:gr8 = PHI %4:gr8, %bb.1, %5:gr8, %bb.0
$al = COPY %6:gr8
RET 0, $al
and the duplicate `UCOMISDrr` end up never being removed.</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>