[llvm] [SLP] Match poison as instruction with the same opcode (PR #115946)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 19 09:08:34 PST 2024


================
@@ -893,18 +896,27 @@ static bool isCmpSameOrSwapped(const CmpInst *BaseCI, const CmpInst *CI,
 static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
                                        const TargetLibraryInfo &TLI) {
   // Make sure these are all Instructions.
-  if (!all_of(VL, IsaPred<Instruction>))
+  if (!all_of(VL, IsaPred<Instruction, PoisonValue>))
+    return InstructionsState::invalid();
+
+  auto *It = find_if(VL, IsaPred<Instruction>);
+  if (It == VL.end())
+    return InstructionsState::invalid();
+
+  Value *V = *It;
+  unsigned InstCnt = std::count_if(It, VL.end(), IsaPred<Instruction>);
+  if ((VL.size() > 2 && !isa<PHINode>(V) && InstCnt < VL.size() / 2) ||
+      (VL.size() == 2 && InstCnt < 2))
----------------
RKSimon wrote:

Why still allow phi nodes with VL.size() == 2?

https://github.com/llvm/llvm-project/pull/115946


More information about the llvm-commits mailing list