]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 weeks agoDaily bump.
GCC Administrator [Tue, 23 Sep 2025 00:20:06 +0000 (00:20 +0000)] 
Daily bump.

2 weeks agoRISC-V: Add missing define_insn_reservation to tt-ascalon-d8.md [PR121982]
Peter Bergner [Mon, 22 Sep 2025 17:17:26 +0000 (12:17 -0500)] 
RISC-V: Add missing define_insn_reservation to tt-ascalon-d8.md [PR121982]

The tt-ascalon-d8's pipeline description has reservations for 16-bit, 32-bit
and 64-bit vector integer divides, but was missing a reservation for 8-bit
vector integer divides, leading to an ICE.  Add the missing reservation.

2025-09-22  Peter Bergner  <bergner@tenstorrent.com>

gcc/
PR target/121982
* config/riscv/tt-ascalon-d8.md (tt_ascalon_d8_vec_idiv_byte): New
define_insn_reservation.

gcc/testsuite/
PR target/121982
* gcc.target/riscv/pr121982.c: New test.

Signed-off-by: Peter Bergner <bergner@tenstorrent.com>
2 weeks agoc++: Fix canonical type for lambda pack captures [PR122015]
Nathaniel Shead [Mon, 22 Sep 2025 14:18:43 +0000 (00:18 +1000)] 
c++: Fix canonical type for lambda pack captures [PR122015]

comp_template_parms_position uses whether a TEMPLATE_TYPE_PARM is a pack
to determine equivalency.  This in turn affects whether
canonical_type_parameter finds a pre-existing auto type as equivalent.

When generating the 'auto...' type for a lambda pack capture, we only
mark it as a pack after generating the node (and calculating its
canonical); this means that later when comparing a version streamed in
from a module we think that two equivalent types have different
TYPE_CANONICAL, because the latter already had
TEMPLATE_PARM_PARAMETER_PACK set before calculating its canonical.

This patch fixes this by using a new 'make_auto_pack' function to ensure
that packness is set before the canonical is looked up.

PR c++/122015

gcc/cp/ChangeLog:

* cp-tree.h (make_auto_pack): Declare.
* lambda.cc (lambda_capture_field_type): Use make_auto_pack to
ensure TYPE_CANONICAL is set correctly.
* pt.cc (make_auto_pack): New function.

gcc/testsuite/ChangeLog:

* g++.dg/modules/lambda-11.h: New test.
* g++.dg/modules/lambda-11_a.H: New test.
* g++.dg/modules/lambda-11_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
2 weeks agocontrib: Add DerivedGeneralCategory.txt to comment in libstdc++ script
Jonathan Wakely [Mon, 22 Sep 2025 10:13:01 +0000 (11:13 +0100)] 
contrib: Add DerivedGeneralCategory.txt to comment in libstdc++ script

contrib/ChangeLog:

* unicode/gen_libstdcxx_unicode_data.py: Update comment at the
top of the file to mention DerivedGeneralCategory.txt
prerequisite.

2 weeks agotop-level: Add .editorconfig file
Jonathan Wakely [Fri, 19 Sep 2025 16:28:51 +0000 (17:28 +0100)] 
top-level: Add .editorconfig file

This config file sets default formatting behaviour for a large number
of common editors, see https://editorconfig.org

It also ensures that https://forge.sourceware.org formats GCC code
correctly, because it defaults to tab_width=4 but will respect a
.editorconfig file if present in the repo.

ChangeLog:

* .editorconfig: New file.

2 weeks agofab/gimple-fold: Move __builtin_constant_p folding to gimple-fold [PR121762]
Andrew Pinski [Fri, 19 Sep 2025 21:37:04 +0000 (14:37 -0700)] 
fab/gimple-fold: Move __builtin_constant_p folding to gimple-fold [PR121762]

This is the first patch in removing fold_all_builtins pass.
We want to fold __builtin_constant_p into 0 if we know the argument can't be
a constant. So currently that is done in fab pass (though ranger handles it now too).
Instead of having fab do it we can check PROP_last_full_fold if set and set it
to 0 instead.

Note for -Og, fab was the only place which did this conversion, so we need to
set PROP_last_full_fold for it; later on fab will be removed and isel will do
it instead but that is for another day.

Also instead of going through fold_call_stmt to call fold_builtin_constant_p,
fold_builtin_constant_p is called directly from gimple_fold_builtin_constant_p.
This should speed up the compiling slight :).

Note fab was originally added to do this transformation during the development
of the ssa branch.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/121762
gcc/ChangeLog:

* builtins.cc (fold_builtin_constant_p): Make non-static.
* builtins.h (fold_builtin_constant_p): New declaration.
* gimple-fold.cc (gimple_fold_builtin_constant_p): New function.
(gimple_fold_builtin): Call gimple_fold_builtin_constant_p
for BUILT_IN_CONSTANT_P.
* tree-ssa-ccp.cc (pass_fold_builtins::execute): Set PROP_last_full_fold
on curr_properties. Remove handling of BUILT_IN_CONSTANT_P.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks agolibstdc++: Rework handling of ISO week calendar and week index formatting.
Tomasz Kamiński [Thu, 11 Sep 2025 09:11:06 +0000 (11:11 +0200)] 
libstdc++: Rework handling of ISO week calendar and week index formatting.

The handling of ISO week-calendar year specifiers (%G, %g) and ISO week
number (%V) was merged into a single _M_g_G_V function, as the latter
requires ISO year value, computed by the former.

The values for %U and %W, which are based on the number of days since the
first Sunday and Monday of the year respectively, are now expressed as an
offset from the existing _M_day_of_year field. This reduces redundant
computation. The required flags were also updated to only need _DayOfYear
and _Weekday.

The _M_g_G_V function uses _M_day_of_year to compute __idoy, the day of the
year for the nearest Thursday. This value is used to determine if the ISO
year is the previous year (__idoy <= 0), the current year (__idoy <= 365/366),
next year (__idoy <= 730), or later year. This avoids an expensive conversion
from local_days to year_month_day in most cases. If the ISO calendar year
is current year, the __idoy value is reused for weekday index computation.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h(__formatter_chrono::_M_parse): Update
needed flags for %g, %G, %V, %U, %W.
(__formatter_chrono::_M_format_to): Change how %V is handled.
(__formatter_chrono::_M_g_G): Merged into _M_g_G_V.
(__formatter_chrono::_M_g_G_V): Reworked from _M_g_G.
(__formatter_chrono::_M_U_V_W): Changed into _M_U_V.
(__formatter_chrono::_M_U_W): Reworked implementation.
* testsuite/std/time/year_month_day/io.cc: New tests.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 weeks agolibstdc++: Move start_lifetime_as functions to bits/stl_construct.h [PR106658]
Tomasz Kamiński [Mon, 22 Sep 2025 11:31:17 +0000 (13:31 +0200)] 
libstdc++: Move start_lifetime_as functions to bits/stl_construct.h [PR106658]

This allows inplace_vector to use these functions without including the entire
<memory> header.

Preprocessor checks are changed to use __glibcxx macros, so new functions are
available outside memory header, that exports __cpp_lib macros.

PR libstdc++/106658

libstdc++-v3/ChangeLog:

* include/bits/stl_construct.h (std::start_lifetime_as_array)
(std::start_lifetime_as): Moved from std/memory, with update
to guard macros.
* include/std/memory (std::start_lifetime_as_array)
(std::start_lifetime_as): Moved to bits/stl_construct.h.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 weeks agodoc: Drop broken reference to modindex in libgdiagnostics
Gerald Pfeifer [Sun, 21 Sep 2025 21:40:32 +0000 (23:40 +0200)] 
doc: Drop broken reference to modindex in libgdiagnostics

gcc:
* doc/libgdiagnostics/index.rst: Drop broken reference to
`modindex`.

2 weeks agoWiden-Mul: Fix mis-compile for build_and_insert_cast refinement [PR122021]
Pan Li [Mon, 22 Sep 2025 06:31:41 +0000 (14:31 +0800)] 
Widen-Mul: Fix mis-compile for build_and_insert_cast refinement [PR122021]

The previous refinement in build_and_insert_cast will convert 2
cast into one, aka:

uint16_t _3;

From:
int16_t _4 = (uint16_t)_3; // no-extend
int32_t _5 = (int32_t)_4   // sign-extend 16 => 32

To:
int32_t _5 = (int32_t)_3;  // zero-extend 16 => 32

That will have a problem for sign-extend, the highest bits may be all 1s
but will be loss after convert to zero-extend.  Thus, there will be more
cases if the convert has different types.  Case 1 as above and Case 2,
3, and 4 as following.

Case 2:
  int16_t _3;

  From:
  uint32_t _4 = (uint32_t)_3; // zero-extend 16 => 32
  uint64_t _5 = (uint64_t)_4; // zero-extend 32 => 64

  To:
  uint64_t _5 = (uint32_t)_3; // zero-extend 16 => 64

Case 3:
  uint8_t _3;

  From:
  uint16_t _4 = (uint16_t)_3; // zero-extend 8 => 16
  int32_t _5 = (int32_t)_4;   // zero-extend 16 => 32

  To:
  int32_t _5 = (int32_t)_3;   // zero-extend 8 => 32

Case 4:
  int8_t _3;

  From:
  int16_t _4 = (int16_t)_3;   // sign-extend 8 => 16
  uint32_t _5 = (uint32_t)_4; // zero-extend 16 => 32
  To:
  uint32_t _5 = (uint32_t)_3; // zero-extend 8 => 32

Then, we can see, there will be mis-compile if and only if there is
a cast from small to big size with sign extend.  Thus, restrict the
check and stop prop if there is sign extend cast.

The below test suites are passed for this patch:
1. The rv64gcv fully regression tests.
2. The x86 bootstrap tests.
3. The x86 fully regression tests.

PR middle-end/122021

gcc/ChangeLog:

* tree-ssa-math-opts.cc (build_and_insert_cast): Add sign-extend
check before prop.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr122021-0.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 weeks agotree-optimization/122016 - PRE insertion breaks abnormal coalescing
Richard Biener [Mon, 22 Sep 2025 08:14:31 +0000 (10:14 +0200)] 
tree-optimization/122016 - PRE insertion breaks abnormal coalescing

When PRE asks VN to simplify a NARY but not insert, that bypasses
the abnormal guard in maybe_push_res_to_seq and we blindly accept
new uses of abnormals.  The following fixes this.

PR tree-optimization/122016
* tree-ssa-sccvn.cc (vn_nary_simplify): Do not use the
simplified expression when it references abnormals.

* gcc.dg/torture/pr122016.c: New testcase.

2 weeks agotree-optimization/122023 - rotate pattern with reductions
Richard Biener [Mon, 22 Sep 2025 07:41:05 +0000 (09:41 +0200)] 
tree-optimization/122023 - rotate pattern with reductions

The following disables the use of rotate patterns with reductions
since it breaks then single rotate SSA use-def chain constraints.

PR tree-optimization/122023
* tree-vect-patterns.cc (vect_recog_rotate_pattern): Disable
for rotates.

* gcc.dg/vect/pr122023.c: New testcase.

2 weeks agoAda: Fix internal error on use clause present in generic formal part
Eric Botcazou [Mon, 22 Sep 2025 09:08:34 +0000 (11:08 +0200)] 
Ada: Fix internal error on use clause present in generic formal part

This is a regression present on the mainline and 15 branch: the compiler
aborts on a use clause present in the formal part of a generic unit because
of an oversight in the new inference code for generic actual parameters.

The fix also adds a missing test to Analyze_Dimension_Array_Aggregate.

gcc/ada/
PR ada/121968
* sem_ch12.adb (Associations.Find_Assoc): Add guard for clauses.
* sem_dim.adb (Analyze_Dimension_Array_Aggregate): Add test for
N_Iterated_Component_Association nodes.

2 weeks agopru: Reject bit-fields for TI ABI
Dimitar Dimitrov [Sat, 19 Oct 2024 20:40:35 +0000 (23:40 +0300)] 
pru: Reject bit-fields for TI ABI

TI ABI has non-conventional requirements for bit-fields, which cannot
be implemented with the current target hooks in GCC.

Target hooks are focused on packing and alignment.  But PRU uses packed
structs by default, and has 1 byte alignment for all types.  As an
example, this makes it difficult to implement the TI ABI requirement
for the following struct to be sized to 4 bytes, per the bit-field type:

  struct S { int i : 1; }

Instead of introducing new target hooks and making risky changes to
common GCC code, simply declare bit-fields as not supported in TI ABI
mode.

PRU is a baremetal target.  It has neither support for interrupts nor an
RTOS.  Hence ABI compatibility is not that critical.  I have not seen
any projects which rely on ABI compatibility in order to mix object
files from GCC and the TI proprietary compiler.

The target-specific pass to scan for TI ABI compatibility was rewritten
as an IPA pass.  This allowed scanning not only of function bodies, but
also global variable declarations.  Diagnostic locations should now be
more accurate.  Thus some test cases had to be adjusted.

PR target/116205

gcc/ChangeLog:

* config/pru/pru-passes.cc (class pass_pru_tiabi_check): Make
this an IPA pass.
(chkp_type_has_function_pointer): Remove.
(check_type_tiabi_compatibility): New function.
(chk_function_decl): Rename.
(check_function_decl): Simplify.
(check_op_callback): Rework to use
check_type_tiabi_compatibility.
(pass_pru_tiabi_check::execute): Rework to scan all symbols and
gimple contents of all defined functions.
* config/pru/pru-passes.def (INSERT_PASS_AFTER): Move after
pass_ipa_auto_profile_offline.
* config/pru/pru-protos.h (make_pru_tiabi_check): New
declaration to mark as IPA pass.
(make_pru_minrt_check): Specify it is making a gimple pass.
* doc/invoke.texi: Document that bit-fields are now rejected for
TI ABI.

gcc/testsuite/ChangeLog:

* gcc.target/pru/mabi-ti-1.c: Adjust diagnostic location.
* gcc.target/pru/mabi-ti-2.c: Ditto.
* gcc.target/pru/mabi-ti-3.c: Ditto.
* gcc.target/pru/mabi-ti-5.c: Ditto.
* gcc.target/pru/mabi-ti-6.c: Ditto.
* gcc.target/pru/mabi-ti-7.c: Adjust diagnostic locations and
add global variables for checking.
* gcc.target/pru/mabi-ti-11.c: New test.
* gcc.target/pru/mabi-ti-12.c: New test.
* gcc.target/pru/mabi-ti-8.c: New test.
* gcc.target/pru/mabi-ti-9.c: New test.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2 weeks agoFortran: Fix error recovery after missing END BLOCK [PR103508]
Paul Thomas [Mon, 22 Sep 2025 06:33:07 +0000 (07:33 +0100)] 
Fortran: Fix error recovery after missing END BLOCK [PR103508]

