public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][AArch64] Set TREE_TARGET_GLOBALS in aarch64_set_current_function when new tree is the default node to recalculate optab availability
@ 2016-02-25 11:04 Kyrill Tkachov
  2016-02-26 15:51 ` James Greenhalgh
  0 siblings, 1 reply; 5+ messages in thread
From: Kyrill Tkachov @ 2016-02-25 11:04 UTC (permalink / raw)
  To: GCC Patches; +Cc: Marcus Shawcroft, Richard Earnshaw, James Greenhalgh

[-- Attachment #1: Type: text/plain, Size: 1137 bytes --]

Hi all,

Seems like aarch64 is suffering from something similar to PR 69245 as well.
If a target pragma sets the target state to the same as the target_option_default_node
the node is just a pointer to target_option_default_node rather than a distinct identical
node. So we must still restore the target globals even when setting to target_option_default_node
in order to force the midend to recompute the availability of various optabs.

If we don't do it, we can get in a problem like in the testcase where the isa_flags are all
set correctly, but the optab HAVE_* predicates have not been recomputed.

There is also a related issue present when popping/resetting target pragmas for which
I'll send out a patch separately.

Bootstrapped and tested on aarch64.

Ok for trunk?
Thanks,
Kyrill


2016-02-25  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     PR target/69245
     * config/aarch64/aarch64.c (aarch64_set_current_function): Save/restore
     target globals when switching to target_option_default_node.

2016-02-25  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     PR target/69245
     * gcc.target/aarch64/pr69245_1.c: New test.

[-- Attachment #2: aarch64-set-func-default.patch --]
[-- Type: text/x-patch, Size: 1139 bytes --]

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 2e69e345545e591d1de76c2d175aac476e6e1107..07590bd43ca81e182ab1e2ba9596cf6881173729 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -8593,7 +8593,7 @@ aarch64_set_current_function (tree fndecl)
       if (old_tree == new_tree)
 	;
 
-      else if (new_tree && new_tree != target_option_default_node)
+      else if (new_tree)
 	{
 	  cl_target_option_restore (&global_options,
 				    TREE_TARGET_OPTION (new_tree));
diff --git a/gcc/testsuite/gcc.target/aarch64/pr69245_1.c b/gcc/testsuite/gcc.target/aarch64/pr69245_1.c
new file mode 100644
index 0000000000000000000000000000000000000000..dcc542b2a8686f1b323433624d4df65ca9e96b36
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr69245_1.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=armv8-a+fp -fomit-frame-pointer" } */
+
+#pragma GCC target "arch=armv8-a+nofp"
+long a;
+static void
+fn1 ()
+{
+}
+
+#pragma GCC target "arch=armv8-a+fp"
+float
+fn2 (float a)
+{
+  return a + 2.0;
+}
+
+/* { dg-final { scan-assembler-not "__addsf3" } } */

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

end of thread, other threads:[~2016-02-29 14:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-25 11:04 [PATCH][AArch64] Set TREE_TARGET_GLOBALS in aarch64_set_current_function when new tree is the default node to recalculate optab availability Kyrill Tkachov
2016-02-26 15:51 ` James Greenhalgh
2016-02-29 14:10   ` Christophe Lyon
2016-02-29 14:28     ` Kyrill Tkachov
2016-02-29 14:33       ` Christophe Lyon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).