[llvm] [SLP] Improve cost model for i1 select-as-or/and patterns (PR #188572)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 14 12:58:02 PDT 2026
alexey-bataev wrote:
> Should this be done by the backends themselves? We already implicitly do a lot of transformations there, why is this case different? For instance, in X86 the conversion of UDIV/UREM by power of 2 is handled like so:
>
> ```
> // Vector unsigned division/remainder will be simplified to shifts/masks.
> if ((ISD == ISD::UDIV || ISD == ISD::UREM) &&
> Op2Info.isConstant() && Op2Info.isPowerOf2()) {
> if (ISD == ISD::UDIV)
> return getArithmeticInstrCost(Instruction::LShr, Ty, CostKind,
> Op1Info.getNoProps(), Op2Info.getNoProps());
> // UREM
> return getArithmeticInstrCost(Instruction::And, Ty, CostKind,
> Op1Info.getNoProps(), Op2Info.getNoProps());
> }
> ```
Looks like this transformation is target independent, i.e. performed for all targets. Generally speaking, we can support it in TargetTransformInfo for all targets, or do it only in SLPVectorizer.
https://github.com/llvm/llvm-project/pull/188572
More information about the llvm-commits
mailing list