2018-05-17 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / pr42542-3.c
blob372f2c1e1365ce9a4fa38ca03618f7d93e7e400a
1 /* { dg-do run } */
2 /* { dg-options "-O1 -msse2 -ftree-vectorize" } */
3 /* { dg-require-effective-target sse2 } */
5 #ifndef CHECK_H
6 #define CHECK_H "sse2-check.h"
7 #endif
9 #ifndef TEST
10 #define TEST sse2_test
11 #endif
13 #include CHECK_H
15 unsigned char v1[] __attribute__ ((aligned(16))) =
17 0x80, 0xd0, 0x90, 0xa0, 1, 15, 10, 15,
18 0xa0, 0xc0, 0xb0, 0xf0, 2, 25, 20, 35,
19 3, 34, 30, 36, 0xd0, 0x80, 0xe0, 0xb0,
20 0xf0, 0xe0, 0xe0, 0x80, 25, 34, 30, 40
22 unsigned char v2[] __attribute__ ((aligned(16))) =
24 4, 44, 40, 48, 0xb0, 0x80, 0x80, 0x90,
25 5, 55, 50, 51, 0xc0, 0xb0, 0xf0, 0xd0,
26 0xd0, 0x80, 0xa0, 0xf0, 6, 61, 65, 68,
27 7, 76, 75, 81, 0xe0, 0xf0, 0xc0, 0x90
30 unsigned char max[] =
32 0x80, 0xd0, 0x90, 0xa0, 0xb0, 0x80, 0x80, 0x90,
33 0xa0, 0xc0, 0xb0, 0xf0, 0xc0, 0xb0, 0xf0, 0xd0,
34 0xd0, 0x80, 0xa0, 0xf0, 0xd0, 0x80, 0xe0, 0xb0,
35 0xf0, 0xe0, 0xe0, 0x80, 0xe0, 0xf0, 0xc0, 0x90
38 unsigned char min[] =
40 4, 44, 40, 48, 1, 15, 10, 15,
41 5, 55, 50, 51, 2, 25, 20, 35,
42 3, 34, 30, 36, 6, 61, 65, 68,
43 7, 76, 75, 81, 25, 34, 30, 40
46 unsigned char res[32] __attribute__ ((aligned(16)));
48 extern void abort (void);
50 void
51 find_max (void)
53 int i;
55 for (i = 0; i < 32; i++)
56 res[i] = v1[i] < v2[i] ? v2[i] : v1[i];
59 void
60 find_min (void)
62 int i;
64 for (i = 0; i < 32; i++)
65 res[i] = v1[i] > v2[i] ? v2[i] : v1[i];
68 static void
69 TEST (void)
71 int i;
72 int err = 0;
74 find_max ();
75 for (i = 0; i < 32; i++)
76 if (res[i] != max[i])
77 err++;
79 find_min ();
80 for (i = 0; i < 32; i++)
81 if (res[i] != min[i])
82 err++;
84 if (err)
85 abort ();