[gcc] Deleted branch 'mikael/heads/refactor_descriptor_v04' in namespace 'refs/users'

2025-03-30 Thread Mikael Morin via Gcc-cvs
The branch 'mikael/heads/refactor_descriptor_v04' in namespace 'refs/users' was 
deleted.
It previously pointed to:

 189b6afd2a99... Réduction utilisations stride_get

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  189b6af... Réduction utilisations stride_get
  f7eac82... Réduction usages gfc_conv_descriptor_ubound_get
  0ae779b... Factorisation gfc_conv_array_extent_dim
  8410cda... Suppression export gfc_conv_descriptor_span_set
  ccd1a87... Suppression modification span
  7d797f8... Sauvegarde modifs fichiers générés.
  53867f6... Suppression déclarations inutiles.


[gcc(refs/users/mikael/heads/refactor_descriptor_v04)] Factorisation gfc_conv_array_extent_dim

2025-03-30 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:0ae779bf3365bafc7b8f6cc51298779333ba22ed

commit 0ae779bf3365bafc7b8f6cc51298779333ba22ed
Author: Mikael Morin 
Date:   Sat Mar 29 12:50:41 2025 +0100

Factorisation gfc_conv_array_extent_dim

Diff:
---
 gcc/fortran/trans-intrinsic.cc | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc
index 1b109f822643..cd047aca8149 100644
--- a/gcc/fortran/trans-intrinsic.cc
+++ b/gcc/fortran/trans-intrinsic.cc
@@ -2359,11 +2359,7 @@ gfc_conv_is_contiguous_expr (gfc_se *se, gfc_expr *arg)
{
  tmp = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[i]);
  extent = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[i]);
- extent = fold_build2_loc (input_location, MINUS_EXPR,
-   gfc_array_index_type, extent, tmp);
- extent = fold_build2_loc (input_location, PLUS_EXPR,
-   gfc_array_index_type, extent,
-   gfc_index_one_node);
+ extent = gfc_conv_array_extent_dim (tmp, extent, nullptr);
  tmp = gfc_conv_descriptor_stride_get (desc, gfc_rank_cst[i]);
  tmp = fold_build2_loc (input_location, MULT_EXPR, TREE_TYPE (tmp),
 tmp, extent);
@@ -2483,10 +2479,7 @@ gfc_conv_intrinsic_bound (gfc_se * se, gfc_expr * expr, 
enum gfc_isym_id op)
 
   ubound = gfc_conv_descriptor_ubound_get (desc, bound);
   lbound = gfc_conv_descriptor_lbound_get (desc, bound);
-  size = fold_build2_loc (input_location, MINUS_EXPR,
- gfc_array_index_type, ubound, lbound);
-  size = fold_build2_loc (input_location, PLUS_EXPR,
- gfc_array_index_type, size, gfc_index_one_node);
+  size = gfc_conv_array_extent_dim (lbound, ubound, nullptr);
 
   /* 13.14.53: Result value for LBOUND


[gcc(refs/users/mikael/heads/refactor_descriptor_v04)] Suppression déclarations inutiles.

2025-03-30 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:53867f6799c9b3dacae90f27a0afd6b9fcc8edd0

commit 53867f6799c9b3dacae90f27a0afd6b9fcc8edd0
Author: Mikael Morin 
Date:   Mon Mar 17 20:21:04 2025 +0100

Suppression déclarations inutiles.

Diff:
---
 gcc/fortran/trans-descriptor.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h
index 5db80f59a528..5e8af26d1d8e 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -61,13 +61,10 @@ tree gfc_conv_descriptor_token_field (tree);
 void gfc_conv_descriptor_data_set (stmtblock_t *, tree, tree);
 void gfc_conv_descriptor_token_set (stmtblock_t *, tree, tree);
 void gfc_conv_descriptor_dtype_set (stmtblock_t *, tree, tree);
-void gfc_conv_descriptor_dimensions_set (stmtblock_t *, tree, tree);
 void gfc_conv_descriptor_version_set (stmtblock_t *, tree, tree);
 void gfc_conv_descriptor_rank_set (stmtblock_t *, tree, tree);
 void gfc_conv_descriptor_rank_set (stmtblock_t *, tree, int);
 void gfc_conv_descriptor_span_set (stmtblock_t *, tree, tree);
-void gfc_conv_descriptor_stride_set (stmtblock_t *, tree, tree, tree);
-void gfc_conv_descriptor_lbound_set (stmtblock_t *, tree, tree, tree);
 void gfc_conv_descriptor_ubound_set (stmtblock_t *, tree, tree, tree);
 
 /* CFI descriptor.  */


[gcc(refs/users/mikael/heads/refactor_descriptor_v04)] Suppression modification span

2025-03-30 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:ccd1a8797bc1c75a443a237755b3394fe75de895

commit ccd1a8797bc1c75a443a237755b3394fe75de895
Author: Mikael Morin 
Date:   Sat Mar 29 11:39:49 2025 +0100

Suppression modification span

Diff:
---
 gcc/fortran/trans-expr.cc | 5 -
 1 file changed, 5 deletions(-)

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index c5cbe2efca49..171fbd78fe6c 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -10912,11 +10912,6 @@ gfc_trans_pointer_assignment (gfc_expr * expr1, 
gfc_expr * expr2)
{
  rse.expr = gfc_class_data_get (rse.expr);
  gfc_add_modify (&lse.pre, desc, rse.expr);
- /* Set the lhs span.  */
- tmp = TREE_TYPE (rse.expr);
- tmp = TYPE_SIZE_UNIT (gfc_get_element_type (tmp));
- tmp = fold_convert (gfc_array_index_type, tmp);
- gfc_conv_descriptor_span_set (&lse.pre, desc, tmp);
}
  else
{


[gcc(refs/users/mikael/heads/refactor_descriptor_v04)] Réduction utilisations stride_get

2025-03-30 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:8fd3bbc0668da212f027c9dbe689b4a69a580f6b

commit 8fd3bbc0668da212f027c9dbe689b4a69a580f6b
Author: Mikael Morin 
Date:   Sun Mar 30 18:16:46 2025 +0200

Réduction utilisations stride_get

Correction régression gomp/pr36726.f90

Diff:
---
 gcc/fortran/trans-decl.cc   |  4 +---
 gcc/fortran/trans-openmp.cc | 45 +++--
 2 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index 0c48f7a062d1..d88ad3655c19 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -7597,9 +7597,7 @@ done:
   tmp = gfc_conv_descriptor_extent_get (gfc_desc, idx);
   gfc_add_modify (&loop_body, gfc_get_cfi_dim_extent (cfi, idx), tmp);
   /* d->dim[n].sm = gfc->dim[i].stride  * gfc->span); */
-  tmp = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
-gfc_conv_descriptor_stride_get (gfc_desc, idx),
-gfc_conv_descriptor_span_get (gfc_desc));
+  tmp = gfc_conv_descriptor_sm_get (gfc_desc, idx);
   gfc_add_modify (&loop_body, gfc_get_cfi_dim_sm (cfi, idx), tmp);
 
   /* Generate loop.  */
diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index f1b50ea00b6b..4ac7ea0893c1 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -779,14 +779,17 @@ gfc_omp_clause_default_ctor (tree clause, tree decl, tree 
outer)
   gfc_add_modify (&cond_block, decl, outer);
   tree rank = gfc_rank_cst[GFC_TYPE_ARRAY_RANK (type) - 1];
   size = gfc_conv_descriptor_extent_get (decl, rank);
-  if (GFC_TYPE_ARRAY_RANK (type) > 1)
+  if (GFC_TYPE_ARRAY_RANK (type) >= 1)
size = fold_build2_loc (input_location, MULT_EXPR,
gfc_array_index_type, size,
-   gfc_conv_descriptor_stride_get (decl, rank));
-  tree esize = fold_convert (gfc_array_index_type,
-TYPE_SIZE_UNIT (gfc_get_element_type (type)));
-  size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
- size, esize);
+   gfc_conv_descriptor_sm_get (decl, rank));
+  else
+   {
+ tree esize = gfc_conv_descriptor_span_get (decl);
+ esize = fold_convert_loc (input_location, gfc_array_index_type, 
esize);
+ size = fold_build2_loc (input_location, MULT_EXPR, 
gfc_array_index_type,
+ size, esize);
+   }
   size = unshare_expr (size);
   size = gfc_evaluate_now (fold_convert (size_type_node, size),
   &cond_block);
@@ -965,14 +968,17 @@ gfc_omp_clause_copy_ctor (tree clause, tree dest, tree 
src)
 {
   tree rank = gfc_rank_cst[GFC_TYPE_ARRAY_RANK (type) - 1];
   size = gfc_conv_descriptor_extent_get (dest, rank);
-  if (GFC_TYPE_ARRAY_RANK (type) > 1)
+  if (GFC_TYPE_ARRAY_RANK (type) >= 1)
size = fold_build2_loc (input_location, MULT_EXPR,
gfc_array_index_type, size,
-   gfc_conv_descriptor_stride_get (dest, rank));
-  tree esize = fold_convert (gfc_array_index_type,
-TYPE_SIZE_UNIT (gfc_get_element_type (type)));
-  size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
- size, esize);
+   gfc_conv_descriptor_sm_get (dest, rank));
+  else
+   {
+ tree esize = gfc_conv_descriptor_span_get (dest);
+ esize = fold_convert_loc (input_location, gfc_array_index_type, 
esize);
+ size = fold_build2_loc (input_location, MULT_EXPR, 
gfc_array_index_type,
+ size, esize);
+   }
   size = unshare_expr (size);
   size = gfc_evaluate_now (fold_convert (size_type_node, size),
   &cond_block);
@@ -1083,14 +1089,17 @@ gfc_omp_clause_assign_op (tree clause, tree dest, tree 
src)
 {
   tree rank = gfc_rank_cst[GFC_TYPE_ARRAY_RANK (type) - 1];
   size = gfc_conv_descriptor_extent_get (src, rank);
-  if (GFC_TYPE_ARRAY_RANK (type) > 1)
+  if (GFC_TYPE_ARRAY_RANK (type) >= 1)
size = fold_build2_loc (input_location, MULT_EXPR,
gfc_array_index_type, size,
-   gfc_conv_descriptor_stride_get (src, rank));
-  tree esize = fold_convert (gfc_array_index_type,
-TYPE_SIZE_UNIT (gfc_get_element_type (type)));
-  size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
- size, esize);
+   gfc_conv_descriptor_sm_get (src, rank));
+  else
+   {
+ tree esize = gfc_conv_descriptor_span_get (src);
+ esize = fold_convert_loc (input_location, gfc_array_index_type, 
esize);
+

[gcc(refs/users/mikael/heads/refactor_descriptor_v04)] Suppression export gfc_conv_descriptor_span_set

2025-03-30 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:8410cda2b70228d358313cbacc0fe404c91b3ad2

commit 8410cda2b70228d358313cbacc0fe404c91b3ad2
Author: Mikael Morin 
Date:   Sat Mar 29 11:41:45 2025 +0100

Suppression export gfc_conv_descriptor_span_set

Diff:
---
 gcc/fortran/trans-descriptor.cc | 2 +-
 gcc/fortran/trans-descriptor.h  | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index bc2055bf3b56..7e709609435c 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -721,7 +721,7 @@ gfc_conv_descriptor_span_get (tree desc)
   return gfc_descriptor::conv_span_get (desc);
 }
 
