It's not enough for the vector we're inserting into to be undef.
We also need to be inserting into the lowest subvector.
Spotted by inspection while trying to figure out why this doesn't
work for vp.reduce.fadd.
SDValue ScalarV = Reduce.getOperand(2);
EVT ScalarVT = ScalarV.getValueType();
if (ScalarV.getOpcode() == ISD::INSERT_SUBVECTOR &&
- ScalarV.getOperand(0)->isUndef())
+ ScalarV.getOperand(0)->isUndef() &&
+ isNullConstant(ScalarV.getOperand(2)))
ScalarV = ScalarV.getOperand(1);
// Make sure that ScalarV is a splat with VL=1.