summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vect/fast-math-vect-call-2.c
blob: edb6670b02875097d136945467caad63f35f7f6b (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include "tree-vect.h"

extern long int lrint (double);
extern void abort (void);
long int a[64];
double b[64];

__attribute__((noinline, noclone)) void
f1 (int n)
{
  int i;
  for (i = 0; i < n; i++)
    {
      a[4 * i + 0] = lrint (b[4 * i + 0]) + 1;
      a[4 * i + 1] = lrint (b[4 * i + 1]) + 2;
      a[4 * i + 2] = lrint (b[4 * i + 2]) + 3;
      a[4 * i + 3] = lrint (b[4 * i + 3]) + 4;
    }
}

__attribute__((noinline, noclone)) void
f2 (int n)
{
  int i;
  for (i = 0; i < 2 * n; i++)
    {
      a[2 * i + 0] = lrint (b[2 * i + 0]) + 1;
      a[2 * i + 1] = lrint (b[2 * i + 1]) + 2;
    }
}

__attribute__((noinline, noclone)) void
f3 (void)
{
  int i;
  for (i = 0; i < 64; i++)
    a[i] = lrint (b[i]) + 1;
}

__attribute__((noinline, noclone)) void
f4 (int n)
{
  int i;
  for (i = 0; i < n; i++)
    {
      a[4 * i + 0] = lrint (b[4 * i + 0]);
      a[4 * i + 1] = lrint (b[4 * i + 1]);
      a[4 * i + 2] = lrint (b[4 * i + 2]);
      a[4 * i + 3] = lrint (b[4 * i + 3]);
    }
}

__attribute__((noinline, noclone)) void
f5 (int n)
{
  int i;
  for (i = 0; i < 2 * n; i++)
    {
      a[2 * i + 0] = lrint (b[2 * i + 0]);
      a[2 * i + 1] = lrint (b[2 * i + 1]);
    }
}

__attribute__((noinline, noclone)) void
f6 (void)
{
  int i;
  for (i = 0; i < 64; i++)
    a[i] = lrint (b[i]);
}

__attribute__((noinline, noclone)) int
main1 ()
{
  int i;

  for (i = 0; i < 64; i++)
    {
      asm ("");
      b[i] = ((i & 1) ? -4 * i : 4 * i) + 0.25;
    }
  f1 (16);
  for (i = 0; i < 64; i++)
    if (a[i] != ((i & 1) ? -4 * i : 4 * i) + 1 + (i & 3))
      abort ();
    else
      a[i] = 131.25;
  f2 (16);
  for (i = 0; i < 64; i++)
    if (a[i] != ((i & 1) ? -4 * i : 4 * i) + 1 + (i & 1))
      abort ();
    else
      a[i] = 131.25;
  f3 ();
  for (i = 0; i < 64; i++)
    if (a[i] != ((i & 1) ? -4 * i : 4 * i) + 1)
      abort ();
    else
      a[i] = 131.25;
  f4 (16);
  for (i = 0; i < 64; i++)
    if (a[i] != ((i & 1) ? -4 * i : 4 * i))
      abort ();
    else
      a[i] = 131.25;
  f5 (16);
  for (i = 0; i < 64; i++)
    if (a[i] != ((i & 1) ? -4 * i : 4 * i))
      abort ();
    else
      a[i] = 131.25;
  f6 ();
  for (i = 0; i < 64; i++)
    if (a[i] != ((i & 1) ? -4 * i : 4 * i))
      abort ();
  return 0;
}

int
main ()
{
  check_vect ();
  return main1 ();
}

/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 6 "vect" { target vect_call_lrint } } } */
/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" { target vect_call_lrint } } } */
/* { dg-final { cleanup-tree-dump "vect" } } */