1 /* { dg-do run } */
2 /* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-details --save-temps" } */
3 
4 extern void abort ();
5 
6 #define N 16
7 float a[N] = {-0.1f, -3.2f, -6.3f, -9.4f,
8 	      -12.5f, -15.6f, -18.7f, -21.8f,
9 	      24.9f, 27.1f, 30.2f, 33.3f,
10 	      36.4f, 39.5f, 42.6f, 45.7f};
11 float b[N] = {-1.2f, 3.4f, -5.6f, 7.8f,
12 	      -9.0f, 1.0f, -2.0f, 3.0f,
13 	      -4.0f, -5.0f, 6.0f, 7.0f,
14 	      -8.0f, -9.0f, 10.0f, 11.0f};
15 float r[N];
16 
17 double ad[N] = {-0.1d,  -3.2d,  -6.3d,  -9.4d,
18 		-12.5d, -15.6d, -18.7d, -21.8d,
19 		 24.9d,  27.1d,  30.2d,  33.3d,
20 		 36.4d,  39.5d,  42.6d, 45.7d};
21 double bd[N] = {-1.2d,  3.4d, -5.6d,  7.8d,
22 		-9.0d,  1.0d, -2.0d,  3.0d,
23 		-4.0d, -5.0d,  6.0d,  7.0d,
24 		-8.0d, -9.0d, 10.0d, 11.0d};
25 double rd[N];
26 
27 int
main(void)28 main (void)
29 {
30   int i;
31 
32   for (i = 0; i < N; i++)
33     r[i] = a[i] * __builtin_copysignf (1.0f, b[i]);
34 
35   /* check results:  */
36   for (i = 0; i < N; i++)
37     if (r[i] != a[i] * __builtin_copysignf (1.0f, b[i]))
38       abort ();
39 
40   for (i = 0; i < N; i++)
41     rd[i] = ad[i] * __builtin_copysign (1.0d, bd[i]);
42 
43   /* check results:  */
44   for (i = 0; i < N; i++)
45     if (rd[i] != ad[i] * __builtin_copysign (1.0d, bd[i]))
46       abort ();
47 
48 
49   return 0;
50 }
51 
52 /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */
53 /* { dg-final { scan-assembler "\[ \t\]?eor\[ \t\]?" } } */
54 /* { dg-final { scan-assembler "\[ \t\]?and\[ \t\]?" } } */
55 /* { dg-final { scan-assembler-not "copysign" } } */
56 /* { dg-final { scan-assembler-not "\[ \t\]?orr\[ \t\]?" } } */
57 /* { dg-final { scan-assembler-not "\[ \t\]?fmul\[ \t\]?" } } */
58 
59