public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] i386: Fix emissing of __builtin_cpu_supports.
@ 2021-12-14  9:55 Martin Liška
  2021-12-14 10:28 ` Jakub Jelinek
  0 siblings, 1 reply; 14+ messages in thread
From: Martin Liška @ 2021-12-14  9:55 UTC (permalink / raw)
  To: gcc-patches; +Cc: Stefan Kneifel

The patch fixes __builtin_cpu_supports("avx512vbmi2") which returns a negative
value (that's not allowed in the documentation).

I also checked ppc target that does the same, and __builtin_cpu_is, which
are fine.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin	

	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.  For
	"avx512vbmi2" argument, we return now 1 << 31, which is a
	negative integer value.
---
  gcc/config/i386/i386-builtins.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/config/i386/i386-builtins.c b/gcc/config/i386/i386-builtins.c
index 0fb14b55712..7e57b665c1e 100644
--- a/gcc/config/i386/i386-builtins.c
+++ b/gcc/config/i386/i386-builtins.c
@@ -2353,7 +2353,8 @@ 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);
+      return build2 (NE_EXPR, integer_type_node, final,
+		     build_int_cst (unsigned_type_node, 0));
      }
    gcc_unreachable ();
  }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-05-11  8:57 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14  9:55 [PATCH] i386: Fix emissing of __builtin_cpu_supports 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
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

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).