Subject: Re: gcc de-optimisations
To: None <tech-toolchain@netbsd.org>
From: Alan Barrett <apb@cequrux.com>
List: tech-toolchain
Date: 10/23/2005 22:22:16
On Sun, 23 Oct 2005, David Laight wrote:
> How do we stop gcc (i386) converting:
>     if (memcmp(a, b, 16))
> into:
>     movl  %ecx, #16
>     repeq cmpsb

CFLAGS += -fno-builtin-memcmp

I suppose a real fix would somehow make gcc choose between the
function call or the string operation based on various optimisation
flags and detailed knowledge of the performance characteristics
of the target CPU, but such a thing is far beyond my skill.  The
relevant code is the (define_expand "cmpstrsi" ...) part of
src/gnu/dist/gcc/gcc/config/i386/i386.md, along with tests for
HAVE_cmpstrsi in src/gnu/dist/gcc/gcc/builtins.c.

--apb (Alan Barrett)