1 /* { dg-do run } */
2 /* { dg-require-effective-target sse4 } */
3 /* { dg-options "-O1 -msse4.2 -ftree-vectorize" } */
4
5 #include "sse4_2-check.h"
6
7 long long v1[] __attribute__ ((aligned(16))) =
8 {
9 -3, 2, 3, -4
10 };
11 long long v2[] __attribute__ ((aligned(16))) =
12 {
13 4, -10, -20, 6
14 };
15
16 long long max[] =
17 {
18 4, 2, 3, 6
19 };
20
21 long long min[] =
22 {
23 -3, -10, -20, -4
24 };
25
26 long long res[4] __attribute__ ((aligned(16)));
27
28 extern void abort (void);
29
30 void
find_max(void)31 find_max (void)
32 {
33 int i;
34
35 for (i = 0; i < 4; i++)
36 res[i] = v1[i] < v2[i] ? v2[i] : v1[i];
37 }
38
39 void
find_min(void)40 find_min (void)
41 {
42 int i;
43
44 for (i = 0; i < 4; i++)
45 res[i] = v1[i] > v2[i] ? v2[i] : v1[i];
46 }
47
48 static void
sse4_2_test(void)49 sse4_2_test (void)
50 {
51 int i;
52 int err = 0;
53
54 find_max ();
55 for (i = 0; i < 4; i++)
56 if (res[i] != max[i])
57 err++;
58
59 find_min ();
60 for (i = 0; i < 4; i++)
61 if (res[i] != min[i])
62 err++;
63
64 if (err)
65 abort ();
66 }
67