public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] x86/bitops: Use TZCNT mnemonic in <asm/bitops.h>
@ 2025-03-25 17:52 Uros Bizjak
  2025-03-25 17:52 ` [PATCH 2/2] x86/bitops: Fix false output register dependency of TZCNT insn Uros Bizjak
  2025-03-25 21:48 ` [tip: x86/asm] x86/bitops: Use TZCNT mnemonic in <asm/bitops.h> tip-bot2 for Uros Bizjak
  0 siblings, 2 replies; 9+ messages in thread
From: Uros Bizjak @ 2025-03-25 17:52 UTC (permalink / raw)
  To: x86, linux-kernel
  Cc: Uros Bizjak, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, H. Peter Anvin

Current minimum required version of binutils is 2.25,
which supports TZCNT instruction mnemonic.

Replace "REP; BSF" in variable__{ffs,ffz}() function
with this proper mnemonic.

No functional change intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
 arch/x86/include/asm/bitops.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
index 100413aff640..bbaf75ea6703 100644
--- a/arch/x86/include/asm/bitops.h
+++ b/arch/x86/include/asm/bitops.h
@@ -248,7 +248,7 @@ arch_test_bit_acquire(unsigned long nr, const volatile unsigned long *addr)
 
 static __always_inline unsigned long variable__ffs(unsigned long word)
 {
-	asm("rep; bsf %1,%0"
+	asm("tzcnt %1,%0"
 		: "=r" (word)
 		: ASM_INPUT_RM (word));
 	return word;
@@ -267,7 +267,7 @@ static __always_inline unsigned long variable__ffs(unsigned long word)
 
 static __always_inline unsigned long variable_ffz(unsigned long word)
 {
-	asm("rep; bsf %1,%0"
+	asm("tzcnt %1,%0"
 		: "=r" (word)
 		: "r" (~word));
 	return word;
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-03-29  8:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-25 17:52 [PATCH 1/2] x86/bitops: Use TZCNT mnemonic in <asm/bitops.h> Uros Bizjak
2025-03-25 17:52 ` [PATCH 2/2] x86/bitops: Fix false output register dependency of TZCNT insn Uros Bizjak
2025-03-25 17:59   ` Borislav Petkov
2025-03-25 18:29   ` H. Peter Anvin
2025-03-25 21:43   ` Ingo Molnar
2025-03-26  8:46     ` Uros Bizjak
2025-03-28 22:27       ` Ingo Molnar
2025-03-29  8:48         ` Uros Bizjak
2025-03-25 21:48 ` [tip: x86/asm] x86/bitops: Use TZCNT mnemonic in <asm/bitops.h> tip-bot2 for Uros Bizjak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox