[llvm] [SandboxVectorizer] Implement topdown/bottomup vectorizers in unison (PR #205249)

Anshil Gandhi via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 21 08:10:59 PDT 2026


================
@@ -285,9 +286,42 @@ Action *BottomUpVec::vectorizeRec(ArrayRef<Value *> Bndl,
       DebugBndlCnt++ >= StopBundle && StopBundle != StopBundleDisabled;
   LLVM_DEBUG(dbgs() << DEBUG_PREFIX << "canVectorize() Bundle:\n";
              VecUtils::dump(Bndl));
+  /// TODO: Enable scheduling for topdown vectorization
   const auto &LegalityRes = StopForDebug ? Legality.getForcedPackForDebugging()
                                          : Legality.canVectorize(Bndl);
   LLVM_DEBUG(dbgs() << DEBUG_PREFIX << "Legality: " << LegalityRes << "\n");
+
+  if (Dir == SchedDirection::TopDown) {
+    // A non-Widen result means we can't extend the vectorized region into
+    // this bundle, so leave its instructions scalar and don't record an
+    // action for it. The scalar users of the already-widened defs get their
+    // values through the unpacks emitted by emitUnpacksForExternalUses().
+    // Note: The DiamondReuse* results are unreachable in the top-down
----------------
gandhi56 wrote:

Currently it fails because the actions aren't ordered correctly. I implemented a topological sort but there is a crash in `tryVectorize`. How about I implement them in a followup PR?

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


More information about the llvm-commits mailing list