https://gcc.gnu.org/g:ac08d3095b031446cca5d7364b5138fc33be2f3f
commit ac08d3095b031446cca5d7364b5138fc33be2f3f Author: Michael Meissner <[email protected]> Date: Wed Nov 5 00:50:08 2025 -0500 Eliminate -mbfloat16, just use -mfloat16. 2025-11-05 Michael Meissner <[email protected]> gcc/ * config/rs6000/float16.md (FP16): Use TARGET_FLOAT16 instead of TARGET_BFLOAT16. (VFP16): Likewise. * config/rs6000/rs6000-builtin.cc (rs6000_type_string): Likewise. (rs6000_init_builtins): Likewise. * config/rs6000/rs6000-c.cc (rs6000_target_modify_macros): Likewise. * config/rs6000/rs6000.cc (rs6000_init_hard_regno_mode_ok): Likewise. (rs6000_init_hard_regno_mode_ok): Likewise. (rs6000_option_override_internal): Likewise. (rs6000_opt_masks): Likewise. * config/rs6000/rs6000.h (TARGET_BFLOAT16_HW): Likewise. (FP16_SCALAR_MODE_P): Likewise. (FP16_VECTOR_MODE_P): Likewise. * config/rs6000/rs6000.md (BOOL_128): Use TARGET_ALTIVEC for V8HFmode and V8BFmode. * config/rs6000/rs6000.opt (-mbfloat): Delete. (-mfloat16-gpr-args): Reword. libgcc/ * config.host (powerpc*-*-linux*): Delete -mbfloat16 support, just use -mfloat16. * config/rs6000/t-float16: Likewise. * configure.ac (powerpc*-*-linux*): Likewise. * configure: Regenerate. * config/rs6000/t-bfloat16: Delete. * config/rs6000/t-both-fp16: Likewise. Diff: --- gcc/config/rs6000/float16.md | 4 ++-- gcc/config/rs6000/rs6000-builtin.cc | 4 ++-- gcc/config/rs6000/rs6000-c.cc | 6 +----- gcc/config/rs6000/rs6000.cc | 35 +++++++---------------------------- gcc/config/rs6000/rs6000.h | 10 ++++------ gcc/config/rs6000/rs6000.md | 4 ++-- gcc/config/rs6000/rs6000.opt | 4 ++-- libgcc/config.host | 8 -------- libgcc/config/rs6000/t-bfloat16 | 30 ------------------------------ libgcc/config/rs6000/t-both-fp16 | 28 ---------------------------- libgcc/config/rs6000/t-float16 | 36 +++++++++++++++++++++++++++++++++--- libgcc/configure | 21 --------------------- libgcc/configure.ac | 9 --------- 13 files changed, 53 insertions(+), 146 deletions(-) diff --git a/gcc/config/rs6000/float16.md b/gcc/config/rs6000/float16.md index b62cd3315143..f9c94811f34d 100644 --- a/gcc/config/rs6000/float16.md +++ b/gcc/config/rs6000/float16.md @@ -22,10 +22,10 @@ ;; Mode iterator for 16-bit floating point modes both as a scalar and ;; as a vector. -(define_mode_iterator FP16 [(BF "TARGET_BFLOAT16") +(define_mode_iterator FP16 [(BF "TARGET_FLOAT16") (HF "TARGET_FLOAT16")]) -(define_mode_iterator VFP16 [(V8BF "TARGET_BFLOAT16") +(define_mode_iterator VFP16 [(V8BF "TARGET_FLOAT16") (V8HF "TARGET_FLOAT16")]) ;; Mode iterator for 16-bit floating point modes on machines with diff --git a/gcc/config/rs6000/rs6000-builtin.cc b/gcc/config/rs6000/rs6000-builtin.cc index 958b1392eee7..cdd41f2d6cca 100644 --- a/gcc/config/rs6000/rs6000-builtin.cc +++ b/gcc/config/rs6000/rs6000-builtin.cc @@ -493,7 +493,7 @@ const char *rs6000_type_string (tree type_node) return "_Float128"; else if (type_node == float16_type_node) return "_Float16"; - else if (TARGET_BFLOAT16 && type_node == bfloat16_type_node) + else if (TARGET_FLOAT16 && type_node == bfloat16_type_node) return "__bfloat16"; else if (type_node == vector_pair_type_node) return "__vector_pair"; @@ -761,7 +761,7 @@ rs6000_init_builtins (void) ieee128_float_type_node = NULL_TREE; /* __bfloat16 support. */ - if (TARGET_BFLOAT16) + if (TARGET_FLOAT16) { if (!bfloat16_type_node) { diff --git a/gcc/config/rs6000/rs6000-c.cc b/gcc/config/rs6000/rs6000-c.cc index 3b4d4c4a09ab..be874f2eb80b 100644 --- a/gcc/config/rs6000/rs6000-c.cc +++ b/gcc/config/rs6000/rs6000-c.cc @@ -590,13 +590,9 @@ rs6000_target_modify_macros (bool define_p, if ((flags & OPTION_MASK_FLOAT16) != 0) { rs6000_define_or_undefine_macro (define_p, "__FLOAT16__"); + rs6000_define_or_undefine_macro (define_p, "__BFLOAT16__"); if ((cpu_option & CPU_OPTION_POWER9_MASK) != 0) rs6000_define_or_undefine_macro (define_p, "__FLOAT16_HW__"); - } - - if ((flags & OPTION_MASK_BFLOAT16) != 0) - { - rs6000_define_or_undefine_macro (define_p, "__BFLOAT16__"); if ((cpu_option & CPU_OPTION_POWER10_MASK) != 0) rs6000_define_or_undefine_macro (define_p, "__BFLOAT16_HW__"); } diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 5b60c9791c13..c848bd5093fa 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -2946,17 +2946,12 @@ rs6000_init_hard_regno_mode_ok (bool global_init_p) rs6000_vector_align[V1TImode] = 128; } - /* _Float16 support. */ + /* _Float16 and __bfloat16 support. */ if (TARGET_FLOAT16) { rs6000_vector_mem[HFmode] = VECTOR_VSX; - rs6000_vector_align[HFmode] = 16; - } - - /* _bfloat16 support. */ - if (TARGET_BFLOAT16) - { rs6000_vector_mem[BFmode] = VECTOR_VSX; + rs6000_vector_align[HFmode] = 16; rs6000_vector_align[BFmode] = 16; } @@ -3077,12 +3072,8 @@ rs6000_init_hard_regno_mode_ok (bool global_init_p) if (TARGET_FLOAT16) { reg_addr[HFmode].reload_store = CODE_FOR_reload_hf_di_store; - reg_addr[HFmode].reload_load = CODE_FOR_reload_hf_di_load; - } - - if (TARGET_BFLOAT16) - { reg_addr[BFmode].reload_store = CODE_FOR_reload_bf_di_store; + reg_addr[HFmode].reload_load = CODE_FOR_reload_hf_di_load; reg_addr[BFmode].reload_load = CODE_FOR_reload_bf_di_load; } @@ -3189,12 +3180,8 @@ rs6000_init_hard_regno_mode_ok (bool global_init_p) if (TARGET_FLOAT16) { reg_addr[HFmode].reload_store = CODE_FOR_reload_hf_si_store; - reg_addr[HFmode].reload_load = CODE_FOR_reload_hf_si_load; - } - - if (TARGET_BFLOAT16) - { reg_addr[BFmode].reload_store = CODE_FOR_reload_bf_si_store; + reg_addr[HFmode].reload_load = CODE_FOR_reload_hf_si_load; reg_addr[BFmode].reload_load = CODE_FOR_reload_bf_si_load; } @@ -3937,9 +3924,9 @@ rs6000_option_override_internal (bool global_init_p) } } - /* -mfloat16 and -mbfloat16 needs power8 at a minimum in order to load up - 16-bit values into vector registers via loads/stores from GPRs and then - using direct moves. */ + /* -mfloat16 needs power8 at a minimum in order to load up 16-bit values into + vector registers via loads/stores from GPRs and then using direct + moves. */ if (TARGET_FLOAT16 && !TARGET_POWER8) { rs6000_isa_flags &= ~OPTION_MASK_FLOAT16; @@ -3947,13 +3934,6 @@ rs6000_option_override_internal (bool global_init_p) error ("%qs requires at least %qs", "-mfloat16", "-mcpu=power8"); } - if (TARGET_BFLOAT16 && !TARGET_POWER8) - { - rs6000_isa_flags &= ~OPTION_MASK_BFLOAT16; - if (rs6000_isa_flags_explicit & OPTION_MASK_BFLOAT16) - error ("%qs requires at least %qs", "-mbfloat16", "-mcpu=power8"); - } - /* If hard-float/altivec/vsx were explicitly turned off then don't allow the -mcpu setting to enable options that conflict. */ if ((!TARGET_HARD_FLOAT || !TARGET_ALTIVEC || !TARGET_VSX) @@ -24630,7 +24610,6 @@ struct rs6000_opt_mask { static struct rs6000_opt_mask const rs6000_opt_masks[] = { { "altivec", OPTION_MASK_ALTIVEC, false, true }, - { "bfloat16", OPTION_MASK_BFLOAT16, false, true }, { "block-ops-unaligned-vsx", OPTION_MASK_BLOCK_OPS_UNALIGNED_VSX, false, true }, { "block-ops-vector-pair", OPTION_MASK_BLOCK_OPS_VECTOR_PAIR, diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index a17aaa785f31..1b648d0506f9 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -344,21 +344,20 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); || (!TARGET_FLOAT128_TYPE && FLOAT128_IEEE_P (MODE))) /* Do we have conversion support in hardware for the 16-bit floating point? */ -#define TARGET_BFLOAT16_HW (TARGET_BFLOAT16 && TARGET_POWER10) +#define TARGET_BFLOAT16_HW (TARGET_FLOAT16 && TARGET_POWER10) #define TARGET_FLOAT16_HW (TARGET_FLOAT16 && TARGET_POWER9) /* Do we have conversion support in hardware for the 16-bit floating point and also enable the 16-bit floating point vector optimizations? */ #define TARGET_BFLOAT16_HW_VECTOR \ - (TARGET_BFLOAT16 && TARGET_POWER10 && TARGET_BFLOAT16_VECTOR) + (TARGET_FLOAT16 && TARGET_POWER10 && TARGET_BFLOAT16_VECTOR) #define TARGET_FLOAT16_HW_VECTOR \ (TARGET_FLOAT16 && TARGET_POWER9 && TARGET_FLOAT16_VECTOR) /* Is this a valid 16-bit scalar floating point mode? */ #define FP16_SCALAR_MODE_P(MODE) \ - (((MODE) == HFmode && TARGET_FLOAT16) \ - || ((MODE) == BFmode && TARGET_BFLOAT16)) + (TARGET_FLOAT16 && ((MODE) == HFmode || (MODE) == BFmode)) /* Is this a valid 16-bit scalar floating point mode that has hardware conversions? */ @@ -368,8 +367,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); /* Is this a valid 16-bit vector floating point mode? */ #define FP16_VECTOR_MODE_P(MODE) \ - (((MODE) == V8HFmode && TARGET_FLOAT16) \ - || ((MODE) == V8BFmode && TARGET_BFLOAT16)) + (TARGET_FLOAT16 && ((MODE) == V8HFmode || (MODE) == V8BFmode)) /* Return true for floating point that does not use a vector register. */ #define SCALAR_FLOAT_MODE_NOT_VECTOR_P(MODE) \ diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index cc78e6e6e5d2..bc5baf1bdbe7 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -785,8 +785,8 @@ PTI (V16QI "TARGET_ALTIVEC") (V8HI "TARGET_ALTIVEC") - (V8BF "TARGET_BFLOAT16") - (V8HF "TARGET_FLOAT16") + (V8BF "TARGET_ALTIVEC") + (V8HF "TARGET_ALTIVEC") (V4SI "TARGET_ALTIVEC") (V4SF "TARGET_ALTIVEC") (V2DI "TARGET_ALTIVEC") diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt index 053183b004c6..899a50e9df4e 100644 --- a/gcc/config/rs6000/rs6000.opt +++ b/gcc/config/rs6000/rs6000.opt @@ -640,7 +640,7 @@ Generate (do not generate) code that uses the LXVKQ instruction. mfloat16 Target Mask(FLOAT16) Var(rs6000_isa_flags) -Enable or disable _Float16 support. +Enable or disable 16-bit floating point. mfloat16-vector Target Undocumented Var(TARGET_FLOAT16_VECTOR) Init(1) Save @@ -648,7 +648,7 @@ Enable or disable _Float16 vectorization optimizations mfloat16-gpr-args Target Undocumented Var(TARGET_FLOAT16_GPR_ARGS) Init(0) Save -Pass and return _Float16 and __bfloat16 in GPR registers. +Pass and return 16-bit floating point types in GPR registers. mbfloat16 Target Mask(BFLOAT16) Var(rs6000_isa_flags) diff --git a/libgcc/config.host b/libgcc/config.host index ea5853d34b79..e1b9cd055be8 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -1306,14 +1306,6 @@ powerpc*-*-linux*) tmake_file="${tmake_file} rs6000/t-float16" fi - if test $libgcc_cv_powerpc_bfloat16 = yes; then - tmake_file="${tmake_file} rs6000/t-bfloat16" - - if test $libgcc_cv_powerpc_bfloat16 = yes; then - tmake_file="${tmake_file} rs6000/t-both-fp16" - fi - fi - extra_parts="$extra_parts ecrti.o ecrtn.o ncrti.o ncrtn.o" md_unwind_header=rs6000/linux-unwind.h ;; diff --git a/libgcc/config/rs6000/t-bfloat16 b/libgcc/config/rs6000/t-bfloat16 deleted file mode 100644 index cade2439c780..000000000000 --- a/libgcc/config/rs6000/t-bfloat16 +++ /dev/null @@ -1,30 +0,0 @@ -# __bfloat16 library support - -bfp16_funcs = extendbfsf2 floatdibf floatsibf floatundibf floatunsibf \ - truncdfbf2 truncsfbf2 - -bfp16_src = $(addprefix $(srcdir)/soft-fp/,$(addsuffix .c,$(bfp16_funcs))) -bfp16_obj = $(addsuffix $(objext),$(bfp16_funcs)) - -BFP16_CFLAGS = -mbfloat16 -Wno-psabi \ - -I$(srcdir)/soft-fp \ - -I$(srcdir)/config/rs6000 \ - -$(bfp16_obj) : INTERNAL_CFLAGS += $(BFP16_CFLAGS) - -# For now, only put it in the static library -# LIB2ADD += $(bfp16_src) - -LIB2ADD_ST += $(bfp16_src) - -.PHONY: test-bfloat16 clean-bfloat16 - -test-bfloat16: - @echo "bfp16_src:"; \ - for x in $(bfp16_src); do echo " $$x"; done; \ - echo; \ - echo "bfp16_obj:"; \ - for x in $(bfp16_obj); do echo " $$x"; done; - -clean-bfloat16: - @$(MULTICLEAN) multi-clean DO=clean-float16 diff --git a/libgcc/config/rs6000/t-both-fp16 b/libgcc/config/rs6000/t-both-fp16 deleted file mode 100644 index d51b7abbf086..000000000000 --- a/libgcc/config/rs6000/t-both-fp16 +++ /dev/null @@ -1,28 +0,0 @@ -# Conversion between __bfloat16 and _Float16 - -both_fp16_funcs = truncbfhf2 trunchfbf2 -both_fp16_src = $(addprefix $(srcdir)/soft-fp/,$(addsuffix .c,$(both_fp16_funcs))) -both_fp16_obj = $(addsuffix $(objext),$(both_fp16_funcs)) - -BOTH_FP16_CFLAGS = -mfloat16 -mbfloat16 -Wno-psabi \ - -I$(srcdir)/soft-fp \ - -I$(srcdir)/config/rs6000 \ - -$(both_fp16_obj) : INTERNAL_CFLAGS += $(BOTH_FP16_CFLAGS) - -# For now, only put it in the static library -# LIB2ADD += $(both_fp16_src) - -LIB2ADD_ST += $(both_fp16_src) - -.PHONY: test-both-fp16 clean-both-fp16 - -test-both-fp16: - @echo "both_fp16_src:"; \ - for x in $(both_fp16_src); do echo " $$x"; done; \ - echo; \ - echo "both_fp16_obj:"; \ - for x in $(both_fp16_obj); do echo " $$x"; done; - -clean-both-fp16: - @$(MULTICLEAN) multi-clean DO=clean-both-fp16 diff --git a/libgcc/config/rs6000/t-float16 b/libgcc/config/rs6000/t-float16 index f961097e85d1..9a0e8cd8963c 100644 --- a/libgcc/config/rs6000/t-float16 +++ b/libgcc/config/rs6000/t-float16 @@ -13,10 +13,28 @@ FP16_CFLAGS = -mfloat16 -Wno-psabi \ $(fp16_obj) : INTERNAL_CFLAGS += $(FP16_CFLAGS) +# __bfloat16 library support + +bfp16_funcs = extendbfsf2 floatdibf floatsibf floatundibf floatunsibf \ + truncdfbf2 truncsfbf2 + +bfp16_src = $(addprefix $(srcdir)/soft-fp/,$(addsuffix .c,$(bfp16_funcs))) +bfp16_obj = $(addsuffix $(objext),$(bfp16_funcs)) + +$(bfp16_obj) : INTERNAL_CFLAGS += $(FP16_CFLAGS) + +# Conversion between __bfloat16 and _Float16 + +both_fp16_funcs = truncbfhf2 trunchfbf2 +both_fp16_src = $(addprefix $(srcdir)/soft-fp/,$(addsuffix .c,$(both_fp16_funcs))) +both_fp16_obj = $(addsuffix $(objext),$(both_fp16_funcs)) + +$(both_fp16_obj) : INTERNAL_CFLAGS += $(FP16_CFLAGS) + # For now, only put it in the static library -# LIB2ADD += $(fp16_src) +# LIB2ADD += $(fp16_src) $(bfp16_src) $(both_fp16_src) -LIB2ADD_ST += $(fp16_src) +LIB2ADD_ST += $(fp16_src) $(bfp16_src) $(both_fp16_src) .PHONY: test-float16 clean-float16 @@ -24,8 +42,20 @@ test-float16: @echo "fp16_src:"; \ for x in $(fp16_src); do echo " $$x"; done; \ echo; \ + echo "bfp16_src:"; \ + for x in $(bfp16_src); do echo " $$x"; done; \ + echo; \ + echo "both_fp16_src:"; \ + for x in $(both_fp16_src); do echo " $$x"; done; \ + echo; \ echo "fp16_obj:"; \ - for x in $(fp16_obj); do echo " $$x"; done; + for x in $(fp16_obj); do echo " $$x"; done; \ + echo; \ + echo "bfp16_obj:"; \ + for x in $(bfp16_obj); do echo " $$x"; done; \ + echo; \ + echo "both_fp16_obj:"; \ + for x in $(bfp16_obj); do echo " $$x"; done; clean-float16: @$(MULTICLEAN) multi-clean DO=clean-float16 diff --git a/libgcc/configure b/libgcc/configure index ed7ea9e7d621..d53bcf5a1277 100755 --- a/libgcc/configure +++ b/libgcc/configure @@ -5305,27 +5305,6 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgcc_cv_powerpc_float16" >&5 $as_echo "$libgcc_cv_powerpc_float16" >&6; } CFLAGS="$saved_CFLAGS" - - CFLAGS="$CFLAGS -mbfloat16 -Wno-psabi" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the PowerPC can build __bfloat16 libraries" >&5 -$as_echo_n "checking whether the PowerPC can build __bfloat16 libraries... " >&6; } -if ${libgcc_cv_powerpc_bfloat16+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -__bfloat16 addbf16 (__bfloat16 a, __bfloat16 b) { return a + b; } -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - libgcc_cv_powerpc_bfloat16=yes -else - libgcc_cv_powerpc_bfloat16=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgcc_cv_powerpc_bfloat16" >&5 -$as_echo "$libgcc_cv_powerpc_bfloat16" >&6; } - CFLAGS="$saved_CFLAGS" esac # Collect host-machine-specific information. diff --git a/libgcc/configure.ac b/libgcc/configure.ac index 464acdee14c3..0e95dc97c867 100644 --- a/libgcc/configure.ac +++ b/libgcc/configure.ac @@ -476,15 +476,6 @@ powerpc*-*-linux*) [libgcc_cv_powerpc_float16=yes], [libgcc_cv_powerpc_float16=no])]) CFLAGS="$saved_CFLAGS" - - CFLAGS="$CFLAGS -mbfloat16 -Wno-psabi" - AC_CACHE_CHECK([whether the PowerPC can build __bfloat16 libraries], - [libgcc_cv_powerpc_bfloat16], - [AC_COMPILE_IFELSE( - [AC_LANG_SOURCE([__bfloat16 addbf16 (__bfloat16 a, __bfloat16 b) { return a + b; }])], - [libgcc_cv_powerpc_bfloat16=yes], - [libgcc_cv_powerpc_bfloat16=no])]) - CFLAGS="$saved_CFLAGS" esac # Collect host-machine-specific information.
