public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* egcs-1.1.1: x86 code gen bug w/ -O2
@ 1999-01-20 7:26 Christoph Breitkopf
1999-04-04 3:07 ` Jeffrey A Law
0 siblings, 1 reply; 2+ messages in thread
From: Christoph Breitkopf @ 1999-01-20 7:26 UTC (permalink / raw)
To: egcs-bugs
OS: Linux (RedHat 5.2, Kernel 2.0.37pre3)
egcs version: 1.1.1
egcs was compiled with default options to configure, only
the prefix was changed.
The following program ist compiled correctly with -O,
but egcs generates seriously incorrect code with -O2.
Included:
egcs-bug.c source of buggy program
build.txt messages from compiler invocation
egcs-bug.s annotated compiler output
---------- egcs-bug.c ----------
#define N 20
int x[N];
extern void print(int);
/* Print elements of x which are > 0 in descending order. */
void buggy(void)
{
for (;;) {
int i, mi, max;
max = 0;
for (i = 0; i < N; i++) {
if (x[i] > max) {
max = x[i];
mi = i;
}
}
if (max == 0)
break;
print(max);
x[mi] = 0;
}
}
---------- build.txt ----------
Reading specs from
/usr/local/egcs-1.1.1/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/specs
gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release)
/usr/local/egcs-1.1.1/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/cpp
-lang-c -v -undef -D__GNUC__=2 -D__GNUC_MINOR__=91 -D__ELF__ -Dunix
-Di386 -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__i386__
-D__linux__ -D__unix -D__i386 -D__linux -Asystem(posix) -D__OPTIMIZE__
-g -Asystem(unix) -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__
-Di686 -Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__
egcs-bug.c /tmp/ccm9P6GP.i
GNU CPP version egcs-2.91.60 19981201 (egcs-1.1.1 release) (i386
Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/local/egcs-1.1.1/i686-pc-linux-gnu/include
/usr/local/egcs-1.1.1/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/include
/usr/include
End of search list.
/usr/local/egcs-1.1.1/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.60/cc1
/tmp/ccm9P6GP.i -quiet -dumpbase egcs-bug.c -g -O2 -version
-fverbose-asm -o egcs-bug.s
GNU C version egcs-2.91.60 19981201 (egcs-1.1.1 release)
(i686-pc-linux-gnu) compiled by GNU C version egcs-2.91.60 19981201
(egcs-1.1.1 release).
---------- egcs-bug.s ----------
.file "egcs-bug.c"
.version "01.01"
# GNU C version egcs-2.91.60 19981201 (egcs-1.1.1 release)
(i686-pc-linux-gnu) compiled by GNU C version egcs-2.91.60 19981201
(egcs-1.1.1 release).
# options passed: -g -O2 -fverbose-asm
# options enabled: -fdefer-pop -fcse-follow-jumps -fcse-skip-blocks
# -fexpensive-optimizations -fthread-jumps -fstrength-reduce -fpeephole
# -fforce-mem -ffunction-cse -finline -fkeep-static-consts
-fcaller-saves
# -fpcc-struct-return -fgcse -frerun-cse-after-loop -frerun-loop-opt
# -fschedule-insns2 -fcommon -fverbose-asm -fgnu-linker -fregmove
# -foptimize-register-move -fargument-alias -m80387 -mhard-float
# -mno-soft-float -mieee-fp -mfp-ret-in-387 -mschedule-prologue
# -mcpu=pentiumpro -march=pentium
.stabs "/home/breitko/",100,0,0,.Ltext0
.stabs "egcs-bug.c",100,0,0,.Ltext0
.text
.Ltext0:
.stabs "gcc2_compiled.", 0x3c, 0, 0, 0
.stabs "int:t(0,1)=r(0,1);0020000000000;0017777777777;",128,0,0,0
.stabs "char:t(0,2)=r(0,2);0;127;",128,0,0,0
.stabs "long int:t(0,3)=r(0,1);0020000000000;0017777777777;",128,0,0,0
.stabs "unsigned
int:t(0,4)=r(0,1);0000000000000;0037777777777;",128,0,0,0
.stabs "long unsigned
int:t(0,5)=r(0,1);0000000000000;0037777777777;",128,0,0,0
.stabs "long long
int:t(0,6)=r(0,1);01000000000000000000000;0777777777777777777777;",128,0,0,0
.stabs "long long unsigned
int:t(0,7)=r(0,1);0000000000000;01777777777777777777777;",128,0,0,0
.stabs "short int:t(0,8)=r(0,8);-32768;32767;",128,0,0,0
.stabs "short unsigned int:t(0,9)=r(0,9);0;65535;",128,0,0,0
.stabs "signed char:t(0,10)=r(0,10);-128;127;",128,0,0,0
.stabs "unsigned char:t(0,11)=r(0,11);0;255;",128,0,0,0
.stabs "float:t(0,12)=r(0,1);4;0;",128,0,0,0
.stabs "double:t(0,13)=r(0,1);8;0;",128,0,0,0
.stabs "long double:t(0,14)=r(0,1);12;0;",128,0,0,0
.stabs "complex
int:t(0,15)=s8real:(0,1),0,32;imag:(0,1),32,32;;",128,0,0,0
.stabs "complex float:t(0,16)=r(0,16);4;0;",128,0,0,0
.stabs "complex double:t(0,17)=r(0,17);8;0;",128,0,0,0
.stabs "complex long double:t(0,18)=r(0,18);12;0;",128,0,0,0
.stabs "void:t(0,19)=(0,19)",128,0,0,0
.align 4
.stabs "buggy:F(0,19)",36,0,7,buggy
.globl buggy
.type buggy,@function
buggy:
.stabn 68,0,7,.LM1-buggy
.LM1:
.LBB2:
pushl %ebp
movl %esp,%ebp
pushl %ebx
.stabn 68,0,8,.LM2-buggy
.LM2:
jmp .L2
.LBB3:
.p2align 4,,7
.L11:
.stabn 68,0,19,.LM3-buggy
.LM3:
.LBE3:
pushl %ebx
call print
.stabn 68,0,20,.LM4-buggy
.LM4:
movl $0,x+76 ; ??? should be 'x[mi] = 0'
.stabn 68,0,8,.LM5-buggy
.LM5:
addl $4,%esp
.L2:
.stabn 68,0,10,.LM6-buggy
.LM6:
xorl %ebx,%ebx ; max = 0
.stabn 68,0,11,.LM7-buggy
.LM7:
xorl %ecx,%ecx ; i = 0
movl $x,%edx
.p2align 4,,7
.L8:
.stabn 68,0,12,.LM8-buggy
.LM8:
movl (%edx),%eax ; if (x[i] > max)
cmpl %ebx,%eax
jle .L7
.stabn 68,0,13,.LM9-buggy
.LM9:
movl %eax,%ebx ; max = x[i]
; ??? but where is 'mi = i' ???
.stabn 68,0,11,.LM10-buggy
.LM10:
.L7:
addl $4,%edx
incl %ecx
cmpl $19,%ecx
jle .L8
.stabn 68,0,17,.LM11-buggy
.LM11:
testl %ebx,%ebx
jne .L11
.stabn 68,0,18,.LM12-buggy
.LM12:
.stabn 68,0,22,.LM13-buggy
.LM13:
.LBE2:
movl -4(%ebp),%ebx
movl %ebp,%esp
popl %ebp
ret
.Lfe1:
.size buggy,.Lfe1-buggy
.stabn 192,0,0,.LBB2-buggy
.stabs "i:r(0,1)",64,0,9,1
.stabs "max:r(0,1)",64,0,9,3
.stabn 192,0,0,.LBB3-buggy
.stabn 224,0,0,.LBE3-buggy
.stabn 224,0,0,.LBE2-buggy
.Lscope0:
.stabs "",36,0,0,.Lscope0-buggy
.stabs "x:G(0,20)=ar(0,1);0;19;(0,1)",32,0,2,0
.comm x,80,32
.stabs "",100,0,0,.Letext
.Letext:
.ident "GCC: (GNU) egcs-2.91.60 19981201 (egcs-1.1.1 release)"
---------- end ----------
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: egcs-1.1.1: x86 code gen bug w/ -O2
1999-01-20 7:26 egcs-1.1.1: x86 code gen bug w/ -O2 Christoph Breitkopf
@ 1999-04-04 3:07 ` Jeffrey A Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeffrey A Law @ 1999-04-04 3:07 UTC (permalink / raw)
To: Christoph Breitkopf; +Cc: egcs-bugs
In message <36A5CEF3.EF699C09@magrathea.de>you write:
> OS: Linux (RedHat 5.2, Kernel 2.0.37pre3)
> egcs version: 1.1.1
>
> egcs was compiled with default options to configure, only
> the prefix was changed.
>
> The following program ist compiled correctly with -O,
> but egcs generates seriously incorrect code with -O2.
>
> Included:
> egcs-bug.c source of buggy program
> build.txt messages from compiler invocation
> egcs-bug.s annotated compiler output
>
> ---------- egcs-bug.c ----------
> #define N 20
> int x[N];
> extern void print(int);
>
> /* Print elements of x which are > 0 in descending order. */
> void buggy(void)
> {
> for (;;) {
> int i, mi, max;
> max = 0;
> for (i = 0; i < N; i++) {
> if (x[i] > max) {
> max = x[i];
> mi = i;
> }
> }
> if (max == 0)
> break;
> print(max);
> x[mi] = 0;
> }
> }
Thanks for the bug report. I've just installed a fix into the egcs source
tree to fix this bug. I've also installed a modified version of your
testcase into our regression testsuite.
jeff
>From jdassen@wi.leidenuniv.nl Sun Apr 04 04:26:00 1999
From: "J.H.M. Dassen" <jdassen@wi.leidenuniv.nl>
To: egcs-bugs@egcs.cygnus.com
Cc: 35477@bugs.debian.org
Subject: [smkelly@zombie.org: Bug#35477: gcc: egcs C++ class mishandling.]
Date: Sun, 04 Apr 1999 04:26:00 -0000
Message-id: <19990404132557.B12093@ultra5.wi.leidenuniv.nl>
X-SW-Source: 1999-04/msg00067.html
Content-length: 503
This problem was reported as a bug through the Debian bugtracking system
( http://www.debian.org/Bugs/ ); please Cc: 35477@bugs.debian.org on replies.
The problem is still reproducable with
gcc version egcs-2.93.13 19990321 (gcc2 ss-980929 experimental)
on a i586 Debian GNU/Linux "potato" system.
Greetings,
Ray
--
POPULATION EXPLOSION Unique in human experience, an event which happened
yesterday but which everyone swears won't happen until tomorrow.
- The Hipcrime Vocab by Chad C. Mulligan
>From law@upchuck.cygnus.com Sun Apr 04 04:29:00 1999
From: Jeffrey A Law <law@upchuck.cygnus.com>
To: craig@jcb-sc.com
Cc: egcs-bugs@egcs.cygnus.com, egcs@egcs.cygnus.com
Subject: Re: new g77 x86 ICE in 19990328
Date: Sun, 04 Apr 1999 04:29:00 -0000
Message-id: <4509.923224723@upchuck>
References: <19990328181544.10702.qmail@deer>
X-SW-Source: 1999-04/msg00068.html
Content-length: 2567
In message <19990328181544.10702.qmail@deer>you write:
> This is a new ICE -- no ICE in previous snapshots. Could someone
> currently working on the x86 backend look into it, and let me know
> if it turns out to be a g77 front-end bug, e.g. a latent one uncovered
> by recent improvements to the x86?
>
> --------
> [craig@deer play]$ /develop/egcs/19990328/bin/g77 -O2 -v -c ice.f
> g77 version egcs-2.93.14 19990328 (gcc2 ss-980929 experimental) (from FSF-g
> 77 version 0.5.24-19990313)
> Reading specs from /develop/egcs/19990328/lib/gcc-lib/i686-pc-linux-gnu/egc
> s-2.93.14/specs
> gcc version egcs-2.93.14 19990328 (gcc2 ss-980929 experimental)
> /develop/egcs/19990328/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.93.14/f771 ice
> .f -quiet -dumpbase ice.f -O2 -version -fversion -o /tmp/ccsUcaaa.s
> GNU F77 version egcs-2.93.14 19990328 (gcc2 ss-980929 experimental) (i686-p
> c-linux-gnu) compiled by GNU C version egcs-2.93.14 19990328 (gcc2 ss-98092
> 9 experimental).
> GNU Fortran Front End version 0.5.24-19990313
> ../../egcs-19990328/gcc/config/i386/i386.c:3697: Internal compiler error in
> function print_operand
> Please submit a full bug report to `egcs-bugs@egcs.cygnus.com'.
> See <URL: http://egcs.cygnus.com/faq.html#bugreport > for details.
> [craig@deer play]$
Got it. It's an obscure latent bug.
I'll buy a beer at LinuxExpo for the first person that can spot the problem in
this code from emit-rtl.c::operand_subword. You've got until I get back from
skiing tomorrow afternoon :-)
/* If OP is a REG or SUBREG, we can handle it very simply. */
if (GET_CODE (op) == REG)
{
/* If the register is not valid for MODE, return 0. If we don't
do this, there is no way to fix up the resulting REG later. */
if (REGNO (op) < FIRST_PSEUDO_REGISTER
&& ! HARD_REGNO_MODE_OK (REGNO (op) + i, word_mode))
return 0;
else if (REGNO (op) >= FIRST_PSEUDO_REGISTER
|| (REG_FUNCTION_VALUE_P (op)
&& rtx_equal_function_value_matters)
/* We want to keep the stack, frame, and arg pointers
special. */
|| op == frame_pointer_rtx
#if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
|| op == arg_pointer_rtx
#endif
|| op == stack_pointer_rtx)
return gen_rtx_SUBREG (word_mode, op, i);
else
return gen_rtx_REG (word_mode, REGNO (op) + i);
}
A hint, OP is the last register in the FP stack register class on the x86.
jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1999-04-04 3:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-01-20 7:26 egcs-1.1.1: x86 code gen bug w/ -O2 Christoph Breitkopf
1999-04-04 3:07 ` Jeffrey A Law
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).