PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / pr58508.c
blobc18b1cf23e549bbdcaf11c88ca8f1312b0ea4ba0
1 /* { dg-do compile } */
2 /* { dg-require-effective-target vect_int } */
5 /* The GCC vectorizer generates loop versioning for the following loop
6 since there may exist aliasing between A and B. The predicate checks
7 if A may alias with B across all iterations. Then for the loop in
8 the true body, we can assert that *B is a loop invariant so that
9 we can hoist the load of *B before the loop body. */
11 void test1 (int* a, int* b)
13 int i;
14 for (i = 0; i < 100000; ++i)
15 a[i] = *b + 1;
18 /* A test case with nested loops. The load of b[j+1] in the inner
19 loop should be hoisted. */
21 void test2 (int* a, int* b)
23 int i, j;
24 for (j = 0; j < 100000; ++j)
25 for (i = 0; i < 100000; ++i)
26 a[i] = b[j+1] + 1;
29 /* A test case with ifcvt transformation. */
31 void test3 (int* a, int* b)
33 int i, t;
34 for (i = 0; i < 10000; ++i)
36 if (*b > 0)
37 t = *b * 2;
38 else
39 t = *b / 2;
40 a[i] = t;
44 /* A test case in which the store in the loop can be moved outside
45 in the versioned loop with alias checks. Note this loop won't
46 be vectorized. */
48 void test4 (int* a, int* b)
50 int i;
51 for (i = 0; i < 100000; ++i)
52 *a += b[i];
55 /* A test case in which the load and store in the loop to b
56 can be moved outside in the versioned loop with alias checks.
57 Note this loop won't be vectorized. */
59 void test5 (int* a, int* b)
61 int i;
62 for (i = 0; i < 100000; ++i)
64 *b += a[i];
65 a[i] = *b;
69 /* { dg-final { scan-tree-dump-times "hoist" 8 "vect" { xfail *-*-* } } } */
70 /* { dg-final { scan-tree-dump-times "hoist" 3 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */