Skip to content

Commit

Permalink
Fixes for gcc-8
Browse files Browse the repository at this point in the history
It looks like 'gcc-8 -ffast-math' does honor the distinction between
+0.0 and -0.0 in floating-point constants.  I suppose that technically
-ffast-math has the right to do so.

For good measure, this patch encodes such constants as their explicit
binary representation.  A separate patch will disable -ffast-math.
  • Loading branch information
matteo-frigo committed May 24, 2018
1 parent bf478af commit 19eeeca
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 8 deletions.
24 changes: 22 additions & 2 deletions simd-support/simd-avx-128-fma.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,28 @@ static inline V FLIP_RI(V x)

static inline V VCONJ(V x)
{
V pmpm = VLIT(-0.0, 0.0);
return VXOR(pmpm, x);
/* Produce a SIMD vector[VL] of (0 + -0i).
We really want to write this:
V pmpm = VLIT(-0.0, 0.0);
but historically some compilers have ignored the distiction
between +0 and -0. It looks like 'gcc-8 -fast-math' treats -0
as 0 too.
*/
union uvec {
unsigned u[4];
V v;
};
static const union uvec pmpm = {
#ifdef FFTW_SINGLE
{ 0x00000000, 0x80000000, 0x00000000, 0x80000000 }
#else
{ 0x00000000, 0x00000000, 0x00000000, 0x80000000 }
#endif
};
return VXOR(pmpm.v, x);
}

static inline V VBYI(V x)
Expand Down
26 changes: 24 additions & 2 deletions simd-support/simd-avx.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,30 @@ static inline V FLIP_RI(V x)

static inline V VCONJ(V x)
{
V pmpm = VLIT(-0.0, 0.0);
return VXOR(pmpm, x);
/* Produce a SIMD vector[VL] of (0 + -0i).
We really want to write this:
V pmpm = VLIT(-0.0, 0.0);
but historically some compilers have ignored the distiction
between +0 and -0. It looks like 'gcc-8 -fast-math' treats -0
as 0 too.
*/
union uvec {
unsigned u[8];
V v;
};
static const union uvec pmpm = {
#ifdef FFTW_SINGLE
{ 0x00000000, 0x80000000, 0x00000000, 0x80000000,
0x00000000, 0x80000000, 0x00000000, 0x80000000 }
#else
{ 0x00000000, 0x00000000, 0x00000000, 0x80000000,
0x00000000, 0x00000000, 0x00000000, 0x80000000 }
#endif
};
return VXOR(pmpm.v, x);
}

static inline V VBYI(V x)
Expand Down
24 changes: 22 additions & 2 deletions simd-support/simd-avx2-128.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,28 @@ static inline V FLIP_RI(V x)

static inline V VCONJ(V x)
{
V pmpm = VLIT(-0.0, 0.0);
return VXOR(pmpm, x);
/* Produce a SIMD vector[VL] of (0 + -0i).
We really want to write this:
V pmpm = VLIT(-0.0, 0.0);
but historically some compilers have ignored the distiction
between +0 and -0. It looks like 'gcc-8 -fast-math' treats -0
as 0 too.
*/
union uvec {
unsigned u[4];
V v;
};
static const union uvec pmpm = {
#ifdef FFTW_SINGLE
{ 0x00000000, 0x80000000, 0x00000000, 0x80000000 }
#else
{ 0x00000000, 0x00000000, 0x00000000, 0x80000000 }
#endif
};
return VXOR(pmpm.v, x);
}

static inline V VBYI(V x)
Expand Down
26 changes: 24 additions & 2 deletions simd-support/simd-avx2.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,30 @@ static inline V FLIP_RI(V x)

static inline V VCONJ(V x)
{
V pmpm = VLIT(-0.0, 0.0);
return VXOR(pmpm, x);
/* Produce a SIMD vector[VL] of (0 + -0i).
We really want to write this:
V pmpm = VLIT(-0.0, 0.0);
but historically some compilers have ignored the distiction
between +0 and -0. It looks like 'gcc-8 -fast-math' treats -0
as 0 too.
*/
union uvec {
unsigned u[8];
V v;
};
static const union uvec pmpm = {
#ifdef FFTW_SINGLE
{ 0x00000000, 0x80000000, 0x00000000, 0x80000000,
0x00000000, 0x80000000, 0x00000000, 0x80000000 }
#else
{ 0x00000000, 0x00000000, 0x00000000, 0x80000000,
0x00000000, 0x00000000, 0x00000000, 0x80000000 }
#endif
};
return VXOR(pmpm.v, x);
}

static inline V VBYI(V x)
Expand Down

0 comments on commit 19eeeca

Please sign in to comment.