]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
7 days agoRISC-V: -mmax-vectorization.
Robin Dapp [Fri, 14 Nov 2025 14:50:05 +0000 (15:50 +0100)] 
RISC-V: -mmax-vectorization.

This adds an -mmax-vectorization option to riscv, a verbatim copy from
aarch64.  It is an option for vector code analysis.  Internally it increases
scalar costs by a large factor so every vector approach will be
profitable.  As opposed to -fno-vect-cost-model, we will still compare
the vector approaches amongst each other, though.

In order to handle this argument without an '=' I needed to change the
parsing flow slightly.

gcc/ChangeLog:

* config/riscv/riscv-target-attr.cc (riscv_target_attr_parser::handle_max_vect):
New parser entry.
(riscv_target_attr_parser::update_settings): Set max-vect
option.
(riscv_process_one_target_attr): Change null-arg handling.
* config/riscv/riscv.cc (riscv_override_options_internal): Set
max-vect option.
* config/riscv/riscv.opt: Add -mmax-vectorization option.
* doc/extend.texi: Document new option.
* doc/invoke.texi: Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/max-vect-1.c: New test.
* gcc.target/riscv/rvv/autovec/max-vect-2.c: New test.

7 days agoRISC-V: Add more mode_idx attributes [PR123022].
Robin Dapp [Mon, 8 Dec 2025 09:22:51 +0000 (10:22 +0100)] 
RISC-V: Add more mode_idx attributes [PR123022].

Similar to 116149 we use the mode size of operand MODE_IDX but that
one could refer to a broadcast scalar.  Use operand 3 for scalar
broadcast patterns instead.

PR target/123022

gcc/ChangeLog:

* config/riscv/vector.md: Add mode_idx attribute.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr123022-2.c: New test.
* gcc.target/riscv/rvv/autovec/pr123022.c: New test.

7 days agoRISC-V: Pragma target [PR115325].
Robin Dapp [Fri, 5 Dec 2025 09:55:18 +0000 (10:55 +0100)] 
RISC-V: Pragma target [PR115325].

This implements #pragma GCC target () for riscv.

All the functionality was already there so we only need to wrap existing
functions.

PR target/115325

gcc/ChangeLog:

* config/riscv/riscv-c.cc (riscv_pragma_target_parse): New
function.
(riscv_register_pragmas): Register riscv_pragma_target_parse.
* config/riscv/riscv-protos.h (riscv_process_target_attr_for_pragma):
Declare.
(riscv_reset_previous_fndecl): Ditto.
* config/riscv/riscv-target-attr.cc (riscv_process_target_attr_for_pragma):
New function.
* config/riscv/riscv.cc (riscv_reset_previous_fndecl): Reset.
(riscv_option_save): New function.
(riscv_option_print): Ditto.
(riscv_get_interrupt_type): Adjust docs.
(TARGET_OPTION_SAVE): Implement.
(TARGET_OPTION_PRINT): Ditto.
* doc/extend.texi: Document that riscv can do target pragams.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/pragma-target-1.c: New test.
* gcc.target/riscv/pragma-target-2.c: New test.

7 days agoRISC-V: Implement mask reduction.
Robin Dapp [Mon, 20 Oct 2025 08:47:45 +0000 (10:47 +0200)] 
RISC-V: Implement mask reduction.

This implements mask reductions by first counting the bits in the mask
(vcpop.m) and then comparing the resulting scalar against 0 or len.

gcc/ChangeLog:

* config/riscv/autovec.md (reduc_sbool_and_scal_<mode>): New
expander.
(reduc_sbool_ior_scal_<mode>): Ditto.
(reduc_sbool_xor_scal_<mode>): Ditto.
* config/riscv/riscv-protos.h (expand_mask_reduction): Declare.
* config/riscv/riscv-v.cc (expand_mask_reduction): New function.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-1-run.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-1.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-2-run.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-2.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-3-run.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-3.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-4-run.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-4.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-5-run.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-5.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-6-run.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-6.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-7-run.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-7.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-8-run.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-8.c: New test.

7 days agotarget/123027 - handle min/max expansion when -ffinite-math-only
Richard Biener [Mon, 8 Dec 2025 09:14:19 +0000 (10:14 +0100)] 
target/123027 - handle min/max expansion when -ffinite-math-only

When we get a <= b ? b : a into ix86_expand_sse_fp_minmax we can
swap and invert this with -ffinite-math-only to get a < b ? a : b.

PR target/123027
* config/i386/i386-expand.cc (ix86_expand_sse_fp_minmax):
With !HONOR_NANS we can handle LE by swapping and inverting.

* gcc.target/i386/pr123027.c: New testcase.
* gcc.dg/torture/pr123027.c: Likewise.

8 days agoc++: Non-inline temploid friends should still be COMDAT [PR122819]
Nathaniel Shead [Sun, 7 Dec 2025 12:17:15 +0000 (23:17 +1100)] 
c++: Non-inline temploid friends should still be COMDAT [PR122819]

Modules allow temploid friends to no longer be implicitly inline, as
functions defined in a class body will not be implicitly inline if
attached to a named module.

This requires us to clean up linkage handling a little bit, mostly by
replacing usages of 'DECL_TEMPLATE_INSTANTIATION' with
'DECL_TEMPLOID_INSTANTIATION' when determining if an entity has vague
linkage.

PR c++/122819

gcc/cp/ChangeLog:

* decl.cc (start_preparsed_function): Use
DECL_TEMPLOID_INSTANTIATION instead of
DECL_TEMPLATE_INSTANTIATION to check vague linkage.
* decl2.cc (vague_linkage_p): Likewise.
(c_parse_final_cleanups): Simplify condition.
* semantics.cc (expand_or_defer_fn_1): Also check for temploid
friend functions.

gcc/testsuite/ChangeLog:

* g++.dg/modules/tpl-friend-22.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
8 days agoDaily bump.
GCC Administrator [Tue, 9 Dec 2025 00:16:30 +0000 (00:16 +0000)] 
Daily bump.

8 days agofinal_cleanup: Call make_forwarders_with_degenerate_phis [PR46555]
Andrew Pinski [Sat, 6 Dec 2025 09:11:29 +0000 (01:11 -0800)] 
final_cleanup: Call make_forwarders_with_degenerate_phis [PR46555]

This fixes a regression introduced with r16-5258-g1d8e2d51e5c5cb.
With GCC 12+, we would not merge forwarders (with phis, vops included),
this meant that after the last cddce, degenerate phis would stay not
merged which allowed for better expansion. Now after my patch, the forwarder
block would be removed and get worse expansion. This fixes the problem
by creating the forwarder blocks in "optimized" and no other cleanupcfg
is called afterwards.

Oh this also fixes the problem at -O1 which was missed because the agressive
version of dce was not done at -O1.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/46555
gcc/ChangeLog:

* tree-cfgcleanup.cc (execute_cleanup_cfg_post_optimizing):
Don't set todo to include cleanupcfg; do it manually.
Call make_forwarders_with_degenerate_phis if optimizing.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr46555.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
8 days agocfg: add debug dump to make_forwarders_with_degenerate_phis.
Andrew Pinski [Sat, 6 Dec 2025 09:10:07 +0000 (01:10 -0800)] 
cfg: add debug dump to make_forwarders_with_degenerate_phis.

To understand what this function does, add a debug dump.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-cfg.cc (make_forwarders_with_degenerate_phis): Add debug
dump.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
8 days agocfg: Move make_forwarders_with_degenerate_phis to tree-cfg
Andrew Pinski [Sat, 6 Dec 2025 09:05:47 +0000 (01:05 -0800)] 
cfg: Move make_forwarders_with_degenerate_phis to tree-cfg

This moves make_forwarders_with_degenerate_phis to tree-cfg.cc
from tree-ssa-dce.cc to be able to use in a different pass.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-ssa-dce.cc (sort_phi_args): Move to tree-cfg.cc.
(make_forwarders_with_degenerate_phis): Move to tree-cfg.cc.
(perform_tree_ssa_dce): Update for the updated return type
of make_forwarders_with_degenerate_phis.
* tree-cfg.cc (sort_phi_args): Moved from tree-ssa-dce.cc.
(make_forwarders_with_degenerate_phis): Moved from tree-ssa-dce.cc.
Update return type to bool and return true if an edge was split.
* tree-cfg.h (make_forwarders_with_degenerate_phis): New decl.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
8 days agoAda: Add missing #include for MinGW
Eric Botcazou [Mon, 8 Dec 2025 21:34:20 +0000 (22:34 +0100)] 
Ada: Add missing #include for MinGW

This adds a missing #include for <stdlib.h> and removes redundant ones.

gcc/ada/
PR ada/123037
* rtinit.c [__MINGW32__]: Include <stdlib.h> and not <windows.h>.
* rtfinal.c [__MINGW32__]: Do not include <windows.h>.

8 days agoFortran: [PR123025] Catch Old-style character declarations.
Harald Anlauf [Mon, 8 Dec 2025 19:48:29 +0000 (11:48 -0800)] 
Fortran: [PR123025] Catch Old-style character declarations.

Before this patch we missed the two cases here:

character*5 string5         ! Gives obsolescent message
character*(5) string5const  ! Silent with constant
character*(2+3) string5expr ! Silent with expression

PR fortran/123025

gcc/fortran/ChangeLog:

* decl.cc (match_char_length): Add a check for the
obsolete '*' style of character declarations in the
alternate branch of checking so we dont miss two
use cases:

gcc/testsuite/ChangeLog:

* gfortran.dg/assumed_charlen_dummy.f90: These tests failed
with the change because of the default -pedantic option
used by the dg.exp mechanisms. Overide this default.
* gfortran.dg/automatic_char_len_1.f90: Ditto.
* gfortran.dg/entry_23.f: Ditto.
* gfortran.dg/finalize_59.f90: Dito.
* gfortran.dg/g77/f90-intrinsic-bit.f: Ditto.
* gfortran.dg/g77/f90-intrinsic-mathematical.f: Ditto.
* gfortran.dg/g77/f90-intrinsic-numeric.f: Ditto.
* gfortran.dg/g77/intrinsic-unix-bessel.f: Ditto.
* gfortran.dg/g77/intrinsic-unix-erf.f: Ditto.
* gfortran.dg/initialization_9.f90: Ditto.
* gfortran.dg/intrinsic_actual_4.f90: Ditto.
* gfortran.dg/namelist_assumed_char.f90: Ditto.
* gfortran.dg/pr15140.f90: Ditto.

Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
8 days agoc++: Document why TARGET_EXPR is not handled in tsubst_expr
Egas Ribeiro [Mon, 8 Dec 2025 18:04:42 +0000 (18:04 +0000)] 
c++: Document why TARGET_EXPR is not handled in tsubst_expr

TARGET_EXPR represents semantic temporary objects and is deliberately
not handled by tsubst routines, which expect syntactic templated trees.
Add a comment and gcc_unreachable to make this explicit.

gcc/cp/ChangeLog:

* pt.cc (tsubst_expr): Add TARGET_EXPR case with explanatory
comment and gcc_unreachable.

Signed-off-by: Egas Ribeiro <egas.g.ribeiro@tecnico.ulisboa.pt>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
8 days agolibstdc++: Implement P2404R3 relaxations to comparable_with concepts [PR122946]
Jonathan Wakely [Thu, 4 Dec 2025 14:45:53 +0000 (14:45 +0000)] 
libstdc++: Implement P2404R3 relaxations to comparable_with concepts [PR122946]

This implements the C++23 proposal P2404R3 "Move-only types for
equality_comparable_with, totally_ordered_with, and
three_way_comparable_with". As agreed with the maintainers of libc++ and
MSVC STL, we treat this as a DR for C++20. It allows reasonable code to
compile which wasn't originally allowed in C++20, and only affects some
obscure subsumption cases for valid C++20 code.

libstdc++-v3/ChangeLog:

PR libstdc++/122946
* include/bits/version.def (concepts): Set value to 202207.
* include/bits/version.h: Regenerate.
* include/std/concepts (__comparison_common_type_with_impl)
(__comparison_common_type_with): New helper concepts.
(equality_comparable_with): Use __comparison_common_type_with.
* libsupc++/compare (three_way_comparable_with): Likewise.
(__glibcxx_want_concepts): Define to get __cpp_lib_concepts
here.
* testsuite/std/concepts/concepts.compare/move_only.cc: New
test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
8 days agolibstdc++: Extend __is_standard_integer to cover extended integer types
Jonathan Wakely [Fri, 5 Dec 2025 20:54:32 +0000 (20:54 +0000)] 
libstdc++: Extend __is_standard_integer to cover extended integer types

