1 /* { dg-require-effective-target vect_int } */
2
3 #include <stdint.h>
4 #include <stdio.h>
5 #include "tree-vect.h"
6
7 #define N 50
8 #define TYPE uint8_t
9
10 #ifndef DEBUG
11 #define DEBUG 0
12 #endif
13
14 #define BASE ((TYPE) -1 < 0 ? -126 : 4)
15
16
17 __attribute__((noipa, noinline, optimize("O1")))
18 void fun1(TYPE* restrict pixel, TYPE level, int n)
19 {
20 for (int i = 0; i < n; i+=1)
21 pixel[i] = (pixel[i] + level) / 0xff;
22 }
23
24 __attribute__((noipa, noinline, optimize("O3")))
25 void fun2(TYPE* restrict pixel, TYPE level, int n)
26 {
27 for (int i = 0; i < n; i+=1)
28 pixel[i] = (pixel[i] + level) / 0xff;
29 }
30
31 int main ()
32 {
33 TYPE a[N];
34 TYPE b[N];
35
36 for (int i = 0; i < N; ++i)
37 {
38 a[i] = BASE + i * 13;
39 b[i] = BASE + i * 13;
40 if (DEBUG)
41 printf ("%d: 0x%x\n", i, a[i]);
42 }
43
44 fun1 (a, N / 2, N);
45 fun2 (b, N / 2, N);
46
47 for (int i = 0; i < N; ++i)
48 {
49 if (DEBUG)
50 printf ("%d = 0x%x == 0x%x\n", i, a[i], b[i]);
51
52 if (a[i] != b[i])
53 __builtin_abort ();
54 }
55 return 0;
56 }
57
58 /* { dg-final { scan-tree-dump "divmod pattern recognized" "vect" { target aarch64*-*-* } } } */