fix loop unrolling
Jan Hubicka
jh@suse.cz
Thu Jan 24 12:51:00 GMT 2002
> On Tue, Jan 22, 2002 at 12:04:34PM +0100, Jan Hubicka wrote:
> > It consists of addition of two thinks fetched directly from insn chain,
> > so they should be nonmemory_operand already.
> >
> > Would be that ok with adding copy_rtx everywhere?
>
> If we don't have memories, then we don't need copy_rtx anywhere.
OK, I see that the final_value comes from rtx stream and we still can
theoretically have memories if something nasty happends to prevent invariant
code motion from being active - it has cost scheme to prevent action in some
cases.
Is this variant OK?
Thu Jan 24 21:33:40 CET 2002 Jan Hubicka <jh@suse.cz>
* unroll.c (unroll_loop): Lower final_value to nonmemory operand;
avoid it's copies.
*** /home/hubicka/egcs2/egcs/gcc/unroll.c Tue Jan 15 00:58:20 2002
--- unroll.c Thu Jan 24 21:33:25 2002
*************** unroll_loop (loop, insn_count, strength_
*** 930,935 ****
--- 930,948 ----
start_sequence ();
+ /* Final value may have form of (PLUS val1 const1_rtx). We need
+ to convert it into general operand, so compute the real value. */
+
+ if (GET_CODE (final_value) == PLUS)
+ {
+ final_value = expand_simple_binop (mode, PLUS,
+ copy_rtx (XEXP (final_value, 0)),
+ copy_rtx (XEXP (final_value, 1)),
+ NULL_RTX, 0, OPTAB_LIB_WIDEN);
+ }
+ if (!nonmemory_operand (final_value, VOIDmode))
+ final_value = force_reg (mode, copy_rtx (final_value));
+
/* Calculate the difference between the final and initial values.
Final value may be a (plus (reg x) (const_int 1)) rtx.
Let the following cse pass simplify this if initial value is
*************** unroll_loop (loop, insn_count, strength_
*** 949,955 ****
so we can pretend that the overflow value is 0/~0. */
if (cc == NE || less_p != neg_inc)
! diff = expand_simple_binop (mode, MINUS, copy_rtx (final_value),
copy_rtx (initial_value), NULL_RTX, 0,
OPTAB_LIB_WIDEN);
else
--- 962,968 ----
so we can pretend that the overflow value is 0/~0. */
if (cc == NE || less_p != neg_inc)
! diff = expand_simple_binop (mode, MINUS, final_value,
copy_rtx (initial_value), NULL_RTX, 0,
OPTAB_LIB_WIDEN);
else
More information about the Gcc-patches
mailing list