We have __is_signed_integer and __is_unsigned_integer traits which
should have been updated by r16-2190-g4faa42ac0dee2c when making
__int128 an extended integer type (for PR libstdc++/96710). Currently
they check whether the type is a signed integer type or an unsigned
integer type, or a cv-qualified version of one of those. This doesn't
match the standard's definition, which does not include cv-qualified
types. This change ensures that signed __int128 and unsigned __int128
are included in those traits in strict -std modes, and it removes the
use of remove_cv_t so that they are not true for cv-qualified types.
This makes the traits match the meaning of "signed integer type" and
"unsigned integer type" in the standard ([basic.fundamental]).

We also have an __is_standard_integer trait, which is true if either
__is_signed_integer or __is_unsigned_integer is true, but that's also
not a match for the definition in the standard. The definitions of
"signed integer type" and "unsigned integer type" include both standard
and extended integer types, so only saying "standard" in the trait name
is misleading (even before this change, because in non-strict -std modes
the __GLIBCXX_TYPE_INT_N_0 .. __GLIBCXX_TYPE_INT_N_3 types were always
included in the trait, and they aren't standard integer types).

This change renames __is_standard_integer to the more accurate
__is_signed_or_unsigned_integer. Because the set of signed and
unsigned integer types is the same as the set of standard and extended
integer types, the trait could instead have been renamed to
__is_standard_or_extended_integer. I think it's clearer and more
self-explanatory to avoid "standard and extended" and name it for the
signed and unsigned integer types.

N.B. we don't want to call it just __is_integer_type because the integer
types includes cv-qualified types and also bool and the character types
char, wchar_t, char16_t etc.

The consequences of redefining and renaming these traits are small, and
only positive.

Apart from the uses in the __is_standard_integer trait, the only other
uses of __is_signed_integer and __is_unsigned_integer are in <format>
and those uses are unaffected by this change to add 128-bit integers to
the traits. In both uses the type argument is already cv-unqualified,
and there is already explicit handling for 128-bit integers where that
is required.

The existing uses of __is_standard_integer can simply be changed to use
the new name. This does change the behaviour of those uses of the trait,
because the __is_signed_or_unsigned_integer trait now includes
128-bit integers in strict modes. However, that is a desirable change
that fixes some bugs. Specifically, the [utility.intcmp] functions such
as std::cmp_less and the [numeric.sat.arith] functions such as
std::add_sat did not support 128-bit integers in strict modes. Since the
standard says they should be enabled for all signed and unsigned integer
types (or equivalently, for all standard and extended integer types),
those functions should all support __int128 and unsigned __int128. That
is fixed by this change.  Additionally, the same changes in <charconv>,
<mdspan>, and <stdckdint.h> enable the use of 128-bit integers for those
APIs in strict modes.

Finally, this also make a drive-by fix to the enable_if constraints for
the integer overloads of std::from_chars. That used remove_cv_t and so
enabled the overload for lvalue arguments of type const char, which
won't work and should not be enabled.

libstdc++-v3/ChangeLog:

* include/bits/intcmp.h: Replace all uses of
__is_standard_integer with __is_signed_or_unsigned_integer.
* include/bits/max_size_type.h: Fix outdated comment.
* include/bits/sat_arith.h: Replace all uses of
__is_standard_integer with __is_signed_or_unsigned_integer.
* include/c_compatibility/stdckdint.h: Replace all uses of the
__cv_unqual_signed_or_unsigned_integer_type concept with
__is_signed_or_unsigned_integer.
(__cv_unqual_signed_or_unsigned_integer_type): Remove.
* include/ext/numeric_traits.h: Fix outdated comment.
* include/std/charconv (from_chars): Replace use of
__is_standard_integer with __is_signed_or_unsigned_integer.
Do not enable for cv-qualified char.
* include/std/mdspan: Likewise.
* include/std/type_traits (__is_unsigned_integer): Include
unsigned __int128 in type list.
(__is_signed_integer): Include signed __int128 in type list.
(__is_standard_integer): Rename to ...
(__is_signed_or_unsigned_integer): ... this.
* testsuite/23_containers/mdspan/extents/ctor_ints.cc: Test
with 128-bit integers.
* testsuite/23_containers/mdspan/submdspan/strided_slice.cc:
Likewise.
* testsuite/20_util/integer_comparisons/extended.cc: New test.
* testsuite/26_numerics/saturation/extended.cc: New test.
* testsuite/26_numerics/stdckdint/extended.cc: New test.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
8 days agoc++: Fix SFINAE for deleted explicit specializations [PR119343]
Egas Ribeiro [Sun, 7 Dec 2025 23:35:00 +0000 (23:35 +0000)] 
c++: Fix SFINAE for deleted explicit specializations [PR119343]

When checking a deleted explicit specialization in a SFINAE context,
we were incorrectly selecting a partial specialization because
resolve_nondeduced_context was calling mark_used.  But resolving an
overload to a single function (per DR 115) does not constitute ODR-use,
so mark_used shouldn't be called there.  Instead callers should call
mark_used or mark_single_function on the result to uniformly handle all
resolvable overloads (even non-template-id ones).

This turns out to fix the below testcase because it causes convert_to_void
for void(X::template g<0>) to properly propagate ODR-use failure (due to
deleted g<0>) and return error_mark_node instead of returning void_node.

PR c++/119343

gcc/cp/ChangeLog:

* pt.cc (resolve_nondeduced_context): Remove mark_used call.

gcc/testsuite/ChangeLog:

* g++.dg/template/sfinae-deleted-pr119343.C: New test.

Signed-off-by: Egas Ribeiro <egas.g.ribeiro@tecnico.ulisboa.pt>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
8 days agocontrib: Set more site.exp variables in test_installed
Joseph Myers [Mon, 8 Dec 2025 17:02:22 +0000 (17:02 +0000)] 
contrib: Set more site.exp variables in test_installed

Add support in contrib/test_installed for more variables (via
associated command-line options to the script) that gcc/Makefile.in
can set:

* ALT_CC_UNDER_TEST, ALT_CXX_UNDER_TEST and COMPAT_OPTIONS are used in
  compat testing (against the same or a different compiler).

* The libiconv variable is used for testing iconv support for
  particular character sets, and defaults to -liconv if not set in
  site.exp, which is wrong on systems with iconv in libc; keep the
  default, but add an option to override this.

  Note that the dg-require-iconv testing is currently bogus in a cross
  environment, and this patch does nothing to address that.  The tests
  using dg-require-iconv actually care about character set support on
  the *host*, for character conversions carried out in the compiler,
  and the libiconv setting put in site.exp by gcc/Makefile.in is a
  *host* library setting.  But dg-require-iconv /
  check_iconv_available tests availability when compiling, linking and
  executing for the *target*.  If the host and target have close
  enough to the same OS, this may work by accident, but otherwise it
  will incorrectly enable / disable these tests based on target
  information (but using a libiconv setting designed for the host)
  when it should be based on host information.

* test_installed (--with-alt-cc=, --with-alt-cxx=)
(--with-compat-options=, --with-libiconv=): New options.

8 days agoMinGW: Fix native TLS bug with -fdata-sections
Eric Botcazou [Mon, 8 Dec 2025 16:47:56 +0000 (17:47 +0100)] 
MinGW: Fix native TLS bug with -fdata-sections

The problem comes from a quirk of the GNU PE-COFF linker, which wants
to make sure that .tls$ZZZ is laid out last among the TLS sections,
but first globs all .tls$* sections together.  The solution matches
Clang's output.

gcc/
PR target/80881
* config/mingw/winnt.cc (mingw_pe_unique_section): Put two dollar
signs for TLS sections after the prefix.
(mingw_pe_asm_named_section): Deal with all TLS sections uniformly.

gcc/testsuite/
* gcc.dg/tls/data-sections-1.c: New test.

8 days agoAdd ncm to MAINTAINERS
Nathan Myers [Mon, 8 Dec 2025 15:30:09 +0000 (10:30 -0500)] 
Add ncm to MAINTAINERS

gcc/Changelog:

* MAINTAINERS: add ncm

8 days agoaarch64: Add support for C1 cores
Ezra Sitorus [Mon, 8 Dec 2025 14:45:00 +0000 (14:45 +0000)] 
aarch64: Add support for C1 cores

Add support for C1-Nano, C1-Pro, C1-Premium and C1-Ultra.

gcc/ChangeLog:

* config/aarch64/aarch64-cores.def (AARCH64_CORE): Add C1-Nano,
C1-Pro, C1-Premium and C1-Ultra.
* config/aarch64/aarch64-tune.md: Regenerate.
* doc/invoke.texi: Document C1 cores.

8 days agotree-optimization/123040 - handle nary -> ifn simplification in VN
Richard Biener [Mon, 8 Dec 2025 10:06:54 +0000 (11:06 +0100)] 
tree-optimization/123040 - handle nary -> ifn simplification in VN

The following handles (by rejecting) simplifications that end up
turning a VN NARY operation into a call which would be a VN REFERENCE
and is unexpected and not handled.

PR tree-optimization/123040
* tree-ssa-sccvn.cc (vn_nary_build_or_lookup_1): Only insert
nary results.

* g++.dg/torture/pr123040.C: New testcase.

8 days agolibstdc++: Refactor _Variadic_union so _Unitialized<T, false> is not needed [PR112591].
Tomasz Kamiński [Mon, 8 Dec 2025 07:49:45 +0000 (08:49 +0100)] 
libstdc++: Refactor _Variadic_union so _Unitialized<T, false> is not needed [PR112591].

The changes the _Variadic_union implementation, in a way that the
_Unitialized<T, false> partial specialization for non-trivial types is not
necessary.

This is simply done by separating the specialization for __trivially_destructible
being true and false, and for the later defining an empty destructor (similarly
as it was done using concepts).

We also reduce the number of specialization of _Variadic_union, so specialization
(int, int) is reused by (string, int, int) and (int, int). This is done by
initialization __trivially_destructible with conjunction of
is_trivially_destructible_v for remaining components. This is only necessary
for non-trivial (false) specialization, as if both _First and _Rest... are
trivially destructible, then _Rest must also be.

The above change does not regress the fix r14-7259-g2d55d94e5df389 for
template depth, and both before and after the change template depth is 266.
I have added dg-options to the 87619.cc to catch future regressions.

This also add test for PR112591.

PR libstdc++/112591

libstdc++-v3/ChangeLog:

* include/std/variant (_Variadic_union): Separate specializations for
for union of only trivially destructible types (true as first template
argument). Unconditionally define destructor for _Variadic_union<false,
_First, _Rest...>.
* testsuite/20_util/variant/87619.cc: Add limit for the template depth.
* testsuite/20_util/variant/112591.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
8 days agocontrib: Skip libstdc++ files in check_GNU_style.py
Jonathan Wakely [Thu, 4 Dec 2025 09:42:50 +0000 (09:42 +0000)] 
contrib: Skip libstdc++ files in check_GNU_style.py

The libstdc++ style is different from the rest of GCC, so do not apply
the checks to libstdc++ files in a patch.

contrib/ChangeLog:

* check_GNU_style_lib.py (check_GNU_style_file): Do not check
libstdc++ files.

Reviewed-by: Christophe Lyon <christophe.lyon@linaro.org>
8 days agoipa/122798: Adjust local and address_taken flags for callback clones.
Josef Melcr [Mon, 8 Dec 2025 08:21:38 +0000 (09:21 +0100)] 
ipa/122798: Adjust local and address_taken flags for callback clones.

Hi,
previously, clones of callback functions had their local flag set.
Because callback edges are direct rather than indirect, GCC falsely
assumes that their callsites are available and that it can change their
ABI, leading to segfaults.  This patch fixes that.  Additionally, this
patch fixes a check in redirect_callee for clearing the address_taken
flag.

PR ipa/122798

gcc/ChangeLog:

* cgraph.cc (cgraph_edge::redirect_callee): Use
iterate_referring instead of referred_to_p.
* cgraphclones.cc (set_new_clone_decl_and_node_flags): Set local
to true iff the node does not have its address taken.

Signed-off-by: Josef Melcr <josef.melcr@suse.com>
8 days agolibstdc++: Remove redundant diagnostic pragmas from <bits/iterator_concepts.h>
Jonathan Wakely [Fri, 5 Dec 2025 15:59:23 +0000 (15:59 +0000)] 
libstdc++: Remove redundant diagnostic pragmas from <bits/iterator_concepts.h>

Since r16-2190-g4faa42ac0dee2c this header no longer mentions __int128
explicitly, because it's just handled like other integer types now. So
we don't need the diagnostic pragmas to disables pedwarns for referring
to __int128.

libstdc++-v3/ChangeLog:

* include/bits/iterator_concepts.h: Remove diagnostic pragmas.

8 days agotree-optimization/123038 - FFS/CTZ pattern incompatible with reductions
Richard Biener [Sun, 7 Dec 2025 10:30:48 +0000 (11:30 +0100)] 
tree-optimization/123038 - FFS/CTZ pattern incompatible with reductions

The pattern ends up using the argument more than one time which
isn't supported.  When FFS directly maps to CTZ + 1 it works though.

PR tree-optimization/123038
* tree-vect-patterns.cc (vect_recog_ctz_ffs_pattern): Reject
pattern for reductions when the call argument is used multiple
times.

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

8 days agolibstdc++: Move std::cmp_equal, std::cmp_less etc. to new file
Jonathan Wakely [Fri, 5 Dec 2025 15:32:17 +0000 (15:32 +0000)] 
libstdc++: Move std::cmp_equal, std::cmp_less etc. to new file

This allows the [utility.intcmp] functions to be used without including
all of <utility>.

libstdc++-v3/ChangeLog:

* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/std/latch: Include <bits/intcmp.h> instead of
<utility>.
* include/std/utility: Include <bits/intcmp.h>.
(cmp_equal, cmp_not_equal, cmp_less, cmp_greater)
(cmp_less_equal, cmp_greater_equal, in_range): Move to ...
* include/bits/intcmp.h: New file.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
8 days agoAArch64: fix subregs in boolean reductions [PR123026]
Tamar Christina [Mon, 8 Dec 2025 09:12:01 +0000 (09:12 +0000)] 
AArch64: fix subregs in boolean reductions [PR123026]

The Adv. SIMD boolean reduction patterns were accidentally
overriding one of the input arguments.  This fixes it and
removes unneeded intermediate moves around the subreg type
castings.

gcc/ChangeLog:

PR target/123026
* config/aarch64/aarch64-simd.md (reduc_sbool_ior_scal_<mode>,
reduc_sbool_and_scal_<mode>): Fix tmp operands[1] override.

gcc/testsuite/ChangeLog:

PR target/123026
* gcc.target/aarch64/pr123026.c: New test.

8 days agovect: move the condition down into the loop checking every scalar load [PR122868]
Tamar Christina [Mon, 8 Dec 2025 09:10:58 +0000 (09:10 +0000)] 
vect: move the condition down into the loop checking every scalar load [PR122868]

As Richi suggested this moves the check into the loop so we check every load.

I had initially not done this because I figured the loads would be treated as a
group anyway and the group would be valid or not as a whole.  But for invariants
they could be a group, but not all the loads within range of a known bounds.

gcc/ChangeLog:

PR tree-optimization/122868
* tree-vect-stmts.cc (vectorizable_load): Move check for invariant loads
down into the loop.

8 days agox86: Compile avx2-vpcmpgtq-1.c with -fno-fuse-ops-with-volatile-access
H.J. Lu [Mon, 8 Dec 2025 05:32:55 +0000 (13:32 +0800)] 
x86: Compile avx2-vpcmpgtq-1.c with -fno-fuse-ops-with-volatile-access

When -march=cascadelake is added, we generate

vmovdqa x(%rip), %ymm0
vpcmpq $1, x(%rip), %ymm0, %k0
vpmovm2q %k0, %ymm0
vmovdqa %ymm0, x(%rip)

instead of

vmovdqa x(%rip), %ymm1
vmovdqa x(%rip), %ymm0
vpcmpgtq %ymm1, %ymm0, %ymm0
vmovdqa %ymm0, x(%rip)

Compile avx2-vpcmpgtq-1.c with -fno-fuse-ops-with-volatile-access to
generate vpcmpgtq instead of vpcmpq.

PR target/122343
* gcc.target/i386/avx2-vpcmpgtq-1.c: Compile with
-fno-fuse-ops-with-volatile-access.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
8 days agox86: Don't allow 2 volatile memory references
H.J. Lu [Mon, 8 Dec 2025 05:29:59 +0000 (13:29 +0800)] 
x86: Don't allow 2 volatile memory references

Don't allow 2 volatile memory references in *<avx512>_cmp<mode>3_dup_op
so that gcc.target/i386/avx2-vpcmpeqq-1.c will generate 2 loads when
-march=cascadelake is used.

PR target/122343
* config/i386/sse.md (*<avx512>_cmp<mode>3_dup_op): Don't allow
2 volatile memory references.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
9 days agoDaily bump.
GCC Administrator [Mon, 8 Dec 2025 00:16:25 +0000 (00:16 +0000)] 
Daily bump.

9 days agoAda: Fix wrong Accum_Type inferred for a reduction expression
Eric Botcazou [Sun, 7 Dec 2025 22:40:25 +0000 (23:40 +0100)] 
Ada: Fix wrong Accum_Type inferred for a reduction expression

This was reported as a regression in GCC 14: the compiler resolves
Accum_Type to Positive for a reduction expression whose "expected
subtype" is Positive, which means that 0 cannot be used as initial
value in the expression:

  Sum : Positive := V'Reduce ("+", 0);

without always raising Constraint_Error as run time.  That's not the
intent according to T. Taft in
  https://forum.ada-lang.io/t/regression-in-gnat-14/890
so this changes the resolution to use the base type (Integer) instead.

gcc/ada/
PR ada/115349
* sem_attr.adb (Resolve_Attribute) <Attribute_Reduce>: Use the base
type as Accum_Type if the reducer is an operator from Standard and
the type is numeric.  Use the type of the first operand for other
operators.  Streamline the error message given for limited types.

gcc/testsuite/
* gnat.dg/reduce3.adb: New test.

9 days agoanalyzer: remove duplicated registration of builtins
David Malcolm [Sun, 7 Dec 2025 15:15:34 +0000 (10:15 -0500)] 
analyzer: remove duplicated registration of builtins

gcc/analyzer/ChangeLog:
* kf.cc (register_known_functions): Remove duplicate calls to
register_atomic_builtins and register_varargs_builtins.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
9 days agolibcpp: adjust _cpp_file accessors
Jason Merrill [Sun, 7 Dec 2025 07:34:15 +0000 (15:34 +0800)] 
libcpp: adjust _cpp_file accessors

Back in r78875 mrs added cpp_get_path/dir accessors for _cpp_file in order
to interface with the darwin framework system.  But now I notice that the
latter duplicates the better-named _cpp_get_file_dir, and I'm inclined to
rename the former to match.

Perhaps we should drop the initial underscore since these are no
longer internal interfaces; OTOH, _cpp_hashnode_value and
_cpp_backup_tokens still have the initial underscore in cpplib.h.

libcpp/ChangeLog:

* include/cpplib.h (cpp_get_path, cpp_get_dir): Remove.
(_cpp_get_file_path, _cpp_get_file_name, _cpp_get_file_stat)
(_cpp_get_file_dir): Move prototypes from...
* internal.h: ...here.
* files.cc (_cpp_get_file_path): Rename from...
(cpp_get_path): ...this.
(cpp_get_dir): Remove.

gcc/ChangeLog:

* config/darwin-c.cc (find_subframework_header): Use
_cpp_get_file_*.

10 days agoAdd -ffuse-ops-with-volatile-access
H.J. Lu [Fri, 24 Oct 2025 01:00:59 +0000 (09:00 +0800)] 
Add -ffuse-ops-with-volatile-access

Volatile memory can be used as source operand for any operations.  Add
-ffuse-ops-with-volatile-access to fuse operations with volatile memory
reference and update simplify_binary_operation_1 to keep PLUS for 2
volatile memory references.  On x86, this optimizes

extern volatile int bar;

int
foo (int z)
{
  z *= 123;
  return bar + z;
}

into

foo:
imull $123, %edi, %eax
addl bar(%rip), %eax
ret

and compile

extern volatile unsigned char u8;

void
test (void)
{
  u8 = u8 + u8;
  u8 = u8 - u8;
}

into

test:
movzbl u8(%rip), %eax
addb %al, u8(%rip)
movzbl u8(%rip), %eax
subb u8(%rip), %al
movb %al, u8(%rip)
ret

Tested with Linux kernel 6.17.9 on Intel Core i7-1195G7.

gcc/

PR target/122343
* common.opt: Add -ffuse-ops-with-volatile-access.
* common.opt.urls: Regenerated.
* recog.cc (general_operand): Allow volatile memory reference if
-ffuse-ops-with-volatile-access is enabled.
* simplify-rtx.cc (simplify_binary_operation_1): Keep PLUS for 2
volatile memory references.
* doc/invoke.texi: Document -ffuse-ops-with-volatile-access.

gcc/testsuite/

PR target/122343
* gcc.target/i386/20040112-1.c: Add -fomit-frame-pointer and use
check-function-bodies to check for loop.
* gcc.target/i386/avx-ne-convert-1.c: Compile with
-fno-fuse-ops-with-volatile-access.
* gcc.target/i386/avx10_2-bf16-1.c: Likewise.
* gcc.target/i386/avx10_2-convert-1.c: Likewise.
* gcc.target/i386/avx10_2-satcvt-1.c: Likewise.
* gcc.target/i386/avx512bf16-vcvtneps2bf16-1.c: Likewise.
* gcc.target/i386/avx512bf16vl-vcvtneps2bf16-1a.c: Likewise.
* gcc.target/i386/avx512bf16vl-vcvtneps2bf16-1b.c: Likewise.
* gcc.target/i386/avx512bitalg-vpshufbitqmb.c: Likewise.
* gcc.target/i386/avx512bw-vpcmpb-1.c: Likewise.
* gcc.target/i386/avx512bw-vpcmpub-1.c: Likewise.
* gcc.target/i386/avx512bw-vpcmpuw-1.c: Likewise.
* gcc.target/i386/avx512bw-vpcmpw-1.c: Likewise.
* gcc.target/i386/avx512dq-vcvtps2qq-1.c: Likewise.
* gcc.target/i386/avx512dq-vcvtps2uqq-1.c: Likewise.
* gcc.target/i386/avx512dq-vcvtqq2pd-1.c: Likewise.
* gcc.target/i386/avx512dq-vcvtqq2ps-1.c: Likewise.
* gcc.target/i386/avx512dq-vcvttps2qq-1.c: Likewise.
* gcc.target/i386/avx512dq-vcvttps2uqq-1.c: Likewise.
* gcc.target/i386/avx512dq-vcvtuqq2pd-1.c: Likewise.
* gcc.target/i386/avx512dq-vcvtuqq2ps-1.c: Likewise.
* gcc.target/i386/avx512dq-vextractf32x8-1.c: Likewise.
* gcc.target/i386/avx512dq-vextractf64x2-1.c: Likewise.
* gcc.target/i386/avx512dq-vextracti64x2-1.c: Likewise.
* gcc.target/i386/avx512dq-vfpclasspd-1.c: Likewise.
* gcc.target/i386/avx512dq-vfpclassps-1.c: Likewise.
* gcc.target/i386/avx512dq-vfpclasssd-1.c: Likewise.
* gcc.target/i386/avx512dq-vfpclassss-1.c: Likewise.
* gcc.target/i386/avx512dq-vpmullq-1.c: Likewise.
* gcc.target/i386/avx512dq-vpmullq-3.c: Likewise.
* gcc.target/i386/avx512f-pr100267-1.c: Likewise.
* gcc.target/i386/avx512f-vcmppd-1.c: Likewise.
* gcc.target/i386/avx512f-vcmpps-1.c: Likewise.
* gcc.target/i386/avx512f-vcvtps2pd-1.c: Likewise.
* gcc.target/i386/avx512f-vcvtsd2si-1.c: Likewise.
* gcc.target/i386/avx512f-vcvtsd2si64-1.c: Likewise.
* gcc.target/i386/avx512f-vcvtsd2usi-1.c: Likewise.
* gcc.target/i386/avx512f-vcvtsd2usi64-1.c: Likewise.
* gcc.target/i386/avx512f-vcvtsi2ss-1.c: Likewise.
* gcc.target/i386/avx512f-vcvtss2si-1.c: Likewise.
* gcc.target/i386/avx512f-vcvtss2si64-1.c: Likewise.
* gcc.target/i386/avx512f-vcvtss2usi-1.c: Likewise.
* gcc.target/i386/avx512f-vcvtss2usi64-1.c: Likewise.
* gcc.target/i386/avx512f-vcvttsd2si-1.c: Likewise.
* gcc.target/i386/avx512f-vcvttsd2si64-1.c: Likewise.
* gcc.target/i386/avx512f-vcvttsd2usi-1.c: Likewise.
* gcc.target/i386/avx512f-vcvttsd2usi64-1.c: Likewise.
* gcc.target/i386/avx512f-vcvttss2si-1.c: Likewise.
* gcc.target/i386/avx512f-vcvttss2si64-1.c: Likewise.
* gcc.target/i386/avx512f-vcvttss2usi-1.c: Likewise.
* gcc.target/i386/avx512f-vcvttss2usi64-1.c: Likewise.
* gcc.target/i386/avx512f-vextractf32x4-1.c: Likewise.
* gcc.target/i386/avx512f-vextractf64x4-1.c: Likewise.
* gcc.target/i386/avx512f-vextracti64x4-1.c: Likewise.
* gcc.target/i386/avx512f-vmovapd-1.c: Likewise.
* gcc.target/i386/avx512f-vmovaps-1.c: Likewise.
* gcc.target/i386/avx512f-vmovdqa64-1.c: Likewise.
* gcc.target/i386/avx512f-vpandnq-1.c: Likewise.
* gcc.target/i386/avx512f-vpbroadcastd-1.c: Likewise.
* gcc.target/i386/avx512f-vpbroadcastq-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpd-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpeqq-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpequq-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpged-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpgeq-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpgeud-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpgeuq-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpled-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpleq-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpleud-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpleuq-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpltd-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpltq-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpltud-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpltuq-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpneqd-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpneqq-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpnequd-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpnequq-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpq-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpud-1.c: Likewise.
* gcc.target/i386/avx512f-vpcmpuq-1.c: Likewise.
* gcc.target/i386/avx512f-vrndscalepd-1.c: Likewise.
* gcc.target/i386/avx512f-vrndscaleps-1.c: Likewise.
* gcc.target/i386/avx512fp16-complex-fma.c: Likewise.
* gcc.target/i386/avx512fp16-vaddph-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vcvtpd2ph-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vcvtph2dq-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vcvtph2pd-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vcvtph2psx-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vcvtph2qq-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vcvtph2udq-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vcvtph2uqq-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vcvtph2uw-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vcvtph2w-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vcvtps2ph-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vcvtqq2ph-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vcvttph2dq-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vcvttph2qq-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vcvttph2udq-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vcvttph2uqq-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vcvttph2uw-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vcvttph2w-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vcvtuqq2ph-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vfcmaddcph-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vfcmulcph-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vfmaddcph-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vfmulcph-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vfpclassph-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vfpclasssh-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vmulph-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vrcpph-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vrsqrtph-1a.c: Likewise.
* gcc.target/i386/avx512fp16-vsqrtph-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vaddph-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vcvtpd2ph-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vcvtph2dq-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vcvtph2psx-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vcvtph2qq-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vcvtph2udq-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vcvtph2uqq-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vcvtph2uw-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vcvtph2w-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vcvtps2ph-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vcvtqq2ph-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vcvttph2dq-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vcvttph2udq-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vcvttph2uw-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vcvttph2w-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vcvtuqq2ph-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vfcmaddcph-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vfcmulcph-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vfmaddcph-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vfmulcph-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vfpclassph-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vmulph-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vrcpph-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vrsqrtph-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-vsqrtph-1a.c: Likewise.
* gcc.target/i386/avx512vl-pr100267-1.c: Likewise.
* gcc.target/i386/avx512vl-vcmppd-1.c: Likewise.
* gcc.target/i386/avx512vl-vcmpps-1.c: Likewise.
* gcc.target/i386/avx512vl-vcvtpd2ps-1.c: Likewise.
* gcc.target/i386/avx512vl-vcvtpd2udq-1.c: Likewise.
* gcc.target/i386/avx512vl-vcvttpd2udq-1.c: Likewise.
* gcc.target/i386/avx512vl-vcvttps2udq-1.c: Likewise.
* gcc.target/i386/avx512vl-vextractf32x4-1.c: Likewise.
* gcc.target/i386/avx512vl-vmovapd-1.c: Likewise.
* gcc.target/i386/avx512vl-vmovaps-1.c: Likewise.
* gcc.target/i386/avx512vl-vmovdqa64-1.c: Likewise.
* gcc.target/i386/avx512vl-vpcmpd-1.c: Likewise.
* gcc.target/i386/avx512vl-vpcmpeqq-1.c: Likewise.
* gcc.target/i386/avx512vl-vpcmpequq-1.c: Likewise.
* gcc.target/i386/avx512vl-vpcmpq-1.c: Likewise.
* gcc.target/i386/avx512vl-vpcmpud-1.c: Likewise.
* gcc.target/i386/avx512vl-vpcmpuq-1.c: Likewise.
* gcc.target/i386/pr122343-1a.c: New test.
* gcc.target/i386/pr122343-1b.c: Likewise.
* gcc.target/i386/pr122343-2a.c: Likewise.
* gcc.target/i386/pr122343-2b.c: Likewise.
* gcc.target/i386/pr122343-3.c: Likewise.
* gcc.target/i386/pr122343-4a.c: Likewise.
* gcc.target/i386/pr122343-4b.c: Likewise.
* gcc.target/i386/pr122343-5a.c: Likewise.
* gcc.target/i386/pr122343-5b.c: Likewise.
* gcc.target/i386/pr122343-6a.c: Likewise.
* gcc.target/i386/pr122343-6b.c: Likewise.
* gcc.target/i386/pr122343-7.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
10 days agocselib: dump_cselib_* fixes
Alexandre Oliva [Sun, 7 Dec 2025 01:08:04 +0000 (22:08 -0300)] 
cselib: dump_cselib_* fixes

Rework dump_cselib_table to not crash when cselib_preserved_hash_table
is not allocated, and to remove the extraneous indirection from
dump_cselib_val that made it inconvenient to call from a debugger.

for  gcc/ChangeLog

* cselib.cc (dump_cselib_val): Split out of and rename to...
(dump_cselib_val_ptr): ... this.
(dump_cselib_table): Adjust.  Skip cselib_preserved_hash_table
when not allocated.

10 days agoDaily bump.
GCC Administrator [Sun, 7 Dec 2025 00:16:26 +0000 (00:16 +0000)] 
Daily bump.

10 days agoadd fusage for non-ACCUMULATE_OUTGOING_ARGS calls [PR122947]
Alexandre Oliva [Sat, 6 Dec 2025 23:11:46 +0000 (20:11 -0300)] 
add fusage for non-ACCUMULATE_OUTGOING_ARGS calls [PR122947]

Since we may delete stores that are found to be redundant in
postreload cse, we need cselib to invalidate argument stores at calls,
and to that end we need CALL_INSN_FUNCTION_USAGE to mention all MEM
stack space that may be legitimately modified by a const/pure callee,
i.e., all arguments passed to it on the stack.

When ACCUMULATE_OUTGOING_ARGS, each on-stack argument gets its own
usage information, but when it's not, each argument is pushed
incrementally, without precomputed stack slots.

Since we only mentioned such precomputed stack slots in
CALL_INSN_FUNCTION_USAGE, non-ACCUMULATE_OUTGOING_ARGS configurations
miss the stack usage data, and cselib fails to invalidate the stores.

Stores in such slots are anonymous, and they often invalidate other
anonymous slots, even part of the same object, but as the testcase
demonstrates, we may occasionally be unlucky that consecutive calls
have the stores to multi-word objects reordered by scheduling in such
a way that the last store for the first call survives the call in the
cselib tables, and then it is found to be redundant with the first
store for the subsequent call, as in the testcase.

So, if we haven't preallocated outgoing arguments for a call (which
would give us preassigned stack slots), and we have used any stack
space, add function call usage covering the entire stack range where
arguments were stored.

