[PATCH 05/20] x86/asm: Always use flag output operands
From: Josh Poimboeuf
Date: Fri Mar 14 2025 - 17:48:54 EST
On x86, __GCC_ASM_FLAG_OUTPUTS__ is supported starting with GCC 6.0 and
Clang 9.
Now that the GCC minimum version on x86 has been bumped to 8.1 with the
following commit:
commit a3e8fe814ad1 ("x86/build: Raise the minimum GCC version to 8.1")
the flag output operand support can be assumed everywhere.
Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
---
arch/x86/include/asm/asm.h | 9 ++-------
arch/x86/include/asm/rmwcc.h | 22 ----------------------
tools/arch/x86/include/asm/asm.h | 5 -----
tools/perf/bench/find-bit-bench.c | 4 ----
4 files changed, 2 insertions(+), 38 deletions(-)
diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h
index 975ae7a9397e..fdebd4356860 100644
--- a/arch/x86/include/asm/asm.h
+++ b/arch/x86/include/asm/asm.h
@@ -131,13 +131,8 @@ static __always_inline __pure void *rip_rel_ptr(void *p)
* Macros to generate condition code outputs from inline assembly,
* The output operand must be type "bool".
*/
-#ifdef __GCC_ASM_FLAG_OUTPUTS__
-# define CC_SET(c) "\n\t/* output condition code " #c "*/\n"
-# define CC_OUT(c) "=@cc" #c
-#else
-# define CC_SET(c) "\n\tset" #c " %[_cc_" #c "]\n"
-# define CC_OUT(c) [_cc_ ## c] "=qm"
-#endif
+#define CC_SET(c) "\n\t/* output condition code " #c "*/\n"
+#define CC_OUT(c) "=@cc" #c
#ifdef __KERNEL__
diff --git a/arch/x86/include/asm/rmwcc.h b/arch/x86/include/asm/rmwcc.h
index 363266cbcada..a54303e3dfa1 100644
--- a/arch/x86/include/asm/rmwcc.h
+++ b/arch/x86/include/asm/rmwcc.h
@@ -6,26 +6,6 @@
#define __CLOBBERS_MEM(clb...) "memory", ## clb
-#ifndef __GCC_ASM_FLAG_OUTPUTS__
-
-/* Use asm goto */
-
-#define __GEN_RMWcc(fullop, _var, cc, clobbers, ...) \
-({ \
- bool c = false; \
- asm goto (fullop "; j" #cc " %l[cc_label]" \
- : : [var] "m" (_var), ## __VA_ARGS__ \
- : clobbers : cc_label); \
- if (0) { \
-cc_label: c = true; \
- } \
- c; \
-})
-
-#else /* defined(__GCC_ASM_FLAG_OUTPUTS__) */
-
-/* Use flags output or a set instruction */
-
#define __GEN_RMWcc(fullop, _var, cc, clobbers, ...) \
({ \
bool c; \
@@ -35,8 +15,6 @@ cc_label: c = true; \
c; \
})
-#endif /* defined(__GCC_ASM_FLAG_OUTPUTS__) */
-
#define GEN_UNARY_RMWcc_4(op, var, cc, arg0) \
__GEN_RMWcc(op " " arg0, var, cc, __CLOBBERS_MEM())
diff --git a/tools/arch/x86/include/asm/asm.h b/tools/arch/x86/include/asm/asm.h
index 3ad3da9a7d97..f66cf34f6197 100644
--- a/tools/arch/x86/include/asm/asm.h
+++ b/tools/arch/x86/include/asm/asm.h
@@ -112,13 +112,8 @@
* Macros to generate condition code outputs from inline assembly,
* The output operand must be type "bool".
*/
-#ifdef __GCC_ASM_FLAG_OUTPUTS__
# define CC_SET(c) "\n\t/* output condition code " #c "*/\n"
# define CC_OUT(c) "=@cc" #c
-#else
-# define CC_SET(c) "\n\tset" #c " %[_cc_" #c "]\n"
-# define CC_OUT(c) [_cc_ ## c] "=qm"
-#endif
#ifdef __KERNEL__
diff --git a/tools/perf/bench/find-bit-bench.c b/tools/perf/bench/find-bit-bench.c
index 7e25b0e413f6..99d36dff9d86 100644
--- a/tools/perf/bench/find-bit-bench.c
+++ b/tools/perf/bench/find-bit-bench.c
@@ -37,7 +37,6 @@ static noinline void workload(int val)
accumulator++;
}
-#if (defined(__i386__) || defined(__x86_64__)) && defined(__GCC_ASM_FLAG_OUTPUTS__)
static bool asm_test_bit(long nr, const unsigned long *addr)
{
bool oldbit;
@@ -48,9 +47,6 @@ static bool asm_test_bit(long nr, const unsigned long *addr)
return oldbit;
}
-#else
-#define asm_test_bit test_bit
-#endif
static int do_for_each_set_bit(unsigned int num_bits)
{
--
2.48.1