2025-09-22  Steve Kargl  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/103508
* decl.cc (gfc_match_end): Remove only the current partial
rather than removing the entire sibling chain.

gcc/testsuite/
PR fortran/103508
* gfortran.dg/pr103508.f90: New test.

2 weeks agoDaily bump.
GCC Administrator [Mon, 22 Sep 2025 00:18:39 +0000 (00:18 +0000)] 
Daily bump.

2 weeks agofab: Remove forced label check from optimize_unreachable
Andrew Pinski [Fri, 19 Sep 2025 19:23:57 +0000 (12:23 -0700)] 
fab: Remove forced label check from optimize_unreachable

Since optimize_unreachable does not directly remove the bb, we can still remove
the condition that goes to a block containing a forced label. This is a small cleanup
from the original patch which added optimize_unreachable.

The review of the original patch missed that the bb was not being removed by the pass
but later on by cleanupcfg; https://gcc.gnu.org/pipermail/gcc-patches/2012-July/343239.html.
Which is why this is allowed to be done.

I added another testcase to check that the `if` is removed too.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-ssa-ccp.cc (optimize_unreachable): Don't check for forced labels.

gcc/testsuite/ChangeLog:

* gcc.dg/builtin-unreachable-7.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks agoFortran: fix frontend memory leaks for ALLOCATE with SOURCE [PR109010]
Harald Anlauf [Sun, 21 Sep 2025 19:54:44 +0000 (21:54 +0200)] 
Fortran: fix frontend memory leaks for ALLOCATE with SOURCE [PR109010]

When running under valgrind the Fortran frontend showed several leaks
involving __gmp_default_allocate for simple code such as

  program p
    real, pointer :: x(:)
    allocate (x, source = reshape ([1.], [1]))
  end

as not all used components of the structure gfc_code were freed when a
statement was freed.  Just do so.

PR fortran/109010

gcc/fortran/ChangeLog:

* st.cc (gfc_free_statement): Also free components expr3 and expr4.

2 weeks agoUpdate calls_comdat_local in cgraph_node::create_version_clone
Jan Hubicka [Sun, 21 Sep 2025 17:54:51 +0000 (19:54 +0200)] 
Update calls_comdat_local in cgraph_node::create_version_clone

This patches fixes ICE when ipa-split is run from ipa-profile.  In normal
computation we recompute the flag elsewhere, but it is supposed to be kept
up-to-date by passes possibly modifying it.

gcc/ChangeLog:

* cgraphclones.cc (cgraph_node::create_version_clone): Recompute
calls_comdat_local

2 weeks agoOne extra special case for AFDO0
Jan Hubicka [Sun, 21 Sep 2025 17:51:57 +0000 (19:51 +0200)] 
One extra special case for AFDO0

This patch makes inliner and ipa-cp to consider optimization interesting even
in scenarios where aufdo countis 0, but scaleis high enough to make optimization
worthwhile.

gcc/ChangeLog:

* cgraph.cc (cgraph_edge::maybe_hot_p): For AFDO profiles force
count to be non-zero.

2 weeks agoRegenerate gcc/m2/lang.opt.urls
Mark Wielaard [Sun, 21 Sep 2025 16:57:27 +0000 (18:57 +0200)] 
Regenerate gcc/m2/lang.opt.urls

Autogenerate for -fmem-report and -ftime-report.

Fixes: 273b53effbf5 ("PR modula2/121856: New wideset implementation")
gcc/m2/ChangeLog:

* lang.opt.urls: Regenerate.

2 weeks agoIncrease auto-fdo profile scaling
Jan Hubicka [Sun, 21 Sep 2025 14:52:18 +0000 (16:52 +0200)] 
Increase auto-fdo profile scaling

Increase scaling factor for auto-fdo profiles.  I origianlly used
n_bits/2 which is also used by local guessing algorithm.  For local guessing
algorithm the main factor is to prevent inliner scaling up the profile till
overflow.

With sane IPA profile large scaling up should essentially never happen. Inliner and
ipa-cp only duplicates code and should only scale down. ipa-icf and tail merging merges
code but not very large number of code paths.
In practice scaling up still happens when profile is inconsisent, so this use
n_bits-10, which is 50 currently.  The main advantage of this is to reduce chances
things drop to 0 and we hit the various special cases for 0 auto-FDO profile.

gcc/ChangeLog:

* auto-profile.cc (autofdo_source_profile::read): Scale profile up to
profile_count::n_bits - 10.

2 weeks agoFix test case and add errors for when -fexternal-blas64 makse no sense.
Thomas Koenig [Sun, 21 Sep 2025 12:46:35 +0000 (14:46 +0200)] 
Fix test case and add errors for when -fexternal-blas64 makse no sense.

-fexternal-blas64 requires front-end optimization to be turned on.
This patch issues a hard error if this is not the case, and also issues
an error on not-64 bit systems, where specifying it would make no sense,
and lead to errors.  Finally, this makes sure that the test is only performed
on 64-bit systems.

I tried creating test cases for the hard errors for the wrong option
combinations, but didn't succeed; see the thread on the gcc mailing
list on that topic.  These can always be added afterwards.

gcc/fortran/ChangeLog:

PR fortran/121161
* invoke.texi: Mention that -ffrontend-optimize is required
for -fexternal-blas64.
* options.cc (gfc_post_options): Fatal error if -fexternal-blas64
is specified without -ffrontend-optimize.
* trans-types.cc (gfc_init_kinds): Fatal error if -fexternal-blas64
is specified on a system which does not have 64-bit ptrdiff_t.

gcc/testsuite/ChangeLog:

PR fortran/121161
* gfortran.dg/matmul_blas_3.f90: Add effective target lp64.

2 weeks agoMake inliner more careful about profile inconsistencies
Jan Hubicka [Sun, 21 Sep 2025 10:28:17 +0000 (12:28 +0200)] 
Make inliner more careful about profile inconsistencies

This patch makes inliner to not subtract inlined function profile from the
offline copy in cases where profile is clearly not consistent.  As a result we
do not drop the offline version to likely never executed profile.  This helps
in cases the profile got lost, i.e. by comdat function merging and also for
auto-fdo.

gcc/ChangeLog:

* ipa-inline-transform.cc (clone_inlined_nodes): Add KEEP_OFFLINE_COPY
parameter.
(inline_call): Sanity check profile and if it is clearly broken do
not subtract profile from original function.
* ipa-inline.cc (recursive_inlining): Update.
* ipa-inline.h (clone_inlined_nodes): Update.

2 weeks agoFortran: fix issues with rank-2 deferred-length character arrays [PR108581]
Harald Anlauf [Sat, 20 Sep 2025 20:20:25 +0000 (22:20 +0200)] 
Fortran: fix issues with rank-2 deferred-length character arrays [PR108581]

PR fortran/108581

gcc/fortran/ChangeLog:

* trans-array.cc (gfc_conv_expr_descriptor): Take the dynamic
string length into account when deriving the dataptr offset for
a deferred-length character array.

gcc/testsuite/ChangeLog:

* gfortran.dg/deferred_character_39.f90: New test.

2 weeks agoDaily bump.
GCC Administrator [Sun, 21 Sep 2025 00:18:03 +0000 (00:18 +0000)] 
Daily bump.

2 weeks agoPR modula2/122009: ODR fixes and prototype correction.
Gaius Mulley [Sat, 20 Sep 2025 18:40:32 +0000 (19:40 +0100)] 
PR modula2/122009: ODR fixes and prototype correction.

This small patch fixes -Wodr warnings and also corrects a prototype.

gcc/m2/ChangeLog:

PR modula2/122009
* gm2-compiler/M2GenGCC.mod (FromM2WIDESETImport): Assign
sym to NulSym.
(CodeMakeAdr): Remove fourth parameter to BuildLogicalOrAddress.
(FoldMakeAdr): Ditto.
* gm2-compiler/M2Quads.mod (BuildAssignmentBoolean): Remove
unused parameter checkTypes.
(doBuildAssignment): Remove checkTypes parameter when calling
BuildAssignmentBoolean.
* gm2-gcc/m2expr.def (BuildLogicalOrAddress): Remove
needconvert parameter.
* gm2-gcc/m2statement.def (IfExprJump): Change label type
to CharStar.
* gm2-gcc/m2type.cc (m2type_BuildEnumerator): Remove const.
* gm2-gcc/m2type.h (m2type_BuildEnumerator): Ditto.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2 weeks agoc++: find_template_parameters and NTTPs [PR121981]
Patrick Palka [Sat, 20 Sep 2025 14:45:22 +0000 (10:45 -0400)] 
c++: find_template_parameters and NTTPs [PR121981]

Here the normal form of the two immediately-declared D<<placeholder>, V>
constraints is the same, so we rightfully share the normal form between
them.  We first compute the normal form from the context of auto deduction
for W in which case the placeholder has level 2 where the set of
in-scope template parameters has depth 2 (a dummy level is added from
normalize_placeholder_type_constraints).

Naturally the atomic constraint only depends on the template parameter
V of depth 1 index 0.  The depth 2 of current_template_parms however
means that find_template_parameters when it sees V within the atomic
constraint will recurse into its TREE_TYPE, an auto of level 2, and mark
the atomic constraint as also depending on the template parameter of
depth 2 index 0, which is clearly wrong.  Later during constraint
checking for B we ICE within the satisfaction cache since we lack two
levels of template arguments supposedly needed by the cached atomic
constraint.

I think when find_template_parameters sees an NTTP, it doesn't need to
walk its TREE_TYPE because NTTP substitution is done obliviously with
respect to its type -- only the corresponding NTTP argument matters,
not other template arguments possibly used within its type.  This is
most clearly true for (unconstrained) auto NTTPs as in the testcase, but
also true for other NTTPs.  Doing so fixes the testcase because we no
longer record any depth 2 when walking V within the atomic constraint.

PR c++/121981

gcc/cp/ChangeLog:

* pt.cc (any_template_parm_r) <case TEMPLATE_TYPE_PARM>:
Don't walk TREE_TYPE.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-placeholder15.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2 weeks agoc++: Fix lambdas with variadic parameters and static specifier [PR119048]
Eczbek [Sat, 20 Sep 2025 13:25:40 +0000 (09:25 -0400)] 
c++: Fix lambdas with variadic parameters and static specifier [PR119048]

PR c++/119048

gcc/cp/ChangeLog:

* lambda.cc (compare_lambda_sig): Only skip first parameter for
object members.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/static-operator-call8.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2 weeks agoFortran: Fix regtest failure in pdt_48.f03. [PR83746]
Paul Thomas [Sat, 20 Sep 2025 13:25:47 +0000 (14:25 +0100)] 
Fortran: Fix regtest failure in pdt_48.f03. [PR83746]

2025-09-20  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/83746
* trans-decl.cc (gfc_trans_deferred_vars): If a procedure with
an non-allocatable, non-pointer explicit PDT result has no
default initializer, the parameterized components should be
allocated.

2 weeks agoAdd --param max-devirt-targets
Jan Hubicka [Sat, 20 Sep 2025 13:11:50 +0000 (15:11 +0200)] 
Add --param max-devirt-targets

Currently we speculatively devirtualize using static analysis (with no profile
feedback) only when there is one possible target found.  With profile feedback
we support multiple targets which seems useful in some scenarios.

This patch adds --param max-devirt-targets which enables devirtualization up to
given number of targets and defaults it to 3.  This happens i.e. in spec2017
omnetpp, though the devirtualizaton is later undone by inliner since it is not
considered useful.  The patch still seems to improve omnetpp by 2% in some
setups.

Other advantage of the patch is that the multi-target devirtualizatoin gets
tested without profile feedback so we more likely notice problems with it.

gcc/ChangeLog:

* doc/invoke.texi (--param max-devirt-targets) Document.
* ipa-devirt.cc (ipa_devirt): Implement muti-target
devirtualization.
* params.opt (max-devirt-targets): New parameter.

gcc/testsuite/ChangeLog:

* g++.dg/ipa/devirt-2.C: Update template.
* g++.dg/ipa/devirt-42.C: Update template.
* g++.dg/lto/devirt-2_0.C: Update template.

2 weeks agoc: Implement C2y N3481 constraint against lvalue conversion with incomplete type
Joseph Myers [Sat, 20 Sep 2025 00:24:26 +0000 (00:24 +0000)] 
c: Implement C2y N3481 constraint against lvalue conversion with incomplete type

C2y replaces undefined behavior for lvalue conversion of an lvalue
with incomplete, non-array type with a constraint violation.
Implement this in GCC, which means disallowing lvalue conversion of
qualified or atomic void for C2y.  (Unqualified, non-atomic void is
excluded from the definition of "lvalue".)

I'm not convinced that the resolution of C90 DR#106 (which said that
certain cases with qualified void were valid) was really justified
even based on the wording of C90; nevertheless, this patch takes the
conservative approach of only disallowing qualified void here for C2y.

The test for this change showed that attempting to access an _Atomic
void object produced an ICE-after-error attempting the atomic load
logic for such a type.  require_complete_type returning
error_mark_node prevents this ICE from occurring any more in C2y mode;
to avoid it in older modes, a check of COMPLETE_TYPE_P is added to
really_atomic_lvalue.  I didn't find any existing bug report in
Bugzilla for this issue.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/c/
* c-typeck.cc (really_atomic_lvalue): Return false for incomplete
types.
(convert_lvalue_to_rvalue): Call require_complete_type for
qualified void for C2y.

gcc/testsuite/
* gcc.dg/c11-atomic-6.c, gcc.dg/c23-incomplete-1.c,
gcc.dg/c2y-incomplete-3.c: New tests.

2 weeks agoDaily bump.
GCC Administrator [Sat, 20 Sep 2025 00:20:23 +0000 (00:20 +0000)] 
Daily bump.

2 weeks agolibstdc++: Add NTTP bind_front, -back, not_fn (P2714) [PR119744]
Nathan Myers [Thu, 3 Jul 2025 21:15:40 +0000 (17:15 -0400)] 
libstdc++: Add NTTP bind_front, -back, not_fn (P2714) [PR119744]

Add non-type template parameter function-object/-pointer argument
versions of bind_front, bind_back, and not_fn.

This introduces a new internal type _Bind_fn_t to carry the
template-argument function object when no arguments are bound,
used in both bind_front and bind_back. Otherwise they return
a lambda object that has captured the arguments.

There is no need to change libstdc++-v3/src/c++23/std.cc.in
because existing exports: "using std::bind_front;" etc. export
the new overloads.

