Re: fix for strict-alias warnings

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: fix for strict-alias warnings
Date: 2003-10-14 21:18:23
Message-ID: 3F8C681F.1010500@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Manfred Spraul wrote:

> Tom Lane wrote:
>
>> Manfred Spraul <manfred(at)colorfullife(dot)com> writes:
>>
>>
>>> After some massaging, I've succeeded in generating bad code using a
>>> slightly modified MemSetAligned macro (parameters -O2
>>> -fstrict-aliasing): gcc pipelined the x*x around the memset.
>>>
>>
>>
>> As I already explained, we do not care about the MemSetAligned case.
>> Is gcc 3.3 smart enough to optimize away the pointer alignment test
>> in the full macro?
>>
> 3.2 optimizes away the pointer alignment test, but then doesn't
> pipeline the "x*x" calculation. It might be due to a known (and now
> fixed) bug in gcc where is lost track of constants, and thus didn't
> succeed in optimizing long calculations.
>
> I don't have gcc 3.3 installed, but IMHO it would be insane to leave
> strict alias analysis enabled - writing to *(int32*)addr violates the
> alias rules, the bad code generated with MemSetAligned proved that.
> Is someone around with 3.3 who could test MemSet?

I have it on my cygwin installation - that's how this whole mess arose
in the first place ;-)

All this is interesting, but the real problem remains that we don't know
what else might be affected because gcc apparently doesn't promise to
tell us. IMO the gcc team made a bad mistake by turning this on by
default for -O2 without reliable accompanying diagnostics.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-10-14 21:23:24 Re: fix for strict-alias warnings
Previous Message Jon Jensen 2003-10-14 21:04:45 Re: postgres --help-config

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2003-10-14 21:23:24 Re: fix for strict-alias warnings
Previous Message Ian Barwick 2003-10-14 21:14:48 psql tab completion bug and possible fix