aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Earnshaw <rearnsha@arm.com>2005-05-09 22:09:47 +0000
committerRichard Earnshaw <rearnsha@gcc.gnu.org>2005-05-09 22:09:47 +0000
commit4642ccb1d0dcd50c52850cd7a5f0d467735b9735 (patch)
treedbebfeb8fce7454ee0ce4ccd21a8182c2cca9eda /gcc
parent4a6ac6a5e6107c301a771ab2398ba3c3ae7ff946 (diff)
downloadgcc-4642ccb1d0dcd50c52850cd7a5f0d467735b9735.zip
gcc-4642ccb1d0dcd50c52850cd7a5f0d467735b9735.tar.gz
gcc-4642ccb1d0dcd50c52850cd7a5f0d467735b9735.tar.bz2
* arm.c (const_ok_for_arm): Use a faster algorithm.
From-SVN: r99476
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/config/arm/arm.c31
2 files changed, 22 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e78b8ae..4f0f859 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2005-05-09 Richard Earnshaw <richard.earnshaw@arm.com>
+
+ * arm.c (const_ok_for_arm): Use a faster algorithm.
+
2005-05-09 David Edelsohn <edelsohn@gnu.org>
PR target/21477
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 6b84d77..905187a 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -1531,8 +1531,8 @@ use_return_insn (int iscond, rtx sibling)
int
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
be all zero, or all one. */
if ((i & ~(unsigned HOST_WIDE_INT) 0xffffffff) != 0
@@ -1541,19 +1541,24 @@ const_ok_for_arm (HOST_WIDE_INT i)
& ~(unsigned HOST_WIDE_INT) 0xffffffff)))
return FALSE;
- /* Fast return for 0 and powers of 2 */
- if ((i & (i - 1)) == 0)
+ i &= (unsigned HOST_WIDE_INT) 0xffffffff;
+
+ /* 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;
- do
- {
- if ((i & mask & (unsigned HOST_WIDE_INT) 0xffffffff) == 0)
- return TRUE;
- mask =
- (mask << 2) | ((mask & (unsigned HOST_WIDE_INT) 0xffffffff)
- >> (32 - 2)) | ~(unsigned HOST_WIDE_INT) 0xffffffff;
- }
- while (mask != ~(unsigned HOST_WIDE_INT) 0xFF);
+ /* Get the number of trailing zeros, rounded down to the nearest even
+ number. */
+ lowbit = (ffs ((int) i) - 1) & ~1;
+
+ if ((i & ~(((unsigned HOST_WIDE_INT) 0xff) << lowbit)) == 0)
+ return TRUE;
+ else if (lowbit <= 4
+ && ((i & ~0xc000003f) == 0
+ || (i & ~0xf000000f) == 0
+ || (i & ~0xfc000003) == 0))
+ return TRUE;
return FALSE;
}