]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR target/80210 (ICE in in extract_insn, at recog.c:2311 on ppc64 for...
authorPeter Bergner <bergner@vnet.ibm.com>
Fri, 15 Dec 2017 03:41:16 +0000 (21:41 -0600)
committerPeter Bergner <bergner@gcc.gnu.org>
Fri, 15 Dec 2017 03:41:16 +0000 (21:41 -0600)
gcc/
Backport from mainline
2017-10-02  Peter Bergner  <bergner@vnet.ibm.com>

PR target/80210
* config/rs6000/rs6000.c (rs6000_option_override_internal): Rewrite
function to not use the have_cpu variable.  Do not set cpu_index,
rs6000_cpu_index or rs6000_tune_index if we end up using TARGET_DEFAULT
or the default cpu.
(rs6000_valid_attribute_p): Remove duplicate initializations of
old_optimize and func_optimize.
(rs6000_pragma_target_parse): Call rs6000_activate_target_options ().
(rs6000_activate_target_options): Make global.
* config/rs6000/rs6000-protos.h (rs6000_activate_target_options): Add
prototype.

gcc/testsuite/
Backport from mainline
2017-10-02  Peter Bergner  <bergner@vnet.ibm.com>

PR target/80210
* gcc.target/powerpc/pr80210-2.c: New test.

From-SVN: r255671

gcc/ChangeLog
gcc/config/rs6000/rs6000-protos.h
gcc/config/rs6000/rs6000.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/powerpc/pr80210-2.c [new file with mode: 0644]

index 35a70d4fbcf5173c014f5be5f67b88def5ad9c8c..256ba2563d19f8794711b9ef2ad9ec631d8a191d 100644 (file)
@@ -1,3 +1,20 @@
+2017-12-14  Peter Bergner  <bergner@vnet.ibm.com>
+
+       Backport from mainline
+       2017-10-02  Peter Bergner  <bergner@vnet.ibm.com>
+
+       PR target/80210
+       * config/rs6000/rs6000.c (rs6000_option_override_internal): Rewrite
+       function to not use the have_cpu variable.  Do not set cpu_index,
+       rs6000_cpu_index or rs6000_tune_index if we end up using TARGET_DEFAULT
+       or the default cpu.
+       (rs6000_valid_attribute_p): Remove duplicate initializations of
+       old_optimize and func_optimize.
+       (rs6000_pragma_target_parse): Call rs6000_activate_target_options ().
+       (rs6000_activate_target_options): Make global.
+       * config/rs6000/rs6000-protos.h (rs6000_activate_target_options): Add
+       prototype.
+
 2017-12-11  Thomas Schwinge  <thomas@codesourcery.com>
 
        PR c++/83301
index ddb2fe9da48bfcf7e66c24895c621565884ac5e1..cbd197b91265c409807c7a4540c0a9ccc13a8320 100644 (file)
@@ -230,6 +230,7 @@ extern void rs6000_cpu_cpp_builtins (struct cpp_reader *);
 #ifdef TREE_CODE
 extern bool rs6000_pragma_target_parse (tree, tree);
 #endif
+extern void rs6000_activate_target_options (tree new_tree);
 extern void rs6000_target_modify_macros (bool, HOST_WIDE_INT, HOST_WIDE_INT);
 extern void (*rs6000_target_modify_macros_ptr) (bool, HOST_WIDE_INT,
                                                HOST_WIDE_INT);
index 8e041047b737080393acbc6ed6842aa50d953fa2..0f2e603a105cb4152ab54b4e68fcc20f7258bd0a 100644 (file)
@@ -3804,13 +3804,8 @@ static bool
 rs6000_option_override_internal (bool global_init_p)
 {
   bool ret = true;
-  bool have_cpu = false;
-
-  /* The default cpu requested at configure time, if any.  */
-  const char *implicit_cpu = OPTION_TARGET_CPU_DEFAULT;
-
   HOST_WIDE_INT set_masks;
-  int cpu_index;
+  int cpu_index = -1;
   int tune_index;
   struct cl_target_option *main_target_opt
     = ((global_init_p || target_option_default_node == NULL)
@@ -3887,42 +3882,20 @@ rs6000_option_override_internal (bool global_init_p)
      with -mtune on the command line.  Process a '--with-cpu' configuration
      request as an implicit --cpu.  */
   if (rs6000_cpu_index >= 0)
-    {
-      cpu_index = rs6000_cpu_index;
-      have_cpu = true;
-    }
+    cpu_index = rs6000_cpu_index;
   else if (main_target_opt != NULL && main_target_opt->x_rs6000_cpu_index >= 0)
-    {
-      rs6000_cpu_index = cpu_index = main_target_opt->x_rs6000_cpu_index;
-      have_cpu = true;
-    }
-  else if (implicit_cpu)
-    {
-      rs6000_cpu_index = cpu_index = rs6000_cpu_name_lookup (implicit_cpu);
-      have_cpu = true;
-    }
-  else
-    {
-      /* PowerPC 64-bit LE requires at least ISA 2.07.  */
-      const char *default_cpu = ((!TARGET_POWERPC64)
-                                ? "powerpc"
-                                : ((BYTES_BIG_ENDIAN)
-                                   ? "powerpc64"
-                                   : "powerpc64le"));
-
-      rs6000_cpu_index = cpu_index = rs6000_cpu_name_lookup (default_cpu);
-      have_cpu = false;
-    }
-
-  gcc_assert (cpu_index >= 0);
+    cpu_index = main_target_opt->x_rs6000_cpu_index;
+  else if (OPTION_TARGET_CPU_DEFAULT)
+    cpu_index = rs6000_cpu_name_lookup (OPTION_TARGET_CPU_DEFAULT);
 
   /* If we have a cpu, either through an explicit -mcpu=<xxx> or if the
      compiler was configured with --with-cpu=<xxx>, replace all of the ISA bits
      with those from the cpu, except for options that were explicitly set.  If
      we don't have a cpu, do not override the target bits set in
      TARGET_DEFAULT.  */
-  if (have_cpu)
+  if (cpu_index >= 0)
     {
+      rs6000_cpu_index = cpu_index;
       rs6000_isa_flags &= ~set_masks;
       rs6000_isa_flags |= (processor_target_table[cpu_index].target_enable
                           & set_masks);
@@ -3936,14 +3909,26 @@ rs6000_option_override_internal (bool global_init_p)
 
         If there is a TARGET_DEFAULT, use that.  Otherwise fall back to using
         -mcpu=powerpc, -mcpu=powerpc64, or -mcpu=powerpc64le defaults.  */
-      HOST_WIDE_INT flags = ((TARGET_DEFAULT) ? TARGET_DEFAULT
-                            : processor_target_table[cpu_index].target_enable);
+      HOST_WIDE_INT flags;
+      if (TARGET_DEFAULT)
+       flags = TARGET_DEFAULT;
+      else
+       {
+         /* PowerPC 64-bit LE requires at least ISA 2.07.  */
+         const char *default_cpu = (!TARGET_POWERPC64
+                                    ? "powerpc"
+                                    : (BYTES_BIG_ENDIAN
+                                       ? "powerpc64"
+                                       : "powerpc64le"));
+         int default_cpu_index = rs6000_cpu_name_lookup (default_cpu);
+         flags = processor_target_table[default_cpu_index].target_enable;
+       }
       rs6000_isa_flags |= (flags & ~rs6000_isa_flags_explicit);
     }
 
   if (rs6000_tune_index >= 0)
     tune_index = rs6000_tune_index;
-  else if (have_cpu)
+  else if (cpu_index >= 0)
     rs6000_tune_index = tune_index = cpu_index;
   else
     {
@@ -3955,7 +3940,7 @@ rs6000_option_override_internal (bool global_init_p)
       for (i = 0; i < ARRAY_SIZE (processor_target_table); i++)
        if (processor_target_table[i].processor == tune_proc)
          {
-           rs6000_tune_index = tune_index = i;
+           tune_index = i;
            break;
          }
     }
@@ -4743,7 +4728,7 @@ rs6000_option_override_internal (bool global_init_p)
 
     default:
 
-      if (have_cpu && !(rs6000_isa_flags_explicit & OPTION_MASK_ISEL))
+      if (cpu_index >= 0 && !(rs6000_isa_flags_explicit & OPTION_MASK_ISEL))
        rs6000_isa_flags &= ~OPTION_MASK_ISEL;
 
       break;
@@ -36382,9 +36367,9 @@ rs6000_valid_attribute_p (tree fndecl,
 {
   struct cl_target_option cur_target;
   bool ret;
-  tree old_optimize = build_optimization_node (&global_options);
+  tree old_optimize;
   tree new_target, new_optimize;
-  tree func_optimize = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl);
+  tree func_optimize;
 
   gcc_assert ((fndecl != NULL_TREE) && (args != NULL_TREE));
 
@@ -36511,6 +36496,7 @@ rs6000_pragma_target_parse (tree args, tree pop_target)
     }
 
   target_option_current_node = cur_tree;
+  rs6000_activate_target_options (target_option_current_node);
 
   /* If we have the preprocessor linked in (i.e. C or C++ languages), possibly
      change the macros that are defined.  */
@@ -36551,7 +36537,7 @@ static GTY(()) tree rs6000_previous_fndecl;
 /* Restore target's globals from NEW_TREE and invalidate the
    rs6000_previous_fndecl cache.  */
 
-static void
+void
 rs6000_activate_target_options (tree new_tree)
 {
   cl_target_option_restore (&global_options, TREE_TARGET_OPTION (new_tree));
index 6a12b8ad78df293804d2b9d6311ff76e5b845129..d6555fb38b4c5cbcf8652337d81ff9969002f807 100644 (file)
@@ -1,3 +1,11 @@
+2017-12-14  Peter Bergner  <bergner@vnet.ibm.com>
+
+       Backport from mainline
+       2017-10-02  Peter Bergner  <bergner@vnet.ibm.com>
+
+       PR target/80210
+       * gcc.target/powerpc/pr80210-2.c: New test.
+
 2017-12-14  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/alignment13.adb: New test.
diff --git a/gcc/testsuite/gcc.target/powerpc/pr80210-2.c b/gcc/testsuite/gcc.target/powerpc/pr80210-2.c
new file mode 100644 (file)
index 0000000..455f7d6
--- /dev/null
@@ -0,0 +1,11 @@
+/* Test for ICE arising from GCC target pragma.  */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#pragma GCC target "no-powerpc-gpopt"
+double
+foo (double a)
+{
+  return __builtin_sqrt (a);
+}
+/* { dg-final { scan-assembler-not "fsqrt" } } */