Skip to content

Optimizations to narrow() - #414

Merged
Shnatsel merged 3 commits into
linebender:mainfrom
Shnatsel:avx512-narrowing
Oct 18, 2026
Merged

Shnatsel merged 3 commits into
linebender:mainfrom
Shnatsel:avx512-narrowing

Conversation

@Shnatsel

Copy link
Copy Markdown
Contributor

AVX-512 dedicated instructions for narrowing integers are actually slower than simply reusing the AVX2 approach. Lower latency but higher throughput, and SIMD cares mostly about throughput.

This fixes a large performance drop when enabling AVX-512 in my port of jpeg-encoder to Fearless SIMD.

Also optimizes the relaxed paths - they can be cheaper than either wrapping or saturation if the input is known to fit into the narrower type.

@LaurenzV LaurenzV left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Rubberstamping. 🙂

@Shnatsel

Copy link
Copy Markdown
Contributor Author

I appreciate the quick turnaround and also you being upfront about it 😅

But yeah, since this doesn't introduce any new APIs and the tests should catch any regressions, there's not much here to review

@Shnatsel
Shnatsel added this pull request to the merge queue Oct 18, 2026
@LaurenzV

Copy link
Copy Markdown
Collaborator

Yeah sorry, I think at this point I'm already too much out-of-context to provide meaningful reviews, and also time-constrained. But unlikely anyone else from Linebender will review, and I don't want to prevent you from landing improvements!

Merged via the queue into linebender:main with commit 95e1d97 Oct 18, 2026
23 checks passed
@Shnatsel
Shnatsel deleted the avx512-narrowing branch October 18, 2026 19:53
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