[Codegen][LLVM] Accept splat form in VLA broadcast test#19716
Conversation
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.
There was a problem hiding this comment.
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.
| 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." | ||
| ) |
There was a problem hiding this comment.
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."|
please adopt gemini reviews |
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)
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)
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 oldershufflevector (<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.