[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wgfk69H-T-vMWR33xUpVsWJLrF34d0OwUXa2sHhtpSwZg@mail.gmail.com>
Date: Sat, 26 Apr 2025 12:55:13 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Arnd Bergmann <arnd@...db.de>
Cc: Ingo Molnar <mingo@...nel.org>, Arnd Bergmann <arnd@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>, Juergen Gross <jgross@...e.com>,
Boris Ostrovsky <boris.ostrovsky@...cle.com>,
Alexander Usyskin <alexander.usyskin@...el.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Mateusz Jończyk <mat.jonczyk@...pl>,
Mike Rapoport <rppt@...nel.org>, Ard Biesheuvel <ardb@...nel.org>, Peter Zijlstra <peterz@...radead.org>,
linux-kernel@...r.kernel.org, xen-devel@...ts.xenproject.org
Subject: Re: [PATCH] [RFC] x86/cpu: rework instruction set selection
On Sat, 26 Apr 2025 at 12:24, Linus Torvalds
<torvalds@...ux-foundation.org> wrote:
>
> (And yes, one use in a x86 header file that is pretty questionable
> too: I think the reason for the cmov is actually i486-only behavior
> and we could probably unify the 32-bit and 64-bit implementation)
Actually, what we *should* do is to remove that manual use of 'cmov'
entirely - even if we decide that yes, that undefined zero case is
actually real.
We should probably change it to use CC_SET(), and the compiler will do
a much better job - and probably never use cmov anyway.
And yes, that will generate worse code if you have an old compiler
that doesn't do ASM_FLAG_OUTPUTS, but hey, that's true in general. If
you want good code, you need a good compiler.
And clang needs to learn the CC_SET() pattern anyway.
So I think that manual cmov pattern for x86-32 should be replaced with
bool zero;
asm("bsfl %[in],%[out]"
CC_SET(z)
: CC_OUT(z) (zero),
[out]"=r" (r)
: [in] "rm" (x));
return zero ? 0 : r+1;
instead (that's ffs(), and fls() would need the same thing except with
bsrl insteadm, of course).
I bet that would actually improve code generation.
And I also bet it doesn't actually matter, of course.
Linus
Powered by blists - more mailing lists