libstdc++-v3/ChangeLog:
PR libstdc++/119744
* include/bits/version.def: Redefine __cpp_lib_bind_front etc.
* include/bits/version.h: Ditto.
* include/std/functional: Add new bind_front etc. overloads
* testsuite/20_util/function_objects/bind_back/1.cc:
Check plumbing better
* testsuite/20_util/function_objects/bind_back/nttp.cc: New test.
* testsuite/20_util/function_objects/bind_back/nttp_neg.cc: New test.
* testsuite/20_util/function_objects/bind_front/1.cc:
Check plumbing better
* testsuite/20_util/function_objects/bind_front/nttp.cc: New test.
* testsuite/20_util/function_objects/bind_front/nttp_neg.cc: New test.
* testsuite/20_util/function_objects/not_fn/nttp.cc: New test.
* testsuite/20_util/function_objects/not_fn/nttp_neg.cc: New test.
* testsuite/20_util/headers/functional/synopsis.cc: New decls.

2 weeks agolibstdc++: Constrain operator<< for chrono::local_type
Jonathan Wakely [Thu, 28 Aug 2025 12:59:09 +0000 (13:59 +0100)] 
libstdc++: Constrain operator<< for chrono::local_type

This was reported as LWG 4257 and moved to Tentatively Ready status.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h: Remove unused <iomanip> header.
(operator<<): Constrain overload for chrono::local_time.
* testsuite/std/time/clock/local/io.cc: Check constraints.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
2 weeks ago[ira] avoid resetting ira_reg_equiv for function invariants
Alexandre Oliva [Fri, 19 Sep 2025 19:45:19 +0000 (16:45 -0300)] 
[ira] avoid resetting ira_reg_equiv for function invariants

An aarch64 toolchain built with --enable-default-pie fails
gcc.target/aarch64/sme/nonlocal_goto_[123].c because the register
allocator ends up resetting equivalences, so it concludes it needs to
preserve a rematerializable function invariant across a call instead
of rematerializing it.

Restore the find_reg_equiv_invariant_const logic that was in place
before commit 55a2c3226a3e90a6d65f19710bab1ac377054234 rewrote it and
added a (spurious?) requirement for non-function-invariants to retain
an equivalence when other PIC-related conditions didn't apply.  That
requirement seems either reversed or unnecessary.

for  gcc/ChangeLog

* ira.cc (setup_reg_equiv): Retain function invariant
equivalences.

2 weeks agoforwprop: change optimize_aggr_zeroprop and optimize_agr_copyprop to take stmt instea...
Andrew Pinski [Fri, 19 Sep 2025 06:06:19 +0000 (23:06 -0700)] 
forwprop: change optimize_aggr_zeroprop and optimize_agr_copyprop to take stmt instead of gsi

As mentioned, optimize_aggr_zeroprop and optimize_agr_copyprop don't change the stmt
so they should take stmt instead of the iterator.

Pushed as obvious after bootstrap/test on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-ssa-forwprop.cc (optimize_aggr_zeroprop): Take gimple*
instead of iterator.
(optimize_agr_copyprop): Likewise.
(simplify_builtin_call): Update call to optimize_aggr_zeroprop.
(pass_forwprop::execute): Update calls to optimize_aggr_zeroprop
and optimize_agr_copyprop.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks agoforwprop: Don't loop on the stmt when optimize_aggr_zeroprop or optimize_agr_copyprop...
Andrew Pinski [Tue, 16 Sep 2025 22:42:54 +0000 (15:42 -0700)] 
forwprop: Don't loop on the stmt when optimize_aggr_zeroprop or optimize_agr_copyprop return true

Since now optimize_aggr_zeroprop and optimize_agr_copyprop work by forward walk to prop
the zero/aggregate and does not change the statement at hand, there is no reason to
repeat the loop if they do anything.  This will prevent problems like PR 121962 from
happening again as we will never loop.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-ssa-forwprop.cc (optimize_aggr_zeroprop_1): Change return type
to void.
(optimize_aggr_zeroprop): Likewise.
(optimize_agr_copyprop_1): Likewise.
(optimize_agr_copyprop_arg): Likewise.
(optimize_agr_copyprop): Likewise.
(simplify_builtin_call): Handle update of the return type
of optimize_aggr_zeroprop.
(pass_forwprop::execute): Likewise and optimize_agr_copyprop.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks ago[MicroBlaze][PR target/118280] Fix __atomic_test_and_set
Michael Eager [Fri, 19 Sep 2025 16:53:28 +0000 (09:53 -0700)] 
[MicroBlaze][PR target/118280] Fix __atomic_test_and_set

Atomic support enhanced to fix existing atomic_compare_and_swapsi pattern
to handle side effects; new patterns atomic_fetch_op and atomic_test_and_set
added. As MicroBlaze has no QImode test/set instruction, use shift magic
to implement atomic_test_and_set.

PR target/118280
gcc/
* config/microblaze/iterators.md: New.
* config/microblaze/microblaze-protos.h: Add
microblaze_subword_address.
* config/microblaze/microblaze.cc: Ditto.
* config/microblaze/microblaze.md: constants: Add UNSPECV_CAS_BOOL,
UNSPECV_CAS_MEM, UNSPECV_CAS_VAL, UNSPECV_ATOMIC_FETCH_OP
type: add atomic
* config/microblaze/sync.md: Add atomic_fetch_<atomic_optab>si
atomic_test_and_set

Signed-off-by: Kirk Meyer <kirk.meyer@sencore.com>
Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
Signed-off-by: Gopi Kumar Bulusu <gopi@sankhya.com>
Signed-off-by: Michael Eager <eager@eagercon.com>
2 weeks agoImprove costing of speculative calls in ipa-fnsummary
Jan Hubicka [Fri, 19 Sep 2025 17:09:00 +0000 (19:09 +0200)] 
Improve costing of speculative calls in ipa-fnsummary

This patch implements logic to estimate_edge_devirt_benefit to not account call
statement sizes of speculative calls in case we know the call we be turned to
direct call by inlining.  I also noticed that estimate_edge_size_and_time fails
to accont code size savings by devirtualization when not asked to compute hints
(this is quite rare; only early inliner and inlining functions called once is
affected) and compensated for that in estimate_calls_size_and_time

gcc/ChangeLog:

* ipa-fnsummary.cc (estimate_edge_devirt_benefit): Handle speculative
edges correctly.
(estimate_edge_size_and_time): Even when not collecting hints,
devirtualization affects function size.
(estimate_calls_size_and_time): Do not use tables when devirtualization
is possible.

2 weeks agoImprove ipa-cp devirtualization costing
Jan Hubicka [Fri, 19 Sep 2025 17:05:34 +0000 (19:05 +0200)] 
Improve ipa-cp devirtualization costing

This patch fixed devirtualization time benefit of ipa-cp which should be scaled
by edge frequency but it is not.  The cost model is still not correct for speculative
calls, since it does not take into account the fact that code size will shrink if
speculation is removed.
I also made cgraph_edge::make_direct to not ICE when there are multiple speculations
to same target. This can happen in combination of devirtualization and ICF in some
rare cases.

gcc/ChangeLog:

* cgraph.cc (cgraph_edge::make_direct): Do not ICE when there are
multiple speculations to comptaible targets
(cgraph_edge::combined_sreal_frequency): New member function.
* cgraph.h (cgraph_edge::combined_sreal_frequency): Declare.
* ipa-cp.cc (devirtualization_time_bonus): Return sreal; consider
profile.
(estimate_local_effects): Likewise.

2 weeks agoFortran: Intrinsic functions in PDT specification exprs. [PR83746]
Paul Thomas [Fri, 19 Sep 2025 16:48:45 +0000 (17:48 +0100)] 
Fortran: Intrinsic functions in PDT specification exprs. [PR83746]

2025-09-19  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/83746
* trans-array.cc (structure_alloc_comps): Add the pre and post
blocks to 'fnblock' for all the evaluations of parameterized
expressions in PDT component allocatation.

gcc/testsuite/
PR fortran/83746
* gfortran.dg/pdt_48.f03: New test.

2 weeks agoPR modula2/121856: New wideset implementation
Gaius Mulley [Fri, 19 Sep 2025 16:26:18 +0000 (17:26 +0100)] 
PR modula2/121856: New wideset implementation

The new wideset implementation uses an ARRAY OF BYTE (internally) to
represent large sets.  This replaces the huge struct of anonymous
fields created by the old implementation and results in quicker
declaration times for large set types.

gcc/ChangeLog:

PR modula2/121856
* doc/gm2.texi (Compiler options): New item -fwideset.

gcc/m2/ChangeLog:

