From 3ee48c5c950c555b8caf331fc0cf464c820c72e6 Mon Sep 17 00:00:00 2001 From: bernds Date: Sun, 9 Aug 2009 07:59:12 +0000 Subject: * tree-dfa.c (renumber_gimple_stmt_uids_in_blocks): New function. * tree-flow.h (renumber_gimple_stmt_uids_in_blocks): Declare it. * tree-ssa-loop-ivopts.c (comp_cost): Make COST an integer. (enum iv_position): Add IP_AFTER_USE and IP_BEFORE_USE. (dump_cand): Handle them. (struct iv_cand): New members COST_STEP and AINC_USE. (stmt_after_increment): Likewise. (stmt_after_inc_pos): Renamed from stmt_after_ip_original_pos. All callers changed. Use gimple_uid comparison instead of scanning. (add_candidate_1): When looking for identical candidates, take AINC_USE into account. Set it for new candidates. (force_expr_to_var_cost): Cast target_spill_cost to int. (get_address_cost): New arguments STMT_AFTER_INC and MAY_AUTOINC. All callers changed. Check for availability of autoinc addressing modes, both in general for a given mode, and in the specific use case. (get_computation_cost_at): New argument CAN_AUTOINC. All callers changed. (get_computation_cost): Likewise. (autoinc_possible_for_pair, set_autoinc_for_original_candidates, add_autoinc_candidates): New static functions. (add_candidate): Call add_autoinc_candidates for candidates based on a USE_ADDRESS use. (find_iv_candidates): Call set_autoinc_for_original_candidates. (determine_use_iv_cost_address): If we have an autoinc candidate at the matching use, verify autoinc is possible and subtract the cost of the candidate's step from the cost. (determine_iv_cost): Record the cost of the increment in the COST_STEP member of the candidate. (tree_ssa_iv_optimize_loop): Swap the calls to determine_iv_costs and determine_use_iv_costs. Call renumber_gimple_stmt_uids_in_blocks. testsuite/ * gcc.target/bfin/loop-autoinc.c: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150588 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 323 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 268 insertions(+), 55 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 00cc18fd159..71d4e17064d 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -135,7 +135,7 @@ enum use_type /* Cost of a computation. */ typedef struct { - unsigned cost; /* The runtime cost. */ + int cost; /* The runtime cost. */ unsigned complexity; /* The estimate of the complexity of the code for the computation (in no concrete units -- complexity field should be larger for more @@ -181,6 +181,8 @@ enum iv_position { IP_NORMAL, /* At the end, just before the exit condition. */ IP_END, /* At the end of the latch block. */ + IP_BEFORE_USE, /* Immediately before a specific use. */ + IP_AFTER_USE, /* Immediately after a specific use. */ IP_ORIGINAL /* The original biv. */ }; @@ -200,6 +202,9 @@ struct iv_cand to replace the final value of an iv by direct computation of the value. */ unsigned cost; /* Cost of the candidate. */ + unsigned cost_step; /* Cost of the candidate's increment operation. */ + struct iv_use *ainc_use; /* For IP_{BEFORE,AFTER}_USE candidates, the place + where it is incremented. */ bitmap depends_on; /* The list of invariants that are used in step of the biv. */ }; @@ -515,6 +520,14 @@ dump_cand (FILE *file, struct iv_cand *cand) fprintf (file, " incremented before exit test\n"); break; + case IP_BEFORE_USE: + fprintf (file, " incremented before use %d\n", cand->ainc_use->id); + break; + + case IP_AFTER_USE: + fprintf (file, " incremented after use %d\n", cand->ainc_use->id); + break; + case IP_END: fprintf (file, " incremented at end\n"); break; @@ -563,14 +576,14 @@ stmt_after_ip_normal_pos (struct loop *loop, gimple stmt) } /* Returns true if STMT if after the place where the original induction - variable CAND is incremented. */ + variable CAND is incremented. If TRUE_IF_EQUAL is set, we return true + if the positions are identical. */ static bool -stmt_after_ip_original_pos (struct iv_cand *cand, gimple stmt) +stmt_after_inc_pos (struct iv_cand *cand, gimple stmt, bool true_if_equal) { basic_block cand_bb = gimple_bb (cand->incremented_at); basic_block stmt_bb = gimple_bb (stmt); - gimple_stmt_iterator bsi; if (!dominated_by_p (CDI_DOMINATORS, stmt_bb, cand_bb)) return false; @@ -578,15 +591,10 @@ stmt_after_ip_original_pos (struct iv_cand *cand, gimple stmt) if (stmt_bb != cand_bb) return true; - /* Scan the block from the end, since the original ivs are usually - incremented at the end of the loop body. */ - for (bsi = gsi_last_bb (stmt_bb); ; gsi_prev (&bsi)) - { - if (gsi_stmt (bsi) == cand->incremented_at) - return false; - if (gsi_stmt (bsi) == stmt) - return true; - } + if (true_if_equal + && gimple_uid (stmt) == gimple_uid (cand->incremented_at)) + return true; + return gimple_uid (stmt) > gimple_uid (cand->incremented_at); } /* Returns true if STMT if after the place where the induction variable @@ -604,7 +612,11 @@ stmt_after_increment (struct loop *loop, struct iv_cand *cand, gimple stmt) return stmt_after_ip_normal_pos (loop, stmt); case IP_ORIGINAL: - return stmt_after_ip_original_pos (cand, stmt); + case IP_AFTER_USE: + return stmt_after_inc_pos (cand, stmt, false); + + case IP_BEFORE_USE: + return stmt_after_inc_pos (cand, stmt, true); default: gcc_unreachable (); @@ -2103,7 +2115,9 @@ add_candidate_1 (struct ivopts_data *data, if (cand->pos != pos) continue; - if (cand->incremented_at != incremented_at) + if (cand->incremented_at != incremented_at + || ((pos == IP_AFTER_USE || pos == IP_BEFORE_USE) + && cand->ainc_use != use)) continue; if (!cand->iv) @@ -2149,6 +2163,11 @@ add_candidate_1 (struct ivopts_data *data, walk_tree (&step, find_depends, &cand->depends_on, NULL); } + if (pos == IP_AFTER_USE || pos == IP_BEFORE_USE) + cand->ainc_use = use; + else + cand->ainc_use = NULL; + if (dump_file && (dump_flags & TDF_DETAILS)) dump_cand (dump_file, cand); } @@ -2192,6 +2211,56 @@ allow_ip_end_pos_p (struct loop *loop) return false; } +/* If possible, adds autoincrement candidates BASE + STEP * i based on use USE. + Important field is set to IMPORTANT. */ + +static void +add_autoinc_candidates (struct ivopts_data *data, tree base, tree step, + bool important, struct iv_use *use) +{ + basic_block use_bb = gimple_bb (use->stmt); + enum machine_mode mem_mode; + unsigned HOST_WIDE_INT cstepi; + + /* If we insert the increment in any position other than the standard + ones, we must ensure that it is incremented once per iteration. + It must not be in an inner nested loop, or one side of an if + statement. */ + if (use_bb->loop_father != data->current_loop + || !dominated_by_p (CDI_DOMINATORS, data->current_loop->latch, use_bb) + || stmt_could_throw_p (use->stmt) + || !cst_and_fits_in_hwi (step)) + return; + + cstepi = int_cst_value (step); + + mem_mode = TYPE_MODE (TREE_TYPE (*use->op_p)); + if ((HAVE_PRE_INCREMENT && GET_MODE_SIZE (mem_mode) == cstepi) + || (HAVE_PRE_DECREMENT && GET_MODE_SIZE (mem_mode) == -cstepi)) + { + enum tree_code code = MINUS_EXPR; + tree new_base; + tree new_step = step; + + if (POINTER_TYPE_P (TREE_TYPE (base))) + { + new_step = fold_build1 (NEGATE_EXPR, TREE_TYPE (step), step); + code = POINTER_PLUS_EXPR; + } + else + new_step = fold_convert (TREE_TYPE (base), new_step); + new_base = fold_build2 (code, TREE_TYPE (base), base, new_step); + add_candidate_1 (data, new_base, step, important, IP_BEFORE_USE, use, + use->stmt); + } + if ((HAVE_POST_INCREMENT && GET_MODE_SIZE (mem_mode) == cstepi) + || (HAVE_POST_DECREMENT && GET_MODE_SIZE (mem_mode) == -cstepi)) + { + add_candidate_1 (data, base, step, important, IP_AFTER_USE, use, + use->stmt); + } +} + /* Adds a candidate BASE + STEP * i. Important field is set to IMPORTANT and position to POS. If USE is not NULL, the candidate is set as related to it. The candidate computation is scheduled on all available positions. */ @@ -2205,6 +2274,9 @@ add_candidate (struct ivopts_data *data, if (ip_end_pos (data->current_loop) && allow_ip_end_pos_p (data->current_loop)) add_candidate_1 (data, base, step, important, IP_END, use, NULL); + + if (use != NULL && use->type == USE_ADDRESS) + add_autoinc_candidates (data, base, step, important, use); } /* Add a standard "0 + 1 * iteration" iv candidate for a @@ -2378,24 +2450,6 @@ record_important_candidates (struct ivopts_data *data) } } -/* Finds the candidates for the induction variables. */ - -static void -find_iv_candidates (struct ivopts_data *data) -{ - /* Add commonly used ivs. */ - add_standard_iv_candidates (data); - - /* Add old induction variables. */ - add_old_ivs_candidates (data); - - /* Add induction variables derived from uses. */ - add_derived_ivs_candidates (data); - - /* Record the important candidates. */ - record_important_candidates (data); -} - /* Allocates the data structure mapping the (use, candidate) pairs to costs. If consider_all_candidates is true, we use a two-dimensional array, otherwise we allocate a simple list to every use. */ @@ -2487,7 +2541,7 @@ infinite_cost_p (comp_cost cost) /* Sets cost of (USE, CANDIDATE) pair to COST and record that it depends on invariants DEPENDS_ON and that the value used in expressing it - is VALUE.*/ + is VALUE. */ static void set_use_iv_cost (struct ivopts_data *data, @@ -3011,21 +3065,30 @@ multiplier_allowed_in_address_p (HOST_WIDE_INT ratio, enum machine_mode mode) variable is omitted. Compute the cost for a memory reference that accesses a memory location of mode MEM_MODE. + MAY_AUTOINC is set to true if the autoincrement (increasing index by + size of MEM_MODE / RATIO) is available. To make this determination, we + look at the size of the increment to be made, which is given in CSTEP. + CSTEP may be zero if the step is unknown. + STMT_AFTER_INC is true iff the statement we're looking at is after the + increment of the original biv. + TODO -- there must be some better way. This all is quite crude. */ static comp_cost get_address_cost (bool symbol_present, bool var_present, unsigned HOST_WIDE_INT offset, HOST_WIDE_INT ratio, - enum machine_mode mem_mode, - bool speed) + HOST_WIDE_INT cstep, enum machine_mode mem_mode, bool speed, + bool stmt_after_inc, bool *may_autoinc) { static bool initialized[MAX_MACHINE_MODE]; static HOST_WIDE_INT rat[MAX_MACHINE_MODE], off[MAX_MACHINE_MODE]; static HOST_WIDE_INT min_offset[MAX_MACHINE_MODE], max_offset[MAX_MACHINE_MODE]; static unsigned costs[MAX_MACHINE_MODE][2][2][2][2]; + static bool has_preinc[MAX_MACHINE_MODE], has_postinc[MAX_MACHINE_MODE]; + static bool has_predec[MAX_MACHINE_MODE], has_postdec[MAX_MACHINE_MODE]; unsigned cost, acost, complexity; - bool offset_p, ratio_p; - HOST_WIDE_INT s_offset; + bool offset_p, ratio_p, autoinc; + HOST_WIDE_INT s_offset, autoinc_offset, msize; unsigned HOST_WIDE_INT mask; unsigned bits; @@ -3084,6 +3147,26 @@ get_address_cost (bool symbol_present, bool var_present, reg0 = gen_raw_REG (Pmode, LAST_VIRTUAL_REGISTER + 1); reg1 = gen_raw_REG (Pmode, LAST_VIRTUAL_REGISTER + 2); + if (HAVE_PRE_DECREMENT) + { + addr = gen_rtx_PRE_DEC (Pmode, reg0); + has_predec[mem_mode] = memory_address_p (mem_mode, addr); + } + if (HAVE_POST_DECREMENT) + { + addr = gen_rtx_POST_DEC (Pmode, reg0); + has_postdec[mem_mode] = memory_address_p (mem_mode, addr); + } + if (HAVE_PRE_INCREMENT) + { + addr = gen_rtx_PRE_INC (Pmode, reg0); + has_preinc[mem_mode] = memory_address_p (mem_mode, addr); + } + if (HAVE_POST_INCREMENT) + { + addr = gen_rtx_POST_INC (Pmode, reg0); + has_postinc[mem_mode] = memory_address_p (mem_mode, addr); + } for (i = 0; i < 16; i++) { sym_p = i & 1; @@ -3122,7 +3205,7 @@ get_address_cost (bool symbol_present, bool var_present, if (base) addr = gen_rtx_fmt_ee (PLUS, Pmode, addr, base); - + start_sequence (); /* To avoid splitting addressing modes, pretend that no cse will follow. */ @@ -3167,7 +3250,7 @@ get_address_cost (bool symbol_present, bool var_present, if (acost < costs[mem_mode][1][var_p][off_p][rat_p]) costs[mem_mode][1][var_p][off_p][rat_p] = acost; } - + if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "Address costs:\n"); @@ -3192,6 +3275,9 @@ get_address_cost (bool symbol_present, bool var_present, acost = costs[mem_mode][sym_p][var_p][off_p][rat_p]; fprintf (dump_file, "index costs %d\n", acost); } + if (has_predec[mem_mode] || has_postdec[mem_mode] + || has_preinc[mem_mode] || has_postinc[mem_mode]) + fprintf (dump_file, " May include autoinc/dec\n"); fprintf (dump_file, "\n"); } } @@ -3203,6 +3289,23 @@ get_address_cost (bool symbol_present, bool var_present, offset |= ~mask; s_offset = offset; + autoinc = false; + msize = GET_MODE_SIZE (mem_mode); + autoinc_offset = offset; + if (stmt_after_inc) + autoinc_offset += ratio * cstep; + if (symbol_present || var_present || ratio != 1) + autoinc = false; + else if ((has_postinc[mem_mode] && autoinc_offset == 0 + && msize == cstep) + || (has_postdec[mem_mode] && autoinc_offset == 0 + && msize == -cstep) + || (has_preinc[mem_mode] && autoinc_offset == msize + && msize == cstep) + || (has_predec[mem_mode] && autoinc_offset == -msize + && msize == -cstep)) + autoinc = true; + cost = 0; offset_p = (s_offset != 0 && min_offset[mem_mode] <= s_offset @@ -3216,6 +3319,8 @@ get_address_cost (bool symbol_present, bool var_present, if (s_offset && !offset_p && !symbol_present) cost += add_cost (Pmode, speed); + if (may_autoinc) + *may_autoinc = autoinc; acost = costs[mem_mode][symbol_present][var_present][offset_p][ratio_p]; complexity = (symbol_present != 0) + (var_present != 0) + offset_p + ratio_p; return new_cost (cost + acost, complexity); @@ -3368,7 +3473,7 @@ force_expr_to_var_cost (tree expr, bool speed) computations often are either loop invariant or at least can be shared between several iv uses, so letting this grow without limits would not give reasonable results. */ - if (cost.cost > target_spill_cost [speed]) + if (cost.cost > (int) target_spill_cost [speed]) cost.cost = target_spill_cost [speed]; return cost; @@ -3535,19 +3640,22 @@ difference_cost (struct ivopts_data *data, from induction variable CAND. If ADDRESS_P is true, we just need to create an address from it, otherwise we want to get it into register. A set of invariants we depend on is stored in - DEPENDS_ON. AT is the statement at that the value is computed. */ + DEPENDS_ON. AT is the statement at that the value is computed. + If CAN_AUTOINC is nonnull, use it to record whether autoinc + addressing is likely. */ static comp_cost get_computation_cost_at (struct ivopts_data *data, struct iv_use *use, struct iv_cand *cand, - bool address_p, bitmap *depends_on, gimple at) + bool address_p, bitmap *depends_on, gimple at, + bool *can_autoinc) { tree ubase = use->iv->base, ustep = use->iv->step; tree cbase, cstep; tree utype = TREE_TYPE (ubase), ctype; unsigned HOST_WIDE_INT cstepi, offset = 0; HOST_WIDE_INT ratio, aratio; - bool var_present, symbol_present; + bool var_present, symbol_present, stmt_is_after_inc; comp_cost cost; double_int rat; bool speed = optimize_bb_for_speed_p (gimple_bb (at)); @@ -3656,7 +3764,8 @@ get_computation_cost_at (struct ivopts_data *data, /* If we are after the increment, the value of the candidate is higher by one iteration. */ - if (stmt_after_increment (data->current_loop, cand, at)) + stmt_is_after_inc = stmt_after_increment (data->current_loop, cand, at); + if (stmt_is_after_inc) offset -= ratio * cstepi; /* Now the computation is in shape symbol + var1 + const + ratio * var2. @@ -3665,8 +3774,10 @@ get_computation_cost_at (struct ivopts_data *data, if (address_p) return add_costs (cost, get_address_cost (symbol_present, var_present, - offset, ratio, - TYPE_MODE (TREE_TYPE (utype)), speed)); + offset, ratio, cstepi, + TYPE_MODE (TREE_TYPE (utype)), + speed, stmt_is_after_inc, + can_autoinc)); /* Otherwise estimate the costs for computing the expression. */ if (!symbol_present && !var_present && !offset) @@ -3694,6 +3805,9 @@ get_computation_cost_at (struct ivopts_data *data, cost.cost += multiply_by_cost (aratio, TYPE_MODE (ctype), speed); fallback: + if (can_autoinc) + *can_autoinc = false; + { /* Just get the expression, expand it and measure the cost. */ tree comp = get_computation_at (data->current_loop, use, cand, at); @@ -3712,15 +3826,17 @@ fallback: from induction variable CAND. If ADDRESS_P is true, we just need to create an address from it, otherwise we want to get it into register. A set of invariants we depend on is stored in - DEPENDS_ON. */ + DEPENDS_ON. If CAN_AUTOINC is nonnull, use it to record whether + autoinc addressing is likely. */ static comp_cost get_computation_cost (struct ivopts_data *data, struct iv_use *use, struct iv_cand *cand, - bool address_p, bitmap *depends_on) + bool address_p, bitmap *depends_on, bool *can_autoinc) { return get_computation_cost_at (data, - use, cand, address_p, depends_on, use->stmt); + use, cand, address_p, depends_on, use->stmt, + can_autoinc); } /* Determines cost of basing replacement of USE on CAND in a generic @@ -3744,7 +3860,7 @@ determine_use_iv_cost_generic (struct ivopts_data *data, return true; } - cost = get_computation_cost (data, use, cand, false, &depends_on); + cost = get_computation_cost (data, use, cand, false, &depends_on, NULL); set_use_iv_cost (data, use, cand, cost, depends_on, NULL_TREE); return !infinite_cost_p (cost); @@ -3757,8 +3873,20 @@ determine_use_iv_cost_address (struct ivopts_data *data, struct iv_use *use, struct iv_cand *cand) { bitmap depends_on; - comp_cost cost = get_computation_cost (data, use, cand, true, &depends_on); + bool can_autoinc; + comp_cost cost = get_computation_cost (data, use, cand, true, &depends_on, + &can_autoinc); + if (cand->ainc_use == use) + { + if (can_autoinc) + cost.cost -= cand->cost_step; + /* If we generated the candidate solely for exploiting autoincrement + opportunities, and it turns out it can't be used, set the cost to + infinity to make sure we ignore it. */ + else if (cand->pos == IP_AFTER_USE || cand->pos == IP_BEFORE_USE) + cost = infinite_cost; + } set_use_iv_cost (data, use, cand, cost, depends_on, NULL_TREE); return !infinite_cost_p (cost); @@ -3938,7 +4066,7 @@ determine_use_iv_cost_condition (struct ivopts_data *data, gcc_assert (ok); express_cost = get_computation_cost (data, use, cand, false, - &depends_on_express); + &depends_on_express, NULL); fd_ivopts_data = data; walk_tree (&cmp_iv->base, find_depends, &depends_on_express, NULL); @@ -3990,6 +4118,78 @@ determine_use_iv_cost (struct ivopts_data *data, } } +/* Return true if get_computation_cost indicates that autoincrement is + a possibility for the pair of USE and CAND, false otherwise. */ + +static bool +autoinc_possible_for_pair (struct ivopts_data *data, struct iv_use *use, + struct iv_cand *cand) +{ + bitmap depends_on; + bool can_autoinc; + comp_cost cost; + + if (use->type != USE_ADDRESS) + return false; + + cost = get_computation_cost (data, use, cand, true, &depends_on, + &can_autoinc); + + BITMAP_FREE (depends_on); + + return !infinite_cost_p (cost) && can_autoinc; +} + +/* Examine IP_ORIGINAL candidates to see if they are incremented next to a + use that allows autoincrement, and set their AINC_USE if possible. */ + +static void +set_autoinc_for_original_candidates (struct ivopts_data *data) +{ + unsigned i, j; + + for (i = 0; i < n_iv_cands (data); i++) + { + struct iv_cand *cand = iv_cand (data, i); + struct iv_use *closest = NULL; + if (cand->pos != IP_ORIGINAL) + continue; + for (j = 0; j < n_iv_uses (data); j++) + { + struct iv_use *use = iv_use (data, j); + unsigned uid = gimple_uid (use->stmt); + if (gimple_bb (use->stmt) != gimple_bb (cand->incremented_at) + || uid > gimple_uid (cand->incremented_at)) + continue; + if (closest == NULL || uid > gimple_uid (closest->stmt)) + closest = use; + } + if (closest == NULL || !autoinc_possible_for_pair (data, closest, cand)) + continue; + cand->ainc_use = closest; + } +} + +/* Finds the candidates for the induction variables. */ + +static void +find_iv_candidates (struct ivopts_data *data) +{ + /* Add commonly used ivs. */ + add_standard_iv_candidates (data); + + /* Add old induction variables. */ + add_old_ivs_candidates (data); + + /* Add induction variables derived from uses. */ + add_derived_ivs_candidates (data); + + set_autoinc_for_original_candidates (data); + + /* Record the important candidates. */ + record_important_candidates (data); +} + /* Determines costs of basing the use of the iv on an iv candidate. */ static void @@ -4105,6 +4305,7 @@ determine_iv_cost (struct ivopts_data *data, struct iv_cand *cand) cost++; cand->cost = cost; + cand->cost_step = cost_step; } /* Determines costs of computation of the candidates. */ @@ -4129,7 +4330,7 @@ determine_iv_costs (struct ivopts_data *data) if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, " %d\t%d\n", i, cand->cost); } - + if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "\n"); } @@ -5051,6 +5252,13 @@ create_new_iv (struct ivopts_data *data, struct iv_cand *cand) after = true; break; + case IP_AFTER_USE: + after = true; + /* fall through */ + case IP_BEFORE_USE: + incr_pos = gsi_for_stmt (cand->incremented_at); + break; + case IP_ORIGINAL: /* Mark that the iv is preserved. */ name_info (data, cand->var_before)->preserve_biv = true; @@ -5512,6 +5720,7 @@ tree_ssa_iv_optimize_loop (struct ivopts_data *data, struct loop *loop) bool changed = false; struct iv_ca *iv_ca; edge exit; + basic_block *body; gcc_assert (!data->niters); data->current_loop = loop; @@ -5533,6 +5742,10 @@ tree_ssa_iv_optimize_loop (struct ivopts_data *data, struct loop *loop) fprintf (dump_file, "\n"); } + body = get_loop_body (loop); + renumber_gimple_stmt_uids_in_blocks (body, loop->num_nodes); + free (body); + /* For each ssa name determines whether it behaves as an induction variable in some loop. */ if (!find_induction_variables (data)) @@ -5547,8 +5760,8 @@ tree_ssa_iv_optimize_loop (struct ivopts_data *data, struct loop *loop) find_iv_candidates (data); /* Calculates the costs (item 3, part 1). */ - determine_use_iv_costs (data); determine_iv_costs (data); + determine_use_iv_costs (data); determine_set_costs (data); /* Find the optimal set of induction variables (item 3, part 2). */ -- cgit v1.2.1 From 9845d1202fec65574ca05d780859eb8c25489566 Mon Sep 17 00:00:00 2001 From: aoliva Date: Wed, 2 Sep 2009 02:42:21 +0000 Subject: gcc/ChangeLog: * doc/invoke.texi (-fvar-tracking-assignments): New. (-fvar-tracking-assignments-toggle): New. (-fdump-final-insns=file): Mark filename as optional. (--param min-nondebug-insn-uid): New. (-gdwarf-@{version}): Mention version 4. * opts.c (common_handle_option): Accept it. * tree-vrp.c (find_assert_locations_1): Skip debug stmts. * regrename.c (regrename_optimize): Drop last. Don't count debug insns as uses. Don't reject change because of debug insn. (do_replace): Reject DEBUG_INSN as chain starter. Take base_regno from the chain starter, and check for inexact matches in DEBUG_INSNS. (scan_rtx_reg): Accept inexact matches in DEBUG_INSNs. (build_def_use): Simplify and fix the marking of DEBUG_INSNs. * sched-ebb.c (schedule_ebbs): Skip boundary debug insns. * fwprop.c (forward_propagate_and_simplify): ...into debug insns. * doc/gimple.texi (is_gimple_debug): New. (gimple_debug_bind_p): New. (is_gimple_call, gimple_assign_cast_p): End sentence with period. * doc/install.texi (bootstrap-debug): More details. (bootstrap-debug-big, bootstrap-debug-lean): Document. (bootstrap-debug-lib): More details. (bootstrap-debug-ckovw): Update. (bootstrap-time): New. * tree-into-ssa.c (mark_def_sites): Skip debug stmts. (insert_phi_nodes_for): Insert debug stmts. (rewrite_stmt): Take iterator. Insert debug stmts. (rewrite_enter_block): Adjust. (maybe_replace_use_in_debug_stmt): New. (rewrite_update_stmt): Use it. (mark_use_interesting): Return early for debug stmts. * tree-ssa-loop-im.c (rewrite_bittest): Propagate DEFs into debug stmts before replacing stmt. (move_computations_stmt): Likewise. * ira-conflicts.c (add_copies): Skip debug insns. * regstat.c (regstat_init_n_sets_and_refs): Discount debug insns. (regstat_bb_compute_ri): Skip debug insns. * tree-ssa-threadupdate.c (redirection_block_p): Skip debug stmts. * tree-ssa-loop-manip.c (find_uses_to_rename_stmt, check_loop_closed_ssa_stmt): Skip debug stmts. * tree-tailcall.c (find_tail_calls): Likewise. * tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Likewise. * tree.h (MAY_HAVE_DEBUG_STMTS): New. (build_var_debug_value_stat): Declare. (build_var_debug_value): Define. (target_for_debug_bind): Declare. * reload.c (find_equiv_reg): Skip debug insns. * rtlanal.c (reg_used_between_p): Skip debug insns. (side_effects_p): Likewise. (canonicalize_condition): Likewise. * ddg.c (create_ddg_dep_from_intra_loop_link): Check that non-debug insns never depend on debug insns. (create_ddg_dep_no_link): Likewise. (add_cross_iteration_register_deps): Use ANTI_DEP for debug insns. Don't add inter-loop dependencies for debug insns. (build_intra_loop_deps): Likewise. (create_ddg): Count debug insns. * ddg.h (struct ddg::num_debug): New. (num_backargs): Pair up with previous int field. * diagnostic.c (diagnostic_report_diagnostic): Skip notes on -fcompare-debug-second. * final.c (get_attr_length_1): Skip debug insns. (rest_of_clean-state): Don't dump CFA_RESTORE_STATE. * gcc.c (invoke_as): Call compare-debug-dump-opt. (driver_self_specs): Map -fdump-final-insns to -fdump-final-insns=.. (get_local_tick): New. (compare_debug_dump_opt_spec_function): Test for . argument and compute output name. Compute temp output spec without flag name. Compute -frandom-seed. (OPT): Undef after use. * cfgloopanal.c (num_loop_insns): Skip debug insns. (average_num_loop_insns): Likewise. * params.h (MIN_NONDEBUG_INSN_UID): New. * gimple.def (GIMPLE_DEBUG): New. * ipa-reference.c (scan_stmt_for_static_refs): Skip debug stmts. * auto-inc-dec.c (merge_in_block): Skip debug insns. (merge_in_block): Fix whitespace. * toplev.c (flag_var_tracking): Update comment. (flag_var_tracking_assignments): New. (flag_var_tracking_assignments_toggle): New. (process_options): Don't open final insns dump file if we're not going to write to it. Compute defaults for var_tracking. * df-scan.c (df_insn_rescan_debug_internal): New. (df_uses_record): Handle debug insns. * haifa-sched.c (ready): Initialize n_debug. (contributes_to_priority): Skip debug insns. (dep_list_size): New. (priority): Use it. (rank_for_schedule): Likewise. Schedule debug insns as soon as they're ready. Disregard previous debug insns to make decisions. (queue_insn): Never queue debug insns. (ready_add, ready_remove_first, ready_remove): Count debug insns. (schedule_insn): Don't reject debug insns because of issue rate. (get_ebb_head_tail, no_real_insns_p): Skip boundary debug insns. (queue_to_ready): Skip and discount debug insns. (choose_ready): Let debug insns through. (schedule_block): Check boundary debug insns. Discount debug insns, schedule them early. Adjust whitespace. (set_priorities): Check for boundary debug insns. (add_jump_dependencies): Use dep_list_size. (prev_non_location_insn): New. (check_cfg): Use it. * tree-ssa-loop-ivopts.c (find-interesting_users): Skip debug stmts. (remove_unused_ivs): Reset debug stmts. * modulo-sched.c (const_iteration_count): Skip debug insns. (res_MII): Discount debug insns. (loop_single_full_bb_p): Skip debug insns. (sms_schedule): Likewise. (sms_schedule_by_order): Likewise. (ps_has_conflicts): Likewise. * caller-save.c (refmarker_fn): New. (save_call_clobbered_regs): Replace regs with saved mem in debug insns. (mark_referenced_regs): Take pointer, mark and arg. Adjust. Call refmarker_fn mark for hardregnos. (mark_reg_as_referenced): New. (replace_reg_with_saved_mem): New. * ipa-pure-const.c (check_stmt): Skip debug stmts. * cse.c (cse_insn): Canonicalize debug insns. Skip them when searching back. (cse_extended_basic_block): Skip debug insns. (count_reg_usage): Likewise. (is_dead_reg): New, split out of... (set_live_p): ... here. (insn_live_p): Use it for debug insns. * tree-stdarg.c (check_all_va_list_escapes): Skip debug stmts. (execute_optimize_stdarg): Likewise. * tree-ssa-dom.c (propagate_rhs_into_lhs): Likewise. * tree-ssa-propagate.c (substitute_and_fold): Don't regard changes in debug stmts as changes. * sel-sched.c (moving_insn_creates_bookkeeping_block_p): New. (moveup_expr): Don't move across debug insns. Don't move debug insn if it would create a bookkeeping block. (moveup_expr_cached): Don't use cache for debug insns that are heads of blocks. (compute_av_set_inside_bb): Skip debug insns. (sel_rank_for_schedule): Schedule debug insns first. Remove dead code. (block_valid_for_bookkeeping_p); Support lax searches. (create_block_for_bookkeeping): Adjust block numbers when encountering debug-only blocks. (find_place_for_bookkeeping): Deal with debug-only blocks. (generate_bookkeeping_insn): Accept no place to insert. (remove_temp_moveop_nops): New argument full_tidying. (prepare_place_to_insert): Deal with debug insns. (advance_state_on_fence): Debug insns don't start cycles. (update_boundaries): Take fence as argument. Deal with debug insns. (schedule_expr_on_boundary): No full_tidying on debug insns. (fill_insns): Deal with debug insns. (track_scheduled_insns_and_blocks): Don't count debug insns. (need_nop_to_preserve_insn_bb): New, split out of... (remove_insn_from_stream): ... this. (fur_orig_expr_not_found): Skip debug insns. * rtl.def (VALUE): Move up. (DEBUG_INSN): New. * tree-ssa-sink.c (all_immediate_uses_same_place): Skip debug stmts. (nearest_common_dominator_of_uses): Take debug_stmts argument. Set it if debug stmts are found. (statement_sink_location): Skip debug stmts. Propagate moving defs into debug stmts. * ifcvt.c (first_active_insn): Skip debug insns. (last_active_insns): Likewise. (cond_exec_process_insns): Likewise. (noce_process_if_block): Likewise. (check_cond_move_block): Likewise. (cond_move_convert_if_block): Likewise. (block_jumps_and_fallthru_p): Likewise. (dead_or_predicable): Likewise. * dwarf2out.c (debug_str_hash_forced): New. (find_AT_string): Add comment. (gen_label_for_indirect_string): New. (get_debug_string_label): New. (AT_string_form): Use it. (mem_loc_descriptor): Handle non-TLS symbols. Handle MINUS , DIV, MOD, AND, IOR, XOR, NOT, ABS, NEG, and CONST_STRING. Accept but discard COMPARE, IF_THEN_ELSE, ROTATE, ROTATERT, TRUNCATE and several operations that cannot be represented with DWARF opcodes. (loc_descriptor): Ignore SIGN_EXTEND and ZERO_EXTEND. Require dwarf_version 4 for DW_OP_implicit_value and DW_OP_stack_value. (dwarf2out_var_location): Take during-call mark into account. (output_indirect_string): Update comment. Output if there are label and references. (prune_indirect_string): New. (prune_unused_types): Call it if debug_str_hash_forced. More in dwarf2out.c, from Jakub Jelinek : (dw_long_long_const): Remove. (struct dw_val_struct): Change val_long_long type to rtx. (print_die, attr_checksum, same_dw_val_p, loc_descriptor): Adjust for val_long_long change to CONST_DOUBLE rtx from a long hi/lo pair. (output_die): Likewise. Use HOST_BITS_PER_WIDE_INT size of each component instead of HOST_BITS_PER_LONG. (output_loc_operands): Likewise. For const8* assert HOST_BITS_PER_WIDE_INT rather than HOST_BITS_PER_LONG is >= 64. (output_loc_operands_raw): For const8* assert HOST_BITS_PER_WIDE_INT rather than HOST_BITS_PER_LONG is >= 64. (add_AT_long_long): Remove val_hi and val_lo arguments, add val_const_double. (size_of_die): Use HOST_BITS_PER_WIDE_INT size multiplier instead of HOST_BITS_PER_LONG for dw_val_class_long_long. (add_const_value_attribute): Adjust add_AT_long_long caller. Don't handle TLS SYMBOL_REFs. If CONST wraps a constant, tail recurse. (dwarf_stack_op_name): Handle DW_OP_implicit_value and DW_OP_stack_value. (size_of_loc_descr, output_loc_operands, output_loc_operands_raw): Handle DW_OP_implicit_value. (extract_int): Move prototype earlier. (mem_loc_descriptor): For SUBREG punt if inner mode size is wider than DWARF2_ADDR_SIZE. Handle SIGN_EXTEND and ZERO_EXTEND by DW_OP_shl and DW_OP_shr{a,}. Handle EQ, NE, GT, GE, LT, LE, GTU, GEU, LTU, LEU, SMIN, SMAX, UMIN, UMAX, SIGN_EXTRACT, ZERO_EXTRACT. (loc_descriptor): Compare mode size with DWARF2_ADDR_SIZE instead of Pmode size. (loc_descriptor): Add MODE argument. Handle CONST_INT, CONST_DOUBLE, CONST_VECTOR, CONST, LABEL_REF and SYMBOL_REF if mode != VOIDmode, attempt to handle other expressions. Don't handle TLS SYMBOL_REFs. (concat_loc_descriptor, concatn_loc_descriptor, loc_descriptor_from_tree_1): Adjust loc_descriptor callers. (add_location_or_const_value_attribute): Likewise. For single location loc_lists attempt to use add_const_value_attribute for constant decls. Add DW_AT_const_value even if NOTE_VAR_LOCATION is VAR_LOCATION with CONSTANT_P or CONST_STRING in its expression. * cfgbuild.c (inside_basic_block_p): Handle debug insns. (control_flow_insn_p): Likewise. * tree-parloops.c (eliminate_local_variables_stmt): Handle debug stmt. (separate_decls_in_region_debug_bind): New. (separate_decls_in_region): Process debug bind stmts afterwards. * recog.c (verify_changes): Handle debug insns. (extract_insn): Likewise. (peephole2_optimize): Skip debug insns. * dse.c (scan_insn): Skip debug insns. * sel-sched-ir.c (return_nop_to_pool): Take full_tidying argument. Pass it on. (setup_id_for_insn): Handle debug insns. (maybe_tidy_empty_bb): Adjust whitespace. (tidy_control_flow): Skip debug insns. (sel_remove_insn): Adjust for debug insns. (sel_estimate_number_of_insns): Skip debug insns. (create_insn_rtx_from_pattern): Handle debug insns. (create_copy_of_insn_rtx): Likewise. * sel-sched-.h (sel_bb_end): Declare. (sel_bb_empty_or_nop_p): New. (get_all_loop_exits): Use it. (_eligible_successor_edge_p): Likewise. (return_nop_to_pool): Adjust. * tree-eh.c (tre_empty_eh_handler_p): Skip debug stmts. * ira-lives.c (process_bb_node_lives): Skip debug insns. * gimple-pretty-print.c (dump_gimple_debug): New. (dump_gimple_stmt): Use it. (dump_bb_header): Skip gimple debug stmts. * regmove.c (optimize_reg_copy_1): Discount debug insns. (fixup_match_2): Likewise. (regmove_backward_pass): Likewise. Simplify combined replacement. Handle debug insns. * function.c (instantiate_virtual_regs): Handle debug insns. * function.h (struct emit_status): Add x_cur_debug_insn_uid. * print-rtl.h: Include cselib.h. (print_rtx): Print VALUEs. Split out and recurse for VAR_LOCATIONs. * df.h (df_inns_rescan_debug_internal): Declare. * gcse.c (alloc_hash_table): Estimate n_insns. (cprop_insn): Don't regard debug insns as changes. (bypass_conditional_jumps): Skip debug insns. (one_pre_gcse_pass): Adjust. (one_code_hoisting_pass): Likewise. (compute_ld_motion_mems): Skip debug insns. (one_cprop_pass): Adjust. * tree-if-conv.c (tree_if_convert_stmt): Reset debug stmts. (if_convertible_stmt_p): Handle debug stmts. * init-regs.c (initialize_uninitialized_regs): Skip debug insns. * tree-vect-loop.c (vect_is_simple_reduction): Skip debug stmts. * ira-build.c (create_bb_allocnos): Skip debug insns. * tree-flow-inline.h (has_zero_uses): Discount debug stmts. (has_single_use): Likewise. (single_imm_use): Likewise. (num_imm_uses): Likewise. * tree-ssa-phiopt.c (empty_block_p): Skip debug stmts. * tree-ssa-coalesce.c (build_ssa_conflict_graph): Skip debug stmts. (create_outofssa_var_map): Likewise. * lower-subreg.c (adjust_decomposed_uses): New. (resolve_debug): New. (decompose_multiword_subregs): Use it. * tree-dfa.c (find_referenced_vars): Skip debug stmts. * emit-rtl.c: Include params.h. (cur_debug_insn_uid): Define. (set_new_first_and_last_insn): Set cur_debug_insn_uid too. (copy_rtx_if_shared_1): Handle debug insns. (reset_used_flags): Likewise. (set_used_flags): LIkewise. (get_max_insn_count): New. (next_nondebug_insn): New. (prev_nondebug_insn): New. (make_debug_insn_raw): New. (emit_insn_before_noloc): Handle debug insns. (emit_jump_insn_before_noloc): Likewise. (emit_call_insn_before_noloc): Likewise. (emit_debug_insn_before_noloc): New. (emit_insn_after_noloc): Handle debug insns. (emit_jump_insn_after_noloc): Likewise. (emit_call_insn_after_noloc): Likewise. (emit_debug_insn_after_noloc): Likewise. (emit_insn_after): Take loc from earlier non-debug insn. (emit_jump_insn_after): Likewise. (emit_call_insn_after): Likewise. (emit_debug_insn_after_setloc): New. (emit_debug_insn_after): New. (emit_insn_before): Take loc from later non-debug insn. (emit_jump_insn_before): Likewise. (emit_call_insn_before): Likewise. (emit_debug_insn_before_setloc): New. (emit_debug_insn_before): New. (emit_insn): Handle debug insns. (emit_debug_insn): New. (emit_jump_insn): Handle debug insns. (emit_call_insn): Likewise. (emit): Likewise. (init_emit): Take min-nondebug-insn-uid into account. Initialize cur_debug_insn_uid. (emit_copy_of_insn_after): Handle debug insns. * cfgexpand.c (gimple_assign_rhs_to_tree): Do not overwrite location of single rhs in place. (maybe_dump_rtl_for_gimple_stmt): Dump lineno. (floor_sdiv_adjust): New. (cell_sdiv_adjust): New. (cell_udiv_adjust): New. (round_sdiv_adjust): New. (round_udiv_adjust): New. (wrap_constant): Moved from cselib. (unwrap_constant): New. (expand_debug_expr): New. (expand_debug_locations): New. (expand_gimple_basic_block): Drop hiding redeclaration. Expand debug bind stmts. (gimple_expand_cfg): Expand debug locations. * cselib.c: Include tree-pass.h. (struct expand_value_data): New. (cselib_record_sets_hook): New. (PRESERVED_VALUE_P, LONG_TERM_PRESERVED_VALUE_P): New. (cselib_clear_table): Move, and implemnet in terms of... (cselib_reset_table_with_next_value): ... this. (cselib_get_next_unknown_value): New. (discard_useless_locs): Don't discard preserved values. (cselib_preserve_value): New. (cselib_preserved_value_p): New. (cselib_preserve_definitely): New. (cselib_clear_preserve): New. (cselib_preserve_only_values): New. (new_cselib_val): Take rtx argument. Dump it in details. (cselib_lookup_mem): Adjust. (expand_loc): Take regs_active in struct. Adjust. Silence dumps unless details are requested. (cselib_expand_value_rtx_cb): New. (cselib_expand_value_rtx): Rename and reimplment in terms of... (cselib_expand_value_rtx_1): ... this. Adjust. Silence dumps without details. Copy more subregs. Try to resolve values using a callback. Wrap constants. (cselib_subst_to_values): Adjust. (cselib_log_lookup): New. (cselib_lookup): Call it. (cselib_invalidate_regno): Don't count preserved values as useless. (cselib_invalidate_mem): Likewise. (cselib_record_set): Likewise. (struct set): Renamed to cselib_set, moved to cselib.h. (cselib_record_sets): Adjust. Call hook. (cselib_process_insn): Reset table when it would be cleared. (dump_cselib_val): New. (dump_cselib_table): New. * tree-cfgcleanup.c (tree_forwarded_block_p): Skip debug stmts. (remove_forwarder_block): Support moving debug stmts. * cselib.h (cselib_record_sets_hook): Declare. (cselib_expand_callback): New type. (cselib_expand_value_rtx_cb): Declare. (cselib_reset_table_with_next_value): Declare. (cselib_get_next_unknown_value): Declare. (cselib_preserve_value): Declare. (cselib_preserved_value_p): Declare. (cselib_preserve_only_values): Declare. (dump_cselib_table): Declare. * cfgcleanup.c (flow_find_cross_jump): Skip debug insns. (try_crossjump_to_edge): Likewise. (delete_unreachable_blocks): Remove dominant GIMPLE blocks after dominated blocks when debug stmts are present. * simplify-rtx.c (delegitimize_mem_from_attrs): New. * tree-ssa-live.c (remove_unused_locals): Skip debug stmts. (set_var_live_on_entry): Likewise. * loop-invariant.c (find_invariants_bb): Skip debug insns. * cfglayout.c (curr_location, last_location): Make static. (set_curr_insn_source_location): Don't avoid bouncing. (get_curr_insn_source_location): New. (get_curr_insn_block): New. (duplicate_insn_chain): Handle debug insns. * tree-ssa-forwprop.c (forward_propagate_addr_expr): Propagate into debug stmts. * common.opt (fcompare-debug): Move to sort order. (fdump-unnumbered-links): Likewise. (fvar-tracking-assignments): New. (fvar-tracking-assignments-toggle): New. * tree-ssa-dce.c (mark_stmt_necessary): Don't mark blocks because of debug stmts. (mark_stmt_if_obviously_necessary): Mark debug stmts. (eliminate_unnecessary_stmts): Walk dominated blocks before dominators. * tree-ssa-ter.c (find_replaceable_in_bb): Skip debug stmts. * ira.c (memref_used_between_p): Skip debug insns. (update_equiv_regs): Likewise. * sched-deps.c (sd_lists_size): Accept empty list. (sd_init_insn): Mark debug insns. (sd_finish_insn): Unmark them. (sd_add_dep): Reject non-debug deps on debug insns. (fixup_sched_groups): Give debug insns group treatment. Skip debug insns. (sched_analyze_reg): Don't mark debug insns for sched before call. (sched_analyze_2): Handle debug insns. (sched_analyze_insn): Compute next non-debug insn. Handle debug insns. (deps_analyze_insn): Handle debug insns. (deps_start_bb): Skip debug insns. (init_deps): Initialize last_debug_insn. * tree-ssa.c (target_for_debug_bind): New. (find_released_ssa_name): New. (propagate_var_def_into_debug_stmts): New. (propagate_defs_into_debug_stmts): New. (verify_ssa): Skip debug bind stmts without values. (warn_uninialized_vars): Skip debug stmts. * target-def.h (TARGET_DELEGITIMIZE_ADDRESS): Set default. * rtl.c (rtx_equal_p_cb): Handle VALUEs. (rtx_equal_p): Likewise. * ira-costs.c (scan_one_insn): Skip debug insns. (process_bb_node_for_hard_reg_moves): Likewise. * rtl.h (DEBUG_INSN_P): New. (NONDEBUG_INSN_P): New. (MAY_HAVE_DEBUG_INSNS): New. (INSN_P): Accept debug insns. (RTX_FRAME_RELATED_P): Likewise. (INSN_DELETED_P): Likewise (PAT_VAR_LOCATION_DECL): New. (PAT_VAR_LOCATION_LOC): New. (PAT_VAR_OCATION_STATUS): New. (NOTE_VAR_LOCATION_DECL): Reimplement. (NOTE_VAR_LOCATION_LOC): Likewise. (NOTE_VAR_LOCATION_STATUS): Likewise. (INSN_VAR_LOCATION): New. (INSN_VAR_LOCATION_DECL): New. (INSN_VAR_LOCATION_LOC): New. (INSN_VAR_LOCATION_STATUS): New. (gen_rtx_UNKNOWN_VAR_LOC): New. (VAR_LOC_UNKNOWN_P): New. (NOTE_DURING_CALL_P): New. (SCHED_GROUP_P): Accept debug insns. (emit_debug_insn_before): Declare. (emit_debug_insn_before_noloc): Declare. (emit_debug_insn_beore_setloc): Declare. (emit_debug_insn_after): Declare. (emit_debug_insn_after_noloc): Declare. (emit_debug_insn_after_setloc): Declare. (emit_debug_insn): Declare. (make_debug_insn_raw): Declare. (prev_nondebug_insn): Declare. (next_nondebug_insn): Declare. (delegitimize_mem_from_attrs): Declare. (get_max_insn_count): Declare. (wrap_constant): Declare. (unwrap_constant): Declare. (get_curr_insn_source_location): Declare. (get_curr_insn_block): Declare. * tree-inline.c (insert_debug_decl_map): New. (processing_debug_stmt): New. (remap_decl): Don't create new mappings in debug stmts. (remap_gimple_op_r): Don't add references in debug stmts. (copy_tree_body_r): Likewise. (remap_gimple_stmt): Handle debug bind stmts. (copy_bb): Skip debug stmts. (copy_edges_for_bb): Likewise. (copy_debug_stmt): New. (copy_debug_stmts): New. (copy_body): Copy debug stmts at the end. (insert_init_debug_bind): New. (insert_init_stmt): Take id. Skip and emit debug stmts. (setup_one_parameter): Remap variable earlier, register debug mapping. (estimate_num_insns): Skip debug stmts. (expand_call_inline): Preserve debug_map. (optimize_inline_calls): Check for no debug_stmts left-overs. (unsave_expr_now): Preserve debug_map. (copy_gimple_seq_and_replace_locals): Likewise. (tree_function_versioning): Check for no debug_stmts left-overs. Init and destroy debug_map as needed. Split edges unconditionally. (build_duplicate_type): Init and destroy debug_map as needed. * tree-inline.h: Include gimple.h instead of pointer-set.h. (struct copy_body_data): Add debug_stmts and debug_map. * sched-int.h (struct ready_list): Add n_debug. (struct deps): Add last_debug_insn. (DEBUG_INSN_SCHED_P): New. (BOUNDARY_DEBUG_INSN_P): New. (SCHEDULE_DEBUG_INSN_P): New. (sd_iterator_cond): Accept empty list. * combine.c (create_log_links): Skip debug insns. (combine_instructions): Likewise. (cleanup_auto_inc_dec): New. From Jakub Jelinek: Make sure the return value is always unshared. (struct rtx_subst_pair): New. (auto_adjust_pair): New. (propagate_for_debug_subst): New. (propagate_for_debug): New. (try_combine): Skip debug insns. Propagate removed defs into debug insns. (next_nonnote_nondebug_insn): New. (distribute_notes): Use it. Skip debug insns. (distribute_links): Skip debug insns. * tree-outof-ssa.c (set_location_for_edge): Likewise. * resource.c (mark_target_live_regs): Likewise. * var-tracking.c: Include cselib.h and target.h. (enum micro_operation_type): Add MO_VAL_USE, MO_VAL_LOC, and MO_VAL_SET. (micro_operation_type_name): New. (enum emit_note_where): Add EMIT_NOTE_AFTER_CALL_INSN. (struct micro_operation_def): Update comments. (decl_or_value): New type. Use instead of decls. (struct emit_note_data_def): Add vars. (struct attrs_def): Use decl_or_value. (struct variable_tracking_info_def): Add permp, flooded. (struct location_chain_def): Update comment. (struct variable_part_def): Use decl_or_value. (struct variable_def): Make var_part a variable length array. (valvar_pool): New. (scratch_regs): New. (cselib_hook_called): New. (dv_is_decl_p): New. (dv_is_value_p): New. (dv_as_decl): New. (dv_as_value): New. (dv_as_opaque): New. (dv_onepart_p): New. (dv_pool): New. (IS_DECL_CODE): New. (check_value_is_not_decl): New. (dv_from_decl): New. (dv_from_value): New. (dv_htab_hash): New. (variable_htab_hash): Use it. (variable_htab_eq): Support values. (variable_htab_free): Free from the right pool. (attrs_list_member, attrs_list_insert): Use decl_or_value. (attrs_list_union): Adjust. (attrs_list_mpdv_union): New. (tie_break_pointers): New. (canon_value_cmp): New. (unshare_variable): Return possibly-modified slot. (vars_copy_1): Adjust. (var_reg_decl_set): Adjust. Split out of... (var_reg_set): ... this. (get_init_value): Adjust. (var_reg_delete_and_set): Adjust. (var_reg_delete): Adjust. (var_regno_delete): Adjust. (var_mem_decl_set): Split out of... (var_mem_set): ... this. (var_mem_delete_and_set): Adjust. (var_mem_delete): Adjust. (val_store): New. (val_reset): New. (val_resolve): New. (variable_union): Adjust. Speed up merge of 1-part vars. (variable_canonicalize): Use unshared slot. (VALUED_RECURSED_INTO): New. (find_loc_in_1pdv): New. (struct dfset_merge): New. (insert_into_intersection): New. (intersect_loc_chains): New. (loc_cmp): New. (canonicalize_loc_order_check): New. (canonicalize_values_mark): New. (canonicalize_values_star): New. (variable_merge_over_cur): New. (variable_merge_over_src): New. (dataflow_set_merge): New. (dataflow_set_equiv_regs): New. (remove_duplicate_values): New. (struct dfset_post_merge): New. (variable_post_merge_new_vals): New. (variable_post_merge_perm_vals): New. (dataflow_post_merge_adjust): New. (find_mem_expr_in_1pdv): New. (dataflow_set_preserve_mem_locs): New. (dataflow_set_remove_mem_locs): New. (dataflow_set_clear_at_call): New. (onepart_variable_different_p): New. (variable_different_p): Use it. (dataflow_set_different_1): Adjust. Make detailed dump more verbose. (track_expr_p): Add need_rtl parameter. Don't generate rtl if not needed. (track_loc_p): Pass it true. (struct count_use_info): New. (find_use_val): New. (replace_expr_with_values): New. (log_op_type): New. (use_type): New, partially split out of... (count_uses): ... this. Count new micro-ops. (count_uses_1): Adjust. (count_stores): Adjust. (count_with_sets): New. (VAL_NEEDS_RESOLUTION): New. (VAL_HOLDS_TRACK_EXPR): New. (VAL_EXPR_IS_COPIED): New. (VAL_EXPR_IS_CLOBBERED): New. (add_uses): Adjust. Generate new micro-ops. (add_uses_1): Adjust. (add_stores): Generate new micro-ops. (add_with_sets): New. (find_src_status): Adjust. (find_src_set_src): Adjust. (compute_bb_dataflow): Use dataflow_set_clear_at_call. Handle new micro-ops. Canonicalize value equivalances. (vt_find_locations): Compute total size of hash tables for dumping. Perform merge for var-tracking-assignments. Don't disregard single-block loops. (dump_attrs_list): Handle decl_or_value. (dump_variable): Take variable. Deal with decl_or_value. (dump_variable_slot): New. (dump_vars): Use it. (dump_dataflow_sets): Adjust. (set_slot_part): New, extended to support one-part variables after splitting out of... (set_variable_part): ... this. (clobber_slot_part): New, split out of... (clobber_variable_part): ... this. (delete_slot_part): New, split out of... (delete_variable_part): .... this. (check_wrap_constant): New. (vt_expand_loc_callback): New. (vt_expand_loc): New. (emit_note_insn_var_location): Adjust. Handle values. Handle EMIT_NOTE_AFTER_CALL_INSN. (emit_notes_for_differences_1): Adjust. Handle values. (emit_notes_for_differences_2): Likewise. (emit_notes_for_differences): Adjust. (emit_notes_in_bb): Take pointer to set. Emit AFTER_CALL_INSN notes. Adjust. Handle new micro-ops. (vt_add_function_parameters): Adjust. Create and bind values. (vt_initialize): Adjust. Initialize scratch_regs and valvar_pool, flooded and perm.. Initialize and use cselib. Log operations. Move some code to count_with_sets and add_with_sets. (delete_debug_insns): New. (vt_debug_insns_local): New. (vt_finalize): Release permp, valvar_pool, scratch_regs. Finish cselib. (var_tracking_main): If var-tracking-assignments is enabled but var-tracking isn't, delete debug insns and leave. Likewise if we exceed limits or fail the stack adjustments tests, and after all var-tracking processing. More in var-tracking, from Jakub Jelinek : (dataflow_set): Add traversed_vars. (value_chain, const_value_chain): New typedefs. (value_chain_pool, value_chains): New variables. (value_chain_htab_hash, value_chain_htab_eq, add_value_chain, add_value_chains, add_cselib_value_chains, remove_value_chain, remove_value_chains, remove_cselib_value_chains): New functions. (shared_hash_find_slot_unshare_1, shared_hash_find_slot_1, shared_hash_find_slot_noinsert_1, shared_hash_find_1): New static inlines. (shared_hash_find_slot_unshare, shared_hash_find_slot, shared_hash_find_slot_noinsert, shared_hash_find): Update. (dst_can_be_shared): New variable. (unshare_variable): Unshare set->vars if shared, use shared_hash_*. Clear dst_can_be_shared. If set->traversed_vars is non-NULL and different from set->vars, look up slot again instead of using the passed in slot. (dataflow_set_init): Initialize traversed_vars. (variable_union): Use shared_hash_*. Use initially NO_INSERT lookup if set->vars is shared. Don't keep slot cleared before calling unshare_variable. Unshare set->vars if needed. Adjust unshare_variable callers. Clear dst_can_be_shared if needed. Even ->refcount == 1 vars must be unshared if set->vars is shared and var needs to be modified. (dataflow_set_union): Set traversed_vars during canonicalization. (VALUE_CHANGED, DECL_CHANGED): Define. (set_dv_changed, dv_changed_p): New static inlines. (track_expr_p): Clear DECL_CHANGED. (dump_dataflow_sets): Set it. (variable_was_changed): Call set_dv_changed. (emit_note_insn_var_location): Likewise. (changed_variables_stack): New variable. (check_changed_vars_1, check_changed_vars_2): New functions. (emit_notes_for_changes): Do nothing if changed_variables is empty. Traverse changed_variables with check_changed_vars_1, call check_changed_vars_2 on each changed_variables_stack entry. (emit_notes_in_bb): Add SET argument. Just clear it at the beginning, use it instead of local &set, don't destroy it at the end. (vt_emit_notes): Call dataflow_set_clear early on all VTI(bb)->out sets, never use them, instead use emit_notes_in_bb computed set, dataflow_set_clear also VTI(bb)->in when we are done with the basic block. Initialize changed_variables_stack, free it afterwards. If ENABLE_CHECKING verify that after noting differences to an empty set value_chains hash table is empty. (vt_initialize): Initialize value_chains and value_chain_pool. (vt_finalize): Delete value_chains htab, free value_chain_pool. (variable_tracking_main): Call dump_dataflow_sets before calling vt_emit_notes, not after it. * tree-flow.h (propagate_defs_into_debug_stmts): Declare. (propagate_var_def_into_debug_stmts): Declare. * df-problems.c (df_lr_bb_local_compute): Skip debug insns. (df_set_note): Reject debug insns. (df_whole_mw_reg_dead_p): Take added_notes_p argument. Don't add notes to debug insns. (df_note_bb_compute): Adjust. Likewise. (df_simulate_uses): Skip debug insns. (df_simulate_initialize_backwards): Likewise. * reg-stack.c (subst_stack_regs_in_debug_insn): New. (subst_stack_regs_pat): Reject debug insns. (convert_regs_1): Handle debug insns. * Makefile.in (TREE_INLINE_H): Take pointer-set.h from GIMPLE_H. (print-rtl.o): Depend on cselib.h. (cselib.o): Depend on TREE_PASS_H. (var-tracking.o): Depend on cselib.h and TARGET_H. * sched-rgn.c (rgn_estimate_number_of_insns): Discount debug insns. (init_ready_list): Skip boundary debug insns. (add_branch_dependences): Skip debug insns. (free_block_dependencies): Check for blocks with only debug insns. (compute_priorities): Likewise. * gimple.c (gss_for_code): Handle GIMPLE_DEBUG. (gimple_build_with_ops_stat): Take subcode as unsigned. Adjust all callers. (gimple_build_debug_bind_stat): New. (empty_body_p): Skip debug stmts. (gimple_has_side_effects): Likewise. (gimple_rhs_has_side_effects): Likewise. * gimple.h (enum gimple_debug_subcode, GIMPLE_DEBUG_BIND): New. (gimple_build_debug_bind_stat): Declare. (gimple_build_debug_bind): Define. (is_gimple_debug): New. (gimple_debug_bind_p): New. (gimple_debug_bind_get_var): New. (gimple_debug_bind_get_value): New. (gimple_debug_bind_get_value_ptr): New. (gimple_debug_bind_set_var): New. (gimple_debug_bind_set_value): New. (GIMPLE_DEBUG_BIND_NOVALUE): New internal temporary macro. (gimple_debug_bind_reset_value): New. (gimple_debug_bind_has_value_p): New. (gsi_next_nondebug): New. (gsi_prev_nondebug): New. (gsi_start_nondebug_bb): New. (gsi_last_nondebug_bb): New. * sched-vis.c (print_pattern): Handle VAR_LOCATION. (print_insn): Handle DEBUG_INSN. * tree-cfg.c (remove_bb): Walk stmts backwards. Let loc of first insn prevail. (first_stmt): Skip debug stmts. (first_non_label_stmt): Likewise. (last_stmt): Likewise. (has_zero_uses_1): New. (single_imm_use_1): New. (verify_gimple_debug): New. (verify_types_in_gimple_stmt): Handle debug stmts. (verify_stmt): Likewise. (debug_loop_num): Skip debug stmts. (remove_edge_and_dominated_blocks): Remove dominators last. * tree-ssa-reasssoc.c (rewrite_expr_tree): Propagate into debug stmts. (linearize_expr): Likewise. * config/i386/i386.c (ix86_delegitimize_address): Call default implementation. * config/ia64/ia64.c (ia64_safe_itanium_class): Handle debug insns. (group_barrier_needed): Skip debug insns. (emit_insn_group_barriers): Likewise. (emit_all_insn_group_barriers): Likewise. (ia64_variable_issue): Handle debug insns. (ia64_dfa_new_cycle): Likewise. (final_emit_insn_group_barriers): Skip debug insns. (ia64_dwarf2out_def_steady_cfa): Take frame argument. Don't def cfa without frame. (process_set): Likewise. (process_for_unwind_directive): Pass frame on. * config/rs6000/rs6000.c (TARGET_DELEGITIMIZE_ADDRESS): Define. (rs6000_delegitimize_address): New. (rs6000_debug_adjust_cost): Handle debug insns. (is_microcoded_insn): Likewise. (is_cracked_insn): Likewise. (is_nonpipeline_insn): Likewise. (insn_must_be_first_in_group): Likewise. (insn_must_be_last_in_group): Likewise. (force_new_group): Likewise. * cfgrtl.c (rtl_split_block): Emit INSN_DELETED note if block contains only debug insns. (rtl_merge_blocks): Skip debug insns. (purge_dead_edges): Likewise. (rtl_block_ends_with_call_p): Skip debug insns. * dce.c (deletable_insn_p): Handle VAR_LOCATION. (mark_reg_dependencies): Skip debug insns. * params.def (PARAM_MIN_NONDEBUG_INSN_UID): New. * tree-ssanames.c (release_ssa_name): Propagate def into debug stmts. * tree-ssa-threadedge.c (record_temporary_equivalences_from_stmts): Skip debug stmts. * regcprop.c (replace_oldest_value_addr): Skip debug insns. (replace_oldest_value_mem): Use ALL_REGS for debug insns. (copyprop_hardreg_forward_1): Handle debug insns. * reload1.c (reload): Skip debug insns. Replace unassigned pseudos in debug insns with their equivalences. (eliminate_regs_in_insn): Skip debug insns. (emit_input_reload_insns): Skip debug insns at first, adjust them later. * tree-ssa-operands.c (add_virtual_operand): Reject debug stmts. (get_indirect_ref_operands): Pass opf_no_vops on. (get_expr_operands): Likewise. Skip debug stmts. (parse_ssa_operands): Scan debug insns with opf_no_vops. gcc/testsuite/ChangeLog: * gcc.dg/guality/guality.c: New. * gcc.dg/guality/guality.h: New. * gcc.dg/guality/guality.exp: New. * gcc.dg/guality/example.c: New. * lib/gcc-dg.exp (cleanup-dump): Remove .gk files. (cleanup-saved-temps): Likewise, .gkd files too. gcc/cp/ChangeLog: * cp-tree.h (TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS): New. * cp-lang.c (cxx_dwarf_name): Pass it. * error.c (count_non_default_template_args): Take flags as argument. Adjust all callers. Skip counting of default arguments if the new flag is given. ChangeLog: * Makefile.tpl (BUILD_CONFIG): Default to bootstrap-debug. * Makefile.in: Rebuilt. contrib/ChangeLog: * compare-debug: Look for .gkd files and compare them. config/ChangeLog: * bootstrap-debug.mk: Add comments. * bootstrap-debug-big.mk: New. * bootstrap-debug-lean.mk: New. * bootstrap-debug-ckovw.mk: Add comments. * bootstrap-debug-lib.mk: Drop CFLAGS for stages. Use -g0 for TFLAGS in stage1. Drop -fvar-tracking-assignments-toggle. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151312 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 71d4e17064d..05988636489 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -1849,7 +1849,8 @@ find_interesting_uses (struct ivopts_data *data) for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi)) find_interesting_uses_stmt (data, gsi_stmt (bsi)); for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) - find_interesting_uses_stmt (data, gsi_stmt (bsi)); + if (!is_gimple_debug (gsi_stmt (bsi))) + find_interesting_uses_stmt (data, gsi_stmt (bsi)); } if (dump_file && (dump_flags & TDF_DETAILS)) @@ -5621,7 +5622,24 @@ remove_unused_ivs (struct ivopts_data *data) && !info->inv_id && !info->iv->have_use_for && !info->preserve_biv) - remove_statement (SSA_NAME_DEF_STMT (info->iv->ssa_name), true); + { + if (MAY_HAVE_DEBUG_STMTS) + { + gimple stmt; + imm_use_iterator iter; + + FOR_EACH_IMM_USE_STMT (stmt, iter, info->iv->ssa_name) + { + if (!gimple_debug_bind_p (stmt)) + continue; + + /* ??? We can probably do better than this. */ + gimple_debug_bind_reset_value (stmt); + update_stmt (stmt); + } + } + remove_statement (SSA_NAME_DEF_STMT (info->iv->ssa_name), true); + } } } -- cgit v1.2.1 From 1b2231948faf0b0611bdb75176304783886730f7 Mon Sep 17 00:00:00 2001 From: aoliva Date: Tue, 8 Sep 2009 17:40:45 +0000 Subject: * tree-ssa-loop-ivopts.c (get_phi_with_result): Remove. (remove_statement): Likewise. (rewrite_use_nonlinear_expr): Adjust. (remove_unused_ivs): Collect SSA NAMEs to remove and call... * tree-ssa.c (release_defs_bitset): ... this. New. * tree-flow.h (release_defs_bitset): Declare. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151520 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 67 +++++++++------------------------------------- 1 file changed, 12 insertions(+), 55 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 05988636489..42b2ef36252 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -5297,42 +5297,6 @@ create_new_ivs (struct ivopts_data *data, struct iv_ca *set) } } -/* Returns the phi-node in BB with result RESULT. */ - -static gimple -get_phi_with_result (basic_block bb, tree result) -{ - gimple_stmt_iterator i = gsi_start_phis (bb); - - for (; !gsi_end_p (i); gsi_next (&i)) - if (gimple_phi_result (gsi_stmt (i)) == result) - return gsi_stmt (i); - - gcc_unreachable (); - return NULL; -} - - -/* Removes statement STMT (real or a phi node). If INCLUDING_DEFINED_NAME - is true, remove also the ssa name defined by the statement. */ - -static void -remove_statement (gimple stmt, bool including_defined_name) -{ - if (gimple_code (stmt) == GIMPLE_PHI) - { - gimple bb_phi = get_phi_with_result (gimple_bb (stmt), - gimple_phi_result (stmt)); - gimple_stmt_iterator bsi = gsi_for_stmt (bb_phi); - remove_phi_node (&bsi, including_defined_name); - } - else - { - gimple_stmt_iterator bsi = gsi_for_stmt (stmt); - gsi_remove (&bsi, true); - release_defs (stmt); - } -} /* Rewrites USE (definition of iv used in a nonlinear expression) using candidate CAND. */ @@ -5435,7 +5399,9 @@ rewrite_use_nonlinear_expr (struct ivopts_data *data, { ass = gimple_build_assign (tgt, op); gsi_insert_before (&bsi, ass, GSI_SAME_STMT); - remove_statement (use->stmt, false); + + bsi = gsi_for_stmt (use->stmt); + remove_phi_node (&bsi, false); } else { @@ -5611,7 +5577,11 @@ remove_unused_ivs (struct ivopts_data *data) { unsigned j; bitmap_iterator bi; + bitmap toremove = BITMAP_ALLOC (NULL); + /* Figure out an order in which to release SSA DEFs so that we don't + release something that we'd have to propagate into a debug stmt + afterwards. */ EXECUTE_IF_SET_IN_BITMAP (data->relevant, 0, j, bi) { struct version_info *info; @@ -5622,25 +5592,12 @@ remove_unused_ivs (struct ivopts_data *data) && !info->inv_id && !info->iv->have_use_for && !info->preserve_biv) - { - if (MAY_HAVE_DEBUG_STMTS) - { - gimple stmt; - imm_use_iterator iter; - - FOR_EACH_IMM_USE_STMT (stmt, iter, info->iv->ssa_name) - { - if (!gimple_debug_bind_p (stmt)) - continue; - - /* ??? We can probably do better than this. */ - gimple_debug_bind_reset_value (stmt); - update_stmt (stmt); - } - } - remove_statement (SSA_NAME_DEF_STMT (info->iv->ssa_name), true); - } + bitmap_set_bit (toremove, SSA_NAME_VERSION (info->iv->ssa_name)); } + + release_defs_bitset (toremove); + + BITMAP_FREE (toremove); } /* Frees data allocated by the optimization of a single loop. */ -- cgit v1.2.1 From bd1a81f7e1665d2e33cc824dd05dd7988da9f1a8 Mon Sep 17 00:00:00 2001 From: uweigand Date: Mon, 26 Oct 2009 21:55:59 +0000 Subject: 2009-10-26 Ben Elliston Michael Meissner Ulrich Weigand * doc/extend.texi (Named Address Spaces): New section. * coretypes.h (addr_space_t): New type. (ADDR_SPACE_GENERIC): New define. (ADDR_SPACE_GENERIC_P): New macro. * doc/tm.texi (Named Address Spaces): New section. (TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P): Document. (TARGET_ADDR_SPACE_LEGITIMIZE_ADDRESS): Document. (TARGET_ADDR_SPACE_SUBSET_P): Document. (TARGET_ADDR_SPACE_CONVERT): Document. * target.h (struct gcc_target): Add addr_space substructure. * target-def.h (TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P): Define. (TARGET_ADDR_SPACE_LEGITIMIZE_ADDRESS): Likewise. (TARGET_ADDR_SPACE_SUBSET_P): Likewise. (TARGET_ADDR_SPACE_CONVERT): Likewise. (TARGET_ADDR_SPACE_HOOKS): Likewise. (TARGET_INITIALIZER): Initialize addr_space hooks. * targhooks.c (default_addr_space_legitimate_address_p): New function. (default_addr_space_legitimize_address): Likewise. (default_addr_space_subset_p): Likewise. (default_addr_space_convert): Likewise. * targhooks.h (default_addr_space_legitimate_address_p): Add prototype. (default_addr_space_legitimize_address): Likewise. (default_addr_space_subset_p): Likewise. (default_addr_space_convert): Likewise. * doc/rtl.texi (MEM_ADDR_SPACE): Document. * rtl.h (mem_attrs): Add ADDRSPACE memory attribute. (MEM_ADDR_SPACE): New macro. * emit-rtl.c (get_mem_attrs): Add ADDRSPACE argument and set address space memory attribute. (mem_attrs_htab_hash): Handle address space memory attribute. (mem_attrs_htab_eq): Likewise. (set_mem_attributes_minus_bitpos): Likewise. (set_mem_alias_set): Likewise. (set_mem_align): Likewise. (set_mem_expr): Likewise. (set_mem_offset): Likewise. (set_mem_size): Likewise. (adjust_address_1): Likewise. (offset_address): Likewise. (widen_memoy_address): Likewise. (get_spill_slot_decl): Likewise. (set_mem_attrs_for_spill): Likewise. (set_mem_addr_space): New function. * emit-rtl.h (set_mem_addr_space): Add prototype. * print-rtl.c (print_rtx): Print address space memory attribute. * expr.c (expand_assignment): Set address space memory attribute of generated MEM RTXes as appropriate. (expand_expr_real_1): Likewise. * cfgexpand.c (expand_debug_expr): Likewise. * tree-ssa-loop-ivopts.c (produce_memory_decl_rtl): Likewise. * tree.h (struct tree_base): Add address_space bitfield. Reduce size of "spare" bitfield. (TYPE_ADDR_SPACE): New macro. (ENCODE_QUAL_ADDR_SPACE): Likewise. (DECODE_QUAL_ADDR_SPACE): Likewise. (CLEAR_QUAL_ADDR_SPACE): Likewise. (KEEP_QUAL_ADDR_SPACE): Likewise. (TYPE_QUALS): Encode type address space. (TYPE_QUALS_NO_ADDR_SPACE): New macro. * tree.c (set_type_quals): Set type address space. (build_array_type): Inherit array address space from element type. * print-tree.c (print_node_brief): Print type address space. (print_node): Likewise. * tree-pretty-print.c (dump_generic_node): Likewise. * explow.c (memory_address): Rename to ... (memory_address_addr_space): ... this. Add ADDRSPACE argument. Use address-space aware variants of memory address routines. * recog.c (memory_address_p): Rename to ... (memory_address_addr_space_p): ... this. Add ADDSPACE argument. Use address-space aware variants of memory address routines. (offsettable_address_p): Rename to ... (offsettable_address_addr_space_p): ... this. Add ADDRSPACE argument. Use address-space aware variants of memory address routines. * reload.c (strict_memory_address_p): Rename to ... (strict_memory_address_addr_space_p): ... this. Add ADDSPACE argument. Use address-space aware variants of memory address routines. (maybe_memory_address_p): Rename to ... (maybe_memory_address_addr_space_p): ... this. Add ADDSPACE argument. Use address-space aware variants of memory address routines. * expr.h (memory_address_addr_space): Add prototype. (memory_address): Define as macro. * recog.h (memory_address_addr_space_p): Add prototype. (memory_address_p): Define as macro. (offsettable_address_addr_space_p): Add prototype. (offsettable_address_p): Define as macro. (strict_memory_address_addr_space_p): Add prototype. (strict_memory_address_p): Define as macro. * combine.c (find_split_point): Use address-space aware variants of memory address routines. * emit-rtl.c (operand_subword): Likewise. (change_address_1): Likewise. (adjust_address_1): Likewise. (offset_address): Likewise. * expr.c (emit_move_insn): Likewise. (expand_assignment): Likewise. (expand_expr_real_1): Likewise. * recog.c (verify_changes): Likewise. (general_operand): Likewise. (offsettable_memref_p): Likewise. (offsettable_nonstrict_memref_p): Likewise. (constrain_operands): Likewise. * reload.c (get_secondary_mem): Likewise. (find_reloads_toplev): Likewise. (find_reloads_address): Likewise. (find_reloads_subreg_address): Likewise. * reload1.c (reload): Likewise. * rtlhooks.c (gen_lowpart_if_possible): Likewise. * rtl.h (address_cost): Add ADDRSPACE argument. * rtlanal.c (address_cost): Add ADDRSPACE argument. Use address-space aware variant of memory address routines. * loop-invariant.c (create_new_invariant): Update address_cost call. * tree-ssa-loop-ivopts.c (computation_cost): Likewise. * fwprop.c (should_replace_address): Add ADDRSPACE argument. Use address-space aware variant of memory address routines. (propagate_rtx_1): Update call to should_replace_address. * tree-flow.h (multiplier_allowed_in_address_p): Add ADDRSPACE argument. * tree-ssa-loop-ivopts.c (multiplier_allowed_in_address_p): Add ADDRSPACE argument. Use per-address-space instead of global cache. Use address-space aware variant of memory address routines. (get_address_cost): Likewise. (get_computation_cost_at): Update calls. * tree-ssa-address.c (valid_mem_ref_p): Add ADDRSPACE argument. Use address-space aware variant of memory address routines. (create_mem_ref_raw): Update call to valid_mem_ref_p. (most_expensive_mult_to_index): Update call to multiplier_allowed_in_address_p. * dwarf2out.c (modified_type_die): Output DW_AT_address_class attribute to indicate named address spaces. * varasm.c (get_variable_section): DECLs in named address spaces cannot be "common". * reload.c (find_reloads_address): Do not use LEGITIMIZE_RELOAD_ADDRESS for addresses in a non-generic address space. * expr.c (emit_block_move_hints): Do not use libcalls for memory in non-generic address spaces. (clear_storage_hints): Likewise. (expand_assignment): Likewise. * fold-const.c (operand_equal_p): Expressions refering to different address spaces are not equivalent. * rtl.c (rtx_equal_p_cb): MEMs refering to different address spaces are not equivalent. (rtx_equal_p): Likewise. * cse.c (exp_equiv_p): Likewise. * jump.c (rtx_renumbered_equal_p): Likewise. * reload.c (operands_match_p): Likewise. * alias.c (nonoverlapping_memrefs_p): MEMs refering to different address spaces may alias. (true_dependence): Likewise. (canon_true_dependence): Likewise. (write_dependence_p): Likewise. * dse.c (canon_address): Handle named address spaces. * ifcvt.c (noce_try_cmove_arith): Likewise. * tree.def (ADDR_SPACE_CONVERT_EXPR): New tree code. * expr.c (expand_expr_real_2): Expand ADDR_SPACE_CONVERT_EXPR. * convert.c (convert_to_pointer): Generate ADDR_SPACE_CONVERT_EXPR to handle conversions between different address spaces. * fold-const.c (fold_convert_loc): Likewise. (fold_unary_loc): Handle ADDR_SPACE_CONVERT_EXPR. * tree-pretty-print.c (dump_generic_node): Likewise. * gimple-pretty-print.c (dump_unary_rhs): Likewise. * tree-cfg.c (verify_gimple_assign_unary): Likewise. * tree-inline.c (estimate_operator_cost): Likewise. * tree-ssa.c (useless_type_conversion_p): Conversions between pointers to different address spaces are not useless. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153572 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 146 +++++++++++++++++++++++++++++---------------- 1 file changed, 93 insertions(+), 53 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 42b2ef36252..7e536136c80 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -2642,6 +2642,7 @@ seq_cost (rtx seq, bool speed) static rtx produce_memory_decl_rtl (tree obj, int *regno) { + addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (obj)); rtx x; gcc_assert (obj); @@ -2651,12 +2652,14 @@ produce_memory_decl_rtl (tree obj, int *regno) x = gen_rtx_SYMBOL_REF (Pmode, name); SET_SYMBOL_REF_DECL (x, obj); x = gen_rtx_MEM (DECL_MODE (obj), x); + set_mem_addr_space (x, as); targetm.encode_section_info (obj, x, true); } else { x = gen_raw_REG (Pmode, (*regno)++); x = gen_rtx_MEM (DECL_MODE (obj), x); + set_mem_addr_space (x, as); } return x; @@ -2744,7 +2747,8 @@ computation_cost (tree expr, bool speed) cost = seq_cost (seq, speed); if (MEM_P (rslt)) - cost += address_cost (XEXP (rslt, 0), TYPE_MODE (type), speed); + cost += address_cost (XEXP (rslt, 0), TYPE_MODE (type), + TYPE_ADDR_SPACE (type), speed); return cost; } @@ -3020,51 +3024,64 @@ multiply_by_cost (HOST_WIDE_INT cst, enum machine_mode mode, bool speed) } /* Returns true if multiplying by RATIO is allowed in an address. Test the - validity for a memory reference accessing memory of mode MODE. */ + validity for a memory reference accessing memory of mode MODE in + address space AS. */ + +DEF_VEC_P (sbitmap); +DEF_VEC_ALLOC_P (sbitmap, heap); bool -multiplier_allowed_in_address_p (HOST_WIDE_INT ratio, enum machine_mode mode) +multiplier_allowed_in_address_p (HOST_WIDE_INT ratio, enum machine_mode mode, + addr_space_t as) { #define MAX_RATIO 128 - static sbitmap valid_mult[MAX_MACHINE_MODE]; - - if (!valid_mult[mode]) + unsigned int data_index = (int) as * MAX_MACHINE_MODE + (int) mode; + static VEC (sbitmap, heap) *valid_mult_list; + sbitmap valid_mult; + + if (data_index >= VEC_length (sbitmap, valid_mult_list)) + VEC_safe_grow_cleared (sbitmap, heap, valid_mult_list, data_index + 1); + + valid_mult = VEC_index (sbitmap, valid_mult_list, data_index); + if (!valid_mult) { rtx reg1 = gen_raw_REG (Pmode, LAST_VIRTUAL_REGISTER + 1); rtx addr; HOST_WIDE_INT i; - valid_mult[mode] = sbitmap_alloc (2 * MAX_RATIO + 1); - sbitmap_zero (valid_mult[mode]); + valid_mult = sbitmap_alloc (2 * MAX_RATIO + 1); + sbitmap_zero (valid_mult); addr = gen_rtx_fmt_ee (MULT, Pmode, reg1, NULL_RTX); for (i = -MAX_RATIO; i <= MAX_RATIO; i++) { XEXP (addr, 1) = gen_int_mode (i, Pmode); - if (memory_address_p (mode, addr)) - SET_BIT (valid_mult[mode], i + MAX_RATIO); + if (memory_address_addr_space_p (mode, addr, as)) + SET_BIT (valid_mult, i + MAX_RATIO); } if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, " allowed multipliers:"); for (i = -MAX_RATIO; i <= MAX_RATIO; i++) - if (TEST_BIT (valid_mult[mode], i + MAX_RATIO)) + if (TEST_BIT (valid_mult, i + MAX_RATIO)) fprintf (dump_file, " %d", (int) i); fprintf (dump_file, "\n"); fprintf (dump_file, "\n"); } + + VEC_replace (sbitmap, valid_mult_list, data_index, valid_mult); } if (ratio > MAX_RATIO || ratio < -MAX_RATIO) return false; - return TEST_BIT (valid_mult[mode], ratio + MAX_RATIO); + return TEST_BIT (valid_mult, ratio + MAX_RATIO); } /* Returns cost of address in shape symbol + var + OFFSET + RATIO * index. If SYMBOL_PRESENT is false, symbol is omitted. If VAR_PRESENT is false, variable is omitted. Compute the cost for a memory reference that accesses - a memory location of mode MEM_MODE. + a memory location of mode MEM_MODE in address space AS. MAY_AUTOINC is set to true if the autoincrement (increasing index by size of MEM_MODE / RATIO) is available. To make this determination, we @@ -3075,16 +3092,25 @@ multiplier_allowed_in_address_p (HOST_WIDE_INT ratio, enum machine_mode mode) TODO -- there must be some better way. This all is quite crude. */ +typedef struct +{ + HOST_WIDE_INT min_offset, max_offset; + unsigned costs[2][2][2][2]; +} *address_cost_data; + +DEF_VEC_P (address_cost_data); +DEF_VEC_ALLOC_P (address_cost_data, heap); + static comp_cost get_address_cost (bool symbol_present, bool var_present, unsigned HOST_WIDE_INT offset, HOST_WIDE_INT ratio, - HOST_WIDE_INT cstep, enum machine_mode mem_mode, bool speed, + HOST_WIDE_INT cstep, enum machine_mode mem_mode, + addr_space_t as, bool speed, bool stmt_after_inc, bool *may_autoinc) { - static bool initialized[MAX_MACHINE_MODE]; - static HOST_WIDE_INT rat[MAX_MACHINE_MODE], off[MAX_MACHINE_MODE]; - static HOST_WIDE_INT min_offset[MAX_MACHINE_MODE], max_offset[MAX_MACHINE_MODE]; - static unsigned costs[MAX_MACHINE_MODE][2][2][2][2]; + static VEC(address_cost_data, heap) *address_cost_data_list; + unsigned int data_index = (int) as * MAX_MACHINE_MODE + (int) mem_mode; + address_cost_data data; static bool has_preinc[MAX_MACHINE_MODE], has_postinc[MAX_MACHINE_MODE]; static bool has_predec[MAX_MACHINE_MODE], has_postdec[MAX_MACHINE_MODE]; unsigned cost, acost, complexity; @@ -3093,16 +3119,22 @@ get_address_cost (bool symbol_present, bool var_present, unsigned HOST_WIDE_INT mask; unsigned bits; - if (!initialized[mem_mode]) + if (data_index >= VEC_length (address_cost_data, address_cost_data_list)) + VEC_safe_grow_cleared (address_cost_data, heap, address_cost_data_list, + data_index + 1); + + data = VEC_index (address_cost_data, address_cost_data_list, data_index); + if (!data) { HOST_WIDE_INT i; HOST_WIDE_INT start = BIGGEST_ALIGNMENT / BITS_PER_UNIT; + HOST_WIDE_INT rat, off; int old_cse_not_expected; unsigned sym_p, var_p, off_p, rat_p, add_c; rtx seq, addr, base; rtx reg0, reg1; - initialized[mem_mode] = true; + data = (address_cost_data) xcalloc (1, sizeof (*data)); reg1 = gen_raw_REG (Pmode, LAST_VIRTUAL_REGISTER + 1); @@ -3110,36 +3142,36 @@ get_address_cost (bool symbol_present, bool var_present, for (i = start; i <= 1 << 20; i <<= 1) { XEXP (addr, 1) = gen_int_mode (i, Pmode); - if (!memory_address_p (mem_mode, addr)) + if (!memory_address_addr_space_p (mem_mode, addr, as)) break; } - max_offset[mem_mode] = i == start ? 0 : i >> 1; - off[mem_mode] = max_offset[mem_mode]; + data->max_offset = i == start ? 0 : i >> 1; + off = data->max_offset; for (i = start; i <= 1 << 20; i <<= 1) { XEXP (addr, 1) = gen_int_mode (-i, Pmode); - if (!memory_address_p (mem_mode, addr)) + if (!memory_address_addr_space_p (mem_mode, addr, as)) break; } - min_offset[mem_mode] = i == start ? 0 : -(i >> 1); + data->min_offset = i == start ? 0 : -(i >> 1); if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "get_address_cost:\n"); fprintf (dump_file, " min offset %s %d\n", GET_MODE_NAME (mem_mode), - (int) min_offset[mem_mode]); + (int) data->min_offset); fprintf (dump_file, " max offset %s %d\n", GET_MODE_NAME (mem_mode), - (int) max_offset[mem_mode]); + (int) data->max_offset); } - rat[mem_mode] = 1; + rat = 1; for (i = 2; i <= MAX_RATIO; i++) - if (multiplier_allowed_in_address_p (i, mem_mode)) + if (multiplier_allowed_in_address_p (i, mem_mode, as)) { - rat[mem_mode] = i; + rat = i; break; } @@ -3151,22 +3183,26 @@ get_address_cost (bool symbol_present, bool var_present, if (HAVE_PRE_DECREMENT) { addr = gen_rtx_PRE_DEC (Pmode, reg0); - has_predec[mem_mode] = memory_address_p (mem_mode, addr); + has_predec[mem_mode] + = memory_address_addr_space_p (mem_mode, addr, as); } if (HAVE_POST_DECREMENT) { addr = gen_rtx_POST_DEC (Pmode, reg0); - has_postdec[mem_mode] = memory_address_p (mem_mode, addr); + has_postdec[mem_mode] + = memory_address_addr_space_p (mem_mode, addr, as); } if (HAVE_PRE_INCREMENT) { addr = gen_rtx_PRE_INC (Pmode, reg0); - has_preinc[mem_mode] = memory_address_p (mem_mode, addr); + has_preinc[mem_mode] + = memory_address_addr_space_p (mem_mode, addr, as); } if (HAVE_POST_INCREMENT) { addr = gen_rtx_POST_INC (Pmode, reg0); - has_postinc[mem_mode] = memory_address_p (mem_mode, addr); + has_postinc[mem_mode] + = memory_address_addr_space_p (mem_mode, addr, as); } for (i = 0; i < 16; i++) { @@ -3178,7 +3214,7 @@ get_address_cost (bool symbol_present, bool var_present, addr = reg0; if (rat_p) addr = gen_rtx_fmt_ee (MULT, Pmode, addr, - gen_int_mode (rat[mem_mode], Pmode)); + gen_int_mode (rat, Pmode)); if (var_p) addr = gen_rtx_fmt_ee (PLUS, Pmode, addr, reg1); @@ -3194,13 +3230,12 @@ get_address_cost (bool symbol_present, bool var_present, if (off_p) base = gen_rtx_fmt_e (CONST, Pmode, - gen_rtx_fmt_ee (PLUS, Pmode, - base, - gen_int_mode (off[mem_mode], - Pmode))); + gen_rtx_fmt_ee + (PLUS, Pmode, base, + gen_int_mode (off, Pmode))); } else if (off_p) - base = gen_int_mode (off[mem_mode], Pmode); + base = gen_int_mode (off, Pmode); else base = NULL_RTX; @@ -3212,17 +3247,17 @@ get_address_cost (bool symbol_present, bool var_present, follow. */ old_cse_not_expected = cse_not_expected; cse_not_expected = true; - addr = memory_address (mem_mode, addr); + addr = memory_address_addr_space (mem_mode, addr, as); cse_not_expected = old_cse_not_expected; seq = get_insns (); end_sequence (); acost = seq_cost (seq, speed); - acost += address_cost (addr, mem_mode, speed); + acost += address_cost (addr, mem_mode, as, speed); if (!acost) acost = 1; - costs[mem_mode][sym_p][var_p][off_p][rat_p] = acost; + data->costs[sym_p][var_p][off_p][rat_p] = acost; } /* On some targets, it is quite expensive to load symbol to a register, @@ -3244,12 +3279,12 @@ get_address_cost (bool symbol_present, bool var_present, off_p = (i >> 1) & 1; rat_p = (i >> 2) & 1; - acost = costs[mem_mode][0][1][off_p][rat_p] + 1; + acost = data->costs[0][1][off_p][rat_p] + 1; if (var_p) acost += add_c; - if (acost < costs[mem_mode][1][var_p][off_p][rat_p]) - costs[mem_mode][1][var_p][off_p][rat_p] = acost; + if (acost < data->costs[1][var_p][off_p][rat_p]) + data->costs[1][var_p][off_p][rat_p] = acost; } if (dump_file && (dump_flags & TDF_DETAILS)) @@ -3273,7 +3308,7 @@ get_address_cost (bool symbol_present, bool var_present, if (rat_p) fprintf (dump_file, "rat * "); - acost = costs[mem_mode][sym_p][var_p][off_p][rat_p]; + acost = data->costs[sym_p][var_p][off_p][rat_p]; fprintf (dump_file, "index costs %d\n", acost); } if (has_predec[mem_mode] || has_postdec[mem_mode] @@ -3281,6 +3316,9 @@ get_address_cost (bool symbol_present, bool var_present, fprintf (dump_file, " May include autoinc/dec\n"); fprintf (dump_file, "\n"); } + + VEC_replace (address_cost_data, address_cost_data_list, + data_index, data); } bits = GET_MODE_BITSIZE (Pmode); @@ -3309,10 +3347,10 @@ get_address_cost (bool symbol_present, bool var_present, cost = 0; offset_p = (s_offset != 0 - && min_offset[mem_mode] <= s_offset - && s_offset <= max_offset[mem_mode]); + && data->min_offset <= s_offset + && s_offset <= data->max_offset); ratio_p = (ratio != 1 - && multiplier_allowed_in_address_p (ratio, mem_mode)); + && multiplier_allowed_in_address_p (ratio, mem_mode, as)); if (ratio != 1 && !ratio_p) cost += multiply_by_cost (ratio, Pmode, speed); @@ -3322,7 +3360,7 @@ get_address_cost (bool symbol_present, bool var_present, if (may_autoinc) *may_autoinc = autoinc; - acost = costs[mem_mode][symbol_present][var_present][offset_p][ratio_p]; + acost = data->costs[symbol_present][var_present][offset_p][ratio_p]; complexity = (symbol_present != 0) + (var_present != 0) + offset_p + ratio_p; return new_cost (cost + acost, complexity); } @@ -3742,8 +3780,9 @@ get_computation_cost_at (struct ivopts_data *data, } else if (address_p && !POINTER_TYPE_P (ctype) - && multiplier_allowed_in_address_p (ratio, - TYPE_MODE (TREE_TYPE (utype)))) + && multiplier_allowed_in_address_p + (ratio, TYPE_MODE (TREE_TYPE (utype)), + TYPE_ADDR_SPACE (TREE_TYPE (utype)))) { cbase = fold_build2 (MULT_EXPR, ctype, cbase, build_int_cst (ctype, ratio)); @@ -3777,6 +3816,7 @@ get_computation_cost_at (struct ivopts_data *data, get_address_cost (symbol_present, var_present, offset, ratio, cstepi, TYPE_MODE (TREE_TYPE (utype)), + TYPE_ADDR_SPACE (TREE_TYPE (utype)), speed, stmt_is_after_inc, can_autoinc)); -- cgit v1.2.1 From 98155838dbd82b97bb7bb16dfcbf98fa2ab27ca9 Mon Sep 17 00:00:00 2001 From: uweigand Date: Mon, 26 Oct 2009 21:57:10 +0000 Subject: 2009-10-26 Ben Elliston Michael Meissner Ulrich Weigand * doc/tm.texi (TARGET_ADDR_SPACE_POINTER_MODE): Document. (TARGET_ADDR_SPACE_ADDRESS_MODE): Likewise. (TARGET_ADDR_SPACE_VALID_POINTER_MODE): Likewise. * target.h (struct target_def): Add pointer_mode, address_mode, and valid_pointer_mode to addr_space substructure. * target-def.h (TARGET_ADDR_SPACE_POINTER_MODE): Define. (TARGET_ADDR_SPACE_ADDRESS_MODE): Likewise. (TARGET_ADDR_SPACE_VALID_POINTER_MODE): Likewise. (TARGET_ADDR_SPACE_HOOKS): Add them. * targhooks.c (target_default_pointer_address_modes_p): New function. * target.h (target_default_pointer_address_modes_p): Add prototype. * targhooks.c (default_addr_space_pointer_mode): New function. (default_addr_space_address_mode): Likewise. (default_addr_space_valid_pointer_mode): Likewise. * targhooks.h (default_addr_space_pointer_mode): Add prototype. (default_addr_space_address_mode): Likewise. (default_addr_space_valid_pointer_mode): Likewise. * output.h (default_valid_pointer_mode): Move to ... * targhooks.h (default_valid_pointer_mode): ... here. * varasm.c (default_valid_pointer_mode): Move to ... * targhooks.c (default_valid_pointer_mode): ... here. * varasm.c (output_constant): Use targetm.addr_space.valid_pointer_mode instead of targetm.valid_pointer_mode. * fold-const.c (fit_double_type): Use int_or_pointer_precision. * tree.c (integer_pow2p): Likewise. (tree_log2): Likewise. (tree_floor_log2): Likewise. (signed_or_unsigned_type_for): Support pointer type of different size. (int_or_pointer_precision): New function. * tree.h (int_or_pointer_precision): Add prototype. * stor-layout.c (layout_type): Set TYPE_PRECISION for offset types. * varasm.c (initializer_constant_valid_p): Use TYPE_PRECISION of incoming pointer type instead of POINTER_SIZE. * tree.c (build_pointer_type): Use appropriate pointer mode instead of ptr_mode. (build_reference_type): Likewise. * expr.c (store_expr): Likewise. (expand_expr_addr_expr): Likewise. * tree-vect-data-refs.c (vect_create_data_ref_ptr): Likewise. * cfgexpand.c (expand_debug_expr): Likewise. * auto-inc-dec.c: Include "target.h". (try_merge): Use appropriate address mode instead of Pmode. (find_inc): Likewise. * combine.c (find_split_point): Likewise. * cselib.c (cselib_record_sets): Likewise. * dse.c (replace_inc_dec): Likewise. (canon_address): Likewise. * var-tracking.c (replace_expr_with_values): Likewise. (count_uses): Likewise. (add_uses): Likewise. (add_stores): Likewise. * emit-rtl.c: Include "target.h". (adjust_address_1): Use appropriate address mode instead of Pmode. (offset_address): Likewise. * explow.c (break_out_memory_refs): Likewise. (memory_address_addr_space): Likewise. (promote_mode): Likewise. * expr.c (move_by_pieces): Likewise. (emit_block_move_via_loop): Likewise. (store_by_pieces): Likewise. (store_by_pieces_1): Likewise. (expand_assignment): Likewise. (store_constructor): Likewise. (expand_expr_addr_expr): Likewise. (expand_expr_real_1): Likewise. * cfgexpand.c (expand_debug_expr): Likewise. * ifcvt.c (noce_try_cmove_arith): Likewise. * regcprop.c (kill_autoinc_value): Likewise. * regmove.c (try_auto_increment): Likewise. * reload.c (find_reloads): Likewise. (find_reloads_address): Likewise. (find_reloads_address_1): Likewise. * sched-deps.c: Include "target.h". (sched_analyze_1): Use appropriate address mode instead of Pmode. (sched_analyze_2): Likewise. * sel-sched-dump.c: Include "target.h". (debug_mem_addr_value): Use appropriate address mode instead of Pmode. * stor-layout.c (layout_type): Likewise. * tree-ssa-loop-ivopts.c (produce_memory_decl_rtl): Likewise. (multiplier_allowed_in_address_p): Likewise. (get_address_cost): Likewise. * varasm.c (make_decl_rtl): Likewise. * expr.c (expand_assignment): Always convert offsets to appropriate address mode. (store_expr): Likewise. (store_constructor): Likewise. (expand_expr_real_1): Likewise. * reload.h (form_sum): Add MODE argument. * reload.c (form_sum): Add MODE argument, use it instead of Pmode. Update recursive calls. (subst_indexed_address): Update calls to form_sum. * tree-flow.h (addr_for_mem_ref): Add ADDRSPACE argument. * tree-ssa-address.c: Include "target.h". (templates): Replace by ... (mem_addr_template_list): ... this new vector. (TEMPL_IDX): Handle address space numbers. (gen_addr_rtx): Add address mode argument, use it instead of Pmode. (addr_for_mem_ref): Add ADDRSPACE argument. Use per-address-space instead of global cache. Update call to gen_addr_rtx. (valid_mem_ref_p): Update call to addr_for_mem_ref. * expr.c (expand_expr_real_1): Update call to addr_for_mem_ref. * rtl.h (convert_memory_address_addr_space): Add prototype. (convert_memory_address): Define as macro. * explow.c (convert_memory_address): Rename to ... (convert_memory_address_addr_space): ... this. Add ADDRSPACE argument. Use appropriate pointer and address modes instead of ptr_mode / Pmode. Update recursive calls. (memory_address_addr_space): Call convert_memory_address_addr_space. * expmed.c (make_tree): Likewise. * expr.c (expand_assignment): Likewise. (expand_expr_addr_expr_1): Likewise. Also, add ADDRSPACE argument. (expand_expr_addr_expr): Likewise. Also, update call. * alias.c (find_base_value): Guard pointer size optimizations. (find_base_term): Likewise. * rtlanal.c (nonzero_bits1): Likewise. (num_sign_bit_copies1): Likewise. * simplify-rtx.c (simplify_unary_operation_1): Likewise. * Makefile.in (tree-ssa-address.o): Add $(TARGET_H) dependency. (emit-rtl.o): Likewise. (auto-inc-dec.o): Likewise. (sched-deps.o): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153573 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 59 ++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 28 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 7e536136c80..82e45d2db4d 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -2643,13 +2643,14 @@ static rtx produce_memory_decl_rtl (tree obj, int *regno) { addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (obj)); + enum machine_mode address_mode = targetm.addr_space.address_mode (as); rtx x; gcc_assert (obj); if (TREE_STATIC (obj) || DECL_EXTERNAL (obj)) { const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (obj)); - x = gen_rtx_SYMBOL_REF (Pmode, name); + x = gen_rtx_SYMBOL_REF (address_mode, name); SET_SYMBOL_REF_DECL (x, obj); x = gen_rtx_MEM (DECL_MODE (obj), x); set_mem_addr_space (x, as); @@ -2657,7 +2658,7 @@ produce_memory_decl_rtl (tree obj, int *regno) } else { - x = gen_raw_REG (Pmode, (*regno)++); + x = gen_raw_REG (address_mode, (*regno)++); x = gen_rtx_MEM (DECL_MODE (obj), x); set_mem_addr_space (x, as); } @@ -3045,16 +3046,17 @@ multiplier_allowed_in_address_p (HOST_WIDE_INT ratio, enum machine_mode mode, valid_mult = VEC_index (sbitmap, valid_mult_list, data_index); if (!valid_mult) { - rtx reg1 = gen_raw_REG (Pmode, LAST_VIRTUAL_REGISTER + 1); + enum machine_mode address_mode = targetm.addr_space.address_mode (as); + rtx reg1 = gen_raw_REG (address_mode, LAST_VIRTUAL_REGISTER + 1); rtx addr; HOST_WIDE_INT i; valid_mult = sbitmap_alloc (2 * MAX_RATIO + 1); sbitmap_zero (valid_mult); - addr = gen_rtx_fmt_ee (MULT, Pmode, reg1, NULL_RTX); + addr = gen_rtx_fmt_ee (MULT, address_mode, reg1, NULL_RTX); for (i = -MAX_RATIO; i <= MAX_RATIO; i++) { - XEXP (addr, 1) = gen_int_mode (i, Pmode); + XEXP (addr, 1) = gen_int_mode (i, address_mode); if (memory_address_addr_space_p (mode, addr, as)) SET_BIT (valid_mult, i + MAX_RATIO); } @@ -3108,6 +3110,7 @@ get_address_cost (bool symbol_present, bool var_present, addr_space_t as, bool speed, bool stmt_after_inc, bool *may_autoinc) { + enum machine_mode address_mode = targetm.addr_space.address_mode (as); static VEC(address_cost_data, heap) *address_cost_data_list; unsigned int data_index = (int) as * MAX_MACHINE_MODE + (int) mem_mode; address_cost_data data; @@ -3136,12 +3139,12 @@ get_address_cost (bool symbol_present, bool var_present, data = (address_cost_data) xcalloc (1, sizeof (*data)); - reg1 = gen_raw_REG (Pmode, LAST_VIRTUAL_REGISTER + 1); + reg1 = gen_raw_REG (address_mode, LAST_VIRTUAL_REGISTER + 1); - addr = gen_rtx_fmt_ee (PLUS, Pmode, reg1, NULL_RTX); + addr = gen_rtx_fmt_ee (PLUS, address_mode, reg1, NULL_RTX); for (i = start; i <= 1 << 20; i <<= 1) { - XEXP (addr, 1) = gen_int_mode (i, Pmode); + XEXP (addr, 1) = gen_int_mode (i, address_mode); if (!memory_address_addr_space_p (mem_mode, addr, as)) break; } @@ -3150,7 +3153,7 @@ get_address_cost (bool symbol_present, bool var_present, for (i = start; i <= 1 << 20; i <<= 1) { - XEXP (addr, 1) = gen_int_mode (-i, Pmode); + XEXP (addr, 1) = gen_int_mode (-i, address_mode); if (!memory_address_addr_space_p (mem_mode, addr, as)) break; } @@ -3177,30 +3180,30 @@ get_address_cost (bool symbol_present, bool var_present, /* Compute the cost of various addressing modes. */ acost = 0; - reg0 = gen_raw_REG (Pmode, LAST_VIRTUAL_REGISTER + 1); - reg1 = gen_raw_REG (Pmode, LAST_VIRTUAL_REGISTER + 2); + reg0 = gen_raw_REG (address_mode, LAST_VIRTUAL_REGISTER + 1); + reg1 = gen_raw_REG (address_mode, LAST_VIRTUAL_REGISTER + 2); if (HAVE_PRE_DECREMENT) { - addr = gen_rtx_PRE_DEC (Pmode, reg0); + addr = gen_rtx_PRE_DEC (address_mode, reg0); has_predec[mem_mode] = memory_address_addr_space_p (mem_mode, addr, as); } if (HAVE_POST_DECREMENT) { - addr = gen_rtx_POST_DEC (Pmode, reg0); + addr = gen_rtx_POST_DEC (address_mode, reg0); has_postdec[mem_mode] = memory_address_addr_space_p (mem_mode, addr, as); } if (HAVE_PRE_INCREMENT) { - addr = gen_rtx_PRE_INC (Pmode, reg0); + addr = gen_rtx_PRE_INC (address_mode, reg0); has_preinc[mem_mode] = memory_address_addr_space_p (mem_mode, addr, as); } if (HAVE_POST_INCREMENT) { - addr = gen_rtx_POST_INC (Pmode, reg0); + addr = gen_rtx_POST_INC (address_mode, reg0); has_postinc[mem_mode] = memory_address_addr_space_p (mem_mode, addr, as); } @@ -3213,15 +3216,15 @@ get_address_cost (bool symbol_present, bool var_present, addr = reg0; if (rat_p) - addr = gen_rtx_fmt_ee (MULT, Pmode, addr, - gen_int_mode (rat, Pmode)); + addr = gen_rtx_fmt_ee (MULT, address_mode, addr, + gen_int_mode (rat, address_mode)); if (var_p) - addr = gen_rtx_fmt_ee (PLUS, Pmode, addr, reg1); + addr = gen_rtx_fmt_ee (PLUS, address_mode, addr, reg1); if (sym_p) { - base = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup ("")); + base = gen_rtx_SYMBOL_REF (address_mode, ggc_strdup ("")); /* ??? We can run into trouble with some backends by presenting it with symbols which haven't been properly passed through targetm.encode_section_info. By setting the local bit, we @@ -3229,18 +3232,18 @@ get_address_cost (bool symbol_present, bool var_present, SYMBOL_REF_FLAGS (base) = SYMBOL_FLAG_LOCAL; if (off_p) - base = gen_rtx_fmt_e (CONST, Pmode, + base = gen_rtx_fmt_e (CONST, address_mode, gen_rtx_fmt_ee - (PLUS, Pmode, base, - gen_int_mode (off, Pmode))); + (PLUS, address_mode, base, + gen_int_mode (off, address_mode))); } else if (off_p) - base = gen_int_mode (off, Pmode); + base = gen_int_mode (off, address_mode); else base = NULL_RTX; if (base) - addr = gen_rtx_fmt_ee (PLUS, Pmode, addr, base); + addr = gen_rtx_fmt_ee (PLUS, address_mode, addr, base); start_sequence (); /* To avoid splitting addressing modes, pretend that no cse will @@ -3272,7 +3275,7 @@ get_address_cost (bool symbol_present, bool var_present, If VAR_PRESENT is true, try whether the mode with SYMBOL_PRESENT = false is cheaper even with cost of addition, and if this is the case, use it. */ - add_c = add_cost (Pmode, speed); + add_c = add_cost (address_mode, speed); for (i = 0; i < 8; i++) { var_p = i & 1; @@ -3321,7 +3324,7 @@ get_address_cost (bool symbol_present, bool var_present, data_index, data); } - bits = GET_MODE_BITSIZE (Pmode); + bits = GET_MODE_BITSIZE (address_mode); mask = ~(~(unsigned HOST_WIDE_INT) 0 << (bits - 1) << 1); offset &= mask; if ((offset >> (bits - 1) & 1)) @@ -3353,10 +3356,10 @@ get_address_cost (bool symbol_present, bool var_present, && multiplier_allowed_in_address_p (ratio, mem_mode, as)); if (ratio != 1 && !ratio_p) - cost += multiply_by_cost (ratio, Pmode, speed); + cost += multiply_by_cost (ratio, address_mode, speed); if (s_offset && !offset_p && !symbol_present) - cost += add_cost (Pmode, speed); + cost += add_cost (address_mode, speed); if (may_autoinc) *may_autoinc = autoinc; -- cgit v1.2.1 From 2451b8b88f07121042f58a4f646cbc045f8630e0 Mon Sep 17 00:00:00 2001 From: uweigand Date: Mon, 2 Nov 2009 14:30:39 +0000 Subject: gcc/ PR tree-optimization/41857 * tree-flow.h (rewrite_use_address): Add BASE_HINT argument. * tree-ssa-loop-ivopts.c (rewrite_use_address): Pass base hint to create_mem_ref. * tree-ssa-address.c (move_hint_to_base): New function. (most_expensive_mult_to_index): Add TYPE argument. Use mode and address space associated with TYPE. (addr_to_parts): Add TYPE and BASE_HINT arguments. Pass TYPE to most_expensive_mult_to_index. Call move_hint_to_base. (create_mem_ref): Add BASE_HINT argument. Pass BASE_HINT and TYPE to addr_to_parts. gcc/testsuite/ PR tree-optimization/41857 * gcc.target/spu/ea/pr41857.c: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153810 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 82e45d2db4d..e89ee0e4ce8 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -5510,6 +5510,7 @@ rewrite_use_address (struct ivopts_data *data, { aff_tree aff; gimple_stmt_iterator bsi = gsi_for_stmt (use->stmt); + tree base_hint = NULL_TREE; tree ref; bool ok; @@ -5517,7 +5518,22 @@ rewrite_use_address (struct ivopts_data *data, gcc_assert (ok); unshare_aff_combination (&aff); - ref = create_mem_ref (&bsi, TREE_TYPE (*use->op_p), &aff, data->speed); + /* To avoid undefined overflow problems, all IV candidates use unsigned + integer types. The drawback is that this makes it impossible for + create_mem_ref to distinguish an IV that is based on a memory object + from one that represents simply an offset. + + To work around this problem, we pass a hint to create_mem_ref that + indicates which variable (if any) in aff is an IV based on a memory + object. Note that we only consider the candidate. If this is not + based on an object, the base of the reference is in some subexpression + of the use -- but these will use pointer types, so they are recognized + by the create_mem_ref heuristics anyway. */ + if (cand->iv->base_object) + base_hint = var_at_stmt (data->current_loop, cand, use->stmt); + + ref = create_mem_ref (&bsi, TREE_TYPE (*use->op_p), &aff, base_hint, + data->speed); copy_ref_info (ref, *use->op_p); *use->op_p = ref; } -- cgit v1.2.1 From 48e1416a24d50cacbb2a5e06a9ee61dd8cbee313 Mon Sep 17 00:00:00 2001 From: hjl Date: Wed, 25 Nov 2009 10:55:54 +0000 Subject: Remove trailing white spaces. 2009-11-25 H.J. Lu * alias.c: Remove trailing white spaces. * alloc-pool.c: Likewise. * alloc-pool.h: Likewise. * attribs.c: Likewise. * auto-inc-dec.c: Likewise. * basic-block.h: Likewise. * bb-reorder.c: Likewise. * bt-load.c: Likewise. * builtins.c: Likewise. * builtins.def: Likewise. * c-common.c: Likewise. * c-common.h: Likewise. * c-cppbuiltin.c: Likewise. * c-decl.c: Likewise. * c-format.c: Likewise. * c-lex.c: Likewise. * c-omp.c: Likewise. * c-opts.c: Likewise. * c-parser.c: Likewise. * c-pretty-print.c: Likewise. * c-tree.h: Likewise. * c-typeck.c: Likewise. * caller-save.c: Likewise. * calls.c: Likewise. * cfg.c: Likewise. * cfganal.c: Likewise. * cfgexpand.c: Likewise. * cfghooks.c: Likewise. * cfghooks.h: Likewise. * cfglayout.c: Likewise. * cfgloop.c: Likewise. * cfgloop.h: Likewise. * cfgloopmanip.c: Likewise. * cfgrtl.c: Likewise. * cgraph.c: Likewise. * cgraph.h: Likewise. * cgraphbuild.c: Likewise. * cgraphunit.c: Likewise. * cif-code.def: Likewise. * collect2.c: Likewise. * combine.c: Likewise. * convert.c: Likewise. * coverage.c: Likewise. * crtstuff.c: Likewise. * cse.c: Likewise. * cselib.c: Likewise. * dbgcnt.c: Likewise. * dbgcnt.def: Likewise. * dbgcnt.h: Likewise. * dbxout.c: Likewise. * dce.c: Likewise. * ddg.c: Likewise. * ddg.h: Likewise. * defaults.h: Likewise. * df-byte-scan.c: Likewise. * df-core.c: Likewise. * df-problems.c: Likewise. * df-scan.c: Likewise. * df.h: Likewise. * dfp.c: Likewise. * diagnostic.c: Likewise. * diagnostic.h: Likewise. * dominance.c: Likewise. * domwalk.c: Likewise. * double-int.c: Likewise. * double-int.h: Likewise. * dse.c: Likewise. * dwarf2asm.c: Likewise. * dwarf2asm.h: Likewise. * dwarf2out.c: Likewise. * ebitmap.c: Likewise. * ebitmap.h: Likewise. * emit-rtl.c: Likewise. * et-forest.c: Likewise. * except.c: Likewise. * except.h: Likewise. * expmed.c: Likewise. * expr.c: Likewise. * expr.h: Likewise. * final.c: Likewise. * flags.h: Likewise. * fold-const.c: Likewise. * function.c: Likewise. * function.h: Likewise. * fwprop.c: Likewise. * gcc.c: Likewise. * gcov-dump.c: Likewise. * gcov-io.c: Likewise. * gcov-io.h: Likewise. * gcov.c: Likewise. * gcse.c: Likewise. * genattr.c: Likewise. * genattrtab.c: Likewise. * genautomata.c: Likewise. * genchecksum.c: Likewise. * genconfig.c: Likewise. * genflags.c: Likewise. * gengtype-parse.c: Likewise. * gengtype.c: Likewise. * gengtype.h: Likewise. * genmddeps.c: Likewise. * genmodes.c: Likewise. * genopinit.c: Likewise. * genpreds.c: Likewise. * gensupport.c: Likewise. * ggc-common.c: Likewise. * ggc-page.c: Likewise. * ggc-zone.c: Likewise. * ggc.h: Likewise. * gimple-iterator.c: Likewise. * gimple-low.c: Likewise. * gimple-pretty-print.c: Likewise. * gimple.c: Likewise. * gimple.def: Likewise. * gimple.h: Likewise. * gimplify.c: Likewise. * graphds.c: Likewise. * graphite-clast-to-gimple.c: Likewise. * gthr-nks.h: Likewise. * gthr-posix.c: Likewise. * gthr-posix.h: Likewise. * gthr-posix95.h: Likewise. * gthr-single.h: Likewise. * gthr-tpf.h: Likewise. * gthr-vxworks.h: Likewise. * gthr.h: Likewise. * haifa-sched.c: Likewise. * hard-reg-set.h: Likewise. * hooks.c: Likewise. * hooks.h: Likewise. * hosthooks.h: Likewise. * hwint.h: Likewise. * ifcvt.c: Likewise. * incpath.c: Likewise. * init-regs.c: Likewise. * integrate.c: Likewise. * ipa-cp.c: Likewise. * ipa-inline.c: Likewise. * ipa-prop.c: Likewise. * ipa-pure-const.c: Likewise. * ipa-reference.c: Likewise. * ipa-struct-reorg.c: Likewise. * ipa-struct-reorg.h: Likewise. * ipa-type-escape.c: Likewise. * ipa-type-escape.h: Likewise. * ipa-utils.c: Likewise. * ipa-utils.h: Likewise. * ipa.c: Likewise. * ira-build.c: Likewise. * ira-color.c: Likewise. * ira-conflicts.c: Likewise. * ira-costs.c: Likewise. * ira-emit.c: Likewise. * ira-int.h: Likewise. * ira-lives.c: Likewise. * ira.c: Likewise. * jump.c: Likewise. * lambda-code.c: Likewise. * lambda-mat.c: Likewise. * lambda-trans.c: Likewise. * lambda.h: Likewise. * langhooks.c: Likewise. * lcm.c: Likewise. * libgcov.c: Likewise. * lists.c: Likewise. * loop-doloop.c: Likewise. * loop-init.c: Likewise. * loop-invariant.c: Likewise. * loop-iv.c: Likewise. * loop-unroll.c: Likewise. * lower-subreg.c: Likewise. * lto-cgraph.c: Likewise. * lto-compress.c: Likewise. * lto-opts.c: Likewise. * lto-section-in.c: Likewise. * lto-section-out.c: Likewise. * lto-streamer-in.c: Likewise. * lto-streamer-out.c: Likewise. * lto-streamer.c: Likewise. * lto-streamer.h: Likewise. * lto-symtab.c: Likewise. * lto-wpa-fixup.c: Likewise. * matrix-reorg.c: Likewise. * mcf.c: Likewise. * mode-switching.c: Likewise. * modulo-sched.c: Likewise. * omega.c: Likewise. * omega.h: Likewise. * omp-low.c: Likewise. * optabs.c: Likewise. * optabs.h: Likewise. * opts-common.c: Likewise. * opts.c: Likewise. * params.def: Likewise. * params.h: Likewise. * passes.c: Likewise. * plugin.c: Likewise. * postreload-gcse.c: Likewise. * postreload.c: Likewise. * predict.c: Likewise. * predict.def: Likewise. * pretty-print.c: Likewise. * pretty-print.h: Likewise. * print-rtl.c: Likewise. * print-tree.c: Likewise. * profile.c: Likewise. * read-rtl.c: Likewise. * real.c: Likewise. * recog.c: Likewise. * reg-stack.c: Likewise. * regcprop.c: Likewise. * reginfo.c: Likewise. * regmove.c: Likewise. * regrename.c: Likewise. * regs.h: Likewise. * regstat.c: Likewise. * reload.c: Likewise. * reload1.c: Likewise. * resource.c: Likewise. * rtl.c: Likewise. * rtl.def: Likewise. * rtl.h: Likewise. * rtlanal.c: Likewise. * sbitmap.c: Likewise. * sched-deps.c: Likewise. * sched-ebb.c: Likewise. * sched-int.h: Likewise. * sched-rgn.c: Likewise. * sched-vis.c: Likewise. * sdbout.c: Likewise. * sel-sched-dump.c: Likewise. * sel-sched-dump.h: Likewise. * sel-sched-ir.c: Likewise. * sel-sched-ir.h: Likewise. * sel-sched.c: Likewise. * sel-sched.h: Likewise. * sese.c: Likewise. * sese.h: Likewise. * simplify-rtx.c: Likewise. * stack-ptr-mod.c: Likewise. * stmt.c: Likewise. * stor-layout.c: Likewise. * store-motion.c: Likewise. * stringpool.c: Likewise. * stub-objc.c: Likewise. * sync-builtins.def: Likewise. * target-def.h: Likewise. * target.h: Likewise. * targhooks.c: Likewise. * targhooks.h: Likewise. * timevar.c: Likewise. * tlink.c: Likewise. * toplev.c: Likewise. * toplev.h: Likewise. * tracer.c: Likewise. * tree-affine.c: Likewise. * tree-affine.h: Likewise. * tree-browser.def: Likewise. * tree-call-cdce.c: Likewise. * tree-cfg.c: Likewise. * tree-cfgcleanup.c: Likewise. * tree-chrec.c: Likewise. * tree-chrec.h: Likewise. * tree-complex.c: Likewise. * tree-data-ref.c: Likewise. * tree-data-ref.h: Likewise. * tree-dfa.c: Likewise. * tree-dump.c: Likewise. * tree-dump.h: Likewise. * tree-eh.c: Likewise. * tree-flow-inline.h: Likewise. * tree-flow.h: Likewise. * tree-if-conv.c: Likewise. * tree-inline.c: Likewise. * tree-into-ssa.c: Likewise. * tree-loop-distribution.c: Likewise. * tree-loop-linear.c: Likewise. * tree-mudflap.c: Likewise. * tree-nested.c: Likewise. * tree-nomudflap.c: Likewise. * tree-nrv.c: Likewise. * tree-object-size.c: Likewise. * tree-optimize.c: Likewise. * tree-outof-ssa.c: Likewise. * tree-parloops.c: Likewise. * tree-pass.h: Likewise. * tree-phinodes.c: Likewise. * tree-predcom.c: Likewise. * tree-pretty-print.c: Likewise. * tree-profile.c: Likewise. * tree-scalar-evolution.c: Likewise. * tree-ssa-address.c: Likewise. * tree-ssa-alias.c: Likewise. * tree-ssa-ccp.c: Likewise. * tree-ssa-coalesce.c: Likewise. * tree-ssa-copy.c: Likewise. * tree-ssa-copyrename.c: Likewise. * tree-ssa-dce.c: Likewise. * tree-ssa-dom.c: Likewise. * tree-ssa-dse.c: Likewise. * tree-ssa-forwprop.c: Likewise. * tree-ssa-ifcombine.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-live.h: Likewise. * tree-ssa-loop-ch.c: Likewise. * tree-ssa-loop-im.c: Likewise. * tree-ssa-loop-ivcanon.c: Likewise. * tree-ssa-loop-ivopts.c: Likewise. * tree-ssa-loop-manip.c: Likewise. * tree-ssa-loop-niter.c: Likewise. * tree-ssa-loop-prefetch.c: Likewise. * tree-ssa-loop-unswitch.c: Likewise. * tree-ssa-loop.c: Likewise. * tree-ssa-math-opts.c: Likewise. * tree-ssa-operands.c: Likewise. * tree-ssa-operands.h: Likewise. * tree-ssa-phiopt.c: Likewise. * tree-ssa-phiprop.c: Likewise. * tree-ssa-pre.c: Likewise. * tree-ssa-propagate.c: Likewise. * tree-ssa-reassoc.c: Likewise. * tree-ssa-sccvn.c: Likewise. * tree-ssa-sink.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-ssa-ter.c: Likewise. * tree-ssa-threadedge.c: Likewise. * tree-ssa-threadupdate.c: Likewise. * tree-ssa-uncprop.c: Likewise. * tree-ssa.c: Likewise. * tree-ssanames.c: Likewise. * tree-switch-conversion.c: Likewise. * tree-tailcall.c: Likewise. * tree-vect-data-refs.c: Likewise. * tree-vect-generic.c: Likewise. * tree-vect-loop-manip.c: Likewise. * tree-vect-loop.c: Likewise. * tree-vect-patterns.c: Likewise. * tree-vect-slp.c: Likewise. * tree-vect-stmts.c: Likewise. * tree-vectorizer.c: Likewise. * tree-vectorizer.h: Likewise. * tree-vrp.c: Likewise. * tree.c: Likewise. * tree.def: Likewise. * tree.h: Likewise. * treestruct.def: Likewise. * unwind-compat.c: Likewise. * unwind-dw2-fde-glibc.c: Likewise. * unwind-dw2.c: Likewise. * value-prof.c: Likewise. * value-prof.h: Likewise. * var-tracking.c: Likewise. * varasm.c: Likewise. * varpool.c: Likewise. * vec.c: Likewise. * vec.h: Likewise. * vmsdbgout.c: Likewise. * web.c: Likewise. * xcoffout.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154645 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 72 +++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index e89ee0e4ce8..759edb11770 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -1,19 +1,19 @@ /* Induction variable optimizations. Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. - + 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 . */ @@ -56,7 +56,7 @@ along with GCC; see the file COPYING3. If not see 4) The trees are transformed to use the new variables, the dead code is removed. - + All of this is done loop by loop. Doing it globally is theoretically possible, it might give a better performance and it might enable us to decide costs more precisely, but getting all the interactions right @@ -1076,7 +1076,7 @@ find_induction_variables (struct ivopts_data *data) print_generic_expr (dump_file, niter, TDF_SLIM); fprintf (dump_file, "\n\n"); }; - + fprintf (dump_file, "Induction variables:\n\n"); EXECUTE_IF_SET_IN_BITMAP (data->relevant, 0, i, bi) @@ -1159,7 +1159,7 @@ find_interesting_uses_op (struct ivopts_data *data, tree op) iv = get_iv (data, op); if (!iv) return NULL; - + if (iv->have_use_for) { use = iv_use (data, iv->use_id); @@ -1545,7 +1545,7 @@ may_be_unaligned_p (tree ref, tree step) || bitpos % GET_MODE_ALIGNMENT (mode) != 0 || bitpos % BITS_PER_UNIT != 0) return true; - + if (!constant_multiple_of (step, al, &mul)) return true; } @@ -2097,7 +2097,7 @@ add_candidate_1 (struct ivopts_data *data, unsigned i; struct iv_cand *cand = NULL; tree type, orig_type; - + if (base) { orig_type = TREE_TYPE (base); @@ -2267,7 +2267,7 @@ add_autoinc_candidates (struct ivopts_data *data, tree base, tree step, it. The candidate computation is scheduled on all available positions. */ static void -add_candidate (struct ivopts_data *data, +add_candidate (struct ivopts_data *data, tree base, tree step, bool important, struct iv_use *use) { if (ip_normal_pos (data->current_loop)) @@ -2604,7 +2604,7 @@ get_use_iv_cost (struct ivopts_data *data, struct iv_use *use, return ret; } - + /* n_map_members is a power of two, so this computes modulo. */ s = cand->id & (use->n_map_members - 1); for (i = s; i < use->n_map_members; i++) @@ -2645,7 +2645,7 @@ produce_memory_decl_rtl (tree obj, int *regno) addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (obj)); enum machine_mode address_mode = targetm.addr_space.address_mode (as); rtx x; - + gcc_assert (obj); if (TREE_STATIC (obj) || DECL_EXTERNAL (obj)) { @@ -2876,7 +2876,7 @@ get_computation_aff (struct loop *loop, if (stmt_after_increment (loop, cand, at)) { aff_tree cstep_aff; - + if (common_type != uutype) cstep_common = fold_convert (common_type, cstep); else @@ -2947,7 +2947,7 @@ add_cost (enum machine_mode mode, bool speed) cost = 1; costs[mode] = cost; - + if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Addition in %s costs %d\n", GET_MODE_NAME (mode), cost); @@ -3012,7 +3012,7 @@ multiply_by_cost (HOST_WIDE_INT cst, enum machine_mode mode, bool speed) gen_int_mode (cst, mode), NULL_RTX, 0); seq = get_insns (); end_sequence (); - + cost = seq_cost (seq, speed); if (dump_file && (dump_flags & TDF_DETAILS)) @@ -3241,7 +3241,7 @@ get_address_cost (bool symbol_present, bool var_present, base = gen_int_mode (off, address_mode); else base = NULL_RTX; - + if (base) addr = gen_rtx_fmt_ee (PLUS, address_mode, addr, base); @@ -3293,7 +3293,7 @@ get_address_cost (bool symbol_present, bool var_present, if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "Address costs:\n"); - + for (i = 0; i < 16; i++) { sym_p = i & 1; @@ -3498,7 +3498,7 @@ force_expr_to_var_cost (tree expr, bool speed) case MULT_EXPR: if (cst_and_fits_in_hwi (op0)) cost = new_cost (multiply_by_cost (int_cst_value (op0), mode, speed), 0); - else if (cst_and_fits_in_hwi (op1)) + else if (cst_and_fits_in_hwi (op1)) cost = new_cost (multiply_by_cost (int_cst_value (op1), mode, speed), 0); else return new_cost (target_spill_cost [speed], 0); @@ -3553,7 +3553,7 @@ split_address_cost (struct ivopts_data *data, tree toffset; enum machine_mode mode; int unsignedp, volatilep; - + core = get_inner_reference (addr, &bitsize, &bitpos, &toffset, &mode, &unsignedp, &volatilep, false); @@ -3576,7 +3576,7 @@ split_address_cost (struct ivopts_data *data, *var_present = false; return zero_cost; } - + *symbol_present = false; *var_present = true; return zero_cost; @@ -3750,7 +3750,7 @@ get_computation_cost_at (struct ivopts_data *data, if (!constant_multiple_of (ustep, cstep, &rat)) return infinite_cost; - + if (double_int_fits_in_shwi_p (rat)) ratio = double_int_to_shwi (rat); else @@ -3761,14 +3761,14 @@ get_computation_cost_at (struct ivopts_data *data, /* use = ubase + ratio * (var - cbase). If either cbase is a constant or ratio == 1, it is better to handle this like - + ubase - ratio * cbase + ratio * var - + (also holds in the case ratio == -1, TODO. */ if (cst_and_fits_in_hwi (cbase)) { - offset = - ratio * int_cst_value (cbase); + offset = - ratio * int_cst_value (cbase); cost = difference_cost (data, ubase, build_int_cst (utype, 0), &symbol_present, &var_present, &offset, @@ -4341,7 +4341,7 @@ determine_iv_cost (struct ivopts_data *data, struct iv_cand *cand) if (cand->pos != IP_ORIGINAL || DECL_ARTIFICIAL (SSA_NAME_VAR (cand->var_before))) cost++; - + /* Prefer not to insert statements into latch unless there are some already (so that we do not create unnecessary jumps). */ if (cand->pos == IP_END @@ -4414,7 +4414,7 @@ determine_set_costs (struct ivopts_data *data) etc.). For now the reserve is a constant 3. Let I be the number of induction variables. - + -- if U + I + R <= A, the cost is I * SMALL_COST (just not to encourage make a lot of ivs without a reason). -- if A - R < U + I <= A, the cost is I * PRES_COST @@ -4893,7 +4893,7 @@ iv_ca_extend (struct ivopts_data *data, struct iv_ca *ivs, if (!iv_ca_has_deps (ivs, new_cp)) continue; - + if (!cheaper_cost_pair (new_cp, old_cp)) continue; @@ -4948,7 +4948,7 @@ iv_ca_narrow (struct ivopts_data *data, struct iv_ca *ivs, continue; if (!iv_ca_has_deps (ivs, cp)) continue; - + if (!cheaper_cost_pair (cp, new_cp)) continue; @@ -4969,7 +4969,7 @@ iv_ca_narrow (struct ivopts_data *data, struct iv_ca *ivs, continue; if (!iv_ca_has_deps (ivs, cp)) continue; - + if (!cheaper_cost_pair (cp, new_cp)) continue; @@ -5117,7 +5117,7 @@ try_add_cand_for (struct ivopts_data *data, struct iv_ca *ivs, /* Already tried this. */ if (cand->important && cand->iv->base_object == NULL_TREE) continue; - + if (iv_ca_cand_used_p (ivs, cand)) continue; @@ -5179,7 +5179,7 @@ try_improve_iv_set (struct ivopts_data *data, struct iv_ca *ivs) for (i = 0; i < n_iv_cands (data); i++) { cand = iv_cand (data, i); - + if (iv_ca_cand_used_p (ivs, cand)) continue; @@ -5310,10 +5310,10 @@ create_new_iv (struct ivopts_data *data, struct iv_cand *cand) /* Rewrite the increment so that it uses var_before directly. */ find_interesting_uses_op (data, cand->var_after)->selected = cand; - + return; } - + gimple_add_tmp_var (cand->var_before); add_referenced_var (cand->var_before); @@ -5606,7 +5606,7 @@ rewrite_use (struct ivopts_data *data, struct iv_use *use, struct iv_cand *cand) default: gcc_unreachable (); } - + update_stmt (use->stmt); } @@ -5763,7 +5763,7 @@ tree_ssa_iv_optimize_loop (struct ivopts_data *data, struct loop *loop) if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "Processing loop %d\n", loop->num); - + exit = single_dom_exit (loop); if (exit) { @@ -5807,7 +5807,7 @@ tree_ssa_iv_optimize_loop (struct ivopts_data *data, struct loop *loop) /* Create the new induction variables (item 4, part 1). */ create_new_ivs (data, iv_ca); iv_ca_free (&iv_ca); - + /* Rewrite the uses (item 4, part 2). */ rewrite_uses (data); -- cgit v1.2.1 From 0d9f1189f3df5ce5c0efc3ecadc7c0a4f75b202d Mon Sep 17 00:00:00 2001 From: rguenth Date: Sun, 7 Feb 2010 13:42:52 +0000 Subject: 2010-02-07 Richard Guenther PR middle-end/42956 * gimplify.c (gimple_fold_indirect_ref): Avoid generating new ARRAY_REFs on variable size element or minimal index arrays. Complete. * tree-ssa-loop-ivopts.c (find_interesting_uses_address): Use gimple_fold_indirect_ref. * gcc.c-torture/compile/pr42956.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156571 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 759edb11770..436e6ce8fc4 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -1686,7 +1686,11 @@ find_interesting_uses_address (struct ivopts_data *data, gimple stmt, tree *op_p while (handled_component_p (*ref)) ref = &TREE_OPERAND (*ref, 0); if (TREE_CODE (*ref) == INDIRECT_REF) - *ref = fold_indirect_ref (*ref); + { + tree tem = gimple_fold_indirect_ref (TREE_OPERAND (*ref, 0)); + if (tem) + *ref = tem; + } } } -- cgit v1.2.1 From 168561ef65d7f576f6f9e25223b5b4c39c2eb8d2 Mon Sep 17 00:00:00 2001 From: spop Date: Thu, 11 Feb 2010 15:45:27 +0000 Subject: Fix PR40886. 2010-02-11 Sebastian Pop Changpeng Fang PR middle-end/40886 * tree-ssa-loop-ivopts.c (determine_use_iv_cost_condition): Decrement the cost of an IV candidate when the IV is used in a test against zero. * gcc.dg/tree-ssa/ivopts-3.c: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156701 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 436e6ce8fc4..74dadf77897 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -4089,6 +4089,7 @@ determine_use_iv_cost_condition (struct ivopts_data *data, bitmap depends_on_elim = NULL, depends_on_express = NULL, depends_on; comp_cost elim_cost, express_cost, cost; bool ok; + tree *control_var, *bound_cst; /* Only consider real candidates. */ if (!cand->iv) @@ -4110,9 +4111,21 @@ determine_use_iv_cost_condition (struct ivopts_data *data, /* Try expressing the original giv. If it is compared with an invariant, note that we cannot get rid of it. */ - ok = extract_cond_operands (data, use->stmt, NULL, NULL, NULL, &cmp_iv); + ok = extract_cond_operands (data, use->stmt, &control_var, &bound_cst, + NULL, &cmp_iv); gcc_assert (ok); + /* When the condition is a comparison of the candidate IV against + zero, prefer this IV. + + TODO: The constant that we're substracting from the cost should + be target-dependent. This information should be added to the + target costs for each backend. */ + if (integer_zerop (*bound_cst) + && (operand_equal_p (*control_var, cand->var_after, 0) + || operand_equal_p (*control_var, cand->var_before, 0))) + elim_cost.cost -= 1; + express_cost = get_computation_cost (data, use, cand, false, &depends_on_express, NULL); fd_ivopts_data = data; -- cgit v1.2.1 From 0a5fa2b7bb7cef9dd55790bf386a5e7c09284947 Mon Sep 17 00:00:00 2001 From: spop Date: Thu, 4 Mar 2010 12:12:50 +0000 Subject: Fix PR43209: Do not decrease the cost of an IV candidate when the cost is infinite. 2010-03-03 Changpeng Fang PR middle-end/43209 * tree-ssa-loop-ivopts.c (determine_use_iv_cost_condition): Do not decrease the cost of an IV candidate when the cost is infinite. * gcc.dg/tree-ssa/ivopts-4.c: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157217 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 74dadf77897..e6565dbdf99 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -1,5 +1,5 @@ /* Induction variable optimizations. - Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 + Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GCC. @@ -4121,7 +4121,8 @@ determine_use_iv_cost_condition (struct ivopts_data *data, TODO: The constant that we're substracting from the cost should be target-dependent. This information should be added to the target costs for each backend. */ - if (integer_zerop (*bound_cst) + if (!infinite_cost_p (elim_cost) /* Do not try to decrease infinite! */ + && integer_zerop (*bound_cst) && (operand_equal_p (*control_var, cand->var_after, 0) || operand_equal_p (*control_var, cand->var_before, 0))) elim_cost.cost -= 1; -- cgit v1.2.1 From 9c44b3951ca82eceb9be44f16a23fbd8c30240f4 Mon Sep 17 00:00:00 2001 From: rguenth Date: Thu, 1 Apr 2010 16:18:07 +0000 Subject: 2010-04-01 Richard Guenther PR middle-end/43614 * tree-ssa-address.c (copy_mem_ref_info): Copy TREE_SIDE_EFFECTS and TREE_THIS_VOLATILE. (copy_ref_info): Likewise. * tree-ssa-operands.c (get_tmr_operands): Check TREE_THIS_VOLATILE. * tree.c (build6_stat): Ignore side-effects of all but arg5 for TARGET_MEM_REF. Set TREE_THIS_VOLATILE from arg5 of TARGET_MEM_REF. * gcc.c-torture/compile/pr43614.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157913 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index e6565dbdf99..f6db2415a36 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -5517,7 +5517,11 @@ copy_ref_info (tree new_ref, tree old_ref) if (TREE_CODE (old_ref) == TARGET_MEM_REF) copy_mem_ref_info (new_ref, old_ref); else - TMR_ORIGINAL (new_ref) = unshare_and_remove_ssa_names (old_ref); + { + TMR_ORIGINAL (new_ref) = unshare_and_remove_ssa_names (old_ref); + TREE_SIDE_EFFECTS (new_ref) = TREE_SIDE_EFFECTS (old_ref); + TREE_THIS_VOLATILE (new_ref) = TREE_THIS_VOLATILE (old_ref); + } } /* Rewrites USE (address that is an iv) using candidate CAND. */ -- cgit v1.2.1 From 125b6d78d39ec6f18cab9f54a07d474e496920c8 Mon Sep 17 00:00:00 2001 From: hubicka Date: Mon, 26 Apr 2010 13:33:24 +0000 Subject: * cgraph.c (cgraph_create_node): Set node frequency to normal. (cgraph_clone_node): Copy function frequency. * cgraph.h (node_frequency): New enum (struct cgraph_node): Add. * final.c (rest_of_clean_state): Update. * lto-cgraph.c (lto_output_node): Output node frequency. (input_overwrite_node): Input node frequency. * tre-ssa-loop-ivopts (computation_cost): Update. * lto-streamer-out.c (output_function): Do not output function frequency. * predict.c (maybe_hot_frequency_p): Update and handle functions executed once. (cgraph_maybe_hot_edge_p): Likewise; use cgraph frequency instead of attribute lookup. (probably_never_executed_bb_p, optimize_function_for_size_p): Update. (compute_function_frequency): Set noreturn functions to be executed once. (choose_function_section): Update. * lto-streamer-in.c (input_function): Do not input function frequency. * function.c (allocate_struct_function): Do not initialize function frequency. * function.h (function_frequency): Remove. (struct function): Remove function frequency. * ipa-profile.c (CGRAPH_NODE_FREQUENCY): Remove. (try_update): Update. * tree-inline.c (initialize_cfun): Do not update function frequency. * passes.c (pass_init_dump_file): Update. * i386.c (ix86_compute_frame_layout): Update. (ix86_pad_returns): Update. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158732 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index f6db2415a36..a7a9e253850 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -2738,9 +2738,10 @@ computation_cost (tree expr, bool speed) unsigned cost; /* Avoid using hard regs in ways which may be unsupported. */ int regno = LAST_VIRTUAL_REGISTER + 1; - enum function_frequency real_frequency = cfun->function_frequency; + struct cgraph_node *node = cgraph_node (current_function_decl); + enum node_frequency real_frequency = node->frequency; - cfun->function_frequency = FUNCTION_FREQUENCY_NORMAL; + node->frequency = NODE_FREQUENCY_NORMAL; crtl->maybe_hot_insn_p = speed; walk_tree (&expr, prepare_decl_rtl, ®no, NULL); start_sequence (); @@ -2748,7 +2749,7 @@ computation_cost (tree expr, bool speed) seq = get_insns (); end_sequence (); default_rtl_profile (); - cfun->function_frequency = real_frequency; + node->frequency = real_frequency; cost = seq_cost (seq, speed); if (MEM_P (rslt)) -- cgit v1.2.1 From 609c710b62c353e5c6732db421774980ef5f0cc4 Mon Sep 17 00:00:00 2001 From: froydnj Date: Mon, 26 Apr 2010 18:21:17 +0000 Subject: * cfgloop.h (struct loop): Move can_be_parallel field up. * ipa-prop.h (struct ip_node_params): Move bitfields up. * tree-ssa-loop-ivopts.c (struct version_info): Move inv_id field down. (struct iv_cand): Convert pos field into a bitfield. * tree-vectorizer.h (struct _loop_vec_info): Move loop_line_number field up. (struct _stmt_vec_info): Shuffle fields for better packing. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158743 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index a7a9e253850..a64950ec85c 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -120,8 +120,8 @@ struct version_info struct iv *iv; /* Induction variable description. */ bool has_nonlin_use; /* For a loop-level invariant, whether it is used in an expression that is not an induction variable. */ - unsigned inv_id; /* Id of an invariant. */ bool preserve_biv; /* For the original biv, whether to preserve it. */ + unsigned inv_id; /* Id of an invariant. */ }; /* Types of uses. */ @@ -192,7 +192,7 @@ struct iv_cand unsigned id; /* The number of the candidate. */ bool important; /* Whether this is an "important" candidate, i.e. such that it should be considered by all uses. */ - enum iv_position pos; /* Where it is computed. */ + ENUM_BITFIELD(iv_position) pos : 8; /* Where it is computed. */ gimple incremented_at;/* For original biv, the statement where it is incremented. */ tree var_before; /* The variable used for it before increment. */ -- cgit v1.2.1 From 3f9da5596a39ec1c557502bf3f559aaeaf48fc0d Mon Sep 17 00:00:00 2001 From: steven Date: Fri, 30 Apr 2010 11:58:49 +0000 Subject: gcc/ChangeLog: * toplev.c: Include varray.h for statistics dumping. * tree.h: Do not declare varray_head_tag. * tree-into-ssa.c, tree-ssa-uninit.c, tree-phinodes.c, omega.c, regs.h, lto-cgraph.c, tree-ssa-loop-ivopts.c, tree-nomudflap.c, c-objc-common.c, lto-streamer-out.c, tree-ssa-propagate.c, gimple-low.c, c-semantics.c, dwarf2out.c, lto-streamer-in.c, lto-section-in.c, alias.c, tree-if-conv.c, gimplify.c, ggc-zone.c, tree-ssa.c, tree-ssa-loop-prefetch.c, integrate.h, c-gimplify.c, c-common.c, c-common.h, reg-stack.c, basic-block.h, tree-ssa-structalias.c, lto-section-out.c, tree-ssanames.c: Do not include varray.h. * Makefile.in: Update for abovementioned changes. objc/ChangeLog: * objc-act.c: Do not include varray.h. objcp/ChangeLog: * objcp-decl.c: Do not include varray.h. cp/ChangeLog: * optimize.c, parser.c,mangle.c, cp-tree.h: DO not include varray.h. * Make-lang.in: Don't include varray.h dependency in CXX_TREE_H. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158933 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 1 - 1 file changed, 1 deletion(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index a64950ec85c..a1fdfa46254 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -77,7 +77,6 @@ along with GCC; see the file COPYING3. If not see #include "tree-dump.h" #include "timevar.h" #include "cfgloop.h" -#include "varray.h" #include "expr.h" #include "tree-pass.h" #include "ggc.h" -- cgit v1.2.1 From 9f5d6ac9c56ca8c00340a41b8fcdae7d8b670a8f Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Fri, 30 Apr 2010 21:10:53 +0000 Subject: * tree-ssa-loop-ivopts.c (may_be_unaligned_p): Check the alignment of the variable part of the offset as well. Use highest_pow2_factor for all alignment checks. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158948 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index a1fdfa46254..8662f4ce30d 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -1536,16 +1536,18 @@ may_be_unaligned_p (tree ref, tree step) if (mode != BLKmode) { - double_int mul; - tree al = build_int_cst (TREE_TYPE (step), - GET_MODE_ALIGNMENT (mode) / BITS_PER_UNIT); + unsigned mode_align = GET_MODE_ALIGNMENT (mode); - if (base_align < GET_MODE_ALIGNMENT (mode) - || bitpos % GET_MODE_ALIGNMENT (mode) != 0 - || bitpos % BITS_PER_UNIT != 0) + if (base_align < mode_align + || (bitpos % mode_align) != 0 + || (bitpos % BITS_PER_UNIT) != 0) return true; - if (!constant_multiple_of (step, al, &mul)) + if (toffset + && (highest_pow2_factor (toffset) * BITS_PER_UNIT) < mode_align) + return true; + + if ((highest_pow2_factor (step) * BITS_PER_UNIT) < mode_align) return true; } -- cgit v1.2.1 From a7a4626828090600459358ca745c4482cf9551a1 Mon Sep 17 00:00:00 2001 From: steven Date: Fri, 21 May 2010 13:53:22 +0000 Subject: gcc/ChangeLog: * tree.h: Include real.h and fixed-value.h as basic datatypes. * dfp.c, convert.c, reload1.c, reginfo.c, tree-flow.h, tree-ssa-threadedge.c, tree-ssanames.c, tree-loop-linear.c, tree-into-ssa.c, tree-vect-generic.c, tree-ssa-structalias.c, tree-ssa-loop-im.c, tree-dump.c, tree-complex.c, tree-ssa-uninit.c, genrecog.c, tree-ssa-threadupdate.c, tree-ssa-loop-niter.c, tree-pretty-print.c, tree-loop-distribution.c, tree-ssa-loop-unswitch.c, c-lex.c, optabs.c, postreload-gcse.c, tree-ssa-loop-manip.c, postreload.c, tree-ssa-loop-ch.c, tree-tailcall.c, tree.c, reload.c, tree-scalar-evolution.c, rtlanal.c, tree-phinodes.c, builtins.c, final.c, genoutput.c, fold-const.c, tree-ssa-dse.c, genautomata.c, tree-ssa-uncprop.c, toplev.c, tree-chrec.c, genemit.c, c-cppbuiltin.c, tree-ssa-sccvn.c, tree-ssa-ccp.c, tree-ssa-loop-ivopts.c, mode-switching.c, tree-call-cdce.c, cse.c, genpeep.c, tree-ssa-math-opts.c, tree-ssa-dom.c, tree-nrv.c, tree-ssa-propagate.c, tree-ssa-alias.c, tree-ssa-sink.c, jump.c, ifcvt.c, dwarf2out.c, expr.c, genattrtab.c, genconditions.c, tree-ssa-loop-ivcanon.c, tree-ssa-loop.c, tree-parloops.c, recog.c, tree-ssa-address.c, lcm.c, tree-eh.c, gimple-pretty-print.c, c-pretty-print.c, print-rtl.c, gcse.c, tree-if-conv.c, tree-data-ref.c, tree-affine.c, gimplify.c, tree-ssa-phiopt.c, implicit-zee.c, expmed.c, tree-dfa.c, emit-rtl.c, store-motion.c, cselib.c, tree-cfgcleanup.c, simplify-rtx.c, tree-ssa-pre.c, genpreds.c, tree-mudflap.c, print-tree.c, tree-ssa-copy.c, tree-ssa-forwprop.c, tree-ssa-dce.c, varasm.c, tree-nested.c, tree-ssa.c, tree-ssa-loop-prefetch.c, rtl.c, tree-inline.c, integrate.c, tree-optimize.c, tree-ssa-phiprop.c, fixed-value.c, combine.c, tree-profile.c, c-common.c, sched-vis.c, tree-cfg.c, passes.c, tree-ssa-reassoc.c, config/alpha/alpha.c, config/frv/frv.c, config/s390/s390.c, config/m32c/m32c.c, config/spu/spu.c, config/sparc/sparc.c, config/mep/mep.c, config/m32r/m32r.c, config/rx/rx.c, config/i386/i386.c, config/sh/sh.c, config/pdp11/pdp11.c, config/avr/avr.c, config/crx/crx.c, config/xtensa/xtensa.c, config/stormy16/stormy16.c, config/fr30/fr30.c, config/lm32/lm32.c, config/moxie/moxie.c, config/m68hc11/m68hc11.c, config/cris/cris.c, config/iq2000/iq2000.c, config/mn10300/mn10300.c, config/ia64/ia64.c, config/m68k/m68k.c, config/rs6000/rs6000.c, config/picochip/picochip.c, config/darwin.c, config/arc/arc.c, config/mcore/mcore.c, config/score/score3.c, config/score/score7.c, config/score/score.c, config/arm/arm.c, config/pa/pa.c, config/mips/mips.c, config/vax/vax.c, config/h8300/h8300.c, config/v850/v850.c, config/mmix/mmix.c, config/bfin/bfin.c: Clean up redundant includes. * Makefile.in: Update accordingly. java/ChangeLog: * typeck.c, decl.c, jcf-parse.c, except.c, expr.c: cp/Changelog: * error.c, tree.c, typeck2.c, cxx-pretty-print.c, mangle.c: Clean up redundant includes. fortran/ChangeLog: * trans-const.c, trans-types.c, trans-intrinsic.c: Clean up redundant includes. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159663 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 8662f4ce30d..80e219db34a 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -67,9 +67,7 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "tm.h" #include "tree.h" -#include "rtl.h" #include "tm_p.h" -#include "hard-reg-set.h" #include "basic-block.h" #include "output.h" #include "diagnostic.h" -- cgit v1.2.1 From ce084dfc1cd60d867d38dbed86a914d82fa908d1 Mon Sep 17 00:00:00 2001 From: jsm28 Date: Fri, 21 May 2010 22:34:26 +0000 Subject: * diagnostic.c: Don't include tm.h, tree.h, tm_p.h, langhooks.h or langhooks-def.h. (diagnostic_initialize): Initialize x_data not last_function. (diagnostic_report_current_function): Move to tree-diagnostic.c. (default_diagnostic_starter): Call diagnostic_report_current_module not diagnostic_report_current_function. (diagnostic_report_diagnostic): Initialize x_data not abstract_origin. (verbatim): Likewise. * diagnostic.h (struct diagnostic_info): Change abstract_origin to x_data. (struct diagnostic_context): Change last_function to x_data. (diagnostic_auxiliary_data): Replace with diagnostic_context_auxiliary_data and diagnostic_info_auxiliary_data. (diagnostic_last_function_changed, diagnostic_set_last_function, diagnostic_report_current_function): Move to tree-diagnostic.h. (print_declaration, dump_generic_node, print_generic_stmt, print_generic_stmt_indented, print_generic_expr, print_generic_decl, debug_c_tree, dump_omp_clauses, print_call_name, debug_generic_expr, debug_generic_stmt, debug_tree_chain, default_tree_printer): Move to tree-pretty-print.h. (debug_gimple_stmt, debug_gimple_seq, print_gimple_seq, print_gimple_stmt, print_gimple_expr, dump_gimple_stmt): Move to gimple-pretty-print.h. * pretty-print.c: Don't include tree.h (pp_base_format): Don't handle %K here. (pp_base_tree_identifier): Move to tree-pretty-print.c. * pretty-print.h (text_info): Change abstract_origin to x_data. (pp_tree_identifier, pp_unsupported_tree, pp_base_tree_identifier): Move to tree-pretty-print.h. * gimple-pretty-print.h, tree-diagnostic.c, tree-diagnostic.h, tree-pretty-print.h: New files. * tree-pretty-print.c: Include tree-pretty-print.h. (percent_K_format): New. Moved from pretty-print.c. (pp_base_tree_identifier): Move from pretty-print.c. * c-objc-common.c: Include tree-pretty-print.h. (c_tree_printer): Handle %K here. * langhooks.c: Include tree-diagnostic.h. (lhd_print_error_function): Use diagnostic_abstract_origin macro. * toplev.c: Include tree-diagnostic.h and tree-pretty-print.h. (default_tree_printer): Handle %K using percent_K_format. (general_init): Use default_tree_diagnostic_starter. * tree.c: Include tree-diagnostic.h and tree-pretty-print.h. (free_lang_data): Use default_tree_diagnostic_starter. * c-pretty-print.c: Include tree-pretty-print.h. * cfgexpand.c: Include tree-pretty-print.h and gimple-pretty-print.h. * cgraphunit.c: Include tree-pretty-print.h and gimple-pretty-print.h. * dwarf2out.c: Include tree-pretty-print.h. * except.c: Include tree-pretty-print.h. * gimple-pretty-print.c: Include tree-pretty-print.h and gimple-pretty-print.h. * gimplify.c: Include tree-pretty-print.h. * graphite-poly.c: Include tree-pretty-print.h and gimple-pretty-print.h. * ipa-cp.c: Include tree-pretty-print.h. * ipa-inline.c: Include gimple-pretty-print.h. * ipa-prop.c: Include tree-pretty-print.h and gimple-pretty-print.h. * ipa-pure-const.c: Include gimple-pretty-print.h. * ipa-struct-reorg.c: Include tree-pretty-print.h and gimple-pretty-print.h. * ipa-type-escape.c: Include tree-pretty-print.h. * print-rtl.c: Include tree-pretty-print.h. * print-tree.c: Include gimple-pretty-print.h. * sese.c: Include tree-pretty-print.h. * tree-affine.c: Include tree-pretty-print.h. * tree-browser.c: Include tree-pretty-print.h. * tree-call-cdce.c: Include gimple-pretty-print.h. * tree-cfg.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-chrec.c: Include tree-pretty-print.h. * tree-data-ref.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-dfa.c: Include tree-pretty-print.h. * tree-if-conv.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-inline.c: Include tree-pretty-print.h. * tree-into-ssa.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-nrv.c: Include tree-pretty-print.h. * tree-object-size.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-outof-ssa.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-parloops.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-predcom.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-scalar-evolution.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-sra.c: Include tree-pretty-print.h. * tree-ssa-address.c: Include tree-pretty-print.h. * tree-ssa-alias.c: Include tree-pretty-print.h. * tree-ssa-ccp.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-coalesce.c: Include tree-pretty-print.h. * tree-ssa-copy.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-copyrename.c: Include tree-pretty-print.h. * tree-ssa-dce.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-dom.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-dse.c: Include gimple-pretty-print.h. * tree-ssa-forwprop.c: Include tree-pretty-print.h. * tree-ssa-ifcombine.c: Include tree-pretty-print.h. * tree-ssa-live.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-loop-im.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-loop-ivcanon.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-loop-ivopts.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-loop-niter.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-loop-prefetch.c: Include tree-pretty-print.h. * tree-ssa-math-opts.c: Include gimple-pretty-print.h. * tree-ssa-operands.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-phiprop.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-pre.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-propagate.c: Include gimple-pretty-print.h. * tree-ssa-reassoc.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-sccvn.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-sink.c: Include gimple-pretty-print.h. * tree-ssa-ter.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-ssa-uninit.c: Include gimple-pretty-print.h. * tree-ssa.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-stdarg.c: Include gimple-pretty-print.h. * tree-switch-conversion.c: Include gimple-pretty-print.h. * tree-tailcall.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-vect-data-refs.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-vect-loop-manip.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-vect-loop.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-vect-patterns.c: Include gimple-pretty-print.h. * tree-vect-slp.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-vect-stmts.c: Include tree-pretty-print.h and gimple-pretty-print.h. * tree-vectorizer.c: Include tree-pretty-print.h. * tree-vrp.c: Include tree-pretty-print.h and gimple-pretty-print.h. * value-prof.c: Include tree-pretty-print.h and gimple-pretty-print.h. * var-tracking.c: Include tree-pretty-print.h. * Makefile.in (OBJS-common): Add tree-diagnostic.o. (tree-diagnostic.o): New dependencies. (c-objc-common.o, c-pretty-print.o, langhooks.o, tree.o, tree-inline.o, print-tree.o, stor-layout.o, tree-ssa-uninit.o, tree-ssa.o, tree-into-ssa.o, tree-ssa-ter.o, tree-ssa-coalesce.o, tree-outof-ssa.o, tree-ssa-forwprop.o, tree-ssa-phiprop.o, tree-ssa-ifcombine.o, tree-nrv.o, tree-ssa-copy.o, tree-ssa-propagate.o, tree-ssa-dom.o, tree-ssa-uncprop.o, tree-ssa-live.o, tree-ssa-copyrename.o, tree-ssa-pre.o, tree-ssa-sccvn.o, tree-vrp.o, tree-cfg.o, tree-tailcall.o, tree-ssa-sink.o, tree-if-conv.o, tree-dfa.o, tree-ssa-operands.o, tree-ssa-address.o, tree-ssa-loop-niter.o, tree-ssa-loop-ivcanon.o, tree-ssa-loop-prefetch.o, tree-predcom.o, tree-ssa-loop-ivopts.o, tree-affine.o, tree-ssa-loop-im.o, tree-ssa-math-opts.o, tree-ssa-alias.o, tree-ssa-reassoc.o, gimplify.o, tree-browser.o, tree-chrec.o, tree-scalar-evolution.o, tree-data-ref.o, sese.o, graphite-poly.o, tree-vect-loop.o, tree-vect-loop-manip.o, tree-vect-patterns.o, tree-vect-slp.o, tree-vect-stmts.o, tree-vect-data-refs.o, tree-vectorizer.o, tree-parloops.o, tree-stdarg.o, tree-object-size.o, gimple-pretty-print.o, tree-pretty-print.o, diagnostic.o, toplev.o, print-rtl.o, except.o, dwarf2out.o, cgraphunit.o, ipa-prop.o, ipa-cp.o, ipa-inline.o, ipa-pure-const.o, ipa-type-escape.o, ipa-struct-reorg.o, tree-ssa-dce.o, tree-call-cdce.o, tree-ssa-ccp.o, tree-sra.o, tree-switch-conversion.o, var-tracking.o, value-prof.o, cfgexpand.o, pretty-print.o): Update dependencies. cp: * error.c: Include tree-diagnostic.h and tree-pretty-print.h. (cp_print_error_function): Use diagnostic_abstract_origin macro. (cp_printer): Handle %K here using percent_K_format. * cxx-pretty-print.c: Include tree-pretty-print.h. * Make-lang.in (cp/error.o, cp/cxx-pretty-print.o): Update dependencies. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159685 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 80e219db34a..9592832f9b7 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -71,6 +71,8 @@ along with GCC; see the file COPYING3. If not see #include "basic-block.h" #include "output.h" #include "diagnostic.h" +#include "tree-pretty-print.h" +#include "gimple-pretty-print.h" #include "tree-flow.h" #include "tree-dump.h" #include "timevar.h" -- cgit v1.2.1 From 134c053efb725c8dfa8238c3329ea0439f96df09 Mon Sep 17 00:00:00 2001 From: spop Date: Fri, 28 May 2010 18:42:15 +0000 Subject: When niter may be zero, return a COND_EXPR with the may_be_zero condition. 2010-05-28 Sebastian Pop * tree-scalar-evolution.c (set_nb_iterations_in_loop): Inlined in the only place it was called from. (number_of_latch_executions): Do not return chrec_dont_know when the may_be_zero is a runtime condition: instead, return a COND_EXPR including the may_be_zero condition. * cfgloop.h (struct loop): Add a note on COND_EXPRs to the comment of nb_iterations. * tree-ssa-loop-ivopts.c (contains_abnormal_ssa_name_p): Handle COND_EXPRs. * gcc.dg/vect/vect-outer-fir-lb.c: Un-XFAIL-ed. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159992 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 9592832f9b7..bda640f3e0e 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -681,6 +681,11 @@ contains_abnormal_ssa_name_p (tree expr) idx_contains_abnormal_ssa_name_p, NULL); + if (code == COND_EXPR) + return contains_abnormal_ssa_name_p (TREE_OPERAND (expr, 0)) + || contains_abnormal_ssa_name_p (TREE_OPERAND (expr, 1)) + || contains_abnormal_ssa_name_p (TREE_OPERAND (expr, 2)); + switch (codeclass) { case tcc_binary: -- cgit v1.2.1 From 8e3cb73bc66100e137b20bcd98316bc415b6e53c Mon Sep 17 00:00:00 2001 From: steven Date: Tue, 1 Jun 2010 22:00:56 +0000 Subject: * gimplify.c: Do not include except.h and optabs.h. (gimplify_body): Do not initialize RTL profiling. * gimple-low.c: Do not include rtl.h, diagnostic.h, langhooks.h, langhooks-def.h, timevar.h, except.h, hashtab.h, and expr.h. * gimple-fold.c: Do not include rtl.h, tm_p.h, ggc.h, basic-block.h, output.h, expr.h, diagnostic.h, timevar.h, value-prof.h, and langhooks.h. * tree-pretty-print.h: Include pretty-print.h. * gimple-pretty-print.h: Include pretty-print.h. * tree-pretty-print.c: Do not include diagnostic.h. * tree-vrp.c: Likewise. * tree-tailcall.c: Likewise * tree-scalar-evolution.c: Likewise * tree-ssa-dse.c: Likewise * tree-chrec.c: Likewise * tree-ssa-sccvn.c: Likewise * tree-ssa-copyrename.c: Likewise * tree-nomudflap.c: Likewise * tree-call-cdce.c: Likewise * tree-stdarg.c: Likewise * tree-ssa-math-opts.c: Likewise * tree-nrv.c: Likewise * tree-ssa-sink.c: Likewise * tree-browser.c: Likewise * tree-ssa-loop-ivcanon.c: Likewise * tree-ssa-loop.c: Likewise * tree-parloops.c: Likewise * tree-ssa-address.c: Likewise * tree-ssa-ifcombine.c: Likewise * tree-if-conv.c: Likewise * tree-data-ref.c: Likewise * tree-affine.c: Likewise * tree-ssa-phiopt.c: Likewise * tree-ssa-coalesce.c: Likewise * tree-ssa-pre.c: Likewise * tree-ssa-live.c: Likewise * tree-predcom.c: Likewise * tree-ssa-forwprop.c: Likewise * tree-ssa-dce.c: Likewise * tree-ssa-ter.c: Likewise * tree-ssa-loop-prefetch.c: Likewise * tree-optimize.c: Likewise * tree-ssa-phiprop.c: Likewise * tree-object-size.c: Likewise * tree-outof-ssa.c: Likewise * tree-ssa-structalias.c: Likewise * tree-switch-conversion.c: Likewise * tree-ssa-reassoc.c: Likewise * tree-ssa-operands.c: Likewise * tree-vectorizer.c: Likewise * tree-vect-data-refs.c: Likewise * tree-vect-generic.c: Likewise * tree-vect-stmts.c: Likewise * tree-vect-patterns.c: Likewise * tree-vect-slp.c: Likewise * tree-vect-loop.c: Likewise * tree-ssa-loop-ivopts.c: Likewise * tree-ssa-loop-im.c: Likewise * tree-ssa-loop-niter.c: Likewise * tree-ssa-loop-unswitch.c: Likewise * tree-ssa-loop-manip.c: Likewise * tree-ssa-loop-ch.c: Likewise * tree-dump.c: Likewise * tree-complex.c: Likewise * tree-into-ssa.c: Do not include diagnostic.h and expr.h. * tree-ssa-uninit.c: Likewise * tree-ssa-threadupdate.c: Likewise * tree-ssa-uncprop.c: Likewise * tree-ssa-ccp.c: Likewise * tree-ssa-dom.c: Likewise * tree-ssa-propagate.c: Likewise * tree-ssa-alias.c: Likewise * tree-dfa.c: Likewise * tree-cfgcleanup.c: Likewise * tree-sra.c: Likewise * tree-ssa-copy.c: Likewise * tree-ssa.c: Likewise * tree-profile.c: Likewise * tree-cfg.c: Likewise * tree-ssa-threadedge.c: Likewise * tree-vect-loop-manip.c: Likewise * tree-inline.c: Do not include diagnostic.h and expr.h. Include rtl.h. (copy_decl_for_dup_finish): Do not use NULL_RTX. * tree-loop-linear.c: Do not include diagnostic.h, expr.h, and optabs.h. * tree-loop-distribution.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160125 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index bda640f3e0e..094e9cc8fe2 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -70,14 +70,12 @@ along with GCC; see the file COPYING3. If not see #include "tm_p.h" #include "basic-block.h" #include "output.h" -#include "diagnostic.h" #include "tree-pretty-print.h" #include "gimple-pretty-print.h" #include "tree-flow.h" #include "tree-dump.h" #include "timevar.h" #include "cfgloop.h" -#include "expr.h" #include "tree-pass.h" #include "ggc.h" #include "insn-config.h" @@ -92,6 +90,11 @@ along with GCC; see the file COPYING3. If not see #include "tree-affine.h" #include "target.h" +/* FIXME: Expressions are expanded to RTL in this pass to determine the + cost of different addressing modes. This should be moved to a TBD + interface between the GIMPLE and RTL worlds. */ +#include "expr.h" + /* The infinite cost. */ #define INFTY 10000000 -- cgit v1.2.1 From fe16669522c4f398ea86347bc38c649984ae8270 Mon Sep 17 00:00:00 2001 From: sandra Date: Wed, 9 Jun 2010 13:10:47 +0000 Subject: 2010-06-09 Sandra Loosemore gcc/ * tree-ssa-loop-ivopts.c (adjust_setup_cost): New function. (get_computation_cost_at): Use it. (determine_use_iv_cost_condition): Likewise. (determine_iv_cost): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160471 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 094e9cc8fe2..53ad252d2fc 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -2936,6 +2936,20 @@ get_computation (struct loop *loop, struct iv_use *use, struct iv_cand *cand) return get_computation_at (loop, use, cand, use->stmt); } +/* Adjust the cost COST for being in loop setup rather than loop body. + If we're optimizing for space, the loop setup overhead is constant; + if we're optimizing for speed, amortize it over the per-iteration cost. */ +static unsigned +adjust_setup_cost (struct ivopts_data *data, unsigned cost) +{ + if (cost == INFTY) + return cost; + else if (optimize_loop_for_speed_p (data->current_loop)) + return cost / AVG_LOOP_NITER (data->current_loop); + else + return cost; +} + /* Returns cost of addition in MODE. */ static unsigned @@ -3848,8 +3862,8 @@ get_computation_cost_at (struct ivopts_data *data, /* Symbol + offset should be compile-time computable so consider that they are added once to the variable, if present. */ if (var_present && (symbol_present || offset)) - cost.cost += add_cost (TYPE_MODE (ctype), speed) - / AVG_LOOP_NITER (data->current_loop); + cost.cost += adjust_setup_cost (data, + add_cost (TYPE_MODE (ctype), speed)); /* Having offset does not affect runtime cost in case it is added to symbol, but it increases complexity. */ @@ -4114,7 +4128,7 @@ determine_use_iv_cost_condition (struct ivopts_data *data, elim_cost = force_var_cost (data, bound, &depends_on_elim); /* The bound is a loop invariant, so it will be only computed once. */ - elim_cost.cost /= AVG_LOOP_NITER (data->current_loop); + elim_cost.cost = adjust_setup_cost (data, elim_cost.cost); } else elim_cost = infinite_cost; @@ -4361,7 +4375,7 @@ determine_iv_cost (struct ivopts_data *data, struct iv_cand *cand) cost_base = force_var_cost (data, base, NULL); cost_step = add_cost (TYPE_MODE (TREE_TYPE (base)), data->speed); - cost = cost_step + cost_base.cost / AVG_LOOP_NITER (current_loop); + cost = cost_step + adjust_setup_cost (data, cost_base.cost); /* Prefer the original ivs unless we may gain something by replacing it. The reason is to make debugging simpler; so this is not relevant for -- cgit v1.2.1 From abc7c8e9e2e1c3b8f432942809233cdc4b6fb98e Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Fri, 11 Jun 2010 21:53:59 +0000 Subject: * tree-ssa-loop-ivopts.c (get_computation_cost_at): Return again the computed cost. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160636 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 53ad252d2fc..32b89352653 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -3875,6 +3875,7 @@ get_computation_cost_at (struct ivopts_data *data, aratio = ratio > 0 ? ratio : -ratio; if (aratio != 1) cost.cost += multiply_by_cost (aratio, TYPE_MODE (ctype), speed); + return cost; fallback: if (can_autoinc) -- cgit v1.2.1 From 182cf5a9a415f31df0f9a10e46faed1221484a35 Mon Sep 17 00:00:00 2001 From: rguenth Date: Thu, 1 Jul 2010 08:49:19 +0000 Subject: 2010-07-01 Richard Guenther PR middle-end/42834 PR middle-end/44468 * doc/gimple.texi (is_gimple_mem_ref_addr): Document. * doc/generic.texi (References to storage): Document MEM_REF. * tree-pretty-print.c (dump_generic_node): Handle MEM_REF. (print_call_name): Likewise. * tree.c (recompute_tree_invariant_for_addr_expr): Handle MEM_REF. (build_simple_mem_ref_loc): New function. (mem_ref_offset): Likewise. * tree.h (build_simple_mem_ref_loc): Declare. (build_simple_mem_ref): Define. (mem_ref_offset): Declare. * fold-const.c: Include tree-flow.h. (operand_equal_p): Handle MEM_REF. (build_fold_addr_expr_with_type_loc): Likewise. (fold_comparison): Likewise. (fold_unary_loc): Fold VIEW_CONVERT_EXPR > to MEM_REF . (fold_binary_loc): Fold MEM[&MEM[p, CST1], CST2] to MEM[p, CST1 + CST2], fold MEM[&a.b, CST2] to MEM[&a, offsetof (a, b) + CST2]. * tree-ssa-alias.c (ptr_deref_may_alias_decl_p): Handle MEM_REF. (ptr_deref_may_alias_ref_p_1): Likewise. (ao_ref_base_alias_set): Properly differentiate base object for offset and TBAA. (ao_ref_init_from_ptr_and_size): Use MEM_REF. (indirect_ref_may_alias_decl_p): Handle MEM_REFs properly. (indirect_refs_may_alias_p): Likewise. (refs_may_alias_p_1): Likewise. Remove pointer SSA name def chasing code. (ref_maybe_used_by_call_p_1): Handle MEM_REF. (call_may_clobber_ref_p_1): Likewise. * dwarf2out.c (loc_list_from_tree): Handle MEM_REF. * expr.c (expand_assignment): Handle MEM_REF. (store_expr): Handle MEM_REFs from STRING_CSTs. (store_field): If expanding a MEM_REF of a non-addressable decl use bitfield operations. (get_inner_reference): Handle MEM_REF. (expand_expr_addr_expr_1): Likewise. (expand_expr_real_1): Likewise. * tree-eh.c (tree_could_trap_p): Handle MEM_REF. * alias.c (ao_ref_from_mem): Handle MEM_REF. (get_alias_set): Likewise. Properly handle VIEW_CONVERT_EXPRs. * tree-data-ref.c (dr_analyze_innermost): Handle MEM_REF. (dr_analyze_indices): Likewise. (dr_analyze_alias): Likewise. (object_address_invariant_in_loop_p): Likewise. * gimplify.c (mark_addressable): Handle MEM_REF. (gimplify_cond_expr): Build MEM_REFs. (gimplify_modify_expr_to_memcpy): Likewise. (gimplify_init_ctor_preeval_1): Handle MEM_REF. (gimple_fold_indirect_ref): Adjust. (gimplify_expr): Handle MEM_REF. Gimplify INDIRECT_REF to MEM_REF. * tree.def (MEM_REF): New tree code. * tree-dfa.c: Include toplev.h. (get_ref_base_and_extent): Handle MEM_REF. (get_addr_base_and_unit_offset): New function. * emit-rtl.c (set_mem_attributes_minus_bitpos): Handle MEM_REF. * gimple-fold.c (may_propagate_address_into_dereference): Handle MEM_REF. (maybe_fold_offset_to_array_ref): Allow possibly out-of bounds accesses if the array has just one dimension. Remove always true parameter. Do not require type compatibility here. (maybe_fold_offset_to_component_ref): Remove. (maybe_fold_stmt_indirect): Remove. (maybe_fold_reference): Remove INDIRECT_REF handling. Fold back to non-MEM_REF. (maybe_fold_offset_to_address): Simplify. Deal with type mismatches here. (maybe_fold_reference): Likewise. (maybe_fold_stmt_addition): Likewise. Also handle &ARRAY + I in addition to &ARRAY[0] + I. (fold_gimple_assign): Handle ADDR_EXPR of MEM_REFs. (gimple_get_relevant_ref_binfo): Handle MEM_REF. * cfgexpand.c (expand_debug_expr): Handle MEM_REF. * tree-ssa.c (useless_type_conversion_p): Make most pointer conversions useless. (warn_uninitialized_var): Handle MEM_REF. (maybe_rewrite_mem_ref_base): New function. (execute_update_addresses_taken): Implement re-writing of MEM_REFs to SSA form. * tree-inline.c (remap_gimple_op_r): Handle MEM_REF, remove INDIRECT_REF handling. (copy_tree_body_r): Handle MEM_REF. * gimple.c (is_gimple_addressable): Adjust. (is_gimple_address): Likewise. (is_gimple_invariant_address): ADDR_EXPRs of MEM_REFs with invariant base are invariant. (is_gimple_min_lval): Adjust. (is_gimple_mem_ref_addr): New function. (get_base_address): Handle MEM_REF. (count_ptr_derefs): Likewise. (get_base_loadstore): Likewise. * gimple.h (is_gimple_mem_ref_addr): Declare. (gimple_call_fndecl): Handle invariant MEM_REF addresses. * tree-cfg.c (verify_address): New function, split out from ... (verify_expr): ... here. Use for verifying ADDR_EXPRs and the address operand of MEM_REFs. Verify MEM_REFs. Reject INDIRECT_REFs. (verify_types_in_gimple_min_lval): Handle MEM_REF. Disallow INDIRECT_REF. Allow conversions. (verify_types_in_gimple_reference): Verify VIEW_CONVERT_EXPR of a register does not change its size. (verify_types_in_gimple_reference): Verify MEM_REF. (verify_gimple_assign_single): Disallow INDIRECT_REF. Handle MEM_REF. * tree-ssa-operands.c (opf_non_addressable, opf_not_non_addressable): New. (mark_address_taken): Handle MEM_REF. (get_indirect_ref_operands): Pass through opf_not_non_addressable. (get_asm_expr_operands): Pass opf_not_non_addressable. (get_expr_operands): Handle opf_[not_]non_addressable. Handle MEM_REF. Remove INDIRECT_REF handling. * tree-vrp.c: (check_array_ref): Handle MEM_REF. (search_for_addr_array): Likewise. (check_array_bounds): Likewise. (vrp_stmt_computes_nonzero): Adjust for MEM_REF. * tree-ssa-loop-im.c (for_each_index): Handle MEM_REF. (ref_always_accessed_p): Likewise. (gen_lsm_tmp_name): Likewise. Handle ADDR_EXPR. * tree-complex.c (extract_component): Do not handle INDIRECT_REF. Handle MEM_REF. * cgraphbuild.c (mark_load): Properly check for NULL result from get_base_address. (mark_store): Likewise. * tree-ssa-loop-niter.c (array_at_struct_end_p): Handle MEM_REF. * tree-loop-distribution.c (generate_builtin): Exchange INDIRECT_REF handling for MEM_REF. * tree-scalar-evolution.c (follow_ssa_edge_expr): Handle &MEM[ptr + CST] similar to POINTER_PLUS_EXPR. * builtins.c (stabilize_va_list_loc): Use the function ABI valist type if we couldn't canonicalize the argument type. Always dereference with the canonical va-list type. (maybe_emit_free_warning): Handle MEM_REF. (fold_builtin_memory_op): Simplify and handle MEM_REFs in folding memmove to memcpy. * builtins.c (fold_builtin_memory_op): Use ref-all types for all memcpy foldings. * omp-low.c (build_receiver_ref): Adjust for MEM_REF. (build_outer_var_ref): Likewise. (scan_omp_1_op): Likewise. (lower_rec_input_clauses): Likewise. (lower_lastprivate_clauses): Likewise. (lower_reduction_clauses): Likewise. (lower_copyprivate_clauses): Likewise. (expand_omp_atomic_pipeline): Likewise. (expand_omp_atomic_mutex): Likewise. (create_task_copyfn): Likewise. * tree-ssa-sccvn.c (copy_reference_ops_from_ref): Handle MEM_REF. Remove old union trick. Initialize constant offsets. (ao_ref_init_from_vn_reference): Likewise. Do not handle INDIRECT_REF. Init base_alias_set properly. (vn_reference_lookup_3): Replace INDIRECT_REF handling with MEM_REF. (vn_reference_fold_indirect): Adjust for MEM_REFs. (valueize_refs): Fold MEM_REFs. Re-evaluate constant offset for ARRAY_REFs. (may_insert): Remove. (visit_reference_op_load): Do not test may_insert. (run_scc_vn): Remove parameter, do not fiddle with may_insert. * tree-ssa-sccvn.h (struct vn_reference_op_struct): Add a field to store the constant offset this op applies. (run_scc_vn): Adjust prototype. * cgraphunit.c (thunk_adjust): Adjust for MEM_REF. * tree-ssa-ccp.c (ccp_fold): Replace INDIRECT_REF folding with MEM_REF. Propagate &foo + CST as &MEM[&foo, CST]. Do not bother about volatile qualifiers on pointers. (fold_const_aggregate_ref): Handle MEM_REF, do not handle INDIRECT_REF. * tree-ssa-loop-ivopts.c * tree-ssa-loop-ivopts.c (determine_base_object): Adjust for MEM_REF. (strip_offset_1): Likewise. (find_interesting_uses_address): Replace INDIRECT_REF handling with MEM_REF handling. (get_computation_cost_at): Likewise. * ipa-pure-const.c (check_op): Handle MEM_REF. * tree-stdarg.c (check_all_va_list_escapes): Adjust for MEM_REF. * tree-ssa-sink.c (is_hidden_global_store): Handle MEM_REF and constants. * ipa-inline.c (likely_eliminated_by_inlining_p): Handle MEM_REF. * tree-parloops.c (take_address_of): Adjust for MEM_REF. (eliminate_local_variables_1): Likewise. (create_call_for_reduction_1): Likewise. (create_loads_for_reductions): Likewise. (create_loads_and_stores_for_name): Likewise. * matrix-reorg.c (may_flatten_matrices_1): Sanitize. (ssa_accessed_in_tree): Handle MEM_REF. (ssa_accessed_in_assign_rhs): Likewise. (update_type_size): Likewise. (analyze_accesses_for_call_stmt): Likewise. (analyze_accesses_for_assign_stmt): Likewise. (transform_access_sites): Likewise. (transform_allocation_sites): Likewise. * tree-affine.c (tree_to_aff_combination): Handle MEM_REF. * tree-vect-data-refs.c (vect_create_addr_base_for_vector_ref): Do not handle INDIRECT_REF. * tree-ssa-phiopt.c (add_or_mark_expr): Handle MEM_REF. (cond_store_replacement): Likewise. * tree-ssa-pre.c (create_component_ref_by_pieces_1): Handle MEM_REF, no not handle INDIRECT_REFs. (insert_into_preds_of_block): Properly initialize avail. (phi_translate_1): Fold MEM_REFs. Re-evaluate constant offset for ARRAY_REFs. Properly handle reference lookups that require a bit re-interpretation. (can_PRE_operation): Do not handle INDIRECT_REF. Handle MEM_REF. * tree-sra.c * tree-sra.c (build_access_from_expr_1): Handle MEM_REF. (build_ref_for_offset_1): Remove. (build_ref_for_offset): Build MEM_REFs. (gate_intra_sra): Disable for now. (sra_ipa_modify_expr): Handle MEM_REF. (ipa_early_sra_gate): Disable for now. * tree-sra.c (create_access): Swap INDIRECT_REF handling for MEM_REF handling. (disqualify_base_of_expr): Likewise. (ptr_parm_has_direct_uses): Swap INDIRECT_REF handling for MEM_REF handling. (sra_ipa_modify_expr): Remove INDIRECT_REF handling. Use mem_ref_offset. Remove bogus folding. (build_access_from_expr_1): Properly handle MEM_REF for non IPA-SRA. (make_fancy_name_1): Add support for MEM_REF. * tree-predcom.c (ref_at_iteration): Handle MEM_REFs. * tree-mudflap.c (mf_xform_derefs_1): Adjust for MEM_REF. * ipa-prop.c (compute_complex_assign_jump_func): Handle MEM_REF. (compute_complex_ancestor_jump_func): Likewise. (ipa_analyze_virtual_call_uses): Likewise. * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Replace INDIRECT_REF folding with more generalized MEM_REF folding. (tree_ssa_forward_propagate_single_use_vars): Adjust accordingly. (forward_propagate_addr_into_variable_array_index): Also handle &ARRAY + I in addition to &ARRAY[0] + I. * tree-ssa-dce.c (ref_may_be_aliased): Handle MEM_REF. * tree-ssa-ter.c (find_replaceable_in_bb): Avoid TER if that creates assignments with overlap. * tree-nested.c (get_static_chain): Adjust for MEM_REF. (get_frame_field): Likewise. (get_nonlocal_debug_decl): Likewise. (convert_nonlocal_reference_op): Likewise. (struct nesting_info): Add mem_refs pointer-set. (create_nesting_tree): Allocate it. (convert_local_reference_op): Insert to be folded mem-refs. (fold_mem_refs): New function. (finalize_nesting_tree_1): Perform defered folding of mem-refs (free_nesting_tree): Free the pointer-set. * tree-vect-stmts.c (vectorizable_store): Adjust for MEM_REF. (vectorizable_load): Likewise. * tree-ssa-phiprop.c (phiprop_insert_phi): Adjust for MEM_REF. (propagate_with_phi): Likewise. * tree-object-size.c (addr_object_size): Handle MEM_REFs instead of INDIRECT_REFs. (compute_object_offset): Handle MEM_REF. (plus_stmt_object_size): Handle MEM_REF. (collect_object_sizes_for): Dispatch to plus_stmt_object_size for &MEM_REF. * tree-flow.h (get_addr_base_and_unit_offset): Declare. (symbol_marked_for_renaming): Likewise. * Makefile.in (tree-dfa.o): Add $(TOPLEV_H). (fold-const.o): Add $(TREE_FLOW_H). * tree-ssa-structalias.c (get_constraint_for_1): Handle MEM_REF. (find_func_clobbers): Likewise. * ipa-struct-reorg.c (decompose_indirect_ref_acc): Handle MEM_REF. (decompose_access): Likewise. (replace_field_acc): Likewise. (replace_field_access_stmt): Likewise. (insert_new_var_in_stmt): Likewise. (get_stmt_accesses): Likewise. (reorg_structs_drive): Disable. * config/i386/i386.c (ix86_va_start): Adjust for MEM_REF. (ix86_canonical_va_list_type): Likewise. cp/ * cp-gimplify.c (cp_gimplify_expr): Open-code the rhs predicate we are looking for, allow non-gimplified INDIRECT_REFs. testsuite/ * gcc.c-torture/execute/20100316-1.c: New testcase. * gcc.c-torture/execute/pr44468.c: Likewise. * gcc.c-torture/compile/20100609-1.c: Likewise. * gcc.dg/volatile2.c: Adjust. * gcc.dg/plugin/selfassign.c: Likewise. * gcc.dg/pr36902.c: Likewise. * gcc.dg/tree-ssa/foldaddr-2.c: Remove. * gcc.dg/tree-ssa/foldaddr-3.c: Likewise. * gcc.dg/tree-ssa/forwprop-8.c: Adjust. * gcc.dg/tree-ssa/pr17141-1.c: Likewise. * gcc.dg/tree-ssa/ssa-fre-13.c: Likewise. * gcc.dg/tree-ssa/ssa-fre-14.c: Likewise. * gcc.dg/tree-ssa/ssa-ccp-21.c: Likewise. * gcc.dg/tree-ssa/pta-ptrarith-1.c: Likewise. * gcc.dg/tree-ssa/20030807-7.c: Likewise. * gcc.dg/tree-ssa/forwprop-10.c: Likewise. * gcc.dg/tree-ssa/ssa-fre-1.c: Likewise. * gcc.dg/tree-ssa/pta-ptrarith-2.c: Likewise. * gcc.dg/tree-ssa/ssa-ccp-23.c: Likewise. * gcc.dg/tree-ssa/forwprop-1.c: Likewise. * gcc.dg/tree-ssa/forwprop-2.c: Likewise. * gcc.dg/tree-ssa/struct-aliasing-1.c: Likewise. * gcc.dg/tree-ssa/ssa-ccp-25.c: Likewise. * gcc.dg/tree-ssa/ssa-pre-26.c: Likewise. * gcc.dg/tree-ssa/struct-aliasing-2.c: Likewise. * gcc.dg/tree-ssa/ssa-ccp-26.c: Likewise. * gcc.dg/tree-ssa/ssa-sccvn-4.c: Likewise. * gcc.dg/tree-ssa/ssa-pre-7.c: Likewise. * gcc.dg/tree-ssa/forwprop-5.c: Likewise. * gcc.dg/struct/w_prof_two_strs.c: XFAIL. * gcc.dg/struct/wo_prof_escape_arg_to_local.c: Likewise. * gcc.dg/struct/wo_prof_global_var.c: Likewise. * gcc.dg/struct/wo_prof_malloc_size_var.c: Likewise. * gcc.dg/struct/w_prof_local_array.c: Likewise. * gcc.dg/struct/w_prof_single_str_global.c: Likewise. * gcc.dg/struct/wo_prof_escape_str_init.c: Likewise. * gcc.dg/struct/wo_prof_array_through_pointer.c: Likewise. * gcc.dg/struct/w_prof_global_array.c: Likewise. * gcc.dg/struct/wo_prof_array_field.c: Likewise. * gcc.dg/struct/wo_prof_single_str_local.c: Likewise. * gcc.dg/struct/w_prof_local_var.c: Likewise. * gcc.dg/struct/wo_prof_two_strs.c: Likewise. * gcc.dg/struct/wo_prof_empty_str.c: Likewise. * gcc.dg/struct/wo_prof_local_array.c: Likewise. * gcc.dg/struct/w_prof_global_var.c: Likewise. * gcc.dg/struct/wo_prof_single_str_global.c: Likewise. * gcc.dg/struct/wo_prof_escape_substr_value.c: Likewise. * gcc.dg/struct/wo_prof_global_array.c: Likewise. * gcc.dg/struct/wo_prof_escape_return.c: Likewise. * gcc.dg/struct/wo_prof_escape_substr_array.c: Likewise. * gcc.dg/struct/wo_prof_double_malloc.c: Likewise. * gcc.dg/struct/w_ratio_cold_str.c: Likewise. * gcc.dg/struct/wo_prof_escape_substr_pointer.c: Likewise. * gcc.dg/struct/wo_prof_local_var.c: Likewise. * gcc.dg/tree-prof/stringop-1.c: Adjust. * g++.dg/tree-ssa/pr31146.C: Likewise. * g++.dg/tree-ssa/copyprop-1.C: Likewise. * g++.dg/tree-ssa/pr33604.C: Likewise. * g++.dg/plugin/selfassign.c: Likewise. * gfortran.dg/array_memcpy_3.f90: Likewise. * gfortran.dg/array_memcpy_4.f90: Likewise. * c-c++-common/torture/pr42834.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161655 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 32b89352653..46356588c94 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -813,7 +813,7 @@ determine_base_object (tree expr) if (!base) return expr; - if (TREE_CODE (base) == INDIRECT_REF) + if (TREE_CODE (base) == MEM_REF) return determine_base_object (TREE_OPERAND (base, 0)); return fold_convert (ptr_type_node, @@ -1694,9 +1694,11 @@ find_interesting_uses_address (struct ivopts_data *data, gimple stmt, tree *op_p tree *ref = &TREE_OPERAND (base, 0); while (handled_component_p (*ref)) ref = &TREE_OPERAND (*ref, 0); - if (TREE_CODE (*ref) == INDIRECT_REF) + if (TREE_CODE (*ref) == MEM_REF) { - tree tem = gimple_fold_indirect_ref (TREE_OPERAND (*ref, 0)); + tree tem = fold_binary (MEM_REF, TREE_TYPE (*ref), + TREE_OPERAND (*ref, 0), + TREE_OPERAND (*ref, 1)); if (tem) *ref = tem; } @@ -2018,7 +2020,8 @@ strip_offset_1 (tree expr, bool inside_addr, bool top_compref, expr = build_fold_addr_expr (op0); return fold_convert (orig_type, expr); - case INDIRECT_REF: + case MEM_REF: + /* ??? Offset operand? */ inside_addr = false; break; @@ -3889,7 +3892,7 @@ fallback: return infinite_cost; if (address_p) - comp = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (comp)), comp); + comp = build_simple_mem_ref (comp); return new_cost (computation_cost (comp, speed), 0); } -- cgit v1.2.1 From e1c894dd585490f66a453b1e81366daba0db607c Mon Sep 17 00:00:00 2001 From: rguenth Date: Fri, 2 Jul 2010 13:25:23 +0000 Subject: 2010-07-02 Richard Guenther * tree-ssa-structalias.c (pt_solution_set_var): New function. * tree-ssa-alias.h (pt_solution_set_var): Declare. * tree-ssa-loop-ivopts.c (copy_ref_info): Also copy or create points-to information. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161716 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 46356588c94..02677fa9049 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -5549,6 +5549,27 @@ copy_ref_info (tree new_ref, tree old_ref) TMR_ORIGINAL (new_ref) = unshare_and_remove_ssa_names (old_ref); TREE_SIDE_EFFECTS (new_ref) = TREE_SIDE_EFFECTS (old_ref); TREE_THIS_VOLATILE (new_ref) = TREE_THIS_VOLATILE (old_ref); + /* We can transfer points-to information from an old pointer + or decl base to the new one. */ + if (TMR_BASE (new_ref) + && TREE_CODE (TMR_BASE (new_ref)) == SSA_NAME + && POINTER_TYPE_P (TREE_TYPE (TMR_BASE (new_ref))) + && !SSA_NAME_PTR_INFO (TMR_BASE (new_ref))) + { + tree base = get_base_address (old_ref); + if ((INDIRECT_REF_P (base) + || TREE_CODE (base) == MEM_REF) + && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME) + duplicate_ssa_name_ptr_info + (TMR_BASE (new_ref), SSA_NAME_PTR_INFO (TREE_OPERAND (base, 0))); + else if (TREE_CODE (base) == VAR_DECL + || TREE_CODE (base) == PARM_DECL + || TREE_CODE (base) == RESULT_DECL) + { + struct ptr_info_def *pi = get_ptr_info (TMR_BASE (new_ref)); + pt_solution_set_var (&pi->pt, base); + } + } } } -- cgit v1.2.1 From f544b9a4ff4531084b88e7ab7df1f191f8ff35e6 Mon Sep 17 00:00:00 2001 From: rguenth Date: Sun, 4 Jul 2010 16:08:21 +0000 Subject: 2010-07-04 Richard Guenther PR tree-optimization/44479 * tree-ssa-loop-ivopts.c (rewrite_use_nonlinear_expr): Avoid extra SSA name copy statements which preserves points-to information. * tree-vect-data-refs.c (vect_create_addr_base_for_vector_ref): Copy points-to information for all pointers. Properly handle MEM_REFs. (vect_create_data_ref_ptr): Likewise. Avoid extra SSA name copy statements. * Makefile.in (tree-ssa-loop-ivopts.o): Add tree-ssa-propagate.h dependency. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161802 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 02677fa9049..b7b26a329f2 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -89,6 +89,7 @@ along with GCC; see the file COPYING3. If not see #include "langhooks.h" #include "tree-affine.h" #include "target.h" +#include "tree-ssa-propagate.h" /* FIXME: Expressions are expanded to RTL in this pass to determine the cost of different addressing modes. This should be moved to a TBD @@ -5481,12 +5482,18 @@ rewrite_use_nonlinear_expr (struct ivopts_data *data, gcc_unreachable (); } - op = force_gimple_operand_gsi (&bsi, comp, false, SSA_NAME_VAR (tgt), - true, GSI_SAME_STMT); + if (!valid_gimple_rhs_p (comp) + || (gimple_code (use->stmt) != GIMPLE_PHI + /* We can't allow re-allocating the stmt as it might be pointed + to still. */ + && (get_gimple_rhs_num_ops (TREE_CODE (comp)) + >= gimple_num_ops (gsi_stmt (bsi))))) + comp = force_gimple_operand_gsi (&bsi, comp, false, SSA_NAME_VAR (tgt), + true, GSI_SAME_STMT); if (gimple_code (use->stmt) == GIMPLE_PHI) { - ass = gimple_build_assign (tgt, op); + ass = gimple_build_assign (tgt, comp); gsi_insert_before (&bsi, ass, GSI_SAME_STMT); bsi = gsi_for_stmt (use->stmt); @@ -5494,7 +5501,7 @@ rewrite_use_nonlinear_expr (struct ivopts_data *data, } else { - gimple_assign_set_rhs_from_tree (&bsi, op); + gimple_assign_set_rhs_from_tree (&bsi, comp); use->stmt = gsi_stmt (bsi); } } -- cgit v1.2.1 From 86638c2ef3b5ed40e2c8f19e5ce0cdbf86593413 Mon Sep 17 00:00:00 2001 From: rguenth Date: Mon, 5 Jul 2010 12:25:20 +0000 Subject: 2010-07-05 Richard Guenther * tree-ssa-loop-im.c (for_each_index): Do not handle ALIGN_INDIRECT_REF. (gen_lsm_tmp_name): Likewise. * tree-dump.c (dequeue_and_dump): Likewise. * tree-pretty-print.c (dump_generic_node): Likewise. (op_code_prio): Likewise. (op_symbol_code): Likewise. * tree.c (staticp): Likewise. (build1_stat): Likewise. * tree.h (INDIRECT_REF_P): Likewise. * fold-const.c (maybe_lvalue_p): Likewise. (operand_equal_p): Likewise. * tree-ssa-sccvn.c (copy_reference_ops_from_ref): Likewise. (ao_ref_init_from_vn_reference): Likewise. * tree-ssa-loop-ivopts.c (idx_find_step): Likewise. (find_interesting_uses_address): Likewise. * dwarf2out.c (loc_list_from_tree): Likewise. * gimplify.c (gimplify_expr): Likewise. * tree-eh.c (tree_could_trap_p): Likewise. * emit-rtl.c (set_mem_attributes_minus_bitpos): Likewise. * cfgexpand.c (expand_debug_expr): Likewise. * tree-ssa-pre.c (create_component_ref_by_pieces_1): Likewise. * tree-ssa-loop-prefetch.c (idx_analyze_ref): Likewise. * tree-cfg.c (verify_types_in_gimple_min_lval): Likewise. * config/rs6000/rs6000 (rs6000_check_sdmode): Likewise. * tree-ssa-operands.c (get_expr_operands): Likewise. * expr.c (safe_from_p): Likewise. (expand_expr_real_1): Likewise. TER BIT_AND_EXPRs into MEM_REFs. * tree-vect-data-refs.c (vect_setup_realignment): Build BIT_AND_EXPR and MEM_REF instead of ALIGN_INDIRECT_REF. * tree-vect-stmts.c (vectorizable_load): Likewise. * tree.def (ALIGN_INDIRECT_REF): Remove. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161830 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index b7b26a329f2..740db68fee0 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -1360,8 +1360,7 @@ idx_find_step (tree base, tree *idx, void *data) tree step, iv_base, iv_step, lbound, off; struct loop *loop = dta->ivopts_data->current_loop; - if (TREE_CODE (base) == MISALIGNED_INDIRECT_REF - || TREE_CODE (base) == ALIGN_INDIRECT_REF) + if (TREE_CODE (base) == MISALIGNED_INDIRECT_REF) return false; /* If base is a component ref, require that the offset of the reference @@ -1673,7 +1672,6 @@ find_interesting_uses_address (struct ivopts_data *data, gimple stmt, tree *op_p goto fail; step = ifs_ivopts_data.step; - gcc_assert (TREE_CODE (base) != ALIGN_INDIRECT_REF); gcc_assert (TREE_CODE (base) != MISALIGNED_INDIRECT_REF); /* Check that the base expression is addressable. This needs -- cgit v1.2.1 From 9614eeffe73081e7a1048f8e6dfd9cd2b80d607e Mon Sep 17 00:00:00 2001 From: rguenth Date: Mon, 5 Jul 2010 14:51:16 +0000 Subject: 2010-07-05 Richard Guenther * tree.c (reference_alias_ptr_type): New function. * tree.h (reference_alias_ptr_type): Declare. * tree-ssa-loop-ivopts.c (copy_ref_info): Restructure to allow non-TARGET_MEM_REF new refs. (rewrite_use_address): Pass old alias pointer type to create_mem_ref. * tree-ssa-address.c (create_mem_ref_raw): Get alias pointer type. Build a MEM_REF instead of a TARGET_MEM_REF if possible. (create_mem_ref): Get alias pointer type. Adjust calls to create_mem_ref_raw. (maybe_fold_tmr): Likewise. * tree-flow.h (create_mem_ref): Adjust prototype. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161840 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 65 ++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 28 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 740db68fee0..db56b93470b 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -5547,33 +5547,41 @@ unshare_and_remove_ssa_names (tree ref) static void copy_ref_info (tree new_ref, tree old_ref) { - if (TREE_CODE (old_ref) == TARGET_MEM_REF) - copy_mem_ref_info (new_ref, old_ref); - else - { - TMR_ORIGINAL (new_ref) = unshare_and_remove_ssa_names (old_ref); - TREE_SIDE_EFFECTS (new_ref) = TREE_SIDE_EFFECTS (old_ref); - TREE_THIS_VOLATILE (new_ref) = TREE_THIS_VOLATILE (old_ref); - /* We can transfer points-to information from an old pointer - or decl base to the new one. */ - if (TMR_BASE (new_ref) - && TREE_CODE (TMR_BASE (new_ref)) == SSA_NAME - && POINTER_TYPE_P (TREE_TYPE (TMR_BASE (new_ref))) - && !SSA_NAME_PTR_INFO (TMR_BASE (new_ref))) + tree new_ptr_base = NULL_TREE; + + if (TREE_CODE (old_ref) == TARGET_MEM_REF + && TREE_CODE (new_ref) == TARGET_MEM_REF) + TMR_ORIGINAL (new_ref) = TMR_ORIGINAL (old_ref); + else if (TREE_CODE (new_ref) == TARGET_MEM_REF) + TMR_ORIGINAL (new_ref) = unshare_and_remove_ssa_names (old_ref); + + TREE_SIDE_EFFECTS (new_ref) = TREE_SIDE_EFFECTS (old_ref); + TREE_THIS_VOLATILE (new_ref) = TREE_THIS_VOLATILE (old_ref); + + if (TREE_CODE (new_ref) == TARGET_MEM_REF) + new_ptr_base = TMR_BASE (new_ref); + else if (TREE_CODE (new_ref) == MEM_REF) + new_ptr_base = TREE_OPERAND (new_ref, 0); + + /* We can transfer points-to information from an old pointer + or decl base to the new one. */ + if (new_ptr_base + && TREE_CODE (new_ptr_base) == SSA_NAME + && POINTER_TYPE_P (TREE_TYPE (new_ptr_base)) + && !SSA_NAME_PTR_INFO (new_ptr_base)) + { + tree base = get_base_address (old_ref); + if ((INDIRECT_REF_P (base) + || TREE_CODE (base) == MEM_REF) + && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME) + duplicate_ssa_name_ptr_info + (new_ptr_base, SSA_NAME_PTR_INFO (TREE_OPERAND (base, 0))); + else if (TREE_CODE (base) == VAR_DECL + || TREE_CODE (base) == PARM_DECL + || TREE_CODE (base) == RESULT_DECL) { - tree base = get_base_address (old_ref); - if ((INDIRECT_REF_P (base) - || TREE_CODE (base) == MEM_REF) - && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME) - duplicate_ssa_name_ptr_info - (TMR_BASE (new_ref), SSA_NAME_PTR_INFO (TREE_OPERAND (base, 0))); - else if (TREE_CODE (base) == VAR_DECL - || TREE_CODE (base) == PARM_DECL - || TREE_CODE (base) == RESULT_DECL) - { - struct ptr_info_def *pi = get_ptr_info (TMR_BASE (new_ref)); - pt_solution_set_var (&pi->pt, base); - } + struct ptr_info_def *pi = get_ptr_info (new_ptr_base); + pt_solution_set_var (&pi->pt, base); } } } @@ -5608,8 +5616,9 @@ rewrite_use_address (struct ivopts_data *data, if (cand->iv->base_object) base_hint = var_at_stmt (data->current_loop, cand, use->stmt); - ref = create_mem_ref (&bsi, TREE_TYPE (*use->op_p), &aff, base_hint, - data->speed); + ref = create_mem_ref (&bsi, TREE_TYPE (*use->op_p), + reference_alias_ptr_type (*use->op_p), + &aff, base_hint, data->speed); copy_ref_info (ref, *use->op_p); *use->op_p = ref; } -- cgit v1.2.1 From 8eb9cb0e65308833014935b086f017f444777b5c Mon Sep 17 00:00:00 2001 From: rguenth Date: Mon, 5 Jul 2010 16:06:56 +0000 Subject: 2010-07-05 Richard Guenther * tree-ssa-loop-ivopts.c (rewrite_use_nonlinear_expr): Copy alias info. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161841 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index db56b93470b..d9362e58fb0 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -5486,8 +5486,12 @@ rewrite_use_nonlinear_expr (struct ivopts_data *data, to still. */ && (get_gimple_rhs_num_ops (TREE_CODE (comp)) >= gimple_num_ops (gsi_stmt (bsi))))) - comp = force_gimple_operand_gsi (&bsi, comp, false, SSA_NAME_VAR (tgt), - true, GSI_SAME_STMT); + { + comp = force_gimple_operand_gsi (&bsi, comp, true, NULL_TREE, + true, GSI_SAME_STMT); + if (POINTER_TYPE_P (TREE_TYPE (tgt))) + duplicate_ssa_name_ptr_info (comp, SSA_NAME_PTR_INFO (tgt)); + } if (gimple_code (use->stmt) == GIMPLE_PHI) { -- cgit v1.2.1 From fdd153a126686fc1729b19b6a3285b94838d6ca9 Mon Sep 17 00:00:00 2001 From: sandra Date: Mon, 5 Jul 2010 17:40:57 +0000 Subject: 2010-07-05 Sandra Loosemore PR middle-end/42505 gcc/ * tree-ssa-loop-ivopts.c (determine_set_costs): Delete obsolete comments about cost model. (try_add_cand_for): Add second strategy for choosing initial set based on original IVs, controlled by ORIGINALP argument. (get_initial_solution): Add ORIGINALP argument. (find_optimal_iv_set_1): New function, split from find_optimal_iv_set. (find_optimal_iv_set): Try two different strategies for choosing the IV set, and return the one with lower cost. gcc/testsuite/ * gcc.target/arm/pr42505.c: New test case. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161844 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 92 +++++++++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 34 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index d9362e58fb0..c0a2194cfd0 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -4446,26 +4446,6 @@ determine_set_costs (struct ivopts_data *data) struct loop *loop = data->current_loop; bitmap_iterator bi; - /* We use the following model (definitely improvable, especially the - cost function -- TODO): - - We estimate the number of registers available (using MD data), name it A. - - We estimate the number of registers used by the loop, name it U. This - number is obtained as the number of loop phi nodes (not counting virtual - registers and bivs) + the number of variables from outside of the loop. - - We set a reserve R (free regs that are used for temporary computations, - etc.). For now the reserve is a constant 3. - - Let I be the number of induction variables. - - -- if U + I + R <= A, the cost is I * SMALL_COST (just not to encourage - make a lot of ivs without a reason). - -- if A - R < U + I <= A, the cost is I * PRES_COST - -- if U + I > A, the cost is I * PRES_COST and - number of uses * SPILL_COST * (U + I - A) / (U + I) is added. */ - if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "Global costs:\n"); @@ -5089,11 +5069,13 @@ iv_ca_prune (struct ivopts_data *data, struct iv_ca *ivs, } /* Tries to extend the sets IVS in the best possible way in order - to express the USE. */ + to express the USE. If ORIGINALP is true, prefer candidates from + the original set of IVs, otherwise favor important candidates not + based on any memory object. */ static bool try_add_cand_for (struct ivopts_data *data, struct iv_ca *ivs, - struct iv_use *use) + struct iv_use *use, bool originalp) { comp_cost best_cost, act_cost; unsigned i; @@ -5112,7 +5094,8 @@ try_add_cand_for (struct ivopts_data *data, struct iv_ca *ivs, iv_ca_set_no_cp (data, ivs, use); } - /* First try important candidates not based on any memory object. Only if + /* If ORIGINALP is true, try to find the original IV for the use. Otherwise + first try important candidates not based on any memory object. Only if this fails, try the specific ones. Rationale -- in loops with many variables the best choice often is to use just one generic biv. If we added here many ivs specific to the uses, the optimization algorithm later @@ -5124,7 +5107,10 @@ try_add_cand_for (struct ivopts_data *data, struct iv_ca *ivs, { cand = iv_cand (data, i); - if (cand->iv->base_object != NULL_TREE) + if (originalp && cand->pos !=IP_ORIGINAL) + continue; + + if (!originalp && cand->iv->base_object != NULL_TREE) continue; if (iv_ca_cand_used_p (ivs, cand)) @@ -5160,8 +5146,13 @@ try_add_cand_for (struct ivopts_data *data, struct iv_ca *ivs, continue; /* Already tried this. */ - if (cand->important && cand->iv->base_object == NULL_TREE) - continue; + if (cand->important) + { + if (originalp && cand->pos == IP_ORIGINAL) + continue; + if (!originalp && cand->iv->base_object == NULL_TREE) + continue; + } if (iv_ca_cand_used_p (ivs, cand)) continue; @@ -5195,13 +5186,13 @@ try_add_cand_for (struct ivopts_data *data, struct iv_ca *ivs, /* Finds an initial assignment of candidates to uses. */ static struct iv_ca * -get_initial_solution (struct ivopts_data *data) +get_initial_solution (struct ivopts_data *data, bool originalp) { struct iv_ca *ivs = iv_ca_new (data); unsigned i; for (i = 0; i < n_iv_uses (data); i++) - if (!try_add_cand_for (data, ivs, iv_use (data, i))) + if (!try_add_cand_for (data, ivs, iv_use (data, i), originalp)) { iv_ca_free (&ivs); return NULL; @@ -5273,14 +5264,12 @@ try_improve_iv_set (struct ivopts_data *data, struct iv_ca *ivs) solution and remove the unused ivs while this improves the cost. */ static struct iv_ca * -find_optimal_iv_set (struct ivopts_data *data) +find_optimal_iv_set_1 (struct ivopts_data *data, bool originalp) { - unsigned i; struct iv_ca *set; - struct iv_use *use; /* Get the initial solution. */ - set = get_initial_solution (data); + set = get_initial_solution (data, originalp); if (!set) { if (dump_file && (dump_flags & TDF_DETAILS)) @@ -5303,11 +5292,46 @@ find_optimal_iv_set (struct ivopts_data *data) } } + return set; +} + +static struct iv_ca * +find_optimal_iv_set (struct ivopts_data *data) +{ + unsigned i; + struct iv_ca *set, *origset; + struct iv_use *use; + comp_cost cost, origcost; + + /* Determine the cost based on a strategy that starts with original IVs, + and try again using a strategy that prefers candidates not based + on any IVs. */ + origset = find_optimal_iv_set_1 (data, true); + set = find_optimal_iv_set_1 (data, false); + + if (!origset && !set) + return NULL; + + origcost = origset ? iv_ca_cost (origset) : infinite_cost; + cost = set ? iv_ca_cost (set) : infinite_cost; + if (dump_file && (dump_flags & TDF_DETAILS)) { - comp_cost cost = iv_ca_cost (set); - fprintf (dump_file, "Final cost %d (complexity %d)\n\n", cost.cost, cost.complexity); + fprintf (dump_file, "Original cost %d (complexity %d)\n\n", + origcost.cost, origcost.complexity); + fprintf (dump_file, "Final cost %d (complexity %d)\n\n", + cost.cost, cost.complexity); + } + + /* Choose the one with the best cost. */ + if (compare_costs (origcost, cost) <= 0) + { + if (set) + iv_ca_free (&set); + set = origset; } + else if (origset) + iv_ca_free (&origset); for (i = 0; i < n_iv_uses (data); i++) { -- cgit v1.2.1 From a6b74a67c831c6d371d91dbbeda762fb01ff180c Mon Sep 17 00:00:00 2001 From: sandra Date: Sat, 10 Jul 2010 18:43:29 +0000 Subject: 2010-07-10 Sandra Loosemore PR middle-end/42505 gcc/ * tree-inline.c (estimate_num_insns): Refactor builtin complexity lookup code into.... * builtins.c (is_simple_builtin, is_inexpensive_builtin): ...these new functions. * tree.h (is_simple_builtin, is_inexpensive_builtin): Declare. * cfgloopanal.c (target_clobbered_regs): Define. (init_set_costs): Initialize target_clobbered_regs. (estimate_reg_pressure_cost): Add call_p argument. When true, adjust the number of available registers to exclude the call-clobbered registers. * cfgloop.h (target_clobbered_regs): Declare. (estimate_reg_pressure_cost): Adjust declaration. * tree-ssa-loop-ivopts.c (struct ivopts_data): Add body_includes_call. (ivopts_global_cost_for_size): Pass it to estimate_reg_pressure_cost. (determine_set_costs): Dump target_clobbered_regs. (loop_body_includes_call): New function. (tree_ssa_iv_optimize_loop): Use it to initialize new field. * loop-invariant.c (gain_for_invariant): Adjust arguments to pass call_p flag through. (best_gain_for_invariant): Likewise. (find_invariants_to_move): Likewise. (move_single_loop_invariants): Likewise, using already-computed has_call field. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162043 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index c0a2194cfd0..83ec13e4a76 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -260,6 +260,9 @@ struct ivopts_data /* Are we optimizing for speed? */ bool speed; + + /* Whether the loop body includes any function calls. */ + bool body_includes_call; }; /* An assignment of iv candidates to uses. */ @@ -4431,7 +4434,8 @@ ivopts_global_cost_for_size (struct ivopts_data *data, unsigned size) { /* We add size to the cost, so that we prefer eliminating ivs if possible. */ - return size + estimate_reg_pressure_cost (size, data->regs_used, data->speed); + return size + estimate_reg_pressure_cost (size, data->regs_used, data->speed, + data->body_includes_call); } /* For each size of the induction variable set determine the penalty. */ @@ -4450,6 +4454,7 @@ determine_set_costs (struct ivopts_data *data) { fprintf (dump_file, "Global costs:\n"); fprintf (dump_file, " target_avail_regs %d\n", target_avail_regs); + fprintf (dump_file, " target_clobbered_regs %d\n", target_clobbered_regs); fprintf (dump_file, " target_reg_cost %d\n", target_reg_cost[data->speed]); fprintf (dump_file, " target_spill_cost %d\n", target_spill_cost[data->speed]); } @@ -5859,6 +5864,25 @@ tree_ssa_iv_optimize_finalize (struct ivopts_data *data) VEC_free (iv_cand_p, heap, data->iv_candidates); } +/* Returns true if the loop body BODY includes any function calls. */ + +static bool +loop_body_includes_call (basic_block *body, unsigned num_nodes) +{ + gimple_stmt_iterator gsi; + unsigned i; + + for (i = 0; i < num_nodes; i++) + for (gsi = gsi_start_bb (body[i]); !gsi_end_p (gsi); gsi_next (&gsi)) + { + gimple stmt = gsi_stmt (gsi); + if (is_gimple_call (stmt) + && !is_inexpensive_builtin (gimple_call_fndecl (stmt))) + return true; + } + return false; +} + /* Optimizes the LOOP. Returns true if anything changed. */ static bool @@ -5890,6 +5914,7 @@ tree_ssa_iv_optimize_loop (struct ivopts_data *data, struct loop *loop) } body = get_loop_body (loop); + data->body_includes_call = loop_body_includes_call (body, loop->num_nodes); renumber_gimple_stmt_uids_in_blocks (body, loop->num_nodes); free (body); -- cgit v1.2.1 From 2512209b236017dc6514906a6f6cf624a490d680 Mon Sep 17 00:00:00 2001 From: aesok Date: Thu, 15 Jul 2010 18:47:23 +0000 Subject: * tree.h (enum tree_index): Add TI_INTEGER_THREE. (integer_three_node): Add. * tree.c (build_common_tree_nodes_2): Use integer_type_node insead of NULL_TREE in build_int_cst calls. Initialize the integer_three_node. * builtins.c (expand_builtin_prefetch): Use common tree nodes instead of call build_int_cst. * tree-ssa-sccvn.c (copy_reference_ops_from_ref): Ditto. * tree-ssa-loop-ivopts.c (idx_find_step): Ditto. (find_interesting_uses_address): Ditto. * tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): Ditto. * tree-eh.c (lower_eh_constructs_2): Ditto. * tree-vect-loop.c (get_initial_def_for_induction): Ditto. * c-typeck.c (really_start_incremental_init, push_init_level): Ditto. * expmed.c (expand_divmod): Ditto. * tree-mudflap.c (mx_register_decls): Ditto. * varasm.c (array_size_for_constructor): Ditto. * tree-ssa-loop-prefetch.c (issue_prefetch_ref): Ditto. * c-parser.c (c_parser_postfix_expression): Ditto. /cp * decl.c (integer_three_node): Remove. (cxx_init_decl_processing): Do not initialize the integer_three_node. * cp-tree.h (integer_three_node): Remove. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162230 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 83ec13e4a76..5f2c6ae0eb8 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -1418,7 +1418,7 @@ idx_find_step (tree base, tree *idx, void *data) } else /* The step for pointer arithmetics already is 1 byte. */ - step = build_int_cst (sizetype, 1); + step = size_one_node; iv_base = iv->base; iv_step = iv->step; @@ -1611,7 +1611,7 @@ may_be_nonaddressable_p (tree expr) static void find_interesting_uses_address (struct ivopts_data *data, gimple stmt, tree *op_p) { - tree base = *op_p, step = build_int_cst (sizetype, 0); + tree base = *op_p, step = size_zero_node; struct iv *civ; struct ifs_ivopts_data ifs_ivopts_data; @@ -1669,7 +1669,7 @@ find_interesting_uses_address (struct ivopts_data *data, gimple stmt, tree *op_p { ifs_ivopts_data.ivopts_data = data; ifs_ivopts_data.stmt = stmt; - ifs_ivopts_data.step = build_int_cst (sizetype, 0); + ifs_ivopts_data.step = size_zero_node; if (!for_each_index (&base, idx_find_step, &ifs_ivopts_data) || integer_zerop (ifs_ivopts_data.step)) goto fail; -- cgit v1.2.1 From da6851c2d3e97429d707fa13ba96a305e866cc03 Mon Sep 17 00:00:00 2001 From: rguenth Date: Fri, 23 Jul 2010 10:15:27 +0000 Subject: 2010-07-23 Richard Guenther PR tree-optimization/45037 * tree-ssa-loop-ivopts.c (copy_ref_info): Handle NULL base. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162451 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-ssa-loop-ivopts.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'gcc/tree-ssa-loop-ivopts.c') diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 5f2c6ae0eb8..c7d534b1f5f 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -5604,11 +5604,13 @@ copy_ref_info (tree new_ref, tree old_ref) && !SSA_NAME_PTR_INFO (new_ptr_base)) { tree base = get_base_address (old_ref); - if ((INDIRECT_REF_P (base) - || TREE_CODE (base) == MEM_REF) - && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME) + if (!base) + ; + else if ((INDIRECT_REF_P (base) + || TREE_CODE (base) == MEM_REF) + && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME) duplicate_ssa_name_ptr_info - (new_ptr_base, SSA_NAME_PTR_INFO (TREE_OPERAND (base, 0))); + (new_ptr_base, SSA_NAME_PTR_INFO (TREE_OPERAND (base, 0))); else if (TREE_CODE (base) == VAR_DECL || TREE_CODE (base) == PARM_DECL || TREE_CODE (base) == RESULT_DECL) -- cgit v1.2.1