[PATCH] D136582: [InstCombine] fold sub pattern to and
chenglin.bi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 25 07:24:00 PDT 2022
bcl5980 added a comment.
In D136582#3882251 <https://reviews.llvm.org/D136582#3882251>, @spatel wrote:
> 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.
Thanks for the idea. It is a more clean and simplier way.
I only have a little concern about the subtract's combination after the canonicalization. For example:
https://alive2.llvm.org/ce/z/i5Qk9-
It will break exist `and` combination. Generally I think subtract's combination should be less than `and`.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136582/new/
https://reviews.llvm.org/D136582
More information about the llvm-commits
mailing list