[PATCH] D143593: [InstCombine] Don't fold freeze poison when its used in shufflevector

Manuel Brito via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 8 10:18:19 PST 2023


ManuelJBrito created this revision.
ManuelJBrito added reviewers: spatel, lebedev.ri, nikic.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
ManuelJBrito requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

With this patch freeze undef/poison will no longer be folded into a constant if it's used as the second vector in a shufflevector.
Currently it's folded into zeroinitializer (https://godbolt.org/z/a6168aecv)

This is necessary to fix avx cast intrinsics, which are currently being fixed in https://reviews.llvm.org/D143287 to use freeze(poison).

We need to maintain the freeze(poison). to have the correct lowering (https://godbolt.org/z/1ecM8roYh), because these are supposed to be no-op intrinsics.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143593

Files:
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp


Index: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -4014,8 +4014,13 @@
     return BestValue;
   };
 
-  if (match(Op0, m_Undef()))
+  if (match(Op0, m_Undef())) {
+    for (const auto *U : I.users()) {
+      if (match(U, m_Shuffle(m_Value(), m_Specific(&I))))
+        return nullptr;
+    }
     return replaceInstUsesWith(I, getUndefReplacement(I.getType()));
+  }
 
   Constant *C;
   if (match(Op0, m_Constant(C)) && C->containsUndefOrPoisonElement()) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143593.495877.patch
Type: text/x-patch
Size: 666 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230208/bc143fce/attachment.bin>


More information about the llvm-commits mailing list