Hello. I've just followed Richi's advises in the PR.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. Ready to be installed? Martin
>From 9a850909d00e2b63961167665d48f7ebbb99ac84 Mon Sep 17 00:00:00 2001 From: marxin <mli...@suse.cz> Date: Thu, 2 Mar 2017 13:34:55 +0100 Subject: [PATCH] Add -Wdisabled-optimization to loop prefetching pass (PR tree-optimization/79803). gcc/ChangeLog: 2017-03-02 Martin Liska <mli...@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. gcc/testsuite/ChangeLog: 2017-03-02 Martin Liska <mli...@suse.cz> PR tree-optimization/79803 * gcc.dg/tree-ssa/pr79803.c: New test. --- gcc/testsuite/gcc.dg/tree-ssa/pr79803.c | 39 +++++++++++++++++++++++++++++++++ gcc/tree-ssa-loop-prefetch.c | 13 +++++++---- 2 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr79803.c diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr79803.c b/gcc/testsuite/gcc.dg/tree-ssa/pr79803.c new file mode 100644 index 00000000000..e43a40739d5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr79803.c @@ -0,0 +1,39 @@ +/* { 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' is not an even number 3" } */ +{ + 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 (); + + return 0; +} diff --git a/gcc/tree-ssa-loop-prefetch.c b/gcc/tree-ssa-loop-prefetch.c index 54cd9421998..2cdf210308b 100644 --- a/gcc/tree-ssa-loop-prefetch.c +++ b/gcc/tree-ssa-loop-prefetch.c @@ -47,6 +47,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" /* This pass inserts prefetch instructions to optimize cache usage during accesses to arrays in loops. It processes loops sequentially and: @@ -1977,10 +1978,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)) @@ -2038,6 +2035,14 @@ pass_loop_prefetch::execute (function *fun) if (number_of_loops (fun) <= 1) return 0; + if ((PREFETCH_BLOCK & (PREFETCH_BLOCK - 1)) != 0) + { + warning (OPT_Wdisabled_optimization, + "%<l1-cache-size%> is not an even number %d", + PREFETCH_BLOCK); + return 0; + } + return tree_ssa_prefetch_arrays (); } -- 2.11.1