Skip to content

Fold wide mask reductions with a bitwise op instead of short-circuiting - #343

Merged
Shnatsel merged 1 commit into
linebender:mainfrom
Dr-Emann:push-lyqtwspmvwpt
Aug 23, 2026
Merged

Fold wide mask reductions with a bitwise op instead of short-circuiting#343
Shnatsel merged 1 commit into
linebender:mainfrom
Dr-Emann:push-lyqtwspmvwpt

Conversation

@Dr-Emann

Copy link
Copy Markdown
Contributor

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.

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.
@Shnatsel

Copy link
Copy Markdown
Contributor

Thank you! I'll try to take a look tomorrow.

Is this a fix for #342 or is this unrelated?

@Dr-Emann

Copy link
Copy Markdown
Contributor Author

Unrelated

@Shnatsel Shnatsel 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.

Looks good to me, thank you!

llvm-mca agrees this is beneficial on both AVX2 and NEON.

@Shnatsel
Shnatsel added this pull request to the merge queue Aug 23, 2026
Merged via the queue into linebender:main with commit 47d2355 Aug 23, 2026
22 checks passed
@Dr-Emann
Dr-Emann deleted the push-lyqtwspmvwpt branch August 23, 2026 12:46
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