libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / sabd_1.c
blob587e3055fce5796ab58eb271fd204fdcbec91df4
1 /* { dg-do run } */
2 /* { dg-options "-O3 -fwrapv" } */
3 /* Make sure vectorized absolute difference behaves same as scalar version. */
5 #define N 16
6 signed char a[] = {-100, -100, -100, -100,-100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 };
7 signed char b[] = { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 };
9 signed char out[N];
11 __attribute__ ((noinline,noipa))
12 void
13 foo (void)
15 for (int i = 0; i < N; i++)
17 signed char diff = b[i] - a[i];
18 out[i] = diff > 0 ? diff : -diff;
22 signed char out2[N];
24 __attribute__ ((noinline,noipa))
25 void
26 foo_scalar (void)
28 for (int i = 0; i < N; i++)
30 asm volatile ("");
31 signed char diff = b[i] - a[i];
32 out2[i] = diff > 0 ? diff : -diff;
36 int
37 main (void)
39 foo ();
40 foo_scalar ();
41 for (int i = 0; i < N; i++)
42 if (out[i] != out2[i])
43 __builtin_abort ();
45 return 0;