[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc
Subject: Suboptimal code (gcc 2.95.1, i386-unknown-openbsd)
From: Marc Espie <espie () schutzenberger ! liafa ! jussieu ! fr>
Date: 1999-09-09 13:49:10
[Download RAW message or body]
Fiddling with optimization...
#define VAL 10
void f(char *s)
{
char *u = s;
while (u < s+VAL)
*u++='a';
}
Using -O3, I get:
.file "a.c"
gcc2_compiled.:
___gnu_compiled_c:
.text
.align 2,0x90
.globl _f
.type _f , @function
_f:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
leal 10(%eax),%edx
cmpl %edx,%eax
jae L4
.align 2,0x90
L5:
movb $97,(%eax)
incl %eax
cmpl %edx,%eax
jb L5
L4:
leave
ret
.size _f , . - _f
Notice the comparison and jump to L4 that will never occur.
Is gcc required to assume that pointer arithmetic may wrap around,
or is it just some optimization it misses ?
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic