[PATCH] D123408: [InstCombine] Limit folding of cast into PHI
Zaara Syeda via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 9 13:39:17 PDT 2022
syzaara added a comment.
In D123408#3571242 <https://reviews.llvm.org/D123408#3571242>, @syzaara wrote:
> In D123408#3571038 <https://reviews.llvm.org/D123408#3571038>, @spatel wrote:
>
>> In D123408#3570605 <https://reviews.llvm.org/D123408#3570605>, @syzaara wrote:
>>
>>> @spatel Could you please provide some feedback about this change to InstCombine.
>>
>> In general, making exceptions to transforms will not solve the general problem. I'm not sure if this is enough, but instcombine seems to miss a narrowing transform like this:
>> https://alive2.llvm.org/ce/z/hRy3rE
>>
>> We do already have a variation of that fold, so it should be a small enhancement. I can take a shot at that.
>> A demanded bits solution within instcombine might be better, but I'm not seeing how to make that work in general since we have to create 3 instructions from the pattern.
Oh nevermind, please ignore above comment, I see what you are saying now! That we can add a transformation which can convert:
> %a.0 = phi i32 [ 0, %entry ], [ %phi.cast, %for.body ]
> %conv = zext i8 %0 to i32
> %add = add nuw nsw i32 %a.0, %conv
> %phi.cast = and i32 %add, 255
Back to:
> %a.0 = phi i32 [ 0, %entry ], [ %phi.cast, %for.body ]
> %conv = trunc i32 %a.0 to i8
> %add = add i8 %0, %conv
> %conv2 = zext i8 %add to i32
So we don't need to disable the phi cast optimization, but will still get the i8 add.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123408/new/
https://reviews.llvm.org/D123408
More information about the llvm-commits
mailing list