[all-commits] [llvm/llvm-project] 1a4fbe: [SandboxIR] Fix notifyEraseInstr to skip scheduled...

Anshil Gandhi via All-commits all-commits at lists.llvm.org
Thu Jul 30 11:26:09 PDT 2026


  Branch: refs/heads/users/gandhi56/sandbox-vectorizer/topdown-vec
  Home:   https://github.com/llvm/llvm-project
  Commit: 1a4fbe79925e91d4f69f3aade4c251314d7d3f01
      https://github.com/llvm/llvm-project/commit/1a4fbe79925e91d4f69f3aade4c251314d7d3f01
  Author: Anshil Gandhi <gandhi21299 at gmail.com>
  Date:   2026-07-30 (Thu, 30 Jul 2026)

  Changed paths:
    M llvm/unittests/Transforms/Vectorize/SandboxVectorizer/DependencyGraphTest.cpp

  Log Message:
  -----------
  [SandboxIR] Fix notifyEraseInstr to skip scheduled neighbors

Guard both loops with !PredN->scheduled() / !SuccN->scheduled() so
scheduled neighbors are left untouched, and add a unit test that erases
a node with one scheduled and one unscheduled predecessor to cover the
fix.


  Commit: 558bd9f7c30e65f42ca41ae151e703fd5599c26c
      https://github.com/llvm/llvm-project/commit/558bd9f7c30e65f42ca41ae151e703fd5599c26c
  Author: Anshil Gandhi <gandhi21299 at gmail.com>
  Date:   2026-07-30 (Thu, 30 Jul 2026)

  Changed paths:
    M llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
    M llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/VecUtils.h
    M llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
    M llvm/lib/Transforms/Vectorize/SandboxVectorizer/VecUtils.cpp
    M llvm/test/Transforms/SandboxVectorizer/external_uses.ll
    M llvm/test/Transforms/SandboxVectorizer/pack.ll
    A llvm/test/Transforms/SandboxVectorizer/topdown_vec.ll
    M llvm/unittests/Transforms/Vectorize/SandboxVectorizer/VecUtilsTest.cpp

  Log Message:
  -----------
  [SBVec] Add top-down vectorization to the unified Sandbox Vectorizer

Extend the Sandbox Vectorizer's `bottom-up-vec` pass so a single
implementation can vectorize in either direction, and add the top-down
strategy that walks def-use chains forward from a seed.

Direction selection
--------------------
The pass direction is chosen from the Region's auxiliary pass argument:
"bottom-up" (or empty, the default) and "top-down" map onto a
SchedDirection, and any other value is rejected with a fatal usage error.
The vectorizer always runs in the same direction as the scheduler.

Top-down traversal
------------------
Bottom-up starts from a seed slice (e.g. stores to consecutive addresses)
and recurses into operands. Top-down instead starts from a seed of
consecutive loads and recurses into *users*:

- vectorizeRec() registers the current bundle's vector (pre-order) before
  recursing, so instructions are marked vectorized as soon as they are
  claimed. This prevents sibling user bundles from claiming the same
  instruction and guarantees termination.
- VecUtils::getNextUserBundles() drives the walk. For each user of lane 0
  it tries to assemble a matching user for every remaining lane, requiring
  the same opcode, type, parent block, and operand-usage indices, and
  claiming each instruction at most once. Only complete bundles (one user
  per lane) are returned.
- A non-Widen legality result stops the walk down that path: the bundle is
  left scalar and no action is recorded. DiamondReuse results cannot occur
  top-down because already-vectorized users are skipped, so a bundle never
  contains an instruction already in InstrMaps.

Operand and external-use handling
---------------------------------
Because a user bundle is emitted after its operand bundle, emitVectors()
looks up each operand's vector in InstrMaps and creates a pack when the
operand was not vectorized. emitUnpacksForExternalUses() now redirects
only the genuinely external (non-vectorized) uses via replaceUsesWithIf(),
instead of a blanket replaceAllUsesWith() that would corrupt the operands
of user bundles not yet emitted. Scheduling is currently skipped for the
top-down direction (TODO).

Refactoring
-----------
Unify the two strategies to avoid code duplication: introduce a shared
BundleTy alias, move user-bundle collection into VecUtils (with unit
tests), and thread the direction through legality checks and vector
emission.

Co-authored-by: Cursor <cursoragent at cursor.com>


  Commit: defbc2bfed18da44c571e9ebe77ccdf6af36c28d
      https://github.com/llvm/llvm-project/commit/defbc2bfed18da44c571e9ebe77ccdf6af36c28d
  Author: Anshil Gandhi <Anshil.Gandhi at amd.com>
  Date:   2026-07-30 (Thu, 30 Jul 2026)

  Changed paths:
    M llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h
    M llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp

  Log Message:
  -----------
  [SBVec] Refactor BottomUpVec pass for clarity and maintainability