PR modula2/121856
* Make-lang.in (GM2-LIBS-BOOT-DEFS): Add M2Diagnostic.def.
Add Selective.def.
(GM2-LIBS-BOOT-MODS): Add M2Diagnostic.mod.
(GM2-LIBS-BOOT-C): Add Selective.c.
(GM2-LIBS-DEFS): Add Selective.def.
(GM2-LIBS-MODS): Add M2Diagnostic.mod.
(MC-LIB-MODS): Add M2Diagnostic.mod.
(m2/gm2-libs-boot/Selective.o): New rule.
(BUILD-PGE-O): Add m2/pge-boot/GM2Diagnostic.o.
Add m2/pge-boot/GM2Diagnostic.o.
Add m2/pge-boot/GStringConvert.o.
Add m2/pge-boot/Gdtoa.o.
Add m2/pge-boot/Gldtoa.o.
* Make-maintainer.in (PPG-LIB-DEFS): Add M2Diagnostic.def.
Add StringConvert.def.
(PPG-LIB-MODS): Add M2Diagnostic.mod.
Add StringConvert.mod.
(PGE-DEF): Add M2Diagnostic.def.
(PGE-DEPS): Add GM2Diagnostic.cc.
Add GM2Diagnostic.h.
* gm2-compiler/FifoQueue.def (PutSetIntoFifoQueue): New
procedure.
(GetSetFromFifoQueue): New procedure function.
* gm2-compiler/FifoQueue.mod (PutSetIntoFifoQueue): New
procedure.
(GetSetFromFifoQueue): New procedure function.
* gm2-compiler/M2ALU.def (KillValue): New procedure.
(PushSetTree): Rename parameter t to value.
(ConstructSetConstant): Rewrite comment.
* gm2-compiler/M2ALU.mod: Rewrite to use the new set type
and introduce memory diagnostics.
* gm2-compiler/M2Base.mod (InitBaseProcedures): Lookup M2WIDESET.
* gm2-compiler/M2CaseList.mod (CheckCaseBoundsResolved): Change
format specifier to allow the preceeding indefinite article to
have a n concatenated providing the following string substitute
begins with a vowel.
(checkTypes): Ditto.
* gm2-compiler/M2Check.mod (checkGenericUnboundedTyped): New
procedure function.
* gm2-compiler/M2Code.mod (OptimizationAnalysis): Replace with ...
(ResourceAnalysis): ... this.
* gm2-compiler/M2Comp.mod (PopulateResource): New procedure.
(compile): Call PopulateResource.
Call M2Diagnostic.Generate.
* gm2-compiler/M2GCCDeclare.mod: Rewrite for new set type.
* gm2-compiler/M2GenGCC.mod: Rewrite implementation for
becomes, incl, excl, and, or, not, xor for the new set type.
* gm2-compiler/M2MetaError.def: Extend comment documenting
the v format specifier.
* gm2-compiler/M2MetaError.mod (errorBlock): New field vowel.
(initErrorBlock): Initialize field vowel.
Reformat comments.
(pop): Call checkVowel.
(checkVowel): New procedure.
(isVowel): New procedure function.
(symDesc): Remove indefinite article.
(op): Set vowel field in case clause.
* gm2-compiler/M2Options.def (OptimizeSets): New global.
(TimeReport): Ditto.
(MemReport): Ditto.
(SetMemReport): New procedure.
(SetTimeReport): Ditto.
(SetWideset): Ditto.
(GetWideset): New procedure function.
* gm2-compiler/M2Options.mod (SetOptimizing): Assign
OptimizeSets depending upon the optimization level.
(SetMemReport): New procedure.
(SetTimeReport): Ditto.
(SetWideset): Ditto.
(GetWideset): New procedure function.
(OptimizeSets): Initialize to FALSE.
(TimeReport): Ditto.
(MemReport): Ditto.
* gm2-compiler/M2Quads.mod (M2Diagnostic): Import.
(QuadsMemDiag): New global variable.
(NewQuad): Bump QuadsMemDiag whenever a quad is allocated.
(BuildAssignmentBoolean): New procedure.
(doBuildAssignment): Ditto.
Add v to the format specifier.
(CheckCompatibleWithBecomes): Add v to the format specifier.
(CheckProcTypeAndProcedure): Ditto.
(BuildAddAdrFunction): Ditto.
(BuildSubAdrFunction): Ditto.
(BuildDifAdrFunction): Ditto.
(BuildDesignatorArrayStaticDynamic): Ditto.
(BuildDesignatorPointer): Ditto.
(CheckVariableOrConstantOrProcedure): Ditto.
(Init): Initialize QuadsMemDiag.
* gm2-compiler/M2Range.mod (CodeTypeAssign): Add v to the
format specifier.
* gm2-compiler/M2Scaffold.mod (DeclareScaffoldFunctions):
Generate more precise warning note.
* gm2-compiler/M2SymInit.mod (PrintSymInit): Add record
field warning.
* gm2-compiler/M2System.mod
(IsPseudoSystemFunctionConstExpression): Add TBitSize.
* gm2-compiler/NameKey.mod: Add MemDiagnostic code
commented out.
* gm2-compiler/P1SymBuild.mod (StartBuildProcedure):
Add v format specifier.
* gm2-compiler/P2SymBuild.mod (BuildFieldRecord): Ditto.
* gm2-compiler/P3Build.bnf (SetType): Reformat.
* gm2-compiler/PathName.def (Copyright): Added.
* gm2-compiler/PathName.mod: Remove blank line.
* gm2-compiler/SymbolConversion.mod (gdbhook): New procedure.
(BreakWhenSymBooked): Ditto.
(CheckBook): Ditto.
(Init): Rewrite.
* gm2-compiler/SymbolTable.def (GetSetArray): New procedure.
(PutSetArray): Ditto.
(MakeSetArray): New procedure function.
(PutSetInWord): New procedure.
(GetSetInWord): New procedure function.
(IsConstVar): Ditto.
* gm2-compiler/SymbolTable.mod (SymSet): SetInWord new field.
SetArray new field.
Align new field.
(SymMemDiag): New global variable.
(Init): Initialize SymMemDiag.
(IsConstVar): New procedure function.
(IsVariableSSA): Replace InternalError with Return FALSE.
(GetNthParamOrdered): Reimplement.
(GetNthParamAnyClosest): Ditto.
(GetOuterModuleScope): Ditto.
(MakeSet): Ditto.
(PutSetArray): New procedure.
(GetSetArray): New procedure function.
(MakeSetArray): Ditto.
(PutSetInWord): New procedure.
(GetSetInWord): New procedure function.
* gm2-gcc/init.cc (_M2_M2Diagnostic_init): Define
prototype.
(init_FrontEndInit):Call _M2_M2Diagnostic_init.
* gm2-gcc/m2block.cc (m2block_GetTotalConstants): New function.
(m2block_GetGlobalTypes): Ditto.
* gm2-gcc/m2block.def (GetTotalConstants): New procedure function.
(GetGlobalTypes): New procedure function.
* gm2-gcc/m2block.h (m2block_GetTotalConstants): New function
prototype.
(m2block_GetGlobalTypes): Ditto.
* gm2-gcc/m2convert.cc (converting_ISO_generic): Reimplement.
(m2convert_ToPIMByte): New function.
* gm2-gcc/m2convert.def (ToLoc): New procedure function.
(ToPIMByte): Ditto.
* gm2-gcc/m2convert.h (m2convert_ToPIMByte): Ditto.
* gm2-gcc/m2decl.h (m2decl_RememberVariables): Ditto.
* gm2-gcc/m2expr.cc (m2expr_BuildLogicalShift): Reimplement.
(m2expr_BuildLRotate): Ditto.
(m2expr_BuildLRLn): Ditto.
(m2expr_BuildLRRn): Ditto.
(m2expr_BuildLogicalRotate): Ditto.
(buildUnboundedArrayOf): Ditto.
(BuildIfBitInSetLower): New function.
(m2expr_BuildBinarySetDo): Reimplement.
(m2expr_BuildIfInSet): Ditto.
(m2expr_BuildIfNotInSet): New function.
(m2expr_Build4LogicalOr): Reimplement.
(m2expr_BuildSetNegate): Ditto.
(m2expr_BuildLogicalOrAddress): Ditto.
(m2expr_BuildLogicalOr): Ditto.
(m2expr_BuildLogicalAnd): Ditto.
(m2expr_BuildSymmetricDifference): Ditto.
(m2expr_BuildLogicalDifference): Ditto.
(boolean_enum_to_unsigned): Ditto.
(m2expr_BuildIsSuperset): Ditto.
(m2expr_BuildIsNotSuperset): Ditto.
(m2expr_BuildIsSubset): Ditto.
(m2expr_BuildIfBitInSetJump): Ditto.
(m2expr_BuildIfNotConstInVar): Ditto.
(m2expr_BuildIfVarInVar): Ditto.
(m2expr_BuildIfNotVarInVar): Remove.
(m2expr_BuildIfConstInVar): Remove.
(m2expr_BuildForeachWordInSetDoIfExpr): Ditto.
(m2expr_BuildBinaryForeachWordDo): Ditto.
(m2expr_BuildIfInRangeGoto): Reimplement.
(m2expr_BuildIfNotInRangeGoto): Ditto.
(m2expr_SetAndNarrow): Ditto.
(m2expr_GetBitsetZero): New function.
(m2expr_GetRValue): Ditto.
* gm2-gcc/m2expr.def (GetBitsetZero): New function.
(BuildSetNegate): Ditto.
(BuildLogicalOr): Reimplement.
(BuildLogicalAnd): Ditto.
(BuildSymmetricDifference): Ditto.
(BuildLogicalDifference): Ditto.
(BuildIfInSet): New procedure function.
(BuildIfNotInSet): Ditto.
(BuildEqualTo): Reimplement.
(BuildNotEqualTo): Ditto.
(BuildBinaryForeachWordDo): Remove.
(BuildBinarySetDo): Ditto.
(GetRValue): New procedure function.
* gm2-gcc/m2expr.h (m2expr_BuildBinaryForeachWordDo): Remove.
(m2expr_BuildForeachWordInSetDoIfExpr): Ditto.
(m2expr_BuildIfNotVarInVar): Ditto.
(m2expr_BuildIfVarInVar): Ditto.
(m2expr_BuildIfNotConstInVar): Ditto.
(m2expr_BuildIfConstInVar): Ditto.
(m2expr_BuildLogicalDifference): Reimplement.
(m2expr_BuildSymmetricDifference): Ditto.
(m2expr_BuildLogicalAnd): Ditto.
(m2expr_BuildLogicalOr): Ditto.
(m2expr_BuildLogicalOrAddress): Ditto.
(m2expr_BuildSetNegate): Ditto.
(m2expr_GetBitsetZero): New function.
(m2expr_GetRValue): Ditto.
(m2expr_BuildIfInSet): Ditto.
(m2expr_BuildIfNotInSet): Ditto.
* gm2-gcc/m2options.h (M2Options_SetTimeReport): New function.
(M2Options_SetMemReport): Ditto.
(M2Options_SetWideset): Ditto.
(M2Options_GetWideset): Ditto.
* gm2-gcc/m2pp.cc (m2pp_shiftrotate_expr): New function.
(m2pp_simple_expression): Ditto.
* gm2-gcc/m2statement.cc (m2statement_BuildStartFunctionCode):
Tidyup comments.
(m2statement_BuildEndFunctionCode): Ditto.
(m2statement_BuildPushFunctionContext): Ditto.
(copy_array): Ditto.
(CopyByField_Lower): Ditto.
(m2statement_BuildGoto): Ditto.
(m2statement_DeclareLabel): Ditto.
(m2statement_BuildParam): Ditto.
(nCount): Ditto.
(m2statement_BuildProcedureCallTree): Ditto.
(m2statement_BuildBuiltinCallTree): Ditto.
(m2statement_BuildFunctValue): Ditto.
(m2statement_BuildCall2): Ditto.
(m2statement_BuildCall3): Ditto.
(m2statement_BuildFunctionCallTree): Ditto.
(m2statement_SetLastFunction): Ditto.
(m2statement_SetParamList): Ditto.
(m2statement_GetLastFunction): Ditto.
(m2statement_GetParamList): Ditto.
(m2statement_GetCurrentFunction): Ditto.
(m2statement_GetParamTree): Ditto.
(m2statement_BuildTryFinally): Ditto.
(m2statement_BuildCleanUp): Ditto.
(m2statement_BuildUnaryForeachWordDo): Remove.
(m2statement_BuildExcludeVarConst): Ditto.
(m2statement_BuildExcludeVarVar): Ditto.
(m2statement_BuildIncludeVarConst): Ditto.
(m2statement_BuildIncludeVarVar): Ditto.
(m2statement_DoJump): Remove.
(m2statement_IfExprJump): New function.
(m2statement_IfBitInSetJump): Ditto.
* gm2-gcc/m2statement.def (DoJump): Remove.
(IfExprJump): New procedure function.
(BuildUnaryForeachWordDo): Remove.
(IfBitInSetJump): New procedure function.
* gm2-gcc/m2statement.h (m2statement_BuildForeachWordDo): Remove.
(m2statement_DoJump): Ditto.
(m2statement_IfExprJump): New function.
(m2statement_IfBitInSetJump): Ditto.
* gm2-gcc/m2treelib.cc (m2treelib_do_jump_if_bit): Reimplement.
(nCount): Replace with ...
(m2treelib_nCount): ... this.
(m2treelib_DoCall): Reimplement.
(m2treelib_get_rvalue): Remove.
* gm2-gcc/m2treelib.def (get_rvalue): Remove.
(nCount): New procedure function.
* gm2-gcc/m2treelib.h (m2treelib_get_rvalue): Remove.
(m2treelib_nCount): New function.
* gm2-gcc/m2type.cc (constructor_elements): Change type to vec.
(m2type_BuildEndArrayType): Reformat.
(build_m2_type_node_by_array): Ditto.
(m2type_GetBooleanEnumList): New procedure function.
(m2type_BuildEnumerator): Add const to char *.
(m2type_BuildSetConstructorElement): Reimplement.
(m2type_BuildEndSetConstructor): Ditto.
(build_record_constructor): New function.
(m2type_BuildEndRecordConstructor): Reimplement.
(m2type_BuildRecordConstructorElement): Ditto.
(m2type_BuildStartArrayConstructor): Reimplement.
(m2type_BuildEndArrayConstructor): Remove blank lines.
* gm2-gcc/m2type.def (BuildSetConstructorElement): Reimplement.
(BuildEndArrayType): Reformat.
(GetBooleanEnumList): New function.
* gm2-gcc/m2type.h (m2type_BuildEnumerator): Add const to char *.
(m2type_BuildSetConstructorElement): Reimplement.
(m2type_GetBooleanEnumList): New procedure function.
* gm2-lang.cc (OPT_fmem_report): New option.
(OPT_ftime_report): Ditto.
(OPT_fwideset): Ditto.
* gm2-libs-coroutines/SYSTEM.def (ShiftVal): Remove.
(ShiftLeft): Ditto.
(ShiftRight): Ditto.
(RotateVal): Ditto.
(RotateLeft): Ditto.
(RotateRight): Ditto.
* gm2-libs-coroutines/SYSTEM.mod: Reimplement.
* gm2-libs-iso/SYSTEM.def (ShiftVal): Remove.
(ShiftLeft): Ditto.
(ShiftRight): Ditto.
(RotateVal): Ditto.
(RotateLeft): Ditto.
(RotateRight): Ditto.
* gm2-libs-iso/SYSTEM.mod: Reimplement.
* gm2-libs/SYSTEM.def (ShiftVal): Remove.
(ShiftLeft): Ditto.
(ShiftRight): Ditto.
(RotateVal): Ditto.
(RotateLeft): Ditto.
(RotateRight): Ditto.
* gm2-libs/SYSTEM.mod: Reimplement.
* gm2-libs/SysStorage.def (DEALLOCATE): Improve comment.
* gm2-libs/SysStorage.mod: Improve comment.
* init/ppginit (M2Diagnostic): Add.
(StringConvert): Add.
* lang.opt (fmem-report): Add access to c.opt.
(ftime-report): Ditto.
(fwideset): New option.
* pge-boot/main.cc (_M2_M2Diagnostic_init): New function.
(_M2_M2Diagnostic_fini): Ditto.
(_M2_StringConvert_init): Ditto.
(_M2_StringConvert_fini): Ditto.
(main): Call _M2_M2Diagnostic_init.
Call _M2_StringConvert_init.
Call _M2_M2Diagnostic_fini.
Call _M2_StringConvert_fini.
* tools-src/makeSystem: Add -gdb option.
* gm2-libs/M2Diagnostic.def: New file.
* gm2-libs/M2Diagnostic.mod: New file.
* gm2-libs/M2WIDESET.def: New file.
* gm2-libs/M2WIDESET.mod: New file.
* mc-boot/GM2Diagnostic.cc: New file.
* mc-boot/GM2Diagnostic.h: New file.
* pge-boot/GM2Diagnostic.cc: New file.
* pge-boot/GM2Diagnostic.h: New file.
* pge-boot/GSelective.h: New file.
* pge-boot/GStringConvert.cc: New file.

libgm2/ChangeLog:

* libm2pim/Makefile.am (M2MODS): Add M2Diagnostic.mod.
Add M2WIDESET.mod.
(M2DEFS): Add M2Diagnostic.def.
Add M2WIDESET.def.
* libm2pim/Makefile.in: Regenerate.

gcc/testsuite/ChangeLog:

* gm2/errors/fail/testbit2.mod: Rewrite.
* gm2/iso/run/pass/shift4.mod: Rewrite adding more internal
tests.
* gm2/iso/run/pass/testsystem.mod (FindFirstElement): Add
bounds check.
* gm2/sets/run/pass/multisetrotate4.mod: Add more runtime
error messages.
* gm2/sets/run/pass/simplepacked.mod (testpset): Correct
setname.
* lib/gm2.exp (gm2_init_minx): Add -fno-wideset.
* gm2/iso/run/pass/assigncons.mod: New test.
* gm2/iso/run/pass/constructor3.mod: New test.
* gm2/iso/run/pass/proc_test.mod: New test.
* gm2/iso/run/pass/simplelarge2.mod: New test.
* gm2/iso/run/pass/simplelarge3.mod: New test.
* gm2/iso/run/pass/simplelarge4.mod: New test.
* gm2/pimlib/wideset/run/pass/bitset.mod: New test.
* gm2/pimlib/wideset/run/pass/bitset2.mod: New test.
* gm2/pimlib/wideset/run/pass/colorset.mod: New test.
* gm2/pimlib/wideset/run/pass/colorset2.mod: New test.
* gm2/pimlib/wideset/run/pass/colorset3.mod: New test.
* gm2/pimlib/wideset/run/pass/highbit.mod: New test.
* gm2/pimlib/wideset/run/pass/highbit2.mod: New test.
* gm2/sets/run/pass/multisetrotate5.mod: New test.
* gm2/sets/run/pass/setcard.mod: New test.
* gm2/sets/run/pass/setincl.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2 weeks ago[RISC-V][PR target/121983] Fix unprotected REGNO invocation
Jeff Law [Fri, 19 Sep 2025 15:17:01 +0000 (09:17 -0600)] 
[RISC-V][PR target/121983] Fix unprotected REGNO invocation

So this was a naked REGNO usage, which of course blows up if RTL checking is
enabled and something else sneaks in (SUBREG).   Thankfully it never results in
incorrect code, though I could theorize it could cause a bootstrap comparison
failure in the "right" circumstances.

Bootstrapped & regression tested on the Pioneer.  Also regression tested on
riscv64-elf and riscv32-elf.   I'll push to the trunk once pre-commit CI is
done.

jeff

PR target/121983
gcc/
* config/riscv/riscv.cc (riscv_macro_fusion_pair_p): Make sure
object is a REG before asking for its REGNO.  Fix a trivial
whitespace nit.

gcc/testsuite/
* gcc.target/riscv/pr121983.c: New test.

2 weeks agoRISC-V: Improve slide patterns recognition
Raphael Moreira Zinsly [Fri, 19 Sep 2025 14:04:48 +0000 (11:04 -0300)] 
RISC-V: Improve slide patterns recognition

Improve shuffle_slide_patterns to better recognize permutations that
can be constructed by a slideup or slidedown, covering more cases:
Slideup one vector into the middle the other like
  {0, 4, 5, 3}.
Slidedown one vector not ending in the last element like
  {5, 6, 2, 3}.
Slidedown one vector from the beginning like
  {4, 5, 2, 3}.

gcc/ChangeLog:

