diff mbox series

x86: Don't enable LZCNT/POPCNT if disabled explicitly

Message ID 20210730130407.1733336-1-hjl.tools@gmail.com
State New
Headers show
Series x86: Don't enable LZCNT/POPCNT if disabled explicitly | expand

Commit Message

H.J. Lu July 30, 2021, 1:04 p.m. UTC
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/pr-101685.c: New test.
---
 gcc/config/i386/i386-options.c            |  6 ++++--
 gcc/testsuite/gcc.target/i386/pr-101685.c | 10 ++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr-101685.c

Comments

Uros Bizjak July 30, 2021, 1:39 p.m. UTC | #1
On Fri, Jul 30, 2021 at 3:04 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> 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/pr-101685.c: New test.

OK.

Thanks,
Uros.

> ---
>  gcc/config/i386/i386-options.c            |  6 ++++--
>  gcc/testsuite/gcc.target/i386/pr-101685.c | 10 ++++++++++
>  2 files changed, 14 insertions(+), 2 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/i386/pr-101685.c
>
> diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c
> index 3416a4f1752..6b789988baa 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/pr-101685.c b/gcc/testsuite/gcc.target/i386/pr-101685.c
> new file mode 100644
> index 00000000000..0c743ecad00
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr-101685.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
> --
> 2.31.1
>
Jakub Jelinek July 30, 2021, 1:42 p.m. UTC | #2
On Fri, Jul 30, 2021 at 03:39:03PM +0200, Uros Bizjak via Gcc-patches wrote:
> On Fri, Jul 30, 2021 at 3:04 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > 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/pr-101685.c: New test.

Can you please remove the hyphen from the test name?  We don't have
any pr-*.c tests...
> 
> OK.

	Jakub
H.J. Lu July 30, 2021, 1:48 p.m. UTC | #3
On Fri, Jul 30, 2021 at 6:42 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Fri, Jul 30, 2021 at 03:39:03PM +0200, Uros Bizjak via Gcc-patches wrote:
> > On Fri, Jul 30, 2021 at 3:04 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >
> > > 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/pr-101685.c: New test.
>
> Can you please remove the hyphen from the test name?  We don't have
> any pr-*.c tests...

Will do.

> >
> > OK.
>
>         Jakub
>
diff mbox series

Patch

diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c
index 3416a4f1752..6b789988baa 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/pr-101685.c b/gcc/testsuite/gcc.target/i386/pr-101685.c
new file mode 100644
index 00000000000..0c743ecad00
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr-101685.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