[llvm] [InstCombine] Combine and->cmp->sel->or-disjoint into and->mul (PR #135274)
Jeffrey Byrnes via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 25 08:32:46 PDT 2025
jrbyrnes wrote:
> I thought the conclusion in a previous PR was to avoid introducing mul?
I would say its more of an open concern rather than a conclusion.
My thought was that
```
%T1 = and %X, %BitMask
%T2 = mul %T1, %Factor
```
was the canonical form of
```
%T1 = and %X, %BitMask
%Cmp = icmp eq i32 %T1, 0
%T2 = select i1 %Cmp, i32 0, %C
```
given certain conditions.
In https://github.com/llvm/llvm-project/pull/133139#issuecomment-2773977867 we discussed the case where %BitMask is 1 (should be lowered into trunc). And for the general case there was concern over the `mul` form due to CodeGen concerns. However, I think there is still a valid argument that the `mul` form is canonical.
That said, this PR most certainly produces canonical form as its combining 2 `and`s, 2 `icmp`s and 2 `select`s into 1 `and` and 1 `mul`
https://github.com/llvm/llvm-project/pull/135274
More information about the llvm-commits
mailing list