* config/riscv/riscv-v.cc
(shuffle_slide_patterns): Cover more permutations.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/shuffle-slide-run.h:
New test.
* gcc.target/riscv/rvv/autovec/shuffle-slidedown-run.c:
Likewise.
* gcc.target/riscv/rvv/autovec/shuffle-slideup-run.c:
Likewise.
* gcc.target/riscv/rvv/autovec/vls-vlmax/shuffle-slide.h:
Likewise.
* gcc.target/riscv/rvv/autovec/vls-vlmax/shuffle-slidedown-1.c:
Likewise.
* gcc.target/riscv/rvv/autovec/vls-vlmax/shuffle-slidedown-2.c:
Likewise.
* gcc.target/riscv/rvv/autovec/vls-vlmax/shuffle-slidedown-perm.h:
Likewise.
* gcc.target/riscv/rvv/autovec/vls-vlmax/shuffle-slideup-1.c:
Likewise.
* gcc.target/riscv/rvv/autovec/vls-vlmax/shuffle-slideup-2.c:
Likewise.
* gcc.target/riscv/rvv/autovec/vls-vlmax/shuffle-slideup-perm.h:
Likewise.

2 weeks agoRISC-V: Only Save/Restore required registers for ILP32E/LP64E
Jim Lin [Fri, 19 Sep 2025 13:08:09 +0000 (07:08 -0600)] 
RISC-V: Only Save/Restore required registers for ILP32E/LP64E

Previously the spec
https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/70
has changed the save/restore routines to save/restore the registers which
are really used for ILP32E/LP64 rather than always save/restore all
of ra/s0/s1.

I also found here that lacks the implementation for lp64e. If it's
necessary I will file anothor patch for that.

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_compute_frame_info): Remove the
dedicated calculation for RVE.

libgcc/ChangeLog:

* config/riscv/save-restore.S: Only save/restore the registers
which are really used for ILP32E/LP64.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/save-restore-cfi-3.c: New test.

2 weeks ago[RISC-V] Optimize clear-lowest-set-bit sequence when ctz is nearby
Jeff Law [Fri, 19 Sep 2025 12:54:01 +0000 (06:54 -0600)] 
[RISC-V] Optimize clear-lowest-set-bit sequence when ctz is nearby

Daniel Barboza and I were looking at deepsjeng recently and spotted an oddity.
In particular we had a sequence like this:

    addi a1,a0,-1
    and a1,a0,a1

That idiom clears the lowest set bit in a0.  In the initial code we looked at
there was a subsequent ctz dest,a0.  In other cases I could see an earlier ctz.
And when I went digging further I even found the ctz between the addi/and.

The key is the ctz uses the same input as the addi, but a different output.  So
the ctz doesn't participate in combine with the addi/and.

