[llvm-bugs] [Bug 43088] New: LLVM is unable to combine multiple equivalent UCOMISDrr instructions
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Aug 22 06:49:26 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43088
Bug ID: 43088
Summary: LLVM is unable to combine multiple equivalent
UCOMISDrr instructions
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: simonas+llvm.org at kazlauskas.me
CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
llvm-dev at redking.me.uk, spatel+llvm at rotateright.com
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.
--
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/20190822/56cbadda/attachment.html>
More information about the llvm-bugs
mailing list