Commit 0e9ff885 by David S. Miller Committed by Jeff Law

combine.c (force_to_mode, [...]): Correctly optimize constant offset…

combine.c (force_to_mode, [...]): Correctly optimize constant offset computations from objects with known...

        * combine.c (force_to_mode, nonzero_bits): Correctly optimize
        constant offset computations from objects with known alignment in
        the presence of STACK_BIAS.

From-SVN: r17405
parent aef28d1d
Sat Jan 17 23:41:36 1998 David S. Miller <davem@tanya.rutgers.edu> Sat Jan 17 23:41:36 1998 David S. Miller <davem@tanya.rutgers.edu>
* combine.c (force_to_mode, nonzero_bits): Correctly optimize
constant offset computations from objects with known alignment in
the presence of STACK_BIAS.
* varasm.c (immed_double_const): Add casts to HOST_WIDE_INT where * varasm.c (immed_double_const): Add casts to HOST_WIDE_INT where
necessary. necessary.
(const_hash): Hash val is unsigned long. (const_hash): Hash val is unsigned long.
......
...@@ -6253,13 +6253,33 @@ force_to_mode (x, mode, mask, reg, just_select) ...@@ -6253,13 +6253,33 @@ force_to_mode (x, mode, mask, reg, just_select)
smask |= (HOST_WIDE_INT) -1 << width; smask |= (HOST_WIDE_INT) -1 << width;
if (GET_CODE (XEXP (x, 1)) == CONST_INT if (GET_CODE (XEXP (x, 1)) == CONST_INT
&& exact_log2 (- smask) >= 0 && exact_log2 (- smask) >= 0)
&& (nonzero_bits (XEXP (x, 0), mode) & ~ mask) == 0 {
#ifdef STACK_BIAS
if (STACK_BIAS
&& (XEXP (x, 0) == stack_pointer_rtx
|| XEXP (x, 0) == frame_pointer_rtx))
{
int sp_alignment = STACK_BOUNDARY / BITS_PER_UNIT;
unsigned HOST_WIDE_INT sp_mask = GET_MODE_MASK (mode);
sp_mask &= ~ (sp_alignment - 1);
if ((sp_mask & ~ mask) == 0
&& ((INTVAL (XEXP (x, 1)) - STACK_BIAS) & ~ mask) != 0)
return force_to_mode (plus_constant (XEXP (x, 0),
((INTVAL (XEXP (x, 1)) -
STACK_BIAS) & mask)
+ STACK_BIAS),
mode, mask, reg, next_select);
}
#endif
if ((nonzero_bits (XEXP (x, 0), mode) & ~ mask) == 0
&& (INTVAL (XEXP (x, 1)) & ~ mask) != 0) && (INTVAL (XEXP (x, 1)) & ~ mask) != 0)
return force_to_mode (plus_constant (XEXP (x, 0), return force_to_mode (plus_constant (XEXP (x, 0),
INTVAL (XEXP (x, 1)) & mask), INTVAL (XEXP (x, 1)) & mask),
mode, mask, reg, next_select); mode, mask, reg, next_select);
} }
}
/* ... fall through ... */ /* ... fall through ... */
...@@ -7331,10 +7351,15 @@ nonzero_bits (x, mode) ...@@ -7331,10 +7351,15 @@ nonzero_bits (x, mode)
In particular, in the Irix6 n64 ABI, the stack has 128 bit In particular, in the Irix6 n64 ABI, the stack has 128 bit
alignment but the argument pointer has only 64 bit alignment. */ alignment but the argument pointer has only 64 bit alignment. */
if (x == stack_pointer_rtx || x == frame_pointer_rtx if ((x == frame_pointer_rtx
|| x == stack_pointer_rtx
|| x == hard_frame_pointer_rtx || x == hard_frame_pointer_rtx
|| (REGNO (x) >= FIRST_VIRTUAL_REGISTER || (REGNO (x) >= FIRST_VIRTUAL_REGISTER
&& REGNO (x) <= LAST_VIRTUAL_REGISTER)) && REGNO (x) <= LAST_VIRTUAL_REGISTER))
#ifdef STACK_BIAS
&& !STACK_BIAS
#endif
)
{ {
int sp_alignment = STACK_BOUNDARY / BITS_PER_UNIT; int sp_alignment = STACK_BOUNDARY / BITS_PER_UNIT;
...@@ -7515,6 +7540,22 @@ nonzero_bits (x, mode) ...@@ -7515,6 +7540,22 @@ nonzero_bits (x, mode)
switch (code) switch (code)
{ {
case PLUS: case PLUS:
#ifdef STACK_BIAS
if (STACK_BIAS
&& (XEXP (x, 0) == stack_pointer_rtx
|| XEXP (x, 0) == frame_pointer_rtx)
&& GET_CODE (XEXP (x, 1)) == CONST_INT)
{
int sp_alignment = STACK_BOUNDARY / BITS_PER_UNIT;
nz0 = (GET_MODE_MASK (mode) & ~ (sp_alignment - 1));
nz1 = INTVAL (XEXP (x, 1)) - STACK_BIAS;
width0 = floor_log2 (nz0) + 1;
width1 = floor_log2 (nz1) + 1;
low0 = floor_log2 (nz0 & -nz0);
low1 = floor_log2 (nz1 & -nz1);
}
#endif
result_width = MAX (width0, width1) + 1; result_width = MAX (width0, width1) + 1;
result_low = MIN (low0, low1); result_low = MIN (low0, low1);
break; break;
......
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