testsuite: Avoid strict aliasing violations in some avx512 tests
These tests violated strict aliasing, fixed by using a union and type punning through that. 2020-12-08 Jakub Jelinek <jakub@redhat.com> * gcc.target/i386/avx512dq-vandnpd-2.c (CALC): Use union to avoid aliasing violations. * gcc.target/i386/avx512dq-vandnps-2.c (CALC): Likewise. * gcc.target/i386/avx512dq-vandpd-2.c (CALC): Likewise. * gcc.target/i386/avx512dq-vandps-2.c (CALC): Likewise. * gcc.target/i386/avx512dq-vorpd-2.c (CALC): Likewise. * gcc.target/i386/avx512dq-vorps-2.c (CALC): Likewise. * gcc.target/i386/avx512dq-vxorpd-2.c (CALC): Likewise. * gcc.target/i386/avx512dq-vxorps-2.c (CALC): Likewise.
This commit is contained in:
parent
19c1ef85c3
commit
4c6a47c7dd
@ -16,8 +16,11 @@ CALC (double *s1, double *s2, double *r)
|
||||
|
||||
for (i = 0; i < SIZE; i++)
|
||||
{
|
||||
tmp = (~(*(long long *) &s1[i])) & (*(long long *) &s2[i]);
|
||||
r[i] = *(double *) &tmp;
|
||||
union U { double d; long long l; } u1, u2;
|
||||
u1.d = s1[i];
|
||||
u2.d = s2[i];
|
||||
u1.l = (~u1.l) & u2.l;
|
||||
r[i] = u1.d;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,11 @@ CALC (float *s1, float *s2, float *r)
|
||||
|
||||
for (i = 0; i < SIZE; i++)
|
||||
{
|
||||
tmp = (~(*(int *) &s1[i])) & (*(int *) &s2[i]);
|
||||
r[i] = *(float *) &tmp;
|
||||
union U { float f; int i; } u1, u2;
|
||||
u1.f = s1[i];
|
||||
u2.f = s2[i];
|
||||
u1.i = (~u1.i) & u2.i;
|
||||
r[i] = u1.f;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,11 @@ CALC (double *s1, double *s2, double *r)
|
||||
|
||||
for (i = 0; i < SIZE; i++)
|
||||
{
|
||||
tmp = (*(long long *) &s1[i]) & (*(long long *) &s2[i]);
|
||||
r[i] = *(double *) &tmp;
|
||||
union U { double d; long long l; } u1, u2;
|
||||
u1.d = s1[i];
|
||||
u2.d = s2[i];
|
||||
u1.l &= u2.l;
|
||||
r[i] = u1.d;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,11 @@ CALC (float *s1, float *s2, float *r)
|
||||
|
||||
for (i = 0; i < SIZE; i++)
|
||||
{
|
||||
tmp = (*(int *) &s1[i]) & (*(int *) &s2[i]);
|
||||
r[i] = *(float *) &tmp;
|
||||
union U { float f; int i; } u1, u2;
|
||||
u1.f = s1[i];
|
||||
u2.f = s2[i];
|
||||
u1.i &= u2.i;
|
||||
r[i] = u1.f;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,11 @@ CALC (double *src1, double *src2, double *dst)
|
||||
|
||||
for (i = 0; i < SIZE; i++)
|
||||
{
|
||||
long long tmp = (*(long long *) &src1[i]) | (*(long long *) &src2[i]);
|
||||
dst[i] = *(double *) &tmp;
|
||||
union U { double d; long long l; } u1, u2;
|
||||
u1.d = src1[i];
|
||||
u2.d = src2[i];
|
||||
u1.l |= u2.l;
|
||||
dst[i] = u1.d;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,11 @@ CALC (float *src1, float *src2, float *dst)
|
||||
|
||||
for (i = 0; i < SIZE; i++)
|
||||
{
|
||||
int tmp = (*(int *) &src1[i]) | (*(int *) &src2[i]);
|
||||
dst[i] = *(float *) &tmp;
|
||||
union U { float f; int i; } u1, u2;
|
||||
u1.f = src1[i];
|
||||
u2.f = src2[i];
|
||||
u1.i |= u2.i;
|
||||
dst[i] = u1.f;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,11 @@ CALC (double *src1, double *src2, double *dst)
|
||||
|
||||
for (i = 0; i < SIZE; i++)
|
||||
{
|
||||
long long tmp = (*(long long *) &src1[i]) ^ (*(long long *) &src2[i]);
|
||||
dst[i] = *(double *) &tmp;
|
||||
union U { double d; long long l; } u1, u2;
|
||||
u1.d = src1[i];
|
||||
u2.d = src2[i];
|
||||
u1.l ^= u2.l;
|
||||
dst[i] = u1.d;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,11 @@ CALC (float *src1, float *src2, float *dst)
|
||||
|
||||
for (i = 0; i < SIZE; i++)
|
||||
{
|
||||
int tmp = (*(int *) &src1[i]) ^ (*(int *) &src2[i]);
|
||||
dst[i] = *(float *) &tmp;
|
||||
union U { float f; int i; } u1, u2;
|
||||
u1.f = src1[i];
|
||||
u2.f = src2[i];
|
||||
u1.i ^= u2.i;
|
||||
dst[i] = u1.f;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user