From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41851 invoked by alias); 6 Jul 2015 12:12:28 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 41788 invoked by uid 89); 6 Jul 2015 12:12:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.1 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 06 Jul 2015 12:12:10 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZC5Fj-0000qU-3z for gcc-patches@gcc.gnu.org; Mon, 06 Jul 2015 08:12:07 -0400 Received: from tbsaunde.org ([66.228.47.254]:43408 helo=paperclip.tbsaunde.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZC5Fi-0000qA-Vm for gcc-patches@gcc.gnu.org; Mon, 06 Jul 2015 08:12:03 -0400 Received: from iceball.corp.tor1.mozilla.com (unknown [23.233.68.71]) by paperclip.tbsaunde.org (Postfix) with ESMTPSA id 7B818C10E for ; Mon, 6 Jul 2015 12:12:02 +0000 (UTC) From: tbsaunde+gcc@tbsaunde.org To: gcc-patches@gcc.gnu.org Subject: [PATCH 6/7] reduce conditional compilation based on AUTO_INC_DEC Date: Mon, 06 Jul 2015 12:12:00 -0000 Message-Id: <1436184690-30134-7-git-send-email-tbsaunde+gcc@tbsaunde.org> In-Reply-To: <1436184690-30134-1-git-send-email-tbsaunde+gcc@tbsaunde.org> References: <1436184690-30134-1-git-send-email-tbsaunde+gcc@tbsaunde.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.228.47.254 X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg00320.txt.bz2 From: Trevor Saunders gcc/ChangeLog: 2015-07-06 Trevor Saunders * auto-inc-dec.c (pass_inc_dec::execute): Don't check the value of AUTO_INC_DEC with the preprocessor. * combine.c (combine_instructions): Likewise. (can_combine_p): Likewise. (try_combine): Likewise. * emit-rtl.c (try_split): Likewise. * loop-invariant.c (calculate_loop_reg_pressure): Likewise. * lower-subreg.c (resolve_simple_move): Likewise. * lra.c (update_inc_notes): Likewise. * recog.c (asm_operand_ok): Likewise. (constrain_operands): Likewise. * regrename.c (scan_rtx_address): Likewise. * reload.c (update_auto_inc_notes): Likewise. (reg_inc_found_and_valid_p): Likewise. * reload1.c (reload): Likewise. (emit_input_reload_insns): Likewise. (delete_output_reload): Likewise. * sched-deps.c (init_insn_reg_pressure_info): Likewise. * valtrack.c (cleanup_auto_inc_dec): Likewise. --- gcc/auto-inc-dec.c | 16 +++++------- gcc/combine.c | 73 ++++++++++++++++++++++++---------------------------- gcc/emit-rtl.c | 7 +++-- gcc/loop-invariant.c | 10 +++---- gcc/lower-subreg.c | 30 ++++++++++----------- gcc/lra.c | 8 +++--- gcc/recog.c | 13 +++------- gcc/regrename.c | 4 +-- gcc/reload.c | 16 +++++------- gcc/reload1.c | 20 +++++--------- gcc/sched-deps.c | 9 +++---- gcc/valtrack.c | 8 +++--- 12 files changed, 89 insertions(+), 125 deletions(-) diff --git a/gcc/auto-inc-dec.c b/gcc/auto-inc-dec.c index dd183ee..831622b 100644 --- a/gcc/auto-inc-dec.c +++ b/gcc/auto-inc-dec.c @@ -123,7 +123,6 @@ along with GCC; see the file COPYING3. If not see before the ref or +c if the increment was after the ref, then if we can do the combination but switch the pre/post bit. */ -#if AUTO_INC_DEC enum form { @@ -1448,8 +1447,6 @@ merge_in_block (int max_reg, basic_block bb) } } -#endif - /* Discover auto-inc auto-dec instructions. */ namespace { @@ -1477,11 +1474,10 @@ public: /* opt_pass methods: */ virtual bool gate (function *) { -#if AUTO_INC_DEC + if (!AUTO_INC_DEC) + return false; + return (optimize > 0 && flag_auto_inc_dec); -#else - return false; -#endif } @@ -1492,7 +1488,9 @@ public: unsigned int pass_inc_dec::execute (function *fun ATTRIBUTE_UNUSED) { -#if AUTO_INC_DEC + if (!AUTO_INC_DEC) + return 0; + basic_block bb; int max_reg = max_reg_num (); @@ -1515,7 +1513,7 @@ pass_inc_dec::execute (function *fun ATTRIBUTE_UNUSED) free (reg_next_def); mem_tmp = NULL; -#endif + return 0; } diff --git a/gcc/combine.c b/gcc/combine.c index 346bdff..96cc3cd 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -1204,9 +1204,7 @@ combine_instructions (rtx_insn *f, unsigned int nregs) FOR_BB_INSNS (this_basic_block, insn) if (INSN_P (insn) && BLOCK_FOR_INSN (insn)) { -#if AUTO_INC_DEC rtx links; -#endif subst_low_luid = DF_INSN_LUID (insn); subst_insn = insn; @@ -1215,12 +1213,11 @@ combine_instructions (rtx_insn *f, unsigned int nregs) insn); record_dead_and_set_regs (insn); -#if AUTO_INC_DEC - for (links = REG_NOTES (insn); links; links = XEXP (links, 1)) - if (REG_NOTE_KIND (links) == REG_INC) - set_nonzero_bits_and_sign_copies (XEXP (links, 0), NULL_RTX, - insn); -#endif + if (AUTO_INC_DEC) + for (links = REG_NOTES (insn); links; links = XEXP (links, 1)) + if (REG_NOTE_KIND (links) == REG_INC) + set_nonzero_bits_and_sign_copies (XEXP (links, 0), NULL_RTX, + insn); /* Record the current insn_rtx_cost of this instruction. */ if (NONJUMP_INSN_P (insn)) @@ -1798,9 +1795,7 @@ can_combine_p (rtx_insn *insn, rtx_insn *i3, rtx_insn *pred ATTRIBUTE_UNUSED, const_rtx set = 0; rtx src, dest; rtx_insn *p; -#if AUTO_INC_DEC rtx link; -#endif bool all_adjacent = true; int (*is_volatile_p) (const_rtx); @@ -2079,22 +2074,21 @@ can_combine_p (rtx_insn *insn, rtx_insn *i3, rtx_insn *pred ATTRIBUTE_UNUSED, Also insist that I3 not be a jump; if it were one and the incremented register were spilled, we would lose. */ -#if AUTO_INC_DEC - for (link = REG_NOTES (insn); link; link = XEXP (link, 1)) - if (REG_NOTE_KIND (link) == REG_INC - && (JUMP_P (i3) - || reg_used_between_p (XEXP (link, 0), insn, i3) - || (pred != NULL_RTX - && reg_overlap_mentioned_p (XEXP (link, 0), PATTERN (pred))) - || (pred2 != NULL_RTX - && reg_overlap_mentioned_p (XEXP (link, 0), PATTERN (pred2))) - || (succ != NULL_RTX - && reg_overlap_mentioned_p (XEXP (link, 0), PATTERN (succ))) - || (succ2 != NULL_RTX - && reg_overlap_mentioned_p (XEXP (link, 0), PATTERN (succ2))) - || reg_overlap_mentioned_p (XEXP (link, 0), PATTERN (i3)))) - return 0; -#endif + if (AUTO_INC_DEC) + for (link = REG_NOTES (insn); link; link = XEXP (link, 1)) + if (REG_NOTE_KIND (link) == REG_INC + && (JUMP_P (i3) + || reg_used_between_p (XEXP (link, 0), insn, i3) + || (pred != NULL_RTX + && reg_overlap_mentioned_p (XEXP (link, 0), PATTERN (pred))) + || (pred2 != NULL_RTX + && reg_overlap_mentioned_p (XEXP (link, 0), PATTERN (pred2))) + || (succ != NULL_RTX + && reg_overlap_mentioned_p (XEXP (link, 0), PATTERN (succ))) + || (succ2 != NULL_RTX + && reg_overlap_mentioned_p (XEXP (link, 0), PATTERN (succ2))) + || reg_overlap_mentioned_p (XEXP (link, 0), PATTERN (i3)))) + return 0; /* Don't combine an insn that follows a CC0-setting insn. An insn that uses CC0 must not be separated from the one that sets it. @@ -3045,20 +3039,19 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0, || GET_CODE (XEXP (SET_DEST (PATTERN (i3)), 0)) == POST_DEC))) /* It's not the exception. */ #endif -#if AUTO_INC_DEC - { - rtx link; - for (link = REG_NOTES (i3); link; link = XEXP (link, 1)) - if (REG_NOTE_KIND (link) == REG_INC - && (reg_overlap_mentioned_p (XEXP (link, 0), PATTERN (i2)) - || (i1 != 0 - && reg_overlap_mentioned_p (XEXP (link, 0), PATTERN (i1))))) - { - undo_all (); - return 0; - } - } -#endif + if (AUTO_INC_DEC) + { + rtx link; + for (link = REG_NOTES (i3); link; link = XEXP (link, 1)) + if (REG_NOTE_KIND (link) == REG_INC + && (reg_overlap_mentioned_p (XEXP (link, 0), PATTERN (i2)) + || (i1 != 0 + && reg_overlap_mentioned_p (XEXP (link, 0), PATTERN (i1))))) + { + undo_all (); + return 0; + } + } /* See if the SETs in I1 or I2 need to be kept around in the merged instruction: whenever the value set there is still needed past I3. diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index eb44066..12984299 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -3594,7 +3594,6 @@ prev_cc0_setter (rtx_insn *insn) return insn; } -#if AUTO_INC_DEC /* Find a RTX_AUTOINC class rtx which matches DATA. */ static int @@ -3610,7 +3609,6 @@ find_auto_inc (const_rtx x, const_rtx reg) } return false; } -#endif /* Increment the label uses for all labels present in rtx. */ @@ -3782,8 +3780,10 @@ try_split (rtx pat, rtx_insn *trial, int last) } break; -#if AUTO_INC_DEC case REG_INC: + if (!AUTO_INC_DEC) + break; + for (insn = insn_last; insn != NULL_RTX; insn = PREV_INSN (insn)) { rtx reg = XEXP (note, 0); @@ -3792,7 +3792,6 @@ try_split (rtx pat, rtx_insn *trial, int last) add_reg_note (insn, REG_INC, reg); } break; -#endif case REG_ARGS_SIZE: fixup_args_size_notes (NULL, insn_last, INTVAL (XEXP (note, 0))); diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c index 1285c66..d6c2c04 100644 --- a/gcc/loop-invariant.c +++ b/gcc/loop-invariant.c @@ -1998,11 +1998,11 @@ calculate_loop_reg_pressure (void) note_stores (PATTERN (insn), mark_reg_store, NULL); -#if AUTO_INC_DEC - for (link = REG_NOTES (insn); link; link = XEXP (link, 1)) - if (REG_NOTE_KIND (link) == REG_INC) - mark_reg_store (XEXP (link, 0), NULL_RTX, NULL); -#endif + if (AUTO_INC_DEC) + for (link = REG_NOTES (insn); link; link = XEXP (link, 1)) + if (REG_NOTE_KIND (link) == REG_INC) + mark_reg_store (XEXP (link, 0), NULL_RTX, NULL); + while (n_regs_set-- > 0) { rtx note = find_regno_note (insn, REG_UNUSED, diff --git a/gcc/lower-subreg.c b/gcc/lower-subreg.c index a57ce43..edcf73d 100644 --- a/gcc/lower-subreg.c +++ b/gcc/lower-subreg.c @@ -948,19 +948,19 @@ resolve_simple_move (rtx set, rtx_insn *insn) reg = gen_reg_rtx (orig_mode); -#if AUTO_INC_DEC - { - rtx move = emit_move_insn (reg, src); - if (MEM_P (src)) - { - rtx note = find_reg_note (insn, REG_INC, NULL_RTX); - if (note) - add_reg_note (move, REG_INC, XEXP (note, 0)); - } - } -#else - emit_move_insn (reg, src); -#endif + if (AUTO_INC_DEC) + { + rtx move = emit_move_insn (reg, src); + if (MEM_P (src)) + { + rtx note = find_reg_note (insn, REG_INC, NULL_RTX); + if (note) + add_reg_note (move, REG_INC, XEXP (note, 0)); + } + } + else + emit_move_insn (reg, src); + src = reg; } @@ -1051,15 +1051,13 @@ resolve_simple_move (rtx set, rtx_insn *insn) mdest = simplify_gen_subreg (orig_mode, dest, GET_MODE (dest), 0); minsn = emit_move_insn (real_dest, mdest); -#if AUTO_INC_DEC - if (MEM_P (real_dest) + if (AUTO_INC_DEC && MEM_P (real_dest) && !(resolve_reg_p (real_dest) || resolve_subreg_p (real_dest))) { rtx note = find_reg_note (insn, REG_INC, NULL_RTX); if (note) add_reg_note (minsn, REG_INC, XEXP (note, 0)); } -#endif smove = single_set (minsn); gcc_assert (smove != NULL_RTX); diff --git a/gcc/lra.c b/gcc/lra.c index 0bf822f..7a22996 100644 --- a/gcc/lra.c +++ b/gcc/lra.c @@ -2093,7 +2093,6 @@ has_nonexceptional_receiver (void) return false; } -#if AUTO_INC_DEC /* Process recursively X of INSN and add REG_INC notes if necessary. */ static void @@ -2121,7 +2120,6 @@ add_auto_inc_notes (rtx_insn *insn, rtx x) } } -#endif /* Remove all REG_DEAD and REG_UNUSED notes and regenerate REG_INC. We change pseudos by hard registers without notification of DF and @@ -2148,9 +2146,9 @@ update_inc_notes (void) else pnote = &XEXP (*pnote, 1); } -#if AUTO_INC_DEC - add_auto_inc_notes (insn, PATTERN (insn)); -#endif + + if (AUTO_INC_DEC) + add_auto_inc_notes (insn, PATTERN (insn)); } } diff --git a/gcc/recog.c b/gcc/recog.c index 2e8be6a..0d40da3 100644 --- a/gcc/recog.c +++ b/gcc/recog.c @@ -1720,9 +1720,7 @@ int asm_operand_ok (rtx op, const char *constraint, const char **constraints) { int result = 0; -#if AUTO_INC_DEC bool incdec_ok = false; -#endif /* Use constrain_operands after reload. */ gcc_assert (!reload_completed); @@ -1790,7 +1788,6 @@ asm_operand_ok (rtx op, const char *constraint, const char **constraints) result = 1; break; -#if AUTO_INC_DEC case '<': case '>': /* ??? Before auto-inc-dec, auto inc/dec insns are not supposed @@ -1800,7 +1797,6 @@ asm_operand_ok (rtx op, const char *constraint, const char **constraints) Match any memory and hope things are resolved after reload. */ incdec_ok = true; -#endif default: cn = lookup_constraint (constraint); switch (get_constraint_type (cn)) @@ -1844,9 +1840,8 @@ asm_operand_ok (rtx op, const char *constraint, const char **constraints) return 0; } -#if AUTO_INC_DEC /* For operands without < or > constraints reject side-effects. */ - if (!incdec_ok && result && MEM_P (op)) + if (AUTO_INC_DEC && !incdec_ok && result && MEM_P (op)) switch (GET_CODE (XEXP (op, 0))) { case PRE_INC: @@ -1859,7 +1854,6 @@ asm_operand_ok (rtx op, const char *constraint, const char **constraints) default: break; } -#endif return result; } @@ -2822,9 +2816,8 @@ constrain_operands (int strict, alternative_mask alternatives) = recog_data.operand[funny_match[funny_match_index].this_op]; } -#if AUTO_INC_DEC /* For operands without < or > constraints reject side-effects. */ - if (recog_data.is_asm) + if (AUTO_INC_DEC && recog_data.is_asm) { for (opno = 0; opno < recog_data.n_operands; opno++) if (MEM_P (recog_data.operand[opno])) @@ -2845,7 +2838,7 @@ constrain_operands (int strict, alternative_mask alternatives) break; } } -#endif + return 1; } } diff --git a/gcc/regrename.c b/gcc/regrename.c index 0fce77e..f10ea09 100644 --- a/gcc/regrename.c +++ b/gcc/regrename.c @@ -1312,11 +1312,11 @@ scan_rtx_address (rtx_insn *insn, rtx *loc, enum reg_class cl, case PRE_INC: case PRE_DEC: case PRE_MODIFY: -#if !AUTO_INC_DEC /* If the target doesn't claim to handle autoinc, this must be something special, like a stack push. Kill this chain. */ + if (!AUTO_INC_DEC) action = mark_all_read; -#endif + break; case MEM: diff --git a/gcc/reload.c b/gcc/reload.c index 3323816..0fdf97e 100644 --- a/gcc/reload.c +++ b/gcc/reload.c @@ -5454,14 +5454,13 @@ static void update_auto_inc_notes (rtx_insn *insn ATTRIBUTE_UNUSED, int regno ATTRIBUTE_UNUSED, int reloadnum ATTRIBUTE_UNUSED) { -#if AUTO_INC_DEC - rtx link; + if (!AUTO_INC_DEC) + return; - for (link = REG_NOTES (insn); link; link = XEXP (link, 1)) + for (rtx link = REG_NOTES (insn); link; link = XEXP (link, 1)) if (REG_NOTE_KIND (link) == REG_INC && (int) REGNO (XEXP (link, 0)) == regno) push_replacement (&XEXP (link, 0), reloadnum, VOIDmode); -#endif } /* Record the pseudo registers we must reload into hard registers in a @@ -7175,13 +7174,15 @@ find_inc_amount (rtx x, rtx inced) /* Return 1 if registers from REGNO to ENDREGNO are the subjects of a REG_INC note in insn INSN. REGNO must refer to a hard register. */ -#if AUTO_INC_DEC static int reg_inc_found_and_valid_p (unsigned int regno, unsigned int endregno, rtx insn) { rtx link; + if (!AUTO_INC_DEC) + return 0; + gcc_assert (insn); if (! INSN_P (insn)) @@ -7196,11 +7197,6 @@ reg_inc_found_and_valid_p (unsigned int regno, unsigned int endregno, } return 0; } -#else - -#define reg_inc_found_and_valid_p(regno,endregno,insn) 0 - -#endif /* Return 1 if register REGNO is the subject of a clobber in insn INSN. If SETS is 1, also consider SETs. If SETS is 2, enable checking diff --git a/gcc/reload1.c b/gcc/reload1.c index f05596f..e80ebf9 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -424,9 +424,7 @@ static void delete_output_reload (rtx_insn *, int, int, rtx); static void delete_address_reloads (rtx_insn *, rtx_insn *); static void delete_address_reloads_1 (rtx_insn *, rtx, rtx_insn *); static void inc_for_reload (rtx, rtx, rtx, int); -#if AUTO_INC_DEC static void add_auto_inc_notes (rtx_insn *, rtx); -#endif static void substitute (rtx *, const_rtx, rtx); static bool gen_reload_chain_without_interm_reg_p (int, int); static int reloads_conflict (int, int); @@ -1257,9 +1255,8 @@ reload (rtx_insn *first, int global) pnote = &XEXP (*pnote, 1); } -#if AUTO_INC_DEC - add_auto_inc_notes (insn, PATTERN (insn)); -#endif + if (AUTO_INC_DEC) + add_auto_inc_notes (insn, PATTERN (insn)); /* Simplify (subreg (reg)) if it appears as an operand. */ cleanup_subreg_operands (insn); @@ -7401,10 +7398,7 @@ emit_input_reload_insns (struct insn_chain *chain, struct reload *rl, is ill-formed and we must reject this optimization. */ extract_insn (temp); if (constrain_operands (1, get_enabled_alternatives (temp)) -#if AUTO_INC_DEC - && ! find_reg_note (temp, REG_INC, reloadreg) -#endif - ) + && (!AUTO_INC_DEC || ! find_reg_note (temp, REG_INC, reloadreg))) { /* If the previous insn is an output reload, the source is a reload register, and its spill_reg_store entry will @@ -8874,10 +8868,10 @@ delete_output_reload (rtx_insn *insn, int j, int last_reload_reg, continue; if (MEM_P (reg2) || reload_override_in[k]) reg2 = rld[k].in_reg; -#if AUTO_INC_DEC - if (rld[k].out && ! rld[k].out_reg) + + if (AUTO_INC_DEC && rld[k].out && ! rld[k].out_reg) reg2 = XEXP (rld[k].in_reg, 0); -#endif + while (GET_CODE (reg2) == SUBREG) reg2 = SUBREG_REG (reg2); if (rtx_equal_p (reg2, reg)) @@ -9270,7 +9264,6 @@ inc_for_reload (rtx reloadreg, rtx in, rtx value, int inc_amount) } } -#if AUTO_INC_DEC static void add_auto_inc_notes (rtx_insn *insn, rtx x) { @@ -9295,4 +9288,3 @@ add_auto_inc_notes (rtx_insn *insn, rtx x) add_auto_inc_notes (insn, XVECEXP (x, i, j)); } } -#endif diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c index a2ab8e5..96a4dc4 100644 --- a/gcc/sched-deps.c +++ b/gcc/sched-deps.c @@ -2228,11 +2228,10 @@ init_insn_reg_pressure_info (rtx_insn *insn) note_stores (PATTERN (insn), mark_insn_reg_store, insn); -#if AUTO_INC_DEC - for (link = REG_NOTES (insn); link; link = XEXP (link, 1)) - if (REG_NOTE_KIND (link) == REG_INC) - mark_insn_reg_store (XEXP (link, 0), NULL_RTX, insn); -#endif + if (AUTO_INC_DEC) + for (link = REG_NOTES (insn); link; link = XEXP (link, 1)) + if (REG_NOTE_KIND (link) == REG_INC) + mark_insn_reg_store (XEXP (link, 0), NULL_RTX, insn); for (link = REG_NOTES (insn); link; link = XEXP (link, 1)) if (REG_NOTE_KIND (link) == REG_DEAD) diff --git a/gcc/valtrack.c b/gcc/valtrack.c index 8646a63..e0d17f9 100644 --- a/gcc/valtrack.c +++ b/gcc/valtrack.c @@ -57,7 +57,9 @@ static rtx cleanup_auto_inc_dec (rtx src, machine_mode mem_mode ATTRIBUTE_UNUSED) { rtx x = src; -#if AUTO_INC_DEC + if (!AUTO_INC_DEC) + return copy_rtx (x); + const RTX_CODE code = GET_CODE (x); int i; const char *fmt; @@ -140,10 +142,6 @@ cleanup_auto_inc_dec (rtx src, machine_mode mem_mode ATTRIBUTE_UNUSED) = cleanup_auto_inc_dec (XVECEXP (src, i, j), mem_mode); } -#else /* !AUTO_INC_DEC */ - x = copy_rtx (x); -#endif /* !AUTO_INC_DEC */ - return x; } -- 2.4.0