This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gcc 2.95.3 bug: generating wrong code on ix86 with -O2 or -O1 -fexpensive-optimizations


Summary: bug in gcc 2.95.3 (but not in gcc 3.0) 
generating wrong code on ix86 with -O2 or -O1 -fexpensive-optimizations


Details:
when Glide is compiled with some optimization options (-O2 or -O1
-fexpensive-optimizations), gcc puts some wrong, strange instructions
that destroy some of function parameters and one word from caller's stack
frame - in function _grClipWindow().

This code is:
.globl _grClipWindow
        .type    _grClipWindow,@function
_grClipWindow:
        pushl %ebp
*       xorl %edx,%edx
        movl %esp,%ebp
        subl $28,%esp
        pushl %edi
        pushl %esi
        pushl %ebx
        xorl %esi,%esi
>       movl 12(%ebp),%eax
*       movl %edx,16(%ebp)
>       movl %eax,12(%ebp)
>       movl 16(%ebp),%eax
*       movl %edx,20(%ebp)
>       movl %eax,16(%ebp)
>       movl 20(%ebp),%eax
*       movl %edx,24(%ebp)
>       movl %eax,20(%ebp)
        movl 8(%ebp),%ebx
        movl threadValueLinux,%edi
        addl $-8,%esp

Instructions marked with "*" destroy third (16(%ebp)) and fourth parameter
(20(%ebp)) and one word from caller's stack frame (24(%ebp)).

Instructions marked with ">" are unnecessary reads and writes of the same
address - and shouldn't be present in optimized code.


Attached files:
gglide.i - preprocessed gglide.c from original sources
gglide-cutdown.i - preprocessed gglide.c from largely cut-down sources (which
                   still triggers this bug).


Below are informations as specified in bug reporting instructions:


GCC version:
gcc version 2.95.3 20010315 (release)

(bug present since at least gcc version 2.95.3 19991030 (prerelease);
 NOT present in egcs-1.1.2 nor gcc 3.0)


System type:
i586-pld-linux


Command line:
bug occurs with:
gcc gglide.i -O2
or
gcc gglide.i -O1 -fexpensive-optimizations

Doesn't occur with simple -O1 or "-O2 -fno-expensive-optimizations".

Compiler output:
(only warnings)
gglide.c: In function `_grBufferClear2D':
gglide.c:957: warning: `clip0min' might be used uninitialized in this function
gglide.c:957: warning: `command' might be used uninitialized in this function
gglide.c:964: warning: `width' might be used uninitialized in this function
gglide.c:964: warning: `height' might be used uninitialized in this function
gglide.c: In function `_grTriFill':
gglide.c:1301: warning: suggest parentheses around arithmetic in operand of |


gcc was configured with:

CFLAGS="-O2 -march=i586" \
CXXFLAGS=-O2 -march=i586" \
TEXCONFIG=false ../configure \
	--prefix=/usr \
	--infodir=/usr/share/info \
	--enable-shared \
	--enable-threads=posix \
	--enable-haifa \
	--with-gnu-as \
	--with-gnu-ld \
	--with-gxx-include-dir="\$\{prefix\}/include/g++" \
	--disable-nls \
	i586-pld-linux


-- 
Jakub Bogusz    http://prioris.mini.pw.edu.pl/~qboosh/
PLD Team        http://www.pld.org.pl/

gglide.i.bz2

gglide-cutdown.i.bz2


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]