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: unassignedb...@nondot.org
Reporter: spatel+l...@rotateright.com
CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs