[PATCH] D112108: [InstCombine] Fold `(a & ~b) & ~c` to `a & ~(b | c)`

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 20 15:39:11 PDT 2021


rampitec added a comment.

In D112108#3075918 <https://reviews.llvm.org/D112108#3075918>, @rampitec wrote:

> In D112108#3074952 <https://reviews.llvm.org/D112108#3074952>, @spatel wrote:
>
>> This seems like another short-coming of the reassociation pass, but I think it's ok to deal with the minimal case here.
>> For example (if I'm seeing it correctly), this test still won't change:
>>
>>   define i4 @src(i4 %a, i4 %b, i4 %c, i4 %d) {
>>     %notb = xor i4 %b, -1
>>     %notc = xor i4 %c, -1
>>     %and1 = and i4 %a, %notb
>>     %and2 = and i4 %and1, %d
>>     %and3 = and i4 %and2, %notc
>>     ret i4 %and3
>>   }
>>
>> https://alive2.llvm.org/ce/z/_T8ZhP
>
> Yes, this test does not change.

Actually it is transformed too. It does not with `opt -instcombine` but does with `opt -reassociate -instcombine` or just `opt -O3`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112108



More information about the llvm-commits mailing list