https://gcc.gnu.org/g:3920da45779d4fe1e5fde9b8b1880a7c656b5580

commit r17-2561-g3920da45779d4fe1e5fde9b8b1880a7c656b5580
Author: Paul-Antoine Arras <[email protected]>
Date:   Fri Jul 17 12:40:09 2026 +0200

    openmp: Update GOMP_{distribute,loop}_static_worksharing_dispatch
    
    Replace the 5-argument OMPT dispatch builtins and libgomp implementations
    (niter, start, incr, chunk_size, istart) with a 2-argument form (start,
    iterations) describing the chunk actually being dispatched, which is all the
    information OMPT needs.
    
    gcc/ChangeLog:
    
            * builtin-types.def (BT_FN_VOID_ULONGLONG_ULONGLONG): New.
            (BT_FN_VOID_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG):
            Remove.
            * omp-builtins.def (BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_DISPATCH,
            BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_DISPATCH): Update
            signature.
            * omp-expand.cc (expand_omp_for_static_nochunk): Pass chunk start
            and iteration count instead of loop bounds.
            (expand_omp_for_static_chunk): Likewise.
    
    gcc/fortran/ChangeLog:
    
            * types.def (BT_FN_VOID_ULONGLONG_ULONGLONG): New.
            (BT_FN_VOID_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG):
            Remove.
    
    libgomp/ChangeLog:
    
            * config/gcn/teams.c (GOMP_distribute_static_worksharing_dispatch):
            Update signature and comment.
            * config/nvptx/teams.c 
(GOMP_distribute_static_worksharing_dispatch):
            Likewise.
            * libgomp_g.h (GOMP_loop_static_worksharing_dispatch,
            GOMP_distribute_static_worksharing_dispatch): Update prototypes.
            * loop.c (GOMP_loop_static_worksharing_dispatch): Update signature
            and comment.
            * teams.c (GOMP_distribute_static_worksharing_dispatch): Likewise.
            * testsuite/libgomp.c-c++-common/for-static-3.c: Update scan-dump
            pattern.
    
    gcc/testsuite/ChangeLog:
    
            * c-c++-common/gomp/for-static-3.c: Update scan-dump pattern.

Diff:
---
 gcc/builtin-types.def                              |  4 ++--
 gcc/fortran/types.def                              |  4 ++--
 gcc/omp-builtins.def                               |  4 ++--
 gcc/omp-expand.cc                                  | 22 +++++++---------------
 gcc/testsuite/c-c++-common/gomp/for-static-3.c     |  6 ++----
 libgomp/config/gcn/teams.c                         | 18 +++++++-----------
 libgomp/config/nvptx/teams.c                       | 18 +++++++-----------
 libgomp/libgomp_g.h                                |  6 ------
 libgomp/loop.c                                     | 18 +++++++-----------
 libgomp/teams.c                                    | 18 +++++++-----------
 .../testsuite/libgomp.c-c++-common/for-static-3.c  |  3 +--
 11 files changed, 44 insertions(+), 77 deletions(-)

diff --git a/gcc/builtin-types.def b/gcc/builtin-types.def
index 4725668643d7..23bfa76eaa4b 100644
--- a/gcc/builtin-types.def
+++ b/gcc/builtin-types.def
@@ -692,6 +692,8 @@ DEF_FUNCTION_TYPE_2 (BT_FN_INT_CONST_FEXCEPT_T_PTR_INT, 
BT_INT,
                     BT_CONST_FEXCEPT_T_PTR, BT_INT)
 DEF_FUNCTION_TYPE_2 (BT_FN_PTR_CONST_PTR_UINT8, BT_PTR, BT_CONST_PTR, BT_UINT8)
 DEF_FUNCTION_TYPE_2 (BT_FN_PTR_CONST_PTR_INT, BT_PTR, BT_CONST_PTR, BT_INT)
+DEF_FUNCTION_TYPE_2 (BT_FN_VOID_ULONGLONG_ULONGLONG,
+                    BT_VOID, BT_ULONGLONG, BT_ULONGLONG)
 
 DEF_POINTER_TYPE (BT_PTR_FN_VOID_PTR_PTR, BT_FN_VOID_PTR_PTR)
 
