[llvm-bugs] [Bug 41101] New: [EarlyCSE] recognize swapped form of selects
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Mar 16 13:05:17 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=41101
Bug ID: 41101
Summary: [EarlyCSE] recognize swapped form of selects
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: spatel+llvm at rotateright.com
CC: llvm-bugs at lists.llvm.org
%sel2 is the same value as %sel1:
define void @f(i8 %a, i8 %b, i8 %c, i8 %d, i8* %p1, i8* %p2) {
%cmp1 = icmp ult i8 %a, %b
%sel1 = select i1 %cmp1, i8 %c, i8 %d
store i8 %sel1, i8* %p1
%cmp2 = icmp uge i8 %a, %b
%sel2 = select i1 %cmp2, i8 %d, i8 %c
store i8 %sel2, i8* %p2
ret void
}
This minimal example would be handled by instcombine canonicalizations, but
that can fail when the compares have multiple uses.
We should also match the pattern where the select condition is inverted from
the 1st cmp:
define void @f(i8 %a, i8 %b, i8 %c, i8 %d, i8* %p1, i8* %p2) {
%cmp = icmp ult i8 %a, %b
%sel1 = select i1 %cmp, i8 %c, i8 %d
store i8 %sel1, i8* %p1
%not = xor i1 %cmp, true
%sel2 = select i1 %not, i8 %d, i8 %c
store i8 %sel2, i8* %p2
ret void
}
This should also work with fcmp.
--
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/20190316/003f0800/attachment.html>
More information about the llvm-bugs
mailing list