This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
-fcompare-elim bug report
- To: <gcc-bugs at gcc dot gnu dot org>
- Subject: -fcompare-elim bug report
- From: "Dimitar Jekov" <jimmy at ncp dot infonet dot bg>
- Date: Thu, 31 Aug 2000 09:22:44 +0300
- Cc: <bug-gcc at gnu dot org>
#!/bin/sh
tar xvfy bash-2.04.tar.bz2
cd bash-2.04
export CFLAGS="-O2 -pipe -fcompare-elim"
export LDFLAGS="-s"
./configure --enable-shared --disable-static --disable-nls i586-pc-linux-gnu
make
cd builtins
./mkbuiltins -D . shift.def
gcc -I. -I.. -I../include -I../lib -v -o shift.i -E shift.c >& CCCP
gcc -O2 -pipe -fno-compare-elim -v -o no-compare-elim.s -S shift.i >&
NO-ELIM
gcc -O2 -pipe -fcompare-elim -v -o compare-elim.s -S shift.i >& ELIM
system type: i586-pc-linux-gnu
compiler version: gcc version pgcc-2.95.2 19991024 (release)
attachment: shift.i, CCCP, no-compare-elim.s, NO-ELIM, compare-elim.s, ELIM
diff --side --width=78 no-compare-elim.s compare-elim.s produces:
<cut>
.L12: .L12:
movl $1,%edx | movl $-8,%edx
leal -1(%esi),%edi | leal -1(%edi),%ebp
movl $dollar_vars,%ebx | movl $dollar_vars,%esi
movl $8,%ecx | movl $8,%ebx
> movl $4,%ecx
.p2align 3 .p2align 3
.L16: .L16:
movl (%ecx,%ebx),%eax | movl (%ebx,%esi),%eax
movl %eax,(%ebx,%edx,4) | movl %eax,(%ecx,%esi)
addl $4,%ecx | addl $4,%ebx
incl %edx | addl $40,%ecx
cmpl $8,%edx | addl $10,%edx
jle .L16 | jne .L16
<cut>
As you can see, shift.def:80 (shift.i:9500)
for (count = 1; count < 9; count++)
with -fcompare-elim assembles to something like
for (count = -8; count; count += 10)
At least, it works that way (I checked it out with gdb).
Starts with a count of -8, continues with 2, then with 12 etc. until
a Segmentation fault for 7072 (your mileage will vary) at shift.def:81
dollar_vars[count] = dollar_vars[count + 1]
Something to do with the fact that 1 - 9 == -8 and 1 + 9 == 10?
E-gards: Jimmy
attachment.tar.bz2