"fast AND correct strncpy" not working by itself?
Posted Aug 24, 2003 13:03 UTC (Sun) by
dwheeler (subscriber, #1216)
Parent article:
[PATCH] fast AND correct strncpy
When I slip this code into its own file and compile
it separately I don't seem to get this magic
"no jump statement" behavior. Any explanation?
I slipped this text into a file (adding headers) and used:
gcc -O3 -S strncpy.c
To see the assembly.
I still get a "jump" corresponding to the "if" statement.
Here's the relevant snippet for the loop. Notice that there's both a
"je" and "jne" instruction; I expected to only see the "jne", and
that the "je" was going to be automagically removed:
.L6:
movb (%ebx), %al
testb %al, %al
movb %al, (%edx)
je .L5
incl %ebx
.L5:
incl %edx
decl %ecx
jne .L6
This is using gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5).
Is this later gcc not optimizing this as well? Does the Linux kernel
use additional compilation option tricks that make this work
(if so, it'd be good to know what they are)? Or, is there
a different assumption of what this "magic" is?
Thanks.
(
Log in to post comments)