projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix mulIntMayOflo on 64-bit arches; fixes trac #867
[ghc-hetmet.git]
/
includes
/
Stg.h
diff --git
a/includes/Stg.h
b/includes/Stg.h
index
8e3da0f
..
5cd3701
100644
(file)
--- a/
includes/Stg.h
+++ b/
includes/Stg.h
@@
-442,7
+442,9
@@
typedef union {
/* Approximate version when we don't have long arithmetic (on 64-bit archs) */
/* Approximate version when we don't have long arithmetic (on 64-bit archs) */
-#define HALF_POS_INT (((I_)1) << (BITS_IN (I_) / 2))
+/* If we have n-bit words then we have n-1 bits after accounting for the
+ * sign bit, so we can fit the result of multiplying 2 (n-1)/2-bit numbers */
+#define HALF_POS_INT (((I_)1) << ((BITS_IN (I_) - 1) / 2))
#define HALF_NEG_INT (-HALF_POS_INT)
#define mulIntMayOflo(a,b) \
#define HALF_NEG_INT (-HALF_POS_INT)
#define mulIntMayOflo(a,b) \