// fold (sub x, x) -> 0
if (N0 == N1) {
- if (ISD::isBuildVectorAllZeros(N0.Val))
- // Zero vectors might be normalized to a particular vector type to ensure
- // they are CSE'd. Return it as it is.
+ if (!AfterLegalize || !MVT::isVector(VT))
+ // For example, zero vectors might be normalized to a particular vector
+ // type to ensure they are CSE'd. Avoid issuing zero vector nodes of
+ // *unexpected* type after legalization.
return N0;
return DAG.getConstant(0, N->getValueType(0));
}