@@ -9409,10 +9409,7 @@ SDValue RISCVTargetLowering::lowerVectorMaskVecReduction(SDValue Op,
94099409 getDefaultVLOps(VecVT, ContainerVT, DL, DAG, Subtarget);
94109410 }
94119411
9412- unsigned BaseOpc;
94139412 ISD::CondCode CC;
9414- SDValue Zero = DAG.getConstant(0, DL, XLenVT);
9415-
94169413 switch (Op.getOpcode()) {
94179414 default:
94189415 llvm_unreachable("Unhandled reduction");
@@ -9423,15 +9420,13 @@ SDValue RISCVTargetLowering::lowerVectorMaskVecReduction(SDValue Op,
94239420 Vec = DAG.getNode(RISCVISD::VMXOR_VL, DL, ContainerVT, Vec, TrueMask, VL);
94249421 Vec = DAG.getNode(RISCVISD::VCPOP_VL, DL, XLenVT, Vec, Mask, VL);
94259422 CC = ISD::SETEQ;
9426- BaseOpc = ISD::AND;
94279423 break;
94289424 }
94299425 case ISD::VECREDUCE_OR:
94309426 case ISD::VP_REDUCE_OR:
94319427 // vcpop x != 0
94329428 Vec = DAG.getNode(RISCVISD::VCPOP_VL, DL, XLenVT, Vec, Mask, VL);
94339429 CC = ISD::SETNE;
9434- BaseOpc = ISD::OR;
94359430 break;
94369431 case ISD::VECREDUCE_XOR:
94379432 case ISD::VP_REDUCE_XOR: {
@@ -9440,11 +9435,11 @@ SDValue RISCVTargetLowering::lowerVectorMaskVecReduction(SDValue Op,
94409435 Vec = DAG.getNode(RISCVISD::VCPOP_VL, DL, XLenVT, Vec, Mask, VL);
94419436 Vec = DAG.getNode(ISD::AND, DL, XLenVT, Vec, One);
94429437 CC = ISD::SETNE;
9443- BaseOpc = ISD::XOR;
94449438 break;
94459439 }
94469440 }
94479441
9442+ SDValue Zero = DAG.getConstant(0, DL, XLenVT);
94489443 SDValue SetCC = DAG.getSetCC(DL, XLenVT, Vec, Zero, CC);
94499444 SetCC = DAG.getNode(ISD::TRUNCATE, DL, Op.getValueType(), SetCC);
94509445
@@ -9457,6 +9452,7 @@ SDValue RISCVTargetLowering::lowerVectorMaskVecReduction(SDValue Op,
94579452 // 0 for an inactive vector, and so we've already received the neutral value:
94589453 // AND gives us (0 == 0) -> 1 and OR/XOR give us (0 != 0) -> 0. Therefore we
94599454 // can simply include the start value.
9455+ unsigned BaseOpc = ISD::getVecReduceBaseOpcode(Op.getOpcode());
94609456 return DAG.getNode(BaseOpc, DL, Op.getValueType(), SetCC, Op.getOperand(0));
94619457}
94629458
0 commit comments