[PATCH] D83163: [DAGCombiner] visitSIGN_EXTEND_INREG should fold sext_vector_inreg(undef) to 0 not undef.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 4 12:54:04 PDT 2020


craig.topper created this revision.
craig.topper added reviewers: RKSimon, spatel, lebedev.ri.
Herald added subscribers: ecnelises, hiraditya.
Herald added a project: LLVM.

We need to ensure that the sign bits of the result all match
so we can't fold to undef.

Similar to PR46585.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83163

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp


Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -10957,8 +10957,9 @@
   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))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83163.275518.patch
Type: text/x-patch
Size: 611 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200704/baba6df6/attachment.bin>


More information about the llvm-commits mailing list