Commit Graph

227776 Commits

Author SHA1 Message Date
Richard Biener
c97e6d7be7 tree-optimization/124555 - guard abs patterns for vector support
The following adds missing vector support checks to abs producing
match.pd patterns.  The g++.dg/absvect.C shows that we previously
then lowered this to non-vector unless you add -msse4 on x86_64
at least.

	PR tree-optimization/124555
	* match.pd ((A - B) >=/> 0 ? (A - B) : (B - A) -> abs (A - B)):
	Guard the vector case with target_supports_op_p checks.
	((A - B) <=/< 0 ? (A - B) : (B - A) -> -abs (A - B)): Likewise.
	((type)A >=/> 0 ? A : -A -> abs (A)): Likewise.
	((type)A <=/< 0 ? A : -A -> -abs (A)): Likewise.

	* gcc.dg/torture/pr124555.c: New testcase.
	* g++.dg/absvect.C: Restrict dump scan to x86-64 and force
	-msse4 there.
2026-03-18 14:19:46 +01:00
Dhruv Chawla
17880c0f39 AutoFDO: Add --print-autofdo-gcov-version
This option prints the current version of GCOV that is being used by the
AutoFDO infrastructure. This avoids the need to bump the number across
multiple files in the build system for future increments to it.

Bootstrapped and regtested on aarch64-linux-gnu.

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>

gcc/ChangeLog:

	* Makefile.in (all.fda): Add `--print-autofdo-gcov-version` to
	profile_merger invocation.
	* auto-profile.cc (AUTO_PROFILE_VERSION): Move from here ...
	* auto-profile.h (AUTO_PROFILE_VERSION): ... to here.
	* common.opt: Add -print-autofdo-gcov-version and
	--print-autofdo-gcov-version.
	* doc/invoke.texi: Document the options.
	* gcc.cc: Add include for auto-profile.h.
	(driver_handle_option): Add OPT_print_autofdo_gcov_version.
	(driver::maybe_print_and_exit): Handle the option.

gcc/c/ChangeLog:

	* Make-lang.in (cc1.fda): Add `--print-autofdo-gcov-version` to
	profile_merger invocation.
	(create_fdas_for_cc1): Add `--print-autofdo-gcov-version` to
	create_gcov invocations.

gcc/cp/ChangeLog:

	* Make-lang.in (cc1plus.fda): Add `--print-autofdo-gcov-version` to
	profile_merger invocation.
	(create_fdas_for_cc1plus): Add `--print-autofdo-gcov-version` to
	create_gcov invocations.

gcc/lto/ChangeLog:

	* Make-lang.in (lto1.fda): Add `--print-autofdo-gcov-version` to
	profile_merger invocation.
	(create_fdas_for_lto1): Add `--print-autofdo-gcov-version` to
	create_gcov invocations.

gcc/testsuite/ChangeLog:

	* lib/profopt.exp: Invoke $GCC_UNDER_TEST with
	`--print-autofdo-gcov-version` before running create_gcov to get
	the GCOV version.
2026-03-18 15:26:52 +05:30
Arsen Arsenović
bb0515578b libgomp/gcn: cache kernel argument allocations
On AMD GCN, for each kernel that we execute on the GPUs, the vast
majority of the time preparing the kernel for execution is spent in
memory allocation and deallocation for the kernel arguments.  Out of the
total execution time of run_kernel, which is the GCN plugin function
that actually performs launching a kernel, ~83.5% of execution time is
spent in these (de)allocation routines.

Obviously, then, these calls should be elliminated.  However, it is not
possible to avoid needing to allocate kernel arguments.

To this end, this patch implements a cache of kernel argument
allocations.

We expect this cache to be of size T where T is the maximum number of
kernels being launched in parallel.  This should be a fairly small
number, as there isn't much benefit to (or, to my awareness, real world
code that) executing very many kernels in parallel.

In my experiments (with BabelStream, though this should by no means be
improvements specific to it as run_kernel is used for all kernels and
branches very little), this was able to cut the non-kernel-wait runtime
of run_kernel by a factor of 5.5x.

libgomp/ChangeLog:

	* plugin/plugin-gcn.c (struct kernel_dispatch): Add a field to
	hold a pointer to the allocation cache node this dispatch is
	holding for kernel arguments, replacing kernarg_address.
	(print_kernel_dispatch): Print the allocation pointer from that
	node as kernargs address.
	(struct agent_info): Add in an allocation cache field.
	(alloc_kernargs_on_agent): New function.  Pulls kernel arguments
	from the cache, or, if no appropriate node is found, allocates
	new ones.
	(create_kernel_dispatch): Use alloc_kernargs_on_agent to
	allocate kernargs.
	(release_kernel_dispatch): Use release_alloc_cache_node to
	release kernargs.
	(run_kernel): Update usages of kernarg_address to use the kernel
	arguments cache node.
	(GOMP_OFFLOAD_fini_device): Clean up kernargs cache.
	(GOMP_OFFLOAD_init_device): Initialize kernargs cache.
	* alloc_cache.h: New file.
	* testsuite/libgomp.c/alloc_cache-1.c: New test.
2026-03-18 09:56:22 +01:00
Richard Biener
029f335b70 middle-end/124552 - release hierarchical discriminator copyid allocator
The following releases it when the CFG is released.

	PR middle-end/124552
	* function.cc (free_after_compilation): Free the copyid
	allocator.
