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] Remove __builtin_ia32_readeflags_u32/__builtin_ia32_writeeflags_u32 builtins for TARGET_64BIT (PR target/85511)


On Tue, Apr 24, 2018 at 2:51 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> These two *_u32 builtins are defined also in -m64 mode, but share the
> builtin codes with the *_u64 ones and the expansion of them uses word_mode.
>
> The following patch just removes them, ia32intrin.h uses the u32 suffixed
> ones only when __x86_64__ is not defined, bootstrapped/regtested on
> x86_64-linux and i686-linux, ok for trunk?
>
> A variant would be to use separate IX86_BUILTIN_ codes for the 32-bit and
> 64-bit builtins and add separate expansion for them, but that looks like
> overkill to me, people should use __readeflags/__writeeflags anyway and
> those do the right thing.
>
> 2018-04-24  Jakub Jelinek  <jakub@redhat.com>
>
>         PR target/85511
>         * config/i386/i386.c (ix86_init_mmx_sse_builtins): Don't define
>         __builtin_ia32_readeflags_u32 and __builtin_ia32_writeeflags_u32
>         if TARGET_64BIT.
>
>         * gcc.target/i386/pr85511.c: New test.

OK.

Thanks,
Uros.

> --- gcc/config/i386/i386.c.jj   2018-04-24 09:37:36.029459208 +0200
> +++ gcc/config/i386/i386.c      2018-04-24 10:37:01.258882134 +0200
> @@ -31934,14 +31934,20 @@ ix86_init_mmx_sse_builtins (void)
>                IX86_BUILTIN_SBB64);
>
>    /* Read/write FLAGS.  */
> -  def_builtin (0, "__builtin_ia32_readeflags_u32",
> -               UNSIGNED_FTYPE_VOID, IX86_BUILTIN_READ_FLAGS);
> -  def_builtin (OPTION_MASK_ISA_64BIT, "__builtin_ia32_readeflags_u64",
> -               UINT64_FTYPE_VOID, IX86_BUILTIN_READ_FLAGS);
> -  def_builtin (0, "__builtin_ia32_writeeflags_u32",
> -               VOID_FTYPE_UNSIGNED, IX86_BUILTIN_WRITE_FLAGS);
> -  def_builtin (OPTION_MASK_ISA_64BIT, "__builtin_ia32_writeeflags_u64",
> -               VOID_FTYPE_UINT64, IX86_BUILTIN_WRITE_FLAGS);
> +  if (TARGET_64BIT)
> +    {
> +      def_builtin (OPTION_MASK_ISA_64BIT, "__builtin_ia32_readeflags_u64",
> +                  UINT64_FTYPE_VOID, IX86_BUILTIN_READ_FLAGS);
> +      def_builtin (OPTION_MASK_ISA_64BIT, "__builtin_ia32_writeeflags_u64",
> +                  VOID_FTYPE_UINT64, IX86_BUILTIN_WRITE_FLAGS);
> +    }
> +  else
> +    {
> +      def_builtin (0, "__builtin_ia32_readeflags_u32",
> +                  UNSIGNED_FTYPE_VOID, IX86_BUILTIN_READ_FLAGS);
> +      def_builtin (0, "__builtin_ia32_writeeflags_u32",
> +                  VOID_FTYPE_UNSIGNED, IX86_BUILTIN_WRITE_FLAGS);
> +    }
>
>    /* CLFLUSHOPT.  */
>    def_builtin (OPTION_MASK_ISA_CLFLUSHOPT, "__builtin_ia32_clflushopt",
> --- gcc/testsuite/gcc.target/i386/pr85511.c.jj  2018-04-24 10:45:18.099260629 +0200
> +++ gcc/testsuite/gcc.target/i386/pr85511.c     2018-04-24 10:47:46.069374103 +0200
> @@ -0,0 +1,15 @@
> +/* PR target/85511 */
> +/* { dg-do compile } */
> +/* { dg-options "-Wimplicit-function-declaration" } */
> +
> +unsigned int
> +foo (void)
> +{
> +  return __builtin_ia32_readeflags_u32 ();     /* { dg-warning "implicit declaration of function" "" { target { ! ia32 } } } */
> +}
> +
> +void
> +bar (unsigned int x)
> +{
> +  __builtin_ia32_writeeflags_u32 (x);          /* { dg-warning "implicit declaration of function" "" { target { ! ia32 } } } */
> +}
>
>         Jakub


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