From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 6C973385800C for ; Mon, 5 Jul 2021 06:51:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6C973385800C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 53D0A225AE; Mon, 5 Jul 2021 06:51:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1625467907; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qz/jylwQ+Wy38o4A6Ah+l/b3afN7QeqQAYZNVSSIy3U=; b=kHrnGtIeF7XWImtSIE3e/iWKQ5ztQhli4AysQVHhfGJZTposJFXhaPyN4s85wk1drgzwLz 4hXUjb5UoGz9gjqyQNrovIx25ZoFv+aIYsVaV4OkWR0vDnYgYAxpSSzS458eTaAhVTFpbK kixozBx6Qez4E/xktmNeYwTq8viDhB8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1625467907; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qz/jylwQ+Wy38o4A6Ah+l/b3afN7QeqQAYZNVSSIy3U=; b=W8rDutUl4VfKnQCNUcQBVhxYvfg4ft13t7oJp6PSwLkRw1PxlHpRWZyOkU6hT1NuhM5M8W WSeGqXiemAQG3+AQ== Received: from murzim.suse.de (murzim.suse.de [10.160.4.192]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 4E167A3B8A; Mon, 5 Jul 2021 06:51:47 +0000 (UTC) Date: Mon, 5 Jul 2021 08:51:47 +0200 (CEST) From: Richard Biener To: Martin Sebor cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] add -fmove-loop-stores option to control GIMPLE loop store-motion In-Reply-To: <2937c7c7-7ee3-9b83-1a67-a1a423a6ff55@gmail.com> Message-ID: References: <2937c7c7-7ee3-9b83-1a67-a1a423a6ff55@gmail.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jul 2021 06:51:50 -0000 On Fri, 2 Jul 2021, Martin Sebor wrote: > On 7/2/21 5:55 AM, Richard Biener wrote: > > 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. > > > > Bootstrap and regtest running on x86_64-unknown-linux-gnu. > > > > OK? > > > > Thanks, > > Richard. > > > > 2021-07-02 Richard Biener > > > > * 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. > > --- > > gcc/common.opt | 4 ++++ > > gcc/doc/invoke.texi | 11 +++++++++-- > > gcc/opts.c | 1 + > > gcc/tree-ssa-loop-im.c | 2 +- > > 4 files changed, 15 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 a9fd5fdc104..7b4f5d26738 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,12 @@ 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. Note for > > +this option to have an effect @code{-ftree-loop-im} has to be enabled as > > well. > ^^^^^ > > The @code markup should be @option as well (same as below). Ah, thanks - fixed. > I find the brief text added to gcc/common.opt more informative than > this longer description. Explaining what the store motion pass does > in a few words would be helpful to those not familiar with > the implementation. OK, so is the following more useful then? " @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}. " Richard. > Martin > > > > +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 (); > > > > > -- Richard Biener SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)