[2/4] openmp: Fix initialization for 'unroll full'
Checks
Commit Message
The index variable initialization for the 'omp unroll'
directive with 'full' clause got lost and the testsuite
did not catch it.
Add the initialization and add -Wall to some tests
to detect uninitialized variable uses and other
potential problems in the code generation.
gcc/ChangeLog:
* omp-transform-loops.cc (full_unroll): Add initialization of index variable.
libgomp/ChangeLog:
* testsuite/libgomp.c-c++-common/loop-transforms/matrix-no-directive-unroll-full-1.c:
Use -Wall and add -Wno-unknown-pragmas to disable warnings about empty pragmas.
Use -O2.
* testsuite/libgomp.c++/loop-transforms/matrix-no-directive-unroll-full-1.C:
Copy of testsuite/libgomp.c-c++-common/matrix-no-directive-unroll-full-1.c,
but using -O0 which works only for C++.
* testsuite/libgomp.c-c++-common/loop-transforms/matrix-no-directive-1.c: Use -Wall
and use -Wno-unknown-pragmas to disable warnings about empty pragmas.
* testsuite/libgomp.c-c++-common/loop-transforms/matrix-omp-distribute-parallel-for-1.c:
Likewise.
* testsuite/libgomp.c-c++-common/loop-transforms/matrix-omp-for-1.c:
Likewise.
* testsuite/libgomp.c-c++-common/loop-transforms/matrix-omp-parallel-for-1.c:
Likewise.
* testsuite/libgomp.c-c++-common/loop-transforms/matrix-omp-parallel-masked-taskloop-1.c:
Likewise.
* testsuite/libgomp.c-c++-common/loop-transforms/matrix-omp-parallel-masked-taskloop-simd-1.c:
Likewise.
* testsuite/libgomp.c-c++-common/loop-transforms/matrix-omp-target-parallel-for-1.c:
Likewise.
* testsuite/libgomp.c-c++-common/loop-transforms/matrix-omp-target-teams-distribute-parallel-for-1.c:
Likewise.
* testsuite/libgomp.c-c++-common/loop-transforms/matrix-omp-taskloop-1.c:
Likewise.
* testsuite/libgomp.c-c++-common/loop-transforms/matrix-omp-teams-distribute-parallel-for-1.c:
Likewise.
* testsuite/libgomp.c-c++-common/loop-transforms/matrix-simd-1.c:
Likewise.
* testsuite/libgomp.c-c++-common/loop-transforms/unroll-non-rect-1.c:
Likewise.
* testsuite/libgomp.c-c++-common/loop-transforms/unroll-1.c:
Likewise and fix broken function calls found by -Wall.
---
gcc/omp-transform-loops.cc | 1 +
.../matrix-no-directive-unroll-full-1.C | 13 +++++++++++++
.../loop-transforms/matrix-no-directive-1.c | 2 +-
.../matrix-no-directive-unroll-full-1.c | 2 +-
.../matrix-omp-distribute-parallel-for-1.c | 2 ++
.../loop-transforms/matrix-omp-for-1.c | 2 +-
.../loop-transforms/matrix-omp-parallel-for-1.c | 2 +-
.../matrix-omp-parallel-masked-taskloop-1.c | 2 ++
.../matrix-omp-parallel-masked-taskloop-simd-1.c | 2 ++
.../matrix-omp-target-parallel-for-1.c | 2 +-
...rix-omp-target-teams-distribute-parallel-for-1.c | 2 ++
.../loop-transforms/matrix-omp-taskloop-1.c | 2 ++
.../matrix-omp-teams-distribute-parallel-for-1.c | 2 ++
.../loop-transforms/matrix-simd-1.c | 2 ++
.../libgomp.c-c++-common/loop-transforms/unroll-1.c | 8 +++++---
.../loop-transforms/unroll-non-rect-1.c | 2 ++
16 files changed, 40 insertions(+), 8 deletions(-)
create mode 100644 libgomp/testsuite/libgomp.c++/loop-transforms/matrix-no-directive-unroll-full-1.C
--
2.36.1
-----------------
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
@@ -548,6 +548,7 @@ full_unroll (gomp_for *omp_for, location_t loc, walk_ctx *ctx ATTRIBUTE_UNUSED)
gimple_seq unrolled = NULL;
gimple_seq_add_seq (&unrolled, gimple_omp_for_pre_body (omp_for));
+ gimplify_assign (index, init, &unrolled);
push_gimplify_context ();
gimple_seq_add_seq (&unrolled,
build_unroll_body (body, unroll_factor, index, incr));
new file mode 100644
@@ -0,0 +1,13 @@
+/* { dg-additional-options { -O0 -fdump-tree-original -Wall -Wno-unknown-pragmas } } */
+
+#define COMMON_DIRECTIVE
+#define COMMON_TOP_TRANSFORM omp unroll full
+#define COLLAPSE_1
+#define COLLAPSE_2
+#define COLLAPSE_3
+#define IMPLEMENTATION_FILE "../../libgomp.c-c++-common/loop-transforms/matrix-constant-iter.h"
+
+#include "../../libgomp.c-c++-common/loop-transforms/matrix-transform-variants-1.h"
+
+/* A consistency check to prevent broken macro usage. */
+/* { dg-final { scan-tree-dump-times "unroll_full" 13 "original" } } */
@@ -1,4 +1,4 @@
-/* { dg-additional-options {-fdump-tree-original} } */
+/* { dg-additional-options { -fdump-tree-original -Wall -Wno-unknown-pragmas } } */
#define COMMON_DIRECTIVE
#define COLLAPSE_1 collapse(1)
@@ -1,4 +1,4 @@
-/* { dg-additional-options {-fdump-tree-original} } */
+/* { dg-additional-options { -O2 -fdump-tree-original -Wall -Wno-unknown-pragmas } } */
#define COMMON_DIRECTIVE
#define COMMON_TOP_TRANSFORM omp unroll full
@@ -1,3 +1,5 @@
+/* { dg-additional-options { -Wall -Wno-unknown-pragmas } } */
+
#define COMMON_DIRECTIVE "omp teams distribute parallel for"
#define COLLAPSE_1 "collapse(1)"
#define COLLAPSE_2 "collapse(2)"
@@ -1,4 +1,4 @@
-/* { dg-additional-options {-fdump-tree-original} } */
+/* { dg-additional-options { -fdump-tree-original -Wall -Wno-unknown-pragmas } } */
#define COMMON_DIRECTIVE omp for
#define COLLAPSE_1 collapse(1)
@@ -1,4 +1,4 @@
-/* { dg-additional-options {-fdump-tree-original} } */
+/* { dg-additional-options { -fdump-tree-original -Wall -Wno-unknown-pragmas } } */
#define COMMON_DIRECTIVE omp parallel for
#define COLLAPSE_1 collapse(1)
@@ -1,3 +1,5 @@
+/* { dg-additional-options { -Wall -Wno-unknown-pragmas } } */
+
#define COMMON_DIRECTIVE omp parallel masked taskloop
#define COLLAPSE_1 collapse(1)
#define COLLAPSE_2 collapse(2)
@@ -1,3 +1,5 @@
+/* { dg-additional-options { -Wall -Wno-unknown-pragmas } } */
+
#define COMMON_DIRECTIVE omp parallel masked taskloop simd
#define COLLAPSE_1 collapse(1)
#define COLLAPSE_2 collapse(2)
@@ -1,4 +1,4 @@
-/* { dg-additional-options {-fdump-tree-original} } */
+/* { dg-additional-options { -fdump-tree-original -Wall -Wno-unknown-pragmas } } */
#define COMMON_DIRECTIVE omp target parallel for map(tofrom:result[0:dim0*dim1]) map(to:matrix1[0:dim0*dim1], matrix2[0:dim0*dim1])
#define COLLAPSE_1 collapse(1)
@@ -1,3 +1,5 @@
+/* { dg-additional-options { -Wall -Wno-unknown-pragmas } } */
+
#define COMMON_DIRECTIVE omp target teams distribute parallel for map(tofrom:result[:dim0*dim1]) map(to:matrix1[0:dim0*dim1], matrix2[0:dim0*dim1])
#define COLLAPSE_1 collapse(1)
#define COLLAPSE_2 collapse(2)
@@ -1,3 +1,5 @@
+/* { dg-additional-options { -Wall -Wno-unknown-pragmas } } */
+
#define COMMON_DIRECTIVE omp taskloop
#define COLLAPSE_1 collapse(1)
#define COLLAPSE_2 collapse(2)
@@ -1,3 +1,5 @@
+/* { dg-additional-options { -Wall -Wno-unknown-pragmas } } */
+
#define COMMON_DIRECTIVE omp teams distribute parallel for
#define COLLAPSE_1 collapse(1)
#define COLLAPSE_2 collapse(2)
@@ -1,3 +1,5 @@
+/* { dg-additional-options { -Wall -Wno-unknown-pragmas } } */
+
#define COMMON_DIRECTIVE omp simd
#define COLLAPSE_1 collapse(1)
#define COLLAPSE_2 collapse(2)
@@ -1,3 +1,5 @@
+/* { dg-additional-options { -Wall -Wno-unknown-pragmas } } */
+
#include <stdio.h>
int compute_sum1 ()
@@ -11,7 +13,7 @@ int compute_sum1 ()
sum++;
if (j != 7)
- __builtin_abort;
+ __builtin_abort ();
return sum;
}
@@ -27,7 +29,7 @@ int compute_sum2()
sum++;
if (j != 7)
- __builtin_abort;
+ __builtin_abort ();
return sum;
}
@@ -43,7 +45,7 @@ int compute_sum3()
sum++;
if (j != 7)
- __builtin_abort;
+ __builtin_abort ();
return sum;
}
@@ -1,3 +1,5 @@
+/* { dg-additional-options { -Wall -Wno-unknown-pragmas } } */
+
#include <stdio.h>
#include <stdlib.h>