Bug 19008 - [3.3 regression] [arm] gcc-3.3 -O3 -fPIC produce wrong code via auto inlining
Summary: [3.3 regression] [arm] gcc-3.3 -O3 -fPIC produce wrong code via auto inlining
Status: RESOLVED WORKSFORME
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.3.5
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-15 11:27 UTC by Debian GCC Maintainers
Modified: 2004-12-15 17:17 UTC (History)
1 user (show)

See Also:
Host: arm-linux
Target: arm-linux
Build: arm-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments
preprocessed source (43.08 KB, application/x-gzip)
2004-12-15 11:28 UTC, Debian GCC Maintainers
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2004-12-15 11:27:33 UTC
[forwarded from http://bugs.debian.org/285238]

works with 3.4.3

gcc-3.3 -O3 -fPIC miscompile pari on ARM.
(see 
<http://buildd.debian.org/fetch.php?&pkg=pari&ver=2.1.6-1&arch=arm&stamp=1102707589&file=log&as=raw>)

More precisely the file src/basemath/alglin1.c
is miscompiled with -O3 -fPIC but correctly compiled with -O3 or -O2 -fPIC

This is a regression since gcc-3.3_1:3.3.2-0pre5 built the same
file correctly with -O3 -fPIC.

Apparenlty gcc inline the function use_maximal_pivot() inside
gauss_pivot_ker() and produce wrong code there.

Removing the static qualifier from use_maximal_pivot() (thus forbidding
the compiler to enable) work around the bug.
Comment 1 Debian GCC Maintainers 2004-12-15 11:28:00 UTC
Created attachment 7747 [details]
preprocessed source
Comment 2 Richard Earnshaw 2004-12-15 11:59:39 UTC
use_maximal_pivot() is casting longs to pointers and vice-versa.  I strongly
suspect this code is violating C's aliasing rules.  The inlining of the function
then opens up more chances for the scheduler to move things out of order.

Does the program run correctly if you use -fno-strict-alias?
Comment 3 Debian GCC Maintainers 2004-12-15 15:06:01 UTC
the bug submitter replied:

   I suppose you mean -fno-strict-aliasing, since -fno-strict-alias
   does not exist. In this case that does not fix the problem. This
   code work correctly when build with the same compiler on 10 other
   platforms and AFAIK, casting long* to long does not break strict
   aliasing rules.
Comment 4 Richard Earnshaw 2004-12-15 17:17:22 UTC
Compiling the testcase with '-O3 -fPIC' using stock gcc-3.3.2 and gcc-3.3.5
configured for arm-linux produces identical assembly code for gauss_pivot_ker().
 So I don't see what the bug can be.