sh.c (shift_insns_rtx, [...]): Truncate shift counts to avoid out-of-bounds array accesses.
2009-04-22 Paolo Bonzini <bonzini@gnu.org> * config/sh/sh.c (shift_insns_rtx, shiftcosts, gen_shifty_op, sh_dynamicalize_shift_p, shl_and_scr_length): Truncate shift counts to avoid out-of-bounds array accesses. From-SVN: r146553
This commit is contained in:
parent
baa48dfaed
commit
6c34a09213
@ -1,3 +1,9 @@
|
||||
2009-04-22 Paolo Bonzini <bonzini@gnu.org>
|
||||
|
||||
* config/sh/sh.c (shift_insns_rtx, shiftcosts, gen_shifty_op,
|
||||
sh_dynamicalize_shift_p, shl_and_scr_length): Truncate
|
||||
shift counts to avoid out-of-bounds array accesses.
|
||||
|
||||
2009-04-22 Paolo Bonzini <bonzini@gnu.org>
|
||||
|
||||
* config/sparc/sparc.h (POINTER_SIZE): Fix comment.
|
||||
|
@ -2247,7 +2247,7 @@ int
|
||||
shift_insns_rtx (rtx insn)
|
||||
{
|
||||
rtx set_src = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
|
||||
int shift_count = INTVAL (XEXP (set_src, 1));
|
||||
int shift_count = INTVAL (XEXP (set_src, 1)) & 31;
|
||||
enum rtx_code shift_code = GET_CODE (set_src);
|
||||
|
||||
switch (shift_code)
|
||||
@ -2286,9 +2286,10 @@ shiftcosts (rtx x)
|
||||
if (GET_CODE (XEXP (x, 1)) != CONST_INT)
|
||||
return SH_DYNAMIC_SHIFT_COST;
|
||||
|
||||
value = INTVAL (XEXP (x, 1));
|
||||
/* Otherwise, return the true cost in instructions. Cope with out of range
|
||||
shift counts more or less arbitrarily. */
|
||||
value = INTVAL (XEXP (x, 1)) & 31;
|
||||
|
||||
/* Otherwise, return the true cost in instructions. */
|
||||
if (GET_CODE (x) == ASHIFTRT)
|
||||
{
|
||||
int cost = ashiftrt_insns[value];
|
||||
@ -2637,7 +2638,7 @@ gen_shifty_op (int code, rtx *operands)
|
||||
int max, i;
|
||||
|
||||
/* Truncate the shift count in case it is out of bounds. */
|
||||
value = value & 0x1f;
|
||||
value = value & 31;
|
||||
|
||||
if (value == 31)
|
||||
{
|
||||
@ -2790,7 +2791,7 @@ expand_ashiftrt (rtx *operands)
|
||||
int
|
||||
sh_dynamicalize_shift_p (rtx count)
|
||||
{
|
||||
return shift_insns[INTVAL (count)] > 1 + SH_DYNAMIC_SHIFT_COST;
|
||||
return shift_insns[INTVAL (count) & 31] > 1 + SH_DYNAMIC_SHIFT_COST;
|
||||
}
|
||||
|
||||
/* Try to find a good way to implement the combiner pattern
|
||||
@ -2950,11 +2951,11 @@ int
|
||||
shl_and_scr_length (rtx insn)
|
||||
{
|
||||
rtx set_src = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
|
||||
int len = shift_insns[INTVAL (XEXP (set_src, 1))];
|
||||
int len = shift_insns[INTVAL (XEXP (set_src, 1)) & 31];
|
||||
rtx op = XEXP (set_src, 0);
|
||||
len += shift_insns[INTVAL (XEXP (op, 1))] + 1;
|
||||
len += shift_insns[INTVAL (XEXP (op, 1)) & 31] + 1;
|
||||
op = XEXP (XEXP (op, 0), 0);
|
||||
return len + shift_insns[INTVAL (XEXP (op, 1))];
|
||||
return len + shift_insns[INTVAL (XEXP (op, 1)) & 31];
|
||||
}
|
||||
|
||||
/* Generate rtl for instructions for which shl_and_kind advised a particular
|
||||
|
Loading…
Reference in New Issue
Block a user