Commit 71a4f307 by Richard Earnshaw Committed by Richard Earnshaw

arm.c (arm_gen_constant): Add new heuristic for generating constant integers…

arm.c (arm_gen_constant): Add new heuristic for generating constant integers that can be expressed as the...

	* arm.c (arm_gen_constant): Add new heuristic for generating
	constant integers that can be expressed as the difference of two
	valid immediates.

From-SVN: r99472
parent 43f6dfd3
2005-05-09 Richard Earnshaw <richard.earnshaw@arm.com>
* arm.c (arm_gen_constant): Add new heuristic for generating
constant integers that can be expressed as the difference of two
valid immediates.
2005-05-09 Roger Sayle <roger@eyesopen.com> 2005-05-09 Roger Sayle <roger@eyesopen.com>
* c-tree.h (parser_build_unary_op): New prototype. * c-tree.h (parser_build_unary_op): New prototype.
......
...@@ -1531,8 +1531,8 @@ use_return_insn (int iscond, rtx sibling) ...@@ -1531,8 +1531,8 @@ use_return_insn (int iscond, rtx sibling)
int int
const_ok_for_arm (HOST_WIDE_INT i) const_ok_for_arm (HOST_WIDE_INT i)
{ {
unsigned HOST_WIDE_INT mask = ~(unsigned HOST_WIDE_INT)0xFF; int lowbit;
/* For machines with >32 bit HOST_WIDE_INT, the bits above bit 31 must /* For machines with >32 bit HOST_WIDE_INT, the bits above bit 31 must
be all zero, or all one. */ be all zero, or all one. */
if ((i & ~(unsigned HOST_WIDE_INT) 0xffffffff) != 0 if ((i & ~(unsigned HOST_WIDE_INT) 0xffffffff) != 0
...@@ -1541,19 +1541,24 @@ const_ok_for_arm (HOST_WIDE_INT i) ...@@ -1541,19 +1541,24 @@ const_ok_for_arm (HOST_WIDE_INT i)
& ~(unsigned HOST_WIDE_INT) 0xffffffff))) & ~(unsigned HOST_WIDE_INT) 0xffffffff)))
return FALSE; return FALSE;
/* Fast return for 0 and powers of 2 */ i &= (unsigned HOST_WIDE_INT) 0xffffffff;
if ((i & (i - 1)) == 0)
/* Fast return for 0 and small values. We must do this for zero, since
the code below can't handle that one case. */
if ((i & ~(unsigned HOST_WIDE_INT) 0xff) == 0)
return TRUE; return TRUE;
do /* Get the number of trailing zeros, rounded down to the nearest even
{ number. */
if ((i & mask & (unsigned HOST_WIDE_INT) 0xffffffff) == 0) lowbit = (ffs ((int) i) - 1) & ~1;
return TRUE;
mask = if ((i & ~(((unsigned HOST_WIDE_INT) 0xff) << lowbit)) == 0)
(mask << 2) | ((mask & (unsigned HOST_WIDE_INT) 0xffffffff) return TRUE;
>> (32 - 2)) | ~(unsigned HOST_WIDE_INT) 0xffffffff; else if (lowbit <= 4
} && ((i & ~0xc000003f) == 0
while (mask != ~(unsigned HOST_WIDE_INT) 0xFF); || (i & ~0xf000000f) == 0
|| (i & ~0xfc000003) == 0))
return TRUE;
return FALSE; return FALSE;
} }
......
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