]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
i386: Fix emissing of __builtin_cpu_supports.
authorMartin Liska <mliska@suse.cz>
Mon, 13 Dec 2021 14:34:30 +0000 (15:34 +0100)
committerMartin Liska <mliska@suse.cz>
Wed, 15 Dec 2021 09:30:45 +0000 (10:30 +0100)
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

index 0fb14b5571276034f846dc31fb73e7bb65e195ce..4b30cf75c26f1c14d31555fe23c56d09a46eda27 100644 (file)
@@ -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 == (INT_TYPE_SIZE - 1))
+       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 ();
 }