OpenMP: Fix folding with simd's linear clause [PR106492]

gcc/ChangeLog:

	PR middle-end/106492
	* omp-low.cc (lower_rec_input_clauses): Add missing folding
	to data type of linear-clause list item.

gcc/testsuite/ChangeLog:

	PR middle-end/106492
	* g++.dg/gomp/pr106492.C: New test.
This commit is contained in:
Tobias Burnus 2022-08-09 07:57:40 +02:00
parent 5f17badb64
commit 8a16b9f983
2 changed files with 52 additions and 3 deletions

View File

@ -6241,10 +6241,10 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
}
if (POINTER_TYPE_P (TREE_TYPE (x)))
x = fold_build2 (POINTER_PLUS_EXPR,
TREE_TYPE (x), x, t);
x = fold_build_pointer_plus (x, t);
else
x = fold_build2 (PLUS_EXPR, TREE_TYPE (x), x, t);
x = fold_build2 (PLUS_EXPR, TREE_TYPE (x), x,
fold_convert (TREE_TYPE (x), t));
}
if ((OMP_CLAUSE_CODE (c) != OMP_CLAUSE_LINEAR

View File

@ -0,0 +1,49 @@
/* PR middle-end/106492 */
template <typename T>
struct S {
T a : 12;
S () : a(0)
{
#pragma omp for simd linear(a)
for (int k = 0; k < 64; ++k)
a++;
}
};
struct U {
int a : 12;
U () : a(0)
{
#pragma omp for simd linear(a)
for (int k = 0; k < 64; ++k)
a++;
}
};
S<int> s;
U u;
template <typename T>
struct Sptr {
T a;
Sptr (T init) : a(init)
{
#pragma omp for simd linear(a)
for (int k = 0; k < 64; ++k)
a++;
}
};
struct Uptr {
int *a;
Uptr (int *init) : a(init)
{
#pragma omp for simd linear(a)
for (int k = 0; k < 64; ++k)
a++;
}
};
int i[1024];
Sptr<int *> sptr(i);
Uptr uptr(&i[100]);