This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Loop IV info patch 4
- To: gcc-patches at gcc dot gnu dot org
- Subject: Loop IV info patch 4
- From: Michael Hayes <mhayes at redhat dot com>
- Date: Sun, 31 Dec 2000 21:05:59 +1300 (NZDT)
This patch makes checking of array bounds for the regs array
consistent.
2000-12-29 Michael Hayes <mhayes@redhat.com>
* loop.c (check_insn_for_bivs): Use ivs->n_regs to check array bounds.
(find_mem_givs, record_biv, maybe_eliminate_biv): Likewise.
(record_initial): Likewise.
* unroll.c (copy_loop_body, loop_iterations): Likewise.
(remap_split_bivs): Likewise.
*** loop-11.c Fri Dec 29 21:39:15 2000
--- loop.c Fri Dec 29 21:57:09 2000
*************** check_insn_for_bivs (loop, p, not_every_
*** 4653,4659 ****
not_every_iteration, maybe_multiple);
REG_IV_TYPE (ivs, REGNO (dest_reg)) = BASIC_INDUCT;
}
! else if (REGNO (dest_reg) < max_reg_before_loop)
REG_IV_TYPE (ivs, REGNO (dest_reg)) = NOT_BASIC_INDUCT;
}
}
--- 4653,4659 ----
not_every_iteration, maybe_multiple);
REG_IV_TYPE (ivs, REGNO (dest_reg)) = BASIC_INDUCT;
}
! else if (REGNO (dest_reg) < ivs->n_regs)
REG_IV_TYPE (ivs, REGNO (dest_reg)) = NOT_BASIC_INDUCT;
}
}
*************** find_mem_givs (loop, x, insn, not_every_
*** 4871,4890 ****
maybe_multiple);
}
! /* Fill in the data about one BIV update.
! V is the `struct induction' in which we record the BIV. (It is
! allocated by the caller.)
INSN is the insn that sets it.
! DEST_REG is the BIV's reg.
! MULT_VAL is const1_rtx if the BIV is being incremented here, in which case
! INC_VAL is the increment. Otherwise, MULT_VAL is const0_rtx and the BIV is
being set to INC_VAL.
! NOT_EVERY_ITERATION is nonzero if this BIV update is not know to be
! executed every iteration; MAYBE_MULTIPLE is nonzero if this BIV update
can be executed more than once per iteration. If MAYBE_MULTIPLE
! and NOT_EVERY_ITERATION are both zero, we know that the BIV update is
executed exactly once per iteration. */
static void
--- 4871,4890 ----
maybe_multiple);
}
! /* Fill in the data about one biv update.
! V is the `struct induction' in which we record the biv. (It is
! allocated by the caller, with alloca.)
INSN is the insn that sets it.
! DEST_REG is the biv's reg.
! MULT_VAL is const1_rtx if the biv is being incremented here, in which case
! INC_VAL is the increment. Otherwise, MULT_VAL is const0_rtx and the biv is
being set to INC_VAL.
! NOT_EVERY_ITERATION is nonzero if this biv update is not know to be
! executed every iteration; MAYBE_MULTIPLE is nonzero if this biv update
can be executed more than once per iteration. If MAYBE_MULTIPLE
! and NOT_EVERY_ITERATION are both zero, we know that the biv update is
executed exactly once per iteration. */
static void
*************** record_biv (loop, v, insn, dest_reg, inc
*** 4979,4996 ****
}
}
! /* Fill in the data about one GIV.
! V is the `struct induction' in which we record the GIV. (It is
! allocated by the caller.)
INSN is the insn that sets it.
BENEFIT estimates the savings from deleting this insn.
! TYPE is DEST_REG or DEST_ADDR; it says whether the GIV is computed
into a register or is used as a memory address.
! SRC_REG is the BIV reg which the GIV is computed from.
! DEST_REG is the GIV's reg (if the GIV is stored in a reg).
! MULT_VAL and ADD_VAL are the coefficients used to compute the GIV.
! LOCATION points to the place where this GIV's value appears in INSN. */
static void
record_giv (loop, v, insn, src_reg, dest_reg, mult_val, add_val, ext_val,
--- 4979,4996 ----
}
}
! /* Fill in the data about one giv.
! V is the `struct induction' in which we record the giv. (It is
! allocated by the caller, with alloca.)
INSN is the insn that sets it.
BENEFIT estimates the savings from deleting this insn.
! TYPE is DEST_REG or DEST_ADDR; it says whether the giv is computed
into a register or is used as a memory address.
! SRC_REG is the biv reg which the giv is computed from.
! DEST_REG is the giv's reg (if the giv is stored in a reg).
! MULT_VAL and ADD_VAL are the coefficients used to compute the giv.
! LOCATION points to the place where this giv's value appears in INSN. */
static void
record_giv (loop, v, insn, src_reg, dest_reg, mult_val, add_val, ext_val,
*************** maybe_eliminate_biv (loop, bl, eliminate
*** 7845,7851 ****
{
unsigned int regno = REGNO (SET_DEST (set));
! if (regno < max_reg_before_loop
&& REG_IV_TYPE (ivs, regno) == GENERAL_INDUCT
&& REG_IV_INFO (ivs, regno)->src_reg == bl->biv->src_reg)
p = last;
--- 7845,7851 ----
{
unsigned int regno = REGNO (SET_DEST (set));
! if (regno < ivs->n_regs
&& REG_IV_TYPE (ivs, regno) == GENERAL_INDUCT
&& REG_IV_INFO (ivs, regno)->src_reg == bl->biv->src_reg)
p = last;
*************** record_initial (dest, set, data)
*** 8327,8333 ****
struct iv_class *bl;
if (GET_CODE (dest) != REG
! || REGNO (dest) >= max_reg_before_loop
|| REG_IV_TYPE (ivs, REGNO (dest)) != BASIC_INDUCT)
return;
--- 8327,8333 ----
struct iv_class *bl;
if (GET_CODE (dest) != REG
! || REGNO (dest) >= ivs->n_regs
|| REG_IV_TYPE (ivs, REGNO (dest)) != BASIC_INDUCT)
return;
*** unroll-11.c Thu Dec 28 18:55:11 2000
--- unroll.c Fri Dec 29 21:57:08 2000
*************** copy_loop_body (loop, copy_start, copy_e
*** 1912,1918 ****
for the BIV was stored in the BIV's first struct
induction entry by find_splittable_regs. */
! if (regno < max_reg_before_loop
&& REG_IV_TYPE (ivs, regno) == BASIC_INDUCT)
{
giv_src_reg = REG_IV_CLASS (ivs, regno)->biv->src_reg;
--- 1912,1918 ----
for the BIV was stored in the BIV's first struct
induction entry by find_splittable_regs. */
! if (regno < ivs->n_regs
&& REG_IV_TYPE (ivs, regno) == BASIC_INDUCT)
{
giv_src_reg = REG_IV_CLASS (ivs, regno)->biv->src_reg;
*************** loop_iterations (loop)
*** 3591,3600 ****
}
else if (REG_IV_TYPE (ivs, REGNO (iteration_var)) == BASIC_INDUCT)
{
! /* When reg_iv_type / reg_iv_info is resized for BIV increments
! that are turned into givs, reg_biv_class is not resized.
! So check here that we don't make an out-of-bounds access. */
! if (REGNO (iteration_var) >= max_reg_before_loop)
abort ();
/* Grab initial value, only useful if it is a constant. */
--- 3591,3597 ----
}
else if (REG_IV_TYPE (ivs, REGNO (iteration_var)) == BASIC_INDUCT)
{
! if (REGNO (iteration_var) >= ivs->n_regs)
abort ();
/* Grab initial value, only useful if it is a constant. */
*************** loop_iterations (loop)
*** 3609,3615 ****
struct induction *v = REG_IV_INFO (ivs, REGNO (iteration_var));
rtx biv_initial_value;
! if (REGNO (v->src_reg) >= max_reg_before_loop)
abort ();
bl = REG_IV_CLASS (ivs, REGNO (v->src_reg));
--- 3606,3612 ----
struct induction *v = REG_IV_INFO (ivs, REGNO (iteration_var));
rtx biv_initial_value;
! if (REGNO (v->src_reg) >= ivs->n_regs)
abort ();
bl = REG_IV_CLASS (ivs, REGNO (v->src_reg));
*************** remap_split_bivs (loop, x)
*** 4013,4019 ****
/* If non-reduced/final-value GIVs were split, then this would also
have to remap those GIVs also. */
#endif
! if (REGNO (x) < max_reg_before_loop
&& REG_IV_TYPE (ivs, REGNO (x)) == BASIC_INDUCT)
return REG_IV_CLASS (ivs, REGNO (x))->biv->src_reg;
break;
--- 4010,4016 ----
/* If non-reduced/final-value GIVs were split, then this would also
have to remap those GIVs also. */
#endif
! if (REGNO (x) < ivs->n_regs
&& REG_IV_TYPE (ivs, REGNO (x)) == BASIC_INDUCT)
return REG_IV_CLASS (ivs, REGNO (x))->biv->src_reg;
break;