summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-12-11 02:03:56 -0800
committerKaz Kylheku <kaz@kylheku.com>2011-12-11 02:03:56 -0800
commitdf456b691838fdbc1e8a7336f84c9e784fa358d5 (patch)
treec75815348cf0e111c1aa59bbf39b9bb5ec1a77ac
parentd49893bac4c0b842765bbf491720512048a1e13c (diff)
downloadtxr-df456b691838fdbc1e8a7336f84c9e784fa358d5.tar.gz
txr-df456b691838fdbc1e8a7336f84c9e784fa358d5.tar.bz2
txr-df456b691838fdbc1e8a7336f84c9e784fa358d5.zip
* arith.c: Regenerated.
* arith.txr (highest_bit): Oops, half the logic for the 64 bit case was missing due to to a cut and paste mistake.
-rw-r--r--ChangeLog7
-rw-r--r--arith.c56
-rw-r--r--arith.txr56
3 files changed, 117 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 1353e7ae..3ec1d4f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,13 @@
* arith.c: Regenerated.
+ * arith.txr (highest_bit): Oops, half the logic for
+ the 64 bit case was missing due to to a cut and paste mistake.
+
+2011-12-11 Kaz Kylheku <kaz@kylheku.com>
+
+ * arith.c: Regenerated.
+
* arith.txr (highest_bit): New function.
(mul): Use highest_bit instead of shift based algorithm.
diff --git a/arith.c b/arith.c
index 43de3888..d5a2f886 100644
--- a/arith.c
+++ b/arith.c
@@ -144,7 +144,61 @@ int highest_bit(int_ptr_t n)
}
}
}
- }
+ } else {
+ if (n & 0x00000000FFFF0000) {
+ if (n & 0x00000000FF000000) {
+ if (n & 0x00000000F0000000) {
+ if (n & 0x00000000C0000000)
+ return (n & 0x0000000080000000) ? 32 : 31;
+ else
+ return (n & 0x0000000020000000) ? 30 : 29;
+ } else {
+ if (n & 0x000000000C000000)
+ return (n & 0x0000000008000000) ? 28 : 27;
+ else
+ return (n & 0x0000000002000000) ? 26 : 25;
+ }
+ } else {
+ if (n & 0x0000000000F00000) {
+ if (n & 0x0000000000C00000)
+ return (n & 0x0000000000800000) ? 24 : 23;
+ else
+ return (n & 0x0000000000200000) ? 22 : 21;
+ } else {
+ if (n & 0x00000000000C0000)
+ return (n & 0x0000000000080000) ? 20 : 19;
+ else
+ return (n & 0x0000000000020000) ? 18 : 17;
+ }
+ }
+ } else {
+ if (n & 0x000000000000FF00) {
+ if (n & 0x000000000000F000) {
+ if (n & 0x000000000000C000)
+ return (n & 0x0000000000008000) ? 16 : 15;
+ else
+ return (n & 0x0000000000002000) ? 14 : 13;
+ } else {
+ if (n & 0x0000000000000C00)
+ return (n & 0x0000000000000800) ? 12 : 11;
+ else
+ return (n & 0x0000000000000200) ? 10 : 9;
+ }
+ } else {
+ if (n & 0x00000000000000F0) {
+ if (n & 0x00000000000000C0)
+ return (n & 0x0000000000000080) ? 8 : 7;
+ else
+ return (n & 0x0000000000000020) ? 6 : 5;
+ } else {
+ if (n & 0x000000000000000C)
+ return (n & 0x0000000000000008) ? 4 : 3;
+ else
+ return (n & 0x0000000000000002) ? 2 : (n ? 1 : 0);
+ }
+ }
+ }
+ }
#elif SIZEOF_PTR == 4
if (n & 0x7FFF0000) {
if (n & 0x7F000000) {
diff --git a/arith.txr b/arith.txr
index e45b8b43..ab5c85bd 100644
--- a/arith.txr
+++ b/arith.txr
@@ -149,7 +149,61 @@ int highest_bit(int_ptr_t n)
}
}
}
- }
+ } else {
+ if (n & 0x00000000FFFF0000) {
+ if (n & 0x00000000FF000000) {
+ if (n & 0x00000000F0000000) {
+ if (n & 0x00000000C0000000)
+ return (n & 0x0000000080000000) ? 32 : 31;
+ else
+ return (n & 0x0000000020000000) ? 30 : 29;
+ } else {
+ if (n & 0x000000000C000000)
+ return (n & 0x0000000008000000) ? 28 : 27;
+ else
+ return (n & 0x0000000002000000) ? 26 : 25;
+ }
+ } else {
+ if (n & 0x0000000000F00000) {
+ if (n & 0x0000000000C00000)
+ return (n & 0x0000000000800000) ? 24 : 23;
+ else
+ return (n & 0x0000000000200000) ? 22 : 21;
+ } else {
+ if (n & 0x00000000000C0000)
+ return (n & 0x0000000000080000) ? 20 : 19;
+ else
+ return (n & 0x0000000000020000) ? 18 : 17;
+ }
+ }
+ } else {
+ if (n & 0x000000000000FF00) {
+ if (n & 0x000000000000F000) {
+ if (n & 0x000000000000C000)
+ return (n & 0x0000000000008000) ? 16 : 15;
+ else
+ return (n & 0x0000000000002000) ? 14 : 13;
+ } else {
+ if (n & 0x0000000000000C00)
+ return (n & 0x0000000000000800) ? 12 : 11;
+ else
+ return (n & 0x0000000000000200) ? 10 : 9;
+ }
+ } else {
+ if (n & 0x00000000000000F0) {
+ if (n & 0x00000000000000C0)
+ return (n & 0x0000000000000080) ? 8 : 7;
+ else
+ return (n & 0x0000000000000020) ? 6 : 5;
+ } else {
+ if (n & 0x000000000000000C)
+ return (n & 0x0000000000000008) ? 4 : 3;
+ else
+ return (n & 0x0000000000000002) ? 2 : (n ? 1 : 0);
+ }
+ }
+ }
+ }
#elif SIZEOF_PTR == 4
if (n & 0x7FFF0000) {
if (n & 0x7F000000) {