for  gcc/ChangeLog

PR rtl-optimization/122947
* calls.cc (expand_call): Add stack function usage in
non-ACCUMULATE_OUTGOING_ARGS configurations.

for  gcc/testsuite/ChangeLog

PR rtl-optimization/122947
* gcc.dg/pr122947.c: New.

10 days ago[riscv] avoid auipc overflow with large offsets [PR91420]
Alexandre Oliva [Sat, 6 Dec 2025 23:11:42 +0000 (20:11 -0300)] 
[riscv] avoid auipc overflow with large offsets [PR91420]

When computing an address plus a large offset on riscv64 with a
PC-relative sequence, we may hit the range limit for auipc and get a
relocation overflow, where on riscv32 the computation wraps around.

Since -mcmodel=medany requires the entire program to fit in a 2GiB
address range, a +/-1GiB+ offset added to an in-range symbol in a
barely-fitting program is more likely than not to be out-of-range.
Since such large constants are unlikely to come up by chance, separate
them from the symbol so as to avoid the relocation overflow.

for  gcc/ChangeLog

PR target/91420
* config/riscv/riscv.cc (riscv_symbolic_constant_p): Require
offsets smaller than +/- 1GiB for PCREL symbols.

for  gcc/testsuite/ChangeLog

PR target/91420
* gcc.target/riscv/pr91420.c: New.

