diff options
author | Richard Guenther <rguenther@suse.de> | 2010-08-04 09:15:51 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2010-08-04 09:15:51 +0000 |
commit | 552cbe64b6e53a613e67e1aef1ecaed66bd71ed7 (patch) | |
tree | 048c888ac173b7ff5e353331c625f86b580387ee /gcc/double-int.c | |
parent | 31af83671c566af8a0c434d3bb1aabb58d7d7ac3 (diff) | |
download | gcc-552cbe64b6e53a613e67e1aef1ecaed66bd71ed7.tar.gz |
Makefile.in (double-int.o): Add $(TOPLEV_H) dependency.
2010-08-04 Richard Guenther <rguenther@suse.de>
* Makefile.in (double-int.o): Add $(TOPLEV_H) dependency.
* double-int.h (double_int_ctz): Declare.
* double-int.c (double_int_ctz): New function.
From-SVN: r162859
Diffstat (limited to 'gcc/double-int.c')
-rw-r--r-- | gcc/double-int.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/double-int.c b/gcc/double-int.c index 924e91b6c90..29e720b2919 100644 --- a/gcc/double-int.c +++ b/gcc/double-int.c @@ -22,6 +22,7 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "tm.h" #include "tree.h" +#include "toplev.h" /* We know that A1 + B1 = SUM1, using 2's complement arithmetic and ignoring overflow. Suppose A, B and SUM have the same respective signs as A1, B1, @@ -850,6 +851,26 @@ double_int_setbit (double_int a, unsigned bitpos) return a; } +/* Count trailing zeros in A. */ +int +double_int_ctz (double_int a) +{ + unsigned HOST_WIDE_INT w = a.low ? a.low : (unsigned HOST_WIDE_INT) a.high; + unsigned bits = a.low ? 0 : HOST_BITS_PER_WIDE_INT; + if (!w) + return HOST_BITS_PER_DOUBLE_INT; +#if (GCC_VERSION >= 3004) + bits += CTZ_HWI (w); +#else + while (!(w & 1)) + { + w >>= 1; + bits += 1; + } +#endif + return bits; +} + /* Shift A left by COUNT places keeping only PREC bits of result. Shift right if COUNT is negative. ARITH true specifies arithmetic shifting; otherwise use logical shift. */ |