[llvm] [SLP] NFC. Use InstructionsState::valid if users just want to know whether VL has same opcode. (PR #120217)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 24 10:17:09 PST 2024


================
@@ -8144,15 +8146,14 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
   }
 
   // Don't handle scalable vectors
-  if (S.getOpcode() == Instruction::ExtractElement &&
-      isa<ScalableVectorType>(
-          cast<ExtractElementInst>(S.getMainOp())->getVectorOperandType())) {
-    LLVM_DEBUG(dbgs() << "SLP: Gathering due to scalable vector type.\n");
-    if (TryToFindDuplicates(S))
-      newTreeEntry(VL, std::nullopt /*not vectorized*/, S, UserTreeIdx,
-                   ReuseShuffleIndices);
-    return;
-  }
+  if (auto *EE = dyn_cast_if_present<ExtractElementInst>(S.getMainOp()))
+    if (isa<ScalableVectorType>(EE->getVectorOperandType())) {
----------------
alexey-bataev wrote:

```suggestion
  if (auto *EE = dyn_cast<ExtractElementInst>(S.getMainOp()); EE && isa<ScalableVectorType>(EE->getVectorOperandType())) {
```

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


More information about the llvm-commits mailing list