10 days agoAda: Fix spurious warning if the reducer subprogram is a procedure
Denis Mazzucato [Sat, 6 Dec 2025 18:13:26 +0000 (19:13 +0100)] 
Ada: Fix spurious warning if the reducer subprogram is a procedure

If the reducer is a function and the accumulator type isn't constrained,
at runtime the reduction will likely raise a Constraint_Error since the
reducer is repeatedly assigned to the accumulator variable (likely changing
its length). However, if the reducer is a procedure, no such assignment
occurs, and thus the runtime error only depends on the reducer logic.
This patch prevents the spurious warning in that case.

gcc/ada/
* sem_attr.adb (Resolve_Attribute): Check if the reducer is a
procedure before giving the warning.

10 days agoAdjust expected output of new risc-v test
Jeff Law [Sat, 6 Dec 2025 16:01:11 +0000 (09:01 -0700)] 
Adjust expected output of new risc-v test

Just a minor update to Dimitar's patch for the RISC-V testcase.

The cfi directives are not emitted for the -elf configurations causing the new
test to fail.  The cfi directives (and associated labels) don't seem relevant
to the test at hand, so this just drops them.

Pushing to the trunk.

PR rtl-optimization/122675

gcc/testsuite
* gcc.target/riscv/pr122675-1.c: Adjust expected output.

10 days agoFortran: [PDT] Verify problems with error recovery have gone [PR103414]
Paul Thomas [Sat, 6 Dec 2025 12:58:30 +0000 (12:58 +0000)] 
Fortran: [PDT] Verify problems with error recovery have gone [PR103414]

2025-12-06  Paul Thomas  <pault@gcc.gnu.org>

gcc/testsuite
PR fortran/103414
* gfortran.dg/pdt_76.f03: New test.

10 days agolibstdc++: add more #if to std.cc
Jason Merrill [Sat, 6 Dec 2025 10:31:44 +0000 (18:31 +0800)] 
libstdc++: add more #if to std.cc

compile-std1.C was breaking on arm-eabi because these interfaces aren't
declared.  So for exporting let's check the same macros that control
declaring them.

libstdc++-v3/ChangeLog:

* src/c++23/std.cc.in: Add more #if.

10 days agoattribs: Use attribute_value_equal in decl_attributes
Jakub Jelinek [Sat, 6 Dec 2025 10:08:05 +0000 (11:08 +0100)] 
attribs: Use attribute_value_equal in decl_attributes

This is another thing discussed in the 1/9 Reflection thread,
also not dependent on reflection.

decl_attributes calls simple_cst_equal on TREE_VALUEs of the
current and preexisting attributes, but that is just a small
part of how attribute values should be compared.

The following patch fixes that.

2025-12-06  Jakub Jelinek  <jakub@redhat.com>

* attribs.cc (decl_attributes): Use attribute_value_equal to
compare attribute values instead of simple_cst_equal.

10 days agoc++: is_late_template_attribute and tsubst_attribute fixes
Jakub Jelinek [Sat, 6 Dec 2025 10:07:18 +0000 (11:07 +0100)] 
c++: is_late_template_attribute and tsubst_attribute fixes

This has been discussed in the 1/9 Reflection thread, but doesn't depend on
reglection in any way.
cp_parser_std_attribute calls lookup_attribute_spec as:
    const attribute_spec *as
      = lookup_attribute_spec (TREE_PURPOSE (attribute));
so with TREE_LIST where TREE_VALUE is attribute name and TREE_PURPOSE
attribute ns.  Similarly c_parser_std_attribute.  And for
attribute_takes_identifier_p those do:
    else if (attr_ns == gnu_identifier
             && attribute_takes_identifier_p (attr_id))
