GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "rtl.h"
#include "rtlanal.h"
#include "df.h"
#include "rtl-ssa.h"
#include "predict.h"
#include "cfgrtl.h"
#include "cfgcleanup.h"
#include "cfgloop.h"
#include "tree-pass.h"
#include "rtl-iter.h"
#include "target.h"
Macros | |
#define | INCLUDE_ALGORITHM |
#define | INCLUDE_FUNCTIONAL |
#define | INCLUDE_ARRAY |
Functions | |
static bool | can_simplify_addr (rtx addr) |
static bool | should_replace_address (int old_num_changes, rtx mem, rtx_insn *insn) |
static bool | reg_single_def_p (rtx x) |
static int | try_fwprop_subst_note (insn_info *use_insn, set_info *def, rtx note, rtx dest, rtx src, bool require_constant) |
static bool | try_fwprop_subst_pattern (obstack_watermark &attempt, insn_change &use_change, set_info *def, rtx *loc, rtx dest, rtx src) |
static bool | try_fwprop_subst_notes (insn_info *use_insn, set_info *def, rtx dest, rtx src) |
static bool | try_fwprop_subst (use_info *use, set_info *def, rtx *loc, rtx dest, rtx src) |
static bool | free_load_extend (rtx src, insn_info *insn) |
static bool | forward_propagate_subreg (use_info *use, set_info *def, rtx dest, rtx src, df_ref ref) |
static bool | forward_propagate_subreg (use_info *use, set_info *def, rtx dest, rtx src) |
static bool | forward_propagate_and_simplify (use_info *use, set_info *def, rtx dest, rtx src) |
static bool | forward_propagate_into (use_info *use, bool reg_prop_only=false) |
static void | fwprop_init (void) |
static void | fwprop_done (void) |
static bool | fwprop_insn (insn_info *insn, bool fwprop_addr_p) |
static bool | gate_fwprop (void) |
static unsigned int | fwprop (bool fwprop_addr_p) |
rtl_opt_pass * | make_pass_rtl_fwprop (gcc::context *ctxt) |
rtl_opt_pass * | make_pass_rtl_fwprop_addr (gcc::context *ctxt) |
Variables | |
static int | num_changes |
#define INCLUDE_ALGORITHM |
RTL-based forward propagation pass for GNU compiler. Copyright (C) 2005-2024 Free Software Foundation, Inc. Contributed by Paolo Bonzini and Steven Bosscher. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>.
#define INCLUDE_ARRAY |
#define INCLUDE_FUNCTIONAL |
Do not try to replace constant addresses or addresses of local and argument slots. These MEM expressions are made only once and inserted in many instructions, as well as being used to control symbol table output. It is not safe to clobber them. There are some uncommon cases where the address is already in a register for some reason, but we cannot take advantage of that because we have no easy way to unshare the MEM. In addition, looking up all stack addresses is costly.
References CONSTANT_ADDRESS_P, GET_CODE, HARD_FRAME_POINTER_REGNUM, REG_P, REGNO, and XEXP.
|
static |
Try to substitute (set DEST SRC), which defines DEF, into USE and simplify the result.
References avoid_constant_pool_reference(), contains_paradoxical_subreg_p(), copy_rtx(), find_reg_note(), GET_MODE, use::insn, MEM_P, MEM_READONLY_P, NULL_RTX, PATTERN(), REG_P, SET_DEST, set_for_reg_notes(), SET_SRC, set_unique_reg_note(), simplify_replace_rtx(), single_set(), try_fwprop_subst(), and XEXP.
Referenced by forward_propagate_into().
Given a use USE of an insn, if it has a single reaching definition, try to forward propagate it into that insn. Return true if something changed. REG_PROP_ONLY is true if we should only propagate register copies.
References find_reg_note(), flow_loop_nested_p(), forward_propagate_and_simplify(), forward_propagate_subreg(), use::insn, JUMP_P, multiple_sets(), NONJUMP_INSN_P, NULL_RTX, PATTERN(), reg_single_def_p(), SET_DEST, SET_SRC, simple_regno_set(), and volatile_refs_p().
Referenced by fwprop_insn().
Try to substitute (set DEST SRC), which defines DEF, into USE and simplify the result, handling cases where DEST is used in a subreg and where applying that subreg to SRC results in a useful simplification.
References DF_REF_REGNO, FOR_EACH_INSN_EQ_USE, FOR_EACH_INSN_USE, forward_propagate_subreg(), GET_CODE, use::insn, and REG_P.
|
static |
Subroutine of forward_propagate_subreg that handles a use of DEST in REF. The other parameters are the same.
References DF_REF_LOC, DF_REF_REG, free_load_extend(), GET_CODE, GET_MODE, is_a(), paradoxical_subreg_p(), REG_P, REGNO, subreg_lowpart_p(), SUBREG_REG, targetm, try_fwprop_subst(), use_reg(), and XEXP.
Referenced by forward_propagate_into(), and forward_propagate_subreg().
For the given single_set INSN, containing SRC known to be a ZERO_EXTEND or SIGN_EXTEND of a register, return true if INSN is redundant due to the register being set by a LOAD_EXTEND_OP load from memory.
References GET_CODE, GET_MODE, load_extend_op(), NONJUMP_INSN_P, PATTERN(), REGNO, rtx_equal_p(), SET, SET_DEST, SET_SRC, and XEXP.
Referenced by forward_propagate_subreg().
|
static |
References crtl, fwprop_done(), fwprop_init(), fwprop_insn(), i, and worklist.
|
static |
References CDI_DOMINATORS, cleanup_cfg(), crtl, delete_trivially_dead_insns(), dump_file, free_dominance_info(), get_insns(), loop_optimizer_finalize(), max_reg_num(), and num_changes.
Referenced by fwprop().
|
static |
References AVOID_CFG_MODIFICATIONS, calculate_dominance_info(), CDI_DOMINATORS, cfun, crtl, df_analyze(), loop_optimizer_init(), and num_changes.
Referenced by fwprop().
Try to optimize INSN, returning true if something changes. FWPROP_ADDR_P is true if we are running fwprop_addr rather than the full fwprop.
References forward_propagate_into(), loop_outer(), and NULL.
Referenced by fwprop().
|
static |
Main entry point.
rtl_opt_pass * make_pass_rtl_fwprop | ( | gcc::context * | ctxt | ) |
rtl_opt_pass * make_pass_rtl_fwprop_addr | ( | gcc::context * | ctxt | ) |
Check that X has a single def.
References crtl, REG_P, and REGNO.
Referenced by forward_propagate_into().
MEM is the result of an address simplification, and temporarily undoing changes OLD_NUM_CHANGES onwards restores the original address. Return whether it is good to use the new address instead of the old one. INSN is the containing instruction.
References address_cost(), BLOCK_FOR_INSN(), GET_MODE, MEM_ADDR_SPACE, optimize_bb_for_speed_p(), set_src_cost(), and XEXP.
|
static |
Check whether we could validly substitute (set DEST SRC), which defines DEF, into USE. If so, first try performing the substitution in location LOC of USE->insn ()'s pattern. If that fails, try instead to substitute into the notes. Return true on success, otherwise leave USE_INSN unchanged.
References crtl, HARD_REGISTER_P, use::insn, REG_P, try_fwprop_subst_notes(), and try_fwprop_subst_pattern().
Referenced by forward_propagate_and_simplify(), and forward_propagate_subreg().
|
static |
Try to substitute (set DEST SRC), which defines DEF, into note NOTE of USE_INSN. Return the number of substitutions on success, otherwise return -1 and leave USE_INSN unchanged. If REQUIRE_CONSTANT is true, require all substituted occurrences of SRC to fold to a constant, so that the note does not use any more registers than it did previously. If REQUIRE_CONSTANT is false, also allow the substitution if it's something we'd normally allow for the main instruction pattern.
References dump_file, dump_flags, INSN_UID(), insn_change_watermark::keep(), print_inline_rtx(), TDF_DETAILS, and XEXP.
Referenced by try_fwprop_subst_notes(), and try_fwprop_subst_pattern().
|
static |
Try to substitute (set DEST SRC), which defines DEF, into USE_INSN's notes, given that it was not possible to do this for USE_INSN's main pattern. Return true on success, otherwise leave USE_INSN unchanged.
References confirm_change_group(), REG_NOTE_KIND, REG_NOTES, try_fwprop_subst_note(), and XEXP.
Referenced by try_fwprop_subst().
|
static |
Try to substitute (set DEST SRC), which defines DEF, into location LOC of USE_INSN's pattern. Return true on success, otherwise leave USE_INSN unchanged.
References cancel_changes(), confirm_change_group(), contains_mem_rtx_p(), contains_paradoxical_subreg_p(), copy_rtx(), crtl, dump_file, dump_flags, find_reg_note(), free_EXPR_LIST_node(), NULL_RTX, num_changes, PATTERN(), print_rtl_single(), recog(), REG_NOTE_KIND, REG_NOTES, REG_P, SET_DEST, set_for_reg_notes(), SET_SRC, set_unique_reg_note(), TDF_DETAILS, try_fwprop_subst_note(), and XEXP.
Referenced by try_fwprop_subst().