[DAGCombiner] visitSIGN_EXTEND_INREG should fold sext_vector_inreg(undef) to 0 not...
authorCraig Topper <craig.topper@intel.com>
Sat, 4 Jul 2020 21:35:49 +0000 (14:35 -0700)
committerCraig Topper <craig.topper@intel.com>
Sat, 4 Jul 2020 21:35:49 +0000 (14:35 -0700)
We need to ensure that the sign bits of the result all match
so we can't fold to undef.

Similar to PR46585.

Reviewed By: lebedev.ri

Differential Revision: https://reviews.llvm.org/D83163

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index c0d5337..015d78a 100644 (file)
@@ -10957,8 +10957,9 @@ SDValue DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) {
   unsigned VTBits = VT.getScalarSizeInBits();
   unsigned ExtVTBits = ExtVT.getScalarSizeInBits();
 
+  // sext_vector_inreg(undef) = 0 because the top bit will all be the same.
   if (N0.isUndef())
-    return DAG.getUNDEF(VT);
+    return DAG.getConstant(0, SDLoc(N), VT);
 
   // fold (sext_in_reg c1) -> c1
   if (DAG.isConstantIntBuildVectorOrConstantInt(N0))