* [Patch] OpenMP: Fix folding with simd's linear clause [PR106492]
@ 2022-08-04 7:32 Tobias Burnus
2022-08-09 6:00 ` [committed] – was: " Tobias Burnus
2022-08-17 11:54 ` Jakub Jelinek
0 siblings, 2 replies; 3+ messages in thread
From: Tobias Burnus @ 2022-08-04 7:32 UTC (permalink / raw)
To: gcc-patches, Jakub Jelinek
[-- Attachment #1: Type: text/plain, Size: 421 bytes --]
Rather obvious fix and similar to PR106449.
OK for mainline and backporting (how far?). I would like to backport it
at least to GCC 12.
Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
[-- Attachment #2: simd-fix.diff --]
[-- Type: text/x-patch, Size: 2005 bytes --]
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.
gcc/omp-low.cc | 6 ++---
gcc/testsuite/g++.dg/gomp/pr106492.C | 49 ++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc
index d73c165f029..3c4b8593c8b 100644
--- a/gcc/omp-low.cc
+++ b/gcc/omp-low.cc
@@ -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
diff --git a/gcc/testsuite/g++.dg/gomp/pr106492.C b/gcc/testsuite/g++.dg/gomp/pr106492.C
new file mode 100644
index 00000000000..f263bb42710
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/pr106492.C
@@ -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]);
^ permalink raw reply [flat|nested] 3+ messages in thread
* [committed] – was: [Patch] OpenMP: Fix folding with simd's linear clause [PR106492]
2022-08-04 7:32 [Patch] OpenMP: Fix folding with simd's linear clause [PR106492] Tobias Burnus
@ 2022-08-09 6:00 ` Tobias Burnus
2022-08-17 11:54 ` Jakub Jelinek
1 sibling, 0 replies; 3+ messages in thread
From: Tobias Burnus @ 2022-08-09 6:00 UTC (permalink / raw)
To: gcc-patches, Jakub Jelinek
On 04.08.22 09:32, Tobias Burnus wrote:
> Rather obvious fix and similar to PR106449.
>
> OK for mainline and backporting (how far?). I would like to backport
> it at least to GCC 12.
Now committed as obvious:
https://gcc.gnu.org/g:r13-1997-g8a16b9f983824b6b9a25275cd23b6bba8c98b800
I intent to backport it to GCC 12 in the next days.
Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch] OpenMP: Fix folding with simd's linear clause [PR106492]
2022-08-04 7:32 [Patch] OpenMP: Fix folding with simd's linear clause [PR106492] Tobias Burnus
2022-08-09 6:00 ` [committed] – was: " Tobias Burnus
@ 2022-08-17 11:54 ` Jakub Jelinek
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Jelinek @ 2022-08-17 11:54 UTC (permalink / raw)
To: Tobias Burnus; +Cc: gcc-patches
On Thu, Aug 04, 2022 at 09:32:22AM +0200, Tobias Burnus wrote:
> Rather obvious fix and similar to PR106449.
>
> OK for mainline and backporting (how far?). I would like to backport it
> at least to GCC 12.
It can go even to 11 and 10 if you are willing to test the backports there
(after a while).
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-08-17 11:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-04 7:32 [Patch] OpenMP: Fix folding with simd's linear clause [PR106492] Tobias Burnus
2022-08-09 6:00 ` [committed] – was: " Tobias Burnus
2022-08-17 11:54 ` Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).