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

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 19 09:06:45 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();
----------------
alexey-bataev wrote:

It can happen. The check above just checks that all elements are Instructions or PoisonValues, but does not check that there is at least single Instruction in the ArrayRef

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


More information about the llvm-commits mailing list