diff mbox series

rs6000: Update option set in rs6000_inner_target_options [PR115713]

Message ID 1b6b1ba8-2134-1cd3-5a8a-4ce236224f54@linux.ibm.com
State New
Headers show
Series rs6000: Update option set in rs6000_inner_target_options [PR115713] | expand

Commit Message

Kewen.Lin July 10, 2024, 8:44 a.m. UTC
Hi,

When function rs6000_inner_target_options parsing target
options, it updates the explicit option set information for
rs6000_opt_masks by rs6000_isa_flags_explicit, but it misses
to update that information for rs6000_opt_vars, and it can
result in some unexpected consequence as the associated test
case shows.  This patch is to fix rs6000_inner_target_options
to update the option set for rs6000_opt_vars as well.

Bootstrapped and regtested on powerpc64-linux-gnu P8/P9 and
powerpc64le-linux-gnu P9 and P10.

I'm going to push this next week if no objections.

BR,
Kewen
-----

	PR target/115713

gcc/ChangeLog:

	* config/rs6000/rs6000.cc (rs6000_inner_target_options): Update option
	set information for rs6000_opt_vars.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr115713-2.c: New test.
---
 gcc/config/rs6000/rs6000.cc                   |  3 ++-
 gcc/testsuite/gcc.target/powerpc/pr115713-2.c | 22 +++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/pr115713-2.c

--
2.45.2
diff mbox series

Patch

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index ed7a9fdeb58..8647aa92fe9 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -24668,7 +24668,8 @@  rs6000_inner_target_options (tree args, bool attr_p)
 		    if (strcmp (r, rs6000_opt_vars[i].name) == 0)
 		      {
 			size_t j = rs6000_opt_vars[i].global_offset;
-			*((int *) ((char *)&global_options + j)) = !invert;
+			*((int *) ((char *) &global_options + j)) = !invert;
+			*((int *) ((char *) &global_options_set + j)) = 1;
 			error_p = false;
 			not_valid_p = false;
 			break;
diff --git a/gcc/testsuite/gcc.target/powerpc/pr115713-2.c b/gcc/testsuite/gcc.target/powerpc/pr115713-2.c
new file mode 100644
index 00000000000..47b39c0faba
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr115713-2.c
@@ -0,0 +1,22 @@ 
+/* { dg-do compile } */
+/* Force power7 to avoid possible error message on AltiVec ABI change.  */
+/* { dg-options "-mdejagnu-cpu=power7" } */
+
+/* Verify there is an error message for -mvsx incompatible with
+   -mavoid-indexed-addresses even when they are specified by
+   target attributes.  */
+
+int __attribute__ ((target ("avoid-indexed-addresses,vsx")))
+test1 (void)
+{
+  /* { dg-error "'-mvsx' and '-mavoid-indexed-addresses' are incompatible" "" { target *-*-* } .-1 } */
+  return 0;
+}
+
+int __attribute__ ((target ("vsx,avoid-indexed-addresses")))
+test2 (void)
+{
+  /* { dg-error "'-mvsx' and '-mavoid-indexed-addresses' are incompatible" "" { target *-*-* } .-1 } */
+  return 0;
+}
+