From patchwork Sun Jul 7 17:12:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Segher Boessenkool X-Patchwork-Id: 1128699 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-504541-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45hZrm0X2wz9s8m for ; Mon, 8 Jul 2019 03:12:17 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; q=dns; s=default; b=bWhROoMB885k hfNQW8phEiPZUXGsJ+g03v6kEaN51T2ClMw2S03BLX/0ahJLFTEsox+zA+UbixHu 1JIuEopeypv/BXnftWV4kygmVHe/Nid9yx6aNuipC0TONtXgOex87FBMR12DzddU Q3t1P+szanAPcSJjFUoJfcNRWBuaqj8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; s=default; bh=wkAAd9ES4XBamJwv8m IrKoq5DZk=; b=DYu9BsdhHxMBToVIUCp+uB7KUQ4yrLN40QcIQHPNvq0zK7bcAb k1z68LJEWUnWl9ZjuuSIk34Uy7B8tm0a5wmKX9jTOuWnUDEs7uYHusYIkBscA4hQ annSe2nP/NowsqucFfPgtDClNnBiMfH8KSeqzCspNCFBtafZqtRuD0SLk= Received: (qmail 122215 invoked by alias); 7 Jul 2019 17:12:09 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 122206 invoked by uid 89); 7 Jul 2019 17:12:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=independent, Fully, gate X-HELO: gcc1-power7.osuosl.org Received: from gcc1-power7.osuosl.org (HELO gcc1-power7.osuosl.org) (140.211.15.137) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 07 Jul 2019 17:12:06 +0000 Received: by gcc1-power7.osuosl.org (Postfix, from userid 10019) id 2C403124069F; Sun, 7 Jul 2019 17:12:05 +0000 (UTC) From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool Subject: [PATCH] subreg: Add -fsplit-wide-types-early (PR88233) Date: Sun, 7 Jul 2019 17:12:02 +0000 Message-Id: <0c1cd0e5706087d51c0d981a313786990ddcad89.1562518763.git.segher@kernel.crashing.org> X-IsSubscribed: yes Currently the second lower-subreg pass is run right before RA. This is much too late to be very useful. At least for targets that do not have RTL patterns for operations on multi-register modes it is a lot better to split patterns earlier, before combine and all related passes. This adds an option -fsplit-wide-types-early that does that, and enables it by default for rs6000. 2019-07-07 Segher Boessenkool PR rtl-optimization/88233 * common.opt (fsplit-wide-types-early): New option. * common/config/rs6000/rs6000-common.c (rs6000_option_optimization_table): Add OPT_fsplit_wide_types_early for OPT_LEVELS_ALL. * doc/invoke.texi (Optimization Options): Add -fsplit-wide-types-early. * lower-subreg.c (pass_lower_subreg2::gate): Add test for flag_split_wide_types_early. (pass_data_lower_subreg3): New. (pass_lower_subreg3): New. (make_pass_lower_subreg3): New. * passes.def (pass_lower_subreg2): Move after the loop passes. (pass_lower_subreg3): New, inserted where pass_lower_subreg2 was. * tree-pass.h (make_pass_lower_subreg2): Move up, to its new place in the pass pipeline; its previous place is taken by ... (make_pass_lower_subreg3): ... this. --- gcc/common.opt | 4 +++ gcc/common/config/rs6000/rs6000-common.c | 2 ++ gcc/doc/invoke.texi | 8 +++++- gcc/lower-subreg.c | 46 +++++++++++++++++++++++++++++++- gcc/passes.def | 3 ++- gcc/tree-pass.h | 3 ++- 6 files changed, 62 insertions(+), 4 deletions(-) diff --git a/gcc/common.opt b/gcc/common.opt index 41514df..b998b25 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2430,6 +2430,10 @@ fsplit-wide-types Common Report Var(flag_split_wide_types) Optimization Split wide types into independent registers. +fsplit-wide-types-early +Common Report Var(flag_split_wide_types_early) Optimization +Split wide types into independent registers earlier. + fssa-backprop Common Report Var(flag_ssa_backprop) Init(1) Optimization Enable backward propagation of use properties at the SSA level. diff --git a/gcc/common/config/rs6000/rs6000-common.c b/gcc/common/config/rs6000/rs6000-common.c index 9857b54..4b0c205 100644 --- a/gcc/common/config/rs6000/rs6000-common.c +++ b/gcc/common/config/rs6000/rs6000-common.c @@ -31,6 +31,8 @@ /* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */ static const struct default_options rs6000_option_optimization_table[] = { + /* Split multi-word types early. */ + { OPT_LEVELS_ALL, OPT_fsplit_wide_types_early, NULL, 1 }, /* Enable -fsched-pressure for first pass instruction scheduling. */ { OPT_LEVELS_1_PLUS, OPT_fsched_pressure, NULL, 1 }, { OPT_LEVELS_NONE, 0, NULL, 0 } diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 73d16b5..6349d4c 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -467,7 +467,7 @@ Objective-C and Objective-C++ Dialects}. -fsignaling-nans @gol -fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops@gol -fsplit-paths @gol --fsplit-wide-types -fssa-backprop -fssa-phiopt @gol +-fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt @gol -fstdarg-opt -fstore-merging -fstrict-aliasing @gol -fthread-jumps -ftracer -ftree-bit-ccp @gol -ftree-builtin-call-dce -ftree-ccp -ftree-ch @gol @@ -8731,6 +8731,12 @@ but may make debugging more difficult. Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}. +@item -fsplit-wide-types-early +@opindex fsplit-wide-types-early +Fully split wide types early, instead of very late. + +This is the default on some targets. + @item -fcse-follow-jumps @opindex fcse-follow-jumps In common subexpression elimination (CSE), scan through jump instructions diff --git a/gcc/lower-subreg.c b/gcc/lower-subreg.c index 4f68a73..e1418e5 100644 --- a/gcc/lower-subreg.c +++ b/gcc/lower-subreg.c @@ -1801,7 +1801,8 @@ public: {} /* opt_pass methods: */ - virtual bool gate (function *) { return flag_split_wide_types != 0; } + virtual bool gate (function *) { return flag_split_wide_types + && flag_split_wide_types_early; } virtual unsigned int execute (function *) { decompose_multiword_subregs (true); @@ -1817,3 +1818,46 @@ make_pass_lower_subreg2 (gcc::context *ctxt) { return new pass_lower_subreg2 (ctxt); } + +/* Implement third lower subreg pass. */ + +namespace { + +const pass_data pass_data_lower_subreg3 = +{ + RTL_PASS, /* type */ + "subreg3", /* name */ + OPTGROUP_NONE, /* optinfo_flags */ + TV_LOWER_SUBREG, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + TODO_df_finish, /* todo_flags_finish */ +}; + +class pass_lower_subreg3 : public rtl_opt_pass +{ +public: + pass_lower_subreg3 (gcc::context *ctxt) + : rtl_opt_pass (pass_data_lower_subreg3, ctxt) + {} + + /* opt_pass methods: */ + virtual bool gate (function *) { return flag_split_wide_types + && !flag_split_wide_types_early; } + virtual unsigned int execute (function *) + { + decompose_multiword_subregs (true); + return 0; + } + +}; // class pass_lower_subreg3 + +} // anon namespace + +rtl_opt_pass * +make_pass_lower_subreg3 (gcc::context *ctxt) +{ + return new pass_lower_subreg3 (ctxt); +} diff --git a/gcc/passes.def b/gcc/passes.def index 9a5b0cd..1a7fd14 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -427,6 +427,7 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_rtl_doloop); NEXT_PASS (pass_rtl_loop_done); POP_INSERT_PASSES () + NEXT_PASS (pass_lower_subreg2); NEXT_PASS (pass_web); NEXT_PASS (pass_rtl_cprop); NEXT_PASS (pass_cse2); @@ -440,7 +441,7 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_partition_blocks); NEXT_PASS (pass_outof_cfg_layout_mode); NEXT_PASS (pass_split_all_insns); - NEXT_PASS (pass_lower_subreg2); + NEXT_PASS (pass_lower_subreg3); NEXT_PASS (pass_df_initialize_no_opt); NEXT_PASS (pass_stack_ptr_mod); NEXT_PASS (pass_mode_switching); diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index b27dbdd..7b83293 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -552,6 +552,7 @@ extern rtl_opt_pass *make_pass_rtl_unroll_loops (gcc::context *ctxt); extern rtl_opt_pass *make_pass_rtl_doloop (gcc::context *ctxt); extern rtl_opt_pass *make_pass_rtl_loop_done (gcc::context *ctxt); +extern rtl_opt_pass *make_pass_lower_subreg2 (gcc::context *ctxt); extern rtl_opt_pass *make_pass_web (gcc::context *ctxt); extern rtl_opt_pass *make_pass_cse2 (gcc::context *ctxt); extern rtl_opt_pass *make_pass_df_initialize_opt (gcc::context *ctxt); @@ -567,7 +568,7 @@ extern rtl_opt_pass *make_pass_partition_blocks (gcc::context *ctxt); extern rtl_opt_pass *make_pass_match_asm_constraints (gcc::context *ctxt); extern rtl_opt_pass *make_pass_split_all_insns (gcc::context *ctxt); extern rtl_opt_pass *make_pass_fast_rtl_byte_dce (gcc::context *ctxt); -extern rtl_opt_pass *make_pass_lower_subreg2 (gcc::context *ctxt); +extern rtl_opt_pass *make_pass_lower_subreg3 (gcc::context *ctxt); extern rtl_opt_pass *make_pass_mode_switching (gcc::context *ctxt); extern rtl_opt_pass *make_pass_sms (gcc::context *ctxt); extern rtl_opt_pass *make_pass_sched (gcc::context *ctxt);