Tackling this in gimple isn't really feasible as the resultant code is going to
have a higher expression count.  The bclr idiom looks like (and (rotate (-2)
(count) (input)) where the count comes from a ctz.  SO to make it work from a
costing standpoint, we'd have to go find the ctz and use it.

Tackling in gimple->rtl expansion looked potentially feasible, but sign and
general type changes make that painful.  So while I could see the add+and and
could speculatively hope there was a nearby ctz it looked less than ideal from
an implementation standpoint.  It also tickled some undesirable behavior in the
combiner.

Tackling in combine isn't possible because the ctz doesn't feed the addi/and or
vice-versa.

Tackling with a peephole works sometimes, but is easily thwarted by the
scheduler putting random code in the middle of the sequences we want to adjust.

So in the end I just made a new RISC-V pass that runs after combine.

It walks each block looking for the addi+and construct.  When found it then
looks a few instructions in either direction for a related ctz. When found
it'll move things around as necessary and use ctz+bclr.  It depends on DCE to
eliminate the almost certainly dead addi+and insns.

I haven't benchmarked this one on design, but it's definitely picking up the
opportunities in deepsjeng and saves a few billion instructions.  It has
survived a riscv64-elf and riscv32-elf build.  Bootstrap on the BPI is in
flight, bootstrap on the Pioneer passes, but this code won't trigger this
because the Pioneer doesn't have ctz or bclr instructions.

Note while I would expect some of this pass to be usable on other targets, it
does make some assumptions about RTL structure that hold on RISC-V.  For
example subword arithmetic has an explicit sign extension to word mode, bit
position is QImode, etc.

Comments?  Other thoughts on how to resolve?

gcc/
* config.gcc (riscv*); Add riscv-bclr-lowest-set-bit.o to extra_objs.
* config/riscv/riscv-bclr-lowest-set-bit.cc: New file.
* config/riscv/riscv-passes.def: Add new pass after combine.
* config/riscv/riscv-protos.h (make_pass_bclr_lowest_set_bit): Add
prototype.
* config/riscv/t-riscv: Add rules to build riscv-bclr-lowest-set-bit.o.

gcc/testsuite
* gcc.target/riscv/bclr-lowest-set-bit-1.c: New test.

2 weeks agoRemove accidentially left if (0) block
Richard Biener [Fri, 19 Sep 2025 09:11:41 +0000 (11:11 +0200)] 
Remove accidentially left if (0) block

The following removes a block I added (and disabled again) when
developing the PR121720 fix.

* tree-ssa-pre.cc (compute_antic_aux): Remove dead code.

2 weeks agoada: Implement support for Is_Link_Once flag on entities
Eric Botcazou [Mon, 25 Aug 2025 20:45:47 +0000 (22:45 +0200)] 
ada: Implement support for Is_Link_Once flag on entities

gcc/ada/ChangeLog:

* gcc-interface/gigi.h (create_var_decl): Add LINKONCE_FLAG boolean
parameter.
(create_subprog_decl): Likewise.
* gcc-interface/decl.cc (gnat_to_gnu_entity): Adjust calls to
create_var_decl and create_subprog_decl.
(elaborate_expression_1): Likewise.
* gcc-interface/trans.cc (gigi): Likewise.
(build_raise_check): Likewise.
(Subprogram_Body_to_gnu): Likewise.
(create_temporary): Likewise.
(Exception_Handler_to_gnu): Likewise.
(Compilation_Unit_to_gnu): Likewise.
(gnat_to_gnu): Likewise.
(use_alias_for_thunk_p): Return false for a one-only target.
* gcc-interface/utils.cc (maybe_pad_type): Adjust call to
create_var_decl.
(create_var_decl): Add LINKONCE_FLAG boolean parameter.
(create_subprog_decl): Likewise.

2 weeks agoada: Initial support for Extended Access types
Marc Poulhiès [Tue, 15 Jul 2025 09:44:56 +0000 (11:44 +0200)] 
ada: Initial support for Extended Access types

This change introduces the support for the new GNAT specific
Extended_Access aspect for access to unconstrained array type :

  type Ext_Access is access all Some_Array_Type with Extended_Access;

 This new kind of access type does not use the existing "fat" layout with
 a record of two pointers: one to the actual data, one to a record with the
 bounds of the array. Instead, it removes the second indirection and extends
 the record to contain the pointer to the actual data followed by the bounds.

This mainly allows the following features:
- have access to slice of array
- easier interface when allocation is done in a foreign language

gcc/ada/ChangeLog:

* gcc-interface/ada-tree.h (TYPE_EXTENDED_POINTER_P): New.
(TYPE_IS_EXTENDED_POINTER_P): New.
(TYPE_EXTENDED_UNCONSTRAINED_ARRAY): New.
(SET_TYPE_EXTENDED_UNCONSTRAINED_ARRAY): New.
(TYPE_DUMMY_EXT_POINTER_TO): New.
(SET_TYPE_DUMMY_EXT_POINTER_TO): New.
* gcc-interface/decl.cc (get_extended_unconstrained_array): New.
(gnat_to_gnu_entity): Handle extended access type.
(get_unpadded_extended_type): New.
(gnat_to_gnu_component_type): Handle extended access type.
(build_template_type): New.
(gnat_to_gnu_field): Handle extended access type.
(validate_size): Likewise.
(set_rm_size): Likewise.
(copy_and_substitute_in_layout): Likewise.
(rm_size): Likewise.
* gcc-interface/gigi.h (get_unpadded_extended_type): New.
(build_template_type): New.
(build_dummy_unc_pointer_types_ext): New.
(finish_extended_pointer_type): New.
(build_unc_object_type_from_ptr): Rename first parameter.
* gcc-interface/misc.cc (gnat_print_type): Handle extended access type.
* gcc-interface/trans.cc (Identifier_to_gnu): Likewise.
(Attribute_to_gnu): Likewise.
(gnat_to_gnu): Likewise.
* gcc-interface/utils.cc (convert_to_fat_pointer): Assert if converting an
extended pointer.
(build_dummy_unc_pointer_types_ext): New.
(finish_extended_pointer_type): New.
(finish_record_type): Handle extended access type.
(build_unc_object_type_from_ptr): Likewise.
(convert_to_extended_pointer): New.
(convert): Handle extended access type.
(gnat_pushdecl): Likewise.
(maybe_pad_type): Likewise.
* gcc-interface/utils2.cc (build_unary_op): Likewise.
(build_binary_op): Likewise.
(build_allocator): Likewise.
(gnat_save_expr): Likewise.
(gnat_protect_expr): Likewise.
(gnat_stabilize_reference_1): Likewise.

2 weeks agoada: Make error recovery for structural generic instantiation more robust
Eric Botcazou [Wed, 10 Sep 2025 12:31:47 +0000 (14:31 +0200)] 
ada: Make error recovery for structural generic instantiation more robust

This adds a guard for the case of a selected component whose prefix is an
illegal structural generic instance.

gcc/ada/ChangeLog:

* sem_ch4.adb (Analyze_Selected_Component): Bail out if the prefix
has Void_Type.

2 weeks agoada: Remove unnecessary declare block
Piotr Trojanek [Wed, 10 Sep 2025 10:07:17 +0000 (12:07 +0200)] 
ada: Remove unnecessary declare block

Code cleanup; semantics is unaffected.

gcc/ada/ChangeLog:

* sem_ch4.adb (Analyze_User_Defined_Binary_Op): Remove declare block.

2 weeks agoada: Preliminary implementation of structural generic instantiation
Eric Botcazou [Fri, 4 Apr 2025 23:00:34 +0000 (01:00 +0200)] 
ada: Preliminary implementation of structural generic instantiation

It contains the changes to the parser required for the new syntax, as well
as the mechanism to instantiate generics implicitly.  The implementation is
strictly structural, in the sense that if the implicit instantiation cannot
be made structural for semantic dependence reasons, then it is rejected.

gcc/ada/ChangeLog:

* doc/gnat_rm/gnat_language_extensions.rst (Structural Generic
Instantiation): New entry
* einfo.ads (Is_Link_Once): New flag defined in entities.
* sinfo.ads (Is_Structural): New flag defined in instantiations.
* gen_il-fields.ads (Opt_Field_Enum): Add Is_Link_Once and
Is_Structural.
* gen_il-gen-gen_entities.adb (Entity_Kind): Add Is_Link_Once
semantic flag.
* gen_il-gen-gen_nodes.adb (N_Generic_Instantiation): Move up
Parent_Spec field and add Is_Structural semantic flag.
* frontend.adb: Add with clause for Sem_Ch12.
(Frontend): After analysis is complete and bodies are instantiated,
call Sem_Ch12.Mark_Link_Once on the declarations of the main unit.
* par.adb (P_Qualified_Simple_Name): Delete.
(P_Qualified_Simple_Name_Resync): Likewise
(P_Exception_Name): New function declaration.
(P_Label_Name): Likewise.
(P_Loop_Name): Likewise.
(P_Generic_Unit_Name): Likewise.
(P_Library_Unit_Name): Likewise.
(P_Package_Name): Likewise.
(P_Parent_Unit_Name): Likewise.
(P_Subtype_Name): Likewise.
(P_Subtype_Name_Resync): Likewise.
* par-ch3.adb (P_Subtype_Mark_Resync): Replace call to
P_Qualified_Simple_Name_Resync by P_Subtype_Name_Resync.
(P_Identifier_Declarations): Replace call to
P_Qualified_Simple_Name_Resync by P_Exception_Name.
(P_Derived_Type_Def_Or_Private_Ext_Decl): Replace call to
P_Qualified_Simple_Name by P_Subtype_Name.
(P_Interface_Type_Definition): Replace calls to
P_Qualified_Simple_Name by P_Subtype_Name.
* par-ch4.adb (P_Reduction_Attribute_Reference): Move around and
change name of parameter.
(P_Name): Document new grammar rule and make a couple of tweaks.
(P_Exception_Name): New function.
(P_Label_Name): Likewise.
(P_Loop_Name): Likewise.
(P_Generic_Unit_Name): Likewise.
(P_Library_Unit_Name): Likewise.
(P_Package_Name): Likewise.
(P_Parent_Unit_Name): Likewise.
(P_Subtype_Name): Likewise.
(P_Subtype_Name_Resync): Likewise.
(P_Qualified_Simple_Name): Rename into...
(P_Simple_Name): ...this.
(P_Qualified_Simple_Name_Resync): Rename into...
(P_Simple_Name_Resync): ...this.  Accept left parenthesis and
dot as name extensions.
(P_Allocator): Replace call to P_Qualified_Simple_Name_Resync
by P_Subtype_Name_Resync.
* par-ch5.adb (P_Goto_Statement): Replace call to
P_Qualified_Simple_Name by P_Label_Name.
(Parse_Loop_Flow_Statement): Replace call to
P_Qualified_Simple_Name by P_Loop_Name.
* par-ch6.adb (P_Subprogram): Replace call to
P_Qualified_Simple_Name by P_Generic_Unit_Name.
* par-ch7.adb (P_Package): Replace calls to
P_Qualified_Simple_Name by P_Package_Name and P_Generic_Unit_Name.
* par-ch8.adb (P_Use_Package_Clause): Replace calls to
P_Qualified_Simple_Name by P_Package_Name.
* par-ch9.adb (P_Task): Replace call to
P_Qualified_Simple_Name by P_Subtype_Name.
(P_Protected): Likewise.
* par-ch10.adb (P_Context_Clause): Replace call to
P_Qualified_Simple_Name by P_Library_Unit_Name.
(P_Subunit): Replace call to P_Qualified_Simple_Name by
P_Parent_Unit_Name.
* par-ch12.adb (P_Generic): Replace call to
P_Qualified_Simple_Name by P_Generic_Unit_Name.
(P_Formal_Derived_Type_Definition): Replace call to
P_Qualified_Simple_Name by P_Subtype_Name.
(P_Formal_Package_Declaration): Replace call to
P_Qualified_Simple_Name by P_Generic_Unit_Name.
* sem_ch4.adb: Add with and use clauses for Sem_Ch12.
(Analyze_Call): Accept implicit instantiations with -gnatX0.
(Analyze_Indexed_Component_Form): Likewise.
* sem_ch8.adb (Analyze_Use_Package): Add guard before inserting
a with clause automatically when there is a use clause.
(Check_In_Previous_With_Clause): Retrieve original names.
(Check_Library_Unit_Renaming): Deal with structural instances.
(End_Use_Type): Minor tweak.
* sem_ch10.adb (Analyze_With_Clause): Remove useless test and
call Defining_Entity_Of_Instance.
* sem_ch12.ads (Build_Structural_Instantiation): New function.
(Mark_Link_Once): New procedure.
* sem_ch12.adb: Add with and use clauses for Exp_Dbug.
(Analyze_Associations): Add support for structural instantiations.
(Analyze_Package_Instantiation): Likewise.
(Analyze_Subprogram_Instantiation): Likewise.
(Analyze_Structural_Associations): New procedure.
(Need_Subprogram_Instance_Body): Return True for instantiation is
in the auxiliary declarations of the main unit.
(Build_Structural_Instantiation): New function.
(Mark_Link_Once): New procedure.
* sem_util.ads (Add_Local_Declaration): New procedure.
(Defining_Entity_Of_Instance): New function.
* sem_util.adb (Add_Local_Declaration): New procedure.
(Defining_Entity_Of_Instance): New function.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

2 weeks agoada: Fix comment about operational aspects
Ronan Desplanques [Fri, 5 Sep 2025 11:44:04 +0000 (13:44 +0200)] 
ada: Fix comment about operational aspects

The comment this patch changes claimed that operational aspects are
"view-specific". The following excerpt from ARM 13.1 (11/5) indicates
that the set of view-specific aspects is in fact much more restricted:

    If a type-related aspect is defined for the partial view of a type,
    then it has the same definition for the full view of the type, except
    for certain Boolean-valued operational aspects where the language
    specifies that the partial view can have the value False even when
    the full view has the value True.

On the other hand, a feature of operational aspects is that they can be
specified on partial views, unlike representation aspects. That's stated
by AARM 13.1 (9.c/1):

    Unlike representation items, operational items can be specified on
    partial views.

So this patch changes the comment to be about that instead.

gcc/ada/ChangeLog:

* aspects.ads: Fix comment.

2 weeks agoada: Remove comment
Ronan Desplanques [Tue, 9 Sep 2025 08:21:12 +0000 (10:21 +0200)] 
ada: Remove comment

The comment this patch removes was about representation aspects but it
was placed above Operational_Aspect. The comment in itself was not very
helpful either since operational aspects, for example, are also needed
during expansion and code generation.

gcc/ada/ChangeLog:

* aspects.ads: Remove comment.

2 weeks agoada: Add procedure to write an extended access as a String
Marc Poulhiès [Tue, 3 Jun 2025 12:50:58 +0000 (14:50 +0200)] 
ada: Add procedure to write an extended access as a String

Add the Put_Image_Extended_Access_Pointer procedure for supporting
Ext_Access'Image.

gcc/ada/ChangeLog:

* libgnat/s-putima.ads (Ext_Access_Pointer): New.
(Put_Image_Extended_Access_Pointer): New.
* libgnat/s-putima.adb (Ext_Acc_Instance): New.
(Put_Image_Extended_Access_Pointer): New.
* rtsfind.ads (RE_Id, RE_Unit_Table): Set value for
RE_Put_Image_Extended_Access_Pointer.
* exp_put_image.adb (Build_Elementary_Put_Image_Call): Handle extended
access.

2 weeks agoada: Add C binding for Is_Extended_Access_Type
Marc Poulhiès [Fri, 5 Sep 2025 13:36:05 +0000 (15:36 +0200)] 
ada: Add C binding for Is_Extended_Access_Type

gcc/ada/ChangeLog:

* fe.h (Is_Extended_Access_Type): Add C bindings.
* sem_util.ads (Is_Extended_Access_Type): Add comment that any
change to the function must take care of the C binding.

2 weeks agoada: Do not set Esize for Extended Accesses
Marc Poulhiès [Thu, 24 Apr 2025 15:15:36 +0000 (17:15 +0200)] 
ada: Do not set Esize for Extended Accesses

The size of an extended access is unknown at this stage, so leave Esize
empty.

gcc/ada/ChangeLog:

* layout.adb (Layout_Type): Adjust comment and code extended
accesses.

2 weeks agoada: Remove superfluous statements
Ronan Desplanques [Mon, 8 Sep 2025 07:57:17 +0000 (09:57 +0200)] 
ada: Remove superfluous statements

This patch removes two occurrences of the following pattern:

    Analyze_Component_Declaration (N);
    Mutate_Ekind (Defining_Identifier (N), E_Component);

The second statement here has absolutely no effect, so its presence can
be confusing to the reader.

gcc/ada/ChangeLog:

* sem_ch3.adb (Add_Tag): Remove superfluous statements.

2 weeks agoada: Compiler crashes on subunits with Streaming/Put_Image attribute references
Steve Baird [Wed, 3 Sep 2025 19:21:10 +0000 (12:21 -0700)] 
ada: Compiler crashes on subunits with Streaming/Put_Image attribute references

When necessary, the compiler builds subprograms to implement the streaming
attributes (or the Put_Image attribute) for a type. In some cases involving
separate subunits, these compiler-generated subprograms were inserted at the
wrong point in the tree, resulting in internal compiler errors.

gcc/ada/ChangeLog:

* exp_attr.adb (Interunit_Ref_OK): Treat a subunit like a body.
(Build_And_Insert_Type_Attr_Subp): When climbing up the
tree, go from an N_Subunit node to its stub (instead of to the
subunit's N_Compilation_Unit node).

2 weeks agoada: Incorrect expansion of VADS Size attribute applied to an array type
Gary Dismukes [Fri, 5 Sep 2025 20:58:54 +0000 (20:58 +0000)] 
ada: Incorrect expansion of VADS Size attribute applied to an array type

The compiler fails, either with an Assert_Failure (for a compiler with
assertions enabled) or by producing a bad value, when processing a VADS_Size
attribute (or a Size attribute when pragma Use_VADS_Size is in force),
in the case where the prefix denotes a composite type or subtype whose
object size (Esise) is not known by the front end. The bug is due to
Eval_Attribute attempting to fold a VADS-related size attribute even
when Esize is not yet known for the type.

gcc/ada/ChangeLog:

* sem_attr.adb (Eval_Attribute): In the case of a VADS-specific
size attribute, only fold to the object size when the Esize field
is known.

2 weeks agolibstdc++: Reorder start_lifetime_as macro in version.def
Jonathan Wakely [Fri, 19 Sep 2025 09:14:39 +0000 (10:14 +0100)] 
libstdc++: Reorder start_lifetime_as macro in version.def

libstdc++-v3/ChangeLog:

* include/bits/version.def (start_lifetime_as): Move adjacent to
other C++23 macros.
* include/bits/version.h: Regenerate.

2 weeks agoRemove DR_GROUP_STORE_COUNT
Richard Biener [Fri, 19 Sep 2025 07:29:04 +0000 (09:29 +0200)] 
Remove DR_GROUP_STORE_COUNT

This was only used for non-SLP.

* tree-vectorizer.h (_stmt_vec_info::store_count): Remove.
(DR_GROUP_STORE_COUNT): Likewise.
* tree-vect-stmts.cc (vect_transform_stmt): Remove non-SLP
path.

2 weeks agoCleanup vect_get_num_copies API
Richard Biener [Thu, 18 Sep 2025 12:19:40 +0000 (14:19 +0200)] 
Cleanup vect_get_num_copies API

The following removes the dual non-SLP/SLP API in favor of only
handling SLP.  This also removes the possibility to override
vectype of a SLP node with an inconsistent one while still using
the SLP nodes number of lanes.  This requires adjustment of
a few places where such inconsistencies happened.

* tree-vectorizer.h (vect_get_num_copies): Remove unused
overload.  Remove defaulted vectype argument and always
use the vector type of the SLP node.
* tree-vect-loop.cc (vect_reduction_update_partial_vector_usage):
Adjust.
(vectorizable_lane_reducing): Likewise.
(vect_transform_reduction): Likewise.
(vectorizable_nonlinear_induction): Likewise.
* tree-vect-stmts.cc (check_load_store_for_partial_vectors):
Likewise.

2 weeks agoRemove SLP_TREE_NUMBER_OF_VEC_STMTS
Richard Biener [Thu, 18 Sep 2025 09:32:09 +0000 (11:32 +0200)] 
Remove SLP_TREE_NUMBER_OF_VEC_STMTS

The following removes the redundant SLP_TREE_NUMBER_OF_VEC_STMTS,
replacing it with vect_get_num_copies.  Previously it was already
made sure that all setters adhere to that.

* tree-vectorizer.h (_slp_tree::vec_stmts_size): Remove.
(SLP_TREE_NUMBER_OF_VEC_STMTS): Likewise.
* tree-vect-loop.cc (vectorizable_reduction): Adjust.
(vect_transform_cycle_phi): Likewise.
(vect_transform_lc_phi): Likewise.
(vectorizable_recurr): Likewise.
(vectorizable_induction): Likewise.
(vectorizable_live_operation): Likewise.
* tree-vect-slp.cc (_slp_tree::_slp_tree): Do not set
SLP_TREE_NUMBER_OF_VEC_STMTS.
(vect_slp_analyze_node_operations_1): Likewise.
(vect_slp_analyze_node_operations): Likewise.
(vect_prologue_cost_for_slp): Adjust.
(vect_create_constant_vectors): Likewise.
(vect_get_slp_vect_def): Likewise.
(vect_transform_slp_perm_load_1): Likewise.
(vectorizable_slp_permutation_1): Likewise.
(vect_schedule_slp_node): Likewise.
(vectorize_slp_instance_root_stmt): Likewise.
* tree-vect-stmts.cc (vect_model_simple_cost): Likewise.
(vectorizable_bswap): Likewise.
(vectorizable_call): Likewise.
(vectorizable_conversion): Likewise.
(vectorizable_shift): Likewise.
(vectorizable_operation): Likewise.
(vectorizable_store): Likewise.
(vectorizable_load): Likewise.
(vectorizable_condition): Likewise.
(vectorizable_early_exit): Likewise.

2 weeks agoDaily bump.
GCC Administrator [Fri, 19 Sep 2025 00:20:17 +0000 (00:20 +0000)] 
Daily bump.

2 weeks agoc: Add more C2Y tests
Joseph Myers [Thu, 18 Sep 2025 22:08:04 +0000 (22:08 +0000)] 
c: Add more C2Y tests

Add further tests for things defined in C2Y that correspond to how GCC
already behaves.  Some of these are for previous undefined behavior
where what is violated has become a constraint but previously was a
"shall" outside Constraints.  Others (c2y-anon-init-1.c and
c2y-incomplete-2.c) reflect semantics that were intended all along but
not correctly or sufficiently clearly stated in the standard.

Tested for x86_64-pc-linux-gnu.

* gcc.dg/c2y-anon-init-1.c, gcc.dg/c2y-incomplete-2.c:
gcc.dg/c2y-linkage-1.c, gcc.dg/c2y-linkage-2.c,
gcc.dg/c2y-linkage-3.c, gcc.dg/c2y-linkage-4.c,
gcc.dg/c2y-static-assert-1.c: New tests.

2 weeks agoc++: tweak constexpr union diagnostic
Jason Merrill [Thu, 18 Sep 2025 11:10:56 +0000 (13:10 +0200)] 
c++: tweak constexpr union diagnostic

It's now possible to see an active member of a union that has not actually
been initialized, so let's clarify the diagnostic.

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_component_reference): Clarify diagnostic.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/constexpr-98122.C: Adjust diagnostic.
* g++.dg/cpp26/constexpr-new6a.C: New test.

2 weeks agoc++: clobber class new-expressions
Jason Merrill [Thu, 18 Sep 2025 11:10:55 +0000 (13:10 +0200)] 
c++: clobber class new-expressions

Since Jakub's P2795R5 work removes the initial clobber from constructors,
let's add a clobber for new of all non-empty classes.

gcc/cp/ChangeLog:

* init.cc (build_new_1): Clobber classes.

gcc/testsuite/ChangeLog:

* g++.dg/analyzer/pr97116.C: Adjust diagnostic.
* g++.dg/warn/Warray-bounds-20.C: Likewise.

2 weeks agoc++: improve constexpr clobber handling
Jason Merrill [Thu, 18 Sep 2025 11:10:55 +0000 (13:10 +0200)] 
c++: improve constexpr clobber handling

r16-3022 changed placement new to clobber the object, and improved constexpr
handling to do more with clobbers.  But it occurred to me that in a lot of
cases we don't need to introduce a constructor_elt to represent an
uninitialized member of an uninitialized struct/array.

gcc/cp/ChangeLog:

* constexpr.cc (get_or_insert_ctor_field): -2 means don't insert.
(cxx_eval_component_reference): Handle finding void_node.
(cxx_eval_store_expression): Don't represent initial clobber
unless we need to activate a union member.
(cxx_eval_statement_list): Don't ask for a void prvalue.
(cxx_eval_loop_expr): The expr is discarded-value.
(cxx_eval_constant_expression): A loose clobber is non-constant.
Handle getting void_node instead of a real result.
(potential_constant_expression_1): A local temp is
potentially-constant.
* init.cc (build_new_1): Don't clobber empty types or
in a template.
(build_vec_init): Fix clobber handling.

gcc/testsuite/ChangeLog:

* g++.dg/init/pr25811.C: Tweak diagnostic.
* g++.dg/warn/Warray-bounds-12.C: Likewise.
* g++.dg/warn/Warray-bounds-13.C: Likewise.
* g++.dg/cpp26/constexpr-new6.C: New test.

2 weeks agoc++: -Wmismatched-new-delete, -O0, new (nothrow)
Jason Merrill [Thu, 18 Sep 2025 11:10:54 +0000 (13:10 +0200)] 
c++: -Wmismatched-new-delete, -O0, new (nothrow)

With new (nothrow) we need to check whether the allocation returned null,
and the resulting COND_EXPR was confusing -Wmismatched-new-delete-2 at -O0.
Let's help it out by appending the address if it's the same on both arms.

gcc/cp/ChangeLog:

* init.cc (build_new_1): Append alloc_node to checking COND_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wmismatched-new-delete-2.C: Remove xfail.

2 weeks agodiagnostics: add dump methods to client_data_hooks and logical_location_manager
David Malcolm [Thu, 18 Sep 2025 20:07:09 +0000 (16:07 -0400)] 
diagnostics: add dump methods to client_data_hooks and logical_location_manager

gcc/ChangeLog:
* diagnostics/client-data-hooks.h (client_data_hooks::dump): New.
* diagnostics/context.cc (context::dump): Dump
m_client_data_hooks.
(client_data_hooks::dump): New.
* diagnostics/logical-locations.h
(logical_locations::manager::dump): New.
* diagnostics/selftest-logical-locations.cc: Include
"diagnostics/dumping.h".
(test_manager::dump): New.
* diagnostics/selftest-logical-locations.h (test_manager::dump):
New decl.
* libgdiagnostics.cc: Include "diagnostics/dumping.h".
(impl_logical_location_manager::dump): New.
* tree-logical-location.cc: Include "diagnostics/dumping.h".
(tree_logical_location_manager::dump): New.
* tree-logical-location.h (tree_logical_location_manager::dump):
New decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 weeks agodiagnostics/libcpp: convert enum location_aspect to enum class
David Malcolm [Thu, 18 Sep 2025 20:07:04 +0000 (16:07 -0400)] 
diagnostics/libcpp: convert enum location_aspect to enum class

Modernization; no functional change intended.

gcc/ChangeLog:
* diagnostics/paths-output.cc: Update for conversion of
location_aspect to enum class.
* diagnostics/source-printing.cc: Likewise.
* input.cc: Likewise.
* input.h: Likewise.

libcpp/ChangeLog:
* include/line-map.h (enum location_aspect): Convert to...
(enum class location_aspect): ...this.
* line-map.cc: Update for conversion of location_aspect to enum
class.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 weeks agodiagnostics: use diagnostic.h in fewer places
David Malcolm [Thu, 18 Sep 2025 20:06:39 +0000 (16:06 -0400)] 
diagnostics: use diagnostic.h in fewer places

No functional change intended.

gcc/ChangeLog:
* diagnostics/buffering.cc: Drop include of "diagnostic.h".
* diagnostics/buffering.h: Likewise.
* diagnostics/context.h (diagnostics::metadata): Add forward decl.
* diagnostics/html-sink.cc: Drop include of "diagnostic.h".
* diagnostics/lazy-paths.cc: Likewise.
* diagnostics/macro-unwinding.cc: Likewise.
* diagnostics/macro-unwinding.h (diagnostics:diagnostic_info): Add
forward decl.
* diagnostics/option-classifier.h: Include
"diagnostics/option-id.h" and "diagnostics/kinds.h".
(diagnostics:diagnostic_info): Add forward decl.
* diagnostics/output-spec.cc: Drop include of "diagnostic.h".
* diagnostics/paths-output.cc: Likewise.
* diagnostics/paths.cc: Likewise.
* diagnostics/sarif-sink.cc: Likewise.
* diagnostics/selftest-context.cc: Likewise.
* diagnostics/selftest-paths.cc: Likewise.
* diagnostics/source-printing-options.h: Include
"rich-location.h".
* diagnostics/text-sink.cc: Drop include of "diagnostic.h".

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 weeks agoFix SRA issue with -ftrivial-auto-var-init= [PR121894]
Qing Zhao [Thu, 18 Sep 2025 15:50:38 +0000 (15:50 +0000)] 
Fix SRA issue with -ftrivial-auto-var-init= [PR121894]

In tree-sra.cc, for the following stmt (initialization in source code):
s = {};

for the above lhs "s", the field "grp_assignment_write" of the created
struct access is 1;

however, for the following stmt (compiler added initialization):
s = .DEFERRED_INIT (size, init_type, &"s"[0]);

for the above lhs "s", the field "grp_assignment_write" of the created
struct access is 0;

Since the field "grp_assignment_write" of the struct access for the
corresponding LHS "s" is not set correctly when the RHS is .DEFERRED_INIT,
SRA phase didn't do a correct transformation for call to .DEFERRED_INIT.

To fix this issue, we should set the field "grp_assignment_write" correctly
for .DEFERRED_INIT.

PR tree-optimization/121894

gcc/ChangeLog:

* tree-sra.cc (scan_function): Set grp_assignment_write to 1 when
specially handle call to .DEFERRED_INIT.

gcc/testsuite/ChangeLog:

* g++.dg/opt/auto-init-sra-pr121894.C: New test.

2 weeks agoFortran: Implement PDT constructors with syntax variants [PR114815]
Paul Thomas [Thu, 18 Sep 2025 18:00:08 +0000 (19:00 +0100)] 
Fortran: Implement PDT constructors with syntax variants [PR114815]

2025-09-18  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/114815
* decl.cc (gfc_get_pdt_instance): Copy the contents of 'tb' and
not the pointer.
* primary.cc (gfc_match_rvalue): If there is only one actual
argument list, use if for the type spec parameter values. If
this fails try the default type specification values and use
the actual arguments for the component values.
* resolve.cc (build_init_assign): Don't initialize implicit PDT
function results.

gcc/testsuite/
PR fortran/114815
* gfortran.dg/pdt_3.f03: Add missing deallocation of 'matrix'.
* gfortran.dg/pdt_17.f03: Change dg-error text.
* gfortran.dg/pdt_47.f03: New test.

2 weeks agoRISC-V: Correct lmul estimation
Zhongyao Chen [Thu, 18 Sep 2025 15:31:18 +0000 (09:31 -0600)] 
RISC-V: Correct lmul estimation

The vectorizer's compute_estimated_lmul function could previously
return a bad value when the estimated lmul was larger than RVV_M8.
This is corrected to return RVV_M8, preventing a register spill.

The patch includes a new regression test for PR target/121910, based
on the x264 mc_chroma function. The test uses scan-tree-dump to
confirm that the compiler chooses the expected vector mode (RVVM1QI)
at -O3, verifying the fix.

PR target/121910
gcc/ChangeLog:

* config/riscv/riscv-vector-costs.cc (compute_estimated_lmul):
Return RVV_M8 when estimated lmul is too large.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr121910.c: New file.

2 weeks agoopenmp: Fix up ICE in lower_omp_regimplify_operands_p [PR121977]
Jakub Jelinek [Thu, 18 Sep 2025 14:41:32 +0000 (16:41 +0200)] 
openmp: Fix up ICE in lower_omp_regimplify_operands_p [PR121977]

The following testcase ICEs in functions called from
lower_omp_regimplify_operands_p, because maybe_lookup_decl returns
NULL for this (on the outer taskloop context) when regimplifying the
taskloop pre body.  If it isn't found in current context, we should
look in outer ones.

2025-09-18  Jakub Jelinek  <jakub@redhat.com>

PR c++/121977
* omp-low.cc (lower_omp_regimplify_operands_p): If maybe_lookup_decl
returns NULL, use maybe_lookup_decl_in_outer_ctx as fallback.

* g++.dg/gomp/pr121977.C: New test.

2 weeks agoAArch64: Add SME LUTv2 intrinsics
Karl Meakin [Thu, 18 Sep 2025 14:15:49 +0000 (15:15 +0100)] 
AArch64: Add SME LUTv2 intrinsics

Add intrinsic functions for the SME LUTv2 architecture extension
(`svluti4_zt`, `svwrite_lane_zt` and `svwrite_zt`).

gcc/ChangeLog:

* config/aarch64/aarch64-sme.md (@aarch64_sme_write_zt<SVE_FULL:mode>): New insn.
(aarch64_sme_lut_zt): Likewise.
* config/aarch64/aarch64-sve-builtins-shapes.cc (parse_type): New type format "%T".
(struct luti_lane_zt_base): New function shape.
(SHAPE): Likewise.
(struct write_zt_def): Likewise.
(struct write_lane_zt_def): Likewise.
* config/aarch64/aarch64-sve-builtins-shapes.h: New function shape.
* config/aarch64/aarch64-sve-builtins-sme.cc (class svluti_zt_impl): New function expander.
(class svwrite_zt_impl): Likewise.
(class svwrite_lane_zt_impl): Likewise.
(FUNCTION): Likewise
* config/aarch64/aarch64-sve-builtins-sme.def (svwrite_zt): New function shape.
(svwrite_lane_zt): Likewise.
(svluti4_zt): Likewise.
* config/aarch64/aarch64-sve-builtins-sme.h: New function base.
* config/aarch64/aarch64-sve-builtins.h: Mention the arrays of function_group_info by name.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sme2/acle-asm/svluti4_zt_1.c: New test.
* gcc.target/aarch64/sme2/acle-asm/svwrite_lane_zt_1.c: New test.
* gcc.target/aarch64/sme2/acle-asm/svwrite_zt_1.c: New test.
* gcc.target/aarch64/sve/acle/general-c/svluti4_zt_1.c: New test.
* gcc.target/aarch64/sve/acle/general-c/svwrite_lane_zt_1.c: New test.
* gcc.target/aarch64/sve/acle/general-c/svwrite_zt_1.c: New test.

2 weeks agoAArch64: Add SME LUTv2 architecture extension
Karl Meakin [Thu, 18 Sep 2025 14:15:45 +0000 (15:15 +0100)] 
AArch64: Add SME LUTv2 architecture extension

Add the SME LUTv2 architecture extension. Users can enable the extension
by adding `+sme-lutv2` to `-march` or `-mcpu`, and test for its presence
with the `__ARM_FEATURE_SME_LUTv2` macro. The intrinsics will be added
in the next commit.

gcc/ChangeLog:

* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins): Conditonally define
`__ARM_FEATURE_SME_LUTv2" macro.
* config/aarch64/aarch64-option-extensions.def (AARCH64_OPT_EXTENSION("sme-lutv2")): New
optional architecture extension.
* config/aarch64/aarch64.h (TARGET_SME_LUTv2): New macro.
* doc/invoke.texi: Document `+sme-lutv2` flag.

2 weeks agoRISC-V: Add test case of unsigned scalar SAT_MUL form 5 for widen-mul
Pan Li [Mon, 1 Sep 2025 01:43:24 +0000 (09:43 +0800)] 
RISC-V: Add test case of unsigned scalar SAT_MUL form 5 for widen-mul

The form 5 of unsigned scalar SAT_MUL is covered in middle-expand
alreay, add test case here to cover form 5.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat/sat_arith.h: Add test helper macros.
* gcc.target/riscv/sat/sat_u_mul-6-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-6-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-6-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-6-u8-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-6-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-6-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-6-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-6-u8-from-u128.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 weeks agoMatch: Add form 5 of unsigned SAT_MUL for widen-mul
Pan Li [Mon, 1 Sep 2025 01:38:48 +0000 (09:38 +0800)] 
Match: Add form 5 of unsigned SAT_MUL for widen-mul

This patch would like to try to match the the unsigned
SAT_MUL form 4, aka below:

  #define DEF_SAT_U_MUL_FMT_5(NT, WT)             \
  NT __attribute__((noinline))                    \
  sat_u_mul_##NT##_from_##WT##_fmt_5 (NT a, NT b) \
  {                                               \
    WT x = (WT)a * (WT)b;                         \
    NT hi = x >> (sizeof(NT) * 8);                \
    NT lo = (NT)x;                                \
    return lo | -!!hi;                            \
  }

  while WT is uint128_t, T is uint8_t, uint16_t, uint32_t or uint64_t.

gcc/ChangeLog:

* match.pd: Add pattern for SAT_MUL form 5.
* tree-ssa-math-opts.cc (math_opts_dom_walker::after_dom_children):
Try match pattern for IOR.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 weeks agoFix verification ICE after ipa-cp
Jan Hubicka [Thu, 18 Sep 2025 12:15:47 +0000 (14:15 +0200)] 
Fix verification ICE after ipa-cp

I managed to reproduce the ICE.  The error is verification error about
callgraph edge count being different from basic block count of the
corresponding call stmt.  This verification is only done for local profiles,
since IPA profiles are scaled during inlining, cloning and other
transformations.

Ipa-cp has logic special casis self recursive functions and it adjust
probability of the recursion to avoid non-sential IPA profiles.  Normally
this is not done for local profiles, however in case the IPA profile
is broken enought the earlier logic will push clone profiles to be local
which in turn causes the verifier error.

This patch simply disables the update.  Its main purpose is to keep IPA
profile seemingly meaningful and the upate is never applied back to
gimple code.  Alternative would be to add machinery to adjust frequencies
of call edges, but I do not think it is worth the effort at this moment.

Bootstrapped/regtested x86_64-linux, comitted.

gcc/ChangeLog:

* ipa-cp.cc (update_counts_for_self_gen_clones): Do not update
call frequency for local profiles.

2 weeks agotree-optimization/87615 - VN predication is expensive
Richard Biener [Thu, 18 Sep 2025 08:41:45 +0000 (10:41 +0200)] 
tree-optimization/87615 - VN predication is expensive

The following restricts the number of locations we register a predicate
as valid which avoids the expensive linear search for cases like

   if (a)
     A;
   if (a)
     B;
   if (a)
     C;
   ...

where we register a != 0 as true for locations A, B, C ... in an
unlimited way.  The patch simply choses 8 as limit.  The underlying
issue for this case is the data structure which does not allow for
easy "forgetting" or more optimal searching when locations become
no longer relevant (the whole point of the location list is to
represent where predicates are relevant).

The patch also splits the search/copy loop into two to avoid copying
stuff that we'll not need when finding an existing better entry or,
new now, when we figure we run over the limit.

PR tree-optimization/87615
* tree-ssa-sccvn.cc (vn_nary_op_insert_into): When inserting
a new predicate or location into an existing predicate list
make sure to not exceed 8 locations.  Avoid copying things
when we later eventually throw them away.
(vn_nary_op_insert_pieces_predicated): Avoid expensive check
when not checking.
(dominated_by_p_w_unex): Apply the limit on a single successors
predecessor count consistently.

2 weeks agoOpenMP: Unshare expr in context-selector condition [PR121922]
Tobias Burnus [Thu, 18 Sep 2025 09:07:50 +0000 (11:07 +0200)] 
OpenMP: Unshare expr in context-selector condition [PR121922]

As the testcase shows, a missing unshare_expr caused that the condition
was only evaluated once instead of every time when a 'declare variant'
was resolved.

PR middle-end/121922

gcc/ChangeLog:

* omp-general.cc (omp_dynamic_cond): Use 'unshare_expr' for
the user condition.

libgomp/ChangeLog:

* testsuite/libgomp.c-c++-common/declare-variant-1.c: New test.

Co-authored-by: Sandra Loosemore <sloosemore@baylibre.com>
2 weeks agotree-optimization/121720 - missed PRE hoisting
Richard Biener [Wed, 17 Sep 2025 10:56:56 +0000 (12:56 +0200)] 
tree-optimization/121720 - missed PRE hoisting

The following re-implements the fix for PR84830 where the original
fix causes missed optimizations.  The issue with PR84830 is that
we end up growing ANTIC_IN value set during iteration which happens
because we conditionally prune values based on ANTIC_OUT - TMP_GEN
expressions.  But when ANTIC_OUT was computed including the
MAX set on one edge we fail to take into account the implicitly
represented MAX expression set.  The following rectifies this by
not pruning the value set in bitmap_set_subtract_expressions in
such case.  This avoids the pruning from the ANTIC_IN value
set when MAX is involved and thus later growing, removing the
need to explicitly prune it with the last iteration set.

PR tree-optimization/121720
* tree-ssa-pre.cc (bitmap_set_subtract_expressions): Add
flag to tell whether we should copy instead of prune the
value set.
(compute_antic_aux): Remove intersection of ANTIC_IN with
the old solution.  When subtracting TMP_GEN from
ANTIC_OUT do not prune the value set when MAX was involved
in the ANTIC_OUT computation.

* gcc.dg/tree-ssa/ssa-pre-36.c: New testcase.

2 weeks agolibstdc++: Implement C++23 P2590R2 - Explicit lifetime management [PR106658]
Jakub Jelinek [Thu, 18 Sep 2025 05:44:54 +0000 (07:44 +0200)] 
libstdc++: Implement C++23 P2590R2 - Explicit lifetime management [PR106658]

As I can't think of how the middle-end would treat
__builtin_start_lifetime_as other than a blackbox and probably would
need to be implemented as such inline asm in RTL, this patch
just implements it using inline asm in the library.
If not anything else, it can serve as fallback before we and/or clang
get some builtin for it.

Right now the inline asms pretend (potential) read from and write to the whole
memory region and make optimizers forget where the return value points to.
If the optimizers don't know where it points to, I think that should be
good enough, but I'm a little bit afraid of possibly future optimizations
trying to optimize
  q->c = 1;
  q->d = 2;
  auto p = std::start_lifetime_as<S>(q);
  if (p == reinterpret_cast<decltype (p)>(q))
    return p->a + p->b;
that because of the guarding condition or perhaps assertion we could
simply use the q pointer in MEM_REFs with S type and be surprised by TBAA.
Though if it is a must-alias case, then we should be fine as well.
Though guess that would be the same case with a builtin.

2025-09-18  Jakub Jelinek  <jakub@redhat.com>

PR c++/106658
* include/bits/version.def: Implement C++23 P2590R2 - Explicit
lifetime management.
(start_lifetime_as): New.
* include/bits/version.h: Regenerate.
* include/std/memory (std::start_lifetime_as,
std::start_lifetime_as_array): New function templates.
* src/c++23/std.cc.in (std::start_lifetime_as,
std::start_lifetime_as_array): Export.
* testsuite/std/memory/start_lifetime_as/start_lifetime_as.cc: New test.

2 weeks agoRemove SPR/GNR/DMR from avx512_{move,store}_by pieces tune.
hongtao.liu [Tue, 16 Sep 2025 01:23:45 +0000 (03:23 +0200)] 
Remove SPR/GNR/DMR from avx512_{move,store}_by pieces tune.

Align move_max with prefer_vector_width for SPR/GNR/DMR similar as
below commit.

commit 6ea25c041964bf63014fcf7bb68fb1f5a0a4e123
Author: liuhongt <hongtao.liu@intel.com>
Date:   Thu Aug 15 12:54:07 2024 +0800

    Align ix86_{move_max,store_max} with vectorizer.

    When none of mprefer-vector-width, avx256_optimal/avx128_optimal,
    avx256_store_by_pieces/avx512_store_by_pieces is specified, GCC will
    set ix86_{move_max,store_max} as max available vector length except
    for AVX part.

                  if (TARGET_AVX512F_P (opts->x_ix86_isa_flags)
                      && TARGET_EVEX512_P (opts->x_ix86_isa_flags2))
                    opts->x_ix86_move_max = PVW_AVX512;
                  else
                    opts->x_ix86_move_max = PVW_AVX128;

    So for -mavx2, vectorizer will choose 256-bit for vectorization, but
    128-bit is used for struct copy, there could be a potential STLF issue
    due to this "misalign".

gcc/ChangeLog:

* config/i386/x86-tune.def (X86_TUNE_AVX512_MOVE_BY_PIECES):
Remove SPR/GNR/DMR.
(X86_TUNE_AVX512_STORE_BY_PIECES): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pieces-memcpy-18.c: Use -mtune=znver5
instead of -mtune=sapphirerapids.
* gcc.target/i386/pieces-memcpy-21.c: Ditto.
* gcc.target/i386/pieces-memset-46.c: Ditto.
* gcc.target/i386/pieces-memset-49.c: Ditto.

2 weeks agoDaily bump.
GCC Administrator [Thu, 18 Sep 2025 00:20:40 +0000 (00:20 +0000)] 
Daily bump.

2 weeks agoc++: improve nesting in print_z_candidate [PR121966]
David Malcolm [Wed, 17 Sep 2025 20:39:32 +0000 (16:39 -0400)] 
c++: improve nesting in print_z_candidate [PR121966]

Comment #2 of PR c++/121966 notes that the "inherited here" messages
should be nested *within* the note they describe.

Implemented by this patch, which also nests other notes emitted for
rejection_reason within the first note of print_z_candidate.

gcc/cp/ChangeLog:
PR c++/121966
* call.cc (print_z_candidate): Consolidate instances of
auto_diagnostic_nesting_level into one, above the "inherited here"
message so that any such message is nested within the note,
and any messages emitted due to the switch on rejection_reason are
similarly nested within the note.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 weeks agoc++: fix count of z candidates for non-viable candidates, nesting [PR121966]
David Malcolm [Wed, 17 Sep 2025 20:39:31 +0000 (16:39 -0400)] 
c++: fix count of z candidates for non-viable candidates, nesting [PR121966]

In r15-6116-gd3dd24acd74605 I updated print_z_candidates to show the
number of candidates, and a number for each candidate.

PR c++/121966 notes that the printed count is sometimes higher than
what's actually printed: I missed the case where candidates in the
list aren't printed due to not being viable.

Fixed thusly.

gcc/cp/ChangeLog:
PR c++/121966
* call.cc (print_z_candidates): Copy the filtering logic on viable
candidates from the printing loop to the counting loop, so that
num_candidates matches the number of iterations of the latter
loop.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 weeks agotestsuite: add 'std-' prefix to c++ analyzer test cases
David Malcolm [Wed, 17 Sep 2025 20:39:31 +0000 (16:39 -0400)] 
testsuite: add 'std-' prefix to c++ analyzer test cases

gcc/testsuite/ChangeLog:
* g++.dg/analyzer/unique_ptr-1.C: Rename to...
* g++.dg/analyzer/std-unique_ptr-1.C: ...this.
* g++.dg/analyzer/unique_ptr-2.C: Rename to...
* g++.dg/analyzer/std-unique_ptr-2.C: ...this.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 weeks agosarif-replay: fix uninitialized m_debug_physical_locations
David Malcolm [Wed, 17 Sep 2025 20:39:31 +0000 (16:39 -0400)] 
sarif-replay: fix uninitialized m_debug_physical_locations

In r16-2766-g7969e4859ed007 I added a new field to replay_opts
but forgot to initialize it in set_defaults.

Fixed thusly.

Spotted thanks to valgrind.

gcc/ChangeLog:
* sarif-replay.cc (set_defaults): Initialize
m_debug_physical_locations.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 weeks agouninclude: Add lib/gcc/<anything>/include as an possible include dir
Andrew Pinski [Wed, 17 Sep 2025 01:12:07 +0000 (18:12 -0700)] 
uninclude: Add lib/gcc/<anything>/include as an possible include dir

While running uninclude on PR99912's preprocessed source uninclude
didn't uninclude some of the x86_64 target headers. This was because
`lib/gcc/<anything>/include` was not noticed as an possible system
include dir. It supported `gcc-lib/<anything>/include` though.

contrib/ChangeLog:

* uninclude: Add `lib/gcc/<anything>/include`.

2 weeks agoforwprop: Fix up "nop" copies after recent changes [PR121962]
Andrew Pinski [Tue, 16 Sep 2025 17:55:03 +0000 (10:55 -0700)] 
forwprop: Fix up "nop" copies after recent changes [PR121962]

After r16-3887-g597b50abb0d2fc, the check to see if the copy is
a nop copy becomes inefficient. The code going into an infinite
loop as the copy keeps on being propagated over and over again.

That is if we have:
```
  struct s1 *b = &a.t;
  a.t = *b;
  p = *b;