-void
+static void
 gfc_conv_descriptor_span_set (stmtblock_t *block, tree desc, tree value)
 {
   return gfc_descriptor::conv_span_set (block, desc, value);
diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h
index 5e8af26d1d8e..b991d2a41895 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -64,7 +64,6 @@ void gfc_conv_descriptor_dtype_set (stmtblock_t *, tree, 
tree);
 void gfc_conv_descriptor_version_set (stmtblock_t *, tree, tree);
 void gfc_conv_descriptor_rank_set (stmtblock_t *, tree, tree);
 void gfc_conv_descriptor_rank_set (stmtblock_t *, tree, int);
-void gfc_conv_descriptor_span_set (stmtblock_t *, tree, tree);
 void gfc_conv_descriptor_ubound_set (stmtblock_t *, tree, tree, tree);
 
 /* CFI descriptor.  */


[gcc(refs/users/mikael/heads/refactor_descriptor_v04)] Réduction usages gfc_conv_descriptor_ubound_get

2025-03-30 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:f7eac82b031e7eaabc88f4a07941f0b22b725105

commit f7eac82b031e7eaabc88f4a07941f0b22b725105
Author: Mikael Morin 
Date:   Sat Mar 29 15:26:26 2025 +0100

Réduction usages gfc_conv_descriptor_ubound_get

Correction régression PR96727.f90

correction ff-descriptor_6.f90

Mise à jour dump coarray_lock_7.f90

Diff:
---
 gcc/fortran/trans-array.cc   | 48 +++-
 gcc/fortran/trans-decl.cc|  6 +---
 gcc/fortran/trans-expr.cc|  3 +-
 gcc/fortran/trans-intrinsic.cc   | 44 +++--
 gcc/fortran/trans-openmp.cc  | 38 --
 gcc/fortran/trans-stmt.cc| 10 +++---
 gcc/testsuite/gfortran.dg/coarray_lock_7.f90 |  4 +--
 7 files changed, 38 insertions(+), 115 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 0cda02d7cefc..595ba97aa8ca 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -6523,8 +6523,7 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree 
tmpdesc,
   tree stmtInit, stmtCleanup;
   tree lbound;
   tree ubound;
-  tree dubound;
-  tree dlbound;
+  tree dextent;
   tree dumdesc;
   tree tmp;
   tree stride, stride2;
@@ -6658,16 +6657,10 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree 
tmpdesc,
   for (n = 0; n < as->rank; n++)
 {
   if (checkparm || !as->upper[n])
-   {
- /* Get the bounds of the actual parameter.  */
- dubound = gfc_conv_descriptor_ubound_get (dumdesc, gfc_rank_cst[n]);
- dlbound = gfc_conv_descriptor_lbound_get (dumdesc, gfc_rank_cst[n]);
-   }
+   /* Get the bounds of the actual parameter.  */
+   dextent = gfc_conv_descriptor_extent_get (dumdesc, gfc_rank_cst[n]);
   else
-   {
- dubound = NULL_TREE;
- dlbound = NULL_TREE;
-   }
+   dextent = NULL_TREE;
 
   lbound = GFC_TYPE_ARRAY_LBOUND (type, n);
   if (!INTEGER_CST_P (lbound))
@@ -6707,12 +6700,7 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree 
tmpdesc,
  temp = fold_build2_loc (input_location, PLUS_EXPR,
  gfc_array_index_type,
  gfc_index_one_node, temp);
- stride2 = fold_build2_loc (input_location, MINUS_EXPR,
-gfc_array_index_type, dubound,
-dlbound);
- stride2 = fold_build2_loc (input_location, PLUS_EXPR,
-gfc_array_index_type,
-gfc_index_one_node, stride2);
+ stride2 = dextent;
  tmp = fold_build2_loc (input_location, NE_EXPR,
 gfc_array_index_type, temp, stride2);
  msg = xasprintf ("Dimension %d of array '%s' has extent "
@@ -6730,7 +6718,8 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree 
tmpdesc,
  /* For assumed shape arrays move the upper bound by the same amount
 as the lower bound.  */
  tmp = fold_build2_loc (input_location, MINUS_EXPR,
-gfc_array_index_type, dubound, dlbound);
+gfc_array_index_type, dextent,
+gfc_index_one_node);
  tmp = fold_build2_loc (input_location, PLUS_EXPR,
 gfc_array_index_type, tmp, lbound);
  gfc_add_modify (&init, ubound, tmp);
@@ -7794,13 +7783,7 @@ gfc_tree_array_size (stmtblock_t *block, tree desc, 
gfc_expr *expr, tree dim)
 {
   if (!dim)
dim = gfc_index_zero_node;
-  tree ubound = gfc_conv_descriptor_ubound_get (desc, dim);
-  tree lbound = gfc_conv_descriptor_lbound_get (desc, dim);
-
-  size = fold_build2_loc (input_location, MINUS_EXPR,
- gfc_array_index_type, ubound, lbound);
-  size = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
- size, gfc_index_one_node);
+  size = gfc_conv_descriptor_extent_get (desc, dim);
   /* if (!allocatable && !pointer && assumed rank)
   size = (idx == rank && ubound[rank-1] == -1 ? -1 : size;
 else
@@ -7861,11 +7844,7 @@ gfc_tree_array_size (stmtblock_t *block, tree desc, 
gfc_expr *expr, tree dim)
   cond = fold_build2_loc (input_location, TRUTH_AND_EXPR, 
boolean_type_node,
  cond, tmp);
 }
-  tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
-gfc_conv_descriptor_ubound_get (desc, idx),
-gfc_conv_descriptor_lbound_get (desc, idx));
-  tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
-tmp, gfc_index_one_node);
+  tmp = gfc_conv_descriptor_extent_get (desc, idx);
   gfc_add_modify (&cond_block, extent

[gcc(refs/users/mikael/heads/refactor_descriptor_v04)] Suppression déclarations inutiles.

2025-03-30 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:53867f6799c9b3dacae90f27a0afd6b9fcc8edd0

commit 53867f6799c9b3dacae90f27a0afd6b9fcc8edd0
Author: Mikael Morin 
Date:   Mon Mar 17 20:21:04 2025 +0100

Suppression déclarations inutiles.

Diff:
---
 gcc/fortran/trans-descriptor.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h
index 5db80f59a528..5e8af26d1d8e 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -61,13 +61,10 @@ tree gfc_conv_descriptor_token_field (tree);
 void gfc_conv_descriptor_data_set (stmtblock_t *, tree, tree);
 void gfc_conv_descriptor_token_set (stmtblock_t *, tree, tree);
 void gfc_conv_descriptor_dtype_set (stmtblock_t *, tree, tree);
-void gfc_conv_descriptor_dimensions_set (stmtblock_t *, tree, tree);
 void gfc_conv_descriptor_version_set (stmtblock_t *, tree, tree);
 void gfc_conv_descriptor_rank_set (stmtblock_t *, tree, tree);
 void gfc_conv_descriptor_rank_set (stmtblock_t *, tree, int);
 void gfc_conv_descriptor_span_set (stmtblock_t *, tree, tree);
-void gfc_conv_descriptor_stride_set (stmtblock_t *, tree, tree, tree);
-void gfc_conv_descriptor_lbound_set (stmtblock_t *, tree, tree, tree);
 void gfc_conv_descriptor_ubound_set (stmtblock_t *, tree, tree, tree);
 
 /* CFI descriptor.  */


[gcc r14-11477] Fix type compatibility for types with flexible array member 1/2 [PR113688, PR114713, PR117724]

2025-03-30 Thread Martin Uecker via Gcc-cvs
https://gcc.gnu.org/g:450dc448eabaaf14a3401788028049b27991213c

commit r14-11477-g450dc448eabaaf14a3401788028049b27991213c
Author: Martin Uecker 
Date:   Mon Dec 9 12:07:57 2024 +0100

Fix type compatibility for types with flexible array member 1/2 
[PR113688,PR114713,PR117724]

Allow the TYPE_MODE of a type with an array as last member to differ from
another compatible type.

gcc/ChangeLog:
* tree.cc (gimple_canonical_types_compatible_p): Add exception.
(verify_type): Add exception.

gcc/lto/ChangeLog:
* lto-common.cc (hash_canonical_type): Add exception.

(cherry picked from commit 1f48225a0ddfaf74a229105343b22f3086c4b8cb)

Diff:
---
 gcc/lto/lto-common.cc |  3 ++-
 gcc/tree.cc   | 12 +---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/gcc/lto/lto-common.cc b/gcc/lto/lto-common.cc
index 2ce94cc32828..f6e08b51dcaf 100644
--- a/gcc/lto/lto-common.cc
+++ b/gcc/lto/lto-common.cc
@@ -254,7 +254,8 @@ hash_canonical_type (tree type)
  checked.  */
   code = tree_code_for_canonical_type_merging (TREE_CODE (type));
   hstate.add_int (code);
-  hstate.add_int (TYPE_MODE (type));
+  if (!RECORD_OR_UNION_TYPE_P (type))
+hstate.add_int (TYPE_MODE (type));
 
   /* Incorporate common features of numerical types.  */
   if (INTEGRAL_TYPE_P (type)
diff --git a/gcc/tree.cc b/gcc/tree.cc
index d716d7ccfe31..f202187754a6 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -13846,8 +13846,11 @@ gimple_canonical_types_compatible_p (const_tree t1, 
const_tree t2,
   || TREE_CODE (t1) == NULLPTR_TYPE)
 return true;
 
-  /* Can't be the same type if they have different mode.  */
-  if (TYPE_MODE (t1) != TYPE_MODE (t2))
+  /* Can't be compatible types if they have different mode.  Because of
+ flexible array members, we allow mismatching modes for structures or
+ unions.  */
+  if (!RECORD_OR_UNION_TYPE_P (t1)
+  && TYPE_MODE (t1) != TYPE_MODE (t2))
 return false;
 
   /* Non-aggregate types can be handled cheaply.  */
@@ -14150,8 +14153,11 @@ verify_type (const_tree t)
   debug_tree (ct);
   error_found = true;
 }
-
   if (COMPLETE_TYPE_P (t) && TYPE_CANONICAL (t)
+  /* We allow a mismatch for structure or union because of
+flexible array members.  */
+  && !RECORD_OR_UNION_TYPE_P (t)
+  && !RECORD_OR_UNION_TYPE_P (TYPE_CANONICAL (t))
   && TYPE_MODE (t) != TYPE_MODE (TYPE_CANONICAL (t)))
 {
   error ("% of % is not compatible");


[gcc r14-11478] Fix type compatibility for types with flexible array member 2/2 [PR113688, PR114713, PR117724]

2025-03-30 Thread Martin Uecker via Gcc-cvs
https://gcc.gnu.org/g:73549be0a3c819b2ab78e0e973f5b4d41b9f4a2d

commit r14-11478-g73549be0a3c819b2ab78e0e973f5b4d41b9f4a2d
Author: Martin Uecker 
Date:   Sat Nov 23 08:04:05 2024 +0100

Fix type compatibility for types with flexible array member 2/2 
[PR113688,PR114713,PR117724]

For checking or computing TYPE_CANONICAL, ignore the array size when it is
the last element of a structure or union.  To not get errors because of
an inconsistent number of members, zero-sized arrays which are the last
element are not ignored anymore when checking the fields of a struct.

PR c/113688
PR c/114014
PR c/114713
PR c/117724

gcc/ChangeLog:
* tree.cc (gimple_canonical_types_compatible_p): Add exception.

gcc/lto/ChangeLog:
* lto-common.cc (hash_canonical_type): Add exception.

gcc/testsuite/ChangeLog:
* gcc.dg/pr113688.c: New test.
* gcc.dg/pr114014.c: New test.
* gcc.dg/pr114713.c: New test.
* gcc.dg/pr117724.c: New test.

(cherry picked from commit d46c7f313b5a30ee04080f249e31e12987d50aa2)

Diff:
---
 gcc/lto/lto-common.cc   |  6 +-
 gcc/testsuite/gcc.dg/pr113688.c |  8 
 gcc/testsuite/gcc.dg/pr114014.c | 14 ++
 gcc/testsuite/gcc.dg/pr114713.c | 35 +++
 gcc/testsuite/gcc.dg/pr117724.c | 16 
 gcc/tree.cc | 37 ++---
 6 files changed, 108 insertions(+), 8 deletions(-)

diff --git a/gcc/lto/lto-common.cc b/gcc/lto/lto-common.cc
index f6e08b51dcaf..7697a7d6ea02 100644
--- a/gcc/lto/lto-common.cc
+++ b/gcc/lto/lto-common.cc
@@ -333,7 +333,11 @@ hash_canonical_type (tree type)
&& (! DECL_SIZE (f)
|| ! integer_zerop (DECL_SIZE (f
  {
-   iterative_hash_canonical_type (TREE_TYPE (f), hstate);
+   tree t = TREE_TYPE (f);
+   if (!TREE_CHAIN (f)
+   && TREE_CODE (t) == ARRAY_TYPE)
+ t = TREE_TYPE  (t);
+   iterative_hash_canonical_type (t, hstate);
nf++;
  }
 
diff --git a/gcc/testsuite/gcc.dg/pr113688.c b/gcc/testsuite/gcc.dg/pr113688.c
new file mode 100644
index ..8dee8c86f1bf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr113688.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-g" } */
+
+struct S{int x,y[1];}*a;
+int main(void){
+   struct S{int x,y[];};
+}
+
diff --git a/gcc/testsuite/gcc.dg/pr114014.c b/gcc/testsuite/gcc.dg/pr114014.c
new file mode 100644
index ..1531ffab1b75
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr114014.c
@@ -0,0 +1,14 @@
+/* PR c/114014
+ * { dg-do compile }
+ * { dg-options "-std=gnu23 -g" } */
+
+struct r {
+  int a;
+  char b[];
+};
+struct r {
+  int a;
+  char b[0];
+};
+
+
diff --git a/gcc/testsuite/gcc.dg/pr114713.c b/gcc/testsuite/gcc.dg/pr114713.c
new file mode 100644
index ..78e3237de948
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr114713.c
@@ -0,0 +1,35 @@
+/* { dg-do run } */
+/* { dg-require-effective-target lto } */
+/* { dg-options "-std=c23 -flto -O2" } */
+
+struct foo { int x; char a[]; };
+
+void test_bar(void* b);
+
+__attribute__((noinline))
+int test_foo(struct foo* a, void* b)
+{
+a->x = 1;
+test_bar(b);
+return a->x;
+}
+
+int main()
+{
+struct foo y;
+
+if (2 != test_foo(&y, &y))
+__builtin_abort();
+
+return 0;
+}
+
+// TU2
+struct foo { int x; char a[0]; };
+
+void test_bar(void* b)
+{
+struct foo *p = b;
+p->x = 2;
+}
+
diff --git a/gcc/testsuite/gcc.dg/pr117724.c b/gcc/testsuite/gcc.dg/pr117724.c
new file mode 100644
index ..d631daeb644d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr117724.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-g" } */
+
+struct {
+  unsigned long len;
+  unsigned long size;
+  char data[];
+}; /* { dg-warning "unnamed struct" } */
+struct {
+  struct {
+unsigned long len;
+unsigned long size;
+char data[6];
+  };
+}; /* { dg-warning "unnamed struct" } */
+
diff --git a/gcc/tree.cc b/gcc/tree.cc
index f202187754a6..a4c62e1f0681 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -13901,7 +13901,7 @@ gimple_canonical_types_compatible_p (const_tree t1, 
const_tree t2,
 {
 case ARRAY_TYPE:
   /* Array types are the same if the element types are the same and
-the number of elements are the same.  */
+minimum and maximum index are the same.  */
   if (!gimple_canonical_types_compatible_p (TREE_TYPE (t1), TREE_TYPE (t2),
trust_type_canonical)
  || TYPE_STRING_FLAG (t1) != TYPE_STRING_FLAG (t2)
@@ -13995,23 +13995,46 @@ gimple_canonical_types_compatible_p (const_tree t1, 
const_tree t2,
 f1 || f2;
 f1 = TREE_CHAIN (f1), f2 = TREE_C

[gcc r15-9036] Alpha: Add option to avoid data races for sub-longword memory stores [PR117759]

2025-03-30 Thread Maciej W. Rozycki via Gcc-cvs
https://gcc.gnu.org/g:3d4d82211c8cbfde0b852bde1603b5d549426df7

commit r15-9036-g3d4d82211c8cbfde0b852bde1603b5d549426df7
Author: Maciej W. Rozycki 
Date:   Sun Mar 30 15:24:50 2025 +0100

Alpha: Add option to avoid data races for sub-longword memory stores 
[PR117759]

With non-BWX Alpha implementations we have a problem of data races where
a 8-bit byte or 16-bit word quantity is to be written to memory in that
in those cases we use an unprotected RMW access of a 32-bit longword or
64-bit quadword width.  If contents of the longword or quadword accessed
outside the byte or word to be written are changed midway through by a
concurrent write executing on the same CPU such as by a signal handler
or a parallel write executing on another CPU such as by another thread
or via a shared memory segment, then the concluding write of the RMW
access will clobber them.  This is especially important for the safety
of RCU algorithms, but is otherwise an issue anyway.

To guard against these data races with byte and aligned word quantities
introduce the `-msafe-bwa' command-line option (standing for Safe Byte &
Word Access) that instructs the compiler to instead use an atomic RMW
access sequence where byte and word memory access machine instructions
are not available.  There is no change to code produced for BWX targets.

It would be sufficient for the secondary reload handle to use a pair of
scratch registers, as requested by `reload_out', but it would end
with poor code produced as one of the scratches would be occupied by
data retrieved and the other one would have to be reloaded with repeated
calculations, all within the LL/SC sequence.

Therefore I chose to add a dedicated `reload_out_safe_bwa' handler
and ask for more scratches there by defining a 256-bit OI integer mode.
While reload is documented in our manual to support an arbitrary number
of scratches in reality it hasn't been implemented for IRA:

/* ??? It would be useful to be able to handle only two, or more than
   three, operands, but for now we can only handle the case of having
   exactly three: output, input and one temp/scratch.  */

and it seems to be the case for LRA as well.  Do what everyone else does
then and just have one wide multi-register scratch.

I note that the atomic sequences emitted are suboptimal performance-wise
as the looping branch for the unsuccessful completion of the sequence
points backwards, which means it will be predicted as taken despite that
in most cases it will fall through.  I do not see it as a deficiency of
this change proposed as it takes care of recording that the branch is
unlikely to be taken, by calling `alpha_emit_unlikely_jump'.  Therefore
generic code elsewhere should instead be investigated and adjusted
accordingly for the arrangement to actually take effect.

Add test cases accordingly.

There are notable regressions between a plain `-mno-bwx' configuration
and a `-mno-bwx -msafe-bwa' one:

FAIL: gcc.dg/torture/inline-mem-cpy-cmp-1.c   -O0  execution test
FAIL: gcc.dg/torture/inline-mem-cpy-cmp-1.c   -O1  execution test
FAIL: gcc.dg/torture/inline-mem-cpy-cmp-1.c   -O2  execution test
FAIL: gcc.dg/torture/inline-mem-cpy-cmp-1.c   -O3 -g  execution test
FAIL: gcc.dg/torture/inline-mem-cpy-cmp-1.c   -Os  execution test
FAIL: gcc.dg/torture/inline-mem-cpy-cmp-1.c   -O2 -flto 
-fno-use-linker-plugin -flto-partition=none  execution test
FAIL: gcc.dg/torture/inline-mem-cpy-cmp-1.c   -O2 -flto -fuse-linker-plugin 
-fno-fat-lto-objects  execution test
FAIL: g++.dg/init/array25.C  -std=c++17 execution test
FAIL: g++.dg/init/array25.C  -std=c++98 execution test
FAIL: g++.dg/init/array25.C  -std=c++26 execution test

They come from the fact that these test cases play tricks with alignment
and end up calling code that expects a reference to aligned data but is
handed one to unaligned data.

This doesn't cause a visible problem with plain `-mno-bwx' code, because
the resulting alignment exception is fixed up by Linux.  There's no such
handling currently implemented for LDL_L or LDQ_L instructions (which
are first in the sequence) and consequently the offender is issued with
SIGBUS instead.  Suitable handling will be added to Linux to complement
this change that will emulate the trapping instructions[1], so these
interim regressions are seen as harmless and expected.

References:

[1] "Alpha: Emulate unaligned LDx_L/STx_C for data consistency",



gcc/
PR target/117759
* config/alpha/alpha-modes.def (OI): New integer mode.
* config/alpha/alpha-protos.h (alpha_expand_mov_safe_bwa): N

[gcc r15-9034] Alpha: Export `emit_unlikely_jump' for a subsequent change to use

2025-03-30 Thread Maciej W. Rozycki via Gcc-cvs
https://gcc.gnu.org/g:47a48c7f42b5ad908f087bf612615632319cf445

commit r15-9034-g47a48c7f42b5ad908f087bf612615632319cf445
Author: Maciej W. Rozycki 
Date:   Sun Mar 30 15:24:50 2025 +0100

Alpha: Export `emit_unlikely_jump' for a subsequent change to use

Rename `emit_unlikely_jump' function to `alpha_emit_unlikely_jump', so
as to avoid namespace pollution, updating callers accordingly and export
it for use in the machine description.  Make it return the insn emitted.

gcc/
* config/alpha/alpha-protos.h (alpha_emit_unlikely_jump): New
prototype.
* config/alpha/alpha.cc (emit_unlikely_jump): Rename to...
(alpha_emit_unlikely_jump): ... this.  Return the insn emitted.
(alpha_split_atomic_op, alpha_split_compare_and_swap)
(alpha_split_compare_and_swap_12, alpha_split_atomic_exchange)
(alpha_split_atomic_exchange_12): Update call sites accordingly.

Diff:
---
 gcc/config/alpha/alpha-protos.h |  1 +
 gcc/config/alpha/alpha.cc   | 19 ++-
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/gcc/config/alpha/alpha-protos.h b/gcc/config/alpha/alpha-protos.h
index 1bc5520e5d55..6d28fa88ecf9 100644
--- a/gcc/config/alpha/alpha-protos.h
+++ b/gcc/config/alpha/alpha-protos.h
@@ -59,6 +59,7 @@ extern rtx alpha_expand_zap_mask (HOST_WIDE_INT);
 extern void alpha_expand_builtin_vector_binop (rtx (*)(rtx, rtx, rtx),
   machine_mode,
   rtx, rtx, rtx);
+extern rtx alpha_emit_unlikely_jump (rtx, rtx);
 extern void alpha_expand_builtin_establish_vms_condition_handler (rtx, rtx);
 extern void alpha_expand_builtin_revert_vms_condition_handler (rtx);
 
diff --git a/gcc/config/alpha/alpha.cc b/gcc/config/alpha/alpha.cc
index 6965ece16d0b..d3e8a3a9756e 100644
--- a/gcc/config/alpha/alpha.cc
+++ b/gcc/config/alpha/alpha.cc
@@ -4421,12 +4421,13 @@ alpha_expand_builtin_vector_binop (rtx (*gen) (rtx, 
rtx, rtx),
 /* A subroutine of the atomic operation splitters.  Jump to LABEL if
COND is true.  Mark the jump as unlikely to be taken.  */
 
-static void
-emit_unlikely_jump (rtx cond, rtx label)
+rtx
+alpha_emit_unlikely_jump (rtx cond, rtx label)
 {
   rtx x = gen_rtx_IF_THEN_ELSE (VOIDmode, cond, label, pc_rtx);
   rtx_insn *insn = emit_jump_insn (gen_rtx_SET (pc_rtx, x));
   add_reg_br_prob_note (insn, profile_probability::very_unlikely ());
+  return insn;
 }
 
 /* Subroutines of the atomic operation splitters.  Emit barriers
@@ -4518,7 +4519,7 @@ alpha_split_atomic_op (enum rtx_code code, rtx mem, rtx 
val, rtx before,
   emit_insn (gen_store_conditional (mode, cond, mem, scratch));
 
   x = gen_rtx_EQ (DImode, cond, const0_rtx);
-  emit_unlikely_jump (x, label);
+  alpha_emit_unlikely_jump (x, label);
 
   alpha_post_atomic_barrier (model);
 }
@@ -4568,7 +4569,7 @@ alpha_split_compare_and_swap (rtx operands[])
   emit_insn (gen_rtx_SET (cond, x));
   x = gen_rtx_EQ (DImode, cond, const0_rtx);
 }
-  emit_unlikely_jump (x, label2);
+  alpha_emit_unlikely_jump (x, label2);
 
   emit_move_insn (cond, newval);
   emit_insn (gen_store_conditional
@@ -4577,7 +4578,7 @@ alpha_split_compare_and_swap (rtx operands[])
   if (!is_weak)
 {
   x = gen_rtx_EQ (DImode, cond, const0_rtx);
-  emit_unlikely_jump (x, label1);
+  alpha_emit_unlikely_jump (x, label1);
 }
 
   if (!is_mm_relaxed (mod_f))
@@ -4680,7 +4681,7 @@ alpha_split_compare_and_swap_12 (rtx operands[])
   emit_insn (gen_rtx_SET (cond, x));
   x = gen_rtx_EQ (DImode, cond, const0_rtx);
 }
-  emit_unlikely_jump (x, label2);
+  alpha_emit_unlikely_jump (x, label2);
 
   emit_insn (gen_mskxl (cond, scratch, mask, addr));
 
@@ -4692,7 +4693,7 @@ alpha_split_compare_and_swap_12 (rtx operands[])
   if (!is_weak)
 {
   x = gen_rtx_EQ (DImode, cond, const0_rtx);
-  emit_unlikely_jump (x, label1);
+  alpha_emit_unlikely_jump (x, label1);
 }
 
   if (!is_mm_relaxed (mod_f))
@@ -4732,7 +4733,7 @@ alpha_split_atomic_exchange (rtx operands[])
   emit_insn (gen_store_conditional (mode, cond, mem, scratch));
 
   x = gen_rtx_EQ (DImode, cond, const0_rtx);
-  emit_unlikely_jump (x, label);
+  alpha_emit_unlikely_jump (x, label);
 
   alpha_post_atomic_barrier (model);
 }
@@ -4806,7 +4807,7 @@ alpha_split_atomic_exchange_12 (rtx operands[])
   emit_insn (gen_store_conditional (DImode, scratch, mem, scratch));
 
   x = gen_rtx_EQ (DImode, scratch, const0_rtx);
-  emit_unlikely_jump (x, label);
+  alpha_emit_unlikely_jump (x, label);
 
   alpha_post_atomic_barrier (model);
 }


[gcc r15-9037] Alpha: Add option to avoid data races for partial writes [PR117759]

2025-03-30 Thread Maciej W. Rozycki via Gcc-cvs
https://gcc.gnu.org/g:1b85c548e2480116c74a7f74b487e3787c770056

commit r15-9037-g1b85c548e2480116c74a7f74b487e3787c770056
Author: Maciej W. Rozycki 
Date:   Sun Mar 30 15:24:51 2025 +0100

Alpha: Add option to avoid data races for partial writes [PR117759]

Similarly to data races with 8-bit byte or 16-bit word quantity memory
writes on non-BWX Alpha implementations we have the same problem even on
BWX implementations with partial memory writes produced for unaligned
stores as well as block memory move and clear operations.  This happens
at the boundaries of the area written where we produce unprotected RMW
sequences, such as for example:

ldbu $1,0($3)
stw $31,8($3)
stq $1,0($3)

to zero a 9-byte member at the byte offset of 1 of a quadword-aligned
struct, happily clobbering a 1-byte member at the beginning of said
struct if concurrent write happens while executing on the same CPU such
as in a signal handler or a parallel write happens while executing on
another CPU such as in another thread or via a shared memory segment.

To guard against these data races with partial memory write accesses
introduce the `-msafe-partial' command-line option that instructs the
compiler to protect boundaries of the data quantity accessed by instead
using a longer code sequence composed of narrower memory writes where
suitable machine instructions are available (i.e. with BWX targets) or
atomic RMW access sequences where byte and word memory access machine
instructions are not available (i.e. with non-BWX targets).

Owing to the desire of branch avoidance there are redundant overlapping
writes in unaligned cases where STQ_U operations are used in the middle
of a block so as to make sure no part of data to be written has been
lost regardless of run-time alignment.  For the non-BWX case it means
that with blocks whose size is not a multiple of 8 there are additional
atomic RMW sequences issued towards the end of the block in addition to
the always required pair enclosing the block from each end.

Only one such additional atomic RMW sequence is actually required, but
code currently issues two for the sake of simplicity.  An improvement
might be added to `alpha_expand_unaligned_store_words_safe_partial' in
the future, by folding `alpha_expand_unaligned_store_safe_partial' code
for handling multi-word blocks whose size is not a multiple of 8 (i.e.
with a trailing partial-word part).  It would improve performance a bit,
but current code is correct regardless.

Update test cases with `-mno-safe-partial' where required and add new
ones accordingly.

In some cases GCC chooses to open-code block memory write operations, so
with non-BWX targets `-msafe-partial' will in the usual case have to be
used together with `-msafe-bwa'.

Credit to Magnus Lindholm  for sharing hardware for
the purpose of verifying the BWX side of this change.

gcc/
PR target/117759
* config/alpha/alpha-protos.h
(alpha_expand_unaligned_store_safe_partial): New prototype.
* config/alpha/alpha.cc (alpha_expand_movmisalign)
(alpha_expand_block_move, alpha_expand_block_clear): Handle
TARGET_SAFE_PARTIAL.
(alpha_expand_unaligned_store_safe_partial)
(alpha_expand_unaligned_store_words_safe_partial)
(alpha_expand_clear_safe_partial_nobwx): New functions.
* config/alpha/alpha.md (insvmisaligndi): Handle
TARGET_SAFE_PARTIAL.
* config/alpha/alpha.opt (msafe-partial): New option.
* config/alpha/alpha.opt.urls: Regenerate.
* doc/invoke.texi (Option Summary, DEC Alpha Options): Document
the new option.

gcc/testsuite/
PR target/117759
* gcc.target/alpha/memclr-a2-o1-c9-ptr.c: Add
`-mno-safe-partial'.
* gcc.target/alpha/memclr-a2-o1-c9-ptr-safe-partial.c: New file.
* gcc.target/alpha/memcpy-di-unaligned-dst.c: New file.
* gcc.target/alpha/memcpy-di-unaligned-dst-safe-partial.c: New
file.
* gcc.target/alpha/memcpy-di-unaligned-dst-safe-partial-bwx.c:
New file.
* gcc.target/alpha/memcpy-si-unaligned-dst.c: New file.
* gcc.target/alpha/memcpy-si-unaligned-dst-safe-partial.c: New
file.
* gcc.target/alpha/memcpy-si-unaligned-dst-safe-partial-bwx.c:
New file.
* gcc.target/alpha/stlx0.c: Add `-mno-safe-partial'.
* gcc.target/alpha/stlx0-safe-partial.c: New file.
* gcc.target/alpha/stlx0-safe-partial-bwx.c: New file.
* gcc.target/alpha/stqx0.c: Add `-mno-safe-partial'.
* gcc.target/alpha/stqx0-safe-partial.c: New file.
  

[gcc r15-9045] Doc: Move Integer Overflow Builtins section [PR42270]

2025-03-30 Thread Sandra Loosemore via Gcc-cvs
https://gcc.gnu.org/g:7af7e80d859da9a2c0f6d228b8489e0bd8c0e61c

commit r15-9045-g7af7e80d859da9a2c0f6d228b8489e0bd8c0e61c
Author: Sandra Loosemore 
Date:   Wed Mar 26 16:43:18 2025 +

Doc: Move Integer Overflow Builtins section [PR42270]

This is part of an incremental effort to make the chapter on GCC
extensions better organized by grouping/rearranging sections by topic.

gcc/ChangeLog
PR other/42270
* doc/extend.texi (Numeric Builtins): Move Integer Overflow Builtins
section here, as a subsection.

Diff:
---
 gcc/doc/extend.texi | 303 ++--
 1 file changed, 153 insertions(+), 150 deletions(-)

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index de9c2b36ba38..f0bbff6dd042 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -14244,8 +14244,6 @@ a function call results in a compile-time error.
 * Stack Scrubbing:: Stack scrubbing internal interfaces.
 * Vector Extensions::   Using vector instructions through built-in functions.
 * Atomic Memory Access:: __atomic and __sync builtins.
-* Integer Overflow Builtins:: Built-in functions to perform arithmetics and
-arithmetic overflow checking.
 * Object Size Checking:: Built-in functions for limited buffer overflow
 checking.
 * New/Delete Builtins:: Built-in functions for C++ allocations and 
deallocations.
@@ -14831,6 +14829,8 @@ floating-point or integer operand.
 * Bit Operation Builtins:: Counting bits and similar functions.
 * Byte-Swapping Builtins:: Reversing byte order.
 * CRC Builtins::   Compute cyclic redundancy checks.
+* Integer Overflow Builtins::  Built-in functions to perform arithmetics
+   and arithmetic overflow checking.
 @end menu
 
 @node Floating-Point Format Builtins
@@ -15445,6 +15445,157 @@ Similar to @code{__builtin_crc64_data64}, except the 
@var{data} argument type
 is 32-bit.
 @enddefbuiltin
 
+@node Integer Overflow Builtins
+@subsection Built-in Functions to Perform Arithmetic with Overflow Checking
+@cindex overflow checking builtins
+@cindex integer arithmetic overflow checking builtins
+@cindex builtins for arithmetic overflow checking
+
+The following built-in functions allow performing simple arithmetic operations
+together with checking whether the operations overflowed.
+
+@defbuiltin{bool __builtin_add_overflow (@var{type1} @var{a}, @var{type2} 
@var{b}, @var{type3} *@var{res})}
+@defbuiltinx{bool __builtin_sadd_overflow (int @var{a}, int @var{b}, int 
*@var{res})}
+@defbuiltinx{bool __builtin_saddl_overflow (long int @var{a}, long int 
@var{b}, long int *@var{res})}
+@defbuiltinx{bool __builtin_saddll_overflow (long long int @var{a}, long long 
int @var{b}, long long int *@var{res})}
+@defbuiltinx{bool __builtin_uadd_overflow (unsigned int @var{a}, unsigned int 
@var{b}, unsigned int *@var{res})}
+@defbuiltinx{bool __builtin_uaddl_overflow (unsigned long int @var{a}, 
unsigned long int @var{b}, unsigned long int *@var{res})}
+@defbuiltinx{bool __builtin_uaddll_overflow (unsigned long long int @var{a}, 
unsigned long long int @var{b}, unsigned long long int *@var{res})}
+
+These built-in functions promote the first two operands into infinite 
precision signed
+type and perform addition on those promoted operands.  The result is then
+cast to the type the third pointer argument points to and stored there.
+If the stored result is equal to the infinite precision result, the built-in
+functions return @code{false}, otherwise they return @code{true}.  As the 
addition is
+performed in infinite signed precision, these built-in functions have fully 
defined
+behavior for all argument values.
+
+The first built-in function allows arbitrary integral types for operands and
+the result type must be pointer to some integral type other than enumerated or
+boolean type, the rest of the built-in functions have explicit integer types.
+
+The compiler will attempt to use hardware instructions to implement
+these built-in functions where possible, like conditional jump on overflow
+after addition, conditional jump on carry etc.
+
+@enddefbuiltin
+
+@defbuiltin{bool __builtin_sub_overflow (@var{type1} @var{a}, @var{type2} 
@var{b}, @var{type3} *@var{res})}
+@defbuiltinx{bool __builtin_ssub_overflow (int @var{a}, int @var{b}, int 
*@var{res})}
+@defbuiltinx{bool __builtin_ssubl_overflow (long int @var{a}, long int 
@var{b}, long int *@var{res})}
+@defbuiltinx{bool __builtin_ssubll_overflow (long long int @var{a}, long long 
int @var{b}, long long int *@var{res})}
+@defbuiltinx{bool __builtin_usub_overflow (unsigned int @var{a}, unsigned int 
@var{b}, unsigned int *@var{res})}
+@defbuiltinx{bool __builtin_usubl_overflow (unsigned long int @var{a}, 
unsigned long int @var{b}, unsigned long int *@var{res})}
+@defbuiltinx{bool __builtin_usubll_overflow (unsigned long long int @var{a}, 
unsigned long

[gcc r15-9042] Doc: Move builtin documentation to a new chapter [PR42270]

2025-03-30 Thread Sandra Loosemore via Gcc-cvs
https://gcc.gnu.org/g:1fb78f025f726e2268da142f07007b1fb0819fb1

commit r15-9042-g1fb78f025f726e2268da142f07007b1fb0819fb1
Author: Sandra Loosemore 
Date:   Tue Mar 25 05:25:34 2025 +

Doc: Move builtin documentation to a new chapter [PR42270]

This is part of an incremental effort to make the documentation for
GCC extensions better organized by grouping/rearranging sections by
topic.

I was originally intending to consolidate all the sections documenting
builtins as subsections of a new container section within the C
extensions chapter, but I ran into a technical limitation of Texinfo:
it only supports sectioning depth up to @subsubsection, and we already
had quite a few of those in the target-specific builtins sections.  So
instead I have pulled all the existing sections out into a new
chapter.  This actually makes sense since some of the builtins are
specific to C++ anyway and are not C language extensions at all.

Subsequent patches in this series will move things around within the
new chapter; this one just adds the new container node and adjusts
the menus.

gcc/ChangeLog
PR other/42270
* doc/extend.texi (C Extensions): Move menu items for
builtin-related sections to...
(Built-in Functions): New chapter.
* doc/gcc.texi (Introduction): Add menu entry for new chapter.

Diff:
---
 gcc/doc/extend.texi | 51 ---
 gcc/doc/gcc.texi|  1 +
 2 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 371e82a6852f..386b6b0f5b1d 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -36,21 +36,6 @@ extensions, accepted by GCC in C90 mode and in C++.
 * Using Assembly Language with C:: Instructions and extensions for interfacing 
C with assembler.
 * Syntax Extensions::   Other extensions to C syntax.
 * Semantic Extensions:: GNU C defines behavior for some non-standard 
constructs.
-* Nonlocal Gotos::  Built-ins for nonlocal gotos.
-* Constructing Calls::  Built-ins for dispatching a call to another function.
-* Return Address::  Getting the return or frame address of a function.
-* Stack Scrubbing:: Stack scrubbing internal interfaces.
-* Vector Extensions::   Using vector instructions through built-in functions.
-* __sync Builtins:: Legacy built-in functions for atomic memory access.
-* __atomic Builtins::   Atomic built-in functions with memory model.
-* Integer Overflow Builtins:: Built-in functions to perform arithmetics and
-arithmetic overflow checking.
-* x86 specific memory model extensions for transactional memory:: x86 memory 
models.
-* Object Size Checking:: Built-in functions for limited buffer overflow
-checking.
-* New/Delete Builtins:: Built-in functions for C++ allocations and 
deallocations.
-* Other Builtins::  Other built-in functions.
-* Target Builtins:: Built-in functions specific to particular targets.
 @end menu
 
 @node Additional Numeric Types
@@ -14217,6 +14202,42 @@ extension explicit.  Additionally, using @code{const} 
and
 @code{volatile} in this way is specific to GNU C and does not work in
 GNU C++.
 
+@node Built-in Functions
+@chapter Built-in Functions Provided by GCC
+@cindex Built-in Functions
+
+GCC provides a very large number of implicitly-declared built-in
+functions that are typically inlined by the compiler.  Some of these
+builtins directly correspond to standard library routines, while
+others provide the underlying functionality needed to implement
+features provided by library functions or similar ``glue'' between GCC
+and other programming languages or libraries.  Others are
+target-specific, providing direct access to instructions that have no
+direct C equivalents without the need to write assembly language.  There
+are also builtins to support various kinds of runtime error checking.
+
+Most builtins have names prefixed with @samp{__builtin_}.  Except as
+otherwise documented, all built-in functions are available from any
+of the C family languages supported by GCC.
+
+@menu
+* Nonlocal Gotos::  Built-ins for nonlocal gotos.
+* Constructing Calls::  Built-ins for dispatching a call to another function.
+* Return Address::  Getting the return or frame address of a function.
+* Stack Scrubbing:: Stack scrubbing internal interfaces.
+* Vector Extensions::   Using vector instructions through built-in functions.
+* __sync Builtins:: Legacy built-in functions for atomic memory access.
+* __atomic Builtins::   Atomic built-in functions with memory model.
+* Integer Overflow Builtins:: Built-in functions to perform arithmetics and
+arithmetic overflow checking.
+* x86 specific memory model extensions for transactional memory:: x86 memory 
models.
+* Object Size Checking:: Built-in functions for limited buffer 

[gcc r15-9041] Doc: Add a container section to consolidate attribute documentation [PR42270]

2025-03-30 Thread Sandra Loosemore via Gcc-cvs
https://gcc.gnu.org/g:1cfb1b58804859199bc2502ab35e08bfd0039040

commit r15-9041-g1cfb1b58804859199bc2502ab35e08bfd0039040
Author: Sandra Loosemore 
Date:   Tue Mar 25 02:56:48 2025 +

Doc: Add a container section to consolidate attribute documentation 
[PR42270]

This is part of an incremental effort to make the chapter on GCC
extensions better organized by grouping/rearranging sections by topic.
Note that this patch does not address the restructuring/rewrite
suggested by PR88472 or PR102397, beyond adding a very short
introduction to the new container section that is more explicit about
both syntaxes being accepted as a GNU extension.

gcc/ChangeLog
PR other/42270
* doc/extend.texi (Attributes): New section.
(Function Attributes): Make it a subsection of the new section.
(Variable Attributes): Likewise.
(Type Attributes): Likewise.
(Label Attributes): Likewise.
(Enumerator Attributes): Likewise.
(Attribute Syntax): Likewise.

Diff:
---
 gcc/doc/extend.texi | 174 ++--
 1 file changed, 101 insertions(+), 73 deletions(-)

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index e68b810c043b..371e82a6852f 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -26,14 +26,7 @@ extensions, accepted by GCC in C90 mode and in C++.
 * Additional Numeric Types::  Additional sizes and formats, plus complex 
numbers.
 * Aggregate Types::Extensions to arrays, structs, and unions.
 * Named Address Spaces::Named address spaces.
-* Function Attributes:: Declaring that functions have no side effects,
-or that they can never return.
-* Variable Attributes:: Specifying attributes of variables.
-* Type Attributes:: Specifying attributes of types.
-* Label Attributes::Specifying attributes on labels.
-* Enumerator Attributes:: Specifying attributes on enumerators.
-* Statement Attributes:: Specifying attributes on statements.
-* Attribute Syntax::Formal syntax for attributes.
+* Attributes::  GCC supports both standard and legacy attribute syntax.
 * Pragmas:: Pragmas accepted by GCC.
 * Thread-Local::Per-thread variables.
 * OpenMP::  Multiprocessing extensions.
@@ -1595,8 +1588,43 @@ The preprocessor symbols @code{__SEG_FS} and 
@code{__SEG_GS} are
 defined when these address spaces are supported.
 @end table
 
+@node Attributes
+@section Attributes Specific to GCC
+@cindex attributes
+@cindex declaring attributes
+@cindex GNU attributes
+
+Attributes provide a mechanism to declare additional properties of
+functions, variables, types, and statements.  For example, attributes
+can be used to control placement of objects in particular memory
+sections, or to specify properties that can allow the compiler to
+generate better code or diagnostics, such as declaring that a function
+never returns.  GCC supports a large number of such attributes, which
+are documented in this section.
+
+GCC provides two different ways to specify attributes: the traditional
+GNU syntax using @samp{__attribute__ ((...))} annotations, and the
+newer standard C and C++ syntax using @samp{[[...]]} with the
+@samp{gnu::} namespace prefix on attribute names.
+The traditional syntax, described in detail in @ref{Attribute Syntax},
+is supported in all non-strict C and C++ language dialects.
+The standard syntax is supported in C with @option{-std=c23} or later,
+in C++ with @option{-std=c++11} or later, and as an extension in older
+GNU C and C++ dialects.
+
+@menu
+* Function Attributes:: Declaring that functions have no side effects,
+or that they can never return.
+* Variable Attributes:: Specifying attributes of variables.
+* Type Attributes:: Specifying attributes of types.
+* Label Attributes::Specifying attributes on labels.
+* Enumerator Attributes:: Specifying attributes on enumerators.
+* Statement Attributes:: Specifying attributes on statements.
+* Attribute Syntax::Formal syntax for attributes.
+@end menu
+
 @node Function Attributes
-@section Declaring Attributes of Functions
+@subsection Declaring Attributes of Functions
 @cindex function attributes
 @cindex declaring attributes of functions
 
@@ -1698,7 +1726,7 @@ GCC plugins may provide their own attributes.
 @end menu
 
 @node Common Function Attributes
-@subsection Common Function Attributes
+@subsubsection Common Function Attributes
 
 The following attributes are supported on most targets.
 
@@ -3760,7 +3788,7 @@ The default for the attribute is controlled by 
@option{-fzero-call-used-regs}.
 @c This is the end of the target-independent attribute table
 
 @node AArch64 Function Attributes
-@subsection AArch64 Function Attributes
+@subsubsection AArch64 Function Attributes
 
 The following target-specific function attributes are available for the
 AArch

[gcc r15-9040] Doc: Remove separate "Target Format Checks" section [PR42270]

2025-03-30 Thread Sandra Loosemore via Gcc-cvs
https://gcc.gnu.org/g:991aa8f992a4f5ea6ebe1bd7aec61d3071c23b8f

commit r15-9040-g991aa8f992a4f5ea6ebe1bd7aec61d3071c23b8f
Author: Sandra Loosemore 
Date:   Tue Mar 25 05:22:38 2025 +

Doc: Remove separate "Target Format Checks" section [PR42270]

This is part of an incremental effort to make the chapter on GCC
extensions better organized by grouping/rearranging sections by topic.

Following the last round of patches, there's a leftover section
"Target Format Checks" that didn't fit into any category.  It seems best
to merge this material into the main discussion of the "format" attribute,
in particular because that discussion already contains similar discussion
for mingw/Windows targets.

gcc/ChangeLog
PR other/42270
* doc/extend.texi (Function Attributes): Merge text from "Target
Format Checks" into the main discussion of the format and
format_arg attributes.
(Target Format Checks): Delete section.

Diff:
---
 gcc/doc/extend.texi | 95 ++---
 1 file changed, 39 insertions(+), 56 deletions(-)

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index ed766e53dcc4..e68b810c043b 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -58,7 +58,6 @@ extensions, accepted by GCC in C90 mode and in C++.
 * New/Delete Builtins:: Built-in functions for C++ allocations and 
deallocations.
 * Other Builtins::  Other built-in functions.
 * Target Builtins:: Built-in functions specific to particular targets.
-* Target Format Checks:: Format checks specific to particular targets.
 @end menu
 
 @node Additional Numeric Types
@@ -2219,18 +2218,43 @@ for consistency with the @code{printf} style format 
string argument
 @code{my_format}.
 
 The parameter @var{archetype} determines how the format string is
-interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
+interpreted.
+Valid archetypes include @code{printf}, @code{scanf}, @code{strftime},
 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
 @code{strfmon}.  (You can also use @code{__printf__},
-@code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
-MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
-@code{ms_strftime} are also present.
+@code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)
 @var{archetype} values such as @code{printf} refer to the formats accepted
 by the system's C runtime library,
 while values prefixed with @samp{gnu_} always refer
-to the formats accepted by the GNU C Library.  On Microsoft Windows
-targets, values prefixed with @samp{ms_} refer to the formats accepted by the
+to the formats accepted by the GNU C Library.
+
+@anchor{Target Format Checks}
+On MinGW and Microsoft Windows targets, @code{ms_printf},
+@code{ms_scanf}, and @code{ms_strftime} are also present.  Values
+prefixed with @samp{ms_} refer to the formats accepted by the
 @file{msvcrt.dll} library.
+
+@anchor{Solaris Format Checks}
+Solaris targets also support the @code{cmn_err} (or @code{__cmn_err__})
+archetype.
+@code{cmn_err} accepts a subset of the standard @code{printf}
+conversions, and the two-argument @code{%b} conversion for displaying
+bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
+
+@anchor{Darwin Format Checks}
+Darwin targets also support the @code{CFString} (or
+@code{__CFString__}) archetype in the @code{format} attribute.
+Declarations with this archetype are parsed for correct syntax
+and argument types.  However, parsing of the format string itself and
+validating arguments against it in calls to such functions is currently
+not performed.
+
+For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
+recognized in the same context.  Declarations including these format attributes
+are parsed for correct syntax, however the result of checking of such format
+strings is not yet defined, and is not carried out by this version of the
+compiler.
+
 The parameter @var{string-index}
 specifies which argument is the format string argument (starting
 from 1), while @var{first-to-check} is the number of the first
@@ -2265,15 +2289,7 @@ standard modes, the X/Open function @code{strfmon} is 
also checked as
 are @code{printf_unlocked} and @code{fprintf_unlocked}.
 @xref{C Dialect Options,,Options Controlling C Dialect}.
 
-For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
-recognized in the same context.  Declarations including these format attributes
-are parsed for correct syntax, however the result of checking of such format
-strings is not yet defined, and is not carried out by this version of the
-compiler.
 
-The target may also provide additional types of format checks.
-@xref{Target Format Checks,,Format Checks Specific to Particular
-Target Machines}.
 
 @cindex @code{format_arg} function attribute
 @opindex Wformat-nonliteral
@@ -2328,13 +2344,17 @@ requested by @option{-ansi

[gcc r15-9038] aarch64: Changed CRC test.

2025-03-30 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:df55a933cfc675be2024b16386b96b2807464b41

commit r15-9038-gdf55a933cfc675be2024b16386b96b2807464b41
Author: Mariam Arutunian 
Date:   Sun Mar 30 09:33:39 2025 -0600

aarch64: Changed CRC test.

Fixed the iteration number in crc-crc32c-data16.c test from 8 to 16 to 
match the test name.

gcc/testsuite
* gcc.target/aarch64/crc-crc32c-data16.c: Fix iteration
count to match testname.

Diff:
---
 gcc/testsuite/gcc.target/aarch64/crc-crc32c-data16.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.target/aarch64/crc-crc32c-data16.c 
b/gcc/testsuite/gcc.target/aarch64/crc-crc32c-data16.c
index d82e6252603a..db0813637edc 100644
--- a/gcc/testsuite/gcc.target/aarch64/crc-crc32c-data16.c
+++ b/gcc/testsuite/gcc.target/aarch64/crc-crc32c-data16.c
@@ -10,7 +10,7 @@ uint32_t _crc32_O0 (uint32_t crc, uint16_t data) {
   int i;
   crc = crc ^ data;
 
-  for (i = 0; i < 8; i++) {
+  for (i = 0; i < 16; i++) {
   if (crc & 1)
crc = (crc >> 1) ^ 0x82F63B78;
   else
@@ -24,7 +24,7 @@ uint32_t _crc32 (uint32_t crc, uint16_t data) {
   int i;
   crc = crc ^ data;
 
-  for (i = 0; i < 8; i++) {
+  for (i = 0; i < 16; i++) {
   if (crc & 1)
crc = (crc >> 1) ^ 0x82F63B78;
   else


[gcc] Created branch 'mikael/heads/refactor_descriptor_v04' in namespace 'refs/users'

2025-03-30 Thread Mikael Morin via Gcc-cvs
The branch 'mikael/heads/refactor_descriptor_v04' was created in namespace 
'refs/users' pointing to:

 8fd3bbc0668d... Réduction utilisations stride_get


[gcc r15-9039] testsuite: Fix up atomic-inst-ldlogic.c

2025-03-30 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:d956474b89eba23965ad984f37a46ba58add7ca0

commit r15-9039-gd956474b89eba23965ad984f37a46ba58add7ca0
Author: Jakub Jelinek 
Date:   Sun Mar 30 20:11:05 2025 +0200

testsuite: Fix up atomic-inst-ldlogic.c

r15-8956 changed in the test:
-/* { dg-final { scan-assembler-times "ldclr\t" 16} */
+/* { dg-final { scan-assembler-times "ldclr\t" 16 } */
which made it even worse than before, when the directive has
been silently ignored because it didn't match the regex for
directives.  Now it matches it but is unbalanced.

The following patch fixes it and adds space after all the
other scan-assembler-times counts in the file.

2025-03-30  Jakub Jelinek  

* gcc.target/aarch64/atomic-inst-ldlogic.c: Fix another
unbalanced {} directive problem.  Add space after all
scan-assembler-times counts.

Diff:
---
 .../gcc.target/aarch64/atomic-inst-ldlogic.c   | 70 +++---
 1 file changed, 35 insertions(+), 35 deletions(-)

diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-inst-ldlogic.c 
b/gcc/testsuite/gcc.target/aarch64/atomic-inst-ldlogic.c
index 11f9bfe7194b..ccb89ce644bd 100644
--- a/gcc/testsuite/gcc.target/aarch64/atomic-inst-ldlogic.c
+++ b/gcc/testsuite/gcc.target/aarch64/atomic-inst-ldlogic.c
@@ -101,54 +101,54 @@ TEST (xor_load_notreturn, XOR_LOAD_NORETURN)
 
 /* Load-OR.  */
 
-/* { dg-final { scan-assembler-times "ldsetb\t" 8} } */
-/* { dg-final { scan-assembler-times "ldsetab\t" 16} } */
-/* { dg-final { scan-assembler-times "ldsetlb\t" 8} } */
-/* { dg-final { scan-assembler-times "ldsetalb\t" 16} } */
+/* { dg-final { scan-assembler-times "ldsetb\t" 8 } } */
+/* { dg-final { scan-assembler-times "ldsetab\t" 16 } } */
+/* { dg-final { scan-assembler-times "ldsetlb\t" 8 } } */
+/* { dg-final { scan-assembler-times "ldsetalb\t" 16 } } */
 
-/* { dg-final { scan-assembler-times "ldseth\t" 8} } */
-/* { dg-final { scan-assembler-times "ldsetah\t" 16} } */
-/* { dg-final { scan-assembler-times "ldsetlh\t" 8} } */
-/* { dg-final { scan-assembler-times "ldsetalh\t" 16} } */
+/* { dg-final { scan-assembler-times "ldseth\t" 8 } } */
+/* { dg-final { scan-assembler-times "ldsetah\t" 16 } } */
+/* { dg-final { scan-assembler-times "ldsetlh\t" 8 } } */
+/* { dg-final { scan-assembler-times "ldsetalh\t" 16 } } */
 
-/* { dg-final { scan-assembler-times "ldset\t" 16} } */
-/* { dg-final { scan-assembler-times "ldseta\t" 32} } */
-/* { dg-final { scan-assembler-times "ldsetl\t" 16} } */
-/* { dg-final { scan-assembler-times "ldsetal\t" 32} } */
+/* { dg-final { scan-assembler-times "ldset\t" 16 } } */
+/* { dg-final { scan-assembler-times "ldseta\t" 32 } } */
+/* { dg-final { scan-assembler-times "ldsetl\t" 16 } } */
+/* { dg-final { scan-assembler-times "ldsetal\t" 32 } } */
 
 /* Load-AND.  */
 
-/* { dg-final { scan-assembler-times "ldclrb\t" 8} } */
-/* { dg-final { scan-assembler-times "ldclrab\t" 16} } */
-/* { dg-final { scan-assembler-times "ldclrlb\t" 8} } */
-/* { dg-final { scan-assembler-times "ldclralb\t" 16} } */
+/* { dg-final { scan-assembler-times "ldclrb\t" 8 } } */
+/* { dg-final { scan-assembler-times "ldclrab\t" 16 } } */
+/* { dg-final { scan-assembler-times "ldclrlb\t" 8 } } */
+/* { dg-final { scan-assembler-times "ldclralb\t" 16 } } */
 
-/* { dg-final { scan-assembler-times "ldclrh\t" 8} } */
-/* { dg-final { scan-assembler-times "ldclrah\t" 16} } */
-/* { dg-final { scan-assembler-times "ldclrlh\t" 8} } */
-/* { dg-final { scan-assembler-times "ldclralh\t" 16} } */
+/* { dg-final { scan-assembler-times "ldclrh\t" 8 } } */
+/* { dg-final { scan-assembler-times "ldclrah\t" 16 } } */
+/* { dg-final { scan-assembler-times "ldclrlh\t" 8 } } */
+/* { dg-final { scan-assembler-times "ldclralh\t" 16 } } */
 
-/* { dg-final { scan-assembler-times "ldclr\t" 16 } */
-/* { dg-final { scan-assembler-times "ldclra\t" 32} } */
-/* { dg-final { scan-assembler-times "ldclrl\t" 16} } */
-/* { dg-final { scan-assembler-times "ldclral\t" 32} } */
+/* { dg-final { scan-assembler-times "ldclr\t" 16 } } */
+/* { dg-final { scan-assembler-times "ldclra\t" 32 } } */
+/* { dg-final { scan-assembler-times "ldclrl\t" 16 } } */
+/* { dg-final { scan-assembler-times "ldclral\t" 32 } } */
 
 /* Load-XOR.  */
 
-/* { dg-final { scan-assembler-times "ldeorb\t" 8} } */
-/* { dg-final { scan-assembler-times "ldeorab\t" 16} } */
+/* { dg-final { scan-assembler-times "ldeorb\t" 8 } } */
+/* { dg-final { scan-assembler-times "ldeorab\t" 16 } } */
 /* { dg-final { scan-assembler-times "ldeorlb\t" 8 } } */
-/* { dg-final { scan-assembler-times "ldeoralb\t" 16} } */
+/* { dg-final { scan-assembler-times "ldeoralb\t" 16 } } */
 
-/* { dg-final { scan-assembler-times "ldeorh\t" 8} } */
-/* { dg-final { scan-assembler-times "ldeorah\t" 16} } */
-/* { dg-final { scan-assembler-times "ldeorlh\t" 8} } */
-/* { dg-final { scan-assembler-times "ldeoralh\t" 16} } */
+/* { dg-final { scan-assembler-times "ldeorh\t" 8

[gcc(refs/users/jmelcr/heads/omp-cp)] omp-cp: multiple callbacks in progress

2025-03-30 Thread Josef Melcr via Gcc-cvs
https://gcc.gnu.org/g:660de7e0a3cd8f1ddf6719d3cfe0a6b452557f9c

commit 660de7e0a3cd8f1ddf6719d3cfe0a6b452557f9c
Author: Josef Melcr 
Date:   Sun Mar 30 19:37:22 2025 +0200

omp-cp: multiple callbacks in progress

gcc/ChangeLog:

* attr-callback.h (callback_edge_useful_p): New function.
* cgraph.cc (cgraph_edge::purge_callback_children): New
function.
(cgraph_edge::redirect_call_stmt_to_callee): Add redirection
skipping for callback edges.
* cgraph.h: Declarations.
* ipa-cp.cc (purge_useless_callback_edges): New function.
(ipcp_decision_stage): Integrate the above function.
* ipa-param-manipulation.cc 
(drop_decl_attribute_if_params_changed_p): New predicate.
(ipa_param_adjustments::build_new_function_type): Add output
parameter.
(ipa_param_adjustments::adjust_decl): Add attribute dropping.
* ipa-param-manipulation.h: Change signature.
* tree-core.h (ECF_CB_1_0): New constant for callback attribute.
(ECF_CB_1_2): Likewise.
(ECF_CB_2_4): Likewise.
(ECF_CB_3_0_2): Likewise.
* tree.cc (set_call_expr_flags): Integrate the above flags.

gcc/fortran/ChangeLog:

* f95-lang.cc (ATTR_CALLBACK_GOMP_LIST): Add constant for list,
see builtin-attrs.def.
(ATTR_CALLBACK_GOMP_TASK_LIST): Likewise.
(ATTR_CALLBACK_OACC_LIST): Likewise.

Signed-off-by: Josef Melcr 

Diff:
---
 gcc/attr-callback.h   | 11 ++
 gcc/cgraph.cc | 20 ++
 gcc/cgraph.h  |  3 +++
 gcc/fortran/f95-lang.cc   |  4 
 gcc/ipa-cp.cc | 47 ++-
 gcc/ipa-param-manipulation.cc | 28 --
 gcc/ipa-param-manipulation.h  |  2 +-
 gcc/tree-core.h   | 14 +
 gcc/tree.cc   | 43 +++
 9 files changed, 168 insertions(+), 4 deletions(-)

diff --git a/gcc/attr-callback.h b/gcc/attr-callback.h
index ea9c9cbbc780..b6a1a0c4106c 100644
--- a/gcc/attr-callback.h
+++ b/gcc/attr-callback.h
@@ -270,4 +270,15 @@ handle_callback_attribute (tree *node, tree name, tree 
args,
   return NULL_TREE;
 }
 
+inline bool
+callback_edge_useful_p (cgraph_edge *e)
+{
+  gcc_checking_assert (e->callback);
+  /* If the edge is not pointing towards a clone, it is no longer useful as its
+ entire purpose is to produce clones of callbacks. */
+  if (!e->callee->clone_of)
+return false;
+  return true;
+}
+
 #endif /* ATTR_CALLBACK_H  */
diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index e032cc0b4864..3bcfe1f2da12 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -1248,6 +1248,19 @@ cgraph_edge::next_callback_target ()
   return e;
 }
 
+void
+cgraph_edge::purge_callback_children ()
+{
+  gcc_checking_assert (has_callback);
+  cgraph_edge *e, *next;
+  for (e = first_callback_target (); e; e = next)
+{
+  next = e->next_callback_target ();
+  cgraph_edge::remove (e);
+}
+  has_callback = false;
+}
+
 /* Speculative call consists of an indirect edge and one or more
direct edge+ref pairs.
 
@@ -1610,6 +1623,13 @@ cgraph_edge::redirect_call_stmt_to_callee (cgraph_edge 
*e,
  redirecting to. */
   if (e->callback)
 {
+  cgraph_edge *parent = e->get_callback_parent_edge ();
+  if (!lookup_attribute ("callback",
+DECL_ATTRIBUTES (parent->callee->decl)))
+   /* Callback attribute is removed if the offloading function changes
+  signature, as the indices would be correct anymore. These edges will
+  get cleaned up later, ignore their redirection for now. */
+   return e->call_stmt;
   int fn_idx
= callback_fetch_fn_position (e->call_stmt, DECL_ATTRIBUTES (decl),
  e->callee->decl);
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 044639793486..18756cf9f4f8 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -1753,6 +1753,9 @@ public:
   /* TODO DOCS */
   cgraph_edge *next_callback_target ();
 
+  /* TODO DOCS */
+  void purge_callback_children ();
+
   /* Speculative call consists of an indirect edge and one or more
  direct edge+ref pairs.  Speculative will expand to the following sequence:
 
diff --git a/gcc/fortran/f95-lang.cc b/gcc/fortran/f95-lang.cc
index aed19a9822ee..1c4b4b0de3d8 100644
--- a/gcc/fortran/f95-lang.cc
+++ b/gcc/fortran/f95-lang.cc
@@ -574,6 +574,10 @@ gfc_builtin_function (tree decl)
 #define ATTR_COLD_NORETURN_NOTHROW_LEAF_LIST \
(ECF_COLD | ECF_NORETURN | \
 ECF_NOTHROW | ECF_LEAF)
+#define ATTR_CALLBACK_GOMP_LIST (ECF_CB_1_2 | ATTR_NOTHROW_LIST)
+#define ATTR_CALLBACK_GOMP_TASK_LIST \
+  (ECF_CB_3_0_2 | ECF_CB_1_0 | ATTR_NOTHROW_LIST)
+#define ATTR_CALLB

[gcc(refs/users/mikael/heads/refactor_descriptor_v04)] Réduction utilisations stride_get

2025-03-30 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:189b6afd2a993e652c8c496f8fdf7e26ad76e80e

commit 189b6afd2a993e652c8c496f8fdf7e26ad76e80e
Author: Mikael Morin 
Date:   Sun Mar 30 18:16:46 2025 +0200

Réduction utilisations stride_get

Diff:
---
 gcc/fortran/trans-decl.cc   |  4 +---
 gcc/fortran/trans-openmp.cc | 38 +++---
 2 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index 0c48f7a062d1..d88ad3655c19 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -7597,9 +7597,7 @@ done:
   tmp = gfc_conv_descriptor_extent_get (gfc_desc, idx);
   gfc_add_modify (&loop_body, gfc_get_cfi_dim_extent (cfi, idx), tmp);
   /* d->dim[n].sm = gfc->dim[i].stride  * gfc->span); */
-  tmp = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
-gfc_conv_descriptor_stride_get (gfc_desc, idx),
-gfc_conv_descriptor_span_get (gfc_desc));
+  tmp = gfc_conv_descriptor_sm_get (gfc_desc, idx);
   gfc_add_modify (&loop_body, gfc_get_cfi_dim_sm (cfi, idx), tmp);
 
   /* Generate loop.  */
diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index f1b50ea00b6b..0ee9898d0483 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -782,11 +782,13 @@ gfc_omp_clause_default_ctor (tree clause, tree decl, tree 
outer)
   if (GFC_TYPE_ARRAY_RANK (type) > 1)
size = fold_build2_loc (input_location, MULT_EXPR,
gfc_array_index_type, size,
-   gfc_conv_descriptor_stride_get (decl, rank));
-  tree esize = fold_convert (gfc_array_index_type,
-TYPE_SIZE_UNIT (gfc_get_element_type (type)));
-  size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
- size, esize);
+   gfc_conv_descriptor_sm_get (decl, rank));
+  else
+   {
+ tree esize = gfc_conv_descriptor_elem_len_get (decl);
+ size = fold_build2_loc (input_location, MULT_EXPR, 
gfc_array_index_type,
+ size, esize);
+   }
   size = unshare_expr (size);
   size = gfc_evaluate_now (fold_convert (size_type_node, size),
   &cond_block);
@@ -968,11 +970,14 @@ gfc_omp_clause_copy_ctor (tree clause, tree dest, tree 
src)
   if (GFC_TYPE_ARRAY_RANK (type) > 1)
size = fold_build2_loc (input_location, MULT_EXPR,
gfc_array_index_type, size,
-   gfc_conv_descriptor_stride_get (dest, rank));
-  tree esize = fold_convert (gfc_array_index_type,
-TYPE_SIZE_UNIT (gfc_get_element_type (type)));
-  size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
- size, esize);
+   gfc_conv_descriptor_sm_get (dest, rank));
+  else
+   {
+ tree esize = fold_convert (gfc_array_index_type,
+TYPE_SIZE_UNIT (gfc_get_element_type 
(type)));
+ size = fold_build2_loc (input_location, MULT_EXPR, 
gfc_array_index_type,
+ size, esize);
+   }
   size = unshare_expr (size);
   size = gfc_evaluate_now (fold_convert (size_type_node, size),
   &cond_block);
@@ -1086,11 +1091,14 @@ gfc_omp_clause_assign_op (tree clause, tree dest, tree 
src)
   if (GFC_TYPE_ARRAY_RANK (type) > 1)
size = fold_build2_loc (input_location, MULT_EXPR,
gfc_array_index_type, size,
-   gfc_conv_descriptor_stride_get (src, rank));
-  tree esize = fold_convert (gfc_array_index_type,
-TYPE_SIZE_UNIT (gfc_get_element_type (type)));
-  size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
- size, esize);
+   gfc_conv_descriptor_sm_get (src, rank));
+  else
+   {
+ tree esize = fold_convert (gfc_array_index_type,
+TYPE_SIZE_UNIT (gfc_get_element_type 
(type)));
+ size = fold_build2_loc (input_location, MULT_EXPR, 
gfc_array_index_type,
+ size, esize);
+   }
   size = unshare_expr (size);
   size = gfc_evaluate_now (fold_convert (size_type_node, size),
   &cond_block);


[gcc(refs/users/omachota/heads/rtl-ssa-dce)] rtl-ssa-dce: cleanup and comparsion with ud_dce

2025-03-30 Thread Ondrej Machota via Gcc-cvs
https://gcc.gnu.org/g:b065e82ac0a5b02167043e7ef1bb7f512e81543f

commit b065e82ac0a5b02167043e7ef1bb7f512e81543f
Author: Ondřej Machota 
Date:   Sun Mar 30 22:53:17 2025 +0200

rtl-ssa-dce: cleanup and comparsion with ud_dce

Diff:
---
 gcc/dce.cc | 292 +
 gcc/passes.def |   3 +-
 2 files changed, 153 insertions(+), 142 deletions(-)

diff --git a/gcc/dce.cc b/gcc/dce.cc
index bb7040ae653d..53934d19c0ac 100644
--- a/gcc/dce.cc
+++ b/gcc/dce.cc
@@ -578,6 +578,7 @@ reset_unmarked_insns_debug_uses (void)
 }
 
 /* Delete every instruction that hasn't been marked.  */
+static bool inside_ud = false;
 
 static void
 delete_unmarked_insns (void)
@@ -585,6 +586,7 @@ delete_unmarked_insns (void)
   basic_block bb;
   rtx_insn *insn, *next;
   bool must_clean = false;
+  bool any = false;
 
   FOR_EACH_BB_REVERSE_FN (bb, cfun)
 FOR_BB_INSNS_REVERSE_SAFE (bb, insn, next)
@@ -653,9 +655,17 @@ delete_unmarked_insns (void)
}
  else
/* Now delete the insn.  */
+  if (inside_ud) {
+debug(insn);
+  }
+  any = true;
must_clean |= delete_insn_and_edges (insn);
}
 
