[llvm] [SelectionDAG][RISCV] Promote VECREDUCE_{FMAX,FMIN,FMAXIMUM,FMINIMUM} (PR #128800)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 25 22:47:04 PST 2025
================
@@ -2913,31 +2913,34 @@ SDValue SelectionDAGLegalize::ExpandPARITY(SDValue Op, const SDLoc &dl) {
}
SDValue SelectionDAGLegalize::PromoteReduction(SDNode *Node) {
- MVT VecVT = Node->getOperand(1).getSimpleValueType();
+ bool IsVPOpcode = ISD::isVPOpcode(Node->getOpcode());
+ MVT VecVT = IsVPOpcode ? Node->getOperand(1).getSimpleValueType()
+ : Node->getOperand(0).getSimpleValueType();
MVT NewVecVT = TLI.getTypeToPromoteTo(Node->getOpcode(), VecVT);
MVT ScalarVT = Node->getSimpleValueType(0);
MVT NewScalarVT = NewVecVT.getVectorElementType();
SDLoc DL(Node);
SmallVector<SDValue, 4> Operands(Node->getNumOperands());
- // promote the initial value.
// FIXME: Support integer.
assert(Node->getOperand(0).getValueType().isFloatingPoint() &&
"Only FP promotion is supported");
- Operands[0] =
- DAG.getNode(ISD::FP_EXTEND, DL, NewScalarVT, Node->getOperand(0));
- for (unsigned j = 1; j != Node->getNumOperands(); ++j)
+ for (unsigned j = 0; j != Node->getNumOperands(); ++j)
if (Node->getOperand(j).getValueType().isVector() &&
- !(ISD::isVPOpcode(Node->getOpcode()) &&
+ !(IsVPOpcode &&
ISD::getVPMaskIdx(Node->getOpcode()) == j)) { // Skip mask operand.
// promote the vector operand.
// FIXME: Support integer.
assert(Node->getOperand(j).getValueType().isFloatingPoint() &&
"Only FP promotion is supported");
Operands[j] =
DAG.getNode(ISD::FP_EXTEND, DL, NewVecVT, Node->getOperand(j));
+ } else if (Node->getOperand(j).getValueType().isFloatingPoint()) {
+ // prmote the initial value.
----------------
lukel97 wrote:
```suggestion
// promote the initial value.
```
https://github.com/llvm/llvm-project/pull/128800
More information about the llvm-commits
mailing list