On Wed, 12 Aug 2015, Marcin Krotkiewski wrote:
Hello, all,
I have doubts about asm generated for the following code that performs
orientation test for a point and a segment:
double orient_test_2d(const double m[2], const double a[2], const double
b[2])
{
double am1 = a[0]-m[0];
double bm1 = b[1]-m[1];
double am2 = a[1]-m[1];
double bm2 = b[0]-m[0];
return ((am1)*(bm1)) - ((am2)*(bm2));
}
In the return statement the operands are all in parentheses. gcc optimizes
Parentheses don't have the meaning you believe they have in C. All those
in your return statement are useless.
the statement and introduces a FMA instruction. I think this is wrong because
FMA causes the subtraction and multiplication to be effectively executed at
the same time, while the source specifies that the multiplications should be
performed before the subtraction.
-ffp-contract=off
--
Marc Glisse