Commit 4fc2e37d by Eric Botcazou Committed by Eric Botcazou

re PR rtl-optimization/54871 (gfortran.dg/vector_subscript_1.f90 FAILs)

	PR rtl-optimization/54871
	* loop-iv.c (simplify_using_initial_values): When scanning previous
	basic blocks, prune the recorded conditions if the current insn was
	not used to make a replacement.

	* loop-unroll.c (decide_unroll_constant_iterations): Clean up message.
	(unroll_loop_constant_iterations): Clarify head comment.
	(decide_unroll_runtime_iterations): Clean up message.
	(unroll_loop_runtime_iterations): Clarify head comment.
	(decide_peel_simple): Clean up message.
	(peel_loop_simple): Clarify head comment.
	(decide_unroll_stupid): Clean up message.
	(unroll_loop_stupid): Clarify head comment.

From-SVN: r192426
parent 258ef007
2012-10-13 Eric Botcazou <ebotcazou@adacore.com>
PR rtl-optimization/54871
* loop-iv.c (simplify_using_initial_values): When scanning previous
basic blocks, prune the recorded conditions if the current insn was
not used to make a replacement.
* loop-unroll.c (decide_unroll_constant_iterations): Clean up message.
(unroll_loop_constant_iterations): Clarify head comment.
(decide_unroll_runtime_iterations): Clean up message.
(unroll_loop_runtime_iterations): Clarify head comment.
(decide_peel_simple): Clean up message.
(peel_loop_simple): Clarify head comment.
(decide_unroll_stupid): Clean up message.
(unroll_loop_stupid): Clarify head comment.
2012-10-13 Andreas Schwab <schwab@linux-m68k.org> 2012-10-13 Andreas Schwab <schwab@linux-m68k.org>
PR gcov-profile/44728 PR gcov-profile/44728
...@@ -2004,11 +2004,30 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr) ...@@ -2004,11 +2004,30 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr)
} }
} }
else else
/* If we did not use this insn to make a replacement, any overlap {
between stores in this insn and our expression will cause the rtx *pnote, *pnote_next;
expression to become invalid. */
if (for_each_rtx (expr, altered_reg_used, this_altered)) /* If we did not use this insn to make a replacement, any overlap
goto out; between stores in this insn and our expression will cause the
expression to become invalid. */
if (for_each_rtx (expr, altered_reg_used, this_altered))
goto out;
/* Likewise for the conditions. */
for (pnote = &cond_list; *pnote; pnote = pnote_next)
{
rtx note = *pnote;
rtx old_cond = XEXP (note, 0);
pnote_next = &XEXP (note, 1);
if (for_each_rtx (&old_cond, altered_reg_used, this_altered))
{
*pnote = *pnote_next;
pnote_next = pnote;
free_EXPR_LIST_node (note);
}
}
}
if (CONSTANT_P (*expr)) if (CONSTANT_P (*expr))
goto out; goto out;
......
...@@ -602,26 +602,21 @@ decide_unroll_constant_iterations (struct loop *loop, int flags) ...@@ -602,26 +602,21 @@ decide_unroll_constant_iterations (struct loop *loop, int flags)
} }
} }
if (dump_file)
fprintf (dump_file, ";; max_unroll %d (%d copies, initial %d).\n",
best_unroll + 1, best_copies, nunroll);
loop->lpt_decision.decision = LPT_UNROLL_CONSTANT; loop->lpt_decision.decision = LPT_UNROLL_CONSTANT;
loop->lpt_decision.times = best_unroll; loop->lpt_decision.times = best_unroll;
if (dump_file) if (dump_file)
fprintf (dump_file, fprintf (dump_file, ";; Decided to unroll the loop %d times (%d copies).\n",
";; Decided to unroll the constant times rolling loop, %d times.\n", loop->lpt_decision.times, best_copies);
loop->lpt_decision.times);
} }
/* Unroll LOOP with constant number of iterations LOOP->LPT_DECISION.TIMES + 1 /* Unroll LOOP with constant number of iterations LOOP->LPT_DECISION.TIMES times.
times. The transformation does this: The transformation does this:
for (i = 0; i < 102; i++) for (i = 0; i < 102; i++)
body; body;
==> ==> (LOOP->LPT_DECISION.TIMES == 3)
i = 0; i = 0;
body; i++; body; i++;
...@@ -671,7 +666,7 @@ unroll_loop_constant_iterations (struct loop *loop) ...@@ -671,7 +666,7 @@ unroll_loop_constant_iterations (struct loop *loop)
of exit condition have continuous body after unrolling. */ of exit condition have continuous body after unrolling. */
if (dump_file) if (dump_file)
fprintf (dump_file, ";; Condition on beginning of loop.\n"); fprintf (dump_file, ";; Condition at beginning of loop.\n");
/* Peel exit_mod iterations. */ /* Peel exit_mod iterations. */
RESET_BIT (wont_exit, 0); RESET_BIT (wont_exit, 0);
...@@ -713,7 +708,7 @@ unroll_loop_constant_iterations (struct loop *loop) ...@@ -713,7 +708,7 @@ unroll_loop_constant_iterations (struct loop *loop)
the loop tests the condition at the end of loop body. */ the loop tests the condition at the end of loop body. */
if (dump_file) if (dump_file)
fprintf (dump_file, ";; Condition on end of loop.\n"); fprintf (dump_file, ";; Condition at end of loop.\n");
/* We know that niter >= max_unroll + 2; so we do not need to care of /* We know that niter >= max_unroll + 2; so we do not need to care of
case when we would exit before reaching the loop. So just peel case when we would exit before reaching the loop. So just peel
...@@ -896,9 +891,7 @@ decide_unroll_runtime_iterations (struct loop *loop, int flags) ...@@ -896,9 +891,7 @@ decide_unroll_runtime_iterations (struct loop *loop, int flags)
loop->lpt_decision.times = i - 1; loop->lpt_decision.times = i - 1;
if (dump_file) if (dump_file)
fprintf (dump_file, fprintf (dump_file, ";; Decided to unroll the loop %d times.\n",
";; Decided to unroll the runtime computable "
"times rolling loop, %d times.\n",
loop->lpt_decision.times); loop->lpt_decision.times);
} }
...@@ -949,14 +942,14 @@ split_edge_and_insert (edge e, rtx insns) ...@@ -949,14 +942,14 @@ split_edge_and_insert (edge e, rtx insns)
return bb; return bb;
} }
/* Unroll LOOP for that we are able to count number of iterations in runtime /* Unroll LOOP for which we are able to count number of iterations in runtime
LOOP->LPT_DECISION.TIMES + 1 times. The transformation does this (with some LOOP->LPT_DECISION.TIMES times. The transformation does this (with some
extra care for case n < 0): extra care for case n < 0):
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
body; body;
==> ==> (LOOP->LPT_DECISION.TIMES == 3)
i = 0; i = 0;
mod = n % 4; mod = n % 4;
...@@ -1314,20 +1307,23 @@ decide_peel_simple (struct loop *loop, int flags) ...@@ -1314,20 +1307,23 @@ decide_peel_simple (struct loop *loop, int flags)
loop->lpt_decision.times = npeel; loop->lpt_decision.times = npeel;
if (dump_file) if (dump_file)
fprintf (dump_file, ";; Decided to simply peel the loop, %d times.\n", fprintf (dump_file, ";; Decided to simply peel the loop %d times.\n",
loop->lpt_decision.times); loop->lpt_decision.times);
} }
/* Peel a LOOP LOOP->LPT_DECISION.TIMES times. The transformation: /* Peel a LOOP LOOP->LPT_DECISION.TIMES times. The transformation does this:
while (cond) while (cond)
body; body;
==> ==> (LOOP->LPT_DECISION.TIMES == 3)
if (!cond) goto end; if (!cond) goto end;
body; body;
if (!cond) goto end; if (!cond) goto end;
body; body;
if (!cond) goto end;
body;
while (cond) while (cond)
body; body;
end: ; end: ;
...@@ -1464,16 +1460,16 @@ decide_unroll_stupid (struct loop *loop, int flags) ...@@ -1464,16 +1460,16 @@ decide_unroll_stupid (struct loop *loop, int flags)
loop->lpt_decision.times = i - 1; loop->lpt_decision.times = i - 1;
if (dump_file) if (dump_file)
fprintf (dump_file, fprintf (dump_file, ";; Decided to unroll the loop stupidly %d times.\n",
";; Decided to unroll the loop stupidly, %d times.\n",
loop->lpt_decision.times); loop->lpt_decision.times);
} }
/* Unroll a LOOP LOOP->LPT_DECISION.TIMES times. The transformation: /* Unroll a LOOP LOOP->LPT_DECISION.TIMES times. The transformation does this:
while (cond) while (cond)
body; body;
==> ==> (LOOP->LPT_DECISION.TIMES == 3)
while (cond) while (cond)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment