Skip to content

[Tests][AArch64] Make SVE codegen assertions robust across LLVM versions - #19752

Merged
tqchen merged 1 commit into
apache:mainfrom
tlopex:fix-aarch64-sve-codegen-tests
Jun 13, 2026
Merged

tqchen merged 1 commit into
apache:mainfrom
tlopex:fix-aarch64-sve-codegen-tests

Conversation

@tlopex

@tlopex tlopex commented Jun 13, 2026 •

Copy link
Copy Markdown
Member

tests/python/codegen/test_target_codegen_aarch64.py cross-compiles AArch64 SVE kernels and regex-matches the generated assembly for specific instruction forms and counts. Several of those assertions encode the exact code shape produced by the LLVM versions used in CI (15-17). On a TVM built against LLVM 20 the tests fail, even though the emitted IR is correct (+sve target-features and vscale_range(1,16) are present) -- the difference is entirely inside LLVM's loop vectorizer / cost model, not in TVM's codegen.

tests/python/codegen/test_target_codegen_aarch64.py cross-compiles AArch64
SVE kernels and regex-matches the generated assembly for specific
instruction forms and counts. Several of those assertions encode the exact
code shape produced by the LLVM versions used in CI (15-17). On a TVM built
against LLVM 20 the tests fail, even though the emitted IR is correct (+sve
target-features and vscale_range(1,16) are present) -- the difference is
entirely inside LLVM's loop vectorizer / cost model, not in TVM's codegen.

This is the same class of issue as apache#19744 (which gated the +v9a
vscale_range expectation); that fix landed separately, and this change
covers the remaining test_muladd / test_eq / test_neq failures.

LLVM 20 behavior changes observed:
- Floating-point mul-add: LLVM 20 prefers a fixed-width NEON main loop
  (fmla v0.4s, ...) over a scalable SVE loop (mla z0.s, ...) for float /
  float16 fmuladd on generic AArch64 +sve, so the SVE mla/mad count drops
  to 0.
- Equality / inequality compares: LLVM <= 17 interleaves the scalable loop
  by two (2 SVE compares), while LLVM 20 emits a fixed-width NEON main loop
  with a single predicated SVE epilogue (1 SVE compare).

Changes (test-only, no codegen change):
- test_muladd: for LLVM >= 18 on float/float16, also accept the NEON
  ldr/ldp q* + fmla/fmls v*.Ns form in addition to the SVE form (a union,
  so whichever form a given LLVM emits keeps the assertion meaningful). The
  NEON regex requires a vector register (v0.4s), so a scalar tail fmadd s0
  cannot satisfy it.
- test_muladd: group the mad|mla alternation as (?:mad|mla)\t... . Without
  the group, a bare mad could match anywhere in the assembly (e.g. inside a
  scalar fmadd), inflating the count.
- test_eq / test_neq: relax the compare-count assertion from > 1 to > 0,
  since the interleave factor is an LLVM cost-model detail, not a codegen
  guarantee. CI's LLVM 15-17 still produces >= 1 SVE compare.

The assertions still require real AArch64 vector code -- they are not
weakened to vacuous checks, and the strict SVE path is unchanged for the
LLVM versions used in CI.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@tqchen
tqchen merged commit 383c446 into apache:main Jun 13, 2026
9 of 10 checks passed
MasterJH5574 pushed a commit to MasterJH5574/tvm that referenced this pull request Jun 15, 2026
…ons (apache#19752)

`tests/python/codegen/test_target_codegen_aarch64.py` cross-compiles
AArch64 SVE kernels and regex-matches the generated assembly for
specific instruction forms and counts. Several of those assertions
encode the exact code shape produced by the LLVM versions used in CI
(15-17). On a TVM built against LLVM 20 the tests fail, even though the
emitted IR is correct (+sve target-features and vscale_range(1,16) are
present) -- the difference is entirely inside LLVM's loop vectorizer /
cost model, not in TVM's codegen.

(cherry picked from commit 383c446)
MasterJH5574 pushed a commit to MasterJH5574/tvm that referenced this pull request Jun 15, 2026
…ons (apache#19752)

`tests/python/codegen/test_target_codegen_aarch64.py` cross-compiles
AArch64 SVE kernels and regex-matches the generated assembly for
specific instruction forms and counts. Several of those assertions
encode the exact code shape produced by the LLVM versions used in CI
(15-17). On a TVM built against LLVM 20 the tests fail, even though the
emitted IR is correct (+sve target-features and vscale_range(1,16) are
present) -- the difference is entirely inside LLVM's loop vectorizer /
cost model, not in TVM's codegen.

(cherry picked from commit 383c446)
tqchen pushed a commit that referenced this pull request Oct 16, 2026
…ons (#19752)

`tests/python/codegen/test_target_codegen_aarch64.py` cross-compiles
AArch64 SVE kernels and regex-matches the generated assembly for
specific instruction forms and counts. Several of those assertions
encode the exact code shape produced by the LLVM versions used in CI
(15-17). On a TVM built against LLVM 20 the tests fail, even though the
emitted IR is correct (+sve target-features and vscale_range(1,16) are
present) -- the difference is entirely inside LLVM's loop vectorizer /
cost model, not in TVM's codegen.
tqchen pushed a commit that referenced this pull request Oct 18, 2026
…ons (#19752)

`tests/python/codegen/test_target_codegen_aarch64.py` cross-compiles
AArch64 SVE kernels and regex-matches the generated assembly for
specific instruction forms and counts. Several of those assertions
encode the exact code shape produced by the LLVM versions used in CI
(15-17). On a TVM built against LLVM 20 the tests fail, even though the
emitted IR is correct (+sve target-features and vscale_range(1,16) are
present) -- the difference is entirely inside LLVM's loop vectorizer /
cost model, not in TVM's codegen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants