[PATCH] D118094: [ValueTracking] Checking haveNoCommonBitsSet for (x & y) and ~(x | y)

Chuanqi Xu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 26 19:39:37 PST 2022


ChuanqiXu marked an inline comment as done.
ChuanqiXu added a comment.

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

> In D118094#3268592 <https://reviews.llvm.org/D118094#3268592>, @ChuanqiXu wrote:
>
>> In D118094#3268554 <https://reviews.llvm.org/D118094#3268554>, @lebedev.ri wrote:
>>
>>> Please fix the patch's description.
>>
>> Do you mean the URL in the description? I would delete it when this one get committed.
>>
>>> Should this go into `have no common bits` check instead?
>>
>> I don't understand why this could go into "have no common bits". Since (x & y) and  ~(x | y) could have common bits 0 if x is 1 and y is 0. Did I misunderstand something?
>
> https://alive2.llvm.org/ce/z/CxLDuT

Oh, I made a basic mistake before. It should be haveNoCommonBits. Thanks for reminding me.



================
Comment at: llvm/test/Transforms/InstCombine/pr53357.ll:61
+  ret i32 %7
+}
----------------
RKSimon wrote:
> For examples (the undef version is an alternative you could use occasionally to show the NOT matching still works):
> ```
> define <2 x i32> @src4_vec(<2 x i32> %0, <2 x i32> %1) {
>   %3 = xor <2 x i32> %0, <i32 -1, i32 -1>
>   %4 = xor <2 x i32> %1, <i32 -1, i32 -1>
>   %5 = and <2 x i32> %3, %4
>   %6 = and <2 x i32> %1, %0
>   %7 = add <2 x i32> %5, %6
>   ret <2 x i32> %7
> }
> 
> define <2 x i32> @src4_vec_undef(<2 x i32> %0, <2 x i32> %1) {
>   %3 = xor <2 x i32> %0, <i32 -1, i32 undef>
>   %4 = xor <2 x i32> %1, <i32 -1, i32 -1>
>   %5 = and <2 x i32> %3, %4
>   %6 = and <2 x i32> %1, %0
>   %7 = add <2 x i32> %5, %6
>   ret <2 x i32> %7
> }
> ```
Got it. Thanks!


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

https://reviews.llvm.org/D118094



More information about the llvm-commits mailing list