1 /* { dg-do run } */ 2 /* { dg-options "-O2 -ffast-math -ftree-vectorize -msse4.1" } */ 3 /* { dg-require-effective-target sse4 } */ 4 /* { dg-skip-if "no M_PI" { vxworks_kernel } } */ 5 6 #ifndef CHECK_H 7 #define CHECK_H "sse4_1-check.h" 8 #endif 9 10 #ifndef TEST 11 #define TEST sse4_1_test 12 #endif 13 14 #include CHECK_H 15 16 #define __NO_MATH_INLINES 17 #include <math.h> 18 19 extern double trunc (double); 20 21 #define NUM 64 22 23 static void 24 __attribute__((__target__("fpmath=sse"))) init_src(double * src)25init_src (double *src) 26 { 27 int i, sign = 1; 28 double f = rand (); 29 30 for (i = 0; i < NUM; i++) 31 { 32 src[i] = (i + 1) * f * M_PI * sign; 33 if (i < (NUM / 2)) 34 { 35 if ((i % 6) == 0) 36 f = f * src[i]; 37 } 38 else if (i == (NUM / 2)) 39 f = rand (); 40 else if ((i % 6) == 0) 41 f = 1 / (f * (i + 1) * src[i] * M_PI * sign); 42 sign = -sign; 43 } 44 } 45 46 static void 47 __attribute__((__target__("fpmath=387"))) TEST(void)48TEST (void) 49 { 50 double a[NUM]; 51 double r[NUM]; 52 int i; 53 54 init_src (a); 55 56 for (i = 0; i < NUM; i++) 57 r[i] = trunc (a[i]); 58 59 /* check results: */ 60 for (i = 0; i < NUM; i++) 61 if (r[i] != trunc (a[i])) 62 abort(); 63 } 64