]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport r245869
authorMartin Liska <mliska@suse.cz>
Wed, 22 Mar 2017 12:28:50 +0000 (13:28 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Wed, 22 Mar 2017 12:28:50 +0000 (12:28 +0000)
2017-03-22  Martin Liska  <mliska@suse.cz>

Backport from mainline
2017-03-03  Martin Liska  <mliska@suse.cz>

PR tree-optimization/79803
* tree-ssa-loop-prefetch.c (tree_ssa_prefetch_arrays): Remove
assert.
(pass_loop_prefetch::execute): Disabled optimization if an
assumption about L1 cache size is not met.
2017-03-22  Martin Liska  <mliska@suse.cz>

Backport from mainline
2017-03-03  Martin Liska  <mliska@suse.cz>

PR tree-optimization/79803
* gcc.dg/tree-ssa/pr79803.c: New test.

From-SVN: r246369

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr79803.c [new file with mode: 0644]
gcc/tree-ssa-loop-prefetch.c

index 6f2e3fc2f7b9ac7c20b1ab51dff10f96aa79560e..cb742fef7b0672352025badbd68f23647a730975 100644 (file)
@@ -1,3 +1,14 @@
+2017-03-22  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       2017-03-03  Martin Liska  <mliska@suse.cz>
+
+       PR tree-optimization/79803
+       * tree-ssa-loop-prefetch.c (tree_ssa_prefetch_arrays): Remove
+       assert.
+       (pass_loop_prefetch::execute): Disabled optimization if an
+       assumption about L1 cache size is not met.
+
 2017-03-22  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
index ff41e874e526af9f412d68c4872f6900eff46098..daceba125eee4ca8e34bc8db7cc11d90730db7c8 100644 (file)
@@ -1,3 +1,11 @@
+2017-03-22  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       2017-03-03  Martin Liska  <mliska@suse.cz>
+
+       PR tree-optimization/79803
+       * gcc.dg/tree-ssa/pr79803.c: New test.
+
 2017-03-22  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr79803.c b/gcc/testsuite/gcc.dg/tree-ssa/pr79803.c
new file mode 100644 (file)
index 0000000..51b245d
--- /dev/null
@@ -0,0 +1,60 @@
+/* { dg-do compile { target { x86_64-*-* } } } */
+/* { dg-options "-march=opteron-sse3 -Ofast --param l1-cache-line-size=3 -Wdisabled-optimization" } */
+/* { dg-require-effective-target indirect_jumps } */
+
+#include <setjmp.h>
+
+extern void abort (void);
+
+jmp_buf buf;
+
+void raise0(void)
+{
+  __builtin_longjmp (buf, 1);
+}
+
+int execute(int cmd) /* { dg-warning "'l1-cache-size' parameter is not a power of two 3" } */
+{
+  int last = 0;
+
+  if (__builtin_setjmp (buf) == 0)
+    while (1)
+      {
+       last = 1;
+       raise0 ();
+      }
+
+  if (last == 0)
+    return 0;
+  else
+    return cmd;
+}
+
+int execute2(int cmd, int cmd2)
+{
+  int last = 0;
+
+  if (__builtin_setjmp (buf) == 0)
+    while (1)
+      {
+       last = 1;
+       raise0 ();
+      }
+
+  if (last == 0)
+    return 0;
+  else
+    return cmd;
+}
+
+
+int main(void)
+{
+  if (execute (1) == 0)
+    abort ();
+
+  if (execute2 (1, 2) == 0)
+    abort ();
+
+  return 0;
+}
index 10e156e997f3ebbcbfc49c03e95cee7ed43f6c19..a007f726cbc9ddace569060ead09352efcbeb883 100644 (file)
@@ -65,6 +65,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "langhooks.h"
 #include "tree-inline.h"
 #include "tree-data-ref.h"
+#include "diagnostic-core.h"
 
 
 /* FIXME: Needed for optabs, but this should all be moved to a TBD interface
@@ -2005,10 +2006,6 @@ tree_ssa_prefetch_arrays (void)
       set_builtin_decl (BUILT_IN_PREFETCH, decl, false);
     }
 
-  /* We assume that size of cache line is a power of two, so verify this
-     here.  */
-  gcc_assert ((PREFETCH_BLOCK & (PREFETCH_BLOCK - 1)) == 0);
-
   FOR_EACH_LOOP (loop, LI_FROM_INNERMOST)
     {
       if (dump_file && (dump_flags & TDF_DETAILS))
@@ -2066,6 +2063,20 @@ pass_loop_prefetch::execute (function *fun)
   if (number_of_loops (fun) <= 1)
     return 0;
 
+  if ((PREFETCH_BLOCK & (PREFETCH_BLOCK - 1)) != 0)
+    {
+      static bool warned = false;
+
+      if (!warned)
+       {
+         warning (OPT_Wdisabled_optimization,
+                  "%<l1-cache-size%> parameter is not a power of two %d",
+                  PREFETCH_BLOCK);
+         warned = true;
+       }
+      return 0;
+    }
+
   return tree_ssa_prefetch_arrays ();
 }