[PR115565] cse: Don't use a valid regno for non-register in comparison_qty
[official-gcc.git] / libgomp / testsuite / libgomp.c / scan-3.c
blob2e1fcadba04632af1f2c7faad51d4354a2d90cf5
1 /* { dg-require-effective-target size32plus } */
3 extern void abort (void);
4 float r = 1.0f, a[1024], b[1024];
6 __attribute__((noipa)) void
7 foo (float *a, float *b)
9 #pragma omp for reduction (inscan, *:r)
10 for (int i = 0; i < 1024; i++)
12 r *= a[i];
13 #pragma omp scan inclusive(r)
14 b[i] = r;
18 __attribute__((noipa)) float
19 bar (void)
21 float s = -__builtin_inff ();
22 #pragma omp parallel for reduction (inscan, max:s)
23 for (int i = 0; i < 1024; i++)
25 s = s > a[i] ? s : a[i];
26 #pragma omp scan inclusive(s)
27 b[i] = s;
29 return s;
32 int
33 main ()
35 float s = 1.0f;
36 for (int i = 0; i < 1024; ++i)
38 if (i < 80)
39 a[i] = (i & 1) ? 0.25f : 0.5f;
40 else if (i < 200)
41 a[i] = (i % 3) == 0 ? 2.0f : (i % 3) == 1 ? 4.0f : 1.0f;
42 else if (i < 280)
43 a[i] = (i & 1) ? 0.25f : 0.5f;
44 else if (i < 380)
45 a[i] = (i % 3) == 0 ? 2.0f : (i % 3) == 1 ? 4.0f : 1.0f;
46 else
47 switch (i % 6)
49 case 0: a[i] = 0.25f; break;
50 case 1: a[i] = 2.0f; break;
51 case 2: a[i] = -1.0f; break;
52 case 3: a[i] = -4.0f; break;
53 case 4: a[i] = 0.5f; break;
54 case 5: a[i] = 1.0f; break;
55 default: a[i] = 0.0f; break;
57 b[i] = -19.0f;
58 asm ("" : "+g" (i));
60 #pragma omp parallel
61 foo (a, b);
62 if (r * 16384.0f != 0.125f)
63 abort ();
64 float m = -175.25f;
65 for (int i = 0; i < 1024; ++i)
67 s *= a[i];
68 if (b[i] != s)
69 abort ();
70 else
72 a[i] = m - ((i % 3) == 1 ? 2.0f : (i % 3) == 2 ? 4.0f : 0.0f);
73 b[i] = -231.75f;
74 m += 0.75f;
77 if (bar () != 592.0f)
78 abort ();
79 s = -__builtin_inff ();
80 for (int i = 0; i < 1024; ++i)
82 if (s < a[i])
83 s = a[i];
84 if (b[i] != s)
85 abort ();
87 return 0;