and
        bool takes_identifier
          = (ns != NULL_TREE
             && strcmp (IDENTIFIER_POINTER (ns), "gnu") == 0
             && attribute_takes_identifier_p (name));
when handling std attributes (for GNU attributes they just call those
with the IDENTIFIER_NODE name.
is_late_template_attribute and tsubst_attribute pass to these functions
just get_attribute_name though, so handle attributes in all namespaces
as GNU attributes only, which means that lookup_attribute_spec can
return NULL or find a different attribute if it is not from gnu:: or
say standard attribute mapped to gnu::, or attribute_takes_identifier_p
can return true even for attributes for which it shouldn't.

I thought about changing attribute_takes_identifier_p to take optionally
TREE_LIST, but that would mean handling it in the target hooks too and
they only care about GNU attributes right now, so given the above
parser.cc/c-parser.cc snippets, the following patch just follow
what they do.

2025-12-06  Jakub Jelinek  <jakub@redhat.com>

* decl2.cc (is_late_template_attribute): Call lookup_attribute_spec
on TREE_PURPOSE (attr) rather than name.  Only call
attribute_takes_identifier_p if get_attribute_namespace (attr) is
gnu_identifier.
* pt.cc (tsubst_attribute): Only call attribute_takes_identifier_p
if get_attribute_namespace (t) is gnu_identifier.

10 days agoFortran: [PDT] Failure with local allocatable PDT array [PR122693]
Paul Thomas [Sat, 6 Dec 2025 08:05:41 +0000 (08:05 +0000)] 
Fortran:  [PDT] Failure with local allocatable PDT array [PR122693]

2025-12-06  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/122693
* array.cc (gfc_match_array_constructor): Stash and restore
gfc_current_ns after the call to 'gfc_match_type_spec'.

gcc/testsuite
PR fortran/122693
* gfortran.dg/pdt_75.f03: New test.

10 days agoFortran: [PDT] Mismatched types with same name in assignment [PR122670]
Paul Thomas [Sat, 6 Dec 2025 08:00:21 +0000 (08:00 +0000)] 
Fortran: [PDT] Mismatched types with same name in assignment [PR122670]

2025-12-06  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/122670
* decl.cc (gfc_get_pdt_instance): Ensure that, in an interface
body, PDT instances imported implicitly if the template has
been explicitly imported.
* module.cc (read_module): If a PDT template appears in a use
only statement, implicitly add the instances as well.

gcc/testsuite
PR fortran/122670
* gfortran.dg/pdt_74.f03: New test.

10 days agoFortran: ALLOCATE with array-valued MOLD expression fails [PR122669]
Paul Thomas [Sat, 6 Dec 2025 07:54:39 +0000 (07:54 +0000)] 
Fortran: ALLOCATE with array-valued MOLD expression fails [PR122669]

2025-12-06  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/122669
* resolve.cc (resolve_allocate_deallocate): Mold expressions
with an array reference and a constant size must be resolved
for each allocate object.

gcc/testsuite
PR fortran/122669
* gfortran.dg/pdt_73.f03: New test.

10 days agoFortran: [PDT] Unresolved component and generic binding [PR122578]
Paul Thomas [Sat, 6 Dec 2025 07:51:21 +0000 (07:51 +0000)] 
Fortran: [PDT] Unresolved component and generic binding [PR122578]

2025-12-06  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/122578
* primary.cc (gfc_match_varspec): Try to resolve a typebound
generic procedure selector expression to provide the associate
name with a type. Also, resolve component calls. In both cases,
make a copy of the selector expression to guard against changes
made by gfc_resolve_expr.

gcc/testsuite
PR fortran/122578
* gfortran.dg/pdt_72.f03: New test.

11 days ago[PATCH] prepare-commit-msg: Add compatibility check for --default-prefix option
Mark Zhuang [Sat, 6 Dec 2025 05:16:25 +0000 (22:16 -0700)] 
[PATCH] prepare-commit-msg: Add compatibility check for --default-prefix option

From: Mark Zhuang <mark.zhuang@spacemit.com>

The previous commit added --default-prefix to handle non-default git
prefix configurations, but this option is not available in older git
versions. This patch adds a compatibility check.

contrib/ChangeLog:

* prepare-commit-msg: check --default-prefix

11 days ago[PATCH v3] rtl-optimization: Fix BB edge ordering [PR122675]
Dimitar Dimitrov [Sat, 6 Dec 2025 04:57:58 +0000 (21:57 -0700)] 
[PATCH v3] rtl-optimization: Fix BB edge ordering [PR122675]

Starting with r16-4438-ga93f80feeef744, the edge sorting order was
switched to lowest execution frequency first.  But the "bbro"
optimization pass chooses the first edge as a fallthrough.  Thus the
most unlikely branches were optimized to fallthroughs.

Fix by restoring the sorting order prior to r16-4438-ga93f80feeef744.
Now the branches most likely to be executed are picked as fallthroughs.

There are no regressions for C and C++ on x86_64-pc-linux-gnu.

The new tests fail for the respective targets without this patch, and
pass with it.

PR rtl-optimization/122675

gcc/ChangeLog:

* bb-reorder.cc (edge_order): Fix BB edge ordering to be
descending.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/pr122675-1.c: New test.
* gcc.target/i386/pr122675-1.c: New test.
* gcc.target/riscv/pr122675-1.c: New test.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
11 days agolibstdc++: Use deducing this in std::bind when available [PR80564]
Patrick Palka [Sat, 6 Dec 2025 02:09:34 +0000 (21:09 -0500)] 
libstdc++: Use deducing this in std::bind when available [PR80564]

Implement the forwarding performed by std::bind via deducing this when
available, instead of needing 4 operator() overloads.  Using deducing
this here is more complicated than in other standard call wrappers
because std::bind is not really "perfect forwarding": it doesn't
consider value category, and along with const-ness it also forwards
volatile-ness (until C++20).

The old implementation suffers from the same problem that other
pre-C++23 SFINAE-friendly call wrappers have which is solved by using
deducing this (see p5.5 of the deducing this paper P0847R7).

PR libstdc++/80564

libstdc++-v3/ChangeLog:

* include/std/functional (__cv_like): New.
(_Bind::_Res_type): Don't define when not needed.
(_Bind::__dependent): Likewise.
(_Bind::_Res_type_cv): Likewise.
(_Bind::operator()) [_GLIBCXX_EXPLICIT_THIS_PARAMETER]:
Define as two instead of four overloads using deducing
this.
* testsuite/20_util/bind/cv_quals_2.cc: Ignore SFINAE
diagnostics inside headers.
* testsuite/20_util/bind/ref_neg.cc: Likewise.
* testsuite/20_util/bind/80564.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
11 days agoa68: handle intTI_type_node in a68_type_for_size
Jose E. Marchesi [Sat, 6 Dec 2025 01:47:37 +0000 (02:47 +0100)] 
a68: handle intTI_type_node in a68_type_for_size

gcc/algol68/ChangeLog

PR algol68/123007
* a68-lang.cc (a68_type_for_size): Handle intTI_type_node.

11 days agolibstdc++: std::atomic should use std::addressof
Jonathan Wakely [Thu, 4 Dec 2025 21:07:19 +0000 (21:07 +0000)] 
libstdc++: std::atomic should use std::addressof

libstdc++-v3/ChangeLog:

* include/bits/atomic_wait.h (__detail::__atomic_eq): Use
std::addressof instead of &.
* include/std/atomic (atomic::wait, atomic::notify_one)
(atomic::notify_all): Likewise.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
11 days agoDaily bump.
GCC Administrator [Sat, 6 Dec 2025 00:16:32 +0000 (00:16 +0000)] 
Daily bump.

11 days agotestsuite: Small tweaks for pr99782-1.c test [PR99782]
Jakub Jelinek [Sat, 6 Dec 2025 00:08:56 +0000 (01:08 +0100)] 
testsuite: Small tweaks for pr99782-1.c test [PR99782]

2025-12-06  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/99782
* gcc.dg/torture/pr99782-1.c: Fix typo, dg-compile -> dg-do compile.
Use int128 effective target directly on that directive.  Move PR
comment first.

11 days agotestsuite: Fix pr99782-1.c for targets that don't support int128
Andrew Pinski [Fri, 5 Dec 2025 21:30:49 +0000 (13:30 -0800)] 
testsuite: Fix pr99782-1.c for targets that don't support int128

When I wrote this testcase I forgot to check if the target
supports __int128. This adds the simple check.

Pushed as obvious after testing the testcase.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr99782-1.c: Require intt128 target.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
11 days ago[PR122215, IRA]: Fix undefined behaviour of improve_allocation
Vladimir N. Makarov [Fri, 5 Dec 2025 19:21:38 +0000 (14:21 -0500)] 
[PR122215, IRA]: Fix undefined behaviour of improve_allocation

Register filters are used in one loop of improve_allocation to ignore some
hard regs for cost calculation but it is missed in the subsequent loop
using the costs.  This results in usage of random (undefined) register costs
and in sporadic code generation for riscv32 which uses the filters.

gcc/ChangeLog:

PR rtl-optimization/122215
* ira-color.cc (improve_allocation): Use register filter for all
loop on hard regs.

gcc/testsuite/ChangeLog:

PR rtl-optimization/122215
* gcc.target/riscv/pr122215.c: New.
* lib/target-supports.exp (check_effective_target_valgrind): New.

11 days agoFortran: associate to a contiguous pointer or target [PR122977]
Harald Anlauf [Thu, 4 Dec 2025 21:16:10 +0000 (22:16 +0100)] 
Fortran: associate to a contiguous pointer or target [PR122977]

PR fortran/122977

gcc/fortran/ChangeLog:

* expr.cc (gfc_is_simply_contiguous): For an associate variable
check whether the associate target is contiguous.
* resolve.cc (resolve_symbol): Skip array type check for an
associate variable when the target has the contiguous attribute.

gcc/testsuite/ChangeLog:

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

11 days agolibstdc++: Implement rest of P2655R3 common_reference of reference_wrapper
Patrick Palka [Fri, 5 Dec 2025 18:43:40 +0000 (13:43 -0500)] 
libstdc++: Implement rest of P2655R3 common_reference of reference_wrapper

PR libstdc++/120446

libstdc++-v3/ChangeLog:

* include/bits/refwrap.h (__detail::__is_ref_wrapper):
Define as per P2655R3 for C++20.
(__detail::__ref_wrap_common_reference_exists_with): Likewise.
(basic_common_reference): Define partial specializations using
the above as per P2655R3 for C++20.
* include/bits/version.def (common_reference_wrapper): New.
* include/bits/version.h: Regenerate.
* include/std/functional (__glibcxx_want_common_reference_wrapper):
Define.
* testsuite/20_util/reference_wrapper/p2655r3.cc: New test.

Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
11 days agolibstdc++: Implement P2655R3 changes to common_reference bullet 1
Patrick Palka [Fri, 5 Dec 2025 18:43:29 +0000 (13:43 -0500)] 
libstdc++: Implement P2655R3 changes to common_reference bullet 1

We implement this paper as a DR against C++20 (as do MSVC and libc++).

PR libstdc++/120446

libstdc++-v3/ChangeLog:

* include/bits/version.def (common_reference): New.
* include/bits/version.h: Regenerate.
* include/std/type_traits (__glibcxx_want_common_reference):
Define.
(__common_reference_impl<T1, T2, 1>): Add pointer convertibility
constraints as per P2655R3.
* testsuite/20_util/common_reference/p2655r3.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
11 days agolibstdc++: Consolidate bullet 1 __common_reference_impl partial specs
Patrick Palka [Fri, 5 Dec 2025 18:43:26 +0000 (13:43 -0500)] 
libstdc++: Consolidate bullet 1 __common_reference_impl partial specs

... and in passing use requires-clauses instead of void_t based SFINAE.
This is a non-functional change that'll simplify implementing the
P2655R3 change to common_reference.

PR c++/120446

libstdc++-v3/ChangeLog:

* include/std/type_traits (__common_reference_impl): Rewrite
partial specializations to use requires-clause instead of
an additional void_t template parameter.  Consolidate the
partial specializations corresponding to bullet 1.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
11 days agolibstdc++/testsuite: Fix malformed dg-error directive
Patrick Palka [Fri, 5 Dec 2025 17:48:44 +0000 (12:48 -0500)] 
libstdc++/testsuite: Fix malformed dg-error directive

libstdc++-v3/ChangeLog:

* testsuite/20_util/function_objects/bind_front/111327.cc:
Add missing space before } ending a dg-error directive.

