2018-01-16 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-peel-3.c
blobd5c0cf10ce1a9725350d64d56e9e26395968eb25
1 /* { dg-require-effective-target vect_int } */
2 /* { dg-add-options bind_pic_locally } */
4 #include <stdarg.h>
5 #include "tree-vect.h"
7 #if VECTOR_BITS > 128
8 #define NINTS (VECTOR_BITS / 32)
9 #define EXTRA (NINTS * 2)
10 #else
11 #define NINTS 4
12 #define EXTRA 10
13 #endif
15 #define N 128
17 #define RES_A (N * N / 4)
18 #define RES_B (N * (N + 1) / 2 + (NINTS + 3) * (N + 1))
19 #define RES_C (N * (N + 1) / 2 + (N + 1))
20 #define RES (RES_A + RES_B + RES_C)
22 int ib[N + EXTRA];
23 int ia[N + EXTRA];
24 int ic[N + EXTRA];
26 __attribute__ ((noinline))
27 int main1 ()
29 int i, suma = 0, sumb = 0, sumc = 0;
31 /* ib and ic have same misalignment, we peel to align them. */
32 for (i = 0; i <= N; i++)
34 suma += ia[i];
35 sumb += ib[i + NINTS + 1];
36 sumc += ic[i + 1];
39 /* check results: */
40 if (suma + sumb + sumc != RES)
41 abort ();
43 return 0;
46 int main (void)
48 int i;
50 check_vect ();
52 for (i = 0; i < N + EXTRA; i++)
54 asm volatile ("" : "+r" (i));
55 ib[i] = i;
56 ic[i] = i+2;
57 ia[i] = i/2;
60 return main1 ();
63 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */
64 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { xfail { { ! vect_unaligned_possible } || vect_sizes_32B_16B } } } } */
65 /* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail { { ! vect_unaligned_possible } || vect_sizes_32B_16B } } } } */