From: "H.J. Lu" <hjl.tools@gmail.com>
To: Sunil K Pandey <skpgkp2@gmail.com>, Florian Weimer <fweimer@redhat.com>
Cc: Libc-stable Mailing List <libc-stable@sourceware.org>
Subject: Re: [PATCH] x86-64: Simplify minimum ISA check ifdef conditional with if
Date: Sat, 13 Apr 2024 08:59:59 -0700 [thread overview]
Message-ID: <CAMe9rOoCwh=+nDdHr2-MtUGCfYQEiapSrdknYd_F7ydLhpY0rw@mail.gmail.com> (raw)
In-Reply-To: <CAMe9rOr6tLZ5Na8XN1QMa4zO2kNw1+cW2E9g=-wat+tQVNqNAA@mail.gmail.com>
On Sun, Mar 3, 2024 at 1:46 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Fri, Mar 1, 2024 at 4:40 PM Sunil K Pandey <skpgkp2@gmail.com> wrote:
> >
> > Replace minimum ISA check ifdef conditional with if. Since
> > MINIMUM_X86_ISA_LEVEL and AVX_X86_ISA_LEVEL are compile time constants,
> > compiler will perform constant folding optimization getting same result.
> > ---
> > sysdeps/x86/cpu-features.c | 19 ++++++++-----------
> > 1 file changed, 8 insertions(+), 11 deletions(-)
> >
> > diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
> > index e7c7ece462..4ea373dffa 100644
> > --- a/sysdeps/x86/cpu-features.c
> > +++ b/sysdeps/x86/cpu-features.c
> > @@ -1196,9 +1196,8 @@ no_cpuid:
> > TUNABLE_CALLBACK (set_x86_shstk));
> > #endif
> >
> > -#if MINIMUM_X86_ISA_LEVEL < AVX_X86_ISA_LEVEL
> > - if (GLRO(dl_x86_cpu_features).xsave_state_size != 0)
> > -#endif
> > + if (MINIMUM_X86_ISA_LEVEL >= AVX_X86_ISA_LEVEL
> > + || (GLRO(dl_x86_cpu_features).xsave_state_size != 0))
> > {
> > if (CPU_FEATURE_USABLE_P (cpu_features, XSAVEC))
> > {
> > @@ -1219,24 +1218,22 @@ no_cpuid:
> > #endif
> > }
> > }
> > -#if MINIMUM_X86_ISA_LEVEL < AVX_X86_ISA_LEVEL
> > else
> > {
> > -# ifdef __x86_64__
> > +#ifdef __x86_64__
> > GLRO(dl_x86_64_runtime_resolve) = _dl_runtime_resolve_fxsave;
> > -# ifdef SHARED
> > +# ifdef SHARED
> > GLRO(dl_x86_tlsdesc_dynamic) = _dl_tlsdesc_dynamic_fxsave;
> > -# endif
> > -# else
> > -# ifdef SHARED
> > +# endif
> > +#else
> > +# ifdef SHARED
> > if (CPU_FEATURE_USABLE_P (cpu_features, FXSR))
> > GLRO(dl_x86_tlsdesc_dynamic) = _dl_tlsdesc_dynamic_fxsave;
> > else
> > GLRO(dl_x86_tlsdesc_dynamic) = _dl_tlsdesc_dynamic_fnsave;
> > -# endif
> > # endif
> > - }
> > #endif
> > + }
> >
> > #ifdef SHARED
> > # ifdef __x86_64__
> > --
> > 2.43.0
> >
>
> LGTM.
>
> Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
>
> Thanks.
>
> --
> H.J.
Should it also be backported to glibc 2.39 together with
commit befe2d3c4dec8be2cdd01a47132e47bdb7020922
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Feb 28 09:51:14 2024 -0800
x86-64: Don't use SSE resolvers for ISA level 3 or above
--
H.J.
next parent reply other threads:[~2024-04-13 16:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAMAf5_fVOYmBsTsfNHNQOBXjLYRF=NQ2gAduJMFwkPOMcW4yCw@mail.gmail.com>
[not found] ` <20240302003843.3333713-1-skpgkp2@gmail.com>
[not found] ` <CAMe9rOr6tLZ5Na8XN1QMa4zO2kNw1+cW2E9g=-wat+tQVNqNAA@mail.gmail.com>
2024-04-13 15:59 ` H.J. Lu [this message]
2024-04-13 17:52 ` Florian Weimer
2024-04-13 18:04 ` H.J. Lu
2024-04-13 18:22 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMe9rOoCwh=+nDdHr2-MtUGCfYQEiapSrdknYd_F7ydLhpY0rw@mail.gmail.com' \
--to=hjl.tools@gmail.com \
--cc=fweimer@redhat.com \
--cc=libc-stable@sourceware.org \
--cc=skpgkp2@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).