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-15 11:56:41
Message-ID: 002e01c39313$65e0f850$6401a8c0@DUNSLANE
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

gcc 3.3.1/cygwin

MemSetAligned: prints "square is 4.000000"
MemSet: prints "square is 0.000000"

Interestingly, a lot of the comparison and call to memset() still seem to be
optimised away, but the loop from MemSet is left, so the multiplication is
also not optimised away.

here's the assembler for test2/MemSet:

subl $28, %esp
leal 16(%esp), %eax
movl $0, 16(%esp)
leal 24(%esp), %edx
cmpl %edx, %eax
movl $1073741824, 20(%esp)
jae L21
.align 16
L26:
movl $0, (%eax)
addl $4, %eax
cmpl %edx, %eax
jb L26
L21:
fldl 16(%esp)
movl $LC1, (%esp)
fmul %st(0), %st
fstl 16(%esp)
fstpl 4(%esp)
call _printf
addl $28, %esp
ret

cheers

andrew

----- Original Message -----
From: "Manfred Spraul" <manfred(at)colorfullife(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Andrew Dunstan" <andrew(at)dunslane(dot)net>; "Patches (PostgreSQL)"
<pgsql-patches(at)postgresql(dot)org>
Sent: Tuesday, October 14, 2003 5:01 PM
Subject: Re: [PATCHES] fix for strict-alias warnings

> 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?
>
> --
> Manfred
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2003-10-15 13:00:37 Re: postgres --help-config
Previous Message Vatsal 2003-10-15 10:26:51 Nested Transactions/Savepoints

Browse pgsql-patches by date

  From Date Subject
Next Message Neil Conway 2003-10-15 15:01:36 minor HISTORY improvement
Previous Message Peter Eisentraut 2003-10-15 10:00:39 Re: More sl translations