[committed] libstdc++: Define C++26 saturation arithmetic functions (P0543R3)
Jonathan Wakely
jwakely@redhat.com
Fri Nov 17 22:00:44 GMT 2023
On Fri, 17 Nov 2023 at 15:32, Jonathan Wakely <jwakely@redhat.com> wrote:
>
> Tested x86_64-linux. Pushed to trunk.
>
> GCC generates better code for add_sat<unsigned> if we use:
>
> unsigned z = x + y;
> z |= -(z < x);
> return z;
>
> If the compiler can't be improved we should consider using that instead
> of __builtin_add_overflow.
I reported PR 112600 for the missed optimization. I added an optimized
sub_sat<unsigned> there as well.
More information about the Libstdc++
mailing list