11 days agolibstdc++: Use deducing this in range adaptors even in C++20 [PR111550]
Patrick Palka [Fri, 5 Dec 2025 17:16:30 +0000 (12:16 -0500)] 
libstdc++: Use deducing this in range adaptors even in C++20 [PR111550]

Use deducing this to implement perfect forwarding even in C++20 mode
by using the _GLIBCXX_EXPLICIT_THIS_PARAMETER internal FTM instead of
the standard __cpp_explicit_this_parameter.  This fixes the original
testcase from this PR even in C++20 mode.

PR libstdc++/111550

libstdc++-v3/ChangeLog:

* include/std/ranges (views::__adaptor::_Partial::operator())
[_GLIBCXX_EXPLICIT_THIS_PARAMETER]: Also use deducing this
in C++20 mode when possible.
(views::__adaptor::_Pipe::Operator())
[_GLIBCXX_EXPLICIT_THIS_PARAMETER]: Likewise.
* testsuite/std/ranges/adaptors/take.cc (test07): New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
11 days agolibstdc++: Use deducing this in std::bind_front even in C++20 [PR111327]
Patrick Palka [Fri, 5 Dec 2025 17:15:08 +0000 (12:15 -0500)] 
libstdc++: Use deducing this in std::bind_front even in C++20 [PR111327]

PR libstdc++/111327

libstdc++-v3/ChangeLog:

* include/bits/binders.h (_Binder::operator())
[_GLIBCXX_EXPLICIT_THIS_PARAMETER]: Also use deducing this in
C++20 mode when possible.
* testsuite/20_util/function_objects/bind_front/111327.cc:
Expect error inside header even in C++20 mode.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
11 days agolibstdc++: Use deducing this in std::not_fn when available [PR111327]
Patrick Palka [Fri, 5 Dec 2025 17:14:23 +0000 (12:14 -0500)] 
libstdc++: Use deducing this in std::not_fn when available [PR111327]

Implement the perfect forwarding required by std::not_fn using deducing
this when available, instead of needing 8 operator() overloads.  This
also fixes Jiang An's test from this PR which would be messy to fix in
the old implementation.

PR libstdc++/111327

libstdc++-v3/ChangeLog:

* include/std/functional (_Not_fn::operator())
[_GLIBCXX_EXPLICIT_THIS_PARAMETER]: Define as a single
overload using deducing this.
* testsuite/20_util/function_objects/not_fn/111327.cc: Extend test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
11 days agolibstdc++: Introduce _GLIBCXX_EXPLICIT_THIS_PARAMETER internal FTM
Patrick Palka [Fri, 5 Dec 2025 17:14:18 +0000 (12:14 -0500)] 
libstdc++: Introduce _GLIBCXX_EXPLICIT_THIS_PARAMETER internal FTM

This FTM is like __cpp_explicit_this_parameter but is also defined
in earlier C++ modes if deducing this is supported as an extension
by the compiler.  Currently only GCC supports this, Clang doesn't.

libstdc++-v3/ChangeLog:

* include/bits/c++config (_GLIBCXX_EXPLICIT_THIS_PARAMETER):
New.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
11 days agoarm: avoid invalid shift in arm_canonicalize_comparison [PR122999]
Richard Earnshaw [Fri, 5 Dec 2025 14:34:38 +0000 (14:34 +0000)] 
arm: avoid invalid shift in arm_canonicalize_comparison [PR122999]

There was UB in arm_canonicalize_comparison if it is called with
both operands of type VOIDmode.  Avoid this by first handling
floating-point types, then returning if we are left with anything
other than an integer mode.  For belt-and-braces also check that
the mode does not require a mask larger than HOST_WIDE_INT.

gcc/ChangeLog:

PR target/122999
* config/arm/arm.cc (arm_canonicalize_comparison): Defer
initializing maxval until we know we are dealing with an
integer mode.

11 days agogomp/dyn_groupprivate-1.f90: Fix scan-tree-dump-times regex
Tobias Burnus [Fri, 5 Dec 2025 13:55:27 +0000 (14:55 +0100)] 
gomp/dyn_groupprivate-1.f90: Fix scan-tree-dump-times regex

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/dyn_groupprivate-1.f90: Fix
scan-tree-dump-times regexp to avoid hard-coded 'D.4680'.

11 days agoFix vect_need_peeling_or_partial_vectors_p wrt peeling for gaps
Richard Biener [Fri, 5 Dec 2025 11:25:09 +0000 (12:25 +0100)] 
Fix vect_need_peeling_or_partial_vectors_p wrt peeling for gaps

The code assuming that peeling for gaps can be elided by means of
knowing niters and prologue peeling is wrong.  Peeling for gaps
means we need an epilog.

* tree-vect-loop.cc (vect_need_peeling_or_partial_vectors_p):
When peeling for gaps we always need an epilog.

11 days agotree-optimization/120939 - remove uninitialized use of LOOP_VINFO_COST_MODEL_THRESHOLD
Richard Biener [Thu, 10 Jul 2025 13:19:30 +0000 (15:19 +0200)] 
tree-optimization/120939 - remove uninitialized use of LOOP_VINFO_COST_MODEL_THRESHOLD

The following removes an optimization that wrongly triggers right now
because it accesses LOOP_VINFO_COST_MODEL_THRESHOLD which might not be
computed yet and uses guessed likely max stmt executions.

It also refactors the code to make the default conservative.

PR tree-optimization/120939
* tree-vect-loop.cc (vect_need_peeling_or_partial_vectors_p):
Remove eliding an epilogue based on not computed
LOOP_VINFO_COST_MODEL_THRESHOLD and estimated max stmt executions.

* gcc.dg/torture/pr113026-1.c: Skip when -ftracer.

11 days agoMake gcc.dg/vect/vect-pr123002.c trigger on unfixed trunk
Richard Biener [Fri, 5 Dec 2025 12:25:02 +0000 (13:25 +0100)] 
Make gcc.dg/vect/vect-pr123002.c trigger on unfixed trunk

The following avoids VRP to access the constant initializer.

PR tree-optimization/123002
* gcc.dg/vect/vect-pr123002.c: Make global data non-const
and non-static.

11 days agoada: Unsigned_Base_Range aspect (part 6)
Javier Miranda [Tue, 18 Nov 2025 19:53:58 +0000 (19:53 +0000)] 
ada: Unsigned_Base_Range aspect (part 6)

Revert patch for Is_Modular_Integer_Type and Is_Signed_Integer_Type;
add new synthesized predicates Has_Modular_Operations and
Has_Overflow_Operations, and adjust the frontend sources
to rely on them.

gcc/ada/ChangeLog:

* einfo.ads (Has_Unsigned_Base_Range_Aspect): Update documentation.
(Has_Modular_Operations): New synthesized predicate.
(Has_Overflow_Operations): New synthesized predicate.
* einfo-utils.ads (Has_Modular_Operations): New function.
(Has_Overflow_Operations): New function.
* einfo-utils.adb (Is_Modular_Integer_Type): Undo previous patch.
(Is_Signed_Integer_Type): Undo previous patch.
(Has_Modular_Operations): New function.
(Has_Overflow_Operations): New function.
* checks.adb (Determine_Range): Replace selected occurrences of calls to
Is_Modular_Integer_Type by calls to Has_Modular_Operations, and calls to
Is_Signed_Integer_Type by calls to Has Overflow_Operations.
(Enable_Range_Check): Ditto.
(Insert_Valid_Check): Ditto.
* exp_aggr.adb (Others_Check): Ditto.
* exp_attr.adb (Expand_N_Attribute_Reference [Attribute_Pred,
Attribute_Succ]): Ditto.
* exp_ch4.adb (Expand_Compare_Minimize_Eliminate_Overflow): Ditto.
(Size_In_Storage_Elements): Ditto.
(Expand_N_Op_Abs): Ditto.
(Expand_N_Op_Expon): Ditto.
(Expand_N_Op_Minus): Ditto.
(Expand_N_Op_Multiply): Ditto.
(Expand_N_Op_Subtract): Ditto.
* freeze.adb (Freeze_Entity): Ditto.
* sem_aggr.adb (Report_Null_Array_Constraint_Error): Ditto plus
report specific error for index with unsigned_base_range aspect.
* sem_attr.adb (Check_Modular_Integer_Type): Ditto.
(Analyze_Attribute [Attribute_Pred, Attribute_Succ, Attribute_
Range_Length, Attribute_Small, Attribute_Reduce]): Ditto.
* sem_ch12.adb (Instantiate_Type): Ditto.
(Validate_Formal_Type_Default): Ditto.
* sem_ch13.adb (Valid_Empty): Ditto.
* sem_ch2.adb (Analyze_Integer_Literal): Ditto.
* sem_ch3.adb (Unsigned_Base_Range_Type_Declaration): Set attribute
Has_Unsigned_Base_Range_Aspect on the implicit base, and set Etype
of its first subtype E_Modular_Integer_Subtype.
* sem_ch4.adb (Analyze_Call): Ditto.
* sem_eval.adb (Check_Non_Static_Context_For_Overflow): Ditto.
(Eval_Arithmetic_Op): Ditto.
(Eval_Integer_Literal): Ditto.
(Eval_Logical_Op): Ditto.
(Eval_Op_Expon): Ditto.
(Eval_Op_Not): Ditto.
(Eval_Unary_Op): Ditto.
(Fold_Shift): Ditto.
(Test_Expression_Is_Foldable): Ditto.
* sem_intr.adb (Check_Shift): Ditto.
* sem_prag.adb (Analyze_Pragma [Pragma_Unsigned_Base_Range]): Add
assertion.
* sem_res.adb (Resolve_Logical_Op): Ditto.
(Resolve_Unary_Op): Ditto.
(Set_String_Literal_Subtype): Ditto.
* sem_type.adb (Covers): Ditto.
(Specific_Type): Ditto.
(Valid_Boolean_Arg): Ditto.
* sem_util.adb (Wrong_Type): Ditto
* style.adb (Check_Boolean_Operator): Ditto.

11 days agoada: Improve readability of table in reference manual
Ronan Desplanques [Fri, 21 Nov 2025 14:29:26 +0000 (15:29 +0100)] 
ada: Improve readability of table in reference manual

This patch changes a table in the reference manual so that the Ada code
inside is properly highlighted and uses the usual casing conventions.

gcc/ada/ChangeLog:

* doc/gnat_rm/representation_clauses_and_pragmas.rst: Improve table.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

11 days agoada: Fix false positive error for classwide containers
Viljar Indus [Tue, 18 Nov 2025 12:39:03 +0000 (14:39 +0200)] 
ada: Fix false positive error for classwide containers

Get_Cursor_Type fails if a classwide container type
is passed to it as it cannot correctly identify the
cursor type since it is expecting the iteration functions
to have a container argument with a classwide container type.

gcc/ada/ChangeLog:

* sem_util.adb (Get_Cursor_Type): use the
specific type for classwide container checks.

11 days agoada: Fix problematic aggregate with box notation
Eric Botcazou [Thu, 20 Nov 2025 20:54:03 +0000 (21:54 +0100)] 
ada: Fix problematic aggregate with box notation

It runs afoul of the pragma Initialize_Scalars + -gnatVa combination.

gcc/ada/ChangeLog:

* sem_ch12.adb (Remove_Parent): Only set the Is_Transient component
of the local scope stack entry.

11 days agoada: Adjust documentation on floating-point overflow handling
Marc Poulhiès [Thu, 20 Nov 2025 14:59:49 +0000 (15:59 +0100)] 
ada: Adjust documentation on floating-point overflow handling

The description of the floating-point overflow behavior is already
documented in other sections: remove the duplication.
This removal also removes confusing/wrong informations

gcc/ada/ChangeLog:

* doc/gnat_ugn/building_executable_programs_with_gnat.rst
(-gnato??): Remove redundant/confusing doc on floating-point
overflow.
* gnat_ugn.texi: Regenerate.

11 days agoada: Ensure that file is not locked on windows when opened RO
Tonu Naks [Wed, 19 Nov 2025 12:56:55 +0000 (12:56 +0000)] 
ada: Ensure that file is not locked on windows when opened RO

gcc/ada/ChangeLog:

* adaint.c: use the _tsopen macro when opening RO file

11 days agoada: Fix reducer selection when resolving 'Reduce attribute
Denis Mazzucato [Wed, 24 Sep 2025 15:25:39 +0000 (17:25 +0200)] 
ada: Fix reducer selection when resolving 'Reduce attribute

This patch ensures that, during the 'Reduce attribute resolution phase, the
selected reducer subprogram exists, is not ambiguous, and has the proper reducer
profile. Before we could have selected a wrong interpretation.

