[PATCH] rs6000: Fix restored rs6000_long_double_type_size.

Martin Liška mliska@suse.cz
Wed Jun 23 13:22:34 GMT 2021


Hello.

As mentioned in the "Fallout: save/restore target options in handle_optimize_attribute"
thread, we need to support target option restore of rs6000_long_double_type_size == FLOAT_PRECISION_TFmode.

Patch can bootstrap on ppc64le-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

gcc/ChangeLog:

	* config/rs6000/rs6000.c (rs6000_option_override_internal): When
	a target option is restored, it can have
	rs6000_long_double_type_size set to FLOAT_PRECISION_TFmode.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pragma-optimize.c: New test.
---
  gcc/config/rs6000/rs6000.c                         |  2 ++
  gcc/testsuite/gcc.target/powerpc/pragma-optimize.c | 14 ++++++++++++++
  2 files changed, 16 insertions(+)
  create mode 100644 gcc/testsuite/gcc.target/powerpc/pragma-optimize.c

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 835af7708f9..2c811480db9 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -4185,6 +4185,8 @@ rs6000_option_override_internal (bool global_init_p)
        else
  	rs6000_long_double_type_size = default_long_double_size;
      }
+  else if (rs6000_long_double_type_size == FLOAT_PRECISION_TFmode)
+    ; /* The option can be restored a TREE_TARGET_OPTION.  */
    else if (rs6000_long_double_type_size == 128)
      rs6000_long_double_type_size = FLOAT_PRECISION_TFmode;
    else if (global_options_set.x_rs6000_ieeequad)
diff --git a/gcc/testsuite/gcc.target/powerpc/pragma-optimize.c b/gcc/testsuite/gcc.target/powerpc/pragma-optimize.c
new file mode 100644
index 00000000000..629bfcee0ec
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pragma-optimize.c
@@ -0,0 +1,14 @@
+/* { dg-do compile { target { powerpc*-*-linux* } } } */
+/* { dg-options "-O2 -mlong-double-128 -mabi=ibmlongdouble" } */
+
+extern unsigned long int x;
+extern float f (float);
+extern __typeof (f) f_power8;
+extern __typeof (f) f_power9;
+extern __typeof (f) f __attribute__ ((ifunc ("f_ifunc")));
+static __attribute__ ((optimize ("-fno-stack-protector"))) __typeof (f) *
+f_ifunc (void)
+{
+  __typeof (f) *res = x ? f_power9 : f_power8;
+  return res;
+}
-- 
2.32.0



More information about the Gcc-patches mailing list