In the middle-end, (A & (signbit l>> K)) ==/!= 0 can be folded into
(A l<< K) s>=/s< 0.
When folding 'And' or 'Or' of ICmps, need to extend the iszero() check
of (A & (signbit l>> K)) to its equivalent form of (A l<< K) s>=/s< 0.
Differential D64275
[InstCombine] Generalize InstCombiner::foldAndOrOfICmpsOfAndWithPow2(). huihuiz on Jul 5 2019, 8:52 PM. Authored by
Details
In the middle-end, (A & (signbit l>> K)) ==/!= 0 can be folded into When folding 'And' or 'Or' of ICmps, need to extend the iszero() check
Diff Detail
Event TimelineComment Actions Thanks for working on this!
Comment Actions Thank you for catching this! For (A & K) ==/!= 0, need to restrict one use for 'and' and 'cmp' , there is no need to check K ('shift') for more than one use.
Test cases added, please expand to see (as there is no diff) Comment Actions I think this looks ok, but i'd like to see more test coverage :)
Comment Actions I think we should only create signbit shift instruction when fold is supposed to happen. I update the differential, let me know what you guys think? Comment Actions test case foo1_and_signbit_lshr_without_shifting_signbit_not_pwr2() aim to check that we are not creating additional shift instruction when fold fails. delete the signbit shift instruction might not break the cycle of infinite "create and delete". Comment Actions Hm, not that ugly; this is still correct?
|
could just return match(...);