```

This goes into an infinite loop propagating over and over again the
`MEM[&a]`.
To solve this a new function is needed for the comparison that is
similar to new_src_based_on_copy.

PR tree-optimization/121962

gcc/ChangeLog:

* tree-ssa-forwprop.cc (same_for_assignment): New function.
(optimize_agr_copyprop_1): Use same_for_assignment to check for
nop copies.
(optimize_agr_copyprop): Likewise.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr121962-1.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks agoforwprop: Add a quick out for new_src_based_on_copy when both are decls
Andrew Pinski [Tue, 16 Sep 2025 16:48:52 +0000 (09:48 -0700)] 
forwprop: Add a quick out for new_src_based_on_copy when both are decls

If both operands that are being compared are decls, operand_equal_p will already
handle that case so an early out can be done here.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-ssa-forwprop.cc (new_src_based_on_copy): An early out
if both are decls.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks agoforwprop: Handle memcpy for arguments with respect to copies
Andrew Pinski [Wed, 10 Sep 2025 22:53:41 +0000 (15:53 -0700)] 
forwprop: Handle memcpy for arguments with respect to copies

This moves the code used in optimize_agr_copyprop_1 (r16-3887-g597b50abb0d)
to handle this same case into its new function and use it inside
optimize_agr_copyprop_arg. This allows to remove more copies that show up only
in arguments.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-ssa-forwprop.cc (optimize_agr_copyprop_1): Split out
the case where `operand_equal_p (dest, src2)` is false into ...
(new_src_based_on_copy): This. New function.
(optimize_agr_copyprop_arg): Use new_src_based_on_copy
instead of operand_equal_p to find the new src.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/copy-prop-aggregate-arg-2.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks agolibstdc++/ranges: Fix more wrong value type init from reference type [PR111861]
Patrick Palka [Wed, 17 Sep 2025 18:14:37 +0000 (14:14 -0400)] 
libstdc++/ranges: Fix more wrong value type init from reference type [PR111861]

As in r16-3912-g412a1f78b53709, this fixes some other spots where we
wrongly use a deduced type and non-direct-initialization when trying
to initialize a value type from an iterator's reference type.

PR libstdc++/111861

libstdc++-v3/ChangeLog:

* include/bits/ranges_algo.h (ranges::unique_copy): When
initializing a value type object from *iter, use
direct-initialization and don't use a deduced type.
(ranges::push_heap): Use direct-initialization when initializing
a value type object from ranges::iter_move.
(ranges::max): As in ranges::unique_copy.
* include/bits/ranges_util.h (ranges::min): Likewise.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2 weeks agoImplement -fexternal-blas64 option.
Thomas Koenig [Wed, 17 Sep 2025 16:50:22 +0000 (18:50 +0200)] 
Implement -fexternal-blas64 option.

Libraries like Intel MKL use 64-bit integers in their API, but gfortran
up to now only provides external BLAS for matmul with 32-bit
integers.  This straightforward patch provides a new option -fexternal-blas64
to remedy that situation.

gcc/fortran/ChangeLog:

* frontend-passes.cc (optimize_namespace): Handle
flag_external_blas64.
(call_external_blas): If flag_external_blas is set, use
gfc_integer_4_kind as the argument kind, gfc_integer_8_kind otherwise.
* gfortran.h (gfc_integer_8_kind): Define.
* invoke.texi: Document -fexternal-blas64.
* lang.opt: Add -fexternal-blas64.
* lang.opt.urls: Regenerated.
* options.cc (gfc_post_options): -fexternal-blas is incompatible
with -fexternal-blas64.

gcc/testsuite/ChangeLog:

* gfortran.dg/matmul_blas_3.f90: New test.

2 weeks ago[PR tree-optimization/58727] Don't over-simplify constants`
Shreya Munnangi [Wed, 17 Sep 2025 13:27:34 +0000 (07:27 -0600)] 
[PR tree-optimization/58727] Don't over-simplify constants`

