[llvm] [SLP] NFC: make candidate state ownership explicit (PR #229846)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 11 10:18:15 PDT 2026


================
@@ -3725,32 +3437,521 @@ class slpvectorizer::BoUpSLP {
   /// SCEVs with \p Exp.
   Value *emitRuntimeAliasCheck(IRBuilderBase &Builder, SCEVExpander &Exp);
 
-  /// Data to model and emit the runtime alias checks.
-  struct RuntimeAliasCheckInfo {
-    /// The block whose body is guarded by the checks. Exactly one block is
-    /// supported per attempt.
-    BasicBlock *BB = nullptr;
-    /// Pairs of base objects that must be proven disjoint.
-    SmallSetVector<std::pair<const Value *, const Value *>, 4> BasePairs;
-    /// Accessed address range [Low, High) for each involved base object.
-    SmallMapVector<const Value *, std::pair<const SCEV *, const SCEV *>, 4>
-        Bounds;
+#ifdef EXPENSIVE_CHECKS
+  /// Verify ownership of references into the current candidate at phase
+  /// boundaries, without dereferencing observer pointers.
+  void verifyCandidateOwnership() const;
+#endif
+
+  /// Owns the graph and the state discarded before building a new candidate.
+  /// Keep this object in place while its entries exist: TreeEntry::Container
+  /// refers to its graph.
+  /// Analysis caches, search history and reusable block scheduling storage
+  /// remain in BoUpSLP and survive a candidate reset.
+  class CandidateState {
+    friend class BoUpSLP;
+
+    CandidateState() = default;
+    CandidateState(const CandidateState &) = delete;
+    CandidateState &operator=(const CandidateState &) = delete;
+    CandidateState(CandidateState &&) = delete;
+    CandidateState &operator=(CandidateState &&) = delete;
+
+  private:
+    /// Holds all of the tree entries. Declared first so entries are destroyed
+    /// after the candidate state that refers to them.
+    TreeEntry::VecTreeTy VectorizableTree;
+
+    /// Maps a specific scalar to its tree entry(ies).
+    SmallDenseMap<Value *, SmallVector<TreeEntry *>> ScalarToTreeEntries;
+
+    /// List of deleted non-profitable nodes.
+    SmallPtrSet<const TreeEntry *, 8> DeletedNodes;
+
+    /// List of nodes, transformed to gathered, with their conservative
+    /// gather/buildvector cost estimation.
+    SmallDenseMap<const TreeEntry *, InstructionCost> TransformedToGatherNodes;
----------------
alexey-bataev wrote:

Same, I think it should notbelong to this class

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


More information about the llvm-commits mailing list