[llvm] [LV] Add vplan folds for (X - (X & Y)) -> (X & ~Y) (PR #226466)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 07:31:49 PDT 2026
lukel97 wrote:
> > Not sure what the fix for this is yet
>
> That's strange because the vplan fold mirrors what instcombine would do anyway! You can see this by piping
>
> ```
> define i64 @foo(i64 %a) {
> %b = and i64 %a, 31
> %c = sub i64 %a, %b
> ret i64 %c
> }
> ```
>
> into instcombine with the command `opt -p instcombine -S < foo.ll`
Yeah this is the bit that's making me scratch my head too. I think InstCombine must do some other combine utilising KnownBits before the `(X - (X & Y)) -> (X & ~Y)` combine. I wonder if we can utilise SCEV in VPlan when we know the trip remainder is a constant to mirror this?
https://github.com/llvm/llvm-project/pull/226466
More information about the llvm-commits
mailing list