[VE] Fix breakage after D118981
VE backend code expected all VP SDNode to have a mask parameter. This
is not the case with vp.select|merge after D118981.
diff --git a/llvm/lib/Target/VE/VEISelLowering.cpp b/llvm/lib/Target/VE/VEISelLowering.cpp
index b55ad83..0585bfa 100644
--- a/llvm/lib/Target/VE/VEISelLowering.cpp
+++ b/llvm/lib/Target/VE/VEISelLowering.cpp
@@ -2710,17 +2710,21 @@
if (FromVP) {
// All upstream VP SDNodes always have a mask and avl.
- auto MaskIdx = ISD::getVPMaskIdx(Opcode).getValue();
- auto AVLIdx = ISD::getVPExplicitVectorLengthIdx(Opcode).getValue();
- Mask = Op->getOperand(MaskIdx);
- AVL = Op->getOperand(AVLIdx);
+ auto MaskIdx = ISD::getVPMaskIdx(Opcode);
+ auto AVLIdx = ISD::getVPExplicitVectorLengthIdx(Opcode);
+ if (MaskIdx)
+ Mask = Op->getOperand(*MaskIdx);
+ if (AVLIdx)
+ AVL = Op->getOperand(*AVLIdx);
- } else {
- // Materialize the VL parameter.
- AVL = CDAG.getConstant(OpVecVT.getVectorNumElements(), MVT::i32);
- Mask = CDAG.getConstantMask(Packing, true);
}
+ // Materialize default mask and avl.
+ if (!AVL)
+ AVL = CDAG.getConstant(OpVecVT.getVectorNumElements(), MVT::i32);
+ if (!Mask)
+ Mask = CDAG.getConstantMask(Packing, true);
+
if (isVVPBinaryOp(VVPOpcode)) {
assert(LegalVecVT.isSimple());
return CDAG.getNode(VVPOpcode, LegalVecVT,