Skip to content

Add saturating_add() and saturating_sub() to integers - #352

Open
Shnatsel wants to merge 8 commits into
linebender:mainfrom
Shnatsel:saturating-add
Open

Add saturating_add() and saturating_sub() to integers#352
Shnatsel wants to merge 8 commits into
linebender:mainfrom
Shnatsel:saturating-add

Conversation

@Shnatsel

@Shnatsel Shnatsel commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

NEON has all these ops natively. x86 has u8/i8/u16/i16, but 32-bit and 64-bit element widths need to be emulated; that emulation is the source of most of the complexity.

@Shnatsel

Copy link
Copy Markdown
Contributor Author

LLVM 23 pessimizes srai(a, 31) ^ i32::MAX and turns it into two constant broadcasts and a blend. Workarounds are available but I'm not going to special-case i32 further, the code is complicated enough.

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.

1 participant