fix(simplifier): VectorReduce(Broadcast(Vector)) used wrong semantics of Broadcast(Vector).#9074
Open
mcourteaux wants to merge 3 commits intomainfrom
Open
fix(simplifier): VectorReduce(Broadcast(Vector)) used wrong semantics of Broadcast(Vector).#9074mcourteaux wants to merge 3 commits intomainfrom
mcourteaux wants to merge 3 commits intomainfrom
Conversation
abadams
reviewed
Mar 23, 2026
src/Simplify_Exprs.cpp
Outdated
| rewrite(h_min(ramp(x, y, arg_lanes), lanes), x + min(y * (arg_lanes - 1), 0)) || | ||
| rewrite(h_min(broadcast(x, c0), 1), h_min(x, 1)) || | ||
| rewrite(h_min(broadcast(x, c0), lanes), broadcast(h_min(x, lanes / c0), c0), lanes % c0 == 0) || | ||
| (lanes == 1 && rewrite(h_min(ramp(x, y, arg_lanes), lanes), x + min(y * (arg_lanes - 1), 0))) || |
Member
There was a problem hiding this comment.
I think this (and the max one) could be more general:
rewrite(h_min(ramp(x, y, arg_lanes), 1), x + min(y * (arg_lanes - 1), 0)) ||
rewrite(h_min(ramp(x, y, arg_lanes), lanes), ramp(x + min(y * (factor - 1), 0), y * factor, lanes)) ||
Not sure if the more general case would ever come up though. Maybe it's not worth it.
Contributor
Author
There was a problem hiding this comment.
With some assistance of Claude to break it down, I am convinced too that these more general rules are good. I'll add them, along with some tests.
Contributor
Author
There was a problem hiding this comment.
Added them! Code formatting looks a lot better. 🥳
…amps. Co-authored-by: Andrew Adams <andrew.b.adams@gmail.com> Co-authored-by: Gemini 3.1 Pro <gemini@aistudio.google.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Halide/src/IR.h
Lines 267 to 271 in bce61d9
The changes in Add simplification rules for vectorreduce of broadcasts #5372 interpret a broadcast of a vector as an interleave of N times the vector (meaning the lanes are repeated).
Checklist