- Corrected comments to clarify the direction of def-use and use-def chains.
- Changed the initialization of the SchedDirection variable to improve clarity.
- Updated documentation in vectorizeRec() to better describe the purpose of UserBndl.
- Removed outdated TODO comment regarding top-down vectorization scheduling.


  Commit: 16dafeff6e698dbedaeceafdca71662a2e151500
      https://github.com/llvm/llvm-project/commit/16dafeff6e698dbedaeceafdca71662a2e151500
  Author: Anshil Gandhi <Anshil.Gandhi at amd.com>
  Date:   2026-07-30 (Thu, 30 Jul 2026)

  Changed paths:
    M llvm/lib/Transforms/Vectorize/SandboxVectorizer/VecUtils.cpp
    M llvm/test/Transforms/SandboxVectorizer/topdown_vec.ll

  Log Message:
  -----------
  [SBVec] Track claimed users across bundles


  Commit: 46264a6f4504d1090717e19bf2a54b2d3341b450
      https://github.com/llvm/llvm-project/commit/46264a6f4504d1090717e19bf2a54b2d3341b450
  Author: Anshil Gandhi <Anshil.Gandhi at amd.com>
  Date:   2026-07-30 (Thu, 30 Jul 2026)

  Changed paths:
    M llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
    M llvm/test/Transforms/SandboxVectorizer/topdown_vec.ll

  Log Message:
  -----------
  3 element tests

- nits


  Commit: 915dca9d80bfda561325074bb97efe72b07185e0
      https://github.com/llvm/llvm-project/commit/915dca9d80bfda561325074bb97efe72b07185e0
  Author: Anshil Gandhi <Anshil.Gandhi at amd.com>
  Date:   2026-07-30 (Thu, 30 Jul 2026)

  Changed paths:
    M llvm/test/Transforms/SandboxVectorizer/topdown_vec.ll

  Log Message:
  -----------
  Add 3-way test to check for consecutive matching


  Commit: 99c71249e1c92a775796dd263fe90596cd34b162
      https://github.com/llvm/llvm-project/commit/99c71249e1c92a775796dd263fe90596cd34b162
  Author: Anshil Gandhi <Anshil.Gandhi at amd.com>
  Date:   2026-07-30 (Thu, 30 Jul 2026)

  Changed paths:
    M llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/VecUtils.h
    M llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.cpp
    M llvm/lib/Transforms/Vectorize/SandboxVectorizer/VecUtils.cpp
    M llvm/test/Transforms/SandboxVectorizer/topdown_vec.ll

  Log Message:
  -----------
  Pass Claimed by ref to getNextUserBundles

A user should not be claimed by multiple successful
bundles. Added a test for this.


  Commit: fec3696cab97a9020722523517686aab7632adf6
      https://github.com/llvm/llvm-project/commit/fec3696cab97a9020722523517686aab7632adf6
  Author: Anshil Gandhi <gandhi21299 at gmail.com>
  Date:   2026-07-30 (Thu, 30 Jul 2026)

  Changed paths:
    M llvm/test/Transforms/SandboxVectorizer/topdown_vec.ll

  Log Message:
  -----------
  Remove stores


  Commit: 6cc9b78bb23895c242d655edfe39bf15060de499
      https://github.com/llvm/llvm-project/commit/6cc9b78bb23895c242d655edfe39bf15060de499
  Author: Anshil Gandhi <gandhi21299 at gmail.com>
  Date:   2026-07-30 (Thu, 30 Jul 2026)

  Changed paths:
    M llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/VecUtils.h
    M llvm/lib/Transforms/Vectorize/SandboxVectorizer/VecUtils.cpp
    M llvm/test/Transforms/SandboxVectorizer/topdown_vec.ll
    M llvm/unittests/Transforms/Vectorize/SandboxVectorizer/VecUtilsTest.cpp

  Log Message:
  -----------
  Refactor getNextUserBundles


  Commit: 94cfa34efabe352af2a05f83f8ecaf8ca5fc9cd1
      https://github.com/llvm/llvm-project/commit/94cfa34efabe352af2a05f83f8ecaf8ca5fc9cd1
  Author: Anshil Gandhi <gandhi21299 at gmail.com>
  Date:   2026-07-30 (Thu, 30 Jul 2026)

  Changed paths:
    M llvm/lib/Transforms/Vectorize/SandboxVectorizer/VecUtils.cpp

  Log Message:
  -----------
  Add a cl::opt to limit the number of users visited


  Commit: 4d86d5a123298d05900367726c283730c84a6491
      https://github.com/llvm/llvm-project/commit/4d86d5a123298d05900367726c283730c84a6491
  Author: Anshil Gandhi <gandhi21299 at gmail.com>
  Date:   2026-07-30 (Thu, 30 Jul 2026)

  Changed paths:
    M llvm/lib/Transforms/Vectorize/SandboxVectorizer/VecUtils.cpp
    M llvm/unittests/Transforms/Vectorize/SandboxVectorizer/VecUtilsTest.cpp

  Log Message:
  -----------
  Refactor VecUtilsTest for readability


  Commit: b205683e2aa6d585b24e5f57fd08e2ccc93590cd
      https://github.com/llvm/llvm-project/commit/b205683e2aa6d585b24e5f57fd08e2ccc93590cd
  Author: Anshil Gandhi <gandhi21299 at gmail.com>
  Date:   2026-07-30 (Thu, 30 Jul 2026)

  Changed paths:
    M llvm/test/Transforms/SandboxVectorizer/external_uses.ll
    M llvm/test/Transforms/SandboxVectorizer/topdown_vec.ll

  Log Message:
  -----------
  Nits, remove topdown vec checks from external_uses.ll


Compare: https://github.com/llvm/llvm-project/compare/7862d524a471...b205683e2aa6

To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list