public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/17394] New: Implicit SSE/SSE2 FP code reordering in Placement Independent Code error (SSE/optimisation/PIC)
@ 2004-09-10 12:30 ivan at vmfacility dot fr
2004-09-10 12:42 ` [Bug c/17394] " ivan at vmfacility dot fr
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: ivan at vmfacility dot fr @ 2004-09-10 12:30 UTC (permalink / raw)
To: gcc-bugs
Here is a simple code :
<testcase>
#include <stdio.h>
float foo;
int main()
{
unsigned int y;
*((unsigned int *)&foo)=0x40555555;
y=(int)foo;
printf("%g %d\n",foo,y);
}
</testcase>
Note : Direct FP manipulation is required by my application as it needs to
perform conversion from a different FP encoding.
Straight compiling (gcc foo.c -o foo) gives the expected result :
"3.3333 3"
However, compiling with the following flags give various results :
"gcc -O3 -march=pentium4 -fPIC foo.c foo"
gives :
"0 0"
Using gcc 3.3.4 with the same flags give :
"3.3333 0"
Examination of the generated assembly indicate various cases :
Starting with 3.4.1 (comments are my own)
... prolog ...
movss (%ecx), %xmm0 Put *%ecx in MMX Reg 0
movl $1079334229, (%ecx) Put constant in *%ecx - UGH ! Backwards
subl $16, %esp
movss %xmm0, -8(%ebp) Save MMX Reg 0 in %ebp[-8]
cvttss2si %xmm0, %edx Convert Single Prec to Signed Int to %edx
movl %eax, (%esp)
flds -8(%ebp)
movl %edx, 12(%esp)
fstpl 4(%esp)
call printf@PLT
... epilog ...
and now with gcc 3.3.4 :
... prolog ...
cvttss2si (%ecx), %eax Convert Single Prec float @%ecx to %eax
movl $1079334229, (%ecx) Put constant value@%ecx - Backwards !
movl %eax, 12(%esp)
flds (%ecx)
movl %edx, (%esp)
fstpl 4(%esp)
call printf@PLT
... epilog ...
Notes
- No problem shows if -fPIC is not specified
- Tried -mfpmath=387 but didn't help
- -msse or -msse2 are also sufficient to trigger the problem
- with -march=pentium2 and no -msseX, the problem goes away
- Problem only shows at -O2 or better
I tried with
- gcc 3.3.4 from debian
- gcc 3.4.1 from debian
- gcc 3.4.1 from Mandrake
(haven't tried stock gcc - but I suspect I might be getting identical results
as I am getting similar results from different vendors).
Thanks,
--Ivan
--
Summary: Implicit SSE/SSE2 FP code reordering in Placement
Independent Code error (SSE/optimisation/PIC)
Product: gcc
Version: 3.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ivan at vmfacility dot fr
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-linux-gnu
GCC host triplet: i686-linux-gnu
GCC target triplet: i686-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17394
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/17394] Implicit SSE/SSE2 FP code reordering in Placement Independent Code error (SSE/optimisation/PIC)
2004-09-10 12:30 [Bug c/17394] New: Implicit SSE/SSE2 FP code reordering in Placement Independent Code error (SSE/optimisation/PIC) ivan at vmfacility dot fr
@ 2004-09-10 12:42 ` ivan at vmfacility dot fr
2004-09-10 15:34 ` pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ivan at vmfacility dot fr @ 2004-09-10 12:42 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From ivan at vmfacility dot fr 2004-09-10 12:42 -------
Ah.. Another thing :
If the 'float' is initialised with a float constant directly
(i.e. "foo=3.3333", instead of filling in directly the IEEE hex representation
of the float through casting and indirections), no problem occurs, which could
mean (writing as I am thinking) a problem exists in the machine description
for SSE capable machines, leading the various insn shufflings to loose the
track of the variable state (forgetting that (int)foo is dependent on foo -
and this possibly happens because 'foo' is never an lvalue - although *&foo is)
--Ivan
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17394
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/17394] Implicit SSE/SSE2 FP code reordering in Placement Independent Code error (SSE/optimisation/PIC)
2004-09-10 12:30 [Bug c/17394] New: Implicit SSE/SSE2 FP code reordering in Placement Independent Code error (SSE/optimisation/PIC) ivan at vmfacility dot fr
2004-09-10 12:42 ` [Bug c/17394] " ivan at vmfacility dot fr
@ 2004-09-10 15:34 ` pinskia at gcc dot gnu dot org
2004-09-10 15:50 ` ivan at vmfacility dot fr
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-10 15:34 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-09-10 15:34 -------
You are violating C aliasing rules: *(unsigned int *)&foo.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17394
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/17394] Implicit SSE/SSE2 FP code reordering in Placement Independent Code error (SSE/optimisation/PIC)
2004-09-10 12:30 [Bug c/17394] New: Implicit SSE/SSE2 FP code reordering in Placement Independent Code error (SSE/optimisation/PIC) ivan at vmfacility dot fr
2004-09-10 12:42 ` [Bug c/17394] " ivan at vmfacility dot fr
2004-09-10 15:34 ` pinskia at gcc dot gnu dot org
@ 2004-09-10 15:50 ` ivan at vmfacility dot fr
2004-09-10 15:52 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ivan at vmfacility dot fr @ 2004-09-10 15:50 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From ivan at vmfacility dot fr 2004-09-10 15:50 -------
Ok..
Getting better results (at least consistent resuls) with a union.. (not sure
it'll fix my original problem though)..
It's still a bit annoying that if this is not a valid C construct (or an
undefined C constuct) that
- No warning or error is given at compile time
- Result is inconsistent
- gcc is producing senseless code (2 instructions in a row writing over the
same memory location and/or register)
Thanks anyway for looking into it :)
--Ivan
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17394
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/17394] Implicit SSE/SSE2 FP code reordering in Placement Independent Code error (SSE/optimisation/PIC)
2004-09-10 12:30 [Bug c/17394] New: Implicit SSE/SSE2 FP code reordering in Placement Independent Code error (SSE/optimisation/PIC) ivan at vmfacility dot fr
` (2 preceding siblings ...)
2004-09-10 15:50 ` ivan at vmfacility dot fr
@ 2004-09-10 15:52 ` pinskia at gcc dot gnu dot org
2004-09-10 17:02 ` ivan at vmfacility dot fr
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-10 15:52 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-09-10 15:52 -------
We do warn with -Wall (which turns on -Wstrict-aliasing).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17394
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/17394] Implicit SSE/SSE2 FP code reordering in Placement Independent Code error (SSE/optimisation/PIC)
2004-09-10 12:30 [Bug c/17394] New: Implicit SSE/SSE2 FP code reordering in Placement Independent Code error (SSE/optimisation/PIC) ivan at vmfacility dot fr
` (3 preceding siblings ...)
2004-09-10 15:52 ` pinskia at gcc dot gnu dot org
@ 2004-09-10 17:02 ` ivan at vmfacility dot fr
2005-06-05 8:55 ` pinskia at gcc dot gnu dot org
2005-06-05 8:55 ` pinskia at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: ivan at vmfacility dot fr @ 2004-09-10 17:02 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From ivan at vmfacility dot fr 2004-09-10 17:02 -------
Subject: RE: Implicit SSE/SSE2 FP code reordering in Placement Independent Code error (SSE/optimisation/PIC)
Thanks for the pointers, and sorry for the extra work.
I still have (what I believe) to be an SSE/SSE2 issue somewhere in my
program (which is raising SIGFPE while all FP traps are blocked), but I want
to get a testcase up and ready (unless I find all this to be an issue in the
code per-se) before I go at posting an eventual bug report.
Again, thank you for your time.
--Ivan
> -----Original Message-----
> From: pinskia at gcc dot gnu dot org
> [mailto:gcc-bugzilla@gcc.gnu.org]
> Sent: Friday, September 10, 2004 5:53 PM
> To: ivan@vmfacility.fr
> Subject: [Bug c/17394] Implicit SSE/SSE2 FP code reordering
> in Placement Independent Code error (SSE/optimisation/PIC)
>
>
>
> ------- Additional Comments From pinskia at gcc dot gnu dot
> org 2004-09-10 15:52 -------
> We do warn with -Wall (which turns on -Wstrict-aliasing).
>
> --
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17394
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17394
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/17394] Implicit SSE/SSE2 FP code reordering in Placement Independent Code error (SSE/optimisation/PIC)
2004-09-10 12:30 [Bug c/17394] New: Implicit SSE/SSE2 FP code reordering in Placement Independent Code error (SSE/optimisation/PIC) ivan at vmfacility dot fr
` (5 preceding siblings ...)
2005-06-05 8:55 ` pinskia at gcc dot gnu dot org
@ 2005-06-05 8:55 ` pinskia at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-05 8:55 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-06-05 08:55 -------
Mark as a dup of bug 21920
*** This bug has been marked as a duplicate of 21920 ***
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17394
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/17394] Implicit SSE/SSE2 FP code reordering in Placement Independent Code error (SSE/optimisation/PIC)
2004-09-10 12:30 [Bug c/17394] New: Implicit SSE/SSE2 FP code reordering in Placement Independent Code error (SSE/optimisation/PIC) ivan at vmfacility dot fr
` (4 preceding siblings ...)
2004-09-10 17:02 ` ivan at vmfacility dot fr
@ 2005-06-05 8:55 ` pinskia at gcc dot gnu dot org
2005-06-05 8:55 ` pinskia at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-05 8:55 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-06-05 08:55 -------
Reopening to ...
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17394
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-06-05 8:55 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-10 12:30 [Bug c/17394] New: Implicit SSE/SSE2 FP code reordering in Placement Independent Code error (SSE/optimisation/PIC) ivan at vmfacility dot fr
2004-09-10 12:42 ` [Bug c/17394] " ivan at vmfacility dot fr
2004-09-10 15:34 ` pinskia at gcc dot gnu dot org
2004-09-10 15:50 ` ivan at vmfacility dot fr
2004-09-10 15:52 ` pinskia at gcc dot gnu dot org
2004-09-10 17:02 ` ivan at vmfacility dot fr
2005-06-05 8:55 ` pinskia at gcc dot gnu dot org
2005-06-05 8:55 ` pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).