public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: "Martin Liška" <mliska@suse.cz>
Cc: gcc-patches@gcc.gnu.org, Stefan Kneifel <stefan.kneifel@bluewin.ch>
Subject: Re: [PATCH] i386: Fix emissing of __builtin_cpu_supports.
Date: Tue, 14 Dec 2021 17:12:19 +0100	[thread overview]
Message-ID: <20211214161219.GX2646553@tucnak> (raw)
In-Reply-To: <80d628c2-ea0d-c542-b0bb-399d83b7292d@suse.cz>

On Tue, Dec 14, 2021 at 04:07:55PM +0100, Martin Liška wrote:
> On 12/14/21 11:28, Jakub Jelinek wrote:
> > Wouldn't this be better done only if field_val has the msb set
> 
> Yes, updated in the attached patch.
> 
> > and keep the CONVERT_EXPR otherwise (why isn't it NOP_EXPR?)?
> 
> Dunno, but I can prepare a separate patch (likely stage1 material,
> right)? Note that are other places that also use CONVERT_EXPR.
> 
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> 
> Ready to be installed?
> Thanks,
> Martin

> From 227450e9f3a506fdfcff67aa45135fe31f3f91f6 Mon Sep 17 00:00:00 2001
> From: Martin Liska <mliska@suse.cz>
> Date: Mon, 13 Dec 2021 15:34:30 +0100
> Subject: [PATCH] i386: Fix emissing of __builtin_cpu_supports.
> 
> 	PR target/103661
> 
> gcc/ChangeLog:
> 
> 	* config/i386/i386-builtins.c (fold_builtin_cpu): Compare to 0
> 	as API expects that non-zero values are returned (do that
> 	it mask == 31).
> 	For "avx512vbmi2" argument, we return now 1 << 31, which is a
> 	negative integer value.
> ---
>  gcc/config/i386/i386-builtins.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/gcc/config/i386/i386-builtins.c b/gcc/config/i386/i386-builtins.c
> index 0fb14b55712..bca244fc011 100644
> --- a/gcc/config/i386/i386-builtins.c
> +++ b/gcc/config/i386/i386-builtins.c
> @@ -2353,7 +2353,11 @@ fold_builtin_cpu (tree fndecl, tree *args)
>        /* Return __cpu_model.__cpu_features[0] & field_val  */
>        final = build2 (BIT_AND_EXPR, unsigned_type_node, array_elt,
>  		      build_int_cstu (unsigned_type_node, field_val));
> -      return build1 (CONVERT_EXPR, integer_type_node, final);
> +      if (isa_names_table[i].feature == 31)
> +	return build2 (NE_EXPR, integer_type_node, final,
> +		       build_int_cst (unsigned_type_node, 0));
> +      else
> +	return build1 (CONVERT_EXPR, integer_type_node, final);
>      }
>    gcc_unreachable ();
>  }

I'd use INT_TYPE_SIZE - 1 instead of 31.  Otherwise LGTM.

	Jakub


  reply	other threads:[~2021-12-14 16:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-14  9:55 Martin Liška
2021-12-14 10:28 ` Jakub Jelinek
2021-12-14 15:07   ` Martin Liška
2021-12-14 16:12     ` Jakub Jelinek [this message]
2021-12-15  9:57       ` [PATCH] i386: simplify cpu_feature handling Martin Liška
2021-12-16 20:58         ` Stefan Kneifel
2021-12-17  8:50           ` Martin Liška
2022-01-03 11:43         ` Martin Liška
2022-03-31  7:01           ` Martin Liška
2022-05-02  7:57             ` Martin Liška
2022-05-11  8:19               ` Martin Liška
2022-05-11  8:27                 ` Uros Bizjak
2022-05-11  8:50                   ` Martin Liška
2022-05-11  8:57                     ` Uros Bizjak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211214161219.GX2646553@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mliska@suse.cz \
    --cc=stefan.kneifel@bluewin.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).