@@ -945,8 +947,6 @@ DEF_FUNCTION_TYPE_5 
(BT_FN_BOOL_UINT_LONGPTR_LONG_LONGPTR_LONGPTR,
 DEF_FUNCTION_TYPE_5 (BT_FN_BOOL_UINT_ULLPTR_ULL_ULLPTR_ULLPTR,
                     BT_BOOL, BT_UINT, BT_PTR_ULONGLONG, BT_ULONGLONG,
                     BT_PTR_ULONGLONG, BT_PTR_ULONGLONG)
-DEF_FUNCTION_TYPE_5 
(BT_FN_VOID_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG,
-                    BT_VOID, BT_ULONGLONG, BT_ULONGLONG, BT_ULONGLONG, 
BT_ULONGLONG, BT_ULONGLONG)
 
 DEF_FUNCTION_TYPE_6 (BT_FN_INT_STRING_SIZE_INT_SIZE_CONST_STRING_VALIST_ARG,
                     BT_INT, BT_STRING, BT_SIZE, BT_INT, BT_SIZE,
diff --git a/gcc/fortran/types.def b/gcc/fortran/types.def
index 30c1050d87d4..eb253d8970e2 100644
--- a/gcc/fortran/types.def
+++ b/gcc/fortran/types.def
@@ -123,6 +123,8 @@ DEF_FUNCTION_TYPE_2 (BT_FN_VOID_PTR_PTRMODE,
                     BT_VOID, BT_PTR, BT_PTRMODE)
 DEF_FUNCTION_TYPE_2 (BT_FN_VOID_CONST_PTR_SIZE, BT_VOID, BT_CONST_PTR, BT_SIZE)
 DEF_FUNCTION_TYPE_2 (BT_FN_PTR_CONST_PTR_INT, BT_PTR, BT_CONST_PTR, BT_INT)
+DEF_FUNCTION_TYPE_2 (BT_FN_VOID_ULONGLONG_ULONGLONG,
+                    BT_VOID, BT_ULONGLONG, BT_ULONGLONG)
 
 DEF_POINTER_TYPE (BT_PTR_FN_VOID_PTR_PTR, BT_FN_VOID_PTR_PTR)
 
@@ -198,8 +200,6 @@ DEF_FUNCTION_TYPE_5 
(BT_FN_BOOL_UINT_LONGPTR_LONG_LONGPTR_LONGPTR,
 DEF_FUNCTION_TYPE_5 (BT_FN_BOOL_UINT_ULLPTR_ULL_ULLPTR_ULLPTR,
                     BT_BOOL, BT_UINT, BT_PTR_ULONGLONG, BT_ULONGLONG,
                     BT_PTR_ULONGLONG, BT_PTR_ULONGLONG)
-DEF_FUNCTION_TYPE_5 
(BT_FN_VOID_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG,
-                    BT_VOID, BT_ULONGLONG, BT_ULONGLONG, BT_ULONGLONG, 
BT_ULONGLONG, BT_ULONGLONG)
 
 DEF_FUNCTION_TYPE_6 (BT_FN_BOOL_LONG_LONG_LONG_LONG_LONGPTR_LONGPTR,
                      BT_BOOL, BT_LONG, BT_LONG, BT_LONG, BT_LONG,
diff --git a/gcc/omp-builtins.def b/gcc/omp-builtins.def
index 6b5e231eb0a8..8e6b6fb3acf6 100644
--- a/gcc/omp-builtins.def
+++ b/gcc/omp-builtins.def
@@ -531,7 +531,7 @@ DEF_GOMP_BUILTIN (BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_END,
                  ATTR_NOTHROW_LEAF_LIST)
 DEF_GOMP_BUILTIN (BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_DISPATCH,
                  "GOMP_loop_static_worksharing_dispatch",
-                 BT_FN_VOID_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG,
+                 BT_FN_VOID_ULONGLONG_ULONGLONG,
                  ATTR_NOTHROW_LEAF_LIST)
 DEF_GOMP_BUILTIN (BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING,
                  "GOMP_distribute_static_worksharing",
@@ -546,5 +546,5 @@ DEF_GOMP_BUILTIN 
(BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_END,
                  ATTR_NOTHROW_LEAF_LIST)
 DEF_GOMP_BUILTIN (BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_DISPATCH,
                  "GOMP_distribute_static_worksharing_dispatch",
-                 BT_FN_VOID_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG,
+                 BT_FN_VOID_ULONGLONG_ULONGLONG,
                  ATTR_NOTHROW_LEAF_LIST)
diff --git a/gcc/omp-expand.cc b/gcc/omp-expand.cc
index cf992eab835f..0d801e0d68a2 100644
--- a/gcc/omp-expand.cc
+++ b/gcc/omp-expand.cc
@@ -5602,13 +5602,9 @@ expand_omp_for_static_nochunk (struct omp_region *region,
        default:
          gcc_unreachable ();
        }
-      tree n_ull = fold_convert (long_long_unsigned_type_node, n);
-      tree n1_ull = fold_convert (long_long_unsigned_type_node, n1);
-      tree step_ull = fold_convert (long_long_unsigned_type_node, step);
-      tree chunk_size_ull = build_int_cst (long_long_unsigned_type_node, 0);
-      tree v_ull = fold_convert (long_long_unsigned_type_node, fd->loop.v);
-      tree call = build_call_expr (decl, 5, n_ull, n1_ull, step_ull,
-                                  chunk_size_ull, v_ull);
+      tree s0_ull = fold_convert (long_long_unsigned_type_node, s0);
+      tree q_ull = fold_convert (long_long_unsigned_type_node, q);
+      tree call = build_call_expr (decl, 2, s0_ull, q_ull);
       force_gimple_operand_gsi (&gsi, call, true, NULL_TREE, true,
                                GSI_SAME_STMT);
     }
@@ -6448,14 +6444,10 @@ expand_omp_for_static_chunk (struct omp_region *region,
        default:
          gcc_unreachable ();
        }
-      tree n_ull = fold_convert (long_long_unsigned_type_node, n);
-      tree n1_ull = fold_convert (long_long_unsigned_type_node, n1);
-      tree step_ull = fold_convert (long_long_unsigned_type_node, step);
-      tree chunk_size_ull
-       = fold_convert (long_long_unsigned_type_node, chunk_size);
-      tree v_ull = fold_convert (long_long_unsigned_type_node, fd->loop.v);
-      tree call = build_call_expr (decl, 5, n_ull, n1_ull, step_ull,
-                                  chunk_size_ull, v_ull);
+      tree s0_ull = fold_convert (long_long_unsigned_type_node, s0);
+      tree iterations = fold_build2 (MINUS_EXPR, itype, e0, s0);
+      iterations = fold_convert (long_long_unsigned_type_node, iterations);
+      tree call = build_call_expr (decl, 2, s0_ull, iterations);
       force_gimple_operand_gsi (&gsi, call, true, NULL_TREE, true,
                                GSI_SAME_STMT);
     }
diff --git a/gcc/testsuite/c-c++-common/gomp/for-static-3.c 
b/gcc/testsuite/c-c++-common/gomp/for-static-3.c
index 950edab0779c..a5cf680a9465 100644
--- a/gcc/testsuite/c-c++-common/gomp/for-static-3.c
+++ b/gcc/testsuite/c-c++-common/gomp/for-static-3.c
@@ -8,13 +8,11 @@
 
 /* { dg-final { scan-tree-dump-not "GOMP_loop_static_worksharing \\(" "ompexp" 
} } */
 /* { dg-final { scan-tree-dump-times "GOMP_loop_static_worksharing_start 
\\(\[^\\)\]" 2 "ompexp" } } */
-/* { dg-final { scan-tree-dump-times "GOMP_loop_static_worksharing_dispatch 
\\(\[^,\]+, \[^,\]+, \[^,\]+, 0, \[^)\]+\\)" 1 "ompexp" } } */
-/* { dg-final { scan-tree-dump-times "GOMP_loop_static_worksharing_dispatch 
\\(\[^,\]+, \[^,\]+, \[^,\]+, 4, \[^)\]+\\)" 1 "ompexp" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_loop_static_worksharing_dispatch 
\\(\[^,\]+, \[^)\]+\\)" 2 "ompexp" } } */
 /* { dg-final { scan-tree-dump-times "GOMP_loop_static_worksharing_end \\(\\)" 
2 "ompexp" } } */
 /* { dg-final { scan-tree-dump-not "GOMP_distribute_static_worksharing \\(" 
"ompexp" } } */
 /* { dg-final { scan-tree-dump-times "GOMP_distribute_static_worksharing_start 
\\(\[^\\)\]" 2 "ompexp" } } */
-/* { dg-final { scan-tree-dump-times 
"GOMP_distribute_static_worksharing_dispatch \\(\[^,\]+, \[^,\]+, \[^,\]+, 0, 
\[^)\]+\\)" 1 "ompexp" } } */
-/* { dg-final { scan-tree-dump-times 
"GOMP_distribute_static_worksharing_dispatch \\(\[^,\]+, \[^,\]+, \[^,\]+, 4, 
\[^)\]+\\)" 1 "ompexp" } } */
+/* { dg-final { scan-tree-dump-times 
"GOMP_distribute_static_worksharing_dispatch \\(\[^,\]+, \[^)\]+\\)" 2 "ompexp" 
} } */
 /* { dg-final { scan-tree-dump-times "GOMP_distribute_static_worksharing_end 
\\(\\)" 2 "ompexp" } } */
 /* { dg-final { scan-tree-dump-not "omp_get_num_threads" "ompexp" } } */
 /* { dg-final { scan-tree-dump-not "omp_get_thread_num" "ompexp" } } */
diff --git a/libgomp/config/gcn/teams.c b/libgomp/config/gcn/teams.c
index 7000e99fb32b..f748d0db1a4e 100644
--- a/libgomp/config/gcn/teams.c
+++ b/libgomp/config/gcn/teams.c
@@ -64,19 +64,15 @@ GOMP_distribute_static_worksharing_start (unsigned long 
long niter
   return nteams + tid * 1I;
 }
 
-/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed. NITER is the total
-   number of iterations. START is the starting iteration index. INCR is the
-   increment of the loop (or step). CHUNK_SIZE is the specific chunk size
-   requested in the schedule clause, or 0 if not specified. ISTART is the
-   iteration index of the logical chunk start.  */
+/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed. START is the
+   starting index of the chunk in the logical iteration space. ITERATIONS is 
the
+   number of iterations in the chunk.  */
 
 void
-GOMP_distribute_static_worksharing_dispatch (
-  unsigned long long niter __attribute__ ((unused)),
-  unsigned long long start __attribute__ ((unused)),
-  unsigned long long incr __attribute__ ((unused)),
-  unsigned long long chunk_size __attribute__ ((unused)),
-  unsigned long long istart __attribute__ ((unused)))
+GOMP_distribute_static_worksharing_dispatch (unsigned long long start
+                                            __attribute__ ((unused)),
+                                            unsigned long long iterations
+                                            __attribute__ ((unused)))
 {}
 
 /* Stub for OMPT callback enabled by -fopenmp-ompt.  */
diff --git a/libgomp/config/nvptx/teams.c b/libgomp/config/nvptx/teams.c
index 7793a745bb11..15a3fe5c3178 100644
--- a/libgomp/config/nvptx/teams.c
+++ b/libgomp/config/nvptx/teams.c
@@ -65,19 +65,15 @@ GOMP_distribute_static_worksharing_start (unsigned long 
long niter
   return nteams + tid * 1I;
 }
 
-/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed. NITER is the total
-   number of iterations. START is the starting iteration index. INCR is the
-   increment of the loop (or step). CHUNK_SIZE is the specific chunk size
-   requested in the schedule clause, or 0 if not specified. ISTART is the
-   iteration index of the logical chunk start.  */
+/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed. START is the
+   starting index of the chunk in the logical iteration space. ITERATIONS is 
the
+   number of iterations in the chunk.  */
 
 void
-GOMP_distribute_static_worksharing_dispatch (
-  unsigned long long niter __attribute__ ((unused)),
-  unsigned long long start __attribute__ ((unused)),
-  unsigned long long incr __attribute__ ((unused)),
-  unsigned long long chunk_size __attribute__ ((unused)),
-  unsigned long long istart __attribute__ ((unused)))
+GOMP_distribute_static_worksharing_dispatch (unsigned long long start
+                                            __attribute__ ((unused)),
+                                            unsigned long long iterations
+                                            __attribute__ ((unused)))
 {}
 
 /* Stub for OMPT callback enabled by -fopenmp-ompt.  */
diff --git a/libgomp/libgomp_g.h b/libgomp/libgomp_g.h
index bc0589672d43..f5f1d8e677b5 100644
--- a/libgomp/libgomp_g.h
+++ b/libgomp/libgomp_g.h
@@ -147,9 +147,6 @@ extern bool GOMP_loop_end_cancel (void);
 extern _Complex int GOMP_loop_static_worksharing (unsigned long long);
 extern _Complex int GOMP_loop_static_worksharing_start (unsigned long long);
 extern void GOMP_loop_static_worksharing_dispatch (unsigned long long,
-                                                  unsigned long long,
-                                                  unsigned long long,
-                                                  unsigned long long,
                                                   unsigned long long);
 extern void GOMP_loop_static_worksharing_end (void);
 
@@ -396,9 +393,6 @@ extern void GOMP_teams_reg (void (*) (void *), void *, 
unsigned, unsigned,
 extern _Complex int GOMP_distribute_static_worksharing (unsigned long long);
 extern _Complex int GOMP_distribute_static_worksharing_start (unsigned long 
long);
 extern void GOMP_distribute_static_worksharing_dispatch (unsigned long long,
-                                                        unsigned long long,
-                                                        unsigned long long,
-                                                        unsigned long long,
                                                         unsigned long long);
 extern void GOMP_distribute_static_worksharing_end (void);
 
diff --git a/libgomp/loop.c b/libgomp/loop.c
index 01ba0a3c9003..0692663215fa 100644
--- a/libgomp/loop.c
+++ b/libgomp/loop.c
@@ -1213,19 +1213,15 @@ GOMP_loop_static_worksharing_start (unsigned long long 
niter
   return nthreads + tid * 1I;
 }
 
-/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed. NITER is the total
-   number of iterations. START is the starting iteration index. INCR is the
-   increment of the loop (or step). CHUNK_SIZE is the specific chunk size
-   requested in the schedule clause, or 0 if not specified. ISTART is the
-   iteration index of the logical chunk start.  */
+/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed. START is the
+   starting index of the chunk in the logical iteration space. ITERATIONS is 
the
+   number of iterations in the chunk.  */
 
 void
-GOMP_loop_static_worksharing_dispatch (
-  unsigned long long niter __attribute__ ((unused)),
-  unsigned long long start __attribute__ ((unused)),
-  unsigned long long incr __attribute__ ((unused)),
-  unsigned long long chunk_size __attribute__ ((unused)),
-  unsigned long long istart __attribute__ ((unused)))
+GOMP_loop_static_worksharing_dispatch (unsigned long long start
+                                      __attribute__ ((unused)),
+                                      unsigned long long iterations
+                                      __attribute__ ((unused)))
 {}
 
 /* Stub for OMPT callback enabled by -fopenmp-ompt.  */
diff --git a/libgomp/teams.c b/libgomp/teams.c
index e95f52056c7a..817d24029106 100644
--- a/libgomp/teams.c
+++ b/libgomp/teams.c
@@ -84,19 +84,15 @@ GOMP_distribute_static_worksharing_start (unsigned long long
   return nteams + tid * 1I;
 }
 
-/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed. NITER is the total
-   number of iterations. START is the starting iteration index. INCR is the
-   increment of the loop (or step). CHUNK_SIZE is the specific chunk size
-   requested in the schedule clause, or 0 if not specified. ISTART is the
-   iteration index of the logical chunk start.  */
+/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed. START is the
+   starting index of the chunk in the logical iteration space. ITERATIONS is 
the
+   number of iterations in the chunk.  */
 
 void
-GOMP_distribute_static_worksharing_dispatch (
-  unsigned long long niter __attribute__ ((unused)),
-  unsigned long long start __attribute__ ((unused)),
-  unsigned long long incr __attribute__ ((unused)),
-  unsigned long long chunk_size __attribute__ ((unused)),
-  unsigned long long istart __attribute__ ((unused)))
+GOMP_distribute_static_worksharing_dispatch (unsigned long long start
+                                            __attribute__ ((unused)),
+                                            unsigned long long iterations
+                                            __attribute__ ((unused)))
 {}
 
 /* Stub for OMPT callback enabled by -fopenmp-ompt.  */
diff --git a/libgomp/testsuite/libgomp.c-c++-common/for-static-3.c 
b/libgomp/testsuite/libgomp.c-c++-common/for-static-3.c
index 77954743843e..1f6922fd2257 100644
--- a/libgomp/testsuite/libgomp.c-c++-common/for-static-3.c
+++ b/libgomp/testsuite/libgomp.c-c++-common/for-static-3.c
@@ -7,6 +7,5 @@
 #include "for-static.h"
 
 /* { dg-final { scan-offload-tree-dump-times 
"GOMP_distribute_static_worksharing_start \\(\[^\\)\]" 2 "optimized" } } */
-/* { dg-final { scan-offload-tree-dump-times 
"GOMP_distribute_static_worksharing_dispatch \\(\[^,\]+, \[^,\]+, \[^,\]+, 0, 
\[^)\]+\\)" 1 "optimized" } } */
-/* { dg-final { scan-offload-tree-dump-times 
"GOMP_distribute_static_worksharing_dispatch \\(\[^,\]+, \[^,\]+, \[^,\]+, 4, 
\[^)\]+\\)" 1 "optimized" } } */
+/* { dg-final { scan-offload-tree-dump-times 
"GOMP_distribute_static_worksharing_dispatch \\(\[^,\]+, \[^)\]+\\)" 2 
"optimized" } } */
 /* { dg-final { scan-offload-tree-dump-times 
"GOMP_distribute_static_worksharing_end \\(\\)" 2 "optimized" } } */

Reply via email to