Skip to content

Commit

Permalink
x86: Don't enable APX_F in 32-bit mode
Browse files Browse the repository at this point in the history
gcc/ChangeLog:

	PR target/115978
	* config/i386/driver-i386.cc (host_detect_local_cpu):  Enable
	APX_F only for 64-bit codegen.
	* config/i386/i386-options.cc (DEF_PTA):  Skip PTA_APX_F if
	not in 64-bit mode.

gcc/testsuite/ChangeLog:

	PR target/115978
	* gcc.target/i386/pr115978-1.c: New test.
	* gcc.target/i386/pr115978-2.c: Ditto.
  • Loading branch information
konglingling7 committed Jul 30, 2024
1 parent 7c688e0 commit ee6c5af
Showing 4 changed files with 32 additions and 2 deletions.
3 changes: 2 additions & 1 deletion gcc/config/i386/driver-i386.cc
Original file line number Diff line number Diff line change
@@ -893,7 +893,8 @@ const char *host_detect_local_cpu (int argc, const char **argv)
if (has_feature (isa_names_table[i].feature))
{
if (codegen_x86_64
|| isa_names_table[i].feature != FEATURE_UINTR)
|| (isa_names_table[i].feature != FEATURE_UINTR
&& isa_names_table[i].feature != FEATURE_APX_F))
options = concat (options, " ",
isa_names_table[i].option, NULL);
}
3 changes: 2 additions & 1 deletion gcc/config/i386/i386-options.cc
Original file line number Diff line number Diff line change
@@ -2385,7 +2385,8 @@ ix86_option_override_internal (bool main_args_p,
#define DEF_PTA(NAME) \
if (((processor_alias_table[i].flags & PTA_ ## NAME) != 0) \
&& PTA_ ## NAME != PTA_64BIT \
&& (TARGET_64BIT || PTA_ ## NAME != PTA_UINTR) \
&& (TARGET_64BIT || (PTA_ ## NAME != PTA_UINTR \
&& PTA_ ## NAME != PTA_APX_F))\
&& !TARGET_EXPLICIT_ ## NAME ## _P (opts)) \
SET_TARGET_ ## NAME (opts);
#include "i386-isa.def"
22 changes: 22 additions & 0 deletions gcc/testsuite/gcc.target/i386/pr115978-1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* { dg-do run } */
/* { dg-options "-O2 -march=native" } */

int
main ()
{
if (__builtin_cpu_supports ("apxf"))
{
#ifdef __x86_64__
# ifndef __APX_F__
__builtin_abort ();
# endif
#else
# ifdef __APX_F__
__builtin_abort ();
# endif
#endif
return 0;
}

return 0;
}
6 changes: 6 additions & 0 deletions gcc/testsuite/gcc.target/i386/pr115978-2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O2 -march=native -mno-apxf" } */

#ifdef __APX_F__
# error APX_F should be disabled
#endif

0 comments on commit ee6c5af

Please sign in to comment.