[PATCH] D83139: [InstCombine] Always try to invert non-canonical predicate of an icmp feeding select
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 3 10:44:52 PDT 2020
lebedev.ri created this revision.
lebedev.ri added reviewers: spatel, jdoerfert, nikic.
lebedev.ri added a project: LLVM.
Herald added a subscriber: hiraditya.
The actual transform i was going after was:
https://rise4fun.com/Alive/Tp9H
Name: zz
Pre: isPowerOf2(C0) && isPowerOf2(C1) && C1 == C0
%t0 = and i8 %x, C0
%r = icmp eq i8 %t0, C1
=>
%t = icmp eq i8 %t0, 0
%r = xor i1 %t, -1
Name: zz
Pre: isPowerOf2(C0)
%t0 = and i8 %x, C0
%r = icmp ne i8 %t0, 0
=>
%t = icmp eq i8 %t0, 0
%r = xor i1 %t, -1
but as it can be seen from the current tests, we already canonicalize most of it,
and we are only missing handling multi-use non-canonical icmp predicates.
If we have both `!=0` and `==0`, even though we can CSE them,
we end up being stuck with them. We should canonicalize to the `==0`.
I believe this is one of the cleanup steps i'll need after `-scalarizer`
if i end up proceeding with my WIP alloca promotion helper pass.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D83139
Files:
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/canonicalize-selects-icmp-condition-bittest.ll
llvm/test/Transforms/InstCombine/select-with-bitwise-ops.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83139.275433.patch
Type: text/x-patch
Size: 25112 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200703/f8366874/attachment-0001.bin>
More information about the llvm-commits
mailing list