[PATCH] D64275: [InstCombine] Generalize InstCombiner::foldAndOrOfICmpsOfAndWithPow2().

Huihui Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 10 22:15:54 PDT 2019


huihuiz added a comment.

In D64275#1575312 <https://reviews.llvm.org/D64275#1575312>, @lebedev.ri wrote:

> Thanks for working on this!
>  This is for sure missing some one-use checks (i.e. increases instruction count).
>  Could you please add 5 copies of `@foo1_and_signbit_lshr_without_shifting_signbit`, each one with different instruction having extra use?


Thank you for catching this!
Yes indeed, increases instruction count.

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.
For equivalent form (A l<< K) s<=/s> 0, need to restrict one use for 'shift' and 'cmp'

> It is also a good idea to add a test where both sides of `or`/`and` are in this new form.

Test cases added, please expand to see (as there is no diff)
I believe we should not try to decompose (A l<< K) s<=/s> 0 into (A & (signbit l>> K)) ==/!= 0, as this decomposition introduce additional instruction of signbit shift.
Also, foldLogOpOfMaskedICmps() in InstCombineCompares.cpp will try to fold ((A l<< K1 <https://reviews.llvm.org/K1>) s<=/> 0) &/| ((A l<< K2) s<=/> 0) into a single icmp.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64275/new/

https://reviews.llvm.org/D64275





More information about the llvm-commits mailing list