[gcc r16-3308] Fortran: gfortran PDT component access [PR84122, PR85942]

2025-08-20 Thread Paul Thomas via Gcc-cvs
https://gcc.gnu.org/g:243b5b23c7e60af875f62a63dd6348e63d237243

commit r16-3308-g243b5b23c7e60af875f62a63dd6348e63d237243
Author: Paul Thomas 
Date:   Thu Aug 21 07:24:02 2025 +0100

Fortran: gfortran PDT component access [PR84122, PR85942]

2025-08-21  Paul Thomas  

gcc/fortran
PR fortran/84122
* parse.cc (parse_derived): PDT type parameters are not allowed
an explicit access specification and must appear before a
PRIVATE statement. If a PRIVATE statement is seen, mark all the
other components as PRIVATE.

PR fortran/85942
* simplify.cc (get_kind): Convert a PDT KIND component into a
specification expression using the default initializer.

gcc/testsuite/
PR fortran/84122
* gfortran.dg/pdt_38.f03: New test.

PR fortran/85942
* gfortran.dg/pdt_39.f03: New test.

Diff:
---
 gcc/fortran/parse.cc |  35 +-
 gcc/fortran/simplify.cc  |  16 +
 gcc/testsuite/gfortran.dg/pdt_38.f03 |  21 ++
 gcc/testsuite/gfortran.dg/pdt_39.f03 | 123 +++
 4 files changed, 193 insertions(+), 2 deletions(-)

diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc
index 300a7a36fbdd..b29f69008417 100644
--- a/gcc/fortran/parse.cc
+++ b/gcc/fortran/parse.cc
@@ -3938,6 +3938,7 @@ parse_derived (void)
   gfc_state_data s;
   gfc_symbol *sym;
   gfc_component *c, *lock_comp = NULL, *event_comp = NULL;
+  bool pdt_parameters;
 
   accept_statement (ST_DERIVED_DECL);
   push_state (&s, COMP_DERIVED, gfc_new_block);
@@ -3946,9 +3947,11 @@ parse_derived (void)
   seen_private = 0;
   seen_sequence = 0;
   seen_component = 0;
+  pdt_parameters = false;
 
   compiling_type = 1;
 
+
   while (compiling_type)
 {
   st = next_statement ();
@@ -3961,6 +3964,31 @@ parse_derived (void)
case ST_PROCEDURE:
  accept_statement (st);
  seen_component = 1;
+ /* Type parameters must not have an explicit access specification
+and must be placed before a PRIVATE statement. If a PRIVATE
+statement is encountered after type parameters, mark the remaining
+components as PRIVATE. */
+ for (c = gfc_current_block ()->components; c; c = c->next)
+   if (!c->next && (c->attr.pdt_kind || c->attr.pdt_len))
+ {
+   pdt_parameters = true;
+   if (c->attr.access != ACCESS_UNKNOWN)
+ {
+   gfc_error ("Access specification of a type parameter at "
+  "%C is not allowed");
+   c->attr.access = ACCESS_PUBLIC;
+   break;
+ }
+   if (seen_private)
+ {
+   gfc_error ("The type parameter at %C must come before a "
+  "PRIVATE statement");
+   break;
+ }
+ }
+   else if (pdt_parameters && seen_private
+&& !(c->attr.pdt_kind || c->attr.pdt_len))
+ c->attr.access = ACCESS_PRIVATE;
  break;
 
case ST_FINAL:
@@ -3986,7 +4014,7 @@ endType:
  break;
}
 