+  if (any && inside_ud) {
+std::cerr << "\033[31m" << "ud was able to delete more insns..." << 
"\033[0m \n";
+  }
+
   /* Deleted a pure or const call.  */
   if (must_clean)
 {
@@ -809,6 +819,7 @@ fini_dce (bool fast)
 static unsigned int
 rest_of_handle_ud_dce (void)
 {
+  inside_ud = true;
   rtx_insn *insn;
 
   init_dce (false);
@@ -829,6 +840,7 @@ rest_of_handle_ud_dce (void)
  they are not bidirectional.  */
   df_remove_problem (df_chain);
   delete_unmarked_insns ();
+  inside_ud = false;
 
   fini_dce (false);
   return 0;
@@ -1306,14 +1318,15 @@ public:
 
 } // namespace
 
+// This struct could help to remove unordered_set for rtl ssa dce
 struct offset_bitmap {
   private:
 const int m_offset;
 sbitmap m_bitmap;
   
   public:
-offset_bitmap(size_t size, int offset) : m_bitmap{sbitmap_alloc(size)} {}
-offset_bitmap(int min_index, int max_index) : offset_bitmap(max_index - 
min_index, 0) {}
+offset_bitmap(size_t size, int offset) : m_offset{offset}, 
m_bitmap{sbitmap_alloc(size)} {}
+offset_bitmap(int min_index, int max_index) : 
offset_bitmap(size_t(max_index - min_index), min_index) {}
 
 void clear_bit(int index) {
   bitmap_clear_bit(m_bitmap, index + m_offset);
@@ -1332,26 +1345,6 @@ struct offset_bitmap {
 }
 };
 
-bool sets_global_register(rtx_insn* insn) {
-  rtx set = single_set(insn);
-  if (!set)
-return false;
-
-  rtx dest = SET_DEST(set);
-
-  // TODO : rewrite to simple return
-  std::cerr << "first pseudo: " << FIRST_PSEUDO_REGISTER << '\n';
-  //std::cerr << "register: " << REGNO(dest) << "\n";
-  //debug(insn);
-  // If I understand correctly, global_regs[i] is 1 iff reg i is used
-  if (REG_P(dest) && HARD_REGISTER_NUM_P(REGNO(dest))) { // && 
global_regs[REGNO(dest)]
-std::cerr << "sets_global_register: true\n";
-return true;
-  }
-
-  return false;
-}
-
 bool side_effects_with_mem (const_rtx x)
 {
   const RTX_CODE code = GET_CODE (x);
@@ -1460,10 +1453,7 @@ bool is_rtx_insn_prelive(rtx_insn *insn) {
   /* Don't delete insns that may throw if we cannot do so.  */
   if (!(cfun->can_delete_dead_exceptions && can_alter_cfg) && !insn_nothrow_p 
(insn))
 return true;
-
-  /* TODO : What about call argumets? Accoring to the docs, for function 
prologue the RTX_FRAME_RELATED_P
- should return true.
-  */  
+ 
   /* Callee-save restores are needed.  */
   if (RTX_FRAME_RELATED_P (insn) && crtl->shrink_wrapped_separate && 
find_reg_note (insn, REG_CFA_RESTORE, NULL))
 return true;
@@ -1496,9 +1486,7 @@ bool is_rtx_insn_prelive(rtx_insn *insn) {
   // e. g. this one: testsuite/gcc.c-torture/execute/20020418-1.c
   // TODO : debug the testcase
   // It seems that the issue was due to trap_if rtl insn and fixed with 
may_trap_or_fault_p
-  // What about can_throw_internal?
-  // || can_throw_internal(body) - testy na ntb prochazi
-  if (side_effects_with_mem(body)) // || may_trap_or_fault_p(body)) // 
replaced by TRAP_IF
+  if (side_effects_with_mem(body)) // may_trap_or_fault_p(body) replaced by 
TRAP_IF
 return true;
 
   return false;
@@ -1532,8 +1520,7 @@ bool is_prelive(insn_info *insn)
   gcc_assert (insn->is_real());
   auto rtl = insn->rtl();
 
-  for (auto&& __def : insn->defs()) {
-def_info * def = __def;
+  for (def_info * def : insn->defs()) {
 // The purpose of this pass is not to eliminate stores to memory...
 if (def->is_mem()) { // TODO : clobbered memory?
   return true;
@@ -1541,18 +1528,52 @@ bool is_prelive(insn_info *insn)
 
 gcc_assert(def->is_reg());
 // this ignores clobbers, which is probably fine
-if (def->kind() == access_kind::SET 
-&& (HARD_REGISTER_NUM_P(def->regno())
-|| ( pic_offset_table_rtx != nullptr 
-  && def->regno() == REGNO (pic_offset_table_

[gcc r15-9047] Optimize string constructor

2025-03-30 Thread Jan Hubicka via Gcc-cvs
https://gcc.gnu.org/g:9c5505a35d9d71705464f9254f55407192d31ec3

commit r15-9047-g9c5505a35d9d71705464f9254f55407192d31ec3
Author: Jan Hubicka 
Date:   Sun Mar 30 23:49:49 2025 +0200

Optimize string constructor

this patch improves code generation on string constructors.  We currently 
have
_M_construct which takes as a parameter two iterators (begin/end pointers to
other string) and produces new string.  This patch adds special case of
constructor where instead of begining/end pointers we readily know the 
string
size and also special case when we know that source is 0 terminated.  This
happens commonly when producing stirng copies. Moreover currently ipa-prop 
is
not able to propagate information that beg-end is known constant (copied 
string
size) which makes it impossible for inliner to spot the common case where
string size is known to be shorter than 15 bytes and fits in local buffer.

Finally I made new constructor inline. Because it is explicitely 
instantiated
without C++20 constexpr we do not produce implicit instantiation (as 
required
by standard) which prevents inlining, ipa-modref and any other IPA analysis 
to
happen.  I think we need to make many of the other functions inline, since
optimization accross string manipulation is quite important. There is 
PR94960
to track this issue.

Bootstrapped/regtested x86_64-linux, OK?

libstdc++-v3/ChangeLog:

PR tree-optimization/103827
PR tree-optimization/80331
PR tree-optimization/87502

* config/abi/pre/gnu.ver: Add version for _M_construct
* include/bits/basic_string.h: (basic_string::_M_construct): 
Declare.
(basic_string constructors): Use it.
* include/bits/basic_string.tcc: 
(basic_string::_M_construct): New template.
* src/c++11/string-inst.cc: Instantated S::_M_construct.

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/pr80331.C: New test.
* g++.dg/tree-ssa/pr87502.C: New test.

Diff:
---
 gcc/testsuite/g++.dg/tree-ssa/pr80331.C|  8 
 gcc/testsuite/g++.dg/tree-ssa/pr87502.C| 15 +++
 libstdc++-v3/config/abi/pre/gnu.ver|  3 +++
 libstdc++-v3/include/bits/basic_string.h   | 10 --
 libstdc++-v3/include/bits/basic_string.tcc | 25 +
 libstdc++-v3/src/c++11/string-inst.cc  |  8 
 6 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr80331.C 
b/gcc/testsuite/g++.dg/tree-ssa/pr80331.C
new file mode 100644
index ..85034504f2f8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr80331.C
@@ -0,0 +1,8 @@
+// { dg-do compile }
+// { dg-additional-options "-O2 -fdump-tree-optimized" }
+#include
+int sain() {
+  const std::string remove_me("remove_me");
+  return 0;
+}
+// { dg-final { scan-tree-dump-not "remove_me" "optimized" } }
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr87502.C 
b/gcc/testsuite/g++.dg/tree-ssa/pr87502.C
new file mode 100644
index ..ad3e9d254044
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr87502.C
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-additional-options "-O2 -fdump-tree-optimized" }
+#include 
+
+
+__attribute__ ((pure))
+extern int foo (const std::string &);
+
+int
+bar ()
+{
+  return foo ("abc") + foo (std::string("abc"));
+}
+// We used to add terminating zero explicitely instead of using fact
+// that memcpy source is already 0 terminated.
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver 
b/libstdc++-v3/config/abi/pre/gnu.ver
index adadc62e3533..eb230290313c 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -2540,6 +2540,9 @@ GLIBCXX_3.4.34 {
 
_ZNSt8__format25__locale_encoding_to_utf8ERKSt6localeSt17basic_string_viewIcSt11char_traitsIcEEPv;
 # __sso_string constructor and destructor
 _ZNSt12__sso_string[CD][12]Ev;
+# void std::__cxx11::basic_string, 
std::allocator >::_M_construct(char const*, unsigned long)
+# and wide char version
+
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE12_M_constructILb[01]EEEvPK[cw]m;
 } GLIBCXX_3.4.33;
 
 # Symbols in the support library (libsupc++) have their own tag.
diff --git a/libstdc++-v3/include/bits/basic_string.h 
b/libstdc++-v3/include/bits/basic_string.h
index e3b484d7a53f..86841cb2c5ed 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -341,6 +341,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   void
   _M_construct(size_type __req, _CharT __c);
 
+  // Construct using block of memory of known size.
+  // If _Terminated is true assume that source is already 0 terminated.
+  template
+   _GLIBCXX20_CONSTEXPR
+   void
+   _M_construct(const _CharT *__c, size_type __n);
+
   _GLIBCXX20_CONSTEXPR
   allocator_type&
   _M_get_allocator()
@@ -56

[gcc r15-9056] target/119010 - fixup Zen4/Zen5 fp<->int convert reservations

2025-03-30 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:a0d1de846b992a626f8b1e9b42cc32de8f069e04

commit r15-9056-ga0d1de846b992a626f8b1e9b42cc32de8f069e04
Author: Richard Biener 
Date:   Thu Mar 27 13:17:40 2025 +0100

target/119010 - fixup Zen4/Zen5 fp<->int convert reservations

They were using ssecvt instead of sseicvt, I've also added handling
for sseicvt2 which was introduced without fixing up automata, and
the relevant instruction uses DFmode.  IMO this is a quite messy
area that could need TLC in the machine description itself.

PR target/119010
* config/i386/zn4zn5.md (znver4_sse_icvt): Use sseicvt.
(znver4_sse_icvt_store): Likewise.
(znver5_sse_icvt_store): Likewise.
(znver4_sse_icvt2): New.

Diff:
---
 gcc/config/i386/zn4zn5.md | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/gcc/config/i386/zn4zn5.md b/gcc/config/i386/zn4zn5.md
index e89d0f49ec89..6720fda17056 100644
--- a/gcc/config/i386/zn4zn5.md
+++ b/gcc/config/i386/zn4zn5.md
@@ -1263,21 +1263,28 @@
 
 (define_insn_reservation "znver4_sse_icvt" 3
 (and (eq_attr "cpu" "znver4,znver5")
- (and (eq_attr "type" "ssecvt")
+ (and (eq_attr "type" "sseicvt")
   (and (eq_attr "mode" "SI")
(eq_attr "memory" "none"
 "znver4-direct,znver4-fpu2|znver4-fpu3")
 
+(define_insn_reservation "znver4_sse_icvt2" 3
+(and (eq_attr "cpu" "znver4,znver5")
+ (and (eq_attr "type" "sseicvt2")
+  (and (eq_attr "mode" "DF")
+   (eq_attr "memory" "none"
+"znver4-direct,znver4-fpu2|znver4-fpu3")
+
 (define_insn_reservation "znver4_sse_icvt_store" 4
 (and (eq_attr "cpu" "znver4")
- (and (eq_attr "type" "ssecvt")
+ (and (eq_attr "type" "sseicvt")
   (and (eq_attr "mode" "SI")
(eq_attr "memory" "store"
 
"znver4-double,znver4-fpu2|znver4-fpu3,znver4-fp-store")
 
 (define_insn_reservation "znver5_sse_icvt_store" 4
 (and (eq_attr "cpu" "znver5")
- (and (eq_attr "type" "ssecvt")
+ (and (eq_attr "type" "sseicvt")
   (and (eq_attr "mode" "SI")
(eq_attr "memory" "store"
 
"znver4-double,znver4-fpu2|znver4-fpu3,znver5-fp-store256")


[gcc r15-9055] target/119010 - handle DFmode in SSE divide reservations for Zen4/Zen5

2025-03-30 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:30fb97f31b69d3dce77efbcd0ef08f216d3fe262

commit r15-9055-g30fb97f31b69d3dce77efbcd0ef08f216d3fe262
Author: Richard Biener 
Date:   Thu Mar 27 12:51:48 2025 +0100

target/119010 - handle DFmode in SSE divide reservations for Zen4/Zen5

Like the other DFmode cases.

PR target/119010
* config/i386/zn4zn5.md (znver4_sse_div_pd,
znver4_sse_div_pd_load, znver5_sse_div_pd_load): Handle DFmode.

Diff:
---
 gcc/config/i386/zn4zn5.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/config/i386/zn4zn5.md b/gcc/config/i386/zn4zn5.md
index c7ced5411f0b..e89d0f49ec89 100644
--- a/gcc/config/i386/zn4zn5.md
+++ b/gcc/config/i386/zn4zn5.md
@@ -1156,7 +1156,7 @@
 (define_insn_reservation "znver4_sse_div_pd" 13
 (and (eq_attr "cpu" "znver4,znver5")
  (and (eq_attr "type" "ssediv")
-  (and (eq_attr "mode" "V4DF,V2DF,V1DF")
+  (and (eq_attr "mode" "V4DF,V2DF,V1DF,DF")
(eq_attr "memory" "none"
 "znver4-direct,znver4-fdiv*5")
 
@@ -1170,14 +1170,14 @@
 (define_insn_reservation "znver4_sse_div_pd_load" 18
 (and (eq_attr "cpu" "znver4")
  (and (eq_attr "type" "ssediv")
-  (and (eq_attr "mode" "V4DF,V2DF,V1DF")
+  (and (eq_attr "mode" "V4DF,V2DF,V1DF,DF")
(eq_attr "memory" "load"
 "znver4-direct,znver4-load,znver4-fdiv*5")
 
 (define_insn_reservation "znver5_sse_div_pd_load" 18
 (and (eq_attr "cpu" "znver5")
  (and (eq_attr "type" "ssediv")
-  (and (eq_attr "mode" "V4DF,V2DF,V1DF")
+  (and (eq_attr "mode" "V4DF,V2DF,V1DF,DF")
(eq_attr "memory" "load"
 "znver4-direct,znver5-load,znver4-fdiv*5")


[gcc r15-9054] target/119010 - add reservations for integer vector compares to zen4/zen5

2025-03-30 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:2ac62db0915ea468b8d92ab6da105e2e168e06bc

commit r15-9054-g2ac62db0915ea468b8d92ab6da105e2e168e06bc
Author: Richard Biener 
Date:   Thu Mar 27 12:40:15 2025 +0100

target/119010 - add reservations for integer vector compares to zen4/zen5

The following handles TI, OI and XI mode in the respective EVEX
compare reservations that do not use memory (I've not yet run into
ones with).  The znver automata has separate reservations for
integer compares (but only for zen1, for zen2 and zen3 there are
no compare reservations at all), but I don't see why that should
be necessary here.

PR target/119010
* config/i386/zn4zn5.md (znver4_sse_cmp_avx128,
znver5_sse_cmp_avx128): Handle TImode.
(znver4_sse_cmp_avx256, znver5_sse_cmp_avx256): Handle OImode.
(znver4_sse_cmp_avx512, znver5_sse_cmp_avx512): Handle XImode.

Diff:
---
 gcc/config/i386/zn4zn5.md | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/config/i386/zn4zn5.md b/gcc/config/i386/zn4zn5.md
index 40e51456a461..c7ced5411f0b 100644
--- a/gcc/config/i386/zn4zn5.md
+++ b/gcc/config/i386/zn4zn5.md
@@ -1601,7 +1601,7 @@
 (define_insn_reservation "znver4_sse_cmp_avx128" 3
 (and (eq_attr "cpu" "znver4")
  (and (eq_attr "type" "ssecmp")
-  (and (eq_attr "mode" 
"V4SF,V2DF,V2SF,V1DF,DF,SF")
+  (and (eq_attr "mode" 
"V4SF,V2DF,V2SF,V1DF,DF,SF,TI")
(and (eq_attr "prefix" "evex")
 (eq_attr "memory" "none")
 "znver4-direct,znver4-fpu0*2|znver4-fpu1*2")
@@ -1609,7 +1609,7 @@
 (define_insn_reservation "znver5_sse_cmp_avx128" 3
 (and (eq_attr "cpu" "znver5")
  (and (eq_attr "type" "ssecmp")
-  (and (eq_attr "mode" 
"V4SF,V2DF,V2SF,V1DF,DF,SF")
+  (and (eq_attr "mode" 
"V4SF,V2DF,V2SF,V1DF,DF,SF,TI")
(and (eq_attr "prefix" "evex")
 (eq_attr "memory" "none")
 "znver4-direct,znver4-fpu1|znver4-fpu2")
@@ -1633,7 +1633,7 @@
 (define_insn_reservation "znver4_sse_cmp_avx256" 4
 (and (eq_attr "cpu" "znver4")
  (and (eq_attr "type" "ssecmp")
-  (and (eq_attr "mode" "V8SF,V4DF")
+  (and (eq_attr "mode" "V8SF,V4DF,OI")
(and (eq_attr "prefix" "evex")
 (eq_attr "memory" "none")
 "znver4-direct,znver4-fpu0*2|znver4-fpu1*2")
@@ -1641,7 +1641,7 @@
 (define_insn_reservation "znver5_sse_cmp_avx256" 4
 (and (eq_attr "cpu" "znver5")
  (and (eq_attr "type" "ssecmp")
-  (and (eq_attr "mode" "V8SF,V4DF")
+  (and (eq_attr "mode" "V8SF,V4DF,OI")
(and (eq_attr "prefix" "evex")
 (eq_attr "memory" "none")
 "znver4-direct,znver4-fpu1|znver4-fpu2")
@@ -1665,7 +1665,7 @@
 (define_insn_reservation "znver4_sse_cmp_avx512" 5
 (and (eq_attr "cpu" "znver4")
  (and (eq_attr "type" "ssecmp")
-  (and (eq_attr "mode" "V16SF,V8DF")
+  (and (eq_attr "mode" "V16SF,V8DF,XI")
(and (eq_attr "prefix" "evex")
 (eq_attr "memory" "none")
 "znver4-direct,znver4-fpu0*2|znver4-fpu1*2")
@@ -1673,7 +1673,7 @@
 (define_insn_reservation "znver5_sse_cmp_avx512" 5
 (and (eq_attr "cpu" "znver5")
  (and (eq_attr "type" "ssecmp")
-  (and (eq_attr "mode" "V16SF,V8DF")
+  (and (eq_attr "mode" "V16SF,V8DF,XI")
(and (eq_attr "prefix" "evex")
 (eq_attr "memory" "none")
 "znver4-direct,znver4-fpu1|znver4-fpu2")


[gcc r15-9052] target/119010 - fixup zn4zn5 reservation for move from const_vector

2025-03-30 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:4903e49b2fe321b1479dce4d3c4e2c2ae297298f

commit r15-9052-g4903e49b2fe321b1479dce4d3c4e2c2ae297298f
Author: Richard Biener 
Date:   Thu Mar 27 09:04:38 2025 +0100

target/119010 - fixup zn4zn5 reservation for move from const_vector

movv8si_internal uses sselog1 and V4SFmode for an instruction like

(insn 363 2437 371 97 (set (reg:V8SI 46 xmm10 [1125])
(const_vector:V8SI [
(const_int 0 [0]) repeated x8
])) "ComputeNonbondedUtil.C":185:21 2402 {movv8si_internal}

this wasn't catched by the existing znver4_sse_log1 reservation,
I think the znver automaton catches this with the generic

(define_insn_reservation "znver1_sse_log1" 1
 (and (eq_attr "cpu" "znver1,znver2,znver3")
  (and (eq_attr "type" "sselog1")
   (eq_attr "memory" "none")))
 "znver1-direct,znver1-fp1|znver1-fp2")

which does not look at the mode at all.  The zn4zn5 automaton lacks
this and instead has separated store and load-store reservations
in odd ways.  The following renames the store one and introduces
a none variant.

PR target/119010
* config/i386/zn4zn5.md (znver4_sse_log1): Rename to
znver4_sse_log1_store.
(znver5_sse_log1): Rename to znver5_sse_log1_store.
(znver4_sse_log1): New memory-less variant.

Diff:
---
 gcc/config/i386/zn4zn5.md | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/config/i386/zn4zn5.md b/gcc/config/i386/zn4zn5.md
index 75e310202150..fb856e9dc988 100644
--- a/gcc/config/i386/zn4zn5.md
+++ b/gcc/config/i386/zn4zn5.md
@@ -893,13 +893,20 @@
 "znver4-direct,znver5-load,znver4-fpu")
 
 (define_insn_reservation "znver4_sse_log1" 1
+(and (eq_attr "cpu" "znver4,znver5")
+ (and (eq_attr "type" "sselog1")
+  (and (eq_attr "mode" 
"V4SF,V8SF,V2DF,V4DF,QI,HI,SI,DI,TI,OI")
+   (eq_attr "memory" "none"
+"znver4-direct,znver4-fpu1|znver4-fpu2")
+
+(define_insn_reservation "znver4_sse_log1_store" 1
 (and (eq_attr "cpu" "znver4")
  (and (eq_attr "type" "sselog1")
   (and (eq_attr "mode" 
"V4SF,V8SF,V2DF,V4DF,QI,HI,SI,DI,TI,OI")
(eq_attr "memory" "store"
 
"znver4-direct,znver4-fpu1|znver4-fpu2,znver4-fp-store")
 
-(define_insn_reservation "znver5_sse_log1" 1
+(define_insn_reservation "znver5_sse_log1_store" 1
 (and (eq_attr "cpu" "znver5")
  (and (eq_attr "type" "sselog1")
   (and (eq_attr "mode" 
"V4SF,V8SF,V2DF,V4DF,QI,HI,SI,DI,TI,OI")


[gcc r15-9058] target/119010 - Zen4/Zen5 reservations for movlhps loads

2025-03-30 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:3154ce9af0163d8d585455230e4c3eee44fbbd01

commit r15-9058-g3154ce9af0163d8d585455230e4c3eee44fbbd01
Author: Richard Biener 
Date:   Thu Mar 27 13:51:38 2025 +0100

target/119010 - Zen4/Zen5 reservations for movlhps loads

The following fixes up the ssemov2 type introduction, amending
the znver4_sse_mov_fp_load reservation.  This fixes

;;  14--> b  0: i1436 xmm6=vec_concat(xmm6,[ax+0x8])  :nothing

PR target/119010
* config/i386/zn4zn5.md (znver4_sse_mov_fp_load,
znver5_sse_mov_fp_load): Also match ssemov2.

Diff:
---
 gcc/config/i386/zn4zn5.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/config/i386/zn4zn5.md b/gcc/config/i386/zn4zn5.md
index 1ac1d07c04b8..ecb1e3bbedba 100644
--- a/gcc/config/i386/zn4zn5.md
+++ b/gcc/config/i386/zn4zn5.md
@@ -1036,14 +1036,14 @@
 
 (define_insn_reservation "znver4_sse_mov_fp_load" 6
 (and (eq_attr "cpu" "znver4")
- (and (eq_attr "type" "ssemov")
+ (and (eq_attr "type" "ssemov,ssemov2")
   (and (eq_attr "mode" 
"V16SF,V8DF,V8SF,V4DF,V4SF,V2DF,V2SF,V1DF,DF,SF")
(eq_attr "memory" "load"
 "znver4-direct,znver4-load,znver4-fpu")
 
 (define_insn_reservation "znver5_sse_mov_fp_load" 6
 (and (eq_attr "cpu" "znver5")
- (and (eq_attr "type" "ssemov")
+ (and (eq_attr "type" "ssemov,ssemov2")
   (and (eq_attr "mode" 
"V16SF,V8DF,V8SF,V4DF,V4SF,V2DF,V2SF,V1DF,DF,SF")
(eq_attr "memory" "load"
 "znver4-direct,znver5-load,znver4-fpu")


[gcc r15-9053] target/119010 - missing reservations for Zen4/5 and SSE compares

2025-03-30 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:18668d9c196a36dc7c0cd698a2a767b8f8c8e8a4

commit r15-9053-g18668d9c196a36dc7c0cd698a2a767b8f8c8e8a4
Author: Richard Biener 
Date:   Thu Mar 27 11:29:21 2025 +0100

target/119010 - missing reservations for Zen4/5 and SSE compares

There's the znver4_sse_test reservation which matches the memory-less
SSE compares but currently requires prefix_extra == 1.  The old
znver automata in this case sometimes uses znver1-double instead of
znver1-direct, but it's quite a maze.  The following simply drops
the prefix_extra requirement, but I have no idea what I'm doing here.
There doesn't seem to be any documentation on the scheduler relevant
attributes used, or at least I cannot find that.

PR target/119010
* config/i386/zn4zn5.md (znver4_sse_test): Drop test of
prefix_extra attribute.

Diff:
---
 gcc/config/i386/zn4zn5.md | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/gcc/config/i386/zn4zn5.md b/gcc/config/i386/zn4zn5.md
index fb856e9dc988..40e51456a461 100644
--- a/gcc/config/i386/zn4zn5.md
+++ b/gcc/config/i386/zn4zn5.md
@@ -953,9 +953,8 @@
 
 (define_insn_reservation "znver4_sse_test" 1
 (and (eq_attr "cpu" "znver4,znver5")
- (and (eq_attr "prefix_extra" "1")
-  (and (eq_attr "type" "ssecomi")
-   (eq_attr "memory" "none"
+ (and (eq_attr "type" "ssecomi")
+   (eq_attr "memory" "none")))
 "znver4-direct,znver4-fpu1|znver4-fpu2")
 
 (define_insn_reservation "znver4_sse_test_load" 6


[gcc r15-9033] gcc/testsuite/g++.dg/gomp/append-args-8.C: Fix scan-dump-tree

2025-03-30 Thread Tobias Burnus via Gcc-cvs
https://gcc.gnu.org/g:e0886d8ad4c51919c349d0b31f2bec3acbc79e14

commit r15-9033-ge0886d8ad4c51919c349d0b31f2bec3acbc79e14
Author: Tobias Burnus 
Date:   Sun Mar 30 09:55:29 2025 +0200

gcc/testsuite/g++.dg/gomp/append-args-8.C: Fix scan-dump-tree

gcc/testsuite/ChangeLog:

* g++.dg/gomp/append-args-8.C: Remove bogus '3' after \.\[0-9\]+
pattern.

Diff:
---
 gcc/testsuite/g++.dg/gomp/append-args-8.C | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.dg/gomp/append-args-8.C 
b/gcc/testsuite/g++.dg/gomp/append-args-8.C
index 7fbbfa88b886..786a2b3dc57c 100644
--- a/gcc/testsuite/g++.dg/gomp/append-args-8.C
+++ b/gcc/testsuite/g++.dg/gomp/append-args-8.C
@@ -89,5 +89,5 @@ test (int *a, int *b)
 
 
 /* { dg-final { scan-tree-dump-times "__builtin_GOMP_interop \\(-5, 0, 0B, 0B, 
0B, 0, 0B, 3, interopobjs\.\[0-9\]+, 0, 0B\\);" 1 "gimple" } }  */
-/* { dg-final { scan-tree-dump-times "repl3 \\(a, 
interop\.\[0-9\]+3, interop\.\[0-9\]+2, interop\.\[0-9\]+, 1, 2, \"abc\"\\);" 1 
"gimple" } }  */
+/* { dg-final { scan-tree-dump-times "repl3 \\(a, 
interop\.\[0-9\]+, interop\.\[0-9\]+, interop\.\[0-9\]+, 1, 2, \"abc\"\\);" 1 
"gimple" } }  */
 /* { dg-final { scan-tree-dump-times "__builtin_GOMP_interop \\(-5, 3, 
interopobjs\.\[0-9\]+, tgt_tgtsync\.\[0-9\]+, pref_type\.\[0-9\]+, 0, 0B, 0, 
0B, 0, 0B\\);" 1 "gimple" } }  */


[gcc(refs/users/aoliva/heads/testme)] [testsuite] [riscv] limit mcpu-xiangshan-nanhu.c to rv64

2025-03-30 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:5d5cf8e9cee550bc938578c2af9cd10f1d907a4f

commit 5d5cf8e9cee550bc938578c2af9cd10f1d907a4f
Author: Alexandre Oliva 
Date:   Sat Mar 29 10:04:22 2025 -0300

[testsuite] [riscv] limit mcpu-xiangshan-nanhu.c to rv64

The testcase makes the -march option conditional on rv64, and #errors
out if the desired CPU properties are not active.  This makes the test
fail on rv32.  Arrange to skip the test on rv32 instead, moving the
rv64 conditional.


for  gcc/testsuite/ChangeLog

* gcc.target/riscv/mcpu-xiangshan-nanhu.c: Skip on rv64.

Diff:
---
 gcc/testsuite/gcc.target/riscv/mcpu-xiangshan-nanhu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.target/riscv/mcpu-xiangshan-nanhu.c 
b/gcc/testsuite/gcc.target/riscv/mcpu-xiangshan-nanhu.c
index 2903c88d91c8..c2a374f54fc8 100644
--- a/gcc/testsuite/gcc.target/riscv/mcpu-xiangshan-nanhu.c
+++ b/gcc/testsuite/gcc.target/riscv/mcpu-xiangshan-nanhu.c
@@ -1,6 +1,6 @@
-/* { dg-do compile } */
+/* { dg-do compile { target { rv64 } } } */
 /* { dg-skip-if "-march given" { *-*-* } { "-march=*" } } */
-/* { dg-options "-mcpu=xiangshan-nanhu" { target { rv64 } } } */
+/* { dg-options "-mcpu=xiangshan-nanhu" } */
 /* XiangShan Nanhu => rv64imafdc_zba_zbb_zbc_zbs_zbkb_zbkc_zbkx_zknd
   _zkne_zknh_zksed_zksh_svinval_zicbom_zicboz */


[gcc] Deleted branch 'mikael/heads/refactor_descriptor_v04' in namespace 'refs/users'

2025-03-30 Thread Mikael Morin via Gcc-cvs
The branch 'mikael/heads/refactor_descriptor_v04' in namespace 'refs/users' was 
deleted.
It previously pointed to:

 4ea1ba1598c2... Réduction usages gfc_conv_descriptor_ubound_get

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  4ea1ba1... Réduction usages gfc_conv_descriptor_ubound_get
  0ae779b... Factorisation gfc_conv_array_extent_dim
  8410cda... Suppression export gfc_conv_descriptor_span_set
  ccd1a87... Suppression modification span
  7d797f8... Sauvegarde modifs fichiers générés.
  53867f6... Suppression déclarations inutiles.


[gcc(refs/users/mikael/heads/refactor_descriptor_v04)] Réduction usages gfc_conv_descriptor_ubound_get

2025-03-30 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:f7eac82b031e7eaabc88f4a07941f0b22b725105

commit f7eac82b031e7eaabc88f4a07941f0b22b725105
Author: Mikael Morin 
Date:   Sat Mar 29 15:26:26 2025 +0100

Réduction usages gfc_conv_descriptor_ubound_get

Correction régression PR96727.f90

correction ff-descriptor_6.f90

Mise à jour dump coarray_lock_7.f90

Diff:
---
 gcc/fortran/trans-array.cc   | 48 +++-
 gcc/fortran/trans-decl.cc|  6 +---
 gcc/fortran/trans-expr.cc|  3 +-
 gcc/fortran/trans-intrinsic.cc   | 44 +++--
 gcc/fortran/trans-openmp.cc  | 38 --
 gcc/fortran/trans-stmt.cc| 10 +++---
 gcc/testsuite/gfortran.dg/coarray_lock_7.f90 |  4 +--
 7 files changed, 38 insertions(+), 115 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 0cda02d7cefc..595ba97aa8ca 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -6523,8 +6523,7 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree 
tmpdesc,
   tree stmtInit, stmtCleanup;
   tree lbound;
   tree ubound;
-  tree dubound;
-  tree dlbound;
+  tree dextent;
   tree dumdesc;
   tree tmp;
   tree stride, stride2;
@@ -6658,16 +6657,10 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree 
tmpdesc,
   for (n = 0; n < as->rank; n++)
 {
   if (checkparm || !as->upper[n])
-   {
- /* Get the bounds of the actual parameter.  */
- dubound = gfc_conv_descriptor_ubound_get (dumdesc, gfc_rank_cst[n]);
- dlbound = gfc_conv_descriptor_lbound_get (dumdesc, gfc_rank_cst[n]);
-   }
+   /* Get the bounds of the actual parameter.  */
+   dextent = gfc_conv_descriptor_extent_get (dumdesc, gfc_rank_cst[n]);
   else
-   {
- dubound = NULL_TREE;
- dlbound = NULL_TREE;
-   }
+   dextent = NULL_TREE;
 
   lbound = GFC_TYPE_ARRAY_LBOUND (type, n);
   if (!INTEGER_CST_P (lbound))
@@ -6707,12 +6700,7 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree 
tmpdesc,
  temp = fold_build2_loc (input_location, PLUS_EXPR,
  gfc_array_index_type,
  gfc_index_one_node, temp);
- stride2 = fold_build2_loc (input_location, MINUS_EXPR,
-gfc_array_index_type, dubound,
-dlbound);
- stride2 = fold_build2_loc (input_location, PLUS_EXPR,
-gfc_array_index_type,
-gfc_index_one_node, stride2);
+ stride2 = dextent;
  tmp = fold_build2_loc (input_location, NE_EXPR,
 gfc_array_index_type, temp, stride2);
  msg = xasprintf ("Dimension %d of array '%s' has extent "
@@ -6730,7 +6718,8 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree 
tmpdesc,
  /* For assumed shape arrays move the upper bound by the same amount
 as the lower bound.  */
  tmp = fold_build2_loc (input_location, MINUS_EXPR,
-gfc_array_index_type, dubound, dlbound);
+gfc_array_index_type, dextent,
+gfc_index_one_node);
  tmp = fold_build2_loc (input_location, PLUS_EXPR,
 gfc_array_index_type, tmp, lbound);
  gfc_add_modify (&init, ubound, tmp);
@@ -7794,13 +7783,7 @@ gfc_tree_array_size (stmtblock_t *block, tree desc, 
gfc_expr *expr, tree dim)
 {
   if (!dim)
dim = gfc_index_zero_node;
-  tree ubound = gfc_conv_descriptor_ubound_get (desc, dim);
-  tree lbound = gfc_conv_descriptor_lbound_get (desc, dim);
-
-  size = fold_build2_loc (input_location, MINUS_EXPR,
- gfc_array_index_type, ubound, lbound);
-  size = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
- size, gfc_index_one_node);
+  size = gfc_conv_descriptor_extent_get (desc, dim);
   /* if (!allocatable && !pointer && assumed rank)
   size = (idx == rank && ubound[rank-1] == -1 ? -1 : size;
 else
@@ -7861,11 +7844,7 @@ gfc_tree_array_size (stmtblock_t *block, tree desc, 
gfc_expr *expr, tree dim)
   cond = fold_build2_loc (input_location, TRUTH_AND_EXPR, 
boolean_type_node,
  cond, tmp);
 }
-  tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
-gfc_conv_descriptor_ubound_get (desc, idx),
-gfc_conv_descriptor_lbound_get (desc, idx));
-  tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
-tmp, gfc_index_one_node);
+  tmp = gfc_conv_descriptor_extent_get (desc, idx);
   gfc_add_modify (&cond_block, extent

[gcc(refs/users/mikael/heads/refactor_descriptor_v04)] Suppression modification span

2025-03-30 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:ccd1a8797bc1c75a443a237755b3394fe75de895

commit ccd1a8797bc1c75a443a237755b3394fe75de895
Author: Mikael Morin 
Date:   Sat Mar 29 11:39:49 2025 +0100

Suppression modification span

Diff:
---
 gcc/fortran/trans-expr.cc | 5 -
 1 file changed, 5 deletions(-)

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index c5cbe2efca49..171fbd78fe6c 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -10912,11 +10912,6 @@ gfc_trans_pointer_assignment (gfc_expr * expr1, 
gfc_expr * expr2)
{
  rse.expr = gfc_class_data_get (rse.expr);
  gfc_add_modify (&lse.pre, desc, rse.expr);
- /* Set the lhs span.  */
- tmp = TREE_TYPE (rse.expr);
- tmp = TYPE_SIZE_UNIT (gfc_get_element_type (tmp));
- tmp = fold_convert (gfc_array_index_type, tmp);
- gfc_conv_descriptor_span_set (&lse.pre, desc, tmp);
}
  else
{


[gcc(refs/users/mikael/heads/refactor_descriptor_v04)] Factorisation gfc_conv_array_extent_dim

2025-03-30 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:0ae779bf3365bafc7b8f6cc51298779333ba22ed

commit 0ae779bf3365bafc7b8f6cc51298779333ba22ed
Author: Mikael Morin 
Date:   Sat Mar 29 12:50:41 2025 +0100

Factorisation gfc_conv_array_extent_dim

Diff:
---
 gcc/fortran/trans-intrinsic.cc | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc
index 1b109f822643..cd047aca8149 100644
--- a/gcc/fortran/trans-intrinsic.cc
+++ b/gcc/fortran/trans-intrinsic.cc
@@ -2359,11 +2359,7 @@ gfc_conv_is_contiguous_expr (gfc_se *se, gfc_expr *arg)
{
  tmp = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[i]);
  extent = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[i]);
- extent = fold_build2_loc (input_location, MINUS_EXPR,
-   gfc_array_index_type, extent, tmp);
- extent = fold_build2_loc (input_location, PLUS_EXPR,
-   gfc_array_index_type, extent,
-   gfc_index_one_node);
+ extent = gfc_conv_array_extent_dim (tmp, extent, nullptr);
  tmp = gfc_conv_descriptor_stride_get (desc, gfc_rank_cst[i]);
  tmp = fold_build2_loc (input_location, MULT_EXPR, TREE_TYPE (tmp),
 tmp, extent);
@@ -2483,10 +2479,7 @@ gfc_conv_intrinsic_bound (gfc_se * se, gfc_expr * expr, 
enum gfc_isym_id op)
 
   ubound = gfc_conv_descriptor_ubound_get (desc, bound);
   lbound = gfc_conv_descriptor_lbound_get (desc, bound);
-  size = fold_build2_loc (input_location, MINUS_EXPR,
- gfc_array_index_type, ubound, lbound);
-  size = fold_build2_loc (input_location, PLUS_EXPR,
- gfc_array_index_type, size, gfc_index_one_node);
+  size = gfc_conv_array_extent_dim (lbound, ubound, nullptr);
 
   /* 13.14.53: Result value for LBOUND


[gcc] Created branch 'mikael/heads/refactor_descriptor_v04' in namespace 'refs/users'

2025-03-30 Thread Mikael Morin via Gcc-cvs
The branch 'mikael/heads/refactor_descriptor_v04' was created in namespace 
'refs/users' pointing to:

 f7eac82b031e... Réduction usages gfc_conv_descriptor_ubound_get


[gcc(refs/users/mikael/heads/refactor_descriptor_v04)] Suppression export gfc_conv_descriptor_span_set

2025-03-30 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:8410cda2b70228d358313cbacc0fe404c91b3ad2

commit 8410cda2b70228d358313cbacc0fe404c91b3ad2
Author: Mikael Morin 
Date:   Sat Mar 29 11:41:45 2025 +0100

Suppression export gfc_conv_descriptor_span_set

Diff:
---
 gcc/fortran/trans-descriptor.cc | 2 +-
 gcc/fortran/trans-descriptor.h  | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index bc2055bf3b56..7e709609435c 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -721,7 +721,7 @@ gfc_conv_descriptor_span_get (tree desc)
   return gfc_descriptor::conv_span_get (desc);
 }
 
-void
+static void
 gfc_conv_descriptor_span_set (stmtblock_t *block, tree desc, tree value)
 {
   return gfc_descriptor::conv_span_set (block, desc, value);
diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h
index 5e8af26d1d8e..b991d2a41895 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -64,7 +64,6 @@ void gfc_conv_descriptor_dtype_set (stmtblock_t *, tree, 
tree);
 void gfc_conv_descriptor_version_set (stmtblock_t *, tree, tree);
 void gfc_conv_descriptor_rank_set (stmtblock_t *, tree, tree);
 void gfc_conv_descriptor_rank_set (stmtblock_t *, tree, int);
-void gfc_conv_descriptor_span_set (stmtblock_t *, tree, tree);
 void gfc_conv_descriptor_ubound_set (stmtblock_t *, tree, tree, tree);
 
 /* CFI descriptor.  */


[gcc r14-11480] LoongArch: doc: Add same-address constraint to the description of '-mld-seq-sa'.

2025-03-30 Thread LuluCheng via Gcc-cvs
https://gcc.gnu.org/g:3d9c933c4cd31806cc9bef3a2b8238370b6df986

commit r14-11480-g3d9c933c4cd31806cc9bef3a2b8238370b6df986
Author: Lulu Cheng 
Date:   Thu Mar 27 11:42:11 2025 +0800

LoongArch: doc: Add same-address constraint to the description of 
'-mld-seq-sa'.

gcc/ChangeLog:

* doc/invoke.texi: Modify the description of '-mld-seq-sa'.

(cherry picked from commit 8ad8f74972923bf2b6d6291d31ef53c4ded4)

Diff:
---
 gcc/doc/invoke.texi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 6a94c7b70a5f..c85cac24f3ce 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -27211,8 +27211,8 @@ Use (do not use) @code{amcas[_db].@{b/h/w/d@}} 
instructions.  When build with
 @opindex mno-ld-seq-sa
 @item -mld-seq-sa
 @itemx -mno-ld-seq-sa
-Whether a load-load barrier (@code{dbar 0x700}) is needed.  When build with
-@option{-march=la664}, it is enabled by default.  The default is
+Whether a same-address load-load barrier (@code{dbar 0x700}) is needed.  When
+build with @option{-march=la664}, it is enabled by default.  The default is
 @option{-mno-ld-seq-sa}, the load-load barrier is needed.
 
 @opindex mtls-dialect


[gcc r15-9050] libstdc++: Fix up string _M_constructor exports [PR103827]

2025-03-30 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:78aed0ae5de801cc1e8220b214145300b28da562

commit r15-9050-g78aed0ae5de801cc1e8220b214145300b28da562
Author: Jakub Jelinek 
Date:   Mon Mar 31 07:39:53 2025 +0200

libstdc++: Fix up string _M_constructor exports [PR103827]

On Thu, Mar 27, 2025 at 02:04:24PM +0100, Jan Hubicka wrote:
> Seems I missed the approval, sorry.  I will push it - I think it would
> be useful to have it in.

Unfortunately the exports in this patch only work on targets where size_t is
unsigned long, not e.g. on ia32 where it is unsigned int, or targets where
it is unsigned long long.

2025-03-31  Jakub Jelinek  

PR tree-optimization/103827
PR tree-optimization/80331
PR tree-optimization/87502
* config/abi/pre/gnu.ver (GLIBCXX_3.4.34): Use [jmy] rather than m
in pattern for _M_construct(char const*, size_t).

Diff:
---
 libstdc++-v3/config/abi/pre/gnu.ver | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/config/abi/pre/gnu.ver 
b/libstdc++-v3/config/abi/pre/gnu.ver
index eb230290313c..10bf9975d450 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -2540,9 +2540,9 @@ GLIBCXX_3.4.34 {
 
_ZNSt8__format25__locale_encoding_to_utf8ERKSt6localeSt17basic_string_viewIcSt11char_traitsIcEEPv;
 # __sso_string constructor and destructor
 _ZNSt12__sso_string[CD][12]Ev;
-# void std::__cxx11::basic_string, 
std::allocator >::_M_construct(char const*, unsigned long)
+# void std::__cxx11::basic_string, 
std::allocator >::_M_construct(char const*, size_t)
 # and wide char version
-
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE12_M_constructILb[01]EEEvPK[cw]m;
+
_ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE12_M_constructILb[01]EEEvPK[cw][jmy];
 } GLIBCXX_3.4.33;
 
 # Symbols in the support library (libsupc++) have their own tag.


[gcc r15-9044] Doc: Organize atomic memory builtins documentation [PR42270]

2025-03-30 Thread Sandra Loosemore via Gcc-cvs
https://gcc.gnu.org/g:34efc890bf7df099e85b34e596dea82f3596aab2

commit r15-9044-g34efc890bf7df099e85b34e596dea82f3596aab2
Author: Sandra Loosemore 
Date:   Wed Mar 26 14:56:02 2025 +

Doc: Organize atomic memory builtins documentation [PR42270]

This is part of an incremental effort to make the chapter on GCC
extensions better organized by grouping/rearranging sections by topic.

This installment adds a container section to hold documentation for
both the _atomic and _sync builtins, reordering them so that the new
_atomic interface is presented before the legacy _sync one.  I also
incorporated material from the separate x86 transactional memory
section directly into the __atomic builtins documentation instead of
retaining that as a parallel section.

gcc/ChangeLog
PR other/42270
* doc/extend.texi (Atomic Memory Access): New section.
(__sync Builtins): Make it a subsection of the above.
(Atomic Memory Access): Likewise.
(x86 specific memory model extensions for transactional memory):
Delete this section, incorporating the text into the discussion
of __atomic builtins.

Diff:
---
 gcc/doc/extend.texi | 371 +++-
 1 file changed, 196 insertions(+), 175 deletions(-)

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 68f9398590f4..de9c2b36ba38 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -14243,11 +14243,9 @@ a function call results in a compile-time error.
 * Return Address::  Getting the return or frame address of a function.
 * Stack Scrubbing:: Stack scrubbing internal interfaces.
 * Vector Extensions::   Using vector instructions through built-in functions.
-* __sync Builtins:: Legacy built-in functions for atomic memory access.
-* __atomic Builtins::   Atomic built-in functions with memory model.
+* Atomic Memory Access:: __atomic and __sync builtins.
 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
 arithmetic overflow checking.
-* x86 specific memory model extensions for transactional memory:: x86 memory 
models.
 * Object Size Checking:: Built-in functions for limited buffer overflow
 checking.
 * New/Delete Builtins:: Built-in functions for C++ allocations and 
deallocations.
@@ -16175,149 +16173,27 @@ x = foo ((v128) @{_mm_adds_epu8 (x.mm, y.mm)@});
 @c but GCC does not accept it for unions of vector types (PR 88955).
 @end smallexample
 
-@node __sync Builtins
-@section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
-
-The following built-in functions
-are intended to be compatible with those described
-in the @cite{Intel Itanium Processor-specific Application Binary Interface},
-section 7.4.  As such, they depart from normal GCC practice by not using
-the @samp{__builtin_} prefix and also by being overloaded so that they
-work on multiple types.
-
-The definition given in the Intel documentation allows only for the use of
-the types @code{int}, @code{long}, @code{long long} or their unsigned
-counterparts.  GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
-size other than the C type @code{_Bool} or the C++ type @code{bool}.
-Operations on pointer arguments are performed as if the operands were
-of the @code{uintptr_t} type.  That is, they are not scaled by the size
-of the type to which the pointer points.
-
-These functions are implemented in terms of the @samp{__atomic}
-builtins (@pxref{__atomic Builtins}).  They should not be used for new
-code which should use the @samp{__atomic} builtins instead.
-
-Not all operations are supported by all target processors.  If a particular
-operation cannot be implemented on the target processor, a call to an
-external function is generated.  The external function carries the same name
-as the built-in version, with an additional suffix
-@samp{_@var{n}} where @var{n} is the size of the data type.
-
-In most cases, these built-in functions are considered a @dfn{full barrier}.
-That is,
-no memory operand is moved across the operation, either forward or
-backward.  Further, instructions are issued as necessary to prevent the
-processor from speculating loads across the operation and from queuing stores
-after the operation.
-
-All of the routines are described in the Intel documentation to take
-``an optional list of variables protected by the memory barrier''.  It's
-not clear what is meant by that; it could mean that @emph{only} the
-listed variables are protected, or it could mean a list of additional
-variables to be protected.  The list is ignored by GCC which treats it as
-empty.  GCC interprets an empty list as meaning that all globally
-accessible variables should be protected.
-
-@defbuiltin{@var{type} __sync_fetch_and_add (@var{type} *@var{ptr}, @var{type} 
@var{value}, ...)}
-@defbuiltinx{@var{type} __sync_fetch_and_sub (@var{

[gcc r15-9051] c++: Honor noipa attribute for FE nothrow discovery [PR119518]

2025-03-30 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:94816c640adf33bb25c79b9a0d5a74d35724b650

commit r15-9051-g94816c640adf33bb25c79b9a0d5a74d35724b650
Author: Jakub Jelinek 
Date:   Mon Mar 31 07:51:04 2025 +0200

c++: Honor noipa attribute for FE nothrow discovery [PR119518]

The following testcase has different code generation in bar depending on
whether foo is defined or just declared.
That is undesirable when it has noipa attribute, that attribute is
documented to be a black box between caller and callee, so the caller
shouldn't know about any implicitly determined properties of the callee
and callee shouldn't know about its callers.

E.g. the ipa-pure-const passes including nothrow discovery in there all
honor noipa attribute, but the FE did not.

2025-03-31  Jakub Jelinek  

PR c++/119518
* decl.cc (finish_function): Don't set TREE_NOTHROW for
functions with "noipa" attribute even when we can prove
they can't throw.

* g++.dg/opt/pr119518.C: New test.

Diff:
---
 gcc/cp/decl.cc  |  3 ++-
 gcc/testsuite/g++.dg/opt/pr119518.C | 20 
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 7d10b228ec62..2ed94fd786ce 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -19454,7 +19454,8 @@ finish_function (bool inline_p)
   && !cp_function_chain->can_throw
   && !flag_non_call_exceptions
   && !decl_replaceable_p (fndecl,
- opt_for_fn (fndecl, flag_semantic_interposition)))
+ opt_for_fn (fndecl, flag_semantic_interposition))
+  && !lookup_attribute ("noipa", DECL_ATTRIBUTES (fndecl)))
 TREE_NOTHROW (fndecl) = 1;
 
  cleanup:
diff --git a/gcc/testsuite/g++.dg/opt/pr119518.C 
b/gcc/testsuite/g++.dg/opt/pr119518.C
new file mode 100644
index ..152b8806fdc3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr119518.C
@@ -0,0 +1,20 @@
+// PR c++/119518
+// { dg-do compile }
+// { dg-options "-O2 -fdump-tree-optimized" }
+// { dg-final { scan-tree-dump "S::~S \\\(&s\\\)" "optimized" } }
+
+[[gnu::noipa, noreturn]] void
+foo ()
+{
+  for (;;)
+;
+}
+
+struct S { ~S (); };
+
+void
+bar ()
+{
+  S s;
+  foo ();
+}


[gcc r15-9035] IRA+LRA: Let the backend request to split basic blocks

2025-03-30 Thread Maciej W. Rozycki via Gcc-cvs
https://gcc.gnu.org/g:89f03fd59fbe151b2efee354c616862a9b194ed9

commit r15-9035-g89f03fd59fbe151b2efee354c616862a9b194ed9
Author: Maciej W. Rozycki 
Date:   Sun Mar 30 15:24:50 2025 +0100

IRA+LRA: Let the backend request to split basic blocks

The next change for Alpha will produce extra labels and branches in
reload, which in turn requires basic blocks to be split at completion.
We do this already for functions that can trap, so just extend the
arrangement with a flag for the backend to use whenever it finds it
necessary.

gcc/
* function.h (struct function): Add
`split_basic_blocks_after_reload' member.
* lra.cc (lra): Handle it.
* reload1.cc (reload): Likewise.

Diff:
---
 gcc/function.h | 3 +++
 gcc/lra.cc | 6 --
 gcc/reload1.cc | 6 --
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/gcc/function.h b/gcc/function.h
index e8aa52fc780a..2260d6704ecc 100644
--- a/gcc/function.h
+++ b/gcc/function.h
@@ -449,6 +449,9 @@ struct GTY(()) function {
   /* Set for artificial function created for [[assume (cond)]].
  These should be GIMPLE optimized, but not expanded to RTL.  */
   unsigned int assume_function : 1;
+
+  /* Nonzero if reload will have to split basic blocks.  */
+  unsigned int split_basic_blocks_after_reload : 1;
 };
 
 /* Add the decl D to the local_decls list of FUN.  */
diff --git a/gcc/lra.cc b/gcc/lra.cc
index 8c6991751e5c..2b3014f160cf 100644
--- a/gcc/lra.cc
+++ b/gcc/lra.cc
@@ -2615,8 +2615,10 @@ lra (FILE *f, int verbose)
 
   inserted_p = fixup_abnormal_edges ();
 
-  /* We've possibly turned single trapping insn into multiple ones.  */
-  if (cfun->can_throw_non_call_exceptions)
+  /* Split basic blocks if we've possibly turned single trapping insn
+ into multiple ones or otherwise the backend requested to do so.  */
+  if (cfun->can_throw_non_call_exceptions
+  || cfun->split_basic_blocks_after_reload)
 {
   auto_sbitmap blocks (last_basic_block_for_fn (cfun));
   bitmap_ones (blocks);
diff --git a/gcc/reload1.cc b/gcc/reload1.cc
index fe4fe58981c9..64ec74e2bf5f 100644
--- a/gcc/reload1.cc
+++ b/gcc/reload1.cc
@@ -1272,8 +1272,10 @@ reload (rtx_insn *first, int global)
 
   inserted = fixup_abnormal_edges ();
 
-  /* We've possibly turned single trapping insn into multiple ones.  */
-  if (cfun->can_throw_non_call_exceptions)
+  /* Split basic blocks if we've possibly turned single trapping insn
+ into multiple ones or otherwise the backend requested to do so.  */
+  if (cfun->can_throw_non_call_exceptions
+  || cfun->split_basic_blocks_after_reload)
 {
   auto_sbitmap blocks (last_basic_block_for_fn (cfun));
   bitmap_ones (blocks);


[gcc r15-9048] Docs: make regenerate-opt-urls

2025-03-30 Thread Sandra Loosemore via Gcc-cvs
https://gcc.gnu.org/g:f7085e23148d415e8fefbcbea72cef607aa1

commit r15-9048-gf7085e23148d415e8fefbcbea72cef607aa1
Author: Sandra Loosemore 
Date:   Sun Mar 30 22:05:51 2025 +

Docs: make regenerate-opt-urls

gcc/c-family/ChangeLog
* c.opt.urls: Regenerate.

gcc/d/ChangeLog
* lang.opt.urls: Regenerate.

gcc/m2/ChangeLog
* lang.opt.urls: Regenerate.

Diff:
---
 gcc/c-family/c.opt.urls | 4 ++--
 gcc/d/lang.opt.urls | 2 +-
 gcc/m2/lang.opt.urls| 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/c-family/c.opt.urls b/gcc/c-family/c.opt.urls
index fd7ffd38d538..dcd81dc28d5f 100644
--- a/gcc/c-family/c.opt.urls
+++ b/gcc/c-family/c.opt.urls
@@ -983,8 +983,8 @@ 
UrlSuffix(gcc/Warning-Options.html#index-Wzero-length-bounds)
 
 ; skipping UrlSuffix for 'ansi' due to multiple URLs:
 ;   duplicate: 'gcc/C-Dialect-Options.html#index-ansi-1'
+;   duplicate: 'gcc/Library-Builtins.html#index-ansi-2'
 ;   duplicate: 'gcc/Non-bugs.html#index-ansi-3'
-;   duplicate: 'gcc/Other-Builtins.html#index-ansi-2'
 ;   duplicate: 'gcc/Standards.html#index-ansi'
 
 ; skipping UrlSuffix for 'd' due to multiple URLs:
@@ -1014,7 +1014,7 @@ 
UrlSuffix(gcc/C_002b_002b-Dialect-Options.html#index-fassume-sane-operators-new-
 
 ; skipping UrlSuffix for 'fbuiltin' due to multiple URLs:
 ;   duplicate: 'gcc/C-Dialect-Options.html#index-fbuiltin'
-;   duplicate: 'gcc/Other-Builtins.html#index-fno-builtin-3'
+;   duplicate: 'gcc/Library-Builtins.html#index-fno-builtin-3'
 ;   duplicate: 'gcc/Warning-Options.html#index-fno-builtin-1'
 ; skipping LangUrlSuffix_D for 'fbuiltin' due to multiple URLs:
 ;   duplicate: 'gdc/Other-Builtins.html#index-fno-builtin-1'
diff --git a/gcc/d/lang.opt.urls b/gcc/d/lang.opt.urls
index 8fcb441a10fb..40bbca74b0ed 100644
--- a/gcc/d/lang.opt.urls
+++ b/gcc/d/lang.opt.urls
@@ -110,7 +110,7 @@ 
LangUrlSuffix_D(gdc/Runtime-Options.html#index-fbounds-check) LangUrlSuffix_Fort
 
 ; skipping UrlSuffix for 'fbuiltin' due to multiple URLs:
 ;   duplicate: 'gcc/C-Dialect-Options.html#index-fbuiltin'
-;   duplicate: 'gcc/Other-Builtins.html#index-fno-builtin-3'
+;   duplicate: 'gcc/Library-Builtins.html#index-fno-builtin-3'
 ;   duplicate: 'gcc/Warning-Options.html#index-fno-builtin-1'
 ; skipping LangUrlSuffix_D for 'fbuiltin' due to multiple URLs:
 ;   duplicate: 'gdc/Other-Builtins.html#index-fno-builtin-1'
diff --git a/gcc/m2/lang.opt.urls b/gcc/m2/lang.opt.urls
index 4c3e6905c2c6..dc1dbf06371a 100644
--- a/gcc/m2/lang.opt.urls
+++ b/gcc/m2/lang.opt.urls
@@ -72,8 +72,8 @@ UrlSuffix(gcc/Preprocessor-Options.html#index-P) 
LangUrlSuffix_Fortran(gfortran/
 
 ; skipping UrlSuffix for 'ansi' due to multiple URLs:
 ;   duplicate: 'gcc/C-Dialect-Options.html#index-ansi-1'
+;   duplicate: 'gcc/Library-Builtins.html#index-ansi-2'
 ;   duplicate: 'gcc/Non-bugs.html#index-ansi-3'
-;   duplicate: 'gcc/Other-Builtins.html#index-ansi-2'
 ;   duplicate: 'gcc/Standards.html#index-ansi'
 
 ; skipping UrlSuffix for 'c' due to multiple URLs:


[gcc/devel/omp/gcc-14] OpenACC: array reductions bug fixes

2025-03-30 Thread Chung-Lin Tang via Gcc-cvs
https://gcc.gnu.org/g:0a5e48f68ff8d2e581031def92eef5bf3338934b

commit 0a5e48f68ff8d2e581031def92eef5bf3338934b
Author: Chung-Lin Tang 
Date:   Sun Mar 30 21:04:45 2025 +

OpenACC: array reductions bug fixes

This is a merge of the v4 to v5 diff patch from:
https://gcc.gnu.org/pipermail/gcc-patches/2025-March/679682.html

This patch fixes issues found for NVPTX sm_70 testing, and another issue
related to copying to reduction buffer for worker/vector mode.

gcc/ChangeLog:

* config/gcn/gcn-tree.cc (gcn_goacc_reduction_setup): Fix array case
copy source into reduction buffer.
* config/nvptx/nvptx.cc (nvptx_expand_shared_addr): Move default 
size
init setting place.
(enum nvptx_builtins): Add NVPTX_BUILTIN_BAR_WARPSYNC.
(nvptx_init_builtins): Add DEF() of nvptx_builtin_bar_warpsync.
(nvptx_expand_builtin): Expand NVPTX_BUILTIN_BAR_WARPSYNC.
(nvptx_goacc_reduction_setup): Fix array case copy source into 
reduction
buffer.
(nvptx_goacc_reduction_fini): Add bar.warpsync for at end of 
vector-mode
reductions for sm_70 and above.

libgomp/ChangeLog:

* testsuite/libgomp.oacc-c-c++-common/reduction-arrays-2.c: Adjust 
test.
* testsuite/libgomp.oacc-c-c++-common/reduction-arrays-3.c: 
Likewise.
* testsuite/libgomp.oacc-c-c++-common/reduction-arrays-4.c: 
Likewise.
* testsuite/libgomp.oacc-c-c++-common/reduction-arrays-5.c: 
Likewise.

Diff:
---
 gcc/config/gcn/gcn-tree.cc |  3 +-
 gcc/config/nvptx/nvptx.cc  | 32 --
 .../libgomp.oacc-c-c++-common/reduction-arrays-2.c | 24 
 .../libgomp.oacc-c-c++-common/reduction-arrays-3.c | 24 
 .../libgomp.oacc-c-c++-common/reduction-arrays-4.c | 24 
 .../libgomp.oacc-c-c++-common/reduction-arrays-5.c | 24 
 6 files changed, 122 insertions(+), 9 deletions(-)

diff --git a/gcc/config/gcn/gcn-tree.cc b/gcc/config/gcn/gcn-tree.cc
index a71aadc395a0..97f35cd6f7a0 100644
--- a/gcc/config/gcn/gcn-tree.cc
+++ b/gcc/config/gcn/gcn-tree.cc
@@ -750,13 +750,14 @@ gcn_goacc_reduction_setup (gcall *call)
   tree offset = gimple_call_arg (call, 5);
   if (array_p)
{
+ tree copy_src = !integer_zerop (ref_to_res) ? ref_to_res : array_addr;
  tree decl = gcn_goacc_get_worker_array_reduction_buffer
(array_type, array_max_idx, &seq);
  tree ptr = make_ssa_name (TREE_TYPE (array_addr));
  gimplify_assign (ptr, build_fold_addr_expr (decl), &seq);
 
  /* Store incoming value to worker reduction buffer.  */
- oacc_build_array_copy (ptr, array_addr, array_max_idx, &seq);
+ oacc_build_array_copy (ptr, copy_src, array_max_idx, &seq);
}
   else
{
diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index 886a39a26e95..8e5d9ecce70a 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -6500,16 +6500,16 @@ nvptx_expand_shared_addr (tree exp, rtx target,
   if (TREE_CONSTANT (size_expr))
 size = TREE_INT_CST_LOW (size_expr);
 
+  /* Default size for unknown size expression.  */
+  if (size == 0)
+size = 256;
+
   if (vector)
 {
   offload_attrs oa;
 
   populate_offload_attrs (&oa);
 
-  /* Default size for unknown size expression.  */
-  if (size == 0)
-   size = 256;
-
   unsigned int psize = ROUND_UP (size + offset, align);
   unsigned int pnum = nvptx_mach_max_workers ();
   vector_red_partition = MAX (vector_red_partition, psize);
@@ -6605,6 +6605,7 @@ enum nvptx_builtins
   NVPTX_BUILTIN_BAR_RED_AND,
   NVPTX_BUILTIN_BAR_RED_OR,
   NVPTX_BUILTIN_BAR_RED_POPC,
+  NVPTX_BUILTIN_BAR_WARPSYNC,
   NVPTX_BUILTIN_BREV,
   NVPTX_BUILTIN_BREVLL,
   NVPTX_BUILTIN_COND_UNI,
@@ -6737,6 +6738,8 @@ nvptx_init_builtins (void)
   DEF (BAR_RED_POPC, "bar_red_popc",
(UINT, UINT, UINT, UINT, UINT, NULL_TREE));
 
+  DEF (BAR_WARPSYNC, "bar_warpsync", (VOID, VOID, NULL_TREE));
+
   DEF (BREV, "brev", (UINT, UINT, NULL_TREE));
   DEF (BREVLL, "brevll", (LLUINT, LLUINT, NULL_TREE));
 
@@ -6787,6 +6790,10 @@ nvptx_expand_builtin (tree exp, rtx target, rtx 
ARG_UNUSED (subtarget),
 case NVPTX_BUILTIN_BAR_RED_POPC:
   return nvptx_expand_bar_red (exp, target, mode, ignore);
 
+case NVPTX_BUILTIN_BAR_WARPSYNC:
+  emit_insn (gen_nvptx_warpsync ());
+  return NULL_RTX;
+
 case NVPTX_BUILTIN_BREV:
 case NVPTX_BUILTIN_BREVLL:
   return nvptx_expand_brev (exp, target, mode, ignore);
@@ -7758,11 +7765,11 @@ nvptx_goacc_reduction_setup (gcall *call, offload_attrs 
*oa)
 
   push_gimplify_context (true);
 
+  /* Copy the receiver object.  */
+  tree ref_to_res = gimple_call_arg (call, 1);
+
   if (level != GOMP_DIM_GANG)
 {
-  /* Copy the receiver obje