On Fri, 17 Nov 2023 at 15:32, Jonathan Wakely wrote:
>
> Tested x86_64-linux. Pushed to trunk.
>
> GCC generates better code for add_sat 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
Am Fr., 17. Nov. 2023 um 18:31 Uhr schrieb Jonathan Wakely :
>
> On Fri, 17 Nov 2023 at 17:01, Daniel Krügler
> wrote:
> >
[..]
> > > +
> > > +namespace std _GLIBCXX_VISIBILITY(default)
> > > +{
> > > +_GLIBCXX_BEGIN_NAMESPACE_VERSION
> > > +
> > > + /// Add two integers, with saturation in
On Fri, 17 Nov 2023 at 17:01, Daniel Krügler wrote:
>
> Am Fr., 17. Nov. 2023 um 16:32 Uhr schrieb Jonathan Wakely
> :
> >
> > Tested x86_64-linux. Pushed to trunk.
> >
> > GCC generates better code for add_sat if we use:
> >
> > unsigned z = x + y;
> > z |= -(z < x);
> > return z;
> >
> > If
Am Fr., 17. Nov. 2023 um 16:32 Uhr schrieb Jonathan Wakely :
>
> Tested x86_64-linux. Pushed to trunk.
>
> GCC generates better code for add_sat 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
Tested x86_64-linux. Pushed to trunk.
GCC generates better code for add_sat 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.
-- >8 --
This was approved for C++26 last week at the WG21