This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Optimization failure
- To: egcs-bugs at cygnus dot com
- Subject: Optimization failure
- From: Kai Henningsen <kai at khms dot westfalen dot de>
- Date: Sun, 28 Feb 1999 11:18:15 +0100 (CET)
- Reply-To: kai-egcs-bug at khms dot westfalen dot de
The following example code demonstrates a problem with the optimizer:
Only the first range of constants is recognized.
I hope this is enough information, but if you need more, just ask :-)
Source (generated by a script, otherwise I would already have hand-optimized
it):
int is_control(int c)
{
return c == 0x0000 || c == 0x0001 || c == 0x0002 || c == 0x0003
|| c == 0x0004 || c == 0x0005 || c == 0x0006 || c == 0x0007
|| c == 0x0008 || c == 0x0009 || c == 0x000A || c == 0x000B
|| c == 0x000C || c == 0x000D || c == 0x000E || c == 0x000F
|| c == 0x0010 || c == 0x0011 || c == 0x0012 || c == 0x0013
|| c == 0x0014 || c == 0x0015 || c == 0x0016 || c == 0x0017
|| c == 0x0018 || c == 0x0019 || c == 0x001A || c == 0x001B
|| c == 0x001C || c == 0x001D || c == 0x001E || c == 0x001F
|| c == 0x007F || c == 0x0080 || c == 0x0081 || c == 0x0082
|| c == 0x0083 || c == 0x0084 || c == 0x0085 || c == 0x0086
|| c == 0x0087 || c == 0x0088 || c == 0x0089 || c == 0x008A
|| c == 0x008B || c == 0x008C || c == 0x008D || c == 0x008E
|| c == 0x008F || c == 0x0090 || c == 0x0091 || c == 0x0092
|| c == 0x0093 || c == 0x0094 || c == 0x0095 || c == 0x0096
|| c == 0x0097 || c == 0x0098 || c == 0x0099 || c == 0x009A
|| c == 0x009B || c == 0x009C || c == 0x009D || c == 0x009E
|| c == 0x009F || c == 0x200C || c == 0x200D || c == 0x200E
|| c == 0x200F || c == 0x202A || c == 0x202B || c == 0x202C
|| c == 0x202D || c == 0x202E || c == 0x206A || c == 0x206B
|| c == 0x206C || c == 0x206D || c == 0x206E || c == 0x206F
|| c == 0xFEFF;
}
Compiler invocation:
Script started on Sun Feb 28 11:10:49 1999
[0m[35;40mkai@khms tty5 ~/mimetext [0m$ egcc -v -O9 -S bug.c
Reading specs from /usr/lib/gcc-lib/i486-linux/egcs-2.91.60/specs
gcc version egcs-2.91.60 Debian 2.1 (egcs-1.1.1 release)
/usr/lib/gcc-lib/i486-linux/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__ -Asystem(unix) -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di486 -D__i486 -D__i486__ bug.c /tmp/cch8cSfx.i
GNU CPP version egcs-2.91.60 Debian 2.1 (egcs-1.1.1 release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc-lib/i486-linux/egcs-2.91.60/include
/usr/include
End of search list.
/usr/lib/gcc-lib/i486-linux/egcs-2.91.60/cc1 /tmp/cch8cSfx.i -quiet -dumpbase bug.c -O9 -version -o bug.s
GNU C version egcs-2.91.60 Debian 2.1 (egcs-1.1.1 release) (i486-linux) compiled by GNU C version egcs-2.91.60 Debian 2.1 (egcs-1.1.1 release).
[0m[35;40mkai@khms tty5 ~/mimetext [0m$ [Kexit
Script done on Sun Feb 28 11:11:10 1999
Assembler output:
.file "bug.c"
.version "01.01"
gcc2_compiled.:
.text
.align 16
.globl is_control
.type is_control,@function
is_control:
pushl %ebp
movl %esp,%ebp
xorl %eax,%eax
movl 8(%ebp),%edx
cmpl $31,%edx
jbe .L3
cmpl $127,%edx
je .L3
cmpl $128,%edx
je .L3
cmpl $129,%edx
je .L3
cmpl $130,%edx
je .L3
cmpl $131,%edx
je .L3
cmpl $132,%edx
je .L3
cmpl $133,%edx
je .L3
cmpl $134,%edx
je .L3
cmpl $135,%edx
je .L3
cmpl $136,%edx
je .L3
cmpl $137,%edx
je .L3
cmpl $138,%edx
je .L3
cmpl $139,%edx
je .L3
cmpl $140,%edx
je .L3
cmpl $141,%edx
je .L3
cmpl $142,%edx
je .L3
cmpl $143,%edx
je .L3
cmpl $144,%edx
je .L3
cmpl $145,%edx
je .L3
cmpl $146,%edx
je .L3
cmpl $147,%edx
je .L3
cmpl $148,%edx
je .L3
cmpl $149,%edx
je .L3
cmpl $150,%edx
je .L3
cmpl $151,%edx
je .L3
cmpl $152,%edx
je .L3
cmpl $153,%edx
je .L3
cmpl $154,%edx
je .L3
cmpl $155,%edx
je .L3
cmpl $156,%edx
je .L3
cmpl $157,%edx
je .L3
cmpl $158,%edx
je .L3
cmpl $159,%edx
je .L3
cmpl $8204,%edx
je .L3
cmpl $8205,%edx
je .L3
cmpl $8206,%edx
je .L3
cmpl $8207,%edx
je .L3
cmpl $8234,%edx
je .L3
cmpl $8235,%edx
je .L3
cmpl $8236,%edx
je .L3
cmpl $8237,%edx
je .L3
cmpl $8238,%edx
je .L3
cmpl $8298,%edx
je .L3
cmpl $8299,%edx
je .L3
cmpl $8300,%edx
je .L3
cmpl $8301,%edx
je .L3
cmpl $8302,%edx
je .L3
cmpl $8303,%edx
je .L3
cmpl $65279,%edx
jne .L2
.L3:
movl $1,%eax
.L2:
movl %ebp,%esp
popl %ebp
ret
.Lfe1:
.size is_control,.Lfe1-is_control
.ident "GCC: (GNU) egcs-2.91.60 Debian 2.1 (egcs-1.1.1 release)"