Re: powerpc pg_atomic_compare_exchange_u32_impl: error: comparison of integer expressions of different signedness (Re: pgsql: For all ppc compilers, implement compare_exchange and) fetch_add

From: Noah Misch <noah(at)leadboat(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Christoph Berg <myon(at)debian(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: powerpc pg_atomic_compare_exchange_u32_impl: error: comparison of integer expressions of different signedness (Re: pgsql: For all ppc compilers, implement compare_exchange and) fetch_add
Date: 2020-10-12 04:46:40
Message-ID: 20201012044640.GA1793921@rfd.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Sun, Oct 11, 2020 at 01:12:40PM -0400, Tom Lane wrote:
> Noah Misch <noah(at)leadboat(dot)com> writes:
> > The first attachment fixes the matter you've reported. While confirming that,
> > I observed that gcc builds don't even use the 64-bit code in arch-ppc.h.
> > Oops. The second attachment fixes that.
>
> I reviewed these, and tested the first one on a nearby Apple machine.
> (I lack access to 64-bit PPC, so I can't actually test the second.)
> They look fine, and I confirmed by examining asm output that even
> the rather-old-now gcc version that Apple last shipped for PPC does
> the right thing with the conditionals.

Thanks for reviewing and for mentioning that old-gcc behavior. I had a
comment asserting that gcc 7.2.0 didn't deduce constancy from those
conditionals. Checking again now, it was just $SUBJECT preventing constancy
deduction. I made the patch remove that comment.

> > I plan not to back-patch either of these.
>
> Hmm, I'd argue for a back-patch. The issue of modern compilers
> warning about the incorrect code will apply to all supported branches.
> Moreover, even if we don't use these code paths today, who's to say
> that someone won't back-patch a bug fix that requires them? I do not
> think it's unreasonable to expect these functions to work well in
> all branches that have them.

Okay, I've pushed with a back-patch. compare_exchange-ppc-immediate-v1.patch
affects on code generation are limited to regress.o, so it's quite safe to
back-patch. I just didn't think it was standard to back-patch for the purpose
of removing a -Wsign-compare warning. (Every branch is noisy under
-Wsign-compare.)

atomics-ppc64-gcc-v1.patch does change code generation, in the manner
discussed in the big arch-ppc.h comment (starts with "This mimics gcc").
Still, I've accepted the modest risk.

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2020-10-12 06:03:51 pgsql: Adjust cycle detection examples and tests
Previous Message Noah Misch 2020-10-12 04:38:47 pgsql: Choose ppc compare_exchange constant path for more operand value

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2020-10-12 05:29:01 Re: Resetting spilled txn statistics in pg_stat_replication
Previous Message Amit Kapila 2020-10-12 03:31:42 Re: Parallel INSERT (INTO ... SELECT ...)