2026-03-18 09:47:15 +01:00
Jakub Jelinek
1a5d977667 testsuite: Fix up a few tests for i686-linux
Some of these tests need -Wno-psabi to pass on ia32, forwprop-43.c
uses the vect* effective targets which rely on vect.exp added options
but doesn't provide those (added -msse2 for ia32).
And lastly, part-vect-absnegbf.c is a really weird test, it needs
at least -msse2 to pass on ia32 obviously (otherwise it is an error
to even use __bf16 or _Float16), but doesn't use -mavx512bf16 but
has avx512bf16 runtime check.  No idea what was meant, perhaps we
need 2 copies of the test, one with plain -msse2 and just requiring
sse2 at runtime and another wiht -mavx512bf16 requiring that?  Just
added -msse2 for now.

2026-03-18  Jakub Jelinek  <jakub@redhat.com>

	* gcc.dg/tree-ssa/forwprop-42.c: Add -Wno-psabi to dg-options.
	* gcc.dg/tree-ssa/forwprop-43.c: Likewise.  For ia32 add -msse2 as
	dg-additional-options.
	* gcc.dg/torture/pr65270-3.c: Add -Wno-psabi to dg-options.
	* gcc.target/i386/part-vect-absnegbf.c: Add -msse2 to dg-options.
2026-03-18 08:59:26 +01:00
Jakub Jelinek
c31ce49786 onfigure: Partial fix for the {gas,gnu_ld}{,_flag} breakage [PR124547]
Here is a partial fix for the PR124547 breakages.
Setting {gas,gnu_ld}_flag to no when user didn't specify any of
--with{,out}-gnu-{as,ld} nor --with-gnu-{as,ld}={yes,no} seems wrong
when we want to later override it based on
 # Check if we are using GNU ld if not already set.
 if test -z "$gnu_ld_flag"; then
   if $gcc_cv_ld --version 2>/dev/null | grep GNU > /dev/null; then
     gnu_ld_flag=yes
   else
     gnu_ld_flag=no
   fi
 fi
 or
 # Check if we are using GNU as if not already set.
 if test -z "$gas_flag"; then
   if $gcc_cv_as --version 2>/dev/null | grep GNU > /dev/null; then
     gas_flag=yes
   else
     gas_flag=no
   fi
 fi
So, this patch unsets it if not explicitly specified so that the later
overriding works.

On x86_64-linux it restores the auto-host.h and Makefile differences:
-LD_VERSION_SCRIPT_OPTION =
-LD_SONAME_OPTION =
+LD_VERSION_SCRIPT_OPTION = --version-script
+LD_SONAME_OPTION = -soname
and
-#define HAVE_AS_IX86_GOT32X 0
+#define HAVE_AS_IX86_GOT32X 1
 #endif
-#define HAVE_AS_IX86_TLSLDM 0
+#define HAVE_AS_IX86_TLSLDM 1
-#define HAVE_AS_IX86_TLS_GET_ADDR_GOT 0
+#define HAVE_AS_IX86_TLS_GET_ADDR_GOT 1
-/* #undef HAVE_LD_DEMANGLE */
+#define HAVE_LD_DEMANGLE 1

