[PATCH] D72007: [InstCombine] try to pull 'not' of select into compare operands
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 30 09:37:57 PST 2019
spatel created this revision.
spatel added reviewers: lebedev.ri, nikic, xbolva00.
Herald added subscribers: hiraditya, mcrosier.
Herald added a project: LLVM.
not (select Cond, (cmp TPred, ?, ?), FVal --> select Cond, (cmp TPred', ?, ?), (not FVal)
(If both sides of the select are cmps, we can remove an instruction.)
We have a more general 'isFreeToInvert' analysis, but I'm not seeing a way to use that more widely without inducing infinite looping (opposing transforms).
Here, we flip the compare predicate directly, so we should not have any danger by creating extra intermediate 'not' ops.
Alive proofs:
https://rise4fun.com/Alive/jKa
Name: both select values are compares - invert predicates
%tcmp = icmp sle i32 %x, %y
%fcmp = icmp ugt i32 %z, %w
%sel = select i1 %cond, i1 %tcmp, i1 %fcmp
%not = xor i1 %sel, true
=>
%tcmp_not = icmp sgt i32 %x, %y
%fcmp_not = icmp ule i32 %z, %w
%not = select i1 %cond, i1 %tcmp_not, i1 %fcmp_not
Name: false val is compare - invert/not
%fcmp = icmp ugt i32 %z, %w
%sel = select i1 %cond, i1 %tcmp, i1 %fcmp
%not = xor i1 %sel, true
=>
%tcmp_not = xor i1 %tcmp, -1
%fcmp_not = icmp ule i32 %z, %w
%not = select i1 %cond, i1 %tcmp_not, i1 %fcmp_not
https://reviews.llvm.org/D72007
Files:
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/not.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72007.235612.patch
Type: text/x-patch
Size: 5867 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191230/9365943f/attachment-0001.bin>
More information about the llvm-commits
mailing list