diff mbox series

For 'OMP_CLAUSE' in 'dump_generic_node', dump the whole OMP clause chain

Message ID 87czssbiq4.fsf@dem-tschwing-1.ger.mentorg.com
State New
Headers show
Series For 'OMP_CLAUSE' in 'dump_generic_node', dump the whole OMP clause chain | expand

Commit Message

Thomas Schwinge June 11, 2021, 2:04 p.m. UTC
Hi!

See attached.  OK to push after testing -- or would there ever be a
reason where this is not appropriate?


For example, for 'gcc.dg/gomp/simd-clones-2.c', this changes ("corrects")
the '*.optimized' dump file as follows:

    @@ -1,7 +1,7 @@

     ;; Function addit (addit, funcdef_no=0, decl_uid=2073, cgraph_uid=1, symbol_order=0)

    -__attribute__((omp declare simd (notinbranch), omp declare simd (inbranch)))
    +__attribute__((omp declare simd (notinbranch aligned(2:32)), omp declare simd (inbranch uniform(2) linear(1:66))))
     int addit (int a, int b, int * c)
     {
       int _3;
    @@ -16,7 +16,7 @@ int addit (int a, int b, int * c)

     ;; Function setArray (setArray, funcdef_no=1, decl_uid=2078, cgraph_uid=2, symbol_order=1)

    -__attribute__((omp declare simd (notinbranch)))
    +__attribute__((omp declare simd (notinbranch uniform(0) aligned(0:32) linear(2:1))))
     float setArray (float * a, float x, int k)
     {
       long unsigned int _1;
    @@ -40,7 +40,7 @@ float setArray (float * a, float x, int k)

     ;; Function setArray.simdclone.0 (_ZGVbN4ua32vl_setArray, funcdef_no=2, decl_uid=2089, cgraph_uid=3, symbol_order=2)

    -__attribute__((omp declare simd (notinbranch)))
    +__attribute__((omp declare simd (notinbranch uniform(0) aligned(0:32) linear(2:1))))
     vector(4) float setArray.simdclone.0 (float * a, vector(4) float simd.4, int k)
     {
       vector(4) float vect__8.86;
    @@ -65,7 +65,7 @@ vector(4) float setArray.simdclone.0 (float * a, vector(4) float simd.4, int k)

     ;; Function setArray.simdclone.1 (_ZGVcN8ua32vl_setArray, funcdef_no=3, decl_uid=2100, cgraph_uid=5, symbol_order=4)

    -__attribute__((omp declare simd (notinbranch)))
    +__attribute__((omp declare simd (notinbranch uniform(0) aligned(0:32) linear(2:1))))
     vector(8) float setArray.simdclone.1 (float * a, vector(8) float simd.8, int k)
     {
       vector(8) float vect__8.98;
    @@ -90,7 +90,7 @@ vector(8) float setArray.simdclone.1 (float * a, vector(8) float simd.8, int k)

     ;; Function setArray.simdclone.2 (_ZGVdN8ua32vl_setArray, funcdef_no=4, decl_uid=2372, cgraph_uid=6, symbol_order=5)

    -__attribute__((omp declare simd (notinbranch)))
    +__attribute__((omp declare simd (notinbranch uniform(0) aligned(0:32) linear(2:1))))
     vector(8) float setArray.simdclone.2 (float * a, vector(8) float simd.12, int k)
     {
       vector(8) float vect__8.110;
    @@ -115,7 +115,7 @@ vector(8) float setArray.simdclone.2 (float * a, vector(8) float simd.12, int k)

     ;; Function setArray.simdclone.3 (_ZGVeN16ua32vl_setArray, funcdef_no=5, decl_uid=2558, cgraph_uid=7, symbol_order=6)

    -__attribute__((omp declare simd (notinbranch)))
    +__attribute__((omp declare simd (notinbranch uniform(0) aligned(0:32) linear(2:1))))
     vector(16) float setArray.simdclone.3 (float * a, vector(16) float simd.16, int k)
     {
       vector(16) float vect__8.122;
    @@ -140,7 +140,7 @@ vector(16) float setArray.simdclone.3 (float * a, vector(16) float simd.16, int

     ;; Function addit.simdclone.0 (_ZGVbN4vvva32_addit, funcdef_no=6, decl_uid=3029, cgraph_uid=8, symbol_order=7)

    -__attribute__((omp declare simd (notinbranch), omp declare simd (inbranch)))
    +__attribute__((omp declare simd (notinbranch aligned(2:32)), omp declare simd (inbranch uniform(2) linear(1:66))))
     vector(4) int addit.simdclone.0 (vector(4) int simd.22, vector(4) int simd.23, vector(2) unsigned long simd.24, vector(2) unsigned long simd.25)
     {
       vector(4) int vect__3.134;
    @@ -155,7 +155,7 @@ vector(4) int addit.simdclone.0 (vector(4) int simd.22, vector(4) int simd.23, v

     ;; Function addit.simdclone.1 (_ZGVcN4vvva32_addit, funcdef_no=7, decl_uid=3046, cgraph_uid=9, symbol_order=8)

    -__attribute__((omp declare simd (notinbranch), omp declare simd (inbranch)))
    +__attribute__((omp declare simd (notinbranch aligned(2:32)), omp declare simd (inbranch uniform(2) linear(1:66))))
     vector(4) int addit.simdclone.1 (vector(4) int simd.31, vector(4) int simd.32, vector(2) unsigned long simd.33, vector(2) unsigned long simd.34)
     {
       vector(4) int vect__3.144;
    @@ -170,7 +170,7 @@ vector(4) int addit.simdclone.1 (vector(4) int simd.31, vector(4) int simd.32, v

     ;; Function addit.simdclone.2 (_ZGVdN8vvva32_addit, funcdef_no=8, decl_uid=3063, cgraph_uid=10, symbol_order=9)

    -__attribute__((omp declare simd (notinbranch), omp declare simd (inbranch)))
    +__attribute__((omp declare simd (notinbranch aligned(2:32)), omp declare simd (inbranch uniform(2) linear(1:66))))
     vector(8) int addit.simdclone.2 (vector(8) int simd.40, vector(8) int simd.41, vector(4) unsigned long simd.42, vector(4) unsigned long simd.43)
     {
       vector(8) int vect__3.154;
    @@ -185,7 +185,7 @@ vector(8) int addit.simdclone.2 (vector(8) int simd.40, vector(8) int simd.41, v

     ;; Function addit.simdclone.3 (_ZGVeN16vvva32_addit, funcdef_no=9, decl_uid=3080, cgraph_uid=11, symbol_order=10)

    -__attribute__((omp declare simd (notinbranch), omp declare simd (inbranch)))
    +__attribute__((omp declare simd (notinbranch aligned(2:32)), omp declare simd (inbranch uniform(2) linear(1:66))))
     vector(16) int addit.simdclone.3 (vector(16) int simd.49, vector(16) int simd.50, vector(8) unsigned long simd.51, vector(8) unsigned long simd.52)
     {
       vector(16) int vect__3.164;
    @@ -202,7 +202,7 @@ vector(16) int addit.simdclone.3 (vector(16) int simd.49, vector(16) int simd.50

     Removing basic block 7
     Removing basic block 8
    -__attribute__((omp declare simd (notinbranch), omp declare simd (inbranch)))
    +__attribute__((omp declare simd (notinbranch aligned(2:32)), omp declare simd (inbranch uniform(2) linear(1:66))))
     vector(4) int addit.simdclone.4 (vector(4) int simd.57, int b, int * c, vector(4) int mask.58)
     {
       sizetype ivtmp.180;
    @@ -251,7 +251,7 @@ vector(4) int addit.simdclone.4 (vector(4) int simd.57, int b, int * c, vector(4

     Removing basic block 7
     Removing basic block 8
    -__attribute__((omp declare simd (notinbranch), omp declare simd (inbranch)))
    +__attribute__((omp declare simd (notinbranch aligned(2:32)), omp declare simd (inbranch uniform(2) linear(1:66))))
     vector(4) int addit.simdclone.5 (vector(4) int simd.63, int b, int * c, vector(4) int mask.64)
     {
       sizetype ivtmp.195;
    @@ -299,7 +299,7 @@ vector(4) int addit.simdclone.5 (vector(4) int simd.63, int b, int * c, vector(4
     ;; Function addit.simdclone.6 (_ZGVdM8vl66u_addit, funcdef_no=12, decl_uid=3125, cgraph_uid=14, symbol_order=13)

     Removing basic block 5
    -__attribute__((omp declare simd (notinbranch), omp declare simd (inbranch)))
    +__attribute__((omp declare simd (notinbranch aligned(2:32)), omp declare simd (inbranch uniform(2) linear(1:66))))
     vector(8) int addit.simdclone.6 (vector(8) int simd.69, int b, int * c, vector(8) int mask.70)
     {
       vector(8) <signed-boolean:32> mask__35.206;
    @@ -335,7 +335,7 @@ vector(8) int addit.simdclone.6 (vector(8) int simd.69, int b, int * c, vector(8
     ;; Function addit.simdclone.7 (_ZGVeM16vl66u_addit, funcdef_no=13, decl_uid=3139, cgraph_uid=15, symbol_order=14)

     Removing basic block 5
    -__attribute__((omp declare simd (notinbranch), omp declare simd (inbranch)))
    +__attribute__((omp declare simd (notinbranch aligned(2:32)), omp declare simd (inbranch uniform(2) linear(1:66))))
     vector(16) int addit.simdclone.7 (vector(16) int simd.74, int b, int * c, unsigned int mask.75)
     {
       vector(16) <signed-boolean:1> mask__36.219;


Grüße
 Thomas


-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf

Comments

Jakub Jelinek June 11, 2021, 2:11 p.m. UTC | #1
On Fri, Jun 11, 2021 at 04:04:35PM +0200, Thomas Schwinge wrote:
> >From db04d261071eb5691906fd46436032a7db8a0b02 Mon Sep 17 00:00:00 2001
> From: Thomas Schwinge <thomas@codesourcery.com>
> Date: Fri, 11 Jun 2021 15:37:33 +0200
> Subject: [PATCH] For 'OMP_CLAUSE' in 'dump_generic_node', dump the whole OMP
>  clause chain
> 
> ... instead of just the first clause.
> 
> 	gcc/
> 	* tree-pretty-print.h (dump_omp_clauses): Add 'bool = true'
> 	default argument.
> 	* tree-pretty-print.c (dump_omp_clauses): Update.
> 	(dump_generic_node) <OMP_CLAUSE>: Use it.
> 	gcc/testsuite/
> 	* gcc.dg/gomp/simd-clones-2.c: Enhance.

LGTM, thanks.

	Jakub
diff mbox series

Patch

From db04d261071eb5691906fd46436032a7db8a0b02 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Fri, 11 Jun 2021 15:37:33 +0200
Subject: [PATCH] For 'OMP_CLAUSE' in 'dump_generic_node', dump the whole OMP
 clause chain

... instead of just the first clause.

	gcc/
	* tree-pretty-print.h (dump_omp_clauses): Add 'bool = true'
	default argument.
	* tree-pretty-print.c (dump_omp_clauses): Update.
	(dump_generic_node) <OMP_CLAUSE>: Use it.
	gcc/testsuite/
	* gcc.dg/gomp/simd-clones-2.c: Enhance.
---
 gcc/testsuite/gcc.dg/gomp/simd-clones-2.c |  2 ++
 gcc/tree-pretty-print.c                   | 31 +++++++++++++----------
 gcc/tree-pretty-print.h                   |  3 ++-
 3 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/gomp/simd-clones-2.c b/gcc/testsuite/gcc.dg/gomp/simd-clones-2.c
index 75554de9339..9f7c84dc70b 100644
--- a/gcc/testsuite/gcc.dg/gomp/simd-clones-2.c
+++ b/gcc/testsuite/gcc.dg/gomp/simd-clones-2.c
@@ -7,6 +7,7 @@  int addit(int a, int b, int *c)
   return a + b;
 }
 /* { dg-warning "GCC does not currently support mixed size types for 'simd' functions" "" { target aarch64*-*-* } .-4 } */
+/* { dg-final { scan-tree-dump {(?n)^__attribute__\(\(omp declare simd \(notinbranch aligned\(2:32\)\), omp declare simd \(inbranch uniform\(2\) linear\(1:66\)\)\)\)$} "optimized" } } */
 
 #pragma omp declare simd uniform(a) aligned(a:32) linear(k:1) notinbranch
 float setArray(float *a, float x, int k)
@@ -14,6 +15,7 @@  float setArray(float *a, float x, int k)
   a[k] = a[k] + x;
   return a[k];
 }
+/* { dg-final { scan-tree-dump {(?n)^__attribute__\(\(omp declare simd \(notinbranch uniform\(0\) aligned\(0:32\) linear\(2:1\)\)\)\)$} "optimized" } } */
 
 /* { dg-final { scan-tree-dump "_ZGVbN4ua32vl_setArray" "optimized" { target i?86-*-* x86_64-*-* } } } */
 /* { dg-final { scan-tree-dump "_ZGVbN4vvva32_addit" "optimized" { target i?86-*-* x86_64-*-* } } } */
diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c
index e4562e44746..1d0738f2031 100644
--- a/gcc/tree-pretty-print.c
+++ b/gcc/tree-pretty-print.c
@@ -442,8 +442,9 @@  dump_omp_iterators (pretty_printer *pp, tree iter, int spc, dump_flags_t flags)
 }
 
 
-/* Dump OpenMP clause CLAUSE.  PP, CLAUSE, SPC and FLAGS are as in
-   dump_generic_node.  */
+/* Dump OMP clause CLAUSE, without following OMP_CLAUSE_CHAIN.
+
+   PP, CLAUSE, SPC and FLAGS are as in dump_generic_node.  */
 
 static void
 dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
@@ -1317,23 +1318,22 @@  dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
 }
 
 
-/* Dump the list of OpenMP clauses.  PP, SPC and FLAGS are as in
-   dump_generic_node.  */
+/* Dump chain of OMP clauses.
+
+   PP, SPC and FLAGS are as in dump_generic_node.  */
 
 void
-dump_omp_clauses (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
+dump_omp_clauses (pretty_printer *pp, tree clause, int spc, dump_flags_t flags,
+		  bool leading_space)
 {
-  if (clause == NULL)
-    return;
-
-  pp_space (pp);
-  while (1)
+  while (clause)
     {
+      if (leading_space)
+	pp_space (pp);
       dump_omp_clause (pp, clause, spc, flags);
+      leading_space = true;
+
       clause = OMP_CLAUSE_CHAIN (clause);
-      if (clause == NULL)
-	return;
-      pp_space (pp);
     }
 }
 
@@ -3643,7 +3643,10 @@  dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
       goto dump_omp_body;
 
     case OMP_CLAUSE:
-      dump_omp_clause (pp, node, spc, flags);
+      /* If we come here, we're dumping something that's not an OMP construct,
+	 for example, OMP clauses attached to a function's '__attribute__'.
+	 Dump the whole OMP clause chain.  */
+      dump_omp_clauses (pp, node, spc, flags, false);
       is_expr = false;
       break;
 
diff --git a/gcc/tree-pretty-print.h b/gcc/tree-pretty-print.h
index 92eb4123e79..cafe9aa9598 100644
--- a/gcc/tree-pretty-print.h
+++ b/gcc/tree-pretty-print.h
@@ -39,7 +39,8 @@  extern void print_generic_stmt (FILE *, tree, dump_flags_t = TDF_NONE);
 extern void print_generic_stmt_indented (FILE *, tree, dump_flags_t, int);
 extern void print_generic_expr (FILE *, tree, dump_flags_t = TDF_NONE);
 extern char *print_generic_expr_to_str (tree);
-extern void dump_omp_clauses (pretty_printer *, tree, int, dump_flags_t);
+extern void dump_omp_clauses (pretty_printer *, tree, int, dump_flags_t,
+			      bool = true);
 extern void dump_omp_atomic_memory_order (pretty_printer *,
 					  enum omp_memory_order);
 extern void dump_omp_loop_non_rect_expr (pretty_printer *, tree, int,
-- 
2.25.1