This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Speed up ix86_expand_builtin


On Wed, Aug 17, 2016 at 4:17 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Tue, Aug 16, 2016 at 09:21:57PM +0200, Uros Bizjak wrote:
>> The idea is indeed good, but please leave full names in the *.def
>> file. We can change them later, if need arises.
>
> Ok, here it is.
> i386-builtin.def is basically moved the bdesc_* definitions, except that
>   { ... },
> is replaced with
> BDESC (...)
> and comments reindented.  The first entry in each bdesc_* array
> uses BDESC_FIRST macro instead of BDESC, and there is BDESC_END after the
> last one.  I've managed to do it without gaps in between enumerator values
> for the boundaries, and with the goal that additions of BDESC entries at the
> end of bdesc_* sections will be much more common than adding new bdesc_*
> arrays, so e.g. didn't want a BDESC_LAST macro that would need to be changed
> to BDESC and added for some new entry every time something is appended.
> Also, I've tried to make the real builtin IX86_BUILTIN_* values to always
> precede the IX86_BUILTIN__BDESC_*_{FIRST,LAST} aliases, so that in the
> debugger one can see IX86_BUILTIN_COMIEQSS rather than
> IX86_BUILTIN__BDESC_COMI_FIRST etc.
>
> Full patch is attached xz compressed, included below is the same patch with
> lots of - or + lines replaced with ... where it doesn't contain anything
> interesting for the review.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2016-08-17  Jakub Jelinek  <jakub@redhat.com>
>
>         * config/i386/i386.c (enum ix86_builtins): Remove IX86_BUILTIN_*
>         codes that appear in bdesc_* arrays, instead include i386-builtin.def
>         twice to define those.
>         (bdesc_comi, bdesc_pcmpestr, bdesc_pcmpistr, bdesc_special_args,
>         bdesc_args, bdesc_round_args, bdesc_mpx, bdesc_mpx_const,
>         bdesc_multi_arg): Define by including i386-builtin.def the third time.
>         * config/i386/i386-builtin.def: New file.

OK.

Thanks,
Uros.

