Use bit_cast to create -0.0 for floating point types to avoid compiler optimization changing sign with --ffast-math enabled.

(cherry picked from commit fc87e2cbaa)
This commit is contained in:
Rasmus Munk Larsen
2021-06-10 19:18:50 -07:00
parent 4b502a7215
commit 1cb1ffd5b2
6 changed files with 16 additions and 12 deletions

View File

@@ -146,8 +146,9 @@ struct quat_conj<Architecture::Target, Derived, double>
{
evaluator<typename Derived::Coefficients> qe(q.coeffs());
Quaternion<double> res;
double arr1[2] = {-0.0, -0.0};
double arr2[2] = {-0.0, 0.0};
const double neg_zero = numext::bit_cast<double>(0x8000000000000000ull);
double arr1[2] = {neg_zero, neg_zero};
double arr2[2] = {neg_zero, 0.0};
const Packet2d mask0 = pset<Packet2d>(arr1);
const Packet2d mask2 = pset<Packet2d>(arr2);
pstoret<double,Packet2d,ResAlignment>(&res.x(), pxor(mask0, qe.template packet<traits<Derived>::Alignment,Packet2d>(0)));