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

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


  Branch: refs/heads/users/gandhi56/sandbox-vectorizer/topdown-vec
  Home:   https://github.com/llvm/llvm-project
  Commit: 667164ca2582c78ad410063be0e6424d208f3817
      https://github.com/llvm/llvm-project/commit/667164ca2582c78ad410063be0e6424d208f3817
  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: 2e60e68cbcf444d789c594e7ab9355fd2c18c063
      https://github.com/llvm/llvm-project/commit/2e60e68cbcf444d789c594e7ab9355fd2c18c063
  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: dc1e7d4e757344d2861981faeb6c04eff80e08b9
      https://github.com/llvm/llvm-project/commit/dc1e7d4e757344d2861981faeb6c04eff80e08b9
  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: 23042787821b02485be20f9aaf263e33ac8acca7
      https://github.com/llvm/llvm-project/commit/23042787821b02485be20f9aaf263e33ac8acca7
  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: 10d5aaff874983472294a01978962be0d0b51e5d
      https://github.com/llvm/llvm-project/commit/10d5aaff874983472294a01978962be0d0b51e5d
  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: 985ad67b81e0d6bb5320edf473cf192b6522c461
      https://github.com/llvm/llvm-project/commit/985ad67b81e0d6bb5320edf473cf192b6522c461
  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: fae75ca8d466945dec02f6c6806476e5a661b6c4
      https://github.com/llvm/llvm-project/commit/fae75ca8d466945dec02f6c6806476e5a661b6c4
  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: b9c323085eb427c15c6923e7d2b3dc4da3c2b7b7
      https://github.com/llvm/llvm-project/commit/b9c323085eb427c15c6923e7d2b3dc4da3c2b7b7
  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: ceed45dfc2c5bef6f49abc705b591debe2e71c49
      https://github.com/llvm/llvm-project/commit/ceed45dfc2c5bef6f49abc705b591debe2e71c49
  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: dcbe0adc7fccd36b8f5e24a54de4e15b5dfc5cca
      https://github.com/llvm/llvm-project/commit/dcbe0adc7fccd36b8f5e24a54de4e15b5dfc5cca
  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: fde90992cf77a68e9a4392114610d2529f42a89a
      https://github.com/llvm/llvm-project/commit/fde90992cf77a68e9a4392114610d2529f42a89a
  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: 667e28a79c5b375d57a33e86ac6bb003e4def6bf
      https://github.com/llvm/llvm-project/commit/667e28a79c5b375d57a33e86ac6bb003e4def6bf
  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/b205683e2aa6...667e28a79c5b

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