> --- gcc/config/i386/i386.c.jj   2016-08-16 21:27:02.000000000 +0200
> +++ gcc/config/i386/i386.c      2016-08-17 12:43:20.255605518 +0200
> @@ -30661,2415 +30661,41 @@ enum ix86_builtins
>    IX86_BUILTIN_READ_FLAGS,
>    IX86_BUILTIN_WRITE_FLAGS,
>
> -  /* All the remaining builtins are tracked in bdesc_* arrays.
> ...
> -  IX86_BUILTIN_VPERMIL2PS256,
> -  IX86_BUILTIN__BDESC_MULTI_ARG_LAST = IX86_BUILTIN_VPERMIL2PS256,
> +  /* All the remaining builtins are tracked in bdesc_* arrays in
> +     i386-builtin.def.  Don't add any IX86_BUILTIN_* enumerators after
> +     this point.  */
> +#define BDESC(mask, icode, name, code, comparison, flag) \
> +  code,
> +#define BDESC_FIRST(kind, kindu, mask, icode, name, code, comparison, flag) \
> +  code,                                                                            \
> +  IX86_BUILTIN__BDESC_##kindu##_FIRST = code,
> +#define BDESC_END(kind, next_kind)
> +
> +#include "i386-builtin.def"
> +
> +#undef BDESC
> +#undef BDESC_FIRST
> +#undef BDESC_END
> +
> +  IX86_BUILTIN_MAX,
> +
> +  IX86_BUILTIN__BDESC_MAX_FIRST = IX86_BUILTIN_MAX,
> +
> +  /* Now just the aliases for bdesc_* start/end.  */
> +#define BDESC(mask, icode, name, code, comparison, flag)
> +#define BDESC_FIRST(kind, kindu, mask, icode, name, code, comparison, flag)
> +#define BDESC_END(kind, next_kind) \
> +  IX86_BUILTIN__BDESC_##kind##_LAST                                        \
> +    = IX86_BUILTIN__BDESC_##next_kind##_FIRST - 1,
> +
> +#include "i386-builtin.def"
> +
> +#undef BDESC
> +#undef BDESC_FIRST
> +#undef BDESC_END
>
> -  IX86_BUILTIN_MAX
> +  /* Just to make sure there is no comma after the last enumerator.  */
> +  IX86_BUILTIN__BDESC_MAX_LAST = IX86_BUILTIN__BDESC_MAX_FIRST
>  };
>
>  /* Table for the ix86 builtin decls.  */
> @@ -33236,2475 +30862,6 @@ struct builtin_description
>    const int flag;
>  };
>
> -static const struct builtin_description bdesc_comi[] =
> -{
> -  { OPTION_MASK_ISA_SSE, CODE_FOR_sse_comi, "__builtin_ia32_comieq", IX86_BUILTIN_COMIEQSS, UNEQ, 0 },
> ...
> -
> -/* FMA4 and XOP.  */
>  #define MULTI_ARG_4_DF2_DI_I   V2DF_FTYPE_V2DF_V2DF_V2DI_INT
>  #define MULTI_ARG_4_DF2_DI_I1  V4DF_FTYPE_V4DF_V4DF_V4DI_INT
>  #define MULTI_ARG_4_SF2_SI_I   V4SF_FTYPE_V4SF_V4SF_V4SI_INT
> @@ -35758,199 +30915,20 @@ static const struct builtin_description
>  #define MULTI_ARG_1_QI_SI      V4SI_FTYPE_V16QI
>  #define MULTI_ARG_1_QI_HI      V8HI_FTYPE_V16QI
>
> -static const struct builtin_description bdesc_multi_arg[] =
> -{
> ...
> -  { OPTION_MASK_ISA_XOP, CODE_FOR_xop_vpermil2v8sf3,     "__builtin_ia32_vpermil2ps256", IX86_BUILTIN_VPERMIL2PS256, UNKNOWN, (int)MULTI_ARG_4_SF2_SI_I1 },
> -
> +#define BDESC(mask, icode, name, code, comparison, flag) \
> +  { mask, icode, name, code, comparison, flag },
> +#define BDESC_FIRST(kind, kindu, mask, icode, name, code, comparison, flag) \
> +static const struct builtin_description bdesc_##kind[] =                   \
> +{                                                                          \
> +  BDESC (mask, icode, name, code, comparison, flag)
> +#define BDESC_END(kind, next_kind) \
>  };
> +
> +#include "i386-builtin.def"
> +
> +#undef BDESC
> +#undef BDESC_FIRST
> +#undef BDESC_END
>
>  /* TM vector builtins.  */
>
> --- gcc/config/i386/i386-builtin.def.jj 2016-08-17 11:08:34.194237549 +0200
> +++ gcc/config/i386/i386-builtin.def    2016-08-17 12:32:21.374986264 +0200
> @@ -0,0 +1,2672 @@
> +/* Builtin functions for ia32.
> +   Copyright (C) 1988-2016 Free Software Foundation, Inc.
> +
> +   This file is part of GCC.
> +
> +   GCC is free software; you can redistribute it and/or modify it
> +   under the terms of the GNU General Public License as published
> +   by the Free Software Foundation; either version 3, or (at your
> +   option) any later version.
> +
> +   GCC is distributed in the hope that it will be useful, but WITHOUT
> +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
> +   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
> +   License for more details.
> +
> +   Under Section 7 of GPL version 3, you are granted additional
> +   permissions described in the GCC Runtime Library Exception, version
> +   3.1, as published by the Free Software Foundation.
> +
> +   You should have received a copy of the GNU General Public License and
> +   a copy of the GCC Runtime Library Exception along with this program;
> +   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +/* Before including this file, some macros must be defined:
> +   BDESC (mask, icode, name, code, comparison, flag)
> +     -- definition of each builtin
> +   BDESC_FIRST (kind, KIND, mask, icode, name, code, comparison, flag)
> +     -- like BDESC, but used for the first builtin in each category;
> +       bdesc_##kind will be used in the name of the array and
> +       IX86_BUILTIN__BDESC_##KIND##_FIRST will be the low boundary
> +   BDESC_END (KIND, NEXT_KIND)
> +     -- marks the end of bdesc_##kind, defines
> +        IX86_BUILTIN__BDESC_##KIND##_LAST to be
> +        IX86_BUILTIN__BDESC_##NEXT_KIND##_FIRST - 1.  */
> +
> +BDESC_FIRST (comi, COMI,
> +       OPTION_MASK_ISA_SSE, CODE_FOR_sse_comi, "__builtin_ia32_comieq", IX86_BUILTIN_COMIEQSS, UNEQ, 0)
> +BDESC (OPTION_MASK_ISA_SSE, CODE_FOR_sse_comi, "__builtin_ia32_comilt", IX86_BUILTIN_COMILTSS, UNLT, 0)
> ...
> +BDESC (OPTION_MASK_ISA_SSE2, CODE_FOR_sse2_ucomi, "__builtin_ia32_ucomisdneq", IX86_BUILTIN_UCOMINEQSD, LTGT, 0)
> +
> +BDESC_END (COMI, PCMPESTR)
> +
> +/* SSE4.2 */
> +BDESC_FIRST (pcmpestr, PCMPESTR,
> +       OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpestr, "__builtin_ia32_pcmpestri128", IX86_BUILTIN_PCMPESTRI128, UNKNOWN, 0)
> ...
> +BDESC (OPTION_MASK_ISA_XOP, CODE_FOR_xop_vpermil2v8sf3,     "__builtin_ia32_vpermil2ps256", IX86_BUILTIN_VPERMIL2PS256, UNKNOWN, (int)MULTI_ARG_4_SF2_SI_I1)
> +
> +BDESC_END (MULTI_ARG, MAX)
>
>
>         Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]