public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: optimization/3921: wrong output with -02 on sparc-sun-solaris2.6) compiled by GNU C version 3.0. /usr/ccs/bin/as -V -using __asm wrong output with -O2 on sparc-sun-solaris2.6
@ 2002-04-02 3:20 rth
0 siblings, 0 replies; 2+ messages in thread
From: rth @ 2002-04-02 3:20 UTC (permalink / raw)
To: bfkelly, gcc-bugs, gcc-prs, nobody
Synopsis: wrong output with -02 on sparc-sun-solaris2.6) compiled by GNU C version 3.0. /usr/ccs/bin/as -V -using __asm wrong output with -O2 on sparc-sun-solaris2.6
State-Changed-From-To: open->closed
State-Changed-By: rth
State-Changed-When: Tue Apr 2 03:20:03 2002
State-Changed-Why:
The definition of BAR is incorrect. The asm modifies memory
without informing the compiler of this. Correct behaviour is
obtained by either adding a clobber of "memory", or by leaving
most of the actual data movement to gcc. E.g.
static inline void
bar(int a, int b, int c, int *z, int *r)
{
__asm__("addcc %[A0],%[B1],%[R0]\n\t"
"addxcc %[A1],%[B1],%[R1]\n\t"
"addx %[A2],%[B2],%[R2]"
: [R0] "=&r" (z[0]), [R1] "=&r" (z[1]), [R2] "=r" (r[1])
: [A0] "r" (z[0]), [B0] "rI" (a),
[A1] "r" (z[1]), [B1] "rI" (b),
[A2] "r" (c), [B2] "rI" (0)
: "cc");
}
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=3921
^ permalink raw reply [flat|nested] 2+ messages in thread
* optimization/3921: wrong output with -02 on sparc-sun-solaris2.6) compiled by GNU C version 3.0. /usr/ccs/bin/as -V -using __asm wrong output with -O2 on sparc-sun-solaris2.6
@ 2001-08-03 7:16 bfkelly
0 siblings, 0 replies; 2+ messages in thread
From: bfkelly @ 2001-08-03 7:16 UTC (permalink / raw)
To: gcc-gnats
>Number: 3921
>Category: optimization
>Synopsis: wrong output with -02 on sparc-sun-solaris2.6) compiled by GNU C version 3.0. /usr/ccs/bin/as -V -using __asm wrong output with -O2 on sparc-sun-solaris2.6
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Fri Aug 03 07:16:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: bfkelly@nsa.gov
>Release: gcc-3.0
>Organization:
>Environment:
Reading specs from /projects/r51/gnu/gcc-core-3.0/SunOS/lib/gcc-lib/sparc-sun-so
laris2.6/3.0/specs
Configured with: ../gcc-core-3.0/configure --prefix=/projects/r51/gnu/gcc-core-3
.0/SunOS
Thread model: posix
gcc version 3.0
/projects/r51/gnu/gcc-core-3.0/SunOS/lib/gcc-lib/sparc-sun-solaris2.6/3.0/cpp0
-lang-c -v -iprefix /projects/r51/gnu/bin-SunOS/../lib/gcc-lib/sparc-sun-solaris
2.6/3.0/ -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=0 -Dsparc -Dsun -
Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -
D__sparc -D__sun -D__unix -Asystem=unix -Asystem=svr4 -D__OPTIMIZE__ -D__STDC_HO
STED__=1 -D__GCC_NEW_VARARGS__ -Acpu=sparc -Amachine=sparc foo.c foo.i
GNU CPP version 3.0 (cpplib) (sparc)
ignoring nonexistent directory "/projects/r51/gnu/lib/gcc-lib/sparc-sun-solaris2
.6/3.0/include"
ignoring nonexistent directory "/projects/r51/gnu/lib/gcc-lib/sparc-sun-solaris2
.6/3.0/../../../../sparc-sun-solaris2.6/include"
ignoring nonexistent directory "/projects/r51/gnu/gcc-core-3.0/SunOS/sparc-sun-s
olaris2.6/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/projects/r51/gnu/gcc-core-3.0/SunOS/lib/gcc-lib/sparc-sun-solaris2.6/3.0/inclu
de
/usr/include
End of search list.
/projects/r51/gnu/gcc-core-3.0/SunOS/lib/gcc-lib/sparc-sun-solaris2.6/3.0/cc1 -
fpreprocessed foo.i -quiet -dumpbase foo.c -O2 -version -o foo.s
GNU CPP version 3.0 (cpplib) (sparc)
GNU C version 3.0 (sparc-sun-solaris2.6)
compiled by GNU C version 3.0.
/usr/ccs/bin/as -V -Qy -s -o foo.o foo.s
/usr/ccs/bin/as: WorkShop Compilers 4.X dev 18 Sep 1996
/projects/r51/gnu/gcc-core-3.0/SunOS/lib/gcc-lib/sparc-sun-solaris2.6/3.0/colle
ct2 -V -Y P,/usr/ccs/lib:/usr/lib -Qy -o foo /projects/r51/gnu/gcc-core-3.0/SunO
S/lib/gcc-lib/sparc-sun-solaris2.6/3.0/crt1.o /projects/r51/gnu/gcc-core-3.0/Sun
OS/lib/gcc-lib/sparc-sun-solaris2.6/3.0/crti.o /usr/ccs/lib/values-Xa.o /project
s/r51/gnu/gcc-core-3.0/SunOS/lib/gcc-lib/sparc-sun-solaris2.6/3.0/crtbegin.o -L/
projects/r51/gnu/gcc-core-3.0/SunOS/lib/gcc-lib/sparc-sun-solaris2.6/3.0 -L/usr/
ccs/bin -L/usr/ccs/lib -L/projects/r51/gnu/gcc-core-3.0/SunOS/lib/gcc-lib/sparc-
sun-solaris2.6/3.0/../../.. foo.o -lgcc -lc -lgcc /projects/r51/gnu/gcc-core-3.0
/SunOS/lib/gcc-lib/sparc-sun-solaris2.6/3.0/crtend.o /projects/r51/gnu/gcc-core-
3.0/SunOS/lib/gcc-lib/sparc-sun-solaris2.6/3.0/crtn.o
ld: Software Generation Utilities - Solaris/ELF (3.0)
>Description:
/* The following code demonstrates a bug in the */
/* optimizer of gcc-3.0 on a SunOS machine. */
/* */
/* % gcc -O1 -o foo foo.c; foo */
/* z[0]= 0 r[0]= 0 */
/* z[1]= 1 r[1]= 1 */
/* ^ */
/* */
/* % gcc -O2 -o foo foo.c; foo */
/* z[0]= 0 r[0]= 0 */
/* z[1]= 0 r[1]= 1 */
/* ^ */
#include <stdio.h>
#define bar(a, b, c, z, r)\
__asm__(\
"ld [%3],%%g4; addcc %%g4,%0,%%g4; st %%g4,[%3];\
ld [%3+4],%%g4; addxcc %%g4,%1,%%g4; st %%g4,[%3+4];\
addx %2,%%g0,%%g4; st %%g4,[%4+4]"\
:: "rJ" ((int) (a)),\
"rJ" ((int) (b)),\
"rJ" ((int) (c)),\
"r" ((int *) (z)),\
"r" ((int *) (r))\
: "%g4", "cc"\
)
void foo(z,r)
int *z;
int *r;
{
int a, b, c;
int i;
for (i=0; i < 2; i++) {
if (i == 0) {
a = 0;
}
if (i == 1) {
a = 0;
}
c = 1;
b = r[1];
bar(a, b, c, z, r);
}
}
main()
{
int z[2];
int r[2];
z[0] = z[1] = 0;
r[0] = r[1] = 0;
foo(z, r);
printf("z[0]= %d r[0]= %d\n", z[0], r[0]);
printf("z[1]= %d r[1]= %d\n", z[1], r[1]);
}
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-04-02 11:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-02 3:20 optimization/3921: wrong output with -02 on sparc-sun-solaris2.6) compiled by GNU C version 3.0. /usr/ccs/bin/as -V -using __asm wrong output with -O2 on sparc-sun-solaris2.6 rth
-- strict thread matches above, loose matches on Subject: below --
2001-08-03 7:16 bfkelly
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).