diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2021-09-27 16:41:01 +0200 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2021-09-28 08:17:29 +0200 |
commit | e475ae9bbf0c85a7d60f236c5a744e163a9ef7b8 (patch) | |
tree | edf942bb62820aa08cba690bfa55461e4397699b /gcc | |
parent | 9cfb95f9b92326e86e99b50350ebf04fa9cd2477 (diff) | |
download | gcc-e475ae9bbf0c85a7d60f236c5a744e163a9ef7b8.zip gcc-e475ae9bbf0c85a7d60f236c5a744e163a9ef7b8.tar.gz gcc-e475ae9bbf0c85a7d60f236c5a744e163a9ef7b8.tar.bz2 |
Control all jump threading passes with -fjump-threads.
Last year I mentioned that -fthread-jumps was being ignored by the
majority of our jump threading passes, and Jeff said he'd be in favor
of fixing this.
This patch remedies the situation, but it does change existing behavior.
Currently -fthread-jumps is only enabled for -O2, -O3, and -Os. This
means that even if we restricted all jump threading passes with
-fthread-jumps, DOM jump threading would still seep through since it
runs at -O1.
I propose this patch, but it does mean that DOM jump threading would
have to be explicitly enabled with -O1 -fthread-jumps.
gcc/ChangeLog:
* tree-ssa-threadbackward.c (pass_thread_jumps::gate): Check
flag_thread_jumps.
(pass_early_thread_jumps::gate): Same.
* tree-ssa-threadedge.c (jump_threader::thread_outgoing_edges):
Return if !flag_thread_jumps.
* tree-ssa-threadupdate.c
(jt_path_registry::register_jump_thread): Assert that
flag_thread_jumps is true.
gcc/testsuite/ChangeLog:
* gcc.dg/auto-init-uninit-1.c: Add -fthread-jumps.
* gcc.dg/auto-init-uninit-15.c: Same.
* gcc.dg/guality/example.c: Same.
* gcc.dg/loop-8.c: Same.
* gcc.dg/strlenopt-40.c: Same.
* gcc.dg/tree-ssa/pr18133-2.c: Same.
* gcc.dg/tree-ssa/pr18134.c: Same.
* gcc.dg/uninit-1.c: Same.
* gcc.dg/uninit-pr44547.c: Same.
* gcc.dg/uninit-pr59970.c: Same.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/gcc.dg/auto-init-uninit-1.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/auto-init-uninit-15.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/guality/example.c | 1 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/loop-8.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/strlenopt-40.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/pr18133-2.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/pr18134.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/uninit-1.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/uninit-pr44547.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/uninit-pr59970.c | 2 | ||||
-rw-r--r-- | gcc/tree-ssa-threadbackward.c | 4 | ||||
-rw-r--r-- | gcc/tree-ssa-threadedge.c | 3 | ||||
-rw-r--r-- | gcc/tree-ssa-threadupdate.c | 2 |
13 files changed, 16 insertions, 12 deletions
diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-1.c b/gcc/testsuite/gcc.dg/auto-init-uninit-1.c index 502db59..ce89096 100644 --- a/gcc/testsuite/gcc.dg/auto-init-uninit-1.c +++ b/gcc/testsuite/gcc.dg/auto-init-uninit-1.c @@ -1,5 +1,5 @@ /* Spurious uninitialized variable warnings, case 1. Taken from cppfiles.c (merge_include_chains) */ /* { dg-do compile } */ -/* { dg-options "-O -Wuninitialized -ftrivial-auto-var-init=zero" } */ +/* { dg-options "-O -Wuninitialized -fthread-jumps -ftrivial-auto-var-init=zero" } */ #include "uninit-1.c" diff --git a/gcc/testsuite/gcc.dg/auto-init-uninit-15.c b/gcc/testsuite/gcc.dg/auto-init-uninit-15.c index 121f0cf..b8f6e2b 100644 --- a/gcc/testsuite/gcc.dg/auto-init-uninit-15.c +++ b/gcc/testsuite/gcc.dg/auto-init-uninit-15.c @@ -5,7 +5,7 @@ But it is of course ok if we warn in bar about uninitialized use of j. (not xfailed alternative) */ /* { dg-do compile } */ -/* { dg-options "-O1 -Wuninitialized -ftrivial-auto-var-init=zero" } */ +/* { dg-options "-O1 -Wuninitialized -fthread-jumps -ftrivial-auto-var-init=zero" } */ inline int foo (int i) diff --git a/gcc/testsuite/gcc.dg/guality/example.c b/gcc/testsuite/gcc.dg/guality/example.c index 6f1c017..37564e5 100644 --- a/gcc/testsuite/gcc.dg/guality/example.c +++ b/gcc/testsuite/gcc.dg/guality/example.c @@ -1,4 +1,3 @@ -/* { dg-do run { xfail { ! aarch64*-*-* } } } */ /* { dg-options "-g" } */ /* { dg-xfail-run-if "" aarch64*-*-* "*" { "-O[01g]" } } */ diff --git a/gcc/testsuite/gcc.dg/loop-8.c b/gcc/testsuite/gcc.dg/loop-8.c index 90ea1c4..e5218eb 100644 --- a/gcc/testsuite/gcc.dg/loop-8.c +++ b/gcc/testsuite/gcc.dg/loop-8.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O1 -fdump-rtl-loop2_invariant" } */ +/* { dg-options "-O1 -fthread-jumps -fdump-rtl-loop2_invariant" } */ /* { dg-skip-if "unexpected IV" { "hppa*-*-* mips*-*-* visium-*-* powerpc*-*-* riscv*-*-* mmix-*-* vax-*-*" } } */ /* Load immediate on condition is available from z13 on and prevents moving the load out of the loop, so always run this test with -march=zEC12 that diff --git a/gcc/testsuite/gcc.dg/strlenopt-40.c b/gcc/testsuite/gcc.dg/strlenopt-40.c index 7a97ebb..7b79910 100644 --- a/gcc/testsuite/gcc.dg/strlenopt-40.c +++ b/gcc/testsuite/gcc.dg/strlenopt-40.c @@ -1,7 +1,7 @@ /* PR tree-optimization/83671 - fix for false positive reported by -Wstringop-overflow does not work with inlining { dg-do compile } - { dg-options "-O1 -fdump-tree-optimized" } */ + { dg-options "-O1 -fthread-jumps -fdump-tree-optimized" } */ #include "strlenopt.h" diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr18133-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr18133-2.c index 8717640..1b40985 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr18133-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr18133-2.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O1 -fdump-tree-optimized-blocks" } */ +/* { dg-options "-O1 -fthread-jumps -fdump-tree-optimized-blocks" } */ int c, d; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr18134.c b/gcc/testsuite/gcc.dg/tree-ssa/pr18134.c index cd40ab2..d7f5d24 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr18134.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr18134.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O1 -fdump-tree-optimized" } */ +/* { dg-options "-O1 -fthread-jumps -fdump-tree-optimized" } */ int foo (int a) { diff --git a/gcc/testsuite/gcc.dg/uninit-1.c b/gcc/testsuite/gcc.dg/uninit-1.c index 060ec25..156d34f 100644 --- a/gcc/testsuite/gcc.dg/uninit-1.c +++ b/gcc/testsuite/gcc.dg/uninit-1.c @@ -1,7 +1,7 @@ /* Spurious uninitialized variable warnings, case 1. Taken from cppfiles.c (merge_include_chains) */ /* { dg-do compile } */ -/* { dg-options "-O -Wuninitialized" } */ +/* { dg-options "-O -Wuninitialized -fthread-jumps" } */ struct list { diff --git a/gcc/testsuite/gcc.dg/uninit-pr44547.c b/gcc/testsuite/gcc.dg/uninit-pr44547.c index ee1035a..f1c3b03 100644 --- a/gcc/testsuite/gcc.dg/uninit-pr44547.c +++ b/gcc/testsuite/gcc.dg/uninit-pr44547.c @@ -1,7 +1,7 @@ /* PR tree-optimization/44547 - -Wuninitialized reports false warning in nested switch statements { dg-do compile } - { dg-options "-O1 -Wall" } */ + { dg-options "-O1 -Wall -fthread-jumps" } */ __attribute__ ((noipa)) int test_O1 (int argc) { diff --git a/gcc/testsuite/gcc.dg/uninit-pr59970.c b/gcc/testsuite/gcc.dg/uninit-pr59970.c index 145af65..d0c41b8 100644 --- a/gcc/testsuite/gcc.dg/uninit-pr59970.c +++ b/gcc/testsuite/gcc.dg/uninit-pr59970.c @@ -41,7 +41,7 @@ d_demangle_callback_O1 (const char *mangled) #pragma GCC pop_options -#pragma GCC optimize ("Og") +#pragma GCC optimize ("Og,thread-jumps") __attribute__ ((noipa)) int d_demangle_callback_Og (const char *mangled) diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c index e6819fe..28c7ef8 100644 --- a/gcc/tree-ssa-threadbackward.c +++ b/gcc/tree-ssa-threadbackward.c @@ -943,7 +943,7 @@ public: bool pass_thread_jumps::gate (function *fun ATTRIBUTE_UNUSED) { - return flag_expensive_optimizations; + return flag_thread_jumps && flag_expensive_optimizations; } // Try to thread blocks in FUN. Return TRUE if any jump thread paths were @@ -1013,7 +1013,7 @@ public: bool pass_early_thread_jumps::gate (function *fun ATTRIBUTE_UNUSED) { - return true; + return flag_thread_jumps; } unsigned int diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c index 0b59cb4..a63a976 100644 --- a/gcc/tree-ssa-threadedge.c +++ b/gcc/tree-ssa-threadedge.c @@ -1196,6 +1196,9 @@ jump_threader::thread_outgoing_edges (basic_block bb) int flags = (EDGE_IGNORE | EDGE_COMPLEX | EDGE_ABNORMAL); gimple *last; + if (!flag_thread_jumps) + return; + /* If we have an outgoing edge to a block with multiple incoming and outgoing edges, then we may be able to thread the edge, i.e., we may be able to statically determine which of the outgoing edges diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c index 2b9b8f8..cf96c90 100644 --- a/gcc/tree-ssa-threadupdate.c +++ b/gcc/tree-ssa-threadupdate.c @@ -2822,6 +2822,8 @@ jt_path_registry::cancel_invalid_paths (vec<jump_thread_edge *> &path) bool jt_path_registry::register_jump_thread (vec<jump_thread_edge *> *path) { + gcc_checking_assert (flag_thread_jumps); + if (!dbg_cnt (registered_jump_thread)) { path->release (); |