diff options
Diffstat (limited to 'gcc/loop-invariant.c')
-rw-r--r-- | gcc/loop-invariant.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c index 40e70ba18c0..524727e9a37 100644 --- a/gcc/loop-invariant.c +++ b/gcc/loop-invariant.c @@ -668,6 +668,7 @@ create_new_invariant (struct def *def, rtx insn, bitmap depends_on, { struct invariant *inv = XNEW (struct invariant); rtx set = single_set (insn); + bool speed = optimize_bb_for_speed_p (BLOCK_FOR_INSN (insn)); inv->def = def; inv->always_executed = always_executed; @@ -676,9 +677,9 @@ create_new_invariant (struct def *def, rtx insn, bitmap depends_on, /* If the set is simple, usually by moving it we move the whole store out of the loop. Otherwise we save only cost of the computation. */ if (def) - inv->cost = rtx_cost (set, SET); + inv->cost = rtx_cost (set, SET, speed); else - inv->cost = rtx_cost (SET_SRC (set), SET); + inv->cost = rtx_cost (SET_SRC (set), SET, speed); inv->move = false; inv->reg = NULL_RTX; @@ -1048,15 +1049,15 @@ get_inv_cost (struct invariant *inv, int *comp_cost, unsigned *regs_needed) static int gain_for_invariant (struct invariant *inv, unsigned *regs_needed, - unsigned new_regs, unsigned regs_used) + unsigned new_regs, unsigned regs_used, bool speed) { int comp_cost, size_cost; get_inv_cost (inv, &comp_cost, regs_needed); actual_stamp++; - size_cost = (estimate_reg_pressure_cost (new_regs + *regs_needed, regs_used) - - estimate_reg_pressure_cost (new_regs, regs_used)); + size_cost = (estimate_reg_pressure_cost (new_regs + *regs_needed, regs_used, speed) + - estimate_reg_pressure_cost (new_regs, regs_used, speed)); return comp_cost - size_cost; } @@ -1069,7 +1070,7 @@ gain_for_invariant (struct invariant *inv, unsigned *regs_needed, static int best_gain_for_invariant (struct invariant **best, unsigned *regs_needed, - unsigned new_regs, unsigned regs_used) + unsigned new_regs, unsigned regs_used, bool speed) { struct invariant *inv; int gain = 0, again; @@ -1084,7 +1085,8 @@ best_gain_for_invariant (struct invariant **best, unsigned *regs_needed, if (inv->eqto != inv->invno) continue; - again = gain_for_invariant (inv, &aregs_needed, new_regs, regs_used); + again = gain_for_invariant (inv, &aregs_needed, new_regs, regs_used, + speed); if (again > gain) { gain = again; @@ -1123,7 +1125,7 @@ set_move_mark (unsigned invno) /* Determines which invariants to move. */ static void -find_invariants_to_move (void) +find_invariants_to_move (bool speed) { unsigned i, regs_used, regs_needed = 0, new_regs; struct invariant *inv = NULL; @@ -1147,7 +1149,7 @@ find_invariants_to_move (void) } new_regs = 0; - while (best_gain_for_invariant (&inv, ®s_needed, new_regs, regs_used) > 0) + while (best_gain_for_invariant (&inv, ®s_needed, new_regs, regs_used, speed) > 0) { set_move_mark (inv->invno); new_regs += regs_needed; @@ -1314,7 +1316,7 @@ move_single_loop_invariants (struct loop *loop) init_inv_motion_data (); find_invariants (loop); - find_invariants_to_move (); + find_invariants_to_move (optimize_loop_for_speed_p (loop)); move_invariants (loop); free_inv_motion_data (); |