- if (seen_component)
+ if (seen_component && !pdt_parameters)
{
  gfc_error ("PRIVATE statement at %C must precede "
 "structure components");
@@ -3996,7 +4024,10 @@ endType:
  if (seen_private)
gfc_error ("Duplicate PRIVATE statement at %C");
 
- s.sym->component_access = ACCESS_PRIVATE;
+ if (pdt_parameters)
+   s.sym->component_access = ACCESS_PUBLIC;
+ else
+   s.sym->component_access = ACCESS_PRIVATE;
 
  accept_statement (ST_PRIVATE);
  seen_private = 1;
diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc
index b25cd2c2388b..00b02f341206 100644
--- a/gcc/fortran/simplify.cc
+++ b/gcc/fortran/simplify.cc
@@ -120,10 +120,26 @@ static int
 get_kind (bt type, gfc_expr *k, const char *name, int default_kind)
 {
   int kind;
+  gfc_expr *tmp;
 
   if (k == NULL)
 return default_kind;
 
+  if (k->expr_type == EXPR_VARIABLE
+  && k->symtree->n.sym->ts.type == BT_DERIVED
+  && k->symtree->n.sym->ts.u.derived->attr.pdt_type)
+{
+  gfc_ref *ref;
+  for (ref = k->ref; ref; ref = ref->next)
+   if (!ref->next && ref->type == REF_COMPONENT
+   && ref->u.c.component->attr.pdt_kind
+   && ref->u.c.component->initializer)
+ {
+   tmp = gfc_copy_expr (ref->u.c.component->initializer);
+   gfc_replace_expr (k, tmp);
+ }
+}
+
   if (k->expr_type != EXPR_CONSTANT)
 {
   gfc_error ("KIND parameter of %s at %L must be an initialization "
diff --git a/gcc/testsuite/gfortran.dg/pdt_38.f03 
b/gcc/testsuite/gfortran.dg/pdt_38.f03
new file mode 100

[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Corrections régressions char_eoshift_1 char_eoshift_3 eoshift_large_1...

2025-08-20 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:cc68e41ca61c7d7b14b174835638661506a112c5

commit cc68e41ca61c7d7b14b174835638661506a112c5
Author: Mikael Morin 
Date:   Wed Aug 20 21:41:29 2025 +0200

Corrections régressions char_eoshift_1 char_eoshift_3 eoshift_large_1...

Diff:
---
 libgfortran/intrinsics/eoshift0.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libgfortran/intrinsics/eoshift0.c 
b/libgfortran/intrinsics/eoshift0.c
index 397d0e0c018b..a3f0c20bf9e2 100644
--- a/libgfortran/intrinsics/eoshift0.c
+++ b/libgfortran/intrinsics/eoshift0.c
@@ -150,8 +150,9 @@ eoshift0 (gfc_array_char * ret, const gfc_array_char * 
array,
 
 so a block move can be used for dim>1.  */
   len = GFC_DESCRIPTOR_SPACING(array, which)
-   * GFC_DESCRIPTOR_EXTENT(array, which);
-  shift *= GFC_DESCRIPTOR_SPACING(array, which);
+   * GFC_DESCRIPTOR_EXTENT(array, which)
+   / size;
+  shift *= GFC_DESCRIPTOR_SPACING(array, which) / size;
   roffset = size;
   soffset = size;
   for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)


[gcc r16-3304] Regenerate common.opt.urls for -fdiagnostics-show-context

2025-08-20 Thread Qing Zhao via Gcc-cvs
https://gcc.gnu.org/g:6747672747cd86f75519f814816b7f83ddaedcc2

commit r16-3304-g6747672747cd86f75519f814816b7f83ddaedcc2
Author: Qing Zhao 
Date:   Wed Aug 20 18:16:23 2025 +

Regenerate common.opt.urls for -fdiagnostics-show-context

When -fdiagnostics-show-context[=DEPTH] was added, they were documented, but
common.opt.urls wasn't regenerated.

gcc/ChangeLog:

* common.opt.urls: Regenerate.

Diff:
---
 gcc/common.opt.urls | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/gcc/common.opt.urls b/gcc/common.opt.urls
index 0bc36c483d3b..3684edd63073 100644
--- a/gcc/common.opt.urls
+++ b/gcc/common.opt.urls
@@ -649,6 +649,12 @@ 
UrlSuffix(gcc/Diagnostic-Message-Formatting-Options.html#index-fdiagnostics-show
 fdiagnostics-show-nesting-levels
 
UrlSuffix(gcc/Diagnostic-Message-Formatting-Options.html#index-fdiagnostics-show-nesting-levels)
 
+fdiagnostics-show-context
+UrlSuffix(gcc/Diagnostic-Message-Formatting-Options.html#index-fdiagnostics-show-context)
+
+fdiagnostics-show-context=
+UrlSuffix(gcc/Diagnostic-Message-Formatting-Options.html#index-fdiagnostics-show-context)
+
 fdisable-
 UrlSuffix(gcc/Developer-Options.html#index-fdisable-)


[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Correction régression pr19928-2

2025-08-20 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:bcc8260a409633d0f648c4d92044434092b9db69

commit bcc8260a409633d0f648c4d92044434092b9db69
Author: Mikael Morin 
Date:   Wed Aug 20 20:24:15 2025 +0200

Correction régression pr19928-2

Diff:
---
 gcc/fortran/trans-array.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 683b09481dde..0e4b2ca0ba72 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -3177,7 +3177,7 @@ gfc_conv_ss_descriptor (stmtblock_t * block, gfc_ss * ss, 
int base)
 analysis by pulling the expressions for elemental array indices
 inside the loop.  */
   if (save_descriptor_data (se.expr, data) && !ss->is_alloc_lhs)
-   tmp = gfc_evaluate_now (data, block);
+   data = gfc_evaluate_now (data, block);
   info->data = data;
 
   tmp = gfc_conv_array_offset (se.expr);


[gcc r16-3301] Merge aarch64-cc-fusion into late-combine

2025-08-20 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:724d88900b7aa8f249b737a33e9b11eedf48ebae

commit r16-3301-g724d88900b7aa8f249b737a33e9b11eedf48ebae
Author: Richard Sandiford 
Date:   Wed Aug 20 13:20:02 2025 +0100

Merge aarch64-cc-fusion into late-combine

I'd added the aarch64-specific CC fusion pass to fold a PTEST
instruction into the instruction that feeds the PTEST, in cases
where the latter instruction can set the appropriate flags as a
side-effect.

Combine does the same optimisation.  However, as explained in the
comments, the PTEST case often has:

  A: set predicate P based on inputs X
  B: clobber X
  C: test P

and so the fusion is only possible if we move C before B.
That's something that combine currently can't do (for the cases
that we needed).

The optimisation was never really AArch64-specific.  It's just that,
in an all-too-familiar fashion, we needed it in stage 3, when it was
too late to add something target-independent.

late-combine adds a convenient place to do the optimisation in a
target-independent way, just as combine is a convenient place to
do its related optimisation.

gcc/
* config.gcc (aarch64*-*-*): Remove aarch64-cc-fusion.o from
extra_objs.
* config/aarch64/aarch64-passes.def (pass_cc_fusion): Delete.
* config/aarch64/aarch64-protos.h (make_pass_cc_fusion): Delete.
* config/aarch64/t-aarch64 (aarch64-cc-fusion.o): Delete.
* config/aarch64/aarch64-cc-fusion.cc: Delete.
* late-combine.cc (late_combine::optimizable_set): Take a set_info *
rather than an insn_info * and move destination tests from...
(late_combine::combine_into_uses): ...here. Take a set_info * rather
an insn_info *.  Take the rtx set.
(late_combine::parallelize_insns, late_combine::combine_cc_setter)
(late_combine::combine_insn): New member functions.
(late_combine::m_parallel): New member variable.
* rtlanal.cc (pattern_cost): Handle sets of CC registers in the
same way as comparisons.

Diff:
---
 gcc/config.gcc  |   2 +-
 gcc/config/aarch64/aarch64-cc-fusion.cc | 297 
 gcc/config/aarch64/aarch64-passes.def   |   1 -
 gcc/config/aarch64/aarch64-protos.h |   1 -
 gcc/config/aarch64/t-aarch64|   6 -
 gcc/late-combine.cc | 243 ++
 gcc/rtlanal.cc  |   3 +-
 7 files changed, 208 insertions(+), 345 deletions(-)

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 56246387ef55..517df40e5dee 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -351,7 +351,7 @@ aarch64*-*-*)
c_target_objs="aarch64-c.o"
cxx_target_objs="aarch64-c.o"
d_target_objs="aarch64-d.o"
-   extra_objs="aarch64-builtins.o aarch-common.o aarch64-elf-metadata.o 
aarch64-sve-builtins.o aarch64-sve-builtins-shapes.o 
aarch64-sve-builtins-base.o aarch64-sve-builtins-sve2.o 
aarch64-sve-builtins-sme.o cortex-a57-fma-steering.o aarch64-speculation.o 
aarch-bti-insert.o aarch64-cc-fusion.o aarch64-early-ra.o aarch64-ldp-fusion.o"
+   extra_objs="aarch64-builtins.o aarch-common.o aarch64-elf-metadata.o 
aarch64-sve-builtins.o aarch64-sve-builtins-shapes.o 
aarch64-sve-builtins-base.o aarch64-sve-builtins-sve2.o 
aarch64-sve-builtins-sme.o cortex-a57-fma-steering.o aarch64-speculation.o 
aarch-bti-insert.o aarch64-early-ra.o aarch64-ldp-fusion.o"
target_gtfiles="\$(srcdir)/config/aarch64/aarch64-protos.h 
\$(srcdir)/config/aarch64/aarch64-builtins.h 
\$(srcdir)/config/aarch64/aarch64-builtins.cc 
\$(srcdir)/config/aarch64/aarch64-sve-builtins.h 
\$(srcdir)/config/aarch64/aarch64-sve-builtins.cc"
target_has_targetm_common=yes
;;
diff --git a/gcc/config/aarch64/aarch64-cc-fusion.cc 
b/gcc/config/aarch64/aarch64-cc-fusion.cc
deleted file mode 100644
index cea54dee298b..
--- a/gcc/config/aarch64/aarch64-cc-fusion.cc
+++ /dev/null
@@ -1,297 +0,0 @@
-// Pass to fuse CC operations with other instructions.
-// Copyright (C) 2021-2025 Free Software Foundation, Inc.
-//
-// This file is part of GCC.
-//
-// GCC is free software; you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation; either version 3, or (at your option) any later
-// version.
-//
-// GCC is distributed in the hope that it will be useful, but WITHOUT ANY
-// WARRANTY; without even the implied warranty of MERCHANTABILITY or
-// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-// for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with GCC; see the file COPYING3.  If not see
-// .
-
-// This pass looks for sequences of the form:
-//
-//A: (set (reg

[gcc r14-11971] tree-sra: Avoid total SRA if there are incompat. aggregate accesses (PR119085)

2025-08-20 Thread Martin Jambor via Gcc-cvs
https://gcc.gnu.org/g:dabac057141c26a69325a410c81de0ff2157c6c9

commit r14-11971-gdabac057141c26a69325a410c81de0ff2157c6c9
Author: Martin Jambor 
Date:   Wed Jul 23 11:22:33 2025 +0200

tree-sra: Avoid total SRA if there are incompat. aggregate accesses  
(PR119085)

We currently use the types encountered in the function body and not in
type declaration to perform total scalarization.  Bug PR 119085
uncovered that we miss a check that when the same data is accessed
with aggregate types that those are actually compatible.  Without it,
we can base total scalarization on a type that does not "cover" all
live data in a different part of the function.  This patch adds the
check.

gcc/ChangeLog:

2025-07-21  Martin Jambor  

PR tree-optimization/119085
* tree-sra.cc (sort_and_splice_var_accesses): Prevent total
scalarization if two incompatible aggregates access the same place.

gcc/testsuite/ChangeLog:

2025-07-21  Martin Jambor  

PR tree-optimization/119085
* gcc.dg/tree-ssa/pr119085.c: New test.

(cherry picked from commit 171fcc80ede596442712e559c4fc787aa4636694)

Diff:
---
 gcc/testsuite/gcc.dg/tree-ssa/pr119085.c | 37 
 gcc/tree-sra.cc  |  6 ++
 2 files changed, 43 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr119085.c 
b/gcc/testsuite/gcc.dg/tree-ssa/pr119085.c
new file mode 100644
index ..e9811ce12b58
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr119085.c
@@ -0,0 +1,37 @@
+/* { dg-do run } */
+/* { dg-options "-O1" } */
+
+struct with_hole {
+  int x;
+  long y;
+};
+struct without_hole {
+  int x;
+  int y;
+};
+union u {
+  struct with_hole with_hole;
+  struct without_hole without_hole;
+};
+
+void __attribute__((noinline))
+test (union u *up, union u u)
+{
+  union u u2;
+  volatile int f = 0;
+  u2 = u;
+  if (f)
+u2.with_hole = u.with_hole;
+  *up = u2;
+}
+
+int main(void)
+{
+  union u u;
+  union u u2;
+  u2.without_hole.y = -1;
+  test (&u, u2);
+  if (u.without_hole.y != -1)
+__builtin_abort ();
+  return 0;
+}
diff --git a/gcc/tree-sra.cc b/gcc/tree-sra.cc
index 75e52e8d9e81..07ef66a4eb68 100644
--- a/gcc/tree-sra.cc
+++ b/gcc/tree-sra.cc
@@ -2480,6 +2480,12 @@ sort_and_splice_var_accesses (tree var)
}
  unscalarizable_region = true;
}
+ /* If there the same place is accessed with two incompatible
+aggregate types, trying to base total scalarization on either of
+them can be wrong.  */
+ if (!first_scalar && !types_compatible_p (access->type, ac2->type))
+   bitmap_set_bit (cannot_scalarize_away_bitmap,
+   DECL_UID (access->base));
 
  if (grp_same_access_path
  && (!ac2->grp_same_access_path


[gcc r16-3300] rtl-ssa: Fix thinko when adding live-out uses

2025-08-20 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:481f96296e87b42b7f25944edd627cc9211dd803

commit r16-3300-g481f96296e87b42b7f25944edd627cc9211dd803
Author: Richard Sandiford 
Date:   Wed Aug 20 13:20:02 2025 +0100

rtl-ssa: Fix thinko when adding live-out uses

While testing a later patch, I found that create_degenerate_phi
had an inverted test for bitmap_set_bit.  It was assuming that
the return value was the previous bit value, rather than a
"something changed" value. :(

Also, the call to add_live_out_use shouldn't be conditional
on the DF_LR_OUT operation, since the register could be live-out
because of uses later in the same EBB (which do not require a
live-out use to be added to the rtl-ssa instruction).  Instead,
add_live_out should itself check whether a live-out use already exists.

gcc/
* rtl-ssa/blocks.cc (function_info::create_degenerate_phi): Fix
inverted test of bitmap_set_bit.  Call add_live_out_use even
if the register was previously live-out from the predecessor block.
Instead...
(function_info::add_live_out_use): ...check here whether a live-out
use already exists.

Diff:
---
 gcc/rtl-ssa/blocks.cc | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/gcc/rtl-ssa/blocks.cc b/gcc/rtl-ssa/blocks.cc
index 953fd9e516ed..a57b9e15f13c 100644
--- a/gcc/rtl-ssa/blocks.cc
+++ b/gcc/rtl-ssa/blocks.cc
@@ -315,15 +315,14 @@ function_info::add_live_out_use (bb_info *bb, set_info 
*def)
 
   // If the end of the block already has an artificial use, that use
   // acts to make DEF live at the appropriate point.
-  use_info *use = def->last_nondebug_insn_use ();
-  if (use && use->insn () == bb->end_insn ())
+  if (find_use (def, bb->end_insn ()).matching_use ())
 return;
 
   // Currently there is no need to maintain a backward link from the end
   // instruction to the list of live-out uses.  Such a list would be
   // expensive to update if it was represented using the usual insn_info
   // access arrays.
-  use = allocate (bb->end_insn (), def->resource (), def);
+  auto *use = allocate (bb->end_insn (), def->resource (), def);
   use->set_is_live_out_use (true);
   add_use (use);
 }
@@ -540,12 +539,12 @@ function_info::create_degenerate_phi (ebb_info *ebb, 
set_info *def)
   basic_block pred_cfg_bb = single_pred (ebb->first_bb ()->cfg_bb ());
   bb_info *pred_bb = this->bb (pred_cfg_bb);
 
-  if (!bitmap_set_bit (DF_LR_IN (ebb->first_bb ()->cfg_bb ()), regno))
+  if (bitmap_set_bit (DF_LR_IN (ebb->first_bb ()->cfg_bb ()), regno))
{
  // The register was not previously live on entry to EBB and
  // might not have been live on exit from PRED_BB either.
- if (bitmap_set_bit (DF_LR_OUT (pred_cfg_bb), regno))
-   add_live_out_use (pred_bb, def);
+ bitmap_set_bit (DF_LR_OUT (pred_cfg_bb), regno);
+ add_live_out_use (pred_bb, def);
}
   else
{


[gcc r16-3299] rtl-ssa: Add a find_uses function

2025-08-20 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:39e822446030c814de92b9de9d251e8a6a5cfba9

commit r16-3299-g39e822446030c814de92b9de9d251e8a6a5cfba9
Author: Richard Sandiford 
Date:   Wed Aug 20 13:20:01 2025 +0100

rtl-ssa: Add a find_uses function

rtl-ssa already has a find_def function for finding the definition
of a particular resource (register or memory) at a particular point
in the program.  This patch adds a similar function for looking
up uses.  Both functions have amortised logarithmic complexity.

gcc/
* rtl-ssa/accesses.h (use_lookup): New class.
* rtl-ssa/functions.h (function_info::find_def): Expand comment.
(function_info::find_use): Declare.
* rtl-ssa/member-fns.inl (use_lookup::prev_use, 
use_lookup::next_use)
(use_lookup::matching_use, use_lookup::matching_or_prev_use)
(use_lookup::matching_or_next_use): New member functions.
* rtl-ssa/accesses.cc (function_info::find_use): Likewise.

Diff:
---
 gcc/rtl-ssa/accesses.cc| 32 
 gcc/rtl-ssa/accesses.h | 36 
 gcc/rtl-ssa/functions.h| 15 +++
 gcc/rtl-ssa/member-fns.inl | 30 ++
 4 files changed, 113 insertions(+)

diff --git a/gcc/rtl-ssa/accesses.cc b/gcc/rtl-ssa/accesses.cc
index 3d929971f56a..0415e9767981 100644
--- a/gcc/rtl-ssa/accesses.cc
+++ b/gcc/rtl-ssa/accesses.cc
@@ -1087,6 +1087,38 @@ rtl_ssa::lookup_use (splay_tree &tree, 
insn_info *insn)
   return tree.lookup (compare);
 }
 
+// See the comment above the declaration.
+use_lookup
+function_info::find_use (set_info *def, insn_info *insn)
+{
+  gcc_assert (!insn->is_debug_insn ());
+  use_info *first = def->first_nondebug_insn_use ();
+  if (!first)
+// There are no uses.  The comparison result is pretty meaningless
+// in this case.
+return { nullptr, -1 };
+
+  // See whether the first use matches.
+  if (*insn <= *first->insn ())
+{
+  int comparison = (insn == first->insn () ? 0 : -1);
+  return { first, comparison };
+}
+
+  // See whether the last use matches.
+  use_info *last = def->last_nondebug_insn_use ();
+  if (*insn >= *last->insn ())
+{
+  int comparison = (insn == last->insn () ? 0 : 1);
+  return { last, comparison };
+}
+
+  // Resort to using a splay tree to search for the result.
+  need_use_splay_tree (def);
+  int comparison = lookup_use (def->m_use_tree, insn);
+  return { def->m_use_tree.root ()->value (), comparison };
+}
+
 // Add USE to USE->def ()'s list of uses. inserting USE immediately before
 // BEFORE.  USE is not currently in the list.
 //
diff --git a/gcc/rtl-ssa/accesses.h b/gcc/rtl-ssa/accesses.h
index 98403f78b37b..b3a31fb78db7 100644
--- a/gcc/rtl-ssa/accesses.h
+++ b/gcc/rtl-ssa/accesses.h
@@ -1044,6 +1044,42 @@ public:
   int comparison;
 };
 
+// This class represents the result of looking for a use of a particular
+// definition at a particular point, here referred to as point P.
+// There are four states:
+//
+// - USE is null if the definition has no uses.
+//
+// - Otherwise, COMPARISON is 0 if we found a definition at P.  USE then
+//   contains this use.
+//
+// - Otherwise, COMPARISON is greater than 0 if we found a use that precedes P.
+//   USE then contains this use.
+//
+// - Otherwise, COMPARISON is less than zero and we found a use that follows P.
+//   USE then contains this use.
+class use_lookup
+{
+public:
+  // If we found a use at P, return that use, otherwise return null.
+  use_info *matching_use () const;
+
+  // If we found a use at P, return that use, otherwise return prev_use ().
+  use_info *matching_or_prev_use () const;
+
+  // If we found a use at P, return that use, otherwise return next_use ().
+  use_info *matching_or_next_use () const;
+
+  // Return the last use that occurs before P, or null if none.
+  use_info *prev_use () const;
+
+  // Return the first use that occurs after P, or null if none.
+  use_info *next_use () const;
+
+  use_info *use;
+  int comparison;
+};
+
 void pp_resource (pretty_printer *, resource_info);
 void pp_access (pretty_printer *, const access_info *,
unsigned int flags = PP_ACCESS_DEFAULT);
diff --git a/gcc/rtl-ssa/functions.h b/gcc/rtl-ssa/functions.h
index 2e20f5e47d72..27cbc18178a7 100644
--- a/gcc/rtl-ssa/functions.h
+++ b/gcc/rtl-ssa/functions.h
@@ -131,8 +131,23 @@ public:
 
   // Look for a definition of RESOURCE at INSN.  Return the result of the
   // search as a def_lookup; see the comments there for more details.
+  //
+  // NOTE: This is not the function to use if INSN is known to be a real
+  // instruction (one with an RTL pattern) and if the caller is only
+  // interested in definitions within INSN itself.  In those cases
+  // it is better to use find_access.
   def_lookup find_def (resource_info resource, insn_info *insn);
 
+  // Search for a use of DEF around non-debug instruction INSN and retur

[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Correction régression pr85938

2025-08-20 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:57de6fa7052db3e7d867fd74b5ca3efe0c558bdd

commit 57de6fa7052db3e7d867fd74b5ca3efe0c558bdd
Author: Mikael Morin 
Date:   Wed Aug 20 16:40:25 2025 +0200

Correction régression pr85938

Diff:
---
 libgfortran/libgfortran.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h
index f930361bc6f6..2ce609bf2297 100644
--- a/libgfortran/libgfortran.h
+++ b/libgfortran/libgfortran.h
@@ -452,7 +452,6 @@ struct {\
   size_t offset;\
   dtype_type dtype;\
   index_type span;\
-  index_type align;\
   descriptor_dimension dim[r];\
 }


[gcc r16-3307] c++: pointer to auto member function [PR120757]

2025-08-20 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:ea6ef13d0fc4e020d8c405333153dad9eee1f18d

commit r16-3307-gea6ef13d0fc4e020d8c405333153dad9eee1f18d
Author: Jason Merrill 
Date:   Tue Aug 19 23:15:20 2025 -0400

c++: pointer to auto member function [PR120757]

Here r13-1210 correctly changed &A::foo to not be considered
type-dependent, but tsubst_expr of the OFFSET_REF got confused trying to
tsubst a type that involved auto.  Fixed by getting the type from the
member rather than tsubst.

PR c++/120757

gcc/cp/ChangeLog:

* pt.cc (tsubst_expr) [OFFSET_REF]: Don't tsubst the type.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/auto-fn66.C: New test.

Diff:
---
 gcc/cp/pt.cc   |  8 ++--
 gcc/testsuite/g++.dg/cpp1y/auto-fn66.C | 20 
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index bb2d0b48fd42..dfabc5437d8b 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -22537,12 +22537,16 @@ tsubst_expr (tree t, tree args, tsubst_flags_t 
complain, tree in_decl)
 
 case OFFSET_REF:
   {
-   tree type = tsubst (TREE_TYPE (t), args, complain, in_decl);
+   /* We should only get here for an OFFSET_REF like A::m; a .* in a
+  template is represented as a DOTSTAR_EXPR.  */
+   gcc_checking_assert
+ (same_type_p (TREE_TYPE (t), TREE_TYPE (TREE_OPERAND (t, 1;
tree op0 = RECUR (TREE_OPERAND (t, 0));
tree op1 = RECUR (TREE_OPERAND (t, 1));
+   tree type = TREE_TYPE (op1);
r = build2 (OFFSET_REF, type, op0, op1);
PTRMEM_OK_P (r) = PTRMEM_OK_P (t);
-   if (!mark_used (TREE_OPERAND (r, 1), complain)
+   if (!mark_used (op1, complain)
&& !(complain & tf_error))
  RETURN (error_mark_node);
RETURN (r);
diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn66.C 
b/gcc/testsuite/g++.dg/cpp1y/auto-fn66.C
new file mode 100644
index ..413154c2a7f8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn66.C
@@ -0,0 +1,20 @@
+// PR c++/120757
+// { dg-do compile { target c++14 } }
+
+template  struct A
+{
+  auto foo() {}
+};
+
+auto bar(void (A::*)()) {}
+
+template  auto baz()
+{
+  bar(&A::foo);
+}
+
+int main()
+{
+  baz<0>();
+  return 0;
+}


[gcc r16-3309] MAINTAINERS: Update my email address and stand down as AArch64 maintainer

2025-08-20 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:e56e05bca4fb52ffafec749582e3464035693ce7

commit r16-3309-ge56e05bca4fb52ffafec749582e3464035693ce7
Author: Richard Sandiford 
Date:   Thu Aug 21 07:51:56 2025 +0100

MAINTAINERS: Update my email address and stand down as AArch64 maintainer

Today is my last working day at Arm, so this patch switches my
MAINTAINERS entries to my personal email address.  (It turns out
that I never updated some of the later entries...oops)

In order to avoid setting false expectations, and to try to avoid
getting in the way, I'm also standing down as an AArch64 maintainer,
effective EOB today.  I might still end up reviewing the odd AArch64
patch under global reviewership though, depending on how things go :)

ChangeLog:

* MAINTAINERS: Update my email address and stand down as AArch64
maintainer.

Diff:
---
 MAINTAINERS | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 50b7a3fe75f5..205e6a4c4b02 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -40,7 +40,7 @@ Michael Meissner

 Jason Merrill   
 David S. Miller 
 Joseph Myers
-Richard Sandiford   
+Richard Sandiford   
 Bernd Schmidt   
 Ian Lance Taylor
 Jim Wilson  
@@ -56,7 +56,6 @@ docs, and the testsuite related to that.
 
 aarch64 ldp/stp Alex Coplan 
 aarch64 portRichard Earnshaw
-aarch64 portRichard Sandiford   
 aarch64 portTamar Christina 
 aarch64 portKyrylo Tkachov  
 alpha port  Richard Henderson   


[gcc r16-3297] AVR: target/121608 - Don't add --relax when linking with -r.

2025-08-20 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:0f15ff7b511493e9197e6153b794081c1557ba02

commit r16-3297-g0f15ff7b511493e9197e6153b794081c1557ba02
Author: Georg-Johann Lay 
Date:   Wed Aug 20 10:53:37 2025 +0200

AVR: target/121608 - Don't add --relax when linking with -r.

The linker rejects --relax in relocatable links (-r), hence only
add --relax when -r is not specified.

gcc/
PR target/121608
* config/avr/specs.h (LINK_RELAX_SPEC): Wrap in %{!r...}.

Diff:
---
 gcc/config/avr/specs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/avr/specs.h b/gcc/config/avr/specs.h
index ff269bf43bdf..c95c75856cb0 100644
--- a/gcc/config/avr/specs.h
+++ b/gcc/config/avr/specs.h
@@ -57,7 +57,7 @@ along with GCC; see the file COPYING3.  If not see
   "%(asm_errata_skip) "
 
 #define LINK_RELAX_SPEC \
-  "%{mrelax:--relax} "
+  "%{!r:%{mrelax:--relax}} "
 
 #undef  LINK_SPEC
 #define LINK_SPEC   \


[gcc r15-10251] AVR: target/121608 - Don't add --relax when linking with -r.

2025-08-20 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:f8c8edf88d98c22a74019b79fbc26d15207789f7

commit r15-10251-gf8c8edf88d98c22a74019b79fbc26d15207789f7
Author: Georg-Johann Lay 
Date:   Wed Aug 20 10:53:37 2025 +0200

AVR: target/121608 - Don't add --relax when linking with -r.

The linker rejects --relax in relocatable links (-r), hence only
add --relax when -r is not specified.

gcc/
PR target/121608
* config/avr/specs.h (LINK_RELAX_SPEC): Wrap in %{!r...}.

(cherry picked from commit 0f15ff7b511493e9197e6153b794081c1557ba02)

Diff:
---
 gcc/config/avr/specs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/avr/specs.h b/gcc/config/avr/specs.h
index ff269bf43bdf..c95c75856cb0 100644
--- a/gcc/config/avr/specs.h
+++ b/gcc/config/avr/specs.h
@@ -57,7 +57,7 @@ along with GCC; see the file COPYING3.  If not see
   "%(asm_errata_skip) "
 
 #define LINK_RELAX_SPEC \
-  "%{mrelax:--relax} "
+  "%{!r:%{mrelax:--relax}} "
 
 #undef  LINK_SPEC
 #define LINK_SPEC   \


[gcc r13-9847] AVR: target/121608 - Don't add --relax when linking with -r.

2025-08-20 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:d15bb53c43ceeafea8cc2f0b8f944eb29324a5d9

commit r13-9847-gd15bb53c43ceeafea8cc2f0b8f944eb29324a5d9
Author: Georg-Johann Lay 
Date:   Wed Aug 20 10:53:37 2025 +0200

AVR: target/121608 - Don't add --relax when linking with -r.

The linker rejects --relax in relocatable links (-r), hence only
add --relax when -r is not specified.

gcc/
PR target/121608
* config/avr/specs.h (LINK_RELAX_SPEC): Wrap in %{!r...}.

(cherry picked from commit 0f15ff7b511493e9197e6153b794081c1557ba02)

Diff:
---
 gcc/config/avr/specs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/avr/specs.h b/gcc/config/avr/specs.h
index b4a5ee6e5fc8..8b1dd9520942 100644
--- a/gcc/config/avr/specs.h
+++ b/gcc/config/avr/specs.h
@@ -59,7 +59,7 @@ along with GCC; see the file COPYING3.  If not see
   "%{mmcu=*:-m%*} "
 
 #define LINK_RELAX_SPEC \
-  "%{mrelax:--relax} "
+  "%{!r:%{mrelax:--relax}} "
 
 #undef  LINK_SPEC
 #define LINK_SPEC   \


[gcc r14-11969] AVR: target/121608 - Don't add --relax when linking with -r.

2025-08-20 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:038c48eb789655fa8a56ac5cd07dd98f8712ec5e

commit r14-11969-g038c48eb789655fa8a56ac5cd07dd98f8712ec5e
Author: Georg-Johann Lay 
Date:   Wed Aug 20 10:53:37 2025 +0200

AVR: target/121608 - Don't add --relax when linking with -r.

The linker rejects --relax in relocatable links (-r), hence only
add --relax when -r is not specified.

gcc/
PR target/121608
* config/avr/specs.h (LINK_RELAX_SPEC): Wrap in %{!r...}.

(cherry picked from commit 0f15ff7b511493e9197e6153b794081c1557ba02)

Diff:
---
 gcc/config/avr/specs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/avr/specs.h b/gcc/config/avr/specs.h
index 0ccc37b8844a..717102eb9266 100644
--- a/gcc/config/avr/specs.h
+++ b/gcc/config/avr/specs.h
@@ -57,7 +57,7 @@ along with GCC; see the file COPYING3.  If not see
   "%(asm_errata_skip) "
 
 #define LINK_RELAX_SPEC \
-  "%{mrelax:--relax} "
+  "%{!r:%{mrelax:--relax}} "
 
 #undef  LINK_SPEC
 #define LINK_SPEC   \


[gcc r16-3303] Provide new option -fdiagnostics-show-context=N for -Warray-bounds, -Wstringop-* warnings [PR109071,

2025-08-20 Thread Qing Zhao via Gcc-cvs
https://gcc.gnu.org/g:6faa3cfe60ff9769d1bebfffdd2c7325217d7389

commit r16-3303-g6faa3cfe60ff9769d1bebfffdd2c7325217d7389
Author: Qing Zhao 
Date:   Wed Aug 20 15:56:06 2025 +

Provide new option -fdiagnostics-show-context=N for -Warray-bounds, 
-Wstringop-* warnings 
[PR109071,PR85788,PR88771,PR106762,PR108770,PR115274,PR117179]

'-fdiagnostics-show-context[=DEPTH]'
'-fno-diagnostics-show-context'
 With this option, the compiler might print the interesting control
 flow chain that guards the basic block of the statement which has
 the warning.  DEPTH is the maximum depth of the control flow chain.
 Currently, The list of the impacted warning options includes:
 '-Warray-bounds', '-Wstringop-overflow', '-Wstringop-overread',
 '-Wstringop-truncation'.  and '-Wrestrict'.  More warning options
 might be added to this list in future releases.  The forms
 '-fdiagnostics-show-context' and '-fno-diagnostics-show-context'
 are aliases for '-fdiagnostics-show-context=1' and
 '-fdiagnostics-show-context=0', respectively.

For example:

$ cat t.c
extern void warn(void);
static inline void assign(int val, int *regs, int *index)
{
  if (*index >= 4)
warn();
  *regs = val;
}
struct nums {int vals[4];};

void sparx5_set (int *ptr, struct nums *sg, int index)
{
  int *val = &sg->vals[index];

  assign(0,ptr, &index);
  assign(*val, ptr, &index);
}

$ gcc -Wall -O2  -c -o t.o t.c
t.c: In function ‘sparx5_set’:
t.c:12:23: warning: array subscript 4 is above array bounds of ‘int[4]’ 
[-Warray-bounds=]
   12 |   int *val = &sg->vals[index];
  |^~~
t.c:8:18: note: while referencing ‘vals’
8 | struct nums {int vals[4];};
  |   ^~~~

In the above, Although the warning is correct in theory, the warning message
itself is confusing to the end-user since there is information that cannot
be connected to the source code directly.

It will be a nice improvement to add more information in the warning message
to report where such index value come from.

With the new option -fdiagnostics-show-context=1, the warning message for
the above testing case is now:

$ gcc -Wall -O2 -fdiagnostics-show-context=1 -c -o t.o t.c
t.c: In function ‘sparx5_set’:
t.c:12:23: warning: array subscript 4 is above array bounds of ‘int[4]’ 
[-Warray-bounds=]
   12 |   int *val = &sg->vals[index];
  |^~~
  ‘sparx5_set’: events 1-2
4 |   if (*index >= 4)
  |  ^
  |  |
  |  (1) when the condition is evaluated to true
..
   12 |   int *val = &sg->vals[index];
  |~~~
  ||
  |(2) warning happens here
t.c:8:18: note: while referencing ‘vals’
8 | struct nums {int vals[4];};
  |   ^~~~

PR tree-optimization/109071
PR tree-optimization/85788
PR tree-optimization/88771
PR tree-optimization/106762
PR tree-optimization/108770
PR tree-optimization/115274
PR tree-optimization/117179

gcc/ChangeLog:

* Makefile.in (OBJS): Add diagnostic-context-rich-location.o.
* common.opt (fdiagnostics-show-context): New option.
(fdiagnostics-show-context=): New option.
* diagnostic-context-rich-location.cc: New file.
* diagnostic-context-rich-location.h: New file.
* doc/invoke.texi (fdiagnostics-details): Add
documentation for the new options.
* gimple-array-bounds.cc (check_out_of_bounds_and_warn): Add
one new parameter. Use rich location with details for warning_at.
(array_bounds_checker::check_array_ref): Use rich location with
ditails for warning_at.
(array_bounds_checker::check_mem_ref): Add one new parameter.
Use rich location with details for warning_at.
(array_bounds_checker::check_addr_expr): Use rich location with
move_history_diagnostic_path for warning_at.
(array_bounds_checker::check_array_bounds): Call check_mem_ref with
one more parameter.
* gimple-array-bounds.h: Update prototype for check_mem_ref.
* gimple-ssa-warn-access.cc (warn_string_no_nul): Use rich location
with details for warning_at.
(maybe_warn_nonstring_arg): Likewise.
(maybe_warn_for_bound): Likewise.
(warn_for_access): Likewise.
(check_access): Likewise.
(pass_waccess::check_strncat): Likewise.
(pass_waccess::maybe_check_access_sizes): Likewise.
* gimple-ssa-warn-restrict.cc (pass_wrestrict

[gcc r16-3298] tree-optimization/114480 - speedup IDF compute

2025-08-20 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:fc23b539caa16a108bd16bcfcb86fe261a9aa174

commit r16-3298-gfc23b539caa16a108bd16bcfcb86fe261a9aa174
Author: Richard Biener 
Date:   Wed Aug 20 11:06:53 2025 +0200

tree-optimization/114480 - speedup IDF compute

The testcase in the PR shows that it's worth splitting the processing
of the initial workset, which is def_blocks from the main iteration.
This reduces SSA incremental update time from 44.7s to 32.9s.  Further
changing the workset bitmap of the main iteration to a vector
speeds up things further to 23.5s for an overall nearly halving of
the SSA incremental update compile-time and an overall 12% compile-time
saving at -O1.

Using bitmap_ior in the first loop or avoiding (immediate) re-processing
of blocks in def_blocks does not make a measurable difference for the
testcase so I left this as-is.

PR tree-optimization/114480
* cfganal.cc (compute_idf): Split processing of the initial
workset from the main iteration.  Use a vector for the
workset of the main iteration.

Diff:
---
 gcc/cfganal.cc | 44 +---
 1 file changed, 25 insertions(+), 19 deletions(-)

diff --git a/gcc/cfganal.cc b/gcc/cfganal.cc
index 790357507714..3537e7927912 100644
--- a/gcc/cfganal.cc
+++ b/gcc/cfganal.cc
@@ -1679,30 +1679,17 @@ compute_dominance_frontiers (bitmap_head *frontiers)
 bitmap
 compute_idf (bitmap def_blocks, bitmap_head *dfs)
 {
-  bitmap_iterator bi;
+  bitmap_iterator bi, bi2;
   unsigned bb_index, i;
   bitmap phi_insertion_points;
 
   phi_insertion_points = BITMAP_ALLOC (NULL);
 
-  /* Seed the work set with all the blocks in DEF_BLOCKS.  */
-  auto_bitmap work_set;
-  bitmap_copy (work_set, def_blocks);
-  bitmap_tree_view (work_set);
-
-  /* Pop a block off the workset, add every block that appears in
- the original block's DF that we have not already processed to
- the workset.  Iterate until the workset is empty.   Blocks
- which are added to the workset are potential sites for
- PHI nodes.  */
-  while (!bitmap_empty_p (work_set))
+  /* The initial workset is the DEF_BLOCKs, process that first,
+ seeding phi_insertion_points as the start of the worklist
+ for the iteration which then also serves as a visited set.  */
+  EXECUTE_IF_SET_IN_BITMAP (def_blocks, 0, bb_index, bi2)
 {
-  /* The dominance frontier of a block is blocks after it so iterating
- on earlier blocks first is better.
-???  Basic blocks are by no means guaranteed to be ordered in
-optimal order for this iteration.  */
-  bb_index = bitmap_clear_first_set_bit (work_set);
-
   /* Since the registration of NEW -> OLD name mappings is done
 separately from the call to update_ssa, when updating the SSA
 form, the basic blocks where new and/or old names are defined
@@ -1716,9 +1703,28 @@ compute_idf (bitmap def_blocks, bitmap_head *dfs)
 the IDF and of work_set which is at most that of the IDF
 as well.  That makes iterating over the DFS bitmap preferential
 to whole bitmap operations involving also phi_insertion_points.  */
+  EXECUTE_IF_SET_IN_BITMAP (&dfs[bb_index], 0, i, bi)
+   bitmap_set_bit (phi_insertion_points, i);
+}
+
+  /* Seed the work set with the initial phi_insertion_points.  */
+  auto_vec work_set (n_basic_blocks_for_fn (cfun));
+  EXECUTE_IF_SET_IN_BITMAP (phi_insertion_points, 0, i, bi)
+work_set.quick_push (i);
+
+  /* Pop a block off the workset, add every block that appears in
+ the original block's DF that we have not already processed to
+ the workset.  Iterate until the workset is empty.   Blocks
+ which are added to the workset are potential sites for
+ PHI nodes.  */
+  while (!work_set.is_empty ())
+{
+  bb_index = work_set.pop ();
+  gcc_checking_assert (bb_index
+  < (unsigned) last_basic_block_for_fn (cfun));
   EXECUTE_IF_SET_IN_BITMAP (&dfs[bb_index], 0, i, bi)
if (bitmap_set_bit (phi_insertion_points, i))
- bitmap_set_bit (work_set, i);
+ work_set.quick_push (i);
 }
 
   return phi_insertion_points;


[gcc r14-11970] tree-sra: Fix grp_covered flag computation when totally scalarizing (PR117423)

2025-08-20 Thread Martin Jambor via Gcc-cvs
https://gcc.gnu.org/g:10925479cb6f3df25b4670d8c490e010abc4694e

commit r14-11970-g10925479cb6f3df25b4670d8c490e010abc4694e
Author: Martin Jambor 
Date:   Fri Jul 18 12:42:11 2025 +0200

tree-sra: Fix grp_covered flag computation when totally scalarizing 
(PR117423)

Testcase of PR 117423 shows a flaw in the fancy way we do "total
scalarization" in SRA now.  We use the types encountered in the
function body and not in type declaration (allowing us to totally
scalarize when only one union field is ever used, since we effectively
"skip" the union then) and can accommodate pre-existing accesses that
happen to fall into padding.

In this case, we skipped the union (bypassing the
totally_scalarizable_type_p check) and the access falling into the
"padding" is an aggregate and so not a candidate for SRA but actually
containing data.  Arguably total scalarization should just bail out
when it encounters this situation (but I decided not to depend on this
mainly because we'd need to detect all cases when we eventually cannot
scalarize, such as when a scalar access has children accesses) but the
actual bug is that the detection if all data in an aggregate is indeed
covered by replacements just assumes that is always the case if total
scalarization triggers which however may not be the case in cases like
this - and perhaps more.

This patch fixes the bug by just assuming that all padding is taken
care of when total scalarization triggered, not that every access was
actually scalarized.

gcc/ChangeLog:

2025-07-17  Martin Jambor  

PR tree-optimization/117423
* tree-sra.cc (analyze_access_subtree): Fix computation of 
grp_covered
flag.

gcc/testsuite/ChangeLog:

2025-07-17  Martin Jambor  

PR tree-optimization/117423
* gcc.dg/tree-ssa/pr117423.c: New test.

(cherry picked from commit 7375909e9d9e7de23acb4b1e0a965d8faf1943c4)

Diff:
---
 gcc/testsuite/gcc.dg/tree-ssa/pr117423.c | 49 
 gcc/tree-sra.cc  |  9 --
 2 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr117423.c 
b/gcc/testsuite/gcc.dg/tree-ssa/pr117423.c
new file mode 100644
index ..a5d3b29886f8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr117423.c
@@ -0,0 +1,49 @@
+/* { dg-do run } */
+/* { dg-options "-O1" } */
+
+struct s4 {
+int _0;
+};
+struct s1 {
+unsigned char _4;
+long _1;
+};
+struct s2 {
+union {
+struct s3 {
+unsigned char _1;
+struct s4 _0;
+} var_0;
+struct s1 var_1;
+} DATA;
+};
+int f1(int arg0) { return arg0 > 12345; }
+__attribute__((noinline))
+struct s4 f2(int arg0) {
+struct s4 rv = {arg0};
+return rv;
+}
+struct s2 f3(int arg0) {
+struct s2 rv;
+struct s1 var6 = {0};
+struct s4 var7;
+if (f1(arg0)) {
+rv.DATA.var_1 = var6;
+return rv;
+} else {
+rv.DATA.var_0._1 = 2;
+var7 = f2(arg0);
+rv.DATA.var_0._0 = var7;
+return rv;
+}
+}
+int main() {
+  if (f3(12345).DATA.var_0._0._0 == 12345)
+;
+  else
+__builtin_abort();
+  if (f3(12344).DATA.var_0._0._0 == 12344)
+;
+  else
+__builtin_abort();
+}
diff --git a/gcc/tree-sra.cc b/gcc/tree-sra.cc
index 6e09476418cd..75e52e8d9e81 100644
--- a/gcc/tree-sra.cc
+++ b/gcc/tree-sra.cc
@@ -2865,7 +2865,10 @@ analyze_access_subtree (struct access *root, struct 
access *parent,
 
   for (child = root->first_child; child; child = child->next_sibling)
 {
-  hole |= covered_to < child->offset;
+  if (totally)
+   covered_to = child->offset;
+  else
+   hole |= covered_to < child->offset;
   sth_created |= analyze_access_subtree (child, root,
 allow_replacements && !scalar
 && !root->grp_partial_lhs,
@@ -2876,6 +2879,8 @@ analyze_access_subtree (struct access *root, struct 
access *parent,
covered_to += child->size;
   else
hole = true;
+  if (totally && !hole)
+   covered_to = limit;
 }
 
   if (allow_replacements && scalar && !root->first_child
@@ -2948,7 +2953,7 @@ analyze_access_subtree (struct access *root, struct 
access *parent,
root->grp_total_scalarization = 0;
 }
 
-  if (!hole || totally)
+  if (!hole)
 root->grp_covered = 1;
   else if (root->grp_write || comes_initialized_p (root->base))
 root->grp_unscalarized_data = 1; /* not covered and written to */


[gcc r16-3302] sra: Make build_ref_for_offset static [PR121568]

2025-08-20 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:39acf3c9dd767626b422843adb8f5be06206af08

commit r16-3302-g39acf3c9dd767626b422843adb8f5be06206af08
Author: Andrew Pinski 
Date:   Tue Aug 19 16:14:57 2025 -0700

sra: Make build_ref_for_offset static [PR121568]

build_ref_for_offset was originally made external
with r0-95095-g3f84bf08c48ea4. The call was extracted
out into ipa_get_jf_ancestor_result by r0-110216-g310bc6334823b9.
Then the call was removed by r10-7273-gf3280e4c0c98e1.
So there is no use of build_ref_for_offset outside of SRA, so
let's make it static again.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/121568
gcc/ChangeLog:

* ipa-prop.h (build_ref_for_offset): Remove.
* tree-sra.cc (build_ref_for_offset): Make static.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/ipa-prop.h  | 4 
 gcc/tree-sra.cc | 2 +-
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h
index 3bd442fff395..74c9a6378370 100644
--- a/gcc/ipa-prop.h
+++ b/gcc/ipa-prop.h
@@ -1276,10 +1276,6 @@ bool unadjusted_ptr_and_unit_offset (tree op, tree *ret,
 void ipa_get_range_from_ip_invariant (vrange &r, tree val, cgraph_node *node);
 void ipa_prop_cc_finalize (void);
 
-/* From tree-sra.cc:  */
-tree build_ref_for_offset (location_t, tree, poly_int64, bool, tree,
-  gimple_stmt_iterator *, bool);
-
 /* In ipa-cp.cc  */
 void ipa_cp_cc_finalize (void);
 bool ipa_return_value_range (value_range &range, tree decl);
diff --git a/gcc/tree-sra.cc b/gcc/tree-sra.cc
index 24ed2b2aea0e..921664ef470b 100644
--- a/gcc/tree-sra.cc
+++ b/gcc/tree-sra.cc
@@ -1882,7 +1882,7 @@ make_fancy_name (tree expr)
the current one as specified by INSERT_AFTER.  This function is not capable
of handling bitfields.  */
 
-tree
+static tree
 build_ref_for_offset (location_t loc, tree base, poly_int64 offset,
  bool reverse, tree exp_type, gimple_stmt_iterator *gsi,
  bool insert_after)


[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Correction régression bounds_check_22

2025-08-20 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:d77b443e59e01da56ac42266512b800d77e6f99f

commit d77b443e59e01da56ac42266512b800d77e6f99f
Author: Mikael Morin 
Date:   Wed Aug 20 15:57:49 2025 +0200

Correction régression bounds_check_22

Diff:
---
 gcc/fortran/trans-array.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index c0b1752dd879..683b09481dde 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -10642,6 +10642,7 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo 
*loop,
   gfc_add_modify (&unalloc_init_block, guard, logical_false_node);
 
   stmtblock_t loop_pre_block;
+  gfc_init_block (&loop_pre_block);
   gfc_set_empty_descriptor (&loop_pre_block, desc, expr1->rank);
 
   tmp = fold_build2_loc (input_location, EQ_EXPR,


[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Correction reshape_3

2025-08-20 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:5f9271eb7e9c66d7a1e4102dfbba3d81d6a320c1

commit 5f9271eb7e9c66d7a1e4102dfbba3d81d6a320c1
Author: Mikael Morin 
Date:   Wed Aug 20 18:19:07 2025 +0200

Correction reshape_3

Diff:
---
 libgfortran/generated/reshape_c10.c | 8 +++-
 libgfortran/generated/reshape_c16.c | 8 +++-
 libgfortran/generated/reshape_c17.c | 8 +++-
 libgfortran/generated/reshape_c4.c  | 8 +++-
 libgfortran/generated/reshape_c8.c  | 8 +++-
 libgfortran/generated/reshape_i16.c | 8 +++-
 libgfortran/generated/reshape_i4.c  | 8 +++-
 libgfortran/generated/reshape_i8.c  | 8 +++-
 libgfortran/generated/reshape_r10.c | 8 +++-
 libgfortran/generated/reshape_r16.c | 8 +++-
 libgfortran/generated/reshape_r17.c | 8 +++-
 libgfortran/generated/reshape_r4.c  | 8 +++-
 libgfortran/generated/reshape_r8.c  | 8 +++-
 libgfortran/m4/reshape.m4   | 8 +++-
 14 files changed, 42 insertions(+), 70 deletions(-)

diff --git a/libgfortran/generated/reshape_c10.c 
b/libgfortran/generated/reshape_c10.c
index 273ceec8cfbe..521446312bcc 100644
--- a/libgfortran/generated/reshape_c10.c
+++ b/libgfortran/generated/reshape_c10.c
@@ -100,7 +100,6 @@ reshape_c10 (gfc_array_c10 * const restrict ret,
 {
   index_type alloc_size;
 
-  rs = sizeof (GFC_COMPLEX_10);
   spacing = sizeof(GFC_COMPLEX_10);
   for (index_type n = 0; n < rdim; n++)
{
@@ -108,15 +107,14 @@ reshape_c10 (gfc_array_c10 * const restrict ret,
 
  GFC_DESCRIPTOR_DIMENSION_SET(ret, n, 0, rex - 1, spacing);
 
- rs *= rex;
  spacing *= rex;
}
   ret->offset = 0;
 
-  if (unlikely (rs < 1))
+  if (unlikely (spacing < 1))
 alloc_size = 0;
   else
-alloc_size = rs;
+alloc_size = spacing;
 
   ret->base_addr = xmalloc (alloc_size);
   ret->dtype.rank = rdim;
@@ -161,7 +159,7 @@ reshape_c10 (gfc_array_c10 * const restrict ret,
 {
   index_type ret_extent, source_extent;
 
-  rs = sizeof (GFC_COMPLEX_10);
+  rs = 1;
   for (index_type n = 0; n < rdim; n++)
{
  rs *= shape_data[n];
diff --git a/libgfortran/generated/reshape_c16.c 
b/libgfortran/generated/reshape_c16.c
index e7170605f6b0..13ab5045aa41 100644
--- a/libgfortran/generated/reshape_c16.c
+++ b/libgfortran/generated/reshape_c16.c
@@ -100,7 +100,6 @@ reshape_c16 (gfc_array_c16 * const restrict ret,
 {
   index_type alloc_size;
 
-  rs = sizeof (GFC_COMPLEX_16);
   spacing = sizeof(GFC_COMPLEX_16);
   for (index_type n = 0; n < rdim; n++)
{
@@ -108,15 +107,14 @@ reshape_c16 (gfc_array_c16 * const restrict ret,
 
  GFC_DESCRIPTOR_DIMENSION_SET(ret, n, 0, rex - 1, spacing);
 
- rs *= rex;
  spacing *= rex;
}
   ret->offset = 0;
 
-  if (unlikely (rs < 1))
+  if (unlikely (spacing < 1))
 alloc_size = 0;
   else
-alloc_size = rs;
+alloc_size = spacing;
 
   ret->base_addr = xmalloc (alloc_size);
   ret->dtype.rank = rdim;
@@ -161,7 +159,7 @@ reshape_c16 (gfc_array_c16 * const restrict ret,
 {
   index_type ret_extent, source_extent;
 
-  rs = sizeof (GFC_COMPLEX_16);
+  rs = 1;
   for (index_type n = 0; n < rdim; n++)
{
  rs *= shape_data[n];
diff --git a/libgfortran/generated/reshape_c17.c 
b/libgfortran/generated/reshape_c17.c
index 8103a75d4592..74eb45c4fb6c 100644
--- a/libgfortran/generated/reshape_c17.c
+++ b/libgfortran/generated/reshape_c17.c
@@ -100,7 +100,6 @@ reshape_c17 (gfc_array_c17 * const restrict ret,
 {
   index_type alloc_size;
 
-  rs = sizeof (GFC_COMPLEX_17);
   spacing = sizeof(GFC_COMPLEX_17);
   for (index_type n = 0; n < rdim; n++)
{
@@ -108,15 +107,14 @@ reshape_c17 (gfc_array_c17 * const restrict ret,
 
  GFC_DESCRIPTOR_DIMENSION_SET(ret, n, 0, rex - 1, spacing);
 
- rs *= rex;
  spacing *= rex;
}
   ret->offset = 0;
 
-  if (unlikely (rs < 1))
+  if (unlikely (spacing < 1))
 alloc_size = 0;
   else
-alloc_size = rs;
+alloc_size = spacing;
 
   ret->base_addr = xmalloc (alloc_size);
   ret->dtype.rank = rdim;
@@ -161,7 +159,7 @@ reshape_c17 (gfc_array_c17 * const restrict ret,
 {
   index_type ret_extent, source_extent;
 
-  rs = sizeof (GFC_COMPLEX_17);
+  rs = 1;
   for (index_type n = 0; n < rdim; n++)
{
  rs *= shape_data[n];
diff --git a/libgfortran/generated/reshape_c4.c 
b/libgfortran/generated/reshape_c4.c
index d78e56b2e277..87d968739228 100644
--- a/libgfortran/generated/reshape_c4.c
+++ b/libgfortran/generated/reshape_c4.c
@@ -100,7 +100,6 @@ reshape_c4 (gfc_array_c4 * const restrict ret,
 {
   index_type alloc_size;
 
-  rs = sizeof (GFC_COMPLEX_4);
   spacing = sizeof(GFC_COMPLEX_4);
   for (index_type n = 0; n < rdim; n++)
{
@@ -108,15 +107,14 @@ reshape_c4 (gfc_array_c4 * cons

[gcc r16-3305] c++: lambda capture and shadowing [PR121553]

2025-08-20 Thread Marek Polacek via Gcc-cvs
https://gcc.gnu.org/g:51fbd1e4ea8023847d786a0fdc89219e93bcc666

commit r16-3305-g51fbd1e4ea8023847d786a0fdc89219e93bcc666
Author: Marek Polacek 
Date:   Wed Aug 20 10:49:47 2025 -0400

c++: lambda capture and shadowing [PR121553]

P2036 says that this:

  [x=1]{ int x; }

should be rejected, but with my P2036 we started giving an error
for the attached testcase as well, breaking Dolphin.  So let's
keep the error only for init-captures.

PR c++/121553

gcc/cp/ChangeLog:

* name-lookup.cc (check_local_shadow): Check 
!is_normal_capture_proxy.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wshadow-19.C: Revert P2036 changes.
* g++.dg/warn/Wshadow-6.C: Likewise.
* g++.dg/warn/Wshadow-20.C: New test.
* g++.dg/warn/Wshadow-21.C: New test.

Reviewed-by: Jason Merrill 

Diff:
---
 gcc/cp/name-lookup.cc  | 3 ++-
 gcc/testsuite/g++.dg/warn/Wshadow-19.C | 4 ++--
 gcc/testsuite/g++.dg/warn/Wshadow-20.C | 7 +++
 gcc/testsuite/g++.dg/warn/Wshadow-21.C | 8 
 gcc/testsuite/g++.dg/warn/Wshadow-6.C  | 8 
 5 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index 46147905e041..ba6246776258 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -3355,7 +3355,8 @@ check_local_shadow (tree decl)
&& TREE_CODE (old) == PARM_DECL)
   /* We should also give an error for
   [x=1]{ int x; }  */
-  || is_capture_proxy (old)))
+  || (is_capture_proxy (old)
+  && !is_normal_capture_proxy (old
{
  /* Go to where the parms should be and see if we find
 them there.  */
diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-19.C 
b/gcc/testsuite/g++.dg/warn/Wshadow-19.C
index d0b8dba8549f..4f3425328eca 100644
--- a/gcc/testsuite/g++.dg/warn/Wshadow-19.C
+++ b/gcc/testsuite/g++.dg/warn/Wshadow-19.C
@@ -1,5 +1,5 @@
 // { dg-do compile }
-// { dg-options "-Wshadow -Wpedantic" }
+// { dg-options "-Wshadow" }
 
 void
 foo (int x)
@@ -10,7 +10,7 @@ foo (int x)
 extern int y;  // { dg-warning "declaration of 
'y' shadows a previous local" }
   }
 #if __cplusplus >= 201102L
-  auto fn = [x] () { extern int x; return 0; };// { dg-warning 
"declaration of 'int x' shadows a parameter" "" { target c++11 } }
+  auto fn = [x] () { extern int x; return 0; };// { dg-warning 
"declaration of 'x' shadows a lambda capture" "" { target c++11 } }
 #endif
 }
 
diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-20.C 
b/gcc/testsuite/g++.dg/warn/Wshadow-20.C
new file mode 100644
index ..420373b9ca8e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wshadow-20.C
@@ -0,0 +1,7 @@
+// PR c++/121553
+// { dg-do compile { target c++11 } }
+
+void foo () {
+ int i;
+  auto f = [i] () { int i; return 0; };
+}
diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-21.C 
b/gcc/testsuite/g++.dg/warn/Wshadow-21.C
new file mode 100644
index ..9b71a082514b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wshadow-21.C
@@ -0,0 +1,8 @@
+// PR c++/121553
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wshadow" }
+
+void foo () {
+ int i;
+  auto f = [i] () { int i; return 0; }; // { dg-warning "declaration of .i. 
shadows a lambda capture" }
+}
diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-6.C 
b/gcc/testsuite/g++.dg/warn/Wshadow-6.C
index 7b44d52781aa..1d8d21b9b6f1 100644
--- a/gcc/testsuite/g++.dg/warn/Wshadow-6.C
+++ b/gcc/testsuite/g++.dg/warn/Wshadow-6.C
@@ -33,8 +33,8 @@ void f2(struct S i, int j) {
 
 void f3(int i) {
  [=]{
-   int j = i;  // { dg-message "previously declared here" }
-   int i;  // { dg-error "shadows a parameter" }
+   int j = i;  // { dg-message "shadowed declaration" }
+   int i;  // { dg-warning "shadows a lambda capture" }
i = 1;
  };
 }
@@ -42,8 +42,8 @@ void f3(int i) {
 template 
 void f4(int i) {
  [=]{
-   int j = i;  // { dg-message "previously declared here" }
-   int i;  // { dg-error "shadows a parameter" }
+   int j = i;  // { dg-message "shadowed declaration" }
+   int i;  // { dg-warning "shadows a " }
i = 1;
  };
 }


[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Correction régressions cshift_1, cshift_large_1, simplify_cshift_4

2025-08-20 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:8ca0837e3ff28d20ec2ad8574640e4bf52018ae3

commit 8ca0837e3ff28d20ec2ad8574640e4bf52018ae3
Author: Mikael Morin 
Date:   Wed Aug 20 21:24:42 2025 +0200

Correction régressions cshift_1, cshift_large_1, simplify_cshift_4

Diff:
---
 libgfortran/generated/cshift0_c10.c | 9 +
 libgfortran/generated/cshift0_c16.c | 9 +
 libgfortran/generated/cshift0_c17.c | 9 +
 libgfortran/generated/cshift0_c4.c  | 9 +
 libgfortran/generated/cshift0_c8.c  | 9 +
 libgfortran/generated/cshift0_i1.c  | 9 +
 libgfortran/generated/cshift0_i16.c | 9 +
 libgfortran/generated/cshift0_i2.c  | 9 +
 libgfortran/generated/cshift0_i4.c  | 9 +
 libgfortran/generated/cshift0_i8.c  | 9 +
 libgfortran/generated/cshift0_r10.c | 9 +
 libgfortran/generated/cshift0_r16.c | 9 +
 libgfortran/generated/cshift0_r17.c | 9 +
 libgfortran/generated/cshift0_r4.c  | 9 +
 libgfortran/generated/cshift0_r8.c  | 9 +
 libgfortran/m4/cshift0.m4   | 9 +
 16 files changed, 80 insertions(+), 64 deletions(-)

diff --git a/libgfortran/generated/cshift0_c10.c 
b/libgfortran/generated/cshift0_c10.c
index a4cf3df20e03..a1dd7ad7495e 100644
--- a/libgfortran/generated/cshift0_c10.c
+++ b/libgfortran/generated/cshift0_c10.c
@@ -116,8 +116,9 @@ cshift0_c10 (gfc_array_c10 *ret, const gfc_array_c10 
*array, ptrdiff_t shift,
   roffset = sizeof (GFC_COMPLEX_10);
   soffset = sizeof (GFC_COMPLEX_10);
   len = GFC_DESCRIPTOR_SPACING(array, which)
-   * GFC_DESCRIPTOR_EXTENT(array, which);  
-  shift *= GFC_DESCRIPTOR_SPACING(array, which);
+   * GFC_DESCRIPTOR_EXTENT(array, which)
+   / sizeof (GFC_COMPLEX_10);  
+  shift *= GFC_DESCRIPTOR_SPACING(array, which) / sizeof (GFC_COMPLEX_10);
   for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)
{
  count[n] = 0;
@@ -175,8 +176,8 @@ cshift0_c10 (gfc_array_c10 *ret, const gfc_array_c10 
*array, ptrdiff_t shift,
{
  size_t len1 = shift * sizeof (GFC_COMPLEX_10);
  size_t len2 = (len - shift) * sizeof (GFC_COMPLEX_10);
- memcpy (rptr, sptr + shift, len2);
- memcpy (rptr + (len - shift), sptr, len1);
+ memcpy (rptr, ((char*) sptr) + len1, len2);
+ memcpy (((char*) rptr) + len2, sptr, len1);
}
   else
{
diff --git a/libgfortran/generated/cshift0_c16.c 
b/libgfortran/generated/cshift0_c16.c
index bd7140d06708..def7bd22f73d 100644
--- a/libgfortran/generated/cshift0_c16.c
+++ b/libgfortran/generated/cshift0_c16.c
@@ -116,8 +116,9 @@ cshift0_c16 (gfc_array_c16 *ret, const gfc_array_c16 
*array, ptrdiff_t shift,
   roffset = sizeof (GFC_COMPLEX_16);
   soffset = sizeof (GFC_COMPLEX_16);
   len = GFC_DESCRIPTOR_SPACING(array, which)
-   * GFC_DESCRIPTOR_EXTENT(array, which);  
-  shift *= GFC_DESCRIPTOR_SPACING(array, which);
+   * GFC_DESCRIPTOR_EXTENT(array, which)
+   / sizeof (GFC_COMPLEX_16);  
+  shift *= GFC_DESCRIPTOR_SPACING(array, which) / sizeof (GFC_COMPLEX_16);
   for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)
{
  count[n] = 0;
@@ -175,8 +176,8 @@ cshift0_c16 (gfc_array_c16 *ret, const gfc_array_c16 
*array, ptrdiff_t shift,
{
  size_t len1 = shift * sizeof (GFC_COMPLEX_16);
  size_t len2 = (len - shift) * sizeof (GFC_COMPLEX_16);
- memcpy (rptr, sptr + shift, len2);
- memcpy (rptr + (len - shift), sptr, len1);
+ memcpy (rptr, ((char*) sptr) + len1, len2);
+ memcpy (((char*) rptr) + len2, sptr, len1);
}
   else
{
diff --git a/libgfortran/generated/cshift0_c17.c 
b/libgfortran/generated/cshift0_c17.c
index dd3e888d7831..b459194aea1e 100644
--- a/libgfortran/generated/cshift0_c17.c
+++ b/libgfortran/generated/cshift0_c17.c
@@ -116,8 +116,9 @@ cshift0_c17 (gfc_array_c17 *ret, const gfc_array_c17 
*array, ptrdiff_t shift,
   roffset = sizeof (GFC_COMPLEX_17);
   soffset = sizeof (GFC_COMPLEX_17);
   len = GFC_DESCRIPTOR_SPACING(array, which)
-   * GFC_DESCRIPTOR_EXTENT(array, which);  
-  shift *= GFC_DESCRIPTOR_SPACING(array, which);
+   * GFC_DESCRIPTOR_EXTENT(array, which)
+   / sizeof (GFC_COMPLEX_17);  
+  shift *= GFC_DESCRIPTOR_SPACING(array, which) / sizeof (GFC_COMPLEX_17);
   for (dim = which + 1; dim < GFC_DESCRIPTOR_RANK (array); dim++)
{
  count[n] = 0;
@@ -175,8 +176,8 @@ cshift0_c17 (gfc_array_c17 *ret, const gfc_array_c17 
*array, ptrdiff_t shift,
{
  size_t len1 = shift * sizeof (GFC_COMPLEX_17);
  size_t len2 = (len - shift) * sizeof (GFC_COMPLEX_17);
- memcpy (rptr, sptr + shift, len2);
- memcpy (rptr + (len - shift), sptr, len1);
+ memcpy (rptr, ((char*) sptr) + len1, len2);
+ memcpy (((char*) rptr) + len2, sptr, len1);
}
   else

[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Suppression fonction inutilisée

2025-08-20 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:943b93db7d98399bfe60bf2ab79bbd04c1a5baae

commit 943b93db7d98399bfe60bf2ab79bbd04c1a5baae
Author: Mikael Morin 
Date:   Wed Aug 20 10:17:48 2025 +0200

Suppression fonction inutilisée

Diff:
---
 gcc/fortran/match.cc | 16 
 1 file changed, 16 deletions(-)

diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc
index eaba692dd81a..8355a390ee08 100644
--- a/gcc/fortran/match.cc
+++ b/gcc/fortran/match.cc
@@ -7224,22 +7224,6 @@ select_intrinsic_set_tmp (gfc_typespec *ts, const char 
*var_name)
 }
 
 
-static const char *
-get_select_type_var_name ()
-{
-  const char *name = "";
-  gfc_expr *e = gfc_state_stack->construct->expr1;
-  if (e->symtree)
-name = e->symtree->name;
-  for (gfc_ref *r = e->ref; r; r = r->next)
-if (r->type == REF_COMPONENT
-   && strcmp (r->u.c.component->name, "_data") != 0)
-  name = r->u.c.component->name;
-
-  return name;
-}
-
-
 /* Set up a temporary for the current TYPE IS / CLASS IS branch .  */
 
 static void


[gcc r16-3296] Thread the remains of vect_analyze_slp_instance

2025-08-20 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:c548abddf5e0aa5cd3a9cd936f926dc1e2c7af7b

commit r16-3296-gc548abddf5e0aa5cd3a9cd936f926dc1e2c7af7b
Author: Richard Biener 
Date:   Tue Aug 19 14:41:30 2025 +0200

Thread the remains of vect_analyze_slp_instance

vect_analyze_slp_instance still handles stores and reduction chains.
The following threads the special handling of those two kinds,
duplicating vect_build_slp_instance into two specialized entries.

* tree-vect-slp.cc (vect_analyze_slp_reduc_chain): New,
copied from vect_analyze_slp_instance and only handle
slp_inst_kind_reduc_chain.  Inline vect_build_slp_instance.
(vect_analyze_slp_instance): Only handle slp_inst_kind_store.
Inline vect_build_slp_instance.
(vect_build_slp_instance): Remove now unused stmt_info parameter,
remove special code for store groups and reduction chains.
(vect_analyze_slp): Call vect_analyze_slp_reduc_chain
for reduction chain SLP build and adjust.

Diff:
---
 gcc/tree-vect-slp.cc | 491 ---
 1 file changed, 345 insertions(+), 146 deletions(-)

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index fd793a36da81..2eac9d56522d 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -3980,8 +3980,6 @@ vect_build_slp_instance (vec_info *vinfo,
 vec &remain,
 unsigned max_tree_size, unsigned *limit,
 scalar_stmts_to_slp_tree_map_t *bst_map,
-/* ???  We need stmt_info for group splitting.  */
-stmt_vec_info stmt_info_,
 bool force_single_lane)
 {
   /* If there's no budget left bail out early.  */
@@ -4017,7 +4015,6 @@ vect_build_slp_instance (vec_info *vinfo,
   bool *matches = XALLOCAVEC (bool, group_size);
   poly_uint64 max_nunits = 1;
   unsigned tree_size = 0;
-  unsigned i;
 
   slp_tree node = NULL;
   if (group_size > 1 && force_single_lane)
@@ -4077,68 +4074,343 @@ vect_build_slp_instance (vec_info *vinfo,
 "SLP size %u vs. limit %u.\n",
 tree_size, max_tree_size);
 
- /* Fixup SLP reduction chains.  */
- if (kind == slp_inst_kind_reduc_chain)
+ vinfo->slp_instances.safe_push (new_instance);
+
+ /* ???  We've replaced the old SLP_INSTANCE_GROUP_SIZE with
+the number of scalar stmts in the root in a few places.
+Verify that assumption holds.  */
+ gcc_assert (SLP_TREE_SCALAR_STMTS (SLP_INSTANCE_TREE (new_instance))
+   .length () == group_size);
+
+ if (dump_enabled_p ())
+   {
+ dump_printf_loc (MSG_NOTE, vect_location,
+  "Final SLP tree for instance %p:\n",
+  (void *) new_instance);
+ vect_print_slp_graph (MSG_NOTE, vect_location,
+   SLP_INSTANCE_TREE (new_instance));
+   }
+
+ return true;
+   }
+}
+  /* Failed to SLP.  */
+
+  /* While we arrive here even with slp_inst_kind_store we should only
+ for group_size == 1.  The code to split store groups is only in
+ vect_analyze_slp_instance now.  */
+  gcc_assert (kind != slp_inst_kind_store || group_size == 1);
+
+  /* Free the allocated memory.  */
+  scalar_stmts.release ();
+
+  /* Failed to SLP.  */
+  if (dump_enabled_p ())
+dump_printf_loc (MSG_NOTE, vect_location, "SLP discovery failed\n");
+  return false;
+}
+
+/* Analyze an SLP instance starting from a the start of a reduction chain.
+   Call vect_build_slp_tree to build a tree of packed stmts if possible.
+   Return FALSE if SLP build fails.  */
+
+static bool
+vect_analyze_slp_reduc_chain (vec_info *vinfo,
+ scalar_stmts_to_slp_tree_map_t *bst_map,
+ stmt_vec_info stmt_info,
+ unsigned max_tree_size, unsigned *limit)
+{
+  vec scalar_stmts;
+
+  /* Collect the reduction stmts and store them in scalar_stmts.  */
+  scalar_stmts.create (REDUC_GROUP_SIZE (stmt_info));
+  stmt_vec_info next_info = stmt_info;
+  while (next_info)
+{
+  scalar_stmts.quick_push (vect_stmt_to_vectorize (next_info));
+  next_info = REDUC_GROUP_NEXT_ELEMENT (next_info);
+}
+  /* Mark the first element of the reduction chain as reduction to properly
+ transform the node.  In the reduction analysis phase only the last
+ element of the chain is marked as reduction.  */
+  STMT_VINFO_DEF_TYPE (stmt_info)
+= STMT_VINFO_DEF_TYPE (scalar_stmts.last ());
+  STMT_VINFO_REDUC_DEF (vect_orig_stmt (stmt_info))
+= STMT_VINFO_REDUC_DEF (vect_orig_stmt (scalar_stmts.last ()));
+
+  /* Build the tree for the SLP instance.  */
+  vec root_stmt_infos = vNULL;
+  vec remain = vNULL;
+
+  /* If there's no budget left bail out early.