
> * testsuite/libgomp.c++/scan-10.C: Add option -fvect-cost-model=cheap. I don't think this is the right thing to do. This just means that at some point between 2013 when -fsimd-cost-model has been introduced and now -fsimd-cost-model= option at least partially stopped working properly. As documented, -fsimd-cost-model= overrides the -fvect-cost-model= setting for OpenMP simd loops (loop->force_vectorize is true) if specified differently from default. In tree-vectorizer.h we have: static inline bool unlimited_cost_model (loop_p loop) { if (loop != NULL && loop->force_vectorize && flag_simd_cost_model != VECT_COST_MODEL_DEFAULT) return flag_simd_cost_model == VECT_COST_MODEL_UNLIMITED; return (flag_vect_cost_model == VECT_COST_MODEL_UNLIMITED); } and use it in various places, but we also just use flag_vect_cost_model in lots of places (and in one spot use flag_simd_cost_model, not sure if we are sure it is a force_vectorize loop or what). So, IMHO we should change the above inline function to loop_cost_model and let it return the cost model and then just reimplement unlimited_cost_model as return loop_cost_model (loop) == VECT_COST_MODEL_UNLIMITED; and then adjust the direct uses of the flag and revert these changes. 2021-10-12 Jakub Jelinek <jakub@redhat.com> gcc/ * tree-vectorizer.h (loop_cost_model): New function. (unlimited_cost_model): Use it. * tree-vect-loop.c (vect_analyze_loop_costing): Use loop_cost_model call instead of flag_vect_cost_model. * tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Likewise. (vect_prune_runtime_alias_test_list): Likewise. Also use it instead of flag_simd_cost_model. gcc/testsuite/ * gcc.dg/gomp/simd-2.c: Remove option -fvect-cost-model=cheap. * gcc.dg/gomp/simd-3.c: Likewise. libgomp/ * testsuite/libgomp.c/scan-11.c: Remove option -fvect-cost-model=cheap. * testsuite/libgomp.c/scan-12.c: Likewise. * testsuite/libgomp.c/scan-13.c: Likewise. * testsuite/libgomp.c/scan-14.c: Likewise. * testsuite/libgomp.c/scan-15.c: Likewise. * testsuite/libgomp.c/scan-16.c: Likewise. * testsuite/libgomp.c/scan-17.c: Likewise. * testsuite/libgomp.c/scan-18.c: Likewise. * testsuite/libgomp.c/scan-19.c: Likewise. * testsuite/libgomp.c/scan-20.c: Likewise. * testsuite/libgomp.c/scan-21.c: Likewise. * testsuite/libgomp.c/scan-22.c: Likewise. * testsuite/libgomp.c++/scan-9.C: Likewise. * testsuite/libgomp.c++/scan-10.C: Likewise. * testsuite/libgomp.c++/scan-11.C: Likewise. * testsuite/libgomp.c++/scan-12.C: Likewise. * testsuite/libgomp.c++/scan-13.C: Likewise. * testsuite/libgomp.c++/scan-14.C: Likewise. * testsuite/libgomp.c++/scan-15.C: Likewise. * testsuite/libgomp.c++/scan-16.C: Likewise.
92 lines
2 KiB
C
92 lines
2 KiB
C
/* { dg-require-effective-target size32plus } */
|
|
/* { dg-additional-options "-O2 -fopenmp -fdump-tree-vect-details" } */
|
|
/* { dg-additional-options "-msse2" { target sse2_runtime } } */
|
|
/* { dg-additional-options "-mavx" { target avx_runtime } } */
|
|
/* { dg-final { scan-tree-dump-times "vectorized \[2-6] loops" 2 "vect" { target sse2_runtime } } } */
|
|
|
|
extern void abort (void);
|
|
float r = 1.0f, a[1024], b[1024];
|
|
|
|
__attribute__((noipa)) void
|
|
foo (float *a, float *b)
|
|
{
|
|
#pragma omp for simd reduction (inscan, *:r)
|
|
for (int i = 0; i < 1024; i++)
|
|
{
|
|
r *= a[i];
|
|
#pragma omp scan inclusive(r)
|
|
b[i] = r;
|
|
}
|
|
}
|
|
|
|
__attribute__((noipa)) float
|
|
bar (void)
|
|
{
|
|
float s = -__builtin_inff ();
|
|
#pragma omp parallel for simd reduction (inscan, max:s)
|
|
for (int i = 0; i < 1024; i++)
|
|
{
|
|
s = s > a[i] ? s : a[i];
|
|
#pragma omp scan inclusive(s)
|
|
b[i] = s;
|
|
}
|
|
return s;
|
|
}
|
|
|
|
int
|
|
main ()
|
|
{
|
|
float s = 1.0f;
|
|
for (int i = 0; i < 1024; ++i)
|
|
{
|
|
if (i < 80)
|
|
a[i] = (i & 1) ? 0.25f : 0.5f;
|
|
else if (i < 200)
|
|
a[i] = (i % 3) == 0 ? 2.0f : (i % 3) == 1 ? 4.0f : 1.0f;
|
|
else if (i < 280)
|
|
a[i] = (i & 1) ? 0.25f : 0.5f;
|
|
else if (i < 380)
|
|
a[i] = (i % 3) == 0 ? 2.0f : (i % 3) == 1 ? 4.0f : 1.0f;
|
|
else
|
|
switch (i % 6)
|
|
{
|
|
case 0: a[i] = 0.25f; break;
|
|
case 1: a[i] = 2.0f; break;
|
|
case 2: a[i] = -1.0f; break;
|
|
case 3: a[i] = -4.0f; break;
|
|
case 4: a[i] = 0.5f; break;
|
|
case 5: a[i] = 1.0f; break;
|
|
default: a[i] = 0.0f; break;
|
|
}
|
|
b[i] = -19.0f;
|
|
asm ("" : "+g" (i));
|
|
}
|
|
#pragma omp parallel
|
|
foo (a, b);
|
|
if (r * 16384.0f != 0.125f)
|
|
abort ();
|
|
float m = -175.25f;
|
|
for (int i = 0; i < 1024; ++i)
|
|
{
|
|
s *= a[i];
|
|
if (b[i] != s)
|
|
abort ();
|
|
else
|
|
{
|
|
a[i] = m - ((i % 3) == 1 ? 2.0f : (i % 3) == 2 ? 4.0f : 0.0f);
|
|
b[i] = -231.75f;
|
|
m += 0.75f;
|
|
}
|
|
}
|
|
if (bar () != 592.0f)
|
|
abort ();
|
|
s = -__builtin_inff ();
|
|
for (int i = 0; i < 1024; ++i)
|
|
{
|
|
if (s < a[i])
|
|
s = a[i];
|
|
if (b[i] != s)
|
|
abort ();
|
|
}
|
|
return 0;
|
|
}
|