[llvm] [RISCV] Refine cost on Min/Max reduction with i1 type (PR #79401)
Shih-Po Hung via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 25 00:50:35 PST 2024
================
@@ -936,10 +936,15 @@ RISCVTTIImpl::getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty,
return BaseT::getMinMaxReductionCost(IID, Ty, FMF, CostKind);
std::pair<InstructionCost, MVT> LT = getTypeLegalizationCost(Ty);
- if (Ty->getElementType()->isIntegerTy(1))
- // vcpop sequences, see vreduction-mask.ll. umax, smin actually only
- // cost 2, but we don't have enough info here so we slightly over cost.
- return (LT.first - 1) + 3;
+ if (Ty->getElementType()->isIntegerTy(1)) {
+ // InstCombine does following transform:
----------------
arcbbb wrote:
Sorry my comment was misleading. I looked at it again and found it at SelectionDAG::getNode
```
case ISD::VECREDUCE_SMIN:
case ISD::VECREDUCE_UMAX:
if (N1.getValueType().getScalarType() == MVT::i1)
return getNode(ISD::VECREDUCE_OR, DL, VT, N1);
break;
case ISD::VECREDUCE_SMAX:
case ISD::VECREDUCE_UMIN:
if (N1.getValueType().getScalarType() == MVT::i1)
return getNode(ISD::VECREDUCE_AND, DL, VT, N1);
```
https://github.com/llvm/llvm-project/pull/79401
More information about the llvm-commits
mailing list