[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 7 17:06:49 PDT 2020


craig.topper created this revision.
craig.topper added reviewers: spatel, nlopes, aqjune, lebedev.ri.
Herald added subscribers: steven.zhang, hiraditya.
Herald added a project: LLVM.

As noted here https://lists.llvm.org/pipermail/llvm-dev/2016-October/106182.html and by alive2, this transform isn't valid. If X is poison this potentially propagates poison when it shouldn't.

It seems we don't have any tests for this in either InstSimplify or InstCombine. I can add negative tests if we want.

The same transform also exists in DAGCombiner.


https://reviews.llvm.org/D83360

Files:
  llvm/lib/Analysis/InstructionSimplify.cpp


Index: llvm/lib/Analysis/InstructionSimplify.cpp
===================================================================
--- llvm/lib/Analysis/InstructionSimplify.cpp
+++ llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4117,11 +4117,6 @@
   if (TrueVal == FalseVal)
     return TrueVal;
 
-  if (isa<UndefValue>(TrueVal))   // select ?, undef, X -> X
-    return FalseVal;
-  if (isa<UndefValue>(FalseVal))   // select ?, X, undef -> X
-    return TrueVal;
-
   // Deal with partial undef vector constants: select ?, VecC, VecC' --> VecC''
   Constant *TrueC, *FalseC;
   if (TrueVal->getType()->isVectorTy() && match(TrueVal, m_Constant(TrueC)) &&


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83360.276265.patch
Type: text/x-patch
Size: 643 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200708/d9f4e796/attachment.bin>


More information about the llvm-commits mailing list