This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH]: Tidy up the code in expand_builtin
- From: Roger Sayle <roger at eyesopen dot com>
- To: <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 10 Dec 2001 17:37:51 -0700 (MST)
- Subject: [PATCH]: Tidy up the code in expand_builtin
Whilst working on builtins.c, I decided that it was about time to clean
up the way we were testing whether a builtin should be expanded inline
when not optimizing in expand_builtin. This "obvious" patch replaces
the 30 sequential comparisons against fcode with a single switch
statement. Given these values are a dense enumeration, the compiler
is now able to generate significantly better code for this check.
Tested with "make bootstrap" and "make -k check" on i686-pc-linux-gnu
with no new regressions.
2001-12-10 Roger Sayle <roger@eyesopen.com>
* builtins.c (expand_builtin): Use a switch statement to list those
functions not expanded without optimizations, instead of a series
of equality tests.
*** gcc/gcc/builtins.c Sun Dec 9 11:26:56 2001
--- patch9/gcc/builtins.c Mon Dec 10 09:54:26 2001
*************** expand_builtin (exp, target, subtarget,
*** 3485,3508 ****
/* When not optimizing, generate calls to library functions for a certain
set of builtins. */
! if (! optimize && ! CALLED_AS_BUILT_IN (fndecl)
! && (fcode == BUILT_IN_SIN || fcode == BUILT_IN_COS
! || fcode == BUILT_IN_FSQRT || fcode == BUILT_IN_SQRTF
! || fcode == BUILT_IN_SQRTL || fcode == BUILT_IN_MEMSET
! || fcode == BUILT_IN_MEMCPY || fcode == BUILT_IN_MEMCMP
! || fcode == BUILT_IN_BCMP || fcode == BUILT_IN_BZERO
! || fcode == BUILT_IN_INDEX || fcode == BUILT_IN_RINDEX
! || fcode == BUILT_IN_STRCHR || fcode == BUILT_IN_STRRCHR
! || fcode == BUILT_IN_STRLEN || fcode == BUILT_IN_STRCPY
! || fcode == BUILT_IN_STRNCPY || fcode == BUILT_IN_STRNCMP
! || fcode == BUILT_IN_STRSTR || fcode == BUILT_IN_STRPBRK
! || fcode == BUILT_IN_STRCAT || fcode == BUILT_IN_STRNCAT
! || fcode == BUILT_IN_STRSPN || fcode == BUILT_IN_STRCSPN
! || fcode == BUILT_IN_STRCMP || fcode == BUILT_IN_FFS
! || fcode == BUILT_IN_PUTCHAR || fcode == BUILT_IN_PUTS
! || fcode == BUILT_IN_PRINTF || fcode == BUILT_IN_FPUTC
! || fcode == BUILT_IN_FPUTS || fcode == BUILT_IN_FWRITE))
! return expand_call (exp, target, ignore);
switch (fcode)
{
--- 3485,3530 ----
/* When not optimizing, generate calls to library functions for a certain
set of builtins. */
! if (!optimize && !CALLED_AS_BUILT_IN (fndecl))
! switch (fcode)
! {
! case BUILT_IN_SIN:
! case BUILT_IN_COS:
! case BUILT_IN_FSQRT:
! case BUILT_IN_SQRTF:
! case BUILT_IN_SQRTL:
! case BUILT_IN_MEMSET:
! case BUILT_IN_MEMCPY:
! case BUILT_IN_MEMCMP:
! case BUILT_IN_BCMP:
! case BUILT_IN_BZERO:
! case BUILT_IN_INDEX:
! case BUILT_IN_RINDEX:
! case BUILT_IN_STRCHR:
! case BUILT_IN_STRRCHR:
! case BUILT_IN_STRLEN:
! case BUILT_IN_STRCPY:
! case BUILT_IN_STRNCPY:
! case BUILT_IN_STRNCMP:
! case BUILT_IN_STRSTR:
! case BUILT_IN_STRPBRK:
! case BUILT_IN_STRCAT:
! case BUILT_IN_STRNCAT:
! case BUILT_IN_STRSPN:
! case BUILT_IN_STRCSPN:
! case BUILT_IN_STRCMP:
! case BUILT_IN_FFS:
! case BUILT_IN_PUTCHAR:
! case BUILT_IN_PUTS:
! case BUILT_IN_PRINTF:
! case BUILT_IN_FPUTC:
! case BUILT_IN_FPUTS:
! case BUILT_IN_FWRITE:
! return expand_call (exp, target, ignore);
!
! default:
! break;
! }
switch (fcode)
{
Roger
--
Roger Sayle, E-mail: roger@eyesopen.com
OpenEye Scientific Software, WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road, Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507. Fax: (+1) 505-438-3470