aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/loop-versioning-13.c
blob: c67da047fa6cd81c9af2183187209396f8b908d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* { dg-options "-O3 -fdump-tree-lversion-details" } */

/* Test that we do version for a step of 1 when that would lead the
   iterations to access consecutive groups.  */

void
f1 (unsigned short *x, int stepx, int n)
{
  for (int i = 0; i < n; ++i)
    {
      x[i * stepx * 2] = 100;
      x[i * stepx * 2 + 1] = 99;
    }
}

void
f2 (unsigned short *x, int stepx, int n)
{
  for (int i = 0; i < n; i += stepx * 2)
    {
      x[i] = 100;
      x[i + 1] = 99;
    }
}

void
f3 (unsigned short *x, int stepx, int n)
{
  for (int i = 0; i < n; ++i)
    {
      x[i * stepx * 2 - 16] = 100;
      x[i * stepx * 2 - 15] = 99;
    }
}

void
f4 (unsigned short *x, int stepx, int n)
{
  for (int i = 0; i < n; i += stepx * 2)
    {
      x[i - 16] = 100;
      x[i - 15] = 99;
    }
}

void
f5 (unsigned short *x, int stepx, int n)
{
  for (unsigned short *y = x; y < x + n; y += stepx * 2)
    {
      y[0] = 100;
      y[1] = 99;
    }
}

unsigned short x[1000];

void
g1 (int stepx, int n)
{
  for (int i = 0; i < n; ++i)
    {
      x[i * stepx * 2] = 100;
      x[i * stepx * 2 + 1] = 99;
    }
}

void
g2 (int stepx, int n)
{
  for (int i = 0; i < n; i += stepx * 2)
    {
      x[i] = 100;
      x[i + 1] = 99;
    }
}

void
g3 (int stepx, int n)
{
  for (int i = 0; i < n; ++i)
    {
      x[i * stepx * 2 - 16] = 100;
      x[i * stepx * 2 - 15] = 99;
    }
}

void
g4 (int stepx, int n)
{
  for (int i = 0; i < n; i += stepx * 2)
    {
      x[i - 16] = 100;
      x[i - 15] = 99;
    }
}

void
g5 (int stepx, int n)
{
  for (unsigned short *y = x; y < x + n; y += stepx * 2)
    {
      y[0] = 100;
      y[1] = 99;
    }
}

/* { dg-final { scan-tree-dump-times {want to version containing loop} 10 "lversion" } } */
/* { dg-final { scan-tree-dump-times {versioned this loop} 10 "lversion" } } */