Fold wide mask reductions with a bitwise op instead of short-circuiting - #343
Merged
Conversation
For masks wider than the native register, any/all_true/false now combine the split halves with `or`/`and` and do a single horizontal aggregation, rather than aggregating each half and joining with `||`/`&&`. This trades away early-exit on the first half for one lane-wise vector op plus one scalar extraction, which is the cheaper path in practice.
Contributor
|
Thank you! I'll try to take a look tomorrow. Is this a fix for #342 or is this unrelated? |
Contributor
Author
|
Unrelated |
Shnatsel
approved these changes
Aug 23, 2026
Shnatsel
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me, thank you!
llvm-mca agrees this is beneficial on both AVX2 and NEON.
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.
For masks wider than the native register, any/all_true/false now combine the split halves with
or/andand do a single horizontal aggregation, rather than aggregating each half and joining with||/&&.This trades away early-exit on the first half for one lane-wise vector op plus one scalar extraction, which is the cheaper path in practice.