@@ -1905,16 +1905,15 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
19051905 Cost += thisT ()->getArithmeticInstrCost (
19061906 BinaryOperator::LShr, RetTy, CostKind, OpInfoY,
19071907 {OpInfoZ.Kind , TTI::OP_None});
1908- // Non-constant shift amounts requires a modulo.
1909- if (!OpInfoZ.isConstant ()) {
1910- Cost += isPowerOf2_32 (RetTy->getScalarSizeInBits ())
1911- ? thisT ()->getArithmeticInstrCost (
1912- BinaryOperator::And, RetTy, CostKind, OpInfoZ,
1913- {TTI::OK_UniformConstantValue, TTI::OP_None})
1914- : thisT ()->getArithmeticInstrCost (
1915- BinaryOperator::URem, RetTy, CostKind, OpInfoZ,
1916- {TTI::OK_UniformConstantValue, TTI::OP_None});
1917- }
1908+ // Non-constant shift amounts requires a modulo. If the typesize is a
1909+ // power-2 then this will be converted to an and, otherwise it will use a
1910+ // urem.
1911+ if (!OpInfoZ.isConstant ())
1912+ Cost += thisT ()->getArithmeticInstrCost (
1913+ isPowerOf2_32 (RetTy->getScalarSizeInBits ()) ? BinaryOperator::And
1914+ : BinaryOperator::URem,
1915+ RetTy, CostKind, OpInfoZ,
1916+ {TTI::OK_UniformConstantValue, TTI::OP_None});
19181917 // For non-rotates (X != Y) we must add shift-by-zero handling costs.
19191918 if (X != Y) {
19201919 Type *CondTy = RetTy->getWithNewBitWidth (1 );
0 commit comments