summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2019-07-29 08:47:20 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2019-07-29 08:47:20 +0000
commitc0fe6bce2a8c35e997f45b0a674ab2058ba50ae0 (patch)
treede568bd7c602e0db7f412c85bcc26411c4eb7ac2 /gcc
parentec8ac265ff21fb379ac072848561a91e4990c47f (diff)
Don't run DSE at -Og
This patch stops gimple and rtl DSE from running by default at -Og. The idea is both to improve compile time and to stop us from deleting stores that we can't track in debug info. We could rein this back in future for stores to local variables with is_gimple_reg_type, but at the moment we don't have any infrastructure for switching between binds to specific values and binds to evolving memory locations. Even then, location tracking only works for direct references to the variables, and doesn't for example help with printing dereferenced pointers (see the next patch in the series for an example). I'm also not sure that DSE is important enough for -Og to justify the compile time cost -- especially in the case of RTL DSE, which is pretty expensive. 2019-07-29 Richard Sandiford <richard.sandiford@arm.com> gcc/ * common.opt (Og): Change the initial value of flag_dse to 0. * opts.c (default_options_table): Move OPT_ftree_dse from OPT_LEVELS_1_PLUS to OPT_LEVELS_1_PLUS_NOT_DEBUG. Also add OPT_fdse to OPT_LEVELS_1_PLUS_NOT_DEBUG. Put the OPT_ftree_pta entry before the OPT_ftree_sra entry. * doc/invoke.texi (Og): Add -fdse and -ftree-dse to the list of flags disabled by Og. gcc/testsuite/ * c-c++-common/guality/Og-global-dse-1.c: New test. From-SVN: r273871
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/common.opt2
-rw-r--r--gcc/doc/invoke.texi4
-rw-r--r--gcc/opts.c5
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/c-c++-common/guality/Og-global-dse-1.c17
6 files changed, 37 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3eb52020e68..3e84bafe8bd 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,15 @@
2019-07-29 Richard Sandiford <richard.sandiford@arm.com>
+ * common.opt (Og): Change the initial value of flag_dse to 0.
+ * opts.c (default_options_table): Move OPT_ftree_dse from
+ OPT_LEVELS_1_PLUS to OPT_LEVELS_1_PLUS_NOT_DEBUG. Also add
+ OPT_fdse to OPT_LEVELS_1_PLUS_NOT_DEBUG. Put the OPT_ftree_pta
+ entry before the OPT_ftree_sra entry.
+ * doc/invoke.texi (Og): Add -fdse and -ftree-dse to the list
+ of flags disabled by Og.
+
+2019-07-29 Richard Sandiford <richard.sandiford@arm.com>
+
* tree-cfg.c (execute_fixup_cfg): Don't delete stores to write-only
variables for -Og.
diff --git a/gcc/common.opt b/gcc/common.opt
index 11637c8cab0..c1605385712 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1955,7 +1955,7 @@ Common Var(flag_dce) Init(1) Optimization
Use the RTL dead code elimination pass.
fdse
-Common Var(flag_dse) Init(1) Optimization
+Common Var(flag_dse) Init(0) Optimization
Use the RTL dead store elimination pass.
freschedule-modulo-scheduled-loops
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 77a2d561e38..d1dfa2a5034 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -8423,10 +8423,10 @@ no effect. Otherwise @option{-Og} enables all @option{-O1}
optimization flags except for those that may interfere with debugging:
@gccoptlist{-fbranch-count-reg -fdelayed-branch @gol
--fif-conversion -fif-conversion2 @gol
+-fdse -fif-conversion -fif-conversion2 @gol
-finline-functions-called-once @gol
-fmove-loop-invariants -fssa-phiopt @gol
--ftree-bit-ccp -ftree-pta -ftree-sra}
+-ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra}
@end table
diff --git a/gcc/opts.c b/gcc/opts.c
index 296f0f61802..28142cef044 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -469,7 +469,6 @@ static const struct default_options default_options_table[] =
{ OPT_LEVELS_1_PLUS, OPT_ftree_copy_prop, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_ftree_dce, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_ftree_dominator_opts, NULL, 1 },
- { OPT_LEVELS_1_PLUS, OPT_ftree_dse, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_ftree_fre, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_ftree_sink, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_ftree_slsr, NULL, 1 },
@@ -480,14 +479,16 @@ static const struct default_options default_options_table[] =
#if DELAY_SLOTS
{ OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fdelayed_branch, NULL, 1 },
#endif
+ { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fdse, NULL, 1 },
{ OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fif_conversion, NULL, 1 },
{ OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fif_conversion2, NULL, 1 },
{ OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_finline_functions_called_once, NULL, 1 },
{ OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fmove_loop_invariants, NULL, 1 },
{ OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fssa_phiopt, NULL, 1 },
{ OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_ftree_bit_ccp, NULL, 1 },
- { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_ftree_sra, NULL, 1 },
+ { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_ftree_dse, NULL, 1 },
{ OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_ftree_pta, NULL, 1 },
+ { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_ftree_sra, NULL, 1 },
/* -O2 and -Os optimizations. */
{ OPT_LEVELS_2_PLUS, OPT_fcaller_saves, NULL, 1 },
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1dd2819e9e8..6dab4515305 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2019-07-29 Richard Sandiford <richard.sandiford@arm.com>
+ * c-c++-common/guality/Og-global-dse-1.c: New test.
+
+2019-07-29 Richard Sandiford <richard.sandiford@arm.com>
+
* c-c++-common/guality/Og-static-wo-1.c: New test.
* g++.dg/guality/guality.exp: Separate the c-c++-common tests into
"Og" and "general" tests. Run the latter at -O0 and -Og only.
diff --git a/gcc/testsuite/c-c++-common/guality/Og-global-dse-1.c b/gcc/testsuite/c-c++-common/guality/Og-global-dse-1.c
new file mode 100644
index 00000000000..3d4b4e60e15
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/guality/Og-global-dse-1.c
@@ -0,0 +1,17 @@
+/* { dg-do run } */
+/* { dg-options "-g" } */
+
+struct s { int i, j; };
+struct s gs1, gs2 = { 3, 4 };
+
+void __attribute__((noipa)) consume (void) {};
+
+int
+main (void)
+{
+ gs1.i = 1;
+ gs1.j = 2; /* { dg-final { gdb-test . "gs1.i" "1" } } */
+ gs1 = gs2; /* { dg-final { gdb-test . "gs1.j" "2" } } */
+ consume (); /* { dg-final { gdb-test . "gs1.i" "3" } } */
+ return 0; /* { dg-final { gdb-test . "gs1.j" "4" } } */
+}