Skip to content

[Codegen][LLVM] Accept splat form in VLA broadcast test#19716

Merged
tqchen merged 2 commits into
apache:mainfrom
tlopex:fix-llvm-vla-broadcast-expectation
Jun 10, 2026
Merged

[Codegen][LLVM] Accept splat form in VLA broadcast test#19716
tqchen merged 2 commits into
apache:mainfrom
tlopex:fix-llvm-vla-broadcast-expectation

Conversation

@tlopex

@tlopex tlopex commented Jun 10, 2026

Copy link
Copy Markdown
Member

Newer LLVM versions (observed with LLVM 20) print a scalable broadcast store as a splat constant, e.g.
store <vscale x 4 x float> splat (float 1.000000e+00), instead of the older shufflevector (<vscale x 4 x float> insertelement (... form. Accept either representation in test_scalable_broadcast so the test passes across LLVM versions while still verifying scalable vector codegen.

Newer LLVM versions (observed with LLVM 20) print a scalable broadcast
store as a splat constant, e.g.
`store <vscale x 4 x float> splat (float 1.000000e+00)`, instead of
the older `shufflevector (<vscale x 4 x float> insertelement (...`
form. Accept either representation in test_scalable_broadcast so the
test passes across LLVM versions while still verifying scalable vector
codegen.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the LLVM VLA codegen test to support newer LLVM versions by allowing the broadcast assertion to match either a shufflevector pattern or a splat constant pattern. The reviewer suggested a performance and readability improvement to use the Python in operator instead of re.findall for literal string matching.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +114 to +118
assert re.findall(
r"shufflevector \(<vscale x 4 x float> insertelement \(<vscale x 4 x float>", llvm
), "No scalable broadcast in generated LLVM."
) or re.findall(r"store <vscale x 4 x float> splat \(float 1\.000000e\+00\)", llvm), (
"No scalable broadcast in generated LLVM."
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since both patterns are literal strings without any dynamic regex patterns (like wildcards or character classes), we can use the Python in operator instead of re.findall. This is more readable, avoids the need to escape parentheses and dots, and is significantly more efficient.

    assert (
        "shufflevector (<vscale x 4 x float> insertelement (<vscale x 4 x float>" in llvm
        or "store <vscale x 4 x float> splat (float 1.000000e+00)" in llvm
    ), "No scalable broadcast in generated LLVM."

@tqchen

tqchen commented Jun 10, 2026

Copy link
Copy Markdown
Member

please adopt gemini reviews

@tqchen tqchen merged commit e214468 into apache:main Jun 10, 2026
8 checks passed
MasterJH5574 pushed a commit to MasterJH5574/tvm that referenced this pull request Jun 15, 2026
Newer LLVM versions (observed with LLVM 20) print a scalable broadcast
store as a splat constant, e.g.
`store <vscale x 4 x float> splat (float 1.000000e+00)`, instead of the
older `shufflevector (<vscale x 4 x float> insertelement (...` form.
Accept either representation in test_scalable_broadcast so the test
passes across LLVM versions while still verifying scalable vector
codegen.

---------

Co-authored-by: tqchen <tianqi.tchen@gmail.com>
(cherry picked from commit e214468)
MasterJH5574 pushed a commit to MasterJH5574/tvm that referenced this pull request Jun 15, 2026
Newer LLVM versions (observed with LLVM 20) print a scalable broadcast
store as a splat constant, e.g.
`store <vscale x 4 x float> splat (float 1.000000e+00)`, instead of the
older `shufflevector (<vscale x 4 x float> insertelement (...` form.
Accept either representation in test_scalable_broadcast so the test
passes across LLVM versions while still verifying scalable vector
codegen.

---------

Co-authored-by: tqchen <tianqi.tchen@gmail.com>
(cherry picked from commit e214468)
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