From: H.J. Lu Date: Fri, 30 Jul 2021 12:58:38 +0000 (-0700) Subject: x86: Don't enable LZCNT/POPCNT if disabled explicitly X-Git-Tag: basepoints/gcc-13~5689 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=854ef6e50acf1b182ddaf007cff2cf60545692b0;p=thirdparty%2Fgcc.git x86: Don't enable LZCNT/POPCNT if disabled explicitly gcc/ PR target/101685 * config/i386/i386-options.c (ix86_option_override_internal): Don't enable LZCNT/POPCNT if they have been disabled explicitly. gcc/testsuite/ PR target/101685 * gcc.target/i386/pr101685.c: New test. --- diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c index 3416a4f17523..6b789988baa4 100644 --- a/gcc/config/i386/i386-options.c +++ b/gcc/config/i386/i386-options.c @@ -2124,8 +2124,10 @@ ix86_option_override_internal (bool main_args_p, if (((processor_alias_table[i].flags & PTA_ABM) != 0) && !TARGET_EXPLICIT_ABM_P (opts)) { - SET_TARGET_LZCNT (opts); - SET_TARGET_POPCNT (opts); + if (!TARGET_EXPLICIT_LZCNT_P (opts)) + SET_TARGET_LZCNT (opts); + if (!TARGET_EXPLICIT_POPCNT_P (opts)) + SET_TARGET_POPCNT (opts); } if ((processor_alias_table[i].flags diff --git a/gcc/testsuite/gcc.target/i386/pr101685.c b/gcc/testsuite/gcc.target/i386/pr101685.c new file mode 100644 index 000000000000..0c743ecad006 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr101685.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=amdfam10 -mno-lzcnt -mno-popcnt" } */ + +#ifdef __LZCNT__ +# error LZCNT should be disabled +#endif + +#ifdef __POPCNT__ +# error POPCNT should be disabled +#endif