Skip to content

fix(simplifier): VectorReduce(Broadcast(Vector)) used wrong semantics of Broadcast(Vector).#9074

Open
mcourteaux wants to merge 3 commits intomainfrom
mcourteaux/simplify-bug
Open

fix(simplifier): VectorReduce(Broadcast(Vector)) used wrong semantics of Broadcast(Vector).#9074
mcourteaux wants to merge 3 commits intomainfrom
mcourteaux/simplify-bug

Conversation

@mcourteaux
Copy link
Contributor

@mcourteaux mcourteaux commented Mar 22, 2026

Checklist

  • Tests added or updated (not required for docs, CI config, or typo fixes)
  • Documentation updated (if public API changed)
  • Python bindings updated (if public API changed)
  • Benchmarks are included here if the change is intended to affect performance.
  • Commits include AI attribution where applicable (see Code of Conduct)

… of Broadcast(Vector).

fix(simplifier): Cherry-picked fix by @abadams in #8629.

Co-authored-by: Andrew Adams <andrew.b.adams@gmail.com>
Co-authored-by: Gemini 3.1 Pro <gemini@aistudio.google.com>
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))) ||
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

@mcourteaux mcourteaux Mar 23, 2026

Choose a reason for hiding this comment

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

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants