<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello,<br>
I found the missing information in POWER ISA
<blockquote>
<p><i><font size="2">To use a multiply-add to perform an IEEE or
Java</font></i><i><br>
</i><i><font size="2">compliant multiply, the addend must be
-0.0. This</font></i><i><br>
</i><i><font size="2">is necessary to insure that the sign of a
zero result</font></i><i><br>
</i><i><font size="2">will be correct when the product is -0.0
(+0.0 + -0.0</font></i><i><br>
</i><i><font size="2"> +0.0, and -0.0 + -0.0 -0.0). When the
sign of a</font></i><i><br>
</i><i><font size="2">resulting 0.0 is not important, then +0.0
can be</font></i><i><br>
</i><i><font size="2">used as an addend which may, in some
cases,</font></i><i><br>
</i><i><font size="2">avoid the need for a second register to
hold a -0.0</font></i><i><br>
</i><i><font size="2">in addition to the integer
0/floating-point +0.0 that</font></i><i><br>
</i><i><font size="2">may already be available.</font></i></p>
</blockquote>
<p><font size="2">so the example shows it:</font></p>
<p><font size="2">$ cat t2.c<br>
#include "stdio.h"<br>
#include "altivec.h"<br>
int main() {<br>
vector float X={ -1, 0, 0, 0 };<br>
vector float Y={ -1, -1, -1, -2 };<br>
vector float Z, V;<br>
<b> vector float p4f_ZERO={ 0, 0, 0, 0 };</b><b><br>
</b><b> vector float p4f_mZERO={ -0.0, -0.0, -0.0, -0.0 };</b><br>
Z = vec_madd(X, Y, p4f_ZERO);<br>
V = vec_madd(X, Y, p4f_mZERO);<br>
printf("%f %f %f %f \n",Z[0], Z[1], Z[2], Z[3]);<br>
printf("%f %f %f %f \n",V[0], V[1], V[2], V[3]);<br>
vector float U;<br>
U= X * Y ;<br>
printf("%f %f %f %f \n",U[0], U[1], U[2], U[3]);<br>
return(0);<br>
}<br>
</font></p>
<p><font size="2">$ gcc t2.c<br>
debian@vm18:~$ ./a.out<br>
1.000000 0.000000 0.000000 0.000000 <br>
<b>1.000000 -0.000000 -0.000000 -0.000000 </b><br>
1.000000 -0.000000 -0.000000 -0.000000 <br>
</font></p>
<p><font size="2">So the vector p4f_ZERO must be modified with a
signed value of -0.0 in order to have that function to work.<br>
</font></p>
<div class="moz-signature">-- <br>
<br>
__________________________________________________________________________
<br>
thf - Thierry Fauck - <a class="moz-txt-link-abbreviated" href="mailto:tfauck@free.fr">tfauck@free.fr</a>>
<br>
<i> pubkey: 4096R/FCC181CE</i>
<br>
<i> fingerprint: 5CCF 6B82 DE4E E72A A40B B63E A153 BF4F FCC1 81CE</i></div>
</body>
</html>