[PATCH] D136582: [InstCombine] fold sub pattern to and

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 25 05:44:56 PDT 2022


spatel added a comment.

In D136582#3880779 <https://reviews.llvm.org/D136582#3880779>, @bcl5980 wrote:

> In D136582#3880098 <https://reviews.llvm.org/D136582#3880098>, @spatel wrote:
>
>> I don't know if it would have any effect on this patch, but we seem to be missing a constant-shrinking (DemandedBits) opportunity for sub nuw:
>> https://alive2.llvm.org/ce/z/7Lb_Dy
>>
>> We can clear high-bits of the mask constant based on the highest bit set in the subtract constant.
>
> Yeah, I also find the shrinking. And that part has no effect on this patch. Condition 1/3 don't care any high-bits for C2.

This patch still seems too specific. 
Can we generalize this as a mask-of-subtract canonicalization instead - https://alive2.llvm.org/ce/z/qz_KmH ?
If we do that, an existing fold for subtract should reduce the motivating example.


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

https://reviews.llvm.org/D136582



More information about the llvm-commits mailing list