public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-2050] add -fmove-loop-stores option to control GIMPLE loop store-motion
@ 2021-07-06 9:57 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-07-06 9:57 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:9f489a5731f12b8e6b49994e8f61acb5d26f508e
commit r12-2050-g9f489a5731f12b8e6b49994e8f61acb5d26f508e
Author: Richard Biener <rguenther@suse.de>
Date: Fri Jul 2 13:48:07 2021 +0200
add -fmove-loop-stores option to control GIMPLE loop store-motion
This adds the -fmove-loop-stores option, mainly as a way to disable
the store-motion part of GIMPLE invariant motion (-ftree-loop-im)
which is enabled by default. It might be sensible to turn off
-fmove-loop-stores at -O1 since it can result in compile-time
as well as memory usage issues but this patch tries to preserve
existing behavior besides introducing the new option with the
exception of -Og where I've disabled it.
Controlling store-motion has been made easy by earlier refactoring
for the invariant motion only use after loop interchange.
2021-07-02 Richard Biener <rguenther@suse.de>
* doc/invoke.texi (fmove-loop-stores): Document.
* common.opt (fmove-loop-stores): New option.
* opts.c (default_options_table): Enable -fmove-loop-stores
at -O1 but not -Og.
* tree-ssa-loop-im.c (pass_lim::execute): Pass
flag_move_loop_stores instead of true to
loop_invariant_motion_in_fun.
Diff:
---
gcc/common.opt | 4 ++++
gcc/doc/invoke.texi | 14 ++++++++++++--
gcc/opts.c | 1 +
gcc/tree-ssa-loop-im.c | 2 +-
4 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/gcc/common.opt b/gcc/common.opt
index 5b03bbc6662..d9da1131eda 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2084,6 +2084,10 @@ fmove-loop-invariants
Common Var(flag_move_loop_invariants) Optimization
Move loop invariant computations out of loops.
+fmove-loop-stores
+Common Var(flag_move_loop_stores) Optimization
+Move stores out of loops.
+
fdce
Common Var(flag_dce) Init(1) Optimization
Use the RTL dead code elimination pass.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index f470fc6be58..e67d47af676 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -528,7 +528,7 @@ Objective-C and Objective-C++ Dialects}.
-floop-parallelize-all -flra-remat -flto -flto-compression-level @gol
-flto-partition=@var{alg} -fmerge-all-constants @gol
-fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves @gol
--fmove-loop-invariants -fno-branch-count-reg @gol
+-fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg @gol
-fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse @gol
-fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole @gol
-fno-peephole2 -fno-printf-return-value -fno-sched-interblock @gol
@@ -10260,6 +10260,7 @@ compilation time.
-fipa-reference-addressable @gol
-fmerge-constants @gol
-fmove-loop-invariants @gol
+-fmove-loop-stores@gol
-fomit-frame-pointer @gol
-freorder-blocks @gol
-fshrink-wrap @gol
@@ -10403,7 +10404,7 @@ optimization flags except for those that may interfere with debugging:
@gccoptlist{-fbranch-count-reg -fdelayed-branch @gol
-fdse -fif-conversion -fif-conversion2 @gol
-finline-functions-called-once @gol
--fmove-loop-invariants -fssa-phiopt @gol
+-fmove-loop-invariants -fmove-loop-stores -fssa-phiopt @gol
-ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra}
@end table
@@ -13011,6 +13012,15 @@ Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}.
Enables the loop invariant motion pass in the RTL loop optimizer. Enabled
at level @option{-O1} and higher, except for @option{-Og}.
+@item -fmove-loop-stores
+@opindex fmove-loop-stores
+Enables the loop store motion pass in the GIMPLE loop optimizer. This
+moves invariant stores to after the end of the loop in exchange for
+carrying the stored value in a register across the iteration.
+Note for this option to have an effect @option{-ftree-loop-im} has to
+be enabled as well. Enabled at level @option{-O1} and higher, except
+for @option{-Og}.
+
@item -fsplit-loops
@opindex fsplit-loops
Split a loop into two if it contains a condition that's always true
diff --git a/gcc/opts.c b/gcc/opts.c
index f159bb35130..25282f71a3b 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -575,6 +575,7 @@ static const struct default_options default_options_table[] =
{ 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_fmove_loop_stores, NULL, 1 },
{ OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fssa_phiopt, NULL, 1 },
{ OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fipa_modref, NULL, 1 },
{ OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_ftree_bit_ccp, NULL, 1 },
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index e7a3050ba9d..9ac390b9a4b 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -3258,7 +3258,7 @@ pass_lim::execute (function *fun)
if (number_of_loops (fun) <= 1)
return 0;
- unsigned int todo = loop_invariant_motion_in_fun (fun, true);
+ unsigned int todo = loop_invariant_motion_in_fun (fun, flag_move_loop_stores);
if (!in_loop_pipeline)
loop_optimizer_finalize ();
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-06 9:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-06 9:57 [gcc r12-2050] add -fmove-loop-stores option to control GIMPLE loop store-motion Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).