Hello! 2011-11-14 Uros Bizjak <ubiz...@gmail.com>
* gcc.target/i386/avx-recip-vec.c: New test. * gcc.target/i386/avx-lrintf-vec.c: Ditto. * gcc.target/i386/avx-lrint-vec.c: Ditto. * gcc.target/i386/avx-ceilf-vec.c: Include sse4_1-ceilf-vec.c. * gcc.target/i386/avx-ceil-vec.c: Include sse4_1-ceil-vec.c. * gcc.target/i386/avx-floorf-vec.c: Include sse4_1-floorf-vec.c. * gcc.target/i386/avx-floor-vec.c: Include sse4_1-floor-vec.c. * gcc.target/i386/avx-rintf-vec.c: Include sse4_1-rintf-vec.c. * gcc.target/i386/avx-rint-vec.c: Include sse4_1-rint-vec.c. * gcc.target/i386/avx-roundf-vec.c: Include sse4_1-roundf-vec.c. * gcc.target/i386/avx-round-vec.c: Include sse4_1-round-vec.c. * gcc.target/i386/avx-truncf-vec.c: Include sse4_1-truncf-vec.c. * gcc.target/i386/avx-trunc-vec.c: Include sse4_1-trunc-vec.c. * gcc.target/i386/avx-copysignf-vec.c: Include sse-copysignf-vec.c. * gcc.target/i386/avx-copysign-vec.c: Include sse2-copysign-vec.c. Tested on x86_64-pc-linux-gnu {,-m32}, committed to mainline. Uros.
Index: avx-round-vec.c =================================================================== --- avx-round-vec.c (revision 181360) +++ avx-round-vec.c (working copy) @@ -3,52 +3,7 @@ /* { dg-require-effective-target avx } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "avx-check.h" +#define CHECK_H "avx-check.h" +#define TEST avx_test -#include <math.h> - -extern double round (double); - -#define NUM 64 - -static void -__attribute__((__target__("fpmath=sse"))) -init_src (double *src) -{ - int i, sign = 1; - double f = rand (); - - for (i = 0; i < NUM; i++) - { - src[i] = (i + 1) * f * M_PI * sign; - if (i < (NUM / 2)) - { - if ((i % 6) == 0) - f = f * src[i]; - } - else if (i == (NUM / 2)) - f = rand (); - else if ((i % 6) == 0) - f = 1 / (f * (i + 1) * src[i] * M_PI * sign); - sign = -sign; - } -} - -static void -__attribute__((__target__("fpmath=387"))) -avx_test (void) -{ - double a[NUM]; - double r[NUM]; - int i; - - init_src (a); - - for (i = 0; i < NUM; i++) - r[i] = round (a[i]); - - /* check results: */ - for (i = 0; i < NUM; i++) - if (r[i] != round (a[i])) - abort(); -} +#include "sse4_1-round-vec.c" Index: sse4_1-floor-vec.c =================================================================== --- sse4_1-floor-vec.c (revision 181360) +++ sse4_1-floor-vec.c (working copy) @@ -3,8 +3,16 @@ /* { dg-require-effective-target sse4 } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "sse4_1-check.h" +#ifndef CHECK_H +#define CHECK_H "sse4_1-check.h" +#endif +#ifndef TEST +#define TEST sse4_1_test +#endif + +#include CHECK_H + #include <math.h> extern double floor (double); @@ -36,7 +44,7 @@ static void __attribute__((__target__("fpmath=387"))) -sse4_1_test (void) +TEST (void) { double a[NUM]; double r[NUM]; Index: avx-rint-vec.c =================================================================== --- avx-rint-vec.c (revision 181360) +++ avx-rint-vec.c (working copy) @@ -3,52 +3,7 @@ /* { dg-require-effective-target avx } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "avx-check.h" +#define CHECK_H "avx-check.h" +#define TEST avx_test -#include <math.h> - -extern double rint (double); - -#define NUM 64 - -static void -__attribute__((__target__("fpmath=sse"))) -init_src (double *src) -{ - int i, sign = 1; - double f = rand (); - - for (i = 0; i < NUM; i++) - { - src[i] = (i + 1) * f * M_PI * sign; - if (i < (NUM / 2)) - { - if ((i % 6) == 0) - f = f * src[i]; - } - else if (i == (NUM / 2)) - f = rand (); - else if ((i % 6) == 0) - f = 1 / (f * (i + 1) * src[i] * M_PI * sign); - sign = -sign; - } -} - -static void -__attribute__((__target__("fpmath=387"))) -avx_test (void) -{ - double a[NUM]; - double r[NUM]; - int i; - - init_src (a); - - for (i = 0; i < NUM; i++) - r[i] = rint (a[i]); - - /* check results: */ - for (i = 0; i < NUM; i++) - if (r[i] != rint (a[i])) - abort(); -} +#include "sse4_1-rint-vec.c" Index: avx-trunc-vec.c =================================================================== --- avx-trunc-vec.c (revision 181360) +++ avx-trunc-vec.c (working copy) @@ -3,52 +3,7 @@ /* { dg-require-effective-target avx } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "avx-check.h" +#define CHECK_H "avx-check.h" +#define TEST avx_test -#include <math.h> - -extern double trunc (double); - -#define NUM 64 - -static void -__attribute__((__target__("fpmath=sse"))) -init_src (double *src) -{ - int i, sign = 1; - double f = rand (); - - for (i = 0; i < NUM; i++) - { - src[i] = (i + 1) * f * M_PI * sign; - if (i < (NUM / 2)) - { - if ((i % 6) == 0) - f = f * src[i]; - } - else if (i == (NUM / 2)) - f = rand (); - else if ((i % 6) == 0) - f = 1 / (f * (i + 1) * src[i] * M_PI * sign); - sign = -sign; - } -} - -static void -__attribute__((__target__("fpmath=387"))) -avx_test (void) -{ - double a[NUM]; - double r[NUM]; - int i; - - init_src (a); - - for (i = 0; i < NUM; i++) - r[i] = trunc (a[i]); - - /* check results: */ - for (i = 0; i < NUM; i++) - if (r[i] != trunc (a[i])) - abort(); -} +#include "sse4_1-truncf-vec.c" Index: avx-copysignf-vec.c =================================================================== --- avx-copysignf-vec.c (revision 181360) +++ avx-copysignf-vec.c (working copy) @@ -2,26 +2,7 @@ /* { dg-require-effective-target avx } */ /* { dg-options "-O2 -ftree-vectorize -mavx -mtune=generic" } */ -#include "avx-check.h" +#define CHECK_H "avx-check.h" +#define TEST avx_test -extern float copysignf (float, float); - -#define N 16 - -float a[N] = {-0.1f,-3.2f,-6.3f,-9.4f,-12.5f,-15.6f,-18.7f,-21.8f,24.9f,27.1f,30.2f,33.3f,36.4f,39.5f,42.6f,45.7f}; -float b[N] = {-1.2f,3.4f,-5.6f,7.8f,-9.0f,1.0f,-2.0f,3.0f,-4.0f,-5.0f,6.0f,7.0f,-8.0f,-9.0f,10.0f,11.0f}; -float r[N]; - -static void -avx_test (void) -{ - int i; - - for (i = 0; i < N; i++) - r[i] = copysignf (a[i], b[i]); - - /* check results: */ - for (i = 0; i < N; i++) - if (r[i] != copysignf (a[i], b[i])) - abort (); -} +#include "sse-copysignf-vec.c" Index: sse4_1-round-vec.c =================================================================== --- sse4_1-round-vec.c (revision 181360) +++ sse4_1-round-vec.c (working copy) @@ -3,8 +3,16 @@ /* { dg-require-effective-target sse4 } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "sse4_1-check.h" +#ifndef CHECK_H +#define CHECK_H "sse4_1-check.h" +#endif +#ifndef TEST +#define TEST sse4_1_test +#endif + +#include CHECK_H + #include <math.h> extern double round (double); @@ -36,7 +44,7 @@ static void __attribute__((__target__("fpmath=387"))) -sse4_1_test (void) +TEST (void) { double a[NUM]; double r[NUM]; Index: sse2-lrint-vec.c =================================================================== --- sse2-lrint-vec.c (revision 181360) +++ sse2-lrint-vec.c (working copy) @@ -2,8 +2,16 @@ /* { dg-options "-O2 -ffast-math -ftree-vectorize -msse2" } */ /* { dg-require-effective-target sse2 } */ -#include "sse2-check.h" +#ifndef CHECK_H +#define CHECK_H "sse2-check.h" +#endif +#ifndef TEST +#define TEST sse2_test +#endif + +#include CHECK_H + extern long lrint (double); #define N 32 @@ -12,7 +20,7 @@ long r[N]; static void -sse2_test (void) +TEST (void) { int i; Index: sse4_1-trunc-vec.c =================================================================== --- sse4_1-trunc-vec.c (revision 181360) +++ sse4_1-trunc-vec.c (working copy) @@ -3,8 +3,16 @@ /* { dg-require-effective-target sse4 } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "sse4_1-check.h" +#ifndef CHECK_H +#define CHECK_H "sse4_1-check.h" +#endif +#ifndef TEST +#define TEST sse4_1_test +#endif + +#include CHECK_H + #include <math.h> extern double trunc (double); @@ -36,7 +44,7 @@ static void __attribute__((__target__("fpmath=387"))) -sse4_1_test (void) +TEST (void) { double a[NUM]; double r[NUM]; Index: avx-recip-vec.c =================================================================== --- avx-recip-vec.c (revision 0) +++ avx-recip-vec.c (revision 0) @@ -0,0 +1,8 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx -mfpmath=sse -mrecip" } */ +/* { dg-require-effective-target avx } */ + +#define CHECK_H "avx-check.h" +#define TEST avx_test + +#include "sse-recip-vec.c" Index: sse4_1-ceil-vec.c =================================================================== --- sse4_1-ceil-vec.c (revision 181360) +++ sse4_1-ceil-vec.c (working copy) @@ -3,8 +3,16 @@ /* { dg-require-effective-target sse4 } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "sse4_1-check.h" +#ifndef CHECK_H +#define CHECK_H "sse4_1-check.h" +#endif +#ifndef TEST +#define TEST sse4_1_test +#endif + +#include CHECK_H + #include <math.h> extern double ceil (double); @@ -36,7 +44,7 @@ static void __attribute__((__target__("fpmath=387"))) -sse4_1_test (void) +TEST (void) { double a[NUM]; double r[NUM]; Index: avx-lrint-vec.c =================================================================== --- avx-lrint-vec.c (revision 0) +++ avx-lrint-vec.c (revision 0) @@ -0,0 +1,8 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx" } */ +/* { dg-require-effective-target avx } */ + +#define CHECK_H "avx-check.h" +#define TEST avx_test + +#include "sse2-lrint-vec.c" Index: sse4_1-floorf-vec.c =================================================================== --- sse4_1-floorf-vec.c (revision 181360) +++ sse4_1-floorf-vec.c (working copy) @@ -3,8 +3,16 @@ /* { dg-require-effective-target sse4 } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "sse4_1-check.h" +#ifndef CHECK_H +#define CHECK_H "sse4_1-check.h" +#endif +#ifndef TEST +#define TEST sse4_1_test +#endif + +#include CHECK_H + #include <math.h> extern float floorf (float); @@ -36,7 +44,7 @@ static void __attribute__((__target__("fpmath=387"))) -sse4_1_test (void) +TEST (void) { float a[NUM]; float r[NUM]; Index: sse-copysignf-vec.c =================================================================== --- sse-copysignf-vec.c (revision 181360) +++ sse-copysignf-vec.c (working copy) @@ -2,8 +2,16 @@ /* { dg-options "-O2 -ftree-vectorize -msse" } */ /* { dg-require-effective-target sse } */ -#include "sse-check.h" +#ifndef CHECK_H +#define CHECK_H "sse-check.h" +#endif +#ifndef TEST +#define TEST sse_test +#endif + +#include CHECK_H + extern float copysignf (float, float); #define N 16 @@ -13,7 +21,7 @@ float r[N]; static void -sse_test (void) +TEST (void) { int i; Index: sse4_1-rint-vec.c =================================================================== --- sse4_1-rint-vec.c (revision 181360) +++ sse4_1-rint-vec.c (working copy) @@ -3,8 +3,16 @@ /* { dg-require-effective-target sse4 } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "sse4_1-check.h" +#ifndef CHECK_H +#define CHECK_H "sse4_1-check.h" +#endif +#ifndef TEST +#define TEST sse4_1_test +#endif + +#include CHECK_H + #include <math.h> extern double rint (double); @@ -36,7 +44,7 @@ static void __attribute__((__target__("fpmath=387"))) -sse4_1_test (void) +TEST (void) { double a[NUM]; double r[NUM]; Index: sse4_1-roundf-vec.c =================================================================== --- sse4_1-roundf-vec.c (revision 181360) +++ sse4_1-roundf-vec.c (working copy) @@ -3,8 +3,16 @@ /* { dg-require-effective-target sse4 } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "sse4_1-check.h" +#ifndef CHECK_H +#define CHECK_H "sse4_1-check.h" +#endif +#ifndef TEST +#define TEST sse4_1_test +#endif + +#include CHECK_H + #include <math.h> extern float roundf (float); @@ -36,7 +44,7 @@ static void __attribute__((__target__("fpmath=387"))) -sse4_1_test (void) +TEST (void) { float a[NUM]; float r[NUM]; Index: avx-floorf-vec.c =================================================================== --- avx-floorf-vec.c (revision 181360) +++ avx-floorf-vec.c (working copy) @@ -3,52 +3,7 @@ /* { dg-require-effective-target avx } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "avx-check.h" +#define CHECK_H "avx-check.h" +#define TEST avx_test -#include <math.h> - -extern float floorf (float); - -#define NUM 64 - -static void -__attribute__((__target__("fpmath=sse"))) -init_src (float *src) -{ - int i, sign = 1; - float f = rand (); - - for (i = 0; i < NUM; i++) - { - src[i] = (i + 1) * f * M_PI * sign; - if (i < (NUM / 2)) - { - if ((i % 6) == 0) - f = f * src[i]; - } - else if (i == (NUM / 2)) - f = rand (); - else if ((i % 6) == 0) - f = 1 / (f * (i + 1) * src[i] * M_PI * sign); - sign = -sign; - } -} - -static void -__attribute__((__target__("fpmath=387"))) -avx_test (void) -{ - float a[NUM]; - float r[NUM]; - int i; - - init_src (a); - - for (i = 0; i < NUM; i++) - r[i] = floorf (a[i]); - - /* check results: */ - for (i = 0; i < NUM; i++) - if (r[i] != floorf (a[i])) - abort(); -} +#include "sse4_1-floorf-vec.c" Index: sse2-copysign-vec.c =================================================================== --- sse2-copysign-vec.c (revision 181360) +++ sse2-copysign-vec.c (working copy) @@ -2,8 +2,16 @@ /* { dg-options "-O2 -ftree-vectorize -msse2" } */ /* { dg-require-effective-target sse2 } */ -#include "sse2-check.h" +#ifndef CHECK_H +#define CHECK_H "sse2-check.h" +#endif +#ifndef TEST +#define TEST sse2_test +#endif + +#include CHECK_H + extern double copysign (double, double); #define N 16 @@ -13,7 +21,7 @@ double r[N]; static void -sse2_test (void) +TEST (void) { int i; Index: avx-rintf-vec.c =================================================================== --- avx-rintf-vec.c (revision 181360) +++ avx-rintf-vec.c (working copy) @@ -3,52 +3,7 @@ /* { dg-require-effective-target avx } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "avx-check.h" +#define CHECK_H "avx-check.h" +#define TEST avx_test -#include <math.h> - -extern float rintf (float); - -#define NUM 64 - -static void -__attribute__((__target__("fpmath=sse"))) -init_src (float *src) -{ - int i, sign = 1; - float f = rand (); - - for (i = 0; i < NUM; i++) - { - src[i] = (i + 1) * f * M_PI * sign; - if (i < (NUM / 2)) - { - if ((i % 6) == 0) - f = f * src[i]; - } - else if (i == (NUM / 2)) - f = rand (); - else if ((i % 6) == 0) - f = 1 / (f * (i + 1) * src[i] * M_PI * sign); - sign = -sign; - } -} - -static void -__attribute__((__target__("fpmath=387"))) -avx_test (void) -{ - float a[NUM]; - float r[NUM]; - int i; - - init_src (a); - - for (i = 0; i < NUM; i++) - r[i] = rintf (a[i]); - - /* check results: */ - for (i = 0; i < NUM; i++) - if (r[i] != rintf (a[i])) - abort(); -} +#include "sse4_1-rintf-vec.c" Index: avx-roundf-vec.c =================================================================== --- avx-roundf-vec.c (revision 181360) +++ avx-roundf-vec.c (working copy) @@ -3,52 +3,7 @@ /* { dg-require-effective-target avx } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "avx-check.h" +#define CHECK_H "avx-check.h" +#define TEST avx_test -#include <math.h> - -extern float roundf (float); - -#define NUM 64 - -static void -__attribute__((__target__("fpmath=sse"))) -init_src (float *src) -{ - int i, sign = 1; - float f = rand (); - - for (i = 0; i < NUM; i++) - { - src[i] = (i + 1) * f * M_PI * sign; - if (i < (NUM / 2)) - { - if ((i % 6) == 0) - f = f * src[i]; - } - else if (i == (NUM / 2)) - f = rand (); - else if ((i % 6) == 0) - f = 1 / (f * (i + 1) * src[i] * M_PI * sign); - sign = -sign; - } -} - -static void -__attribute__((__target__("fpmath=387"))) -avx_test (void) -{ - float a[NUM]; - float r[NUM]; - int i; - - init_src (a); - - for (i = 0; i < NUM; i++) - r[i] = roundf (a[i]); - - /* check results: */ - for (i = 0; i < NUM; i++) - if (r[i] != roundf (a[i])) - abort(); -} +#include "sse4_1-roundf-vec.c" Index: avx-lrintf-vec.c =================================================================== --- avx-lrintf-vec.c (revision 0) +++ avx-lrintf-vec.c (revision 0) @@ -0,0 +1,8 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx" } */ +/* { dg-require-effective-target avx } */ + +#define CHECK_H "avx-check.h" +#define TEST avx_test + +#include "sse2-lrintf-vec.c" Index: sse-recip-vec.c =================================================================== --- sse-recip-vec.c (revision 181360) +++ sse-recip-vec.c (working copy) @@ -2,8 +2,16 @@ /* { dg-options "-O2 -ffast-math -ftree-vectorize -msse -mfpmath=sse -mrecip" } */ /* { dg-require-effective-target sse } */ -#include "sse-check.h" +#ifndef CHECK_H +#define CHECK_H "sse-check.h" +#endif +#ifndef TEST +#define TEST sse_test +#endif + +#include CHECK_H + extern float sqrtf (float); extern float fabsf (float); @@ -16,7 +24,7 @@ float rc[N] = { 0.f, 3.f, 6.f, 9.f, 12.f, 18.f, 21.f, 27.f }; static void -sse_test (void) +TEST (void) { int i; Index: avx-ceilf-vec.c =================================================================== --- avx-ceilf-vec.c (revision 181360) +++ avx-ceilf-vec.c (working copy) @@ -3,52 +3,7 @@ /* { dg-require-effective-target avx } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "avx-check.h" +#define CHECK_H "avx-check.h" +#define TEST avx_test -#include <math.h> - -extern float ceilf (float); - -#define NUM 64 - -static void -__attribute__((__target__("fpmath=sse"))) -init_src (float *src) -{ - int i, sign = 1; - float f = rand (); - - for (i = 0; i < NUM; i++) - { - src[i] = (i + 1) * f * M_PI * sign; - if (i < (NUM / 2)) - { - if ((i % 6) == 0) - f = f * src[i]; - } - else if (i == (NUM / 2)) - f = rand (); - else if ((i % 6) == 0) - f = 1 / (f * (i + 1) * src[i] * M_PI * sign); - sign = -sign; - } -} - -static void -__attribute__((__target__("fpmath=387"))) -avx_test (void) -{ - float a[NUM]; - float r[NUM]; - int i; - - init_src (a); - - for (i = 0; i < NUM; i++) - r[i] = ceilf (a[i]); - - /* check results: */ - for (i = 0; i < NUM; i++) - if (r[i] != ceilf (a[i])) - abort(); -} +#include "sse4_1-ceilf-vec.c" Index: sse4_1-rintf-vec.c =================================================================== --- sse4_1-rintf-vec.c (revision 181360) +++ sse4_1-rintf-vec.c (working copy) @@ -3,8 +3,16 @@ /* { dg-require-effective-target sse4 } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "sse4_1-check.h" +#ifndef CHECK_H +#define CHECK_H "sse4_1-check.h" +#endif +#ifndef TEST +#define TEST sse4_1_test +#endif + +#include CHECK_H + #include <math.h> extern float rintf (float); @@ -36,7 +44,7 @@ static void __attribute__((__target__("fpmath=387"))) -sse4_1_test (void) +TEST (void) { float a[NUM]; float r[NUM]; Index: sse4_1-ceilf-vec.c =================================================================== --- sse4_1-ceilf-vec.c (revision 181360) +++ sse4_1-ceilf-vec.c (working copy) @@ -3,8 +3,16 @@ /* { dg-require-effective-target sse4 } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "sse4_1-check.h" +#ifndef CHECK_H +#define CHECK_H "sse4_1-check.h" +#endif +#ifndef TEST +#define TEST sse4_1_test +#endif + +#include CHECK_H + #include <math.h> extern float ceilf (float); @@ -36,7 +44,7 @@ static void __attribute__((__target__("fpmath=387"))) -sse4_1_test (void) +TEST (void) { float a[NUM]; float r[NUM]; Index: sse4_1-truncf-vec.c =================================================================== --- sse4_1-truncf-vec.c (revision 181360) +++ sse4_1-truncf-vec.c (working copy) @@ -3,8 +3,16 @@ /* { dg-require-effective-target sse4 } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "sse4_1-check.h" +#ifndef CHECK_H +#define CHECK_H "sse4_1-check.h" +#endif +#ifndef TEST +#define TEST sse4_1_test +#endif + +#include CHECK_H + #include <math.h> extern float truncf (float); @@ -36,7 +44,7 @@ static void __attribute__((__target__("fpmath=387"))) -sse4_1_test (void) +TEST (void) { float a[NUM]; float r[NUM]; Index: avx-ceil-vec.c =================================================================== --- avx-ceil-vec.c (revision 181360) +++ avx-ceil-vec.c (working copy) @@ -3,52 +3,7 @@ /* { dg-require-effective-target avx } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "avx-check.h" +#define CHECK_H "avx-check.h" +#define TEST avx_test -#include <math.h> - -extern double ceil (double); - -#define NUM 64 - -static void -__attribute__((__target__("fpmath=sse"))) -init_src (double *src) -{ - int i, sign = 1; - double f = rand (); - - for (i = 0; i < NUM; i++) - { - src[i] = (i + 1) * f * M_PI * sign; - if (i < (NUM / 2)) - { - if ((i % 6) == 0) - f = f * src[i]; - } - else if (i == (NUM / 2)) - f = rand (); - else if ((i % 6) == 0) - f = 1 / (f * (i + 1) * src[i] * M_PI * sign); - sign = -sign; - } -} - -static void -__attribute__((__target__("fpmath=387"))) -avx_test (void) -{ - double a[NUM]; - double r[NUM]; - int i; - - init_src (a); - - for (i = 0; i < NUM; i++) - r[i] = ceil (a[i]); - - /* check results: */ - for (i = 0; i < NUM; i++) - if (r[i] != ceil (a[i])) - abort(); -} +#include "sse4_1-ceil-vec.c" Index: sse2-lrintf-vec.c =================================================================== --- sse2-lrintf-vec.c (revision 181360) +++ sse2-lrintf-vec.c (working copy) @@ -2,8 +2,16 @@ /* { dg-options "-O2 -ffast-math -ftree-vectorize -msse2" } */ /* { dg-require-effective-target sse2 } */ -#include "sse2-check.h" +#ifndef CHECK_H +#define CHECK_H "sse2-check.h" +#endif +#ifndef TEST +#define TEST sse2_test +#endif + +#include CHECK_H + extern long lrintf (float); #define N 32 @@ -12,7 +20,7 @@ long r[N]; static void -sse2_test (void) +TEST (void) { int i; Index: avx-floor-vec.c =================================================================== --- avx-floor-vec.c (revision 181360) +++ avx-floor-vec.c (working copy) @@ -3,52 +3,7 @@ /* { dg-require-effective-target avx } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "avx-check.h" +#define CHECK_H "avx-check.h" +#define TEST avx_test -#include <math.h> - -extern double floor (double); - -#define NUM 64 - -static void -__attribute__((__target__("fpmath=sse"))) -init_src (double *src) -{ - int i, sign = 1; - double f = rand (); - - for (i = 0; i < NUM; i++) - { - src[i] = (i + 1) * f * M_PI * sign; - if (i < (NUM / 2)) - { - if ((i % 6) == 0) - f = f * src[i]; - } - else if (i == (NUM / 2)) - f = rand (); - else if ((i % 6) == 0) - f = 1 / (f * (i + 1) * src[i] * M_PI * sign); - sign = -sign; - } -} - -static void -__attribute__((__target__("fpmath=387"))) -avx_test (void) -{ - double a[NUM]; - double r[NUM]; - int i; - - init_src (a); - - for (i = 0; i < NUM; i++) - r[i] = floor (a[i]); - - /* check results: */ - for (i = 0; i < NUM; i++) - if (r[i] != floor (a[i])) - abort(); -} +#include "sse4_1-floor-vec.c" Index: avx-truncf-vec.c =================================================================== --- avx-truncf-vec.c (revision 181360) +++ avx-truncf-vec.c (working copy) @@ -3,52 +3,7 @@ /* { dg-require-effective-target avx } */ /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ -#include "avx-check.h" +#define CHECK_H "avx-check.h" +#define TEST avx_test -#include <math.h> - -extern float truncf (float); - -#define NUM 64 - -static void -__attribute__((__target__("fpmath=sse"))) -init_src (float *src) -{ - int i, sign = 1; - float f = rand (); - - for (i = 0; i < NUM; i++) - { - src[i] = (i + 1) * f * M_PI * sign; - if (i < (NUM / 2)) - { - if ((i % 6) == 0) - f = f * src[i]; - } - else if (i == (NUM / 2)) - f = rand (); - else if ((i % 6) == 0) - f = 1 / (f * (i + 1) * src[i] * M_PI * sign); - sign = -sign; - } -} - -static void -__attribute__((__target__("fpmath=387"))) -avx_test (void) -{ - float a[NUM]; - float r[NUM]; - int i; - - init_src (a); - - for (i = 0; i < NUM; i++) - r[i] = truncf (a[i]); - - /* check results: */ - for (i = 0; i < NUM; i++) - if (r[i] != truncf (a[i])) - abort(); -} +#include "sse4_1-truncf-vec.c" Index: avx-copysign-vec.c =================================================================== --- avx-copysign-vec.c (revision 181360) +++ avx-copysign-vec.c (working copy) @@ -2,26 +2,7 @@ /* { dg-require-effective-target avx } */ /* { dg-options "-O2 -ftree-vectorize -mavx -mtune=generic" } */ -#include "avx-check.h" +#define CHECK_H "avx-check.h" +#define TEST avx_test -extern double copysign (double, double); - -#define N 16 - -double a[N] = {-0.1,-3.2,-6.3,-9.4,-12.5,-15.6,-18.7,-21.8,24.9,27.1,30.2,33.3,36.4,39.5,42.6,45.7}; -double b[N] = {-1.2,3.4,-5.6,7.8,-9.0,1.0,-2.0,3.0,-4.0,-5.0,6.0,7.0,-8.0,-9.0,10.0,11.0}; -double r[N]; - -static void -avx_test (void) -{ - int i; - - for (i = 0; i < N; i++) - r[i] = copysign (a[i], b[i]); - - /* check results: */ - for (i = 0; i < N; i++) - if (r[i] != copysign (a[i], b[i])) - abort (); -} +#include "sse2-copysign-vec.c"