Debian Codegraph @

gcc/testsuite/gcc.dg/vect/vect-mod-var.c

raw
1 #include "tree-vect.h"
2
3 #define N 64
4
5 __attribute__ ((noinline)) int
6 f (int *restrict a, int *restrict b, int *restrict c)
7 {
8 for (int i = 0; i < N; ++i)
9 c[i] = a[i] % b[i];
10 }
11
12 #define BASE1 -126
13 #define BASE2 116
14
15 int
16 main (void)
17 {
18 check_vect ();
19
20 int a[N], b[N], c[N];
21
22 for (int i = 0; i < N; ++i)
23 {
24 a[i] = BASE1 + i * 5;
25 b[i] = BASE2 - i * 4;
26 /* b[i] cannot be 0 as that would cause undefined
27 behavior with respect to `% b[i]`. */
28 b[i] = b[i] ? b[i] : 1;
29 __asm__ volatile ("");
30 }
31
32 f (a, b, c);
33
34 #pragma GCC novector
35 for (int i = 0; i < N; ++i)
36 if (c[i] != a[i] % b[i])
37 __builtin_abort ();
38 }
39
40 /* { dg-final { scan-tree-dump "vect_recog_mod_var_pattern: detected" "vect" { target vect_int_div } } } */