[PATCH] D144777: [InstCombine] Fold signbit test of a pow2 or zero

Jun Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 26 20:31:13 PST 2023


junaire added a comment.

In D144777#4154057 <https://reviews.llvm.org/D144777#4154057>, @spatel wrote:

> In D144777#4153685 <https://reviews.llvm.org/D144777#4153685>, @junaire wrote:
>
>> Hi @spatel, thanks for your comments, I updated the tests according to your
>> suggestions. However, everything stop folding after I use div instructions to
>> each oprands of and instruction.
>>
>> Can you take a look? Is this because I missed something? Or my fold pattern is wrong.
>
> There shouldn't be any extra instruction between the `sub` (negate) and `and`. You just need one extra binary-op instruction to create "%x", so it stays operand 0 of the `and`. You don't need any extra instructions if you want "%x" to be operand 1.
>
> I think it would be better to add the transform inside of `InstCombinerImpl::foldICmpAndConstant()`.

Thanks for your comments, they are very helpful. I pushed an NFC change about the recommit test in https://github.com/llvm/llvm-project/commit/cf491a165f239abfa7ab9e707f5cbd1861a6cb20 and moved the fold pattern to the place you suggest.

Please take a look :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144777



More information about the llvm-commits mailing list