summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Frederico Temple Pedrosa <gustavo.pedrosa@eldorado.org.br>2014-11-25 15:41:15 +0000
committerRemi Collet <remi@php.net>2014-12-01 10:55:53 +0100
commit87e0802a997001954603e64ca3987080b50afb21 (patch)
treea3a38fdbfa74de52eda34de5b75b1711789f66ad
parentd04685732ec315d1b4e2df1883bdfef7ed2c1dbe (diff)
downloadphp-git-87e0802a997001954603e64ca3987080b50afb21.tar.gz
PowerPC64 support in long multiplication
In long integer multiplications, avoid casting both operands to long double and use an inline assembly-based overflow checking function instead.
-rw-r--r--Zend/zend_multiply.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h
index 6dce8fb6ac..ab5fd6279d 100644
--- a/Zend/zend_multiply.h
+++ b/Zend/zend_multiply.h
@@ -84,6 +84,24 @@
} \
} while (0)
+#elif defined(__powerpc64__) && defined(__GNUC__)
+
+#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
+ long __tmpvar; \
+ __asm__("li 14, 0\n\t" \
+ "mtxer 14\n\t" \
+ "mulldo. %0, %2,%3\n\t" \
+ "xor %1, %1, %1\n\t" \
+ "bns+ 0f\n\t" \
+ "li %1, 1\n\t" \
+ "0:\n" \
+ : "=r"(__tmpvar),"=r"(usedval) \
+ : "r"(a), "r"(b) \
+ : "r14", "cc"); \
+ if (usedval) (dval) = (double) (a) * (double) (b); \
+ else (lval) = __tmpvar; \
+} while (0)
+
#elif SIZEOF_ZEND_LONG == 4
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \