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]
Other format: [Raw text]

optimization/6537: For -O (but not -O2 or -O0) incorrect assembly is generated



>Number:         6537
>Category:       optimization
>Synopsis:       For -O (but not -O2 or -O0) incorrect assembly is generated
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May 01 12:56:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Michael Flaster
>Release:        gcc version 2.95.3 20010315 (release)
>Organization:
>Environment:
FreeBSD 4.4-RELEASE #0
>Description:
When compiling the gzip compression library (zlib), some incorrect assembler seems to be generated.  Here is a snipped from the .c source:
line 201: f = q - c->sub.copy.dist;
      
      while (f < s->window) {            
        
        f += s->end - s->window;       
      }

Here is the generated .s:
.stabn 68,0,203,.LM75-inflate_codes
.LM75:
        movl 8(%ebp),%edx
        cmpl 40(%edx),%eax
' Compare s->window (40(%edx)) with f
        jae .L107
        movl 40(%edx),%eax
' Move s->window eax
        movl %edx,%ecx
' ? Curious
        movl 44(%ecx),%edx
' Move s->end to edx
        subl %eax,%edx
' Sub and put result in edx
        movl 40(%edx),%eax
' ??? Dereference the difference.  It seems to be trying to put s->window back in eax - except that edx no longer has a pointer to s.

I am attaching the compressed .i file.  The output of the compile line is:
nstg24:~/lucent/ews/zlib-1.1.4> cc -v -save-temps -g -O -DNO_DEFLATE -D_REENTRANT -c -o infcodes.o infcodes.c
Using builtin specs.
gcc version 2.95.3 20010315 (release) [FreeBSD]
 /usr/libexec/cpp0 -lang-c -v -D__GNUC__=2 -D__GNUC_MINOR__=95 -Di386 -D__FreeBSD__=4 -D__FreeBSD_cc_version=440000 -Dunix -D__i386__ -D__FreeBSD__=4 -D__FreeBSD_cc_version=440000 -D__unix__ -D__i386 -D__unix -Acpu(i386) -Amachine(i386) -Asystem(unix) -Asystem(FreeBSD) -D__OPTIMIZE__ -g -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -D__ELF__ -DNO_DEFLATE -D_REENTRANT infcodes.c infcodes.i
GNU CPP version 2.95.3 20010315 (release) [FreeBSD] (i386 FreeBSD/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
 /usr/include/g++
End of omitted list.
 /usr/libexec/cc1 infcodes.i -quiet -dumpbase infcodes.c -g -O -version -o infcodes.s
GNU C version 2.95.3 20010315 (release) [FreeBSD] (i386-unknown-freebsd) compiled by GNU C version 2.95.3 20010315 (release) [FreeBSD].
 /usr/libexec/elf/as -v -o infcodes.o infcodes.s
GNU assembler version 2.11.2 20010719 [FreeBSD] (i386-unknown-freebsd4) using BFD version 2.11.2 20010719 [FreeBSD]


I've tried this on other FreeBSD machines in our lab, some running gcc 2.95.2, some running 3.0.4, and I seem to get the exact same problem.  Adding printf's near the source lines in question, or changing the optimization level, makes the problem go away.

Thanks in advance!

Michael Flaster
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/x-gzip-compressed; name="infcodes.i.gz"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="infcodes.i.gz"

H4sICIxD0DwCA2luZmNvZGVzLmkA7Tz7b9tG0j9bf8VeDQSSLDux83LNyIfm7A9fgKAtEuPuiiAg
KHIpM+JDJik7tk7/+83sg9xdLkWqSdv07oTAEndnZmfnvQ9mnxyT76I09LOAFkf+dwMywM8+Nj+s
yig+uv6OHItW9S+HiKOZCrDtwxH8LA1bSO6TZ9/XEAb2FvoqIQWOtOCStk9jMOD4+XMLRwR7Ttt5
VT7l/ZIGNCSrtIjmKQ2If+3lhLy+L6nDhmwARGkJHas3ackAGv1xls6h/y18OZJnAJRwSBkng9+h
U9Pn4xL2De2ymY9G8FtpxdGJ4EJtfsvG5t9IXB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HsEEdEg8JSDUOWhxFU3oyailiavMTM4HaCLMPCB+3/2tzc5TDI8Um3lzVMJpBbjQW
HpHjF71ZwLLpCEovoM8wnzsqBF7vsjCo2SkUyz3YYny9eDYyBNTOVu1I+sCmD5VgBQ0Gt0rn6Um3
dIhtshgeOsaogWUQMccAp0mKOZoUHmaOR7DWufXiKMBCmeZe/Dhm/x0IK6q/k+QxJA8Pn44qtv54
79WiE9jA2dboxI3sPzU4CU85kHHCEo6MaPRJxp5PaqSxZ5GgO4sEahYhzXSCi1oln+Dj2f/yyZ8h
n3zFYF5B4Dp6e1gXmyB/jrj+BTEXJeGlPv0TRVuhmrP/6mirm/IXx11LxMRNPyVi4qMlYoYAeUMO
GyxVFiu+xaIxJK9whcs3vkfGanGwV69eQpwTX9oA9QqlYdgbnT7PQ5bFI2g8mU6fcN3fTKec9KNH
YiX1l2nNlViB8fF2XoJtMCrIsXQjIPnUqv0vXvOR33FS34KvbLjrKovd9fjm4GDKd7yGZBweHIB1
J4eHjrEgDjFK85mNlMVtyDdehHiM+h+otMZbZUtOi828LHxzZVu0/s8W/5NtUbdEZZlr2GNPG8IV
lyXsoi0vyDl5uaXgqC1/QQ6n5LS26/TgoH5YAle22mozUPbdfgfDUWYmoHDzSpJUtrC+jVJE1eDl
jxeKyuDpTKmjjr/JIkoUimYR9a0WfgENvVVcnmlsnnxjbOJJCTsuablUM/TZ2VXruVPjhEo5XEJ8
y9kSv1sMgYb4ZCTEgUc2/wZpZ6otGWAAAA==


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