On Wed, 26 Aug 2026 at 00:33, Daniel Gustafsson <[email protected]> wrote:
>
> > On 25 Aug 2026, at 14:18, Dagfinn Ilmari MannsÃ¥ker <[email protected]> 
> > wrote:
> >
> > Instead of open-coding this, how about about using pg_neg_s32_overflow?
> >
> > if (pg_neg_s32_overflow(n, &n))
> > n = PG_INT32_MAX;
>
> Yes, that's indeed a good idea.

I do see a few places where we do check for PG_INT32_MIN instead of
using pg_neg_s32_overflow(). The example in [1] does end up with less
code as a result of using pg_neg_s32_overflow(), so it might be worth
removing all applicable examples that use the other method from master
as a follow-up. It'd be worth verifying it doesn't make anything worse
for build systems that don't have __builtin_sub_overflow().

David

[1] https://godbolt.org/z/sfxY847E4


Reply via email to