I agree with Andreas in the PR that after including config.gcc configure
should be using gas and gnu_ld vars rather than gas_flag and gnu_ld_flag,
but this patch doesn't implement that (yet).  I think to do that,
it would need to move the
 AS_VAR_SET_IF(gcc_cv_as,, [
 AC_MSG_CHECKING(Solaris assembler)
 # Check if we are using GNU as if not already set.
and
 AC_MSG_CHECKING(Solaris linker)
 # Identify the linker which will work hand-in-glove with the newly
 # Check if we are using GNU ld if not already set.
hunks in configure.ac from where they are to before config.gcc inclusion,
and sed s/\(gnu_ld\|gas\)_flag/\1/g after the config.gcc inclusion.
I can prepare/test the patch tomorrow, but IMHO this patch is a good start.

2026-03-18  Jakub Jelinek  <jakub@redhat.com>

	PR bootstrap/124547
	* configure.ac (--with-gnu-ld): Set gnu_ld_flag= instead of
	gnu_ld_flag=no if not explicitly specified.
	(--with-gnu-as): Similarly for gas_flag.
	(DEFAULT_ASSEMBLER): Use wording without GNU as whenever gas_flag
	is not yes rather than when it is no.
	* configure: Regenerate.
2026-03-18 08:42:47 +01:00
Richard Biener
6348a1fd50 Fix typo in -fpost-ipa-mem-report help text
* common.opt (fpost-ipa-mem-report): Fix typo.
2026-03-18 08:41:57 +01:00
Richard Biener
1f9487075c Fix leak of edge vector in IPA CP
The following makes gather_edges_for_value return an auto_vec,
simplifying the single caller decide_about_value and fixing the
leak of the callers vector upon early return.

	* ipa-cp.cc (gather_edges_for_value): Return an auto_vec.
	(decide_about_value): Simplify, fixing leak of callers.
2026-03-18 08:06:57 +01:00
Prachi Godbole
0f8e6cf83b [PATCH] ipa-reorder-for-locality - Fix PR123749 avoid creating new partition if no more nodes left to process
This patch fixes PR123749 which caused by an empty partition created in WPA
partitioning pass as a result of -fipa-reorder-for-locality creating one.
This also fixes an indentation issue.

Bootstrapped and regtested on aarch64-none-linux-gnu. OK for mainline?

Signed-off-by: Prachi Godbole <pgodbole@nvidia.com>

gcc/Changelog:

	PR target/123749
	* ipa-locality-cloning.cc (partition_callchain): Start new partition
	if no. of insns exceeds size and if there are nodes to process.
2026-03-17 22:40:45 -07:00
Jakub Jelinek
801c6fbeec c++: Fix up reflect/init11.C on cdtor_returns_this targets [PR124474]
On arm*-linux-gnueabi init11.C emits extra diagnostics which the testcase
doesn't expect.
E.g. it emits
init11.C: At global scope:
init11.C:19:13: error: function of consteval-only type must be declared ‘consteval’
   19 |   constexpr C() : i{} {}  // { dg-error "function of consteval-only type must be declared .consteval." }
      |             ^
init11.C: In constructor ‘constexpr C::C()’:
init11.C:19:24: error: consteval-only expressions are only allowed in a constant-evaluated context
   19 |   constexpr C() : i{} {}  // { dg-error "function of consteval-only type must be declared .consteval." }
      |                        ^
while on most other targets only the first error from these and not
the second is emitted.
This is because of targetm.cxx.cdtor_returns_this (), the error is emitted
on the constructor declaration and then again during
check_out_of_consteval_use on its body, when walking RETURN_EXPR (which
normally isn't there).

The following patch arranges diagnostics parity.

Though, as I wrote in the PR, I wonder if it makes sense to report
any errors on bodies of functions for which we've already diagnosed
function of consteval-only type must be declared ‘consteval’.
Especially for methods of consteval-only types, any use of this keyword
will result in an extra error (sure, only the first occurrence in a
function).  But even if a function has only some other consteval-only
argument and that argument is used somewhere in the body.  Though, wonder
if it is worth trying to improve that now when we don't know if
consteval-only will not be removed completely or changed significantly.

2026-03-18  Jakub Jelinek  <jakub@redhat.com>

	PR c++/124474
	* reflect.cc (check_out_of_consteval_use_r): Don't walk subtrees
	of RETURN_EXPR on cdtor_returns_this targets in cdtors.
2026-03-18 06:36:15 +01:00
Sebastian Huber
7d70ce4e9a RTEMS: Add leon5 multilibs
gcc/ChangeLog:

	* config/sparc/t-rtems: Add leon5 multilibs.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2026-03-18 02:29:08 +01:00
GCC Administrator
d084709be7 Daily bump. 2026-03-18 00:16:29 +00:00
Jonathan Wakely
62dec39dbd libstdc++: Fix some non-uglified names
Jakub wrote a plugin which identified some non-reserved names being used
in our headers. The "count" one is actually a reserved name (there's
std::set::count and std::count and std::bitset::count) but we might as
well uglify it when used as a function parameter name. I think the "ext"
ones must have happened when moving function definitions from fs_path.cc
to fs_path.h and I forgot to change them.

The __cond::wait and __cond::wait_recursive member functions are using
non-reserved names, so that should be changed too, but this patch
doesn't fix that. I don't think we use the __gnu_cxx::__cond type in any
headers, so maybe that should just be moved into libsupc++/guard.cc or a
new header which is not installed and only used while building the
library.

libstdc++-v3/ChangeLog:

	* include/bits/chrono_io.h (__formatter_duration::_S_subseconds):
	Uglify subs variable name.
	* include/bits/fs_path.h (path::stem, path::extension)
	(path::has_stem, path::has_extension): Uglify ext parameter
	name.
	* include/ext/concurrence.h (__cond::wait, __cond::wait_recursive):
	Uglify mutex parameter names.
	* include/pstl/glue_algorithm_defs.h (generate_n): Uglify count
	parameter name.
	* include/std/ranges (zip_transform_view): Uglify Rs template
	parameter name.
	(__cartesian_is_sized_sentinel): Uglify FirstSent template
	parameter name.
	* include/tr1/riemann_zeta.tcc: Uglify max_size variable name.
2026-03-17 21:49:43 +00:00
Jonathan Wakely
892451e7b6 libstdc++: Optimize __uninitialized_copy_a for std::deque iterators [PR124463]
I reimplemented uninitialized_copy and uninitialized_move in
r15-4473-g3abe751ea86e34 so that they no longer delegate to std::copy,
but that meant that they were no longer optimized for std::deque
iterators, leading to performance regressions for operations on a
std::deque with trivial element types. This adds new overloads of
__uninitialized_copy_a and __uninitialized_move_a to handle std::deque
iterators, restoring the lost performance.

There are also overloads of std::fill for deque iterators which are no
longer used for std::uninitialized_fill. This does not add replacements
for those, so there will still be lost performance for std::deque
operations that depend on std::uninitialized_fill. Similarly, inserting
or assigning from istreambuf_iterator into a std::deque no longer uses
the std::copy overloads for those types, and that isn't fixed by this
patch either.

libstdc++-v3/ChangeLog:

	PR libstdc++/124463
	* include/bits/deque.tcc (__uninitialized_copy_a): Define
	overloads for input and output iterators being std::deque
	iterators, and for only the output iterator being a std::deque
	iterator.
	(__uninitialized_move_a): Overload for input and output
	iterators being std::deque iterators.
	* include/bits/stl_uninitialized.h (__uninitialized_copy_a)
	(__uninitialized_move_a): Declare overloads for std::deque
	iterators.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2026-03-17 21:49:14 +00:00
Marek Polacek
824538311a c++/reflection: add var tmpl to inform_tree_category [PR124493]
Modifying the recently added crash22.C test to use a variable template
shows that inform_tree_category doesn't say reflection of what we
actually got.  With this patch we say:

  • but 'Y<T>' is a variable template
    crash23.C:6:13:
	6 | constexpr T Y{};
	  |             ^

I couldn't figure out a test for alias templates so I'm not adding
that now.

	PR c++/124493

gcc/cp/ChangeLog:

	* error.cc (inform_tree_category): Handle variable templates.

gcc/testsuite/ChangeLog:

	* g++.dg/reflect/crash23.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2026-03-17 16:10:49 -04:00
Jerry DeLisle
0438b22c04 fortran: Delete pr120286.f90 from gfortran testsuite. [PR120286]
PR fortran/120286

gcc/testsuite/ChangeLog:

	* gfortran.dg/pr120286.f90: Removed.

libgomp/ChangeLog:

	* testsuite/libgomp.fortran/pr120286.f90: New test.
2026-03-17 11:44:06 -07:00
Alice Carlotti
b5ac584928 aarch64: Disallow movprfx before revd
An architectural relaxation in 2024 (listed in the "Known issues in
Issue K.a" of the Arm ARM) removed support for revd to be prefixed by a
movprfx instruction.  This patch removes this (now invalid) codegen.

The patch also makes identical changes to each revd* testsuite file.
Interestingly, this actually improves codegen for one of the three
functions.

gcc/ChangeLog:

	* config/aarch64/aarch64-sve2.md (@aarch64_pred_revd<mode>):
	Remove movprfx alternative.
	(@cond_revd<mode>): Likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/sme/acle-asm/revd_bf16.c: Update checks.
	* gcc.target/aarch64/sme/acle-asm/revd_f16.c: Likewise.
	* gcc.target/aarch64/sme/acle-asm/revd_f32.c: Likewise.
	* gcc.target/aarch64/sme/acle-asm/revd_f64.c: Likewise.
	* gcc.target/aarch64/sme/acle-asm/revd_mf8.c: Likewise.
	* gcc.target/aarch64/sme/acle-asm/revd_s16.c: Likewise.
	* gcc.target/aarch64/sme/acle-asm/revd_s32.c: Likewise.
	* gcc.target/aarch64/sme/acle-asm/revd_s64.c: Likewise.
	* gcc.target/aarch64/sme/acle-asm/revd_s8.c: Likewise.
	* gcc.target/aarch64/sme/acle-asm/revd_u16.c: Likewise.
	* gcc.target/aarch64/sme/acle-asm/revd_u32.c: Likewise.
	* gcc.target/aarch64/sme/acle-asm/revd_u64.c: Likewise.
	* gcc.target/aarch64/sme/acle-asm/revd_u8.c: Likewise.
	* gcc.target/aarch64/sve2/acle/asm/revd_bf16.c: Likewise.
	* gcc.target/aarch64/sve2/acle/asm/revd_f16.c: Likewise.
	* gcc.target/aarch64/sve2/acle/asm/revd_f32.c: Likewise.
	* gcc.target/aarch64/sve2/acle/asm/revd_f64.c: Likewise.
	* gcc.target/aarch64/sve2/acle/asm/revd_mf8.c: Likewise.
	* gcc.target/aarch64/sve2/acle/asm/revd_s16.c: Likewise.
	* gcc.target/aarch64/sve2/acle/asm/revd_s32.c: Likewise.
	* gcc.target/aarch64/sve2/acle/asm/revd_s64.c: Likewise.
	* gcc.target/aarch64/sve2/acle/asm/revd_s8.c: Likewise.
	* gcc.target/aarch64/sve2/acle/asm/revd_u16.c: Likewise.
	* gcc.target/aarch64/sve2/acle/asm/revd_u32.c: Likewise.
	* gcc.target/aarch64/sve2/acle/asm/revd_u64.c: Likewise.
	* gcc.target/aarch64/sve2/acle/asm/revd_u8.c: Likewise.
2026-03-17 18:21:37 +00:00
Marek Polacek
206518b423 c++: add fixed test [PR109521]
Fixed by r16-4212.

	PR c++/109521

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wuninitialized-35.C: New test.
2026-03-17 13:49:16 -04:00
Marek Polacek
000d2da1c0 c++: add fixed test [PR115852]
Fixed by r16-2490.

	PR c++/115852

gcc/testsuite/ChangeLog:

	* g++.dg/cpp23/explicit-obj-lambda22.C: New test.
2026-03-17 13:38:25 -04:00
Marek Polacek
8dc3baf9bc c++: add fixed test [PR118482]
Fixed by r15-9362.

	PR c++/118482

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/lambda-uneval31.C: New test.
2026-03-17 13:32:39 -04:00
Philipp Tomsich
a48fbdd6a8 avoid-store-forwarding: Reject overlapping stores [PR124476]
The redundant-store tracking introduced in ec5349c37a replaced a
safe bitmap_bit_in_range_p check (which bailed on any overlap) with
bitmap_all_bits_in_range_p (which only removed fully redundant stores).
This broke "last writer wins" semantics for partially overlapping
stores: when an earlier store's BFI was applied after the base store's
value, it overwrote bytes that should have belonged to the later store.

Restore the original overlap check from 1d8de1e93e: bail out of the
optimization when any bit in a store's byte range is already claimed
by a later store in program order.  Remove the now-unnecessary
redundant-store tracking (redundant_stores, store_ind_to_remove).

gcc/ChangeLog:

	PR rtl-optimization/124476
	* avoid-store-forwarding.cc
	(store_forwarding_analyzer::process_store_forwarding): Replace
	bitmap_all_bits_in_range_p with bitmap_any_bit_in_range_p and
	return false on partial overlap.  Remove redundant-store vectors
	and their associated removal, dump, and deletion logic.

gcc/testsuite/ChangeLog:

	PR rtl-optimization/124476
	* gcc.dg/pr124476.c: New test.
2026-03-17 17:53:39 +01:00
Jonathan Wakely
1f97354f55 Revert "libstdc++: Add module initialization functions to the library [PR124268]"
This reverts commit c362a260ca.
2026-03-17 16:37:11 +00:00
Marek Polacek
9d17a04f24 c++/reflection: add test for ICE with ^^decltype [PR124494]
This test with invalid ^^decltype crashes.  finish_decltype_type
got a USING_DECL because they sometimes aren't stripped when
using -freflection.  We should give an error like we do for TYPE_DECL,
otherwise finish_decltype_type returns NULL_TREE and eventually we
crash in cp_parser_qualifying_entity after calling cp_parser_decltype.

Fixed by r16-8132 which moved the cp_preserve_using_decl overriding.

	PR c++/124494

gcc/testsuite/ChangeLog:

	* g++.dg/reflect/decltype1.C: New test.
2026-03-17 11:42:15 -04:00
Marek Polacek
8655ef0b65 c++/reflection: bogus error with targ and using-decl [PR124472]
Here we emit a bogus "type/value mismatch" error because
convert_template_argument gets a USING_DECL instead of an expected
TYPE_DECL.  When we are parsing a reflect-expression we set
cp_preserve_using_decl not to strip USING_DECLs.  The flag should
probably go, subject to 124169, but meanwhile we can at least move
overriding cp_preserve_using_decl below, just before the call to
cp_parser_lookup_name_simple, where it actually matters.  The wrong
error comes from _reflection_name -> _nested_name_specifier_opt
which happens before cp_parser_identifier.

	PR c++/124472

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_reflection_name): Move the
	cp_preserve_using_decl overriding below, before
	cp_parser_lookup_name_simple.

gcc/testsuite/ChangeLog:

	* g++.dg/reflect/using2.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2026-03-17 11:26:46 -04:00
Marek Polacek
6edc241e2a c++/reflection: ICE with invalid splice-spec-spec [PR124493]
This is a crash on invalid [:X:]<args> where [:X:] doesn't
designate a template.  Like in cp_parser_template_id, we should
check that we have an appropriate template before calling
finish_template_type on it.

	PR c++/124493

gcc/cp/ChangeLog:

	* pt.cc (tsubst) <case TEMPLATE_ID_EXPR>: Check that templ is
	either DECL_TYPE_TEMPLATE_P or DECL_TEMPLATE_TEMPLATE_PARM_P.

gcc/testsuite/ChangeLog:

	* g++.dg/reflect/crash19.C: New test.
	* g++.dg/reflect/crash22.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2026-03-17 11:23:41 -04:00
Richard Biener
c16aebb8b4 Fix memory leak in vect_analyze_slp
When I made the function to fail when SLP discovery fails I failed
to release the BST map.

	* tree-vect-slp.cc (vect_analyze_slp): Release BST map when
	returning.
2026-03-17 15:21:46 +01:00
Richard Biener
cc3370077c Fix uninitialized LOOP_VINFO_LOOP_IV_COND
With uncounted loop support we can leave LOOP_VINFO_LOOP_IV_COND
uninitialized but that's accessed from vect_stmt_relevant_p,
unlikely to match by chance, but the following fixes it nevertheless.

	* tree-vect-loop.cc (_loop_vec_info::_loop_vec_info):
	Initialize loop_iv_cond given it's no longer always
	initialized ...
	(vect_create_loop_vinfo): ... here.  Fix formatting.
2026-03-17 14:05:51 +01:00
Richard Biener
5f1024922d tree-optimization/122380 - avoid PRE/hoisting of incompatible access-path
This decouples the PRE reference IL from the VN hash tables, following
the corresponding PR103037 fix for nary expressions in r12-7389 to avoid
correctness issues regarding to access paths when inserting expressions.

Unfortunately this makes existing workarounds for alignment and alias
mismatches ineffective so those have to be re-implemented.  Instead
of going back to implement canonexpr() during the ANTIC dataflow the
following does this at insertion time, hoping all relevant reaching
expressions will survive.  A convenient place to do this is
sorted_array_from_bitmap_set, the actual magic worker is 'prefer',
for the moment handling alignment and innermost access size only,
as those are the cases we have test coverage.  In particular the
access path difference seen in this PR is not covered - it is enough
to fix the AVAIL_OUT computation in compute_avail for this.

Where the old fixup code massaged the expressions the new code selects
from existing expressions or as fallback makes sure to not perform
code insertion when two incompatible expressions met.

	PR tree-optimization/122380
	* tree-ssa-sccvn.h (copy_reference_ops_from_ref): Declare.
	(vn_reference_compute_hash): Likewise.
	(vn_reference_eq): Add parameter indicating lexical equivalence,
	defaulted to false.
	* tree-ssa-sccvn.cc (vn_reference_eq): Likewise.
	(print_vn_reference_ops): Print alias type and alignment.
	(vn_reference_compute_hash): Export.
	(copy_reference_ops_from_ref): Likewise.
	* tree-ssa-pre.cc (pre_expr_d::equal): Use lexical equivalence.
	(get_or_alloc_expr_for_reference): Also get value-id, upon
	zero assign a new value-id if the expression is unknown.
	(expr_cmp): New helper.
	(prefer): Likewise.
	(pre_expr_DFS): Get expression exclusion bitmap and honor it.
	(sorted_array_from_bitmap_set): If done for insertion, do limited
	canonexpr() via pairwise prefer on expression pairs with the same
	value, populating an exclution bitmap.
	(phi_translate_1): Do not use the VN hashtable expressions
	or insert there.  Instead maintain a PRE view of expressions.
	(clean): Adjust.
	(do_hoist_insertion): Likewise.
	(insert): Likewise.
	(compute_avail): Use gimple_could_trap_p_1
	on the original stmt rather than vn_reference_may_trap on
	the VN leader.  Use the original stmt operands for the PRE
	view of reference expressions, only use the value number from the VN
	tables.  Remove no longer effective workarounds for semantically
	different references with same value.
	(fini_pre): Release operand vectors for PRE IL reference
	expressions.

	* g++.dg/torture/pr122380.C: New testcase.
	* gcc.dg/torture/pr65270-3.c: Likewise.
	* gcc.dg/tree-ssa/ssa-pre-30.c: XFAIL.
2026-03-17 13:28:19 +01:00
Yangyu Chen
e769ec31ee i386: Fix ICE with target_clones inlining
When a target_clones function is inlined, the resolver function's
assembler name must be properly registered in the symbol table.
Using SET_DECL_ASSEMBLER_NAME only updates the tree node without
notifying the symbol table, which can lead to an ICE during IPA
inlining when the assembler name hash becomes inconsistent.

Replace SET_DECL_ASSEMBLER_NAME with symtab->change_decl_assembler_name
in make_resolver_func to properly update the symbol table's assembler
name mapping.

This only happens on x86, other targets already uses
symtab->change_decl_assembler_name.

Fixes: b500cd2634 ("x86: fmv: Refactor FMV name mangling.")

gcc/ChangeLog:

	* config/i386/i386-features.cc (make_resolver_func): Use
	symtab->change_decl_assembler_name instead of
	SET_DECL_ASSEMBLER_NAME to properly update the symbol table.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/tct-ipa-inline-ice.c: New test.

Signed-off-by: Yangyu Chen <cyy@cyyself.name>
2026-03-17 12:18:21 +01:00
Tomasz Kamiński
63fef6d337 libstdc++: Fix is_explict checks in extents test.
The condition was checking if extents<int, ...> is convertible to index_type,
and not the reverse. This patch tests implicit conversion from braced
initializer list (to cover multiple arguments) and is_convertible in case of
single index.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/mdspan/extents/ctor_ints.cc: Updated
	is_explicit, and added more test cases.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2026-03-17 10:37:53 +01:00
Jakub Jelinek
49b52ecc65 testsuite: Add also decltype(nullptr) testcase for PR124489
In r16-8116 Marek has fixed not just whitespace around
std::meta::info in diagnostics, but also std::nullptr_t.

This patch adds a testcase for that, such that the part of the
change related to NULLPTR_TYPE and this test can be backported.

2026-03-17  Jakub Jelinek  <jakub@redhat.com>

	PR c++/124489
	* g++.dg/cpp0x/pr124489.C: New test.
2026-03-17 10:27:47 +01:00
Prachi Godbole
7bdc5db5eb [PATCH] Add Myself to Write After Approval and DCO List
ChangeLog:

	* MAINTAINERS: Add myself to write after approval and DCO.

Signed-off-by: Prachi Godbole pgodbole@nvidia.com
2026-03-17 00:35:24 -07:00
Christopher Albert
60fbabc1a1 fortran: Preserve scalar class pointers in OpenMP privatization [PR120286]
OpenMP privatization currently treats scalar class pointers like owned
polymorphic class objects.  In the worker cleanup for private/firstprivate
class pointers, the generated code finalizes and frees ptr._data even though
the clause only copied pointer association status from a shared target.

Fix this in gfc_omp_clause_copy_ctor and gfc_omp_clause_dtor by unwrapping
saved descriptors first and by recognizing class-pointer container types
locally in those hooks.  That keeps scalar class pointers on the
association-only path without changing the broader polymorphic mapping
classification used for OpenMP warnings and deep mapping.

Add a runtime regression test for the original private(ptr) crash plus a
firstprivate(ptr) association check.

gcc/fortran/ChangeLog:

	PR fortran/120286
	* trans-openmp.cc (gfc_is_class_pointer_type): New helper.
	(gfc_omp_clause_copy_ctor): Unwrap saved descriptors before
	deciding whether privatization should preserve only pointer
	association.  Handle scalar class pointers on that path too.
	(gfc_omp_clause_dtor): Likewise.

gcc/testsuite/ChangeLog:

	PR fortran/120286
	* gfortran.dg/pr120286.f90: New test.

Signed-off-by: Christopher Albert <albert@tugraz.at>
2026-03-16 17:33:15 -07:00
GCC Administrator
9c2e4b6ac0 Daily bump. 2026-03-17 00:16:31 +00:00
Marek Polacek
4f5ba54888 c++/reflection: fix ICE on invalid splice [PR124496]
Just an ICE-on-invalid, but while writing tests for 123237 my
typos would result in this crash often enough to prompt me to
go ahead and fix it.

We crash here because we are asserting that we've emitted hard
errors when cp_parser_splice_specifier returns error_mark_node
even when parsing tentatively.  In the crash20.C case we have
[:R<T>:] where we interpret the < as a "less than" operator and
expect that T will produce a primary expression, which it does
not.  But cp_parser_error won't emit any errors yet.

	PR c++/124496

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_splice_specifier): Use NULL_TREE instead of
	NULL.
	(cp_parser_splice_expression): Don't assert seen_error() when not
	committed to tentative parse.

gcc/testsuite/ChangeLog:

	* g++.dg/reflect/crash20.C: New test.
	* g++.dg/reflect/crash21.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2026-03-16 18:34:26 -04:00
Marek Polacek
8dc559d513 c++/reflection: reject annotations on void parms [PR123618]
Annotations on void parameter don't make much sense so they
should be rejected, even if the wording isn't currently so
clear on that.

	PR c++/123618

gcc/cp/ChangeLog:

	* tree.cc (handle_annotation_attribute): Reject annotations on void
	parameters.

gcc/testsuite/ChangeLog:

	* g++.dg/reflect/annotations14.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2026-03-16 18:11:53 -04:00
Andrew Pinski
57ccf06509 c++: Fix ICE with error mark for an attribute [PR124307]
After r16-6808-g4b0e94b394fa38, we started to ICE when the
std_attrs was error_mark_node. This fixes the problem by
checking if it was an error_mark_node before looking for
annotations.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

Changes since v1:
 * v2: Move the check for error mark earlier.
 * v3: small formating changes.

	PR c++/124307

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_base_specifier): Check for
	error mark like checking for non-nullness on the
	attribute.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/alignas24.C: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2026-03-16 15:07:00 -07:00
Jonathan Wakely
c362a260ca libstdc++: Add module initialization functions to the library [PR124268]
This ensures that the module init functions are present in libstdc++.so
and libstdc++.a, so that users of the std and std.compat modules don't
need to manually link to std.o and/or std.compat.o in addition to
compiling the CMIs.

This also adds a clean-local target to remove the generated interface
units and manifest, and the gcm.cache directory for the CMIs.

libstdc++-v3/ChangeLog:

	PR libstdc++/124268
	* config/abi/pre/gnu.ver: Export symbols.
	* src/Makefile.am: Add libmodulesconvenience.la to libstdc++
	link.
	* src/Makefile.in: Regenerate.
	* src/c++23/Makefile.am: Create libmodulesconvenience.la
	and populate it with std.o and std.compat.o interface units.
	Add clean-local target.
	* src/c++23/Makefile.in: Regenerate.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2026-03-16 22:04:23 +00:00
Jonathan Wakely
c351a240ad libstdc++: Make ranges::distance work with volatile iterators (LWG 4242)
This implements LWG 4242 which was approved in Sofia 2025.

I don't think the change from static_cast<const decay_t<I>&> to just
static_cast<decay_t<I>> is observable, but it doesn't hurt. What fixes
the problem identified in the issue is the is_array_v check, which
avoids the static_cast entirely for volatile-qualified iterators.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h (distance(It&&, Sent)): Only decay
	arrays to pointers when the type is actually an array, as per
	LWG 4242.
	* testsuite/24_iterators/range_operations/distance.cc: Add test
	for LWG 4242.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2026-03-16 22:04:23 +00:00
Marek Polacek
a65cafbc52 c++: fix for printing std::meta::info [PR124489]
When printing the diagnostics in this test, we're saying
"constexprstd::meta::info dm" which misses a space.  We
should use pp_cxx_ws_string which does pp_c_maybe_whitespace
when printing "std::meta::info".

	PR c++/124489

gcc/cp/ChangeLog:

	* error.cc (dump_type) <case NULLPTR_TYPE>: Use pp_cxx_ws_string
	instead of pp_string.
	<case META_TYPE>: Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/reflect/diag6.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2026-03-16 17:59:54 -04:00
Joseph Myers
5a2de9e0ee Update gcc fr.po, sv.po
* fr.po, sv.po: Update.
2026-03-16 21:28:35 +00:00
Jose E. Marchesi
bdc5921ca5 a68: fix copy-pasto in install.texi
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>

gcc/ChangeLog

	* doc/install.texi (Configuration): Fix copy pasto
	--enable-objc-gc to --enable-algol68-gc.
2026-03-16 22:07:03 +01:00
Jonathan Wakely
ebe8e07eb8 libstdc++: Rewrite test for compare_exchange padding
Change the struct to ensure there is a padding byte between the members,
which was previously not the case for byte-aligned targets such as
cris-elf.

Add a new helper function to verify that the padding bits in a struct S
and in the std::atomic<S> are zero, without needing to disable SRA. Then
rewrite the test in terms of that helper, so we check directly that the
atomic object has the correct value and has no padding bits. Previously
we loaded a value (with -fno-tree-sra to hopefully preserve padding) and
then just using memcmp on that value to see if it was bitwise identical
to another value, but didn't actually check the members were correct or
that the padding was clear.

Also add a loop around the weak compare-exchange, to tolerate spurious
failures as described in
https://gcc.gnu.org/pipermail/gcc-patches/2026-March/710289.html

libstdc++-v3/ChangeLog:

	* testsuite/29_atomics/atomic/compare_exchange_padding.cc:
	Rewrite to be robust against spurious failures of weak compare
	exchange, and to check padding bits more directly.
2026-03-16 15:17:45 +00:00
Jonathan Wakely
f60dbb5796 libstdc++: Improve diagnostics for std::allocator<incomplete type>
Using requires { sizeof(T); } in __new_allocator::allocate gives a
better diagnostic when the static_assert fails.

We can also reduce the total number of diagnostics due to invalid
sizeof(T) and alignof(T) by using the same requires-expression to make
the body of the function a discarded statement when the static_assert
already failed. This fixes a regression in diagnostic quality due to
making __new_allocator::allocate constexpr in r16-7271-g7197d0cce70525,
which caused a cascade of seven errors instead of just one for
std::allocator<incomplete-type>().allocate(1).

libstdc++-v3/ChangeLog:

	* include/bits/allocator.h (allocator::allocate): Use specific
	feature test macro for constexpr allocate and deallocate. Make
	consteval path a discarded statement if sizeof(T) is ill-formed.
	* include/bits/new_allocator.h (__new_allocator::allocate): Use
	requires-expression for static_cast. Make function body a
	discarded stament if sizeof(T) is ill-formed. Use if-constexpr
	for alignment checks.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2026-03-16 15:17:45 +00:00
Alex Coplan
11f073a805 aarch64, testsuite: Add test for already-fixed PR [PR124491]
This adds a testcase for PR124491, which was fixed by these commits:

r16-6709-ga4716ece529dfd29d169ccc96979f7c747231f25
r16-6743-ge787d5ace5cc315892868f3e5e2a2a16fd31bcc8

I originally just added the test to the 15 branch with the backports for
those commits, but richi pointed out in the PR that we should have it on
trunk too, so this adds it to the trunk.

gcc/testsuite/ChangeLog:

	PR middle-end/124491
	* gcc.target/aarch64/torture/pr124491.c: New test.
2026-03-16 14:51:14 +00:00
Richard Biener
2894493adf tree-optimization/124528 - UB from SCEV
SCEV has a long-standing issue in that it negates the addend of
a subtraction within a SSA cycle without considering UB from
negating of the most negative value.  The following tries to
rectify this.

	PR tree-optimization/124528
	* tree-scalar-evolution.cc (scev_dfs::add_to_evolution):
	Perform the negation in an unsigned type if we cannot make
	sure it will not cause UB.

	* gcc.dg/tree-ssa/scev-17.c: New testcase.
2026-03-16 14:51:02 +01:00
Kito Cheng
4565290a96 RISC-V: Document big-endian support as experimental
The RISC-V big-endian ABI is not yet stable, add a note to the
-mbig-endian option documentation to warn users that support is
experimental and could change in incompatible ways.

gcc/ChangeLog:

	* doc/invoke.texi: Add experimental warning for RISC-V
	big-endian support.
2026-03-16 17:05:21 +08:00
Paul Thomas
37950565de Fortran: Regression in gfc_convert_to_structure_constructor [PR93832]
2026-03-16  Paul Thomas  <pault@gcc.gnu.org>
	    Steve Kargl  <kargls@comcast.net>

gcc/fortran
	PR fortran/93832
	* array.cc (resolve_array_bound): Emit error and return false
	if bound expression is derived type or class.
	* primary.cc (gfc_convert_to_structure_constructor): Do not
	dereference NULL in character component test. Define 'shorter'
	and use it help cure one of several whitespace issues.

gcc/testsuite/
	PR fortran/93832
	* gfortran.dg/pr93832.f90: New test.
2026-03-16 08:20:20 +00:00
Paul Thomas
c523f2a33b Fortran: Fix segfault due to class actual in parentheses [PR105168]
2026-03-16  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/105168
	* trans-expr.cc (gfc_conv_class_to_class): If the argument expr
	is not a class type use the parent tree if that is a class.
	(gfc_conv_procedure_call): If the argument expression is not a
	variable, shift the bounds to give unity lbounds.
	(gfc_trans_arrayfunc_assign): Return NULL_TREE instead of NULL.

gcc/testsuite/
	PR fortran/105168
	* gfortran.dg/pr105168.f90: New test.
2026-03-16 07:23:49 +00:00
Jakub Jelinek
caae42b311 c++: Fix up sb as condition instantiation error-recovery [PR120039]
The following two testcases ICE during instantation.
Normally for the artificial var used for structured binding as condition
(which has NULL DECL_NAME) there is a DECL_EXPR which registers local
specialization and so tsubst_expr works fine.
But if there are errors while parsing the initializer, the VAR_DECL
has still NULL_TREE DECL_NAME, but error_mark_node TREE_TYPE and
when tsubst_expr is called on it, it falls back to calling lookup_name
(NULL_TREE) and ICEs on that.

The following patch fixes it by not calling lookup_name if DECL_NAME is
NULL.

2026-03-16  Jakub Jelinek  <jakub@redhat.com>

	PR c++/120039
	PR c++/122559
	* pt.cc (tsubst_expr) <case VAR_DECL>: Don't call lookup_name on
	DECL_NAME (t) if it is NULL_TREE.

	* g++.dg/cpp26/decomp28.C: New test.
	* g++.dg/cpp26/decomp29.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2026-03-16 08:06:52 +01:00