public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/54290] New: gcc 4.4/4.5/4.6 produces wrong code on sparc with -O2
@ 2012-08-16 19:49 eriksnga at gmail dot com
2012-08-16 19:51 ` [Bug target/54290] " eriksnga at gmail dot com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: eriksnga at gmail dot com @ 2012-08-16 19:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54290
Bug #: 54290
Summary: gcc 4.4/4.5/4.6 produces wrong code on sparc with -O2
Classification: Unclassified
Product: gcc
Version: 4.6.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: eriksnga@gmail.com
Created attachment 28031
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28031
Output from gcc -v
Test system: SunOS 5.10 sun4u sparc SUNW,SPARC-Enterprise Solaris
GCC Config: output from gcc -v is attached for version 4.6.3
########################################################################
# Test case:
# cat ./testcase.c
#define CHECK 1234567890
double vd[2] = {1., 0.};
int vi[2] = {CHECK, 0};
double *pd = vd;
int *pi = vi;
void init (int *n, int *dummy) __attribute__ ((noinline));
void init (int *n, int *dummy)
{
if(0 == n) dummy[0] = 0;
}
int main ()
{
int dummy[1532];
int i = -1, n = 1, s = 0;
init (&n, dummy);
while (i < n) {
if (i == 0) {
if (pd[i] > 0) {
if (pi[i] > 0) {
s += pi[i];
#ifdef VERIFY
return (pi[i] == CHECK? 2 : 3);
#endif
}
}
pd[i] = pi[i];
}
++i;
}
return (s == CHECK? 0 : 1);
}
#
# gcc-4.6.3 -O2 ./testcase.c
# ./a.out; echo $?
1
#
O1 returns expected result (exit code 0).
Problem is reproducible with gcc/g++, 32/64bit ABI with same test case
or slight variations thereof.
Problem is not reproducible on x86_64/Linux.
########################################################################
# Results from other GCC versions:
GCC version 4.3.2: returns 0, ie. correct result
GCC version 4.4.3: returns 1, ie. wrong result
GCC version 4.5.2: returns 1, ie. wrong result
GCC version 4.6.1: returns 1, ie. wrong result
GCC version 4.6.3: returns 1, ie. wrong result
GCC version 4.7.1: returns 0, ie. correct result
On x86_64/Linux, all versions return 0.
########################################################################
# Details:
The code produced by gcc-4.6.3 misses a load (resp. contains erroneous
instructions) resulting in the use of the address of a temp in place of
the value stored at that address.
[..]
fbule,pt %fcc0, .LL10
ld [%o7], %f8 ! %f8 <- pi[i]
sethi %hi(-6144), %i5 ! compute address for temp
or %i5, 4, %i5
add %i5, %fp, %i5
st %f8, [%i5] ! copy from %f8 ...
ld [%i5], %i5 ! ... to %i5 via temp
add %g4, %i5, %o5 ! %o5 <- s+pi[i]
sethi %hi(-6144), %i5 ! recompute address of temp ...
or %i5, 4, %i5 ! ... which is unnecessary; but when doing so
add %i5, %fp, %i5 ! ... value needs to be reloaded as well:
! !
! ld [%i5], %i5 ! missing instruction
! !
cmp %i5, 0 ! supposedly (pi[i] <=> 0), except %i5 contains
! ! address of temp instead of its value
movg %icc, %o5, %g4 ! pi[i] > 0 : s <- s+pi[i]
.LL10:
fitod %f8, %f8
[..]
As an apparent pre-requisite, the offset for the temp needs to be too
large to fit into an immediate constant. Any array size greater equal to
1022(m32) resp. 1532(m64) for "dummy" in the test case seems to fit the bill.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/54290] gcc 4.4/4.5/4.6 produces wrong code on sparc with -O2
2012-08-16 19:49 [Bug target/54290] New: gcc 4.4/4.5/4.6 produces wrong code on sparc with -O2 eriksnga at gmail dot com
@ 2012-08-16 19:51 ` eriksnga at gmail dot com
2012-08-28 23:24 ` [Bug target/54290] [4.6 regression] wrong code at -O2 with large offset ebotcazou at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: eriksnga at gmail dot com @ 2012-08-16 19:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54290
--- Comment #1 from Erik Volk <eriksnga at gmail dot com> 2012-08-16 19:51:23 UTC ---
Created attachment 28032
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28032
preprocessed test case
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/54290] [4.6 regression] wrong code at -O2 with large offset
2012-08-16 19:49 [Bug target/54290] New: gcc 4.4/4.5/4.6 produces wrong code on sparc with -O2 eriksnga at gmail dot com
2012-08-16 19:51 ` [Bug target/54290] " eriksnga at gmail dot com
@ 2012-08-28 23:24 ` ebotcazou at gcc dot gnu.org
2012-08-28 23:27 ` ebotcazou at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-08-28 23:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54290
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target| |sparc*-*-*
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-08-28
CC| |ebotcazou at gcc dot
| |gnu.org
Known to work| |4.7.2
Summary|gcc 4.4/4.5/4.6 produces |[4.6 regression] wrong code
|wrong code on sparc with |at -O2 with large offset
|-O2 |
Ever Confirmed|0 |1
Known to fail| |4.5.4
--- Comment #2 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-08-28 23:23:57 UTC ---
Confirmed (with 4.5.4 at least).
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/54290] [4.6 regression] wrong code at -O2 with large offset
2012-08-16 19:49 [Bug target/54290] New: gcc 4.4/4.5/4.6 produces wrong code on sparc with -O2 eriksnga at gmail dot com
2012-08-16 19:51 ` [Bug target/54290] " eriksnga at gmail dot com
2012-08-28 23:24 ` [Bug target/54290] [4.6 regression] wrong code at -O2 with large offset ebotcazou at gcc dot gnu.org
@ 2012-08-28 23:27 ` ebotcazou at gcc dot gnu.org
2012-09-02 14:19 ` ebotcazou at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-08-28 23:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54290
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
CC|ebotcazou at gcc dot |
|gnu.org |
AssignedTo|unassigned at gcc dot |ebotcazou at gcc dot
|gnu.org |gnu.org
--- Comment #3 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-08-28 23:26:59 UTC ---
Investigating.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/54290] [4.6 regression] wrong code at -O2 with large offset
2012-08-16 19:49 [Bug target/54290] New: gcc 4.4/4.5/4.6 produces wrong code on sparc with -O2 eriksnga at gmail dot com
` (2 preceding siblings ...)
2012-08-28 23:27 ` ebotcazou at gcc dot gnu.org
@ 2012-09-02 14:19 ` ebotcazou at gcc dot gnu.org
2012-09-19 15:38 ` ebotcazou at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-09-02 14:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54290
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
URL| |http://gcc.gnu.org/ml/gcc-p
| |atches/2012-09/msg00037.htm
| |l
Target Milestone|--- |4.6.4
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/54290] [4.6 regression] wrong code at -O2 with large offset
2012-08-16 19:49 [Bug target/54290] New: gcc 4.4/4.5/4.6 produces wrong code on sparc with -O2 eriksnga at gmail dot com
` (3 preceding siblings ...)
2012-09-02 14:19 ` ebotcazou at gcc dot gnu.org
@ 2012-09-19 15:38 ` ebotcazou at gcc dot gnu.org
2012-09-19 15:41 ` ebotcazou at gcc dot gnu.org
2012-09-21 11:07 ` ebotcazou at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-09-19 15:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54290
--- Comment #4 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-09-19 15:38:20 UTC ---
Author: ebotcazou
Date: Wed Sep 19 15:38:16 2012
New Revision: 191484
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=191484
Log:
PR rtl-optimization/54290
* reload1.c (choose_reload_regs): Also take into account secondary MEMs
to remove address replacements for inherited reloads.
(replaced_subreg): Move around.
Added:
trunk/gcc/testsuite/gcc.c-torture/execute/20120919-1.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/reload1.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/54290] [4.6 regression] wrong code at -O2 with large offset
2012-08-16 19:49 [Bug target/54290] New: gcc 4.4/4.5/4.6 produces wrong code on sparc with -O2 eriksnga at gmail dot com
` (4 preceding siblings ...)
2012-09-19 15:38 ` ebotcazou at gcc dot gnu.org
@ 2012-09-19 15:41 ` ebotcazou at gcc dot gnu.org
2012-09-21 11:07 ` ebotcazou at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-09-19 15:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54290
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|4.6.4 |4.8.0
--- Comment #5 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-09-19 15:41:25 UTC ---
The fix has been installed on the mainline. Given the very rare occurrence of
the problem and the delicate nature of the change, no backports are planned.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/54290] [4.6 regression] wrong code at -O2 with large offset
2012-08-16 19:49 [Bug target/54290] New: gcc 4.4/4.5/4.6 produces wrong code on sparc with -O2 eriksnga at gmail dot com
` (5 preceding siblings ...)
2012-09-19 15:41 ` ebotcazou at gcc dot gnu.org
@ 2012-09-21 11:07 ` ebotcazou at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-09-21 11:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54290
--- Comment #6 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-09-21 11:06:57 UTC ---
Author: ebotcazou
Date: Fri Sep 21 11:06:51 2012
New Revision: 191609
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=191609
Log:
PR rtl-optimization/54290
PR rtl-optimization/54644
* reload1.c (choose_reload_regs): Fix thinko in previous change.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/reload1.c
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-09-21 11:07 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-16 19:49 [Bug target/54290] New: gcc 4.4/4.5/4.6 produces wrong code on sparc with -O2 eriksnga at gmail dot com
2012-08-16 19:51 ` [Bug target/54290] " eriksnga at gmail dot com
2012-08-28 23:24 ` [Bug target/54290] [4.6 regression] wrong code at -O2 with large offset ebotcazou at gcc dot gnu.org
2012-08-28 23:27 ` ebotcazou at gcc dot gnu.org
2012-09-02 14:19 ` ebotcazou at gcc dot gnu.org
2012-09-19 15:38 ` ebotcazou at gcc dot gnu.org
2012-09-19 15:41 ` ebotcazou at gcc dot gnu.org
2012-09-21 11:07 ` ebotcazou at gcc dot gnu.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).