1/* { dg-require-effective-target vect_int } */
2
3#include <stdarg.h>
4#include "tree-vect.h"
5
6#define N 128
7#define OFF 3
8
9/* unaligned load.  */
10
11int ia[N];
12int ib[N+OFF];
13
14__attribute__ ((noinline))
15int main1 (int off)
16{
17  int i;
18
19  for (i = 0; i < N+OFF; i++)
20    {
21      ib[i] = i;
22    }
23
24  for (i = 0; i < N; i++)
25    {
26      ia[i] = ib[i+off];
27    }
28
29  /* check results:  */
30  for (i = 0; i < N; i++)
31    {
32      if (ia[i] != ib[i+off])
33        abort ();
34    }
35
36  return 0;
37}
38
39int main (void)
40{
41  check_vect ();
42
43  main1 (0); /* aligned */
44  main1 (OFF); /* unaligned */
45  return 0;
46}
47
48/* For targets that don't support misaligned loads we version for the load.
49   (The store is aligned).  */
50
51/* The initialization induction loop (with aligned access) is also vectorized.  */
52/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */
53/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { xfail vect_no_align } } } */
54/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */
55/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 1 "vect" {target vect_no_align } } } */
56/* { dg-final { cleanup-tree-dump "vect" } } */
57