Here's Shreya's next patch.

In pr58727 we have a case where the tree/gimple optimizers have decided to
"simplify" constants involved in logical ops by turning off as many bits as
they can in the hope that the simplified constant will be easier/smaller to
encode.  That "simplified" constant gets passed down into the RTL optimizers
where it can ultimately cause a missed optimization.

Concretely let's assume we have insns 6, 7, 8 as shown in the combine dump
below:

> Trying 6, 7 -> 9:
>     6: r139:SI=r141:SI&0xfffffffffffffffd
>       REG_DEAD r141:SI
>     7: r140:SI=r139:SI&0xffffffffffbfffff
>       REG_DEAD r139:SI
>     9: r137:SI=r140:SI|0x2
>       REG_DEAD r140:SI

We can obviously see that insn 6 is redundant as the bit we turn off would be
turned on by insn 9.  But combine ultimately tries to generate:

> (set (reg:SI 137 [ _3 ])
>     (ior:SI (and:SI (reg:SI 141 [ a ])
>             (const_int -4194305 [0xffffffffffbffffd]))
>         (const_int 2 [0x2])))

That does actually match a pattern on RISC-V, but it's a pattern that generates
two bit-clear insns (or a bit-clear followed by andi and a pattern we'll be
removing someday).  But if instead we IOR 0x2 back into the simplified constant
we get:

> (set (reg:SI 137 [ _3 ])
>     (ior:SI (and:SI (reg:SI 141 [ a ])
>             (const_int -4194305 [0xffffffffffbfffff]))
>         (const_int 2 [0x2])))

That doesn't match, but when split by generic code in the combiner we get:

> Successfully matched this instruction:
> (set (reg:SI 140)
>     (and:SI (reg:SI 141 [ a ])
>         (const_int -4194305 [0xffffffffffbfffff])))
> Successfully matched this instruction:
> (set (reg:SI 137 [ _3 ])
>     (ior:SI (reg:SI 140)
>         (const_int 2 [0x2])))

Which is bclr+bset/ori.  ie, we dropped one of the logical AND operations.

Bootstrapped and regression tested on x86 and riscv.  Regression tested on the
30 or so embedded targets as well without new failures.

I'll give this a couple days for folks to chime in before pushing on Shreya's
behalf.  This doesn't fix pr58727 for the other targets as they would need
target dependent hackery.

Jeff

PR tree-optimization/58727
gcc/
* simplify-rtx.cc (simplify_context::simplify_binary_operation_1):
In (A & C1) | C2, if (C1|C2) results in a constant with a single bit
clear, then adjust C1 appropriately.

gcc/testsuite/
* gcc.target/riscv/pr58727.c: New test.