On Fri, 17 Nov 2023 at 15:32, Jonathan Wakely <jwak...@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.