[llvm] [CostModel] Account for power-2 urem in funnel shift costs (PR #127037)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 13 02:11:32 PST 2025
================
@@ -1910,9 +1906,15 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
BinaryOperator::LShr, RetTy, CostKind, OpInfoY,
{OpInfoZ.Kind, TTI::OP_None});
// Non-constant shift amounts requires a modulo.
- if (!OpInfoZ.isConstant())
- Cost += thisT()->getArithmeticInstrCost(BinaryOperator::URem, RetTy,
- CostKind, OpInfoZ, OpInfoBW);
+ if (!OpInfoZ.isConstant()) {
+ Cost += isPowerOf2_32(RetTy->getScalarSizeInBits())
+ ? thisT()->getArithmeticInstrCost(
+ BinaryOperator::And, RetTy, CostKind, OpInfoZ,
+ {TTI::OK_UniformConstantValue, TTI::OP_None})
+ : thisT()->getArithmeticInstrCost(
+ BinaryOperator::URem, RetTy, CostKind, OpInfoZ,
+ {TTI::OK_UniformConstantValue, TTI::OP_None});
----------------
arsenm wrote:
Also comment this?
https://github.com/llvm/llvm-project/pull/127037
More information about the llvm-commits
mailing list