[PATCH] D44043: [DAGCombine] Remove AND in SETCC if we can prove they are unneeded
Dave Green via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 2 12:53:04 PST 2018
dmgreen created this revision.
dmgreen added reviewers: efriedma, spatel, john.brawn, samparker.
Herald added subscribers: fedor.sergeev, kbarton, javed.absar, nhaehnle, nemanjai, jyknight, arsenm.
This is a possible solution for the remainder of https://reviews.llvm.org/D35875. The idea is that if
we have a SETCC of two ANDs with the same mask, and we can calculate
that the non-mask bits of the operands of the AND are the same, we can
drop the ANDs from the SETCC.
i.e (x&C < y&C) => x<y for any s/u </>/=/etc.
Here is an attempt to prove such a thing at the IR level:
So that seems to be fine. Except that the code in question, the ANDs come
from type legalising a SETCC node, with values that come from anyext loads.
These don't provide upper known bits, even though they are likely to become
Hence all this plumbing to find and return anyext loads, treating them as
zeroext loads during computeKnownBits and adjusting the loads to zeroext
if that is useful for this case.
The left hand side of these tests are not yet checked in. As you can hopefully
see, it helps out quite a bit here. If there are better ways to solve this
problem, I'm all ears.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 65389 bytes
Desc: not available
More information about the llvm-commits