From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id 6C6EB3858404 for ; Mon, 11 Jul 2022 20:31:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6C6EB3858404 Received: by mail-pg1-x52a.google.com with SMTP id f11so4845131pgj.7 for ; Mon, 11 Jul 2022 13:31:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=2zJQUaAm7e+NdBw5Qe+Sx4RAZdOVTvKL8CKKPYOKw4k=; b=uAKz2syYzJMVkcgOnodyTmS2p0IBJyoiV8U7WOup5Dz5cwZuHhTc3z/kbUI3mdljtM 23r7sFEiP03wCyybTYla6BdNVjTx+9FlYcI+tFytml86lv4YKyPJfMXluEpdqU+20z3a 8JCW+28pYuDQ1v/pLnLGCGdyg2N0UV0NiZFAJ43gAgU+VDBPihV1B6hYUic/JlTLADKV 16L9hECZw5uj1MRPClAf6Ue0s7CKoIuDjB0oJdwGaZ1vofKVQKwhluHuxCnGp3ibVVKd 2bzK5BVJtf6xVt/CWiEUjgU4McETc05IQNhM62VOojoH5Izat8IpQXUV7T69yj9iF50Q 9zXg== X-Gm-Message-State: AJIora8SX/8kW71R+SfYq1IbHYdHARgTYlhNXZz4NOWw9dVKeaZXkPQW 5S/PAQ3XOw1e6DnVO5302tNjKV49/YI= X-Google-Smtp-Source: AGRyM1sX6//woopubCU/guNIIK8yCs9pM2mXsxh3tGWu+hH9zY8zuoz6hofXiuG8f5s+BJApM2TMXg== X-Received: by 2002:a05:6a00:22d6:b0:525:74b3:d020 with SMTP id f22-20020a056a0022d600b0052574b3d020mr19882071pfj.80.1657571489756; Mon, 11 Jul 2022 13:31:29 -0700 (PDT) Received: from [172.31.0.204] (c-73-63-24-84.hsd1.ut.comcast.net. [73.63.24.84]) by smtp.gmail.com with ESMTPSA id p7-20020a63f447000000b003fc4001fd5fsm4519601pgk.10.2022.07.11.13.31.27 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 Jul 2022 13:31:28 -0700 (PDT) Message-ID: Date: Mon, 11 Jul 2022 14:31:26 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH] Move reload_completed and other rtl.h globals to crtl structure. Content-Language: en-US To: gcc-patches@gcc.gnu.org References: <00e601d89489$a5133740$ef39a5c0$@nextmovesoftware.com> From: Jeff Law In-Reply-To: <00e601d89489$a5133740$ef39a5c0$@nextmovesoftware.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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, 11 Jul 2022 20:31:33 -0000 On 7/10/2022 12:19 PM, Roger Sayle wrote: > This patch builds upon Richard Biener's suggestion of avoiding global > variables to track state/identify which passes have already been run. > In the early middle-end, the tree-ssa passes use the curr_properties > field in cfun to track this. This patch uses a new rtl_pass_progress > int field in crtl to do something similar. > > This patch allows the global variables lra_in_progress, reload_in_progress, > reload_completed, epilogue_completed and regstack_completed to be removed > from rtl.h and implemented as bits within the new crtl->rtl_pass_progress. > I've also taken the liberty of adding a new combine_completed bit at the > same time [to respond the Segher's comment it's easy to change this to > combine1_completed and combine2_completed if we ever perform multiple > combine passes (or multiple reload/regstack passes)]. At the same time, > I've also refactored bb_reorder_complete into the same new field; > interestingly bb_reorder_complete was already a bool in crtl. > > One very minor advantage of this implementation/refactoring is that the > predicate "can_create_pseudo_p ()" which is semantically defined to be > !reload_in_progress && !reload_completed, can now be performed very > efficiently as effectively the test (progress & 12) == 0, i.e. a single > test instruction on x86. > > For consistency, I've also moved cse_not_expected (the last remaining > global variable in rtl.h) into crtl, as its own bool field. > > The vast majority of this patch is then churn to handle these changes. > Thanks to macros, most code is unaffected, assuming it treats those > global variables as r-values, though some source files required/may > require tweaks as these "variables" are now defined in emit-rtl.h > instead of rtl.h. > > This patch has been tested on x86_64-pc-linux-gnu with make bootstrap > and make -k check, both with and without --target_board=unix{-m32}, > with no new failures. Might this clean-up be acceptable in stage 1, > given the possible temporary disruption transitioning some backends? > I'll start checking various backends myself with cross-compilers, but if > Jeff Law could spin this patch on his build farm, that would help > identify targets that need attention. > > > 2022-07-10 Roger Sayle > > gcc/ChangeLog > * bb-reorder.cc (reorder_basic_blocks): bb_reorder_complete is > now a bit in crtl->rtl_pass_progress. > * cfgrtl.cc (rtl_split_edge): Likewise. > (fixup_partitions): Likewise. > (verify_hot_cold_block_grouping): Likewise. > (cfg_layout_initialize): Likewise. > * combine.cc (rest_of_handle_combine): Set combine_completed > bit in crtl->rtl_pass_progress. > * cse.cc (rest_of_handle_cse): cse_not_expected is now a field > in crtl. > (rest_of_handle_cse2): Likewise. > (rest_of_handle_cse_after_global_opts): Likewise. > * df-problems.cc: Include emit-rtl.h to access RTL pass progress > variables. > > * emit-rtl.h (PROGRESS_reload_completed): New bit masks. > (rtl_data::rtl_pass_progress): New integer field to track progress. > (rtl_data::bb_reorder_complete): Delete, no part of > rtl_pass_progress. > (rtl_data::cse_not_expected): New bool field, previously a global > variable. > (crtl_pass_progress): New convience macro. > (combine_completed): New macro. > (lra_in_progress): New macro replacing global variable. > (reload_in_progress): Likewise. > (reload_completed): Likewise. > (bb_reorder_complete): New macro replacing bool field in crtl. > (epilogue_completed): New macro replacing global variable. > (regstack_completed): Likewise. > (can_create_pseudo_p): Move from rtl.h and update definition. > > * explow.cc (memory_address_addr_space): cse_not_expected is now > a field in crtl. > (use_anchored_address): Likewise. > * final.c (rest_of_clean_state): Reset crtl->rtl_pass_progress > to zero. > * function.cc (prepare_function_start): cse_not_expected is now > a field in crtl. > (thread_prologue_and_epilogue_insns): epilogue_completed is now > a bit in crtl->rtl_pass_progress. > * ifcvt.cc (noce_try_cmove_arith): cse_not_expected is now a > field in crtl. > * lra-eliminations.cc (init_elim_table): lra_in_progress is now > a bit in crtl->rtl_pass_progress. > * lra.cc (lra_in_progress): Delete global variable. > (lra): lra_in_progress and reload_completed are now bits in > crtl->rtl_pass_progress. > * modulo-sched.cc (sms_schedule): reload_completed is now a bit > in crtl->rtl_pass_progress. > * passes.cc (skip_pass): reload_completed and epilogue_completed > are now bits in crtl->rtl_pass_progress. > * recog.cc (reload_completed): Delete global variable. > (epilogue_completed): Likewise. > * reg-stack.cc (regstack_completed): Likewise. > (rest_of_handle_stack_regs): regstack_completed is now a bit in > crtl->rtl_pass_progress. > * regstat.cc: Include memmodel.h and emit-rtl.h to access RTL > pass progress variables. > * reload1.cc (reload_in_progress): Delete global variable. > (reload): reload_in_progress and reload_completed are now bits > in crtl->rtl_pass_progress. > * rtl.h (reload_completed): Delete global variable prototype. > (epilogue_completed): Likewise. > (reload_in_progress): Likewise. > (lra_in_progress): Likewise. > (can_create_pseudo_p): Delete, moved to emit-rtl.h. > (regstack_completed): Delete global variable prototype. > (cse_not_expected): Likewise. > * sched-ebb.cc: Include memmodel.h and emit-rtl.h to access RTL > pass progress variables. > > * config/i386/x86-tune-sched-atom.cc: Include memmodel.h and > emit-rtl.h to access RTL pass progress variables. > * config/i386/x86-tune-sched.cc: Likewise. So we need a #include "emit-rtl.h" generated by genpeep.cc and genconditions.cc which fixes a number of targets. Several targets use reload_completed, epilogue_completed as lvalues and will need updating (microblaze, sh, likely others).  Most should be complete by this time tomorrow. Jeff