]> granicus.if.org Git - php/commitdiff
PowerPC64 support in long multiplication
authorGustavo Frederico Temple Pedrosa <gustavo.pedrosa@eldorado.org.br>
Tue, 25 Nov 2014 15:41:15 +0000 (15:41 +0000)
committerRemi Collet <remi@php.net>
Mon, 1 Dec 2014 09:55:53 +0000 (10:55 +0100)
In long integer multiplications, avoid casting
both operands to long double and use an inline
assembly-based overflow checking function instead.

Zend/zend_multiply.h

index 6dce8fb6ac20f379cdf9aea801d7b037c27b35c0..ab5fd6279d3eb78e792f7081c6f00a2a33928947 100644 (file)
        }                                                                                                                               \
 } 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 {      \