gcc/ada/ChangeLog:

* sem_attr.adb
(Analyze_Attribute): Set the type of the attribute expression only when
not ambiguous (it will later be resolved correctly). Emit an error in
case the type is limited.
(Resolve_Attribute): Emit an error if the reducer has no entity.
(Get_Value_Subtype): Try to resolve the Value_Subtype of the aggregate
expression, and if it succeeds, set the candidate reducer subprogram.
(Is_Reducer_Subprogram): Check whether the selected candidate has a
proper reducer profile.
(Make_Array_Type): Return simple array type to resolve the array
aggregate against it.
(Resolve_Attribute): Reimplement the resolution of Reduce attribute,
including its prefix.
* sem_res.adb (Resolve_Declare_Expression): Save and restore variables
that may be hidden by the local declaration. Only setting the new
entities is problematic when dealing with copied trees where the ref is
lost (eg. when resolving array aggregates).
* exp_attr.adb (Expand_N_Attribute_Reference): Remove tricks to resolve
the reducer in case of faulty resolution as not needed anymore.

gcc/testsuite/ChangeLog:

* gnat.dg/reduce1.adb: Adjust expected error message.

11 days agoMove even/odd validity check from supportable_widening_operation to caller
Richard Biener [Thu, 21 Aug 2025 11:46:06 +0000 (13:46 +0200)] 
Move even/odd validity check from supportable_widening_operation to caller

The following moves the incomplete validity check to use
WIDEN_MULT_{EVEN,ODD} to the caller of supportable_widening_operation
where we have access to more (but not enough) information.  I have
made the test conservative enough I hope.  For the testcase what was
broken is that it uses a SLP reduction where lane-swizzling isn't
valid.

PR tree-optimization/123002
* tree-vectorizer.h (supportable_widening_operation): Remove
vinfo and stmt_info parameters, add flag to indicate whether
the context would allow OP_{EVEN,ODD}.
* tree-vect-patterns.cc (vect_recog_abd_pattern): Adjust
and pass false.
(vect_recog_widen_op_pattern): Likewise.
(vect_recog_widen_abd_pattern): Likewise.
* tree-vect-stmts.cc (vectorizable_conversion): Move
even/odd validity check here, from supportable_widening_operation.
Adjust it to be conservative.
(supportable_widening_operation): Get flag whether even/odd
is OK to use and remove then unused parameters and code.

* gcc.dg/vect/vect-pr123002.c: New testcase.

11 days agoAdd clique/base parsing and dumping to the GIMPLE FE
Richard Biener [Fri, 5 Dec 2025 09:29:07 +0000 (10:29 +0100)] 
Add clique/base parsing and dumping to the GIMPLE FE

The following adds clique/base on __MEM to the GIMPLE parser and
to -gimple dumping.

gcc/c/
* gimple-parser.cc (c_parser_gimple_postfix_expression):
Parse optional clique : base specifier on __MEM.

gcc/
* tree-pretty-print.cc (dump_mem_ref): Dump clique : base
specifier for MEM_REF and TARGET_MEM_REF when dumping
GIMPLE format.

gcc/testsuite/
* gcc.dg/gimplefe-58.c: New testcase.

11 days agoAda, Darwin: Implement OSLock for Darwin [PR115305].
Iain Sandoe [Wed, 3 Dec 2025 07:44:53 +0000 (07:44 +0000)] 
Ada, Darwin: Implement OSLock for Darwin [PR115305].

The generic Posix code does not match the layout of the pthread entities
in the Darwin _pthread_types.h.  So, let's make a Darwin-specific version
and use it.

PR ada/115305

gcc/ada/ChangeLog:

* Makefile.rtl: Use s-oslock__darwin instead of the Posix version.
* libgnat/s-oslock__darwin.ads: New file.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
11 days agoOpenMP: C/C++ parser support for dyn_groupprivate
Tobias Burnus [Fri, 5 Dec 2025 08:08:06 +0000 (09:08 +0100)] 
OpenMP: C/C++ parser support for dyn_groupprivate

Follow-up to the Fortran patch r16-5633-g26d41e245dbba3, which (besides
other changes) added parser support for the 'dyn_groupprivate' clause to
the target directive.
This commit adds now the parser support to C/C++ and moves the
not-yet-implemented 'sorry' to the early middle end.

gcc/c-family/ChangeLog:

* c-omp.cc (c_omp_split_clauses): Handle
OMP_CLAUSE_DYN_GROUPPRIVATE, sort target clauses
alphabetically.
* c-pragma.h (enum pragma_omp_clause): Add
PRAGMA_OMP_CLAUSE_DYN_GROUPPRIVATE.

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_clause_dyn_groupprivate): New.
(OMP_TARGET_CLAUSE_MASK): Add PRAGMA_OMP_CLAUSE_DYN_GROUPPRIVATE;
sort clauses alphabetically.
(c_parser_omp_clause_name, c_parser_omp_all_clauses):
Handle 'dyn_groupprivate' clause.
* c-typeck.cc (c_finish_omp_clauses): Likewise.

gcc/cp/ChangeLog:

* pt.cc (tsubst_omp_clauses): Handle OMP_CLAUSE_DYN_GROUPPRIVATE.
* semantics.cc (finish_omp_clauses): Likewise.
* parser.cc (cp_parser_omp_clause_dyn_groupprivate): New.
(cp_parser_omp_clause_name, cp_parser_omp_all_clauses):
Handle 'dyn_groupprivate' clause.
(OMP_TARGET_CLAUSE_MASK): Add PRAGMA_OMP_CLAUSE_DYN_GROUPPRIVATE;
sort clauses alphabetically.

gcc/fortran/ChangeLog:

* openmp.cc (resolve_omp_clauses): Permit zero with
DYN_GROUPPRIVATE clause.
* trans-openmp.cc (fallback): Generate TREE code
for DYN_GROUPPRIVATE and remove 'sorry'.

gcc/ChangeLog:

* gimplify.cc (gimplify_scan_omp_clauses): Handle
OMP_CLAUSE_DYN_GROUPPRIVATE by printing 'sorry, unimplemented'.
* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_DYN_GROUPPRIVATE.
(enum omp_clause_fallback_kind): New.
(struct tree_omp_clause): Add fallback_kind union member.
* tree-nested.cc (convert_nonlocal_omp_clauses,
convert_local_omp_clauses): Handle OMP_CLAUSE_DYN_GROUPPRIVATE.
* tree.cc (omp_clause_num_ops, omp_clause_code_name): Add
OMP_CLAUSE_DYN_GROUPPRIVATE.
* tree-pretty-print.cc (dump_omp_clause): Handle
OMP_CLAUSE_DYN_GROUPPRIVATE.
* tree.h (OMP_CLAUSE_DYN_GROUPPRIVATE_EXPR,
OMP_CLAUSE_DYN_GROUPPRIVATE_KIND): New #define.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/dyn_groupprivate-1.f90: Add scan-dump test.
* gfortran.dg/gomp/dyn_groupprivate-2.f90: Extend and update.
* c-c++-common/gomp/dyn_groupprivate-1.c: New test.
* c-c++-common/gomp/dyn_groupprivate-2.c: New test.

11 days agoMake gcc.dg/vect/vect-simd-clone-24.c more robust
Richard Biener [Fri, 5 Dec 2025 08:04:02 +0000 (09:04 +0100)] 
Make gcc.dg/vect/vect-simd-clone-24.c more robust

When -march=cascadelake is added we get 256bit vectorization by
default but there's no OMP SIMD ABI for this case with inbranch.
So add -mprefer-vector-width=512 to the testcase.

PR tree-optimization/122776
* gcc.dg/vect/vect-simd-clone-24.c: Add -mprefer-vector-width=512.

11 days agox86/aarch64: Fix compile time hog with ccmp [PR99782]
Andrew Pinski [Fri, 24 Oct 2025 04:20:24 +0000 (21:20 -0700)] 
x86/aarch64: Fix compile time hog with ccmp [PR99782]

With ccmp, right now with TER, we hit an O(n^2) explosion in
compile time. This can be stopped by returning NULL early in
ix86_gen_ccmp_next before we expand the operands which will expand seperately
at that point.

A similar change aarch64's aarch64_gen_ccmp_next is done.

Changes since v1:
 * v2: Change how cmp_mode is assigned in ix86_gen_ccmp_next.
       Reworded commit message about aarch64.

Bootstrapped and tested on x86_64-linux-gnu and aarch64-linux-gnu.

PR middle-end/99782
gcc/ChangeLog:

* config/i386/i386-expand.cc (ix86_gen_ccmp_next): Move the check
for mode earlier before expand_operands.
* config/aarch64/aarch64.cc (aarch64_gen_ccmp_next): Likewise.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
12 days agomatch.pd: x&c ?(x op c):(x|c) -> x^c [PR122615, PR122616]
Daniel Barboza [Fri, 28 Nov 2025 01:03:18 +0000 (22:03 -0300)] 
match.pd: x&c ?(x op c):(x|c) -> x^c [PR122615, PR122616]

Add a single pattern to reduce these patterns to "x ^ c":

x & c ? (x - c) | (x | c)
x & c ? (x & ~c) | (x | c)

As long as "c" has a single bit set.

        PR tree-optimization/122615
        PR tree-optimization/122616

gcc/ChangeLog:

* match.pd (`x & c ? (x - c) | (x | c)`): New pattern.
(`x & c ? (x & ~c) | (x | c)`): Likewise.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr122615.c: New test.
* gcc.dg/torture/pr122616.c: Likewise.

Co-authored-by: Jeff Law <jlaw@ventanamicro.com>
Signed-off-by: Daniel Barboza <dbarboza@ventanamicro.com>
12 days agoRISC-V: Add test for vec_duplicate + vmsltu.vv combine with GR2VR cost 0, 1 and 15
Pan Li [Mon, 24 Nov 2025 01:15:24 +0000 (09:15 +0800)] 
RISC-V: Add test for vec_duplicate + vmsltu.vv combine with GR2VR cost 0, 1 and 15

Add asm dump check and run test for vec_duplicate + vmsltu.vv
combine to vmsltu.vx, with the GR2VR cost is 0, 2 and 15.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u16.c: Add asm check
for vmsltu.vx.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary.h: Add test
helper macros.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary_data.h: Add test
data for run test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmsltu-run-1-u16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmsltu-run-1-u32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmsltu-run-1-u64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmsltu-run-1-u8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
12 days agoRISC-V: Combine vec_duplicate + vmsltu.vv to vmsltu.vx on GR2VR cost
Pan Li [Mon, 24 Nov 2025 01:05:02 +0000 (09:05 +0800)] 
RISC-V: Combine vec_duplicate + vmsltu.vv to vmsltu.vx on GR2VR cost

This patch would like to combine the vec_duplicate + vmsltu.wv to the
vmsltu.vx.  From example as below code.  The related pattern will depend
on the cost of vec_duplicate from GR2VR.  Then the late-combine will
take action if the cost of GR2VR is zero, and reject the combination
if the GR2VR cost is greater than zero.

Assume we have asm code like below, GR2VR cost is 0.

Before this patch:
  11       beq a3,zero,.L8
  12       vsetvli a5,zero,e32,m1,ta,ma
  13       vmv.v.x v2,a2
  ...
  16   .L3:
  17       vsetvli a5,a3,e32,m1,ta,ma
  ...
  22       vmsltu.wv v1,v2,v3
  ...
  25       bne a3,zero,.L3

After this patch:
  11       beq a3,zero,.L8
  ...
  14    .L3:
  15       vsetvli a5,a3,e32,m1,ta,ma
  ...
  20       vmsltu.wx v1,a2,v3
  ...
  23       bne a3,zero,.L3

gcc/ChangeLog:

* config/riscv/autovec-opt.md (*pred_cmp_swapped<mode>_scalar):
Add new pattern to match vec_dup > vec for vmsltu.
* config/riscv/predicates.md (comparison_swappable_operator):
Add new iterator for above pattern
* config/riscv/riscv-protos.h (expand_vx_cmp_vec_dup_vec): Add
new func to emit vmsltu.vx.
* config/riscv/riscv-v.cc (get_swapped_cmp_rtx_code): Add new
func to convert cmp code to swapped, like gtu to ltu.
(expand_vx_cmp_vec_dup_vec): Add new func decl.

Signed-off-by: Pan Li <pan2.li@intel.com>
12 days agoDaily bump.
GCC Administrator [Fri, 5 Dec 2025 00:16:26 +0000 (00:16 +0000)] 
Daily bump.

