re PR rtl-optimization/54919 (gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller)

gcc/
	PR rtl-optimization/54919
	* loop-unroll.c (struct var_to_expand): Remove accum_pos field.
	(analyze_insn_to_expand_var): Do not record accum_pos.
	(expand_var_during_unrolling): Use validate_replace_rtx_group to
	perform replacement of all references to SET_DEST (set) with the
	new register, including references in REG_EQUAL notes.
	(insert_var_expansion_initialization): Insert initializatio insns
	at the bottom of the pre-header of the loop.

testsuite/
	PR rtl-optimization/54919
	* gcc.dg/pr54919.c: New testcase.

From-SVN: r192439
This commit is contained in:
Steven Bosscher 2012-10-14 19:29:18 +00:00
parent b5afa20284
commit 6e74642b2c
4 changed files with 47 additions and 15 deletions

View File

@ -1,3 +1,14 @@
2012-10-14 Steven Bosscher <steven@gcc.gnu.org>
PR rtl-optimization/54919
* loop-unroll.c (struct var_to_expand): Remove accum_pos field.
(analyze_insn_to_expand_var): Do not record accum_pos.
(expand_var_during_unrolling): Use validate_replace_rtx_group to
perform replacement of all references to SET_DEST (set) with the
new register, including references in REG_EQUAL notes.
(insert_var_expansion_initialization): Insert initializatio insns
at the bottom of the pre-header of the loop.
2012-10-14 Jan Hubicka <jh@suse.cz> 2012-10-14 Jan Hubicka <jh@suse.cz>
* tree-ssa-loop-niter.c (estimate_numbers_of_iterations_loop): Do not * tree-ssa-loop-niter.c (estimate_numbers_of_iterations_loop): Do not
@ -19034,7 +19045,7 @@
2012-04-26 Bernd Schmidt <bernds@codesourcery.com> 2012-04-26 Bernd Schmidt <bernds@codesourcery.com>
* PR middle-end/52997 PR middle-end/52997
* ira.c (find_moveable_pseudos): Call resize_reg_info. * ira.c (find_moveable_pseudos): Call resize_reg_info.
PR middle-end/52940 PR middle-end/52940

View File

@ -100,10 +100,6 @@ struct var_to_expand
the accumulator. If REUSE_EXPANSION is 0 reuse the accumulator. If REUSE_EXPANSION is 0 reuse
the original accumulator. Else use the original accumulator. Else use
var_expansions[REUSE_EXPANSION - 1]. */ var_expansions[REUSE_EXPANSION - 1]. */
unsigned accum_pos; /* The position in which the accumulator is placed in
the insn src. For example in x = x + something
accum_pos is 0 while in x = something + x accum_pos
is 1. */
}; };
/* Information about optimization applied in /* Information about optimization applied in
@ -1763,7 +1759,6 @@ analyze_insn_to_expand_var (struct loop *loop, rtx insn)
ves->op = GET_CODE (src); ves->op = GET_CODE (src);
ves->expansion_count = 0; ves->expansion_count = 0;
ves->reuse_expansion = 0; ves->reuse_expansion = 0;
ves->accum_pos = accum_pos;
return ves; return ves;
} }
@ -2123,9 +2118,7 @@ expand_var_during_unrolling (struct var_to_expand *ve, rtx insn)
else else
new_reg = get_expansion (ve); new_reg = get_expansion (ve);
validate_change (insn, &SET_DEST (set), new_reg, 1); validate_replace_rtx_group (SET_DEST (set), new_reg, insn);
validate_change (insn, &XEXP (SET_SRC (set), ve->accum_pos), new_reg, 1);
if (apply_change_group ()) if (apply_change_group ())
if (really_new_expansion) if (really_new_expansion)
{ {
@ -2165,7 +2158,7 @@ static void
insert_var_expansion_initialization (struct var_to_expand *ve, insert_var_expansion_initialization (struct var_to_expand *ve,
basic_block place) basic_block place)
{ {
rtx seq, var, zero_init, insn; rtx seq, var, zero_init;
unsigned i; unsigned i;
enum machine_mode mode = GET_MODE (ve->reg); enum machine_mode mode = GET_MODE (ve->reg);
bool honor_signed_zero_p = HONOR_SIGNED_ZEROS (mode); bool honor_signed_zero_p = HONOR_SIGNED_ZEROS (mode);
@ -2205,11 +2198,7 @@ insert_var_expansion_initialization (struct var_to_expand *ve,
seq = get_insns (); seq = get_insns ();
end_sequence (); end_sequence ();
insn = BB_HEAD (place); emit_insn_after (seq, BB_END (place));
while (!NOTE_INSN_BASIC_BLOCK_P (insn))
insn = NEXT_INSN (insn);
emit_insn_after (seq, insn);
} }
/* Combine the variable expansions at the loop exit. PLACE is the /* Combine the variable expansions at the loop exit. PLACE is the

View File

@ -1,3 +1,8 @@
2012-10-14 Steven Bosscher <steven@gcc.gnu.org>
PR rtl-optimization/54919
* gcc.dg/pr54919.c: New testcase.
2012-10-14 Paolo Carlini <paolo.carlini@oracle.com> 2012-10-14 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/53581 PR c++/53581

View File

@ -0,0 +1,27 @@
/* PR tree-optimization/54919 */
/* Testcase by Zdenek Sojka <zsojka@seznam.cz> */
/* { dg-do run } */
/* { dg-options "-O3 -ffast-math -funroll-loops -fvariable-expansion-in-unroller" } */
int a[10];
extern void abort(void) __attribute__((noreturn));
int __attribute__((__noinline__, __noclone__))
foo (void)
{
double d;
int i;
for (i = 0, d = 0; i < 64; i++)
d--;
return (int) d;
}
int
main (void)
{
if (foo () != -64)
abort ();
return 0;
}