[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
[rtl] Optimization question.
Hello, everybody.
I have this tiny example :
#define ONE 0x01
int fun ()
{
volatile register temp=0;
while ( temp&ONE ) {
/* Do something */
}
}
And when I compile it with gcc -O2 -S I get this assembly code:
fun:
pushl %ebp
movl %esp,%ebp
subl $4,%esp
movl $0,-4(%ebp)
.align 4
.L2:
movl -4(%ebp),%eax
testb $1,%al <--Instead of logical AND gcc generate testb
jne .L2 <--But for test==3,5,7... it will not work
leave <--as I expect it to
ret
Does anybody knows how to avoid this?
I absolutely have to compile the program with -O2 flag, but with this
"optimization" my program does not work. I am also very surprized by my
discovery - this type of code is all over the Linux code, but it still
works.
Thanks for any help.
Oleg.
--- [rtl] ---
For more information on Real-Time Linux see:
http://www.rtlinux.org/