12 days agolibstdc++: Fix std::erase_if behavior for std::__debug::deque
François Dumont [Thu, 20 Nov 2025 06:15:30 +0000 (07:15 +0100)] 
libstdc++: Fix std::erase_if behavior for std::__debug::deque

std::erase and std::erase_if are broken for users directly referencing
__gnu_debug::deque in their code that is to say without activating the
_GLIBCXX_DEBUG mode. The iterators potentially invalidated by the erase
operations are not detected by the __gnu_debug::deque container and so
won't be reported as invalidated.

We need explicit std::erase and std::erase_if implementations for
std::__debug::deque which will work also when _GLIBCXX_DEBUG mode is
activated.

libstdc++-v3/ChangeLog:

* include/debug/deque
(std::erase_if<>(std::__debug::deque<>&, _Pred)): New.
(std::erase<>(std::__debug::deque<>&, const _Up&)): New.
* include/std/deque (std::erase_if(std::deque<>&, _Pred)): Remove
_GLIBCXX_DEBUG code.
* testsuite/23_containers/deque/debug/erase.cc: New test case.
* testsuite/23_containers/deque/debug/invalidation/erase.cc: New test case.

12 days agoaarch64: Fix crc{,_rev}<SWI124:mode>si4 expanders [PR122991]
Jakub Jelinek [Thu, 4 Dec 2025 19:37:00 +0000 (20:37 +0100)] 
aarch64: Fix crc{,_rev}<SWI124:mode>si4 expanders [PR122991]

The newly added gcc.dg/pr122991.c test fails also on aarch64.
The problem is the same as on x86 which has been fixed in r16-5882,
while the last operand is guaranteed to be a CONST_INT of the right
mode initially, maybe_legitimize_operands can change that if some earlier
operand has the same value and e.g. register_operand predicate has been
used, that operand is forced into a pseudo and maybe_legitimize_operands
then checks if that satisfies the predicate of the other operand.
As on x86 and aarch64 it didn't have any predicate, it happily used
a pseudo in those cases instead of the expected CONST_INT.

The following patch fixes that.

2025-12-04  Jakub Jelinek  <jakub@redhat.com>

PR target/122991
* config/aarch64/aarch64.md (crc_rev<ALLI:mode><ALLX:mode>4,
crc<ALLI:mode><ALLX:mode>4): Use const_int_operand predicate for
the last operand.

12 days agoamdgcn, libgomp: improve generic device errors
Andrew Stubbs [Wed, 3 Dec 2025 15:21:30 +0000 (15:21 +0000)] 
amdgcn, libgomp: improve generic device errors

Switching to use "generic" ISA variants has changed the error modes a bit.

This patch changes the runtime so that it doesn't say to use the
device-specific -march option when the real problem is not the ISA (it'll be a
mismatched xnack setting, probably).

Additionally, the testsuite effective target check needs to see if the xnack
mode is accepted by the runtime, as well as the compiler.

libgomp/ChangeLog:

* plugin/plugin-gcn.c (generic_isa_code): New function.
(isa_matches_agent): Use generic ISA details to help select an error
message on ISA mismatch.
* testsuite/lib/libgomp.exp
(check_effective_target_offload_target_amdgcn_with_xnack): Use a
runtime check.

12 days agolibstdc++: Fix debug mode for unordered containers.
Tomasz Kamiński [Thu, 4 Dec 2025 14:28:00 +0000 (15:28 +0100)] 
libstdc++: Fix debug mode for unordered containers.

The r16-5845-g8a2e6590cc4a2f changed the _Safe_container copy-assignment
to delegate to assignment of the _Base. However, _Safe_unordered_container_base
was not updated, and due the presence of move constructor, it's assignments are
deleted, causing hard error for assignment of any unordered container.

libstdc++-v3/ChangeLog:

* include/debug/safe_unordered_base.h
(_Safe_unordered_container_base::operator=): Define as
defaulted, inherit behavior of _Safe_sequence_base.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
12 days agoSelect both inbranch and notinbranch clone during SIMD call analysis
Richard Biener [Sun, 23 Nov 2025 13:01:03 +0000 (14:01 +0100)] 
Select both inbranch and notinbranch clone during SIMD call analysis

The following recors both a possibly notinbranch and an inbranch
SIMD clone during analysis so that we can properly handle the
late decision on loop masking.  Recording of linear-clause data
from analysis is extended to cover linear-clause arguments from
both clones.

This also fixes AVX512 masked loop code generation in line with
the previous fixes.

PR tree-optimization/122776
* tree-vectorizer.h (vect_simd_clone_data::clone,
vect_simd_clone_data::clone_inbranch): New fields for
the two selected clones.
* tree-vect-stmts.cc (vectorizable_simd_clone_call): Record
both a possibly notinbranch and a inbranch clone.  Delay
the choice between both to code generation based on
LOOP_VINFO_FULLY_MASKED_P.

* gcc.dg/vect/vect-simd-clone-24.c: New testcase.
* gcc.dg/gomp/pr110485.c: Adjust.

12 days agovrp: Infer ranges from constant aggregates with initializers (v4)
Martin Jambor [Thu, 4 Dec 2025 13:18:05 +0000 (14:18 +0100)] 
vrp: Infer ranges from constant aggregates with initializers (v4)

This patch adds the ability to infer ranges from loads from global
constant static aggregates which have static initializers.  Even when
the load has one or more ARRAY_REFs with an unknown index and thus we
do not know the particular constant that is being loaded, we can
traverse the correponding elements of the initializer and see if we
know in what range(s) the loaed value must fall - or for pointers we
can sometimes infer that the value cannot be NULL.

I thought this was similar to fold_using_range::range_of_address and
so I decided to put my implementation alongside of it.

The differences from v3 posted in
https://inbox.sourceware.org/gcc-patches/ri6a50xjv39.fsf@virgil.suse.cz/
are:

  - The walking budget is not passed around recursively and
    decremented but is estimated from the size of the constant
    variable, which must not be bigger than param_vrp_cstload_limit
    times the size of the loaded type.

  - range_from_readonly_load uses a test for INTEGER_CST tree code to
    verify a tree is an integer constant and leaves all pointer checks
    to tree_single_nonzero_warnv_p.

  - In the testcases, all comparisons with number 666 were replaced
    with tighter bounds.

The one important change compared to v2 posted in
https://inbox.sourceware.org/gcc-patches/ri6fratkchf.fsf@virgil.suse.cz/T/#u
is:

- To get at the static constructor, the patch now uses
  ctor_for_folding instead of directly looking into DECL_INITIAL.  In
  LTO this loads the constructor on demand if necessary, and is also
  capable of looking through symbol aliases, which is necessary for
  example when the variable in question has been merged with another
  one by IPA-ICF.

The changes compared to v1 posted in
https://inbox.sourceware.org/gcc-patches/d1bb0175-0dee-481d-8078-12e74da58787@redhat.com/T/#m974fa6138bb074a239fb2a300e1d60bc087913ad
are:

- The limiting parameter limits the number of constructor leaf
  "elements" that we traverse.

- I have incorporated (hopefully) all suggestions from Richi, mainly
  assuming value zero if we do not encounter a corresponding part of a
  static initializer and using get_array_ctor_element_at_index to get
  at an element of an array with known constant index.  I tried to
  emulate how it is used in fold_array_ctor_reference, I hope I got it
  right.

- I have changed to code to only work for pranges and iranges for now.
  I will file a bug about extending it for frange and attach a patch
  to the code I'm now adding to handle frange.  But as I mentioned in
  an earlier email, something else will need to change too to get it
  working as expected.

- I have changed range_from_readonly_load to simply work true or false
  for pointers - where true means we can infer that it does not
  contain NULL and false means we cannot do anything.  For integers, I
  have changed it to instantiate int_range<1> rather than value_range
  to add another constant.

- I have introduced range_from_missing_constructor_part to handle the
  cases of missing bits in a constructor.

- I have put the (now simplified) functionality of
  add_loaded_invariant_to_range at the beginning of
  range_from_readonly_load.  That function remains recursive and walks
  the memory reference expression "backwards" for reasons explained in
  the previous email thread.

- The case where we need to iterate over all elements of an array was
  optimized for pointers, we first check if all elements are present and
  do not iterate if not.  For integers, we still need to iterate, of
  course.

- I have added testcases to cover situations with two-dimensional
  arrays.  Both when both indices are unknown and when only the second
  one is (in the C-sense).

gcc/ChangeLog:

2025-11-28  Martin Jambor  <mjambor@suse.cz>

* gimple-range-fold.h (class fold_using_range): New member
function range_from_readonly_var.
* gimple-range-fold.cc (fold_using_range::fold_stmt): Call
range_from_readonly_var on assignments.
(range_from_missing_constructor_part): New function.
(range_from_readonly_load): Likewise.
(fold_using_range::range_from_readonly_var): Likewise.
* params.opt (param_vrp_cstload_limit): New.
* doc/invoke.texi (vrp-cstload-limit): Likewise.

gcc/testsuite/ChangeLog:

2025-11-28  Martin Jambor  <mjambor@suse.cz>

* gcc.dg/tree-ssa/vrp-from-cst-agg-1.c: New test.
* gcc.dg/tree-ssa/vrp-from-cst-agg-2.c: Likewise.
* gcc.dg/tree-ssa/vrp-from-cst-agg-3.c: Likewise.
* gcc.dg/tree-ssa/vrp-from-cst-agg-4.c: Likewise.
* gcc.dg/tree-ssa/vrp-from-cst-agg-5.c: Likewise.
* gcc.dg/tree-ssa/vrp-from-cst-agg-6.c: Likewise.
* gcc.dg/tree-ssa/vrp-from-cst-agg-7.c: Likewise.
* gcc.dg/ipa/vrp-from-cst-agg-1.c: Likewise.

12 days agolibstdc++: Convertibility of rank == 0 layouts, LWG4272.
Luc Grosheintz [Tue, 9 Sep 2025 15:04:05 +0000 (17:04 +0200)] 
libstdc++: Convertibility of rank == 0 layouts, LWG4272.

LWG4272 proposes to add a condition for convertibility from
layout_stride::mapping to other mappings. New conversion requires
both that rank == 0 and that the extent types are convertible.

LWG4272 also proposes to add the same condition for conversion of
padded layouts, i.e. in addition to the condition on the padding
value, the extent types must be convertible.

libstdc++-v3/ChangeLog:

* include/std/mdspan (layout_left): Apply LWG4272.
(layout_right, layout_left_padded, layout_right_padded): Ditto.
* testsuite/23_containers/mdspan/layouts/ctors.cc: Add
test to check ctor uniformity at rank == 0. Update test
for new behavior.
* testsuite/23_containers/mdspan/layouts/padded.cc: Update test
for new behavior.

Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
12 days agoi386: Fix gcc.dg/asm-hard-reg-9.c
Stefan Schulze Frielinghaus [Thu, 4 Dec 2025 12:49:19 +0000 (13:49 +0100)] 
i386: Fix gcc.dg/asm-hard-reg-9.c

The testcase introduced in r16-5879-g55cc4377a31 was ment for 64-bit
only because it is referencing register r8.  Fixed by restricting it to
lp64.

gcc/testsuite/ChangeLog:

* gcc.dg/asm-hard-reg-9.c: Restrict to lp64 x86_64.

12 days agoamdgcn, libgomp: use xfail for gfx908 requires tests
Andrew Stubbs [Wed, 3 Dec 2025 17:53:07 +0000 (17:53 +0000)] 
amdgcn, libgomp: use xfail for gfx908 requires tests

Use a different way to remove the "FAIL" cases for gfx908.  It really isn't
working with fall-back, as intended, so XFAIL is appropriate.

libgomp/ChangeLog:

* testsuite/libgomp.c-c++-common/requires-4.c: Change dg-excess-errors
to dg-xfail-if.
* testsuite/libgomp.c-c++-common/requires-4a.c: Likewise.
* testsuite/libgomp.c-c++-common/requires-5.c: Likewise.

12 days agolibstdc++: Fix node-base containers copy and move constructor in debug mode.
Tomasz Kamiński [Thu, 4 Dec 2025 10:25:37 +0000 (11:25 +0100)] 
libstdc++: Fix node-base containers copy and move constructor in debug mode.

The fixes regression from r16-5845-g8a2e6590cc4a2f that added an move
assignment operator to the _Safe_node_sequence, and made the class both
non move and copy constructible (copy is deleted, move is not declared).
In consequence debug version of node containers, that define they copy
and move as defaulted, and inherit from above, have deleted copy and moves.

libstdc++-v3/ChangeLog:

* include/debug/safe_sequence.h
(_Safe_node_sequence::_Safe_node_sequence): Define as defaulted.