]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
4 weeks agoPR81358: Enable automatic linking of libatomic.
Prathamesh Kulkarni [Thu, 9 Oct 2025 07:07:24 +0000 (07:07 +0000)] 
PR81358: Enable automatic linking of libatomic.

ChangeLog:
PR driver/81358
* Makefile.def: Add no_atomic=true for libraries that don't depend on
libatomic.
* Makefile.tpl: Export TARGET_CONFIGDIRS and create rule to
add dependencies for libatomic.
* configure.ac: Add libatomic to bootstrap_target_libs.
* Makefile.in: Regenerate.
* configure: Regenerate.

gcc/ChangeLog:
PR driver/81358
* common.opt: New option -flink-libatomic.
* gcc.cc (LINK_LIBATOMIC_SPEC): New macro.
* config/alpha/linux.h (LINK_GCC_C_SEQUENCE_SPEC): Use LINK_LIBATOMIC_SPEC.
* config/arm/uclinux-elf.h: Likewise.
* config/arm/unknown-elf.h: Likewise.
* config/avr/avrlibc.h: Likewise.
* config/bfin/linux.h: Likewise.
* config/darwin.h: Likewise.
* config/gnu-user.h: Likewise.
* config/lm32/uclinux-elf.h: Likewise.
* config/rs6000/linux64.h: Likewise.
* config/rs6000/rtems.h: Likewise.
* config/sparc/sparc.h: Likewise.
* doc/invoke.texi: Document -flink-libatomic.
* configure.ac: Define TARGET_PROVIDES_LIBATOMIC.
* configure: Regenerate.
* config.in: Regenerate.
* common.opt.urls: Regenerate.

libatomic/ChangeLog:
PR driver/81358
* Makefile.am: Pass -fno-link-libatomic.
New rule all-local.
* configure.ac: Assert that CFLAGS is set and pass -fno-link-libatomic.
Use __libatomic_save_CFLAGS__ instead of save_CFLAGS.
* Makefile.in: Regenerate.
* configure: Regenerate.

Signed-off-by: Prathamesh Kulkarni <prathameshk@nvidia.com>
Co-authored-by: Matthew Malcolmson <mmalcolmson@nvidia.com>
4 weeks agovect: Remove type from misalignment hook.
Robin Dapp [Thu, 11 Sep 2025 13:20:36 +0000 (15:20 +0200)] 
vect: Remove type from misalignment hook.

This patch removes the type argument from the vector_misalignment hook.
Ever since we switched from element to byte misalignment its
semantics haven't been particularly clear and nowadays it should be
redundant.

Also, in case of gather/scatter, the patch sets misalignment to the
misalignment of one unit of the vector mode so targets can
distinguish between element size alignment and element mode alignment.

is_packed is now always set, regardless of misalignment.

gcc/ChangeLog:

* config/aarch64/aarch64.cc (aarch64_builtin_support_vector_misalignment):
Remove type.
* config/arm/arm.cc (arm_builtin_support_vector_misalignment):
Ditto.
* config/epiphany/epiphany.cc (epiphany_support_vector_misalignment):
Ditto.
* config/gcn/gcn.cc (gcn_vectorize_support_vector_misalignment):
Ditto.
* config/loongarch/loongarch.cc (loongarch_builtin_support_vector_misalignment):
Ditto.
* config/riscv/riscv.cc (riscv_support_vector_misalignment):
Ditto.
* config/rs6000/rs6000.cc (rs6000_builtin_support_vector_misalignment):
Ditto.
* config/s390/s390.cc (s390_support_vector_misalignment):
Ditto.
* doc/tm.texi: Adjust vector misalignment docs.
* target.def: Ditto.
* targhooks.cc (default_builtin_support_vector_misalignment):
Remove type.
* targhooks.h (default_builtin_support_vector_misalignment):
Ditto.
* tree-vect-data-refs.cc (vect_can_force_dr_alignment_p):
Set misalignment for gather/scatter and remove type.
(vect_supportable_dr_alignment): Ditto.

4 weeks agodoc: type-punning through a union is a GNU extension for C++
Sam James [Thu, 9 Oct 2025 02:40:58 +0000 (03:40 +0100)] 
doc: type-punning through a union is a GNU extension for C++

We didn't explicitly say that type-punning through a union is undefined
behavior in C++. Mention that, and that we support it as a GNU extension.

This was reported on LLVM's Discourse (forums) [0].

[0] https://discourse.llvm.org/t/ub-when-type-punning-through-unions/88527/6

gcc/ChangeLog:
PR c++/117219

* doc/invoke.texi (-fstrict-aliasing): Explain that type-punning
through a union in C++ is supported as a GNU extension.

4 weeks agodoc: fix grammar nit
Sam James [Thu, 9 Oct 2025 02:38:06 +0000 (03:38 +0100)] 
doc: fix grammar nit

gcc/ChangeLog:

* doc/invoke.texi: Add missing full stop.

4 weeks agodoc: mention -Wmaybe-uninitialized vs CCP
Sam James [Tue, 7 Oct 2025 00:51:55 +0000 (01:51 +0100)] 
doc: mention -Wmaybe-uninitialized vs CCP

CCP interacts poorly with -Wmaybe-uninitialized in some cases by assuming a value
which stops us warning about it (false negatives). Inform users about this
infamous interaction.

gcc/ChangeLog:
PR tree-optimization/18501

* doc/invoke.texi (-Wmaybe-uninitialized): Mention interaction with
CCP.

4 weeks agoDaily bump.
GCC Administrator [Thu, 9 Oct 2025 00:21:21 +0000 (00:21 +0000)] 
Daily bump.

4 weeks agoc: Implement C23 rules for undefined static functions in _Generic
Joseph Myers [Wed, 8 Oct 2025 23:12:11 +0000 (23:12 +0000)] 
c: Implement C23 rules for undefined static functions in _Generic

A fairly late change in C23, the resolution of CD2 ballot comments
US-077 and US-078, added certain locations in _Generic to the
obviously unevaluated locations where it is permitted to have a
reference to a static function that is never defined.

Implement this feature in GCC.  The main complication is that, unlike
previous cases where it's known at the end of an operand to a
construct such as sizeof whether that operand is obviously unevaluated
and so an appropriate argument can be passed to pop_maybe_used, in the
case of a default generic association in _Generic it may not be known
until the end of that _Generic expression whether that case is
evaluated or not.  Thus, we arrange for the state of the
maybe_used_decls stack to be saved in this case and later restored
once the correct argument to pop_maybe_used is known.

There may well be further changes in this area in C2y (if the
"discarded" proposal is adopted, further locations will be OK for such
references to undefined static functions).  For now, only expressions
and not type names in _Generic have this special treatment.

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

gcc/c/
* c-typeck.cc (in_generic, save_maybe_used, restore_maybe_used):
New.
(mark_decl_used, record_maybe_used_decl, pop_maybe_used): Use
in_generic.
(struct maybe_used_decl): Move to c-tree.h.
* c-tree.h (struct maybe_used_decl): Move from c-typeck.cc.
(in_generic, save_maybe_used, restore_maybe_used): Declare.
* c-parser.cc (c_parser_generic_selection): Increment and
decrement in_generic.  Use pop_maybe_used, save_maybe_used and
restore_maybe_used.

gcc/testsuite/
* gcc.dg/c11-generic-4.c, gcc.dg/c23-generic-5.c,
gcc.dg/c2y-generic-5.c: New tests.

4 weeks agoFortran: fix warnings for symbols with C binding and declared PRIVATE [PR49111]
Harald Anlauf [Tue, 7 Oct 2025 19:54:45 +0000 (21:54 +0200)] 
Fortran: fix warnings for symbols with C binding and declared PRIVATE [PR49111]

The Fortran standard does not prohibit restricting the accessibility of a
symbol by use of the PRIVATE attribute and exposing it via a C binding
label.  Instead of unconditionally generating a warning, only warn if the
binding label is surprisingly identical to the privatized Fortran symbol
and when -Wsurprising is specified.

PR fortran/49111

gcc/fortran/ChangeLog:

* decl.cc (verify_bind_c_sym): Modify condition for generation of
accessibility warning, and adjust warning message.

gcc/testsuite/ChangeLog:

* gfortran.dg/binding_label_tests_9.f03: Adjust test.
* gfortran.dg/module_private_2.f90: Likewise.
* gfortran.dg/public_private_module_2.f90: Likewise.
* gfortran.dg/binding_label_tests_35.f90: New test.

4 weeks agoc: Allow variably-modified types in generic associations for C2Y
Martin Uecker [Sat, 30 Aug 2025 17:05:05 +0000 (19:05 +0200)] 
c: Allow variably-modified types in generic associations for C2Y

This implements part of N3348 to allow variably-modified types in
generic associations in C2Y and making it a pedantic warning before.
Allowing star * is not yet implemented.

gcc/c/ChangeLog:
* c-parser.cc (c_parser_generic_selection): Change
error_at to pedwarn_c23.

gcc/testsuite/ChangeLog:
* gcc.dg/c11-generic-2.c: Adapt error message.
* gcc.dg/c2y-generic-3.c: Adapt test.
* gcc.dg/c2y-generic-4.c: New test.

4 weeks agolibstdc++: Update dead links to PSTL upstream in docs
Jonathan Wakely [Wed, 8 Oct 2025 11:41:16 +0000 (12:41 +0100)] 
libstdc++: Update dead links to PSTL upstream in docs

The pstl code has been removed from the llvm repo so point to the Intel
upstream project where it really originates from.

libstdc++-v3/ChangeLog:

* doc/xml/manual/status_cxx2017.xml: Replace broken link to PSTL
upstream.
* doc/xml/manual/status_cxx2020.xml: Likewise.
* doc/html/manual/status.html: Regenerate.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 weeks agolibstdc++: Remove unused config/cpu/i486/atomicity.h file
Jonathan Wakely [Tue, 7 Oct 2025 14:06:43 +0000 (15:06 +0100)] 
libstdc++: Remove unused config/cpu/i486/atomicity.h file

This file is no longer used, because we always use the definitions in
config/cpu/generic/atomicity_builtins/atomicity.h now.

libstdc++-v3/ChangeLog:

* config/cpu/i486/atomicity.h: Removed.

Reviewed-by: Uros Bizjak <ubizjak@gmail.com>
4 weeks agolibstdc++: Remove unused config/cpu/cris/atomicity.h file [PR122172]
Jonathan Wakely [Tue, 7 Oct 2025 14:06:43 +0000 (15:06 +0100)] 
libstdc++: Remove unused config/cpu/cris/atomicity.h file [PR122172]

This file is no longer used, because we always use the definitions in
config/cpu/generic/atomicity_builtins/atomicity.h now.

H-P confirmed that the code generated by __atomic_fetch_add is fine and
we don't need the handwritten assembly.

libstdc++-v3/ChangeLog:

PR libstdc++/122172
* config/cpu/cris/atomicity.h: Removed.

Reviewed-by: Hans-Peter Nilsson <hp@axis.com>
4 weeks agolibstdc++: Fix allocator propagation and tests for std::indirect and std::polymorphic
Jonathan Wakely [Wed, 1 Oct 2025 11:45:17 +0000 (12:45 +0100)] 
libstdc++: Fix allocator propagation and tests for std::indirect and std::polymorphic

I noticed that several tests were doing:

static_assert([] { /* ... */; return true; });

i.e. just testing a lambda, not invoking it and testing the result. This
change fixes that, so that all the lambdas are invoked.

After fixing that, most of the tests failed because they were using
__gnu_test::tracker_allocator or std::scoped_allocator_adaptor in
constexpr functions. The tracker_allocator modifies global state, so can
never be constexpr, and none of std::scoped_allocator_adaptor's members
are marked constexpr.

This change makes __gnu_test::uneq_allocator and
__gnu_test::propagating_allocator usable in constant expressions, which
allows some of the tests which can't be constexpr to be duplicated to
new functions which use uneq_allocator or propagating_allocator instead
of tracker_allocator. This new functions can be tested with the
static_assert calling a lambda.

In some cases none of the tests could be adapted to be constexpr, so the
static_assert and lambda were just removed.

Two changes were also needed for the actual library code, because the
move assignment operators for std::indirect and std::polymorphic were
using copy-assignment on the allocator. Although the semantics of
move-assignment for allocators should be equivalent to copy-assignment,
an allocator isn't actually required to support copy-assignment unless
propagate_on_container_copy_assignment is true. So we have to use
move-assignment for propagate_on_container_move_assignment cases.

libstdc++-v3/ChangeLog:

* include/bits/indirect.h (indirect::operator=(indirect&&)):
Move assign allocator when POCMA is true.
(polymorphic::operator=(polymorphic&&)): Likewise.
* testsuite/std/memory/indirect/copy.cc: Remove constexpr from
functions that use tracker_allocator. Add test_constexpr().
* testsuite/std/memory/indirect/copy_alloc.cc: Remove constexpr
from all functions and remove static_assert.
* testsuite/std/memory/indirect/ctor.cc: Do not use
scoped_allocator_adaptor during constant evaluation.
* testsuite/std/memory/indirect/move.cc: Remove constexpr from
functions that use tracker_allocator. Add test_constexpr().
* testsuite/std/memory/indirect/move_alloc.cc: Remove constexpr
from all functions and remove static_assert.
* testsuite/std/memory/indirect/relops.cc: Invoke lambda in
static_assert.
* testsuite/std/memory/polymorphic/copy.cc: Remove constexpr
from functions that use tracker_allocator. Add test_constexpr().
* testsuite/std/memory/polymorphic/copy_alloc.cc: Remove
constexpr from all functions and remove static_assert.
* testsuite/std/memory/polymorphic/ctor.cc: Do not use
scoped_allocator_adaptor during constant evaluation.
* testsuite/std/memory/polymorphic/ctor_poly.cc: Likewise.
* testsuite/std/memory/polymorphic/move.cc: Remove constexpr
from functions that use tracker_allocator. Add test_constexpr().
* testsuite/std/memory/polymorphic/move_alloc.cc: Remove
constexpr from all functions and remove static_assert.
* testsuite/util/testsuite_allocator.h (tracker_allocator):
Remove redundant 'inline' from friend.
(uneq_allocator): Make all functions constexpr.
(uneq_allocator::base, uneq_allocator::swap_base): Remove.
(uneq_allocator::~uneq_allocator): Remove.
(uneq_allocator::allocate, uneq_allocator::deallocate): Do not
use map of allocations during constant evaluation.
(propagating_allocator): Make all functions constexpr.
(propagating_allocator::base): Remove.
(propagating_allocator::swap_base): Simplify.
(ExplicitConsAlloc, CustomPointerAlloc, NullablePointer): Add
constexpr to all functions.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 weeks agoUpdate to Unicode 17.0.0
Jakub Jelinek [Wed, 8 Oct 2025 15:54:11 +0000 (17:54 +0200)] 
Update to Unicode 17.0.0

The following patch updates GCC from Unicode 16.0.0 to 17.0.0.

I've followed what the README says and updated also one script from
glibc, but that needed another Unicode file - HangulSyllableType.txt -
around as well, so I'm adding it.
I've added one new test to named-universal-char-escape-1.c for
randomly chosen character from new CJK block.
Note, Unicode 17.0.0 authors forgot to adjust the 4-8 table, I've filed
bugreports about that but the UnicodeData.txt changes for the range ends
and the new range seems to match e.g. what is in the glyph tables, so
the patch follows UnicodeData.txt and not 4-8 table here.

Another thing was that makeuname2c.cc didn't handle correctly when
the size of the generated string table modulo 77 was 76 or 77, in which
case it forgot to emit a semicolon after the string literal and so failed
to compile.

And as can be seen in the emoji-data.txt diff, some properties like
Extended_Pictographic have been removed from certain characters, e.g.
from the Mahjong cards characters except U+1F004, and one libstdc++
test was testing that property exactly on U+1F000.  Dunno why that was
changed, but U+1F004 is the only colored one among tons of black and white
ones.

2025-10-08  Jakub Jelinek  <jakub@redhat.com>

contrib/
* unicode/README: Add HangulSyllableType.txt file to the
list as newest utf8_gen.py from glibc now needs it.  Adjust
git commit hash and change unicode 16 version to 17.
* unicode/from_glibc/utf8_gen.py: Updated from glibc.
* unicode/DerivedCoreProperties.txt: Updated from Unicode 17.0.0.
* unicode/emoji-data.txt: Likewise.
* unicode/PropList.txt: Likewise.
* unicode/GraphemeBreakProperty.txt: Likewise.
* unicode/DerivedNormalizationProps.txt: Likewise.
* unicode/NameAliases.txt: Likewise.
* unicode/UnicodeData.txt: Likewise.
* unicode/EastAsianWidth.txt: Likewise.
* unicode/DerivedGeneralCategory.txt: Likewise.
* unicode/HangulSyllableType.txt: New file.
gcc/testsuite/
* c-c++-common/cpp/named-universal-char-escape-1.c: Add test for
\N{CJK UNIFIED IDEOGRAPH-3340E}.
libcpp/
* makeucnid.cc (write_copyright): Adjust copyright year.
* makeuname2c.cc (generated_ranges): Adjust end points for a couple
of ranges based on UnicodeData.txt Last changes and add a whole new
CJK UNIFIED IDEOGRAPH- entry.  None of these changes are in the 4-8
table, but clearly it has just been forgotten.
(write_copyright): Adjust copyright year.
(write_dict): Fix up condition when to print semicolon.
* generated_cpp_wcwidth.h: Regenerate.
* ucnid.h: Regenerate.
* uname2c.h: Regenerate.
libstdc++-v3/
* include/bits/unicode-data.h: Regenerate.
* testsuite/ext/unicode/properties.cc: Test __is_extended_pictographic
on U+1F004 rather than U+1F000.

4 weeks agoc++: clobber non-placement new
Jason Merrill [Wed, 8 Oct 2025 15:09:49 +0000 (16:09 +0100)] 
c++: clobber non-placement new

And also add the clobber for non-placement new.

For now let's limit the clobber of an array with non-constant bound to
placement new in constant evaluation, where we need it to set the active
member of a union.

And catch some additional cases of there being no actual data to clobber.

This changes the diagnostics in a couple of analyzer tests, but the new
diagnostics are also valid.

It also adds some -Wuninitialized warnings which seem like an improvement;
the lines that now warn about an uninitialized vptr are correct, since
trying to assign to a member of a virtual base reads the vptr of an object
that was never created.

gcc/cp/ChangeLog:

* init.cc (build_new_1): Also clobber for non-placement new.
Only loop clobber in constexpr.
* expr.cc (wrap_with_if_consteval): New.
* cp-tree.h (wrap_with_if_consteval): Declare.

gcc/testsuite/ChangeLog:

* g++.dg/analyzer/new-2.C: Adjust diags.
* g++.dg/analyzer/noexcept-new.C: Adjust diags.
* g++.dg/warn/Warray-bounds-23.C: Add warnings.
* g++.dg/warn/Warray-bounds-24.C: Add warnings.
* g++.dg/cpp26/constexpr-new4a.C: New test.

4 weeks agoRegenerate gcc/configure
Antoni Boucher [Wed, 8 Oct 2025 13:49:13 +0000 (09:49 -0400)] 
Regenerate gcc/configure

Use autoconf 2.69 to regenerate gcc/configure

gcc/ChangeLog:

* configure: Regenerate.

4 weeks agolibstdc++: Fix type in computation of _M_weekday_index.
Tomasz Kamiński [Wed, 8 Oct 2025 13:14:04 +0000 (15:14 +0200)] 
libstdc++: Fix type in computation of _M_weekday_index.

The value should use divide instead of modulo, as given 1st of month
being weekday X (Mon, Tue, ...), 01 is always X[1], 08 is X[2], e.t.c.

This values is currently not observable, as there is no user-accessible
format specifier that will print it, however it may be exposed in future.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (_ChronoData::_M_fill_day): Replace
'%' by '/'.

4 weeks agox86-64: mingw: Pass and return _Float16 in vector registers [PR115054]
Trevor Gross [Sun, 14 Sep 2025 00:50:21 +0000 (19:50 -0500)] 
x86-64: mingw: Pass and return _Float16 in vector registers [PR115054]

For MinGW on x86-64, GCC currently passes and returns `_Float16` in
GPRs. Microsoft does not specify an ABI for the type so this is purely
an extension; however, there are a few reasons the current ABI is not
ideal:

1. `float` and `double` are both passed and returned in xmm registers
   under the MSVC ABI, there isn't any reason for `_Float16` to deviate.
2. `_Float16` is returned in xmm0 on Windows x86-32 by both GCC and
   Clang.
3. There is a platform-natural ABI with AVX512-FP16, which requires
   half-precision operands to be in vector registers.
4. System V uses vector registers for `_Float16`.

Thus, update the `HFmode` ABI to both pass and return in vector
registers, meaning its ABI is now identical to `float` and `double`.
This is already Clang's behavior on both its x64 MSVC and MinGW targets,
so the change here also resolves an ABI incompatibility (originally
reported in linked issue).

The results can be verified by evaluating the change in assembly output
with this source:

    void pass_f16(_Float16 x, _Float16 *dst) {
        *dst = x;
    }

    void callee_f16(_Float16);
    void call_f16() {
        callee_f16(1.0);
    }

    _Float16 ret_f16(_Float16 *x) {
        return *x;
    }

    /* Check libcall ABI */

    void extend_f16(_Float16 *x, _Float32 *dst) {
        *dst = (_Float32)*x;
    }

    void trunc_f16(_Float32 *x, _Float16 *dst) {
        *dst = (_Float16)*x;
    }

    /* Float varargs should be in vregs with a zeroed shadow GPR */

    void va(_Float16, ...);
    void va_f16() {
        va(1.0f16, 2.0f16, 3.0f16, 4.0f16, 5.0f16);
    }

While modifying the `function_value_ms_64` `switch` statement, a
redundant condition and trailing whitespace in the 16-byte case is
cleaned up.

2025-09-13  Trevor Gross  <tmgross@umich.edu>

gcc:
PR target/115054
* config/i386/i386.cc (function_arg_ms_64,
function_value_ms_64): Pass and return _Float16 in vector
registers on Windows.

Signed-off-by: Trevor Gross <tmgross@umich.edu>
Signed-off-by: Jonathan Yong <10walls@gmail.com>
4 weeks agolibstdc++: Add missing include to std/time/format/format.cc
Jonathan Wakely [Wed, 8 Oct 2025 09:14:27 +0000 (10:14 +0100)] 
libstdc++: Add missing include to std/time/format/format.cc

libstdc++-v3/ChangeLog:

* testsuite/std/time/format/format.cc: Include <vector>.

4 weeks agoAdd boolean pattern for bitwise ops
Richard Biener [Tue, 7 Oct 2025 13:38:57 +0000 (15:38 +0200)] 
Add boolean pattern for bitwise ops

As we consider bitwise operations possible mask operations we have
to consider the case of only one operand arriving as mask.  The
following compensates for this by creating mask from the other operand
and insert possibly required mask conversions.

PR tree-optimization/110223
PR tree-optimization/122128
* tree-vect-patterns.cc (vect_recog_bool_pattern): Add
compensation for mixed mask/data bitwise operations.

* gcc.dg/vect/vect-bool-2.c: New testcase.
* gcc.dg/vect/vect-bool-cmp-3.c: Likewise.
* gcc.dg/vect/vect-bool-cmp-4.c: Likewise.

4 weeks agoCheck non-strictly vect_internal_def internal defs in integer_type_for_mask
Richard Biener [Wed, 8 Oct 2025 07:19:50 +0000 (09:19 +0200)] 
Check non-strictly vect_internal_def internal defs in integer_type_for_mask

We are missing masks produced by inductions or reductions otherwise.

* tree-vect-patterns.cc (integer_type_for_mask): Only
reject vect_external_defs.

4 weeks agoAdjust g++.dg/vect/pr64410.cc scan
Richard Biener [Wed, 8 Oct 2025 09:50:14 +0000 (11:50 +0200)] 
Adjust g++.dg/vect/pr64410.cc scan

We are now vectorizing more loops in standard library functions.
Restrict the dump scan to the loop we're interested in.

PR testsuite/120100
* g++.dg/vect/pr64410.cc: Adjust.

4 weeks agolibstdc++: Implement submdspan_mapping_result. [PR110352]
Luc Grosheintz [Thu, 2 Oct 2025 09:27:16 +0000 (11:27 +0200)] 
libstdc++: Implement submdspan_mapping_result. [PR110352]

Implement the class submdspan_mapping_result and add it to the std
module.

PR libstdc++/110352

libstdc++-v3/ChangeLog:

* include/std/mdspan (submdspan_mapping_result): New class.
* src/c++23/std.cc.in (submdspan_mapping_result): Add.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
4 weeks agolibstdc++: Implement full_extent_t. [PR110352]
Luc Grosheintz [Thu, 2 Oct 2025 09:27:15 +0000 (11:27 +0200)] 
libstdc++: Implement full_extent_t. [PR110352]

Add the class and updates the std module.

PR libstdc++/110352

libstdc++-v3/ChangeLog:

* include/std/mdspan (full_extent_t): New class.
* src/c++23/std.cc.in (full_extent_t): Add.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
4 weeks agolibstdc++: Implement strided_slice from <mdspan>. [PR110352]
Luc Grosheintz [Thu, 2 Oct 2025 09:27:14 +0000 (11:27 +0200)] 
libstdc++: Implement strided_slice from <mdspan>. [PR110352]

Adds strided_slice as standardized in N5014. Also creates
the internal feature testing macro for submdspan.

PR libstdc++/110352

libstdc++-v3/ChangeLog:

* include/bits/version.def (submdspan): New internal macro.
* include/bits/version.h: Regenerate.
* include/std/mdspan (strided_slice): New class.
* src/c++23/std.cc.in (strided_slice): Add.
* testsuite/23_containers/mdspan/submdspan/strided_slice.cc: New test.
* testsuite/23_containers/mdspan/submdspan/strided_slice_neg.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
4 weeks agolibstdc++: Improve and cleanup mdspan related code.
Luc Grosheintz [Tue, 30 Sep 2025 10:55:18 +0000 (12:55 +0200)] 
libstdc++: Improve and cleanup mdspan related code.

The improvement is that in __index_type_cast, we don't need to check at
runtime if we know that _IndexType is smaller than _OIndexType.

The cleanup is whitespace (overlength lines) in <mdspan>, grouping is_always_foo
and is_foo together, and de-uglifying a variable in test code.

libstdc++-v3/ChangeLog:

* include/std/mdspan (__mdspan::__index_type_cast): Optimize by
skipping a __glibcxx_assert if it's know at compile-time.
(std::layout_left_padded, std::layout_righ_padded): Reorder
is_always_strided and is_unique member functions.
* testsuite/23_containers/mdspan/int_like.h: Rename _M_i to
value.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
4 weeks agoDo not expect 8 byte vectorization with ia32
Richard Biener [Wed, 8 Oct 2025 09:38:12 +0000 (11:38 +0200)] 
Do not expect 8 byte vectorization with ia32

We are not considering ia32 to be TARGET_MMX_WITH_SSE so the testcase
cannot work there.

PR target/120091
gcc/testsuite/
* gcc.target/i386/pr119919.c: Only check for vectorization
when !ia32.

4 weeks agolibstdc++: Implement std::layout_right_padded [PR110352].
Luc Grosheintz [Mon, 29 Sep 2025 06:00:19 +0000 (08:00 +0200)] 
libstdc++: Implement std::layout_right_padded [PR110352].

This commit adds the right padded layout as described in N5014, with
LWG4372 (dynamic padding value) and LWG4314 (move in operator()).

PR libstdc++/110352

libstdc++-v3/ChangeLog:

* include/std/mdspan (_RightPaddedIndices): Traits for right
padded layouts.
(layout_right::mapping::mapping) New overload for right padded
layouts.
(layout_right_padded): Add implementation.
* src/c++23/std.cc.in (layout_right_padded): Add.
* testsuite/23_containers/mdspan/layouts/ctors.cc: Update
test for right padded layouts.
* testsuite/23_containers/mdspan/layouts/empty.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/mapping.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded_neg.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded_traits.h: Ditto.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
4 weeks agolibstdc++: Implement std::layout_left_padded [PR110352].
Luc Grosheintz [Mon, 29 Sep 2025 06:00:18 +0000 (08:00 +0200)] 
libstdc++: Implement std::layout_left_padded [PR110352].

This commit adds a new layout layout_left_padded as standardized in
N5014. It adds a purely internal feature testing macro padded_layouts
and registers layout_left_padded in the std module.

This commit implements LWG4372, because without it's not possible
to properly test padded layouts with a dynamic padding value. It also
implements LWG4314, for consistency with prior layouts.

The implementation uses a _PaddedStorage to deduplicate most of the code
shared between left- and right-padded layouts. It's implemented through
aggregation rather than inheritence, because of a bug related to
inheriting conditionally explicit ctors.

The tests are written such that the canonical version works for
layout_left_padded. A version for layout_right_padded is derived
essentially by reversing the order of the extents.

PR libstdc++/110352

libstdc++-v3/ChangeLog:

* include/bits/version.def (padded_layouts): Add new internal
feature testing macro.
* include/bits/version.h: Regenerate.
* include/std/mdspan (__fwd_prod): New overload.
(layout_left_padded): Add declaration and implementation.
(layout_right_padded): Add declaration only.
(layout_left::mapping::mapping): New overload for left
padded mappings.
(__index_type_cast): New function that performs a checked cast
to index_type.
(__is_left_padded_mapping): New concept.
(__is_right_padded_mapping): Ditto.
(__standardized_mapping): Recognize left and right padded
mappings.
(_LeftPaddedIndices): Traits for left padded details.
(_PaddedStorage): New class for implementing padded layouts.
* src/c++23/std.cc.in (layout_left_padded): Add.
* testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc:
Refactor and add tests for layout_left_padded.
* testsuite/23_containers/mdspan/layouts/ctors.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/empty.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/mapping.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded_neg.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded_traits.h: New
traits.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
4 weeks agoAdd missing menu item for JIT Language and ABI
Richard Biener [Wed, 8 Oct 2025 09:13:15 +0000 (11:13 +0200)] 
Add missing menu item for JIT Language and ABI

Build of gccint.texi is currently broken, the following fixes it.

* doc/tm.texi.in (JIT Language and ABI): Add menu item.
* doc/tm.texi: Re-generate.

4 weeks agoc: Fix i386 target attribute regression [PR 122180]
Alfie Richards [Tue, 7 Oct 2025 09:34:48 +0000 (09:34 +0000)] 
c: Fix i386 target attribute regression [PR 122180]

My patch (r16-4182-g73888cefe6da65) broke another target (i386), which this
patch fixes.

The issue was the target_version code was incorrectly being triggered on
targets that do not support target_version semantics (i386).

PR target/122180

gcc/c/ChangeLog:

* c-decl.cc (pushdecl): Add TARGET_HAS_FMV_TARGET_ATTRIBUTE check.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr122180.c: New test.

4 weeks agogimplify: Fix up __builtin_c[lt]zg gimplification [PR122188]
Jakub Jelinek [Wed, 8 Oct 2025 07:58:41 +0000 (09:58 +0200)] 
gimplify: Fix up __builtin_c[lt]zg gimplification [PR122188]

The following testcase ICEs during gimplification.
The problem is that save_expr sometimes doesn't create a SAVE_EXPR but
returns the original complex tree (COND_EXPR) and the code then uses that
tree in 2 different spots without unsharing.  As this is done during
gimplification it wasn't unshared when whole body is unshared and because
gimplification is destructive, the first time we gimplify it we destruct it
and second time we try to gimplify it we ICE on it.
Now, we could replace one a use with unshare_expr (a), but because this
is a gimplification hook, I think easier than trying to create a save_expr
is just gimplify the argument, then we know it is is_gimple_val and so
something without side-effects and can safely use it twice.  That argument
would be the first thing to gimplify after return GS_OK anyway, so it
doesn't change argument sequencing etc.

2025-10-08  Jakub Jelinek  <jakub@redhat.com>

PR c/122188
* c-gimplify.cc (c_gimplify_expr): Gimplify CALL_EXPR_ARG (*expr_p, 0)
instead of calling save_expr on it.

* c-c++-common/pr122188.c: New test.

4 weeks agotestsuite: Fix up pr121987.c testcase for ilp32 [PR121206]
Jakub Jelinek [Wed, 8 Oct 2025 07:49:25 +0000 (09:49 +0200)] 
testsuite: Fix up pr121987.c testcase for ilp32 [PR121206]

The test FAILs on ilp32 targets with
pr121987.c:5:21: warning: unsigned conversion from 'long long int' to 'long unsigned int' changes value from '10000000000' to '1410065408' [-Woverflow]
excess error.  Fixed by using unsigned long long instead of unsigned and
using a suffix on the constant.
Tested on x86_64-linux with -m32/-m64, additionally tested with older cc1
where it ICEd in both cases in upper_bound.

2025-10-08  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/121206
* gcc.dg/pr121987.c (main): Use unsigned long long type for e instead
of unsigned long and use ULL suffix on the initializer.

4 weeks agoFortran: Fix PDT parameter substitution [PR93175,PR102240,PR102686]
Paul Thomas [Wed, 8 Oct 2025 07:17:10 +0000 (08:17 +0100)] 
Fortran: Fix PDT parameter substitution [PR93175,PR102240,PR102686]

2025-10-08  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/93175
PR fortran/102240
PR fortran/102686
* array.cc (match_array_element_spec): For pdt templates, call
gfc_correct_parm_expr to elimante extraneous symbols from the
bound expressions.
* decl.cc (correct_parm_expr, gfc_correct_parm_expr): New fcns
that remove symbols that are not PDT parameters from the type
specification expressions.
(insert_parameter_exprs): Process function symbols as if they
are variables in the substitution with parameter expressions.
(gfc_get_pdt_instance): Make sure that the parameter list of
PDT components is updated as the instance is built. Move the
construction of pdt_strings down a bit in the function and
remove the tie up with pdt_arrays.
* gfortran.h: Add prototype for gfc_correct_parm_expr.
* resolve.cc (resolve_component): Skip testing for constant
specification expressions in pdt_template component string
lengths and pdt_strings.
* trans-array.cc (structure_alloc_comps): Remove testing for
deferred parameters and instead make sure that components of
PDT type have parameters substituted with the parameter exprs
of the enclosing PDT.

gcc/testsuite/
PR fortran/93175
PR fortran/102240
PR fortran/102686
* gfortran.dg/pdt_55.f03: New test.

4 weeks agoFixup store bool pattern
Richard Biener [Tue, 7 Oct 2025 13:32:45 +0000 (15:32 +0200)] 
Fixup store bool pattern

I think the bool pattern recognition for a store from a bool we
decided to represent with a mask type is a bit confused.  The
following streamlines it by using the mask to create a data 0/1
and first possibly converting the mask according to the vector
data type we produce (that was missing and is noticable in PR110223).

This alone doesn't fix the 2nd testcase from the PR, but is required.

PR tree-optimization/110223
* tree-vect-patterns.cc (vect_recog_bool_pattern): Fix
mistakes in the store-from-mask bool pattern.  Add
required mask conversions.

4 weeks agotree-optimization/105490 - improve COND_EXPR bool pattern
Richard Biener [Tue, 7 Oct 2025 12:31:18 +0000 (14:31 +0200)] 
tree-optimization/105490 - improve COND_EXPR bool pattern

We miss to add a mask conversion from the mask producer to the
appropriate mask for the condition operation.  The following moves
required helpers and adds the missing part of the pattern.  That's
required both for the case we have different mask element sizes
and for the case we have a different number of elements because
cond expression vectorization doesn't handle the mask having
different nunits than the data vector.

PR tree-optimization/105490
* tree-vect-patterns.cc (build_mask_conversion): Move earlier.
(vect_convert_mask_for_vectype): Likewise.
(vect_recog_bool_pattern): Remove redundant truth type
construction.  Add missing possibly required mask conversion.

* gcc.dg/vect/vect-cond-14.c: New testcase.

4 weeks agolibgccjit: Add ability to get CPU features
Antoni Boucher [Fri, 21 Mar 2025 17:13:41 +0000 (13:13 -0400)] 
libgccjit: Add ability to get CPU features

gcc/ChangeLog:
PR jit/112466
* Makefile.in (tm_jit_file_list, tm_jit_include_list, TM_JIT_H,
JIT_TARGET_DEF, JIT_TARGET_H, JIT_TARGET_OBJS): New variables.
(tm_jit.h, cs-tm_jit.h, jit/jit-target-hooks-def.h,
s-jit-target-hooks-def-h, default-jit.o): New rules.
(s-tm-texi): Also check timestamp on jit-target.def.
(generated_files): Add TM_JIT_H and jit/jit-target-hooks-def.h.
(build/genhooks.o): Also depend on JIT_TARGET_DEF.
* config.gcc (tm_jit_file, jit_target_objs, target_has_targetjitm):
New variables.
* config/i386/t-i386 (i386-jit.o): New rule.
* configure: Regenerate.
* configure.ac (tm_jit_file_list, tm_jit_include_list,
jit_target_objs): Add substitutes.
* doc/tm.texi: Regenerate.
* doc/tm.texi.in (targetjitm): Document.
(target_has_targetjitm): Document.
* genhooks.cc: Include jit/jit-target.def.
* config/default-jit.cc: New file.
* config/i386/i386-jit.cc: New file.
* config/i386/i386-jit.h: New file.

gcc/jit/ChangeLog:
PR jit/112466
* Make-lang.in (JIT_OBJS): New variable.
* jit-playback.cc (replay): Include jit-target.h and initialize
target.
* jit-playback.h (class populate_target_info): New class.
* jit-recording.cc (recording::context::populate_target_info): New
method.
* jit-recording.h (recording::context::populate_target_info): New
method.
(recording::context::m_populated_target_info): New field.
* libgccjit.cc: Include jit-target.h.
(struct gcc_jit_target_info): New struct.
(gcc_jit_context_get_target_info, gcc_jit_target_info_release,
gcc_jit_target_info_cpu_supports, gcc_jit_target_info_arch,
gcc_jit_target_info_supports_target_dependent_type): New functions.
* libgccjit.h (gcc_jit_context_get_target_info,
gcc_jit_target_info_release, gcc_jit_target_info_cpu_supports,
gcc_jit_target_info_arch,
gcc_jit_target_info_supports_target_dependent_type):
New functions.
* libgccjit.map (LIBGCCJIT_ABI_35): New ABI tag.
* docs/topics/compilation.rst: Add documentation for the
functions gcc_jit_context_get_target_info, gcc_jit_target_info_release,
gcc_jit_target_info_cpu_supports, gcc_jit_target_info_arch,
gcc_jit_target_info_supports_target_dependent_type.
* docs/topics/compatibility.rst (LIBGCCJIT_ABI_35): New ABI tag.
* jit-target-def.h: New file.
* jit-target.cc: New file.
* jit-target.def: New file.
* jit-target.h: New file.

gcc/testsuite/ChangeLog:
PR jit/112466
* jit.dg/all-non-failing-tests.h: Mention
test-target-info.c.
* jit.dg/test-target-info.c: New test.
* jit.dg/test-error-target-info.c: New test.

4 weeks agoDaily bump.
GCC Administrator [Wed, 8 Oct 2025 00:20:55 +0000 (00:20 +0000)] 
Daily bump.

4 weeks agoc: Implement C2y handling of incomplete tentative definitions [PR26581]
Joseph Myers [Tue, 7 Oct 2025 23:04:54 +0000 (23:04 +0000)] 
c: Implement C2y handling of incomplete tentative definitions [PR26581]

Before C2y, a tentative definition (file-scope, not extern, no
initializer) with internal linkage and incomplete type was undefined
behavior ("shall" outside Constraints violated).  In C2y, this has
changed to a constraint violation if the type has not been completed
by the end of the translation unit, and is valid if the type has been
completed by the end of the translation unit.  This change originates
from N3347 but the wording accepted into C2y was that from reflector
message 26758.

In GCC, the case of incomplete array types was a hard error with
-pedantic, rather than a pedwarn, contrary to how -pedantic is
supposed to behave; bug 26581 requested a change to allow this case
with -pedantic (i.e. the change made in C2y).  For incomplete structs
and unions, GCC only diagnoses them if the type remains incomplete at
the end of the translation unit; bug 88727 (*not* fixed here) requests
the case where the type gets completed should also be diagnosed as a
quality of implementation matter (and that bug is still applicable for
pre-C2y langauge versions and -Wc23-c2y-compat).

Change the handling of arrays following C2y; the previous error
becomes a pedwarn_c23 while there is a new error at the end of the
translation unit if the type remains incomplete there in C2y mode.

There is an ambiguity in the wording in C2y for the case where the
type gets completed only in an inner scope; I've raised that in
reflector message 34118.

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

PR c/26581

gcc/c/
* c-decl.cc (c_finish_incomplete_decl): Give error for tentative
definition of incomplete array for C2y with internal linkage.
(finish_decl): Do not set DO_DEFAULT based on -pedantic.  Use
pedwarn_c23 for missing array sizes for internal linkage.

gcc/testsuite/
* gcc.dg/c23-incomplete-2.c, gcc.dg/c23-incomplete-3.c,
gcc.dg/c23-incomplete-4.c, gcc.dg/c2y-incomplete-4.c,
gcc.dg/c2y-incomplete-5.c: New tests.
* gcc.dg/c23-thread-local-2.c, gcc.dg/c2y-incomplete-1.c: Update
expected errors.

4 weeks agolibbid: Set rounding mode to round-to-nearest for _Decimal128 arithmetic
H.J. Lu [Sat, 30 Aug 2025 18:46:31 +0000 (11:46 -0700)] 
libbid: Set rounding mode to round-to-nearest for _Decimal128 arithmetic

Since _Decimal128 arithmetic requires the round-to-nearest rounding
mode, define DFP_INIT_ROUNDMODE and DFP_RESTORE_ROUNDMODE, similar to
FP_INIT_ROUNDMODE in sfp-machine.h, to set the rounding mode to
round-to-nearest at _Decimal128 related arithmetic function entrances
and restores it upon return.  This doesn't require linking with libm
when libgcc is used.

libgcc/

PR target/120691
* Makefile.in (DECNUMINC): Add -I$(srcdir)/config/$(cpu_type).
* config/i386/dfp-machine.h: New file.
* config/i386/32/dfp-machine.h: Likewise.
* config/i386/64/dfp-machine.h: Likewise.

libgcc/config/libbid/

PR target/120691
* bid128_div.c: Run DFP_INIT_ROUNDMODE at function entrace and
DFP_RESTORE_ROUNDMODE at function exit.
* bid128_rem.c: Likewise.
* bid128_sqrt.c: Likewise.
* bid64_div.c (bid64_div): Likewise.
* bid64_sqrt.c (bid64_sqrt): Likewise.
* bid_conf.h: Include <dfp-machine.h>.
* dfp-machine.h: New file.

gcc/testsuite/

PR target/120691
* gcc.target/i386/pr120691.c: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
4 weeks agoc++: new-expr clobber of constant-size array
Jason Merrill [Sat, 4 Oct 2025 08:24:29 +0000 (09:24 +0100)] 
c++: new-expr clobber of constant-size array

I previously tried to clobber an array as a whole, but fell back on a loop
due to issues with std::construct_at following the resolution of LWG3436.
But the loop seems to make life hard for the optimizers and it occurs to me
that for a one-element array we can just clobber the element type.

This also fixes some xfails in Warray-bounds-20.C.

gcc/cp/ChangeLog:

* init.cc (build_new_1): Clobber a constant-bound array as a whole.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Warray-bounds-20.C: Remove xfails, add diags.

4 weeks agodocs: Add documentation for TARGET_HAS_FMV_TARGET_ATTRIBUTE macro
Alfie Richards [Wed, 13 Aug 2025 20:13:28 +0000 (20:13 +0000)] 
docs: Add documentation for TARGET_HAS_FMV_TARGET_ATTRIBUTE macro

Adds documentation for the TARGET_HAS_FMV_TARGET_ATTRIBUTE macro hook.

gcc/ChangeLog:

* doc/tm.texi: Regenerate.
* doc/tm.texi.in: Add documentation for TARGET_HAS_FMV_TARGET_ATTRIBUTE.

4 weeks agoAVR: target/122187 - Don't clobber recog_data.operand[] in insn out.
Georg-Johann Lay [Tue, 7 Oct 2025 15:50:34 +0000 (17:50 +0200)] 
AVR: target/122187 - Don't clobber recog_data.operand[] in insn out.

avr.cc::avr_out_extr() and avr.cc::avr_out_extr_not()
changed xop for output, which spoiled the operand for
the next invokation, running into an assertion.

This patch makes a local copy of the operands.

PR target/122187
gcc/
* config/avr/avr.cc (avr_out_extr, avr_out_extr_not):
Make a local copy of the passed rtx[] operands.

gcc/testsuite/
* gcc.target/avr/torture/pr122187.c: New test.

4 weeks agoall: Fix "specifc", "costant" and "constat" typos in comments
Jonathan Wakely [Tue, 7 Oct 2025 14:00:24 +0000 (15:00 +0100)] 
all: Fix "specifc", "costant" and "constat" typos in comments

gcc/ChangeLog:

* config/i386/i386-features.cc
(general_scalar_chain::vector_const_cost): Fix spelling in
comment.
* ipa-prop.h (enum jump_func_type): Likewise.
* tree-vectorizer.cc (try_vectorize_loop_1): Likewise.

gcc/cp/ChangeLog:

* module.cc (trees_out::lang_vals): Fix spelling in comment.

gcc/jit/ChangeLog:

* docs/_build/texinfo/libgccjit.texi: Fix spelling.
* docs/internals/index.rst: Likewise.

libgm2/ChangeLog:

* configure.host: Fix spelling in comment.

libstdc++-v3/ChangeLog:

* configure.host: Fix spelling in comment.

gcc/testsuite/ChangeLog:

* gfortran.dg/dynamic_dispatch_9.f03: Fix spelling in comment.
* gfortran.dg/use_only_3.inc: Likewise

4 weeks ago[PATCH] RISC-V: Detect wrap in shuffle_series_pattern [PR121845].
Robin Dapp [Tue, 7 Oct 2025 13:18:27 +0000 (07:18 -0600)] 
[PATCH] RISC-V: Detect wrap in shuffle_series_pattern [PR121845].

Hi,

In shuffle_series_pattern we use series_p to determine if the permute
mask is a simple series.  This didn't take into account that series_p
also returns true for e.g. {0, 3, 2, 1} where the step is 3 and the
indices form a series modulo 4.

We emit
 vid + vmul
in order to synthesize a series.  In order to be always correct we would
need a vrem afterwards still which does not seem worth it.

This patch adds the modulo for VLA permutes and punts if we wrap around
for VLS permutes.  I'm not really certain whether we'll really see a wrapping
VLA series (certainly we haven't so far in the test suite) but as we observed
a VLS one here now it appears conservatively correct to module the indices.

Regtested on rv64gcv_zvl512b.

Regards
 Robin

PR target/121845

gcc/ChangeLog:

* config/riscv/riscv-v.cc (shuffle_series_patterns):
Modulo indices for VLA and punt when wrapping for VLS.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr121845.c: New test.

4 weeks ago[PATCH] RISC-V: Fix slide pattern recognition [PR122124]
Raphael Moreira Zinsly [Tue, 7 Oct 2025 13:14:01 +0000 (07:14 -0600)] 
[PATCH] RISC-V: Fix slide pattern recognition [PR122124]

Ensure the second pivot is really a pivot and it's not in OP1.

PR target/122124
gcc/ChangeLog:
* config/riscv/riscv-v.cc (shuffle_slide_patterns): Check if
the second pivot is in OP1 and improve comments.

gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/pr122124.c: New test.

4 weeks agoFortran: Fix ICE in pdt_1[3-5].f03 with -fcheck=all [PR102901]
Paul Thomas [Tue, 7 Oct 2025 12:30:43 +0000 (13:30 +0100)] 
Fortran: Fix ICE in pdt_1[3-5].f03 with -fcheck=all [PR102901]

2025-10-07  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/102901
* trans-array.cc (structure_alloc_comps): Do not use
gfc_check_pdt_dummy with pointer or allocatable components.

gcc/testsuite/
PR fortran/102901
* gfortran.dg/pdt_56.f03: Copy of pdt_13.f03 compiled with
-fcheck=all.

4 weeks agolibstdc++: Initialize local variable in __gnu_cxx::rope
Jonathan Wakely [Wed, 1 Oct 2025 14:12:35 +0000 (15:12 +0100)] 
libstdc++: Initialize local variable in __gnu_cxx::rope

This avoids -Wmaybe-uninitialized warnings.

libstdc++-v3/ChangeLog:

* include/ext/ropeimpl.h (rope::_S_fetch): Initialize variable.

4 weeks agolibstdc++: Fix -Wparentheses warning in std::mul_sat
Jonathan Wakely [Wed, 1 Oct 2025 12:53:14 +0000 (13:53 +0100)] 
libstdc++: Fix -Wparentheses warning in std::mul_sat

libstdc++-v3/ChangeLog:

* include/bits/sat_arith.h (mul_sat): Add parentheses around
operands.

4 weeks agolibstdc++: Fix -Wmaybe-uninitialized warning in another test
Jonathan Wakely [Wed, 1 Oct 2025 12:51:55 +0000 (13:51 +0100)] 
libstdc++: Fix -Wmaybe-uninitialized warning in another test

Like r16-4120-ge1b9ccaa10df01 this is a false positive, but we can just
initialize the variable.

libstdc++-v3/ChangeLog:

* testsuite/std/time/parse/parse.cc: Initialize variable.

4 weeks agolibstdc++: Suppress -Wpessimizing-move warnings in shared_ptr tests
Jonathan Wakely [Thu, 2 Oct 2025 15:37:33 +0000 (16:37 +0100)] 
libstdc++: Suppress -Wpessimizing-move warnings in shared_ptr tests

libstdc++-v3/ChangeLog:

* testsuite/20_util/shared_ptr/cons/move.cc: Add comment and
dg-prune-output for -Wpessimizing-move warning.
* testsuite/experimental/memory/shared_ptr/cons/move_ctor.cc:
Likewise.

4 weeks agolibstdc++: Fix -Wreorder warning in std::philox_engine
Jonathan Wakely [Wed, 1 Oct 2025 12:48:18 +0000 (13:48 +0100)] 
libstdc++: Fix -Wreorder warning in std::philox_engine

libstdc++-v3/ChangeLog:

* include/bits/random.h (philox_engine(result_type)): Reorder
ctor-initializer-list to match declaration order.

4 weeks agolibstdc++: Fix -Wformat warning in std::string
Jonathan Wakely [Wed, 1 Oct 2025 12:31:59 +0000 (13:31 +0100)] 
libstdc++: Fix -Wformat warning in std::string

The __throw_out_of_range_fmt function works like fprintf and so the
arguments corresponding to %zu specifiers need to be size_t. The
std::basic_string<C,T,A>::size_type type is A::size_type which is not
necessarily size_t. Add explicit casts to avoid a -Wformat warning with
-Wsystem-headers.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h (basic_string::_M_check): Cast
size_type arguments to size_t.

4 weeks agoRevert "Ada: Remove useless Makefile variable"
Eric Botcazou [Tue, 7 Oct 2025 07:51:37 +0000 (09:51 +0200)] 
Revert "Ada: Remove useless Makefile variable"

This reverts commit 49aed8ceb5d3ee8af96ebd7edd5d250b682697cd.

4 weeks agomatch: Extend `-(a ptrdiff b)` pattern by allowing a nop conversion between the neg...
Andrew Pinski [Sun, 5 Oct 2025 16:08:15 +0000 (09:08 -0700)] 
match: Extend `-(a ptrdiff b)` pattern by allowing a nop conversion between the neg and ptrdiff [PR121921]

When I tried to fix this before I didn't realize there was already a pattern for
`-(a ptrdiff b) -> (b ptrdiff a)`, I had added a complex pattern to match `ptr0 - (ptr0 - ptr1)`.
But with there being a pattern for `-(a ptrdiff b)`, we just need to extend the pattern
to support a nop conversion inbetween the negative and the ptrdiff.
Also the check for TYPE_OVERFLOW_UNDEFINED was wrong, in the case of `-(a - b) -> (b - a)`, the check
is !TYPE_OVERFLOW_SANITIZED so this pattern should use the same check.

Bootstrapped and tested on x86_64-linux-gnu.

Changes since v1:
* v2: Use the old type of the pointer_diff rather than ssizetype.

PR tree-optimization/121921

gcc/ChangeLog:

* match.pd (`-(a ptrdiff b)`): Extend for a nop_convert
between the neg and ptrdiff.

gcc/testsuite/ChangeLog:

* gcc.dg/pr121921-1.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 weeks agophiopt/cselim: Improve cselim-limited to commonalize all stores [PR122083]
Andrew Pinski [Sat, 4 Oct 2025 03:18:07 +0000 (20:18 -0700)] 
phiopt/cselim: Improve cselim-limited to commonalize all stores [PR122083]

cselim (and the phiopt's cselim-limited) can commonalize a single
store which makes this too limited in some/many cases. Instead let's
commonalize all trailing stores as much as possible (only in the same
order).
The change is smallish, basically the restriction on being the only store
is removed from single_trailing_store_in_bb (renamed too). And also
looping to remove all of the trailing stores instead of just doing one for
the pass.

Note sink will do the same optimization so doing it earlier seems like a good
idea because it improve change inlining size estimates.
For an example with this change, early inlining can happen for min_cmp<long int>
in g++.dg/opt/pr122083-1.C now; that avoids a -Wnonnull warning as the memcmp with
the null argument is optimized early. It can also catch some min in phiopt1 in some
cases.

Bootstrapped and tested on x86_64-linux-gnu.

Changes since v1:
* v2: For !flag_expensive_optimizations, handle the only store rather than just the last
      store.

PR tree-optimization/122083

gcc/ChangeLog:

* tree-ssa-phiopt.cc (single_trailing_store_in_bb): Rename to ...
(trailing_store_in_bb): This and take new argument to check for
only store.
(cond_if_else_store_replacement_limited): Update to use
trailing_store_in_bb.
(cond_if_else_store_replacement): Loop until
cond_if_else_store_replacement_limited returns false.
(pass_phiopt::execute): Instead of calling cond_if_else_store_replacement_limited
once, also loop on it.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/ssa-pre-19.c: Disable phiopt and cselim.
* g++.dg/opt/pr122083-1.C: New test.
* gcc.dg/tree-ssa/cselim-1.c: New test.
* gcc.dg/tree-ssa/cselim-2.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 weeks agox86: Swap %edx/%rdx with %eax/%rax for PR middle-end/122122
H.J. Lu [Tue, 7 Oct 2025 00:28:04 +0000 (08:28 +0800)] 
x86: Swap %edx/%rdx with %eax/%rax for PR middle-end/122122

Swap %edx/%rdx with %eax/%rax after

commit r16-4255-g075310d3a3ef1a8b483b62d9535887b37f291ee4
Author: Jan Hubicka <hubicka@ucw.cz>
Date:   Mon Oct 6 21:35:22 2025 +0200

    Update profile in tree-ssa-dce

commit 8498ef3d0758012bf3e355a61a0f89aff7513851
Author: Jan Hubicka <hubicka@ucw.cz>
Date:   Wed Oct 1 16:56:15 2025 +0200

    Improve profile update in merge_blocks

PR middle-end/122122
* gcc.target/i386/memcpy-pr120683-2.c: Swap %edx/%rdx with
%eax/%rax after
* gcc.target/i386/memcpy-pr120683-3.c: Likewise.
* gcc.target/i386/memcpy-pr120683-4.c: Likewise.
* gcc.target/i386/memcpy-pr120683-5.c: Likewise.
* gcc.target/i386/memcpy-pr120683-6.c: Likewise.
* gcc.target/i386/memcpy-pr120683-7.c: Likewise.
* gcc.target/i386/pr111657-1.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
4 weeks agoDaily bump.
GCC Administrator [Tue, 7 Oct 2025 00:21:28 +0000 (00:21 +0000)] 
Daily bump.

4 weeks agocselim: Don't create a phi node if the rhs side are the same [PR122155]
Andrew Pinski [Sat, 4 Oct 2025 17:16:20 +0000 (10:16 -0700)] 
cselim: Don't create a phi node if the rhs side are the same [PR122155]

This is a small compile time optimization where if commonalizing stores
that have the same rhs, a phi node does not need to be created.
This uses the same code as what was added for the `= {};` case.
The reason why it is a compile time optimization is that Copy prop
later on will do the same thing so not creating a new phi and a new
ssa name will have a small compile time improvement.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/122155

gcc/ChangeLog:

* tree-ssa-phiopt.cc (cond_if_else_store_replacement_1): Don't
create a phi if the 2 rhs are the same.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 weeks agoAVR/LibF7: Implement sincos.
Georg-Johann Lay [Mon, 6 Oct 2025 19:31:46 +0000 (21:31 +0200)] 
AVR/LibF7: Implement sincos.

libgcc/config/avr/libf7/
* libf7-common.mk (F7_ASM_PARTS): Add D_sincos.
* libf7-asm.sx: (D_sincos): New module implements sincos / sincosl.

gcc/testsuite/
* gcc.target/avr/sincos-1.c: New test.

4 weeks agoUpdate profile in tree-ssa-dce
Jan Hubicka [Mon, 6 Oct 2025 19:35:22 +0000 (21:35 +0200)] 
Update profile in tree-ssa-dce

The profile mismatches uncovered by my merge_blocks change are actually caused
by tree-ssa-dce not updating profile of blocks with no statements for whose it
optimized away control dependencies.  In most cases those basic blocks are
merged or skipped as forwarders.  I tried to simply set their count as
uninitialized but that upsets verifier since in some cases we keep the block
around (for example, when it is header of a loop).

In all cases I debugged we optimized away an unnecesary loop and while merging
old code picked porfile of loop preheader, while we now pick loop header.  This
is however not guaranteed and we may process blocks in different order and pick
wrong profile.

Since regions of dead basic blocks must be acyclic it is easy to propagate the
frequencies as implemented by this patch.

Bootstrapped/regtested x86_64-linux. Comitted

gcc/ChangeLog:

PR middle-end/122122
* tree-cfgcleanup.cc (tree_forwarder_block_p): Cleanup.
* tree-ssa-dce.cc (propagate_counts): New function.
(eliminate_unnecessary_stmts): Use it.

4 weeks agoFix description of --param auto-profile-bbs
Jan Hubicka [Thu, 2 Oct 2025 10:12:05 +0000 (12:12 +0200)] 
Fix description of --param auto-profile-bbs

gcc/ChangeLog:

* params.opt (-param=auto-profile-bbs=): Add missing full stop after
description.

4 weeks agoIf a range's bitmask changes, reflect it in the bounds.
Andrew MacLeod [Thu, 2 Oct 2025 15:51:01 +0000 (11:51 -0400)] 
If a range's bitmask changes, reflect it in the bounds.

Rather than trying to be smart, if the bitmask changes, adjust all range
bounds to satisfy the bitmask requirements.

PR tree-optimization/121206
gcc/
* value-range.cc (irange::intersect_bitmask): Always call
set_range_from_bitmask if the bitmask changes.

gcc/testsuite
* gcc.dg/pr121987.c: New.

4 weeks agodoc: mention STAGE1_CFLAGS
Sam James [Wed, 14 Aug 2024 12:15:30 +0000 (13:15 +0100)] 
doc: mention STAGE1_CFLAGS

STAGE1_CFLAGS can be used to accelerate the just-built stage1 compiler
which especially improves its performance on some of the large generated
files during bootstrap. It defaults to nothing (i.e. -O0).

The downside is that if the native compiler is buggy, there's a greater
risk of a failed bootstrap. Those with a modern native compiler, ideally
a recent version of GCC, should be able to use -O1 or -O2 without issue
to get a faster build.

PR rtl-optimization/111619
* doc/install.texi (Building a native compiler): Discuss STAGE1_CFLAGS.

4 weeks agoAVR/LibF7: target/122177 - fix fmin / fmax return value for one NaN arg.
Georg-Johann Lay [Sun, 5 Oct 2025 18:56:56 +0000 (20:56 +0200)] 
AVR/LibF7: target/122177 - fix fmin / fmax return value for one NaN arg.

fmin and fmax should return the non-NaN argument in the case where
exactly one argument is a NaN.

Moreover, IEEE double fmin and fmax can be performed without
first converting the args to the internal representation and
then converting back again.

PR target/122177
libgcc/config/avr/libf7/
* libf7-common.mk (m_ddd): Remove: fmin, fmax.
(F7_ASM_PARTS): Add: D_fminfmax.
* libf7-asm.sx (D_fmanfmax): New module.
* f7-wraps.h: Rebuild.

gcc/testsuite/
* gcc.target/avr/fminfmax-1.c: New test.

4 weeks agoAVR: Speed up IEEE double comparisons.
Georg-Johann Lay [Sun, 5 Oct 2025 18:56:56 +0000 (20:56 +0200)] 
AVR: Speed up IEEE double comparisons.

IEEE double can be compared without first converting them to
the internal representation.

libgcc/config/avr/libf7/
* libf7-common.mk (g_xdd_cmp): Remove le, lt, ge, gt, ne, eq, unord.
(F7_ASM_PARTS): Add D_cmp, D_eq, D_ne, D_ge, D_gt, D_le, D_lt, D_unord.
* libf7-asm.sx (D_cmp, D_eq, D_ne, D_ge, D_gt, D_le, D_lt, D_unord):
New modules.
* f7-wraps.h: Rebuild.

gcc/testsuite/
* gcc.target/avr/cmpdi-1.c: New test.

4 weeks agoaarch64: Fix ICE when op2 is zero for SVE2 saturating add intrinsics.
Jennifer Schmitz [Thu, 21 Aug 2025 17:01:49 +0000 (10:01 -0700)] 
aarch64: Fix ICE when op2 is zero for SVE2 saturating add intrinsics.

When op2 in SVE2 saturating add intrinsics (svuqadd, svsqadd) is a zero
vector and predication is _z, an ICE in vregs occurs, e.g. for

svuint8_t foo (svbool_t pg, svuint8_t op1)
{
    return svsqadd_u8_z (pg, op1, svdup_s8 (0));
}

The insn failed to match the pattern (aarch64-sve2.md):

;; Predicated binary operations with no reverse form, merging with zero.
;; At present we don't generate these patterns via a cond_* optab,
;; so there's no correctness requirement to handle merging with an
;; independent value.
(define_insn_and_rewrite "*cond_<sve_int_op><mode>_z"
  [(set (match_operand:SVE_FULL_I 0 "register_operand")
(unspec:SVE_FULL_I
  [(match_operand:<VPRED> 1 "register_operand")
   (unspec:SVE_FULL_I
     [(match_operand 5)
      (unspec:SVE_FULL_I
[(match_operand:SVE_FULL_I 2 "register_operand")
 (match_operand:SVE_FULL_I 3 "register_operand")]
SVE2_COND_INT_BINARY_NOREV)]
     UNSPEC_PRED_X)
   (match_operand:SVE_FULL_I 4 "aarch64_simd_imm_zero")]
  UNSPEC_SEL))]
  "TARGET_SVE2"
  {@ [ cons: =0 , 1   , 2 , 3  ]
     [ &w       , Upl , 0 , w  ] movprfx\t%0.<Vetype>, %1/z, %0.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
     [ &w       , Upl , w , w  ] movprfx\t%0.<Vetype>, %1/z, %2.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
  }
  "&& !CONSTANT_P (operands[5])"
  {
    operands[5] = CONSTM1_RTX (<VPRED>mode);
  }
  [(set_attr "movprfx" "yes")]
)

because operands[3] and operands[4] were both expanded into the same register
operand containing a zero vector by define_expand "@cond_<sve_int_op><mode>".

This patch fixes the ICE by making a case distinction in
function_expander::use_cond_insn that uses add_fixed_operand if
fallback_arg == CONST0_RTX (mode), and otherwise add_input_operand (which was
previously the default and allowed the expansion of the zero-vector
fallback_arg to a register operand).

The patch was bootstrapped and tested on aarch64-linux-gnu, no regression.
OK for trunk?

Alex Coplan pointed out in the bugzilla ticket that this ICE goes back
to GCC 10. Shall we backport?

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
Co-authored by: Richard Sandiford <rdsandiford@googlemail.com>

gcc/
PR target/121599
* config/aarch64/aarch64-sve-builtins.cc
(function_expander::use_cond_insn): Use add_fixed_operand if
fallback_arg == CONST0_RTX (mode).

gcc/testsuite/
PR target/121599
* gcc.target/aarch64/sve2/pr121599.c: New test.

4 weeks agotree-optimization/122131 - do not use re-align load for gathers
Richard Biener [Mon, 6 Oct 2025 07:53:07 +0000 (09:53 +0200)] 
tree-optimization/122131 - do not use re-align load for gathers

As we now ask vect_supportable_dr_alignment for gathers avoid using
(optimized) re-align instructions for them.

PR tree-optimization/122131
* tree-vect-data-refs.cc (vect_supportable_dr_alignment): Do
not use re-align loads for gathers.

* gcc.target/powerpc/altivec-39.c: New testcase.

4 weeks agoada: Fix handling of Extended_Access with array subtype
Marc Poulhiès [Mon, 22 Sep 2025 08:57:13 +0000 (10:57 +0200)] 
ada: Fix handling of Extended_Access with array subtype

For array subtypes, return the extended types corresponding to the array
type.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (get_extended_unconstrained_array): Handle
array subtype.

Co-authored-by: Éric Botcazou <botcazou@adacore.com>
4 weeks agoada: Implement proper upcasting in more cases
Eric Botcazou [Wed, 24 Sep 2025 17:02:34 +0000 (19:02 +0200)] 
ada: Implement proper upcasting in more cases

Upcasting (conversion from a tagged type extension to one of its parents)
is represented as a simple N_Type_Conversion node in the expanded code,
but translating it into a VIEW_CONVERT_EXPR is a bit problematic because
source and target types of the GCC node are supposed to have the same size
(at least in "non-pathological" cases).

That's why Gigi attempts to build an explicit chain of references to the
appropriate _Parent (sub)component instead, but it currently does that
only for simple (i.e. non-discriminated) tagged types.  This can be easily
extended to discriminated tagged types in not-too-dynamic cases (an example
is the ACATS c391002 test).

gcc/ada/ChangeLog:

* gcc-interface/utils.cc (convert): Also extract the _Parent field
to implement upcasting in the case where only the sizes match.

4 weeks agoada: Fix extended access and memory pool explicit deref
Marc Poulhiès [Tue, 16 Sep 2025 13:07:29 +0000 (15:07 +0200)] 
ada: Fix extended access and memory pool explicit deref

Explicit dereference of an extended access with data allocation in a
memory pool would crash the compiler.

gcc/ada/ChangeLog:

* gcc-interface/trans.cc (Attribute_to_gnu)<Attr_Pool_Address>: Handle
extended access.

4 weeks agoada: Fix usage of Table.Table in Fmap
Ronan Desplanques [Thu, 25 Sep 2025 07:53:35 +0000 (09:53 +0200)] 
ada: Fix usage of Table.Table in Fmap

Table.Table can be instantiated to use either 0-based or 1-based
indexing, which can cause some confusion and make 0-based instances get
used as 1-based ones.

This was the case for two tables in Fmap before this patch. That did not
cause any bugs but allocated an extra cell in the arrays that went
unused.

This patch also replaces Increment_Last-and-assignment combos with
equivalent calls to Append.

gcc/ada/ChangeLog:

* fmap.adb (File_Mapping, Path_Mapping): Fix instantiations.
(Add_To_File_Map): Use Table.Table.Append.

4 weeks agoada: Remove obsolete code
Ronan Desplanques [Wed, 24 Sep 2025 12:53:18 +0000 (14:53 +0200)] 
ada: Remove obsolete code

This patch removes code that has been unused since the project manager
infrastructure was retired.

gcc/ada/ChangeLog:

* fmap.ads (Add_Forbidden_File_Name): Remove obsolete code.
* fmap.adb (Forbidden_Names, Add_Forbidden_File_Name,
Mapped_Path_Name, Reset_Tables): Remove obsolete code.

4 weeks agoada: Refine documentation of -gnatwr
Tonu Naks [Thu, 18 Sep 2025 07:18:08 +0000 (10:18 +0300)] 
ada: Refine documentation of -gnatwr

gcc/ada/ChangeLog:

* doc/gnat_ugn/building_executable_programs_with_gnat.rst: refine
description of -gnatwr
* gnat_ugn.texi: Regenerate.

4 weeks agotree-optimization/122158 - vector reduction epilog for bit-precision result
Richard Biener [Mon, 6 Oct 2025 07:06:45 +0000 (09:06 +0200)] 
tree-optimization/122158 - vector reduction epilog for bit-precision result

The following makes sure to perform the vector element extraction
using the element type and convert to the original, possibly
bit-precision, result afterwards.  I've also used gimple_build
for the BIT_FIELD_REF since that simplifies the code.

PR tree-optimization/122158
* tree-vect-loop.cc (vect_create_epilog_for_reduction): Handle
bit-precision result.

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

4 weeks agostmt: Handle %cc[name] in resolve_asm_operand_names [PR122133]
Jakub Jelinek [Mon, 6 Oct 2025 07:46:48 +0000 (09:46 +0200)] 
stmt: Handle %cc[name] in resolve_asm_operand_names [PR122133]

Last year I've extended the asm template syntax in inline asm to support
%cc0 etc., apparently the first 2 letter generic operand modifier.
As the following testcase shows, I forgot to tweak the [foo] handling
for it though.  As final.cc will error on any % ISALPHA not followed by
digit (with the exception of % c c digit), I think we can safely handle
this for any 2 letters in between % and [, instead of hardcoding it for
now only for %cc[ and changing it again next time we add something
two-letter.

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

PR middle-end/122133
* stmt.cc (resolve_asm_operand_names): Handle % and 2 letters followed
by open square.

* c-c++-common/toplevel-asm-9.c: New test.

4 weeks agoIntroduce fold_before_rtl_expansion_p [PR122142]
Andrew Pinski [Fri, 3 Oct 2025 16:54:45 +0000 (09:54 -0700)] 
Introduce fold_before_rtl_expansion_p [PR122142]

As requested in https://inbox.sourceware.org/gcc-patches/CAFiYyc1jzZSZNhTas-DdMBFOzH1p96oGN=OVj6fyjt8HzDUyCA@mail.gmail.com/T/#u.
This introduces fold_before_rtl_expansion_p to replace
`(cfun->curr_properties & PROP_last_full_fold) != 0`.
I am not a fan of include tree-pass.h in gimple-fold.h but that was the
only way to reduce the number of changes.

Bootrapped and tested on x86_64-linux-gnu.

PR tree-optimization/122142
gcc/ChangeLog:

* generic-match-head.cc: Include gimple-iterator.h
and gimple-fold.h.
* gimple-fold.cc (gimple_fold_builtin_constant_p): Use
fold_before_rtl_expansion_p.
(gimple_fold_builtin_assume_aligned): Likewise.
(gimple_fold_builtin_stdarg): Likewise.
(gimple_fold_call): Likewise.
* gimple-fold.h: Include "tree-pass.h".
(fold_before_rtl_expansion_p): New function.
* match.pd: Use fold_before_rtl_expansion_p
instead of `cfun->curr_properties & PROP_last_full_fold`.
* tree-ssa-forwprop.cc (simplify_builtin_memcmp): Likewise.
(optimize_stack_restore): Likewise.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 weeks agoDaily bump.
GCC Administrator [Mon, 6 Oct 2025 00:17:42 +0000 (00:17 +0000)] 
Daily bump.

4 weeks agox86: Handle small OP size in setmem_epilogue_gen_val
H.J. Lu [Fri, 3 Oct 2025 23:02:20 +0000 (07:02 +0800)] 
x86: Handle small OP size in setmem_epilogue_gen_val

Since OP size passed to setmem_epilogue_gen_val may be smaller than the
required vector size, duplicate it first before setting vector.

gcc/

PR target/122150
* config/i386/i386-expand.cc (setmem_epilogue_gen_val): Duplicate
OP if its size is smaller than MODE size.

gcc/testsuite/

PR target/122150
* gcc.target/i386/pr122150.c: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
4 weeks agoDisable some testcase for -Og
Andrew Pinski [Sun, 5 Oct 2025 20:30:49 +0000 (13:30 -0700)] 
Disable some testcase for -Og

Running the testsuite with ADDITIONAL_TORTURE_OPTIONS set include "-Og -g",
there are a few extra failures in the torture testsuite. These 2 failures
are expected so let's skip them in the same way for -O0.

asm-inline.c is because inlining does not happen as much at -Og.
restrict-8.c fails due to not building the points to aliasing info at -Og.

gcc/testsuite/ChangeLog:

* c-c++-common/torture/asm-inline.c: Disable at -Og.
* gcc.dg/torture/restrict-8.c: Likewise.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 weeks agohppa: Fix over alignment of 64-bit functions
John David Anglin [Sun, 5 Oct 2025 16:52:28 +0000 (12:52 -0400)] 
hppa: Fix over alignment of 64-bit functions

Both 32 and 64-bit assembly code needs 32-bit alignment.

2025-10-05  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

* config/pa/pa.h (FUNCTION_BOUNDARY): Set to 32.

4 weeks agoDaily bump.
GCC Administrator [Sun, 5 Oct 2025 16:50:51 +0000 (16:50 +0000)] 
Daily bump.

4 weeks agocontrib: Ignore commit b40ef6e9dc09 Sync toplevel files from binutils-gdb
Mark Wielaard [Sun, 5 Oct 2025 16:26:43 +0000 (18:26 +0200)] 
contrib: Ignore commit b40ef6e9dc09 Sync toplevel files from binutils-gdb

contrib/ChangeLog:

* gcc-changelog/git_update_version.py (ignored_commits): Add
commit b40ef6e9dc096c8c19399e94947a1965258a6942.

4 weeks ago*: regenerate autotools
Sam James [Sun, 5 Oct 2025 16:12:21 +0000 (17:12 +0100)] 
*: regenerate autotools

libatomic/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* testsuite/Makefile.in: Regenerate.

libcc1/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.

libffi/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* include/Makefile.in: Regenerate.
* man/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.

libgcobol/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.

libgfortran/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.

libgm2/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* libm2cor/Makefile.in: Regenerate.
* libm2iso/Makefile.in: Regenerate.
* libm2log/Makefile.in: Regenerate.
* libm2min/Makefile.in: Regenerate.
* libm2pim/Makefile.in: Regenerate.

libgomp/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* testsuite/Makefile.in: Regenerate.

libgrust/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* libformat_parser/Makefile.in: Regenerate.
* libproc_macro_internal/Makefile.in: Regenerate.

libitm/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* testsuite/Makefile.in: Regenerate.

libobjc/ChangeLog:

* aclocal.m4: Regenerate.
* configure: Regenerate.

libphobos/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* libdruntime/Makefile.in: Regenerate.
* src/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.

libquadmath/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.

libsanitizer/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* asan/Makefile.in: Regenerate.
* configure: Regenerate.
* hwasan/Makefile.in: Regenerate.
* interception/Makefile.in: Regenerate.
* libbacktrace/Makefile.in: Regenerate.
* lsan/Makefile.in: Regenerate.
* sanitizer_common/Makefile.in: Regenerate.
* tsan/Makefile.in: Regenerate.
* ubsan/Makefile.in: Regenerate.

libssp/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.

libstdc++-v3/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* doc/Makefile.in: Regenerate.
* include/Makefile.in: Regenerate.
* libsupc++/Makefile.in: Regenerate.
* po/Makefile.in: Regenerate.
* python/Makefile.in: Regenerate.
* src/Makefile.in: Regenerate.
* src/c++11/Makefile.in: Regenerate.
* src/c++17/Makefile.in: Regenerate.
* src/c++20/Makefile.in: Regenerate.
* src/c++23/Makefile.in: Regenerate.
* src/c++26/Makefile.in: Regenerate.
* src/c++98/Makefile.in: Regenerate.
* src/experimental/Makefile.in: Regenerate.
* src/filesystem/Makefile.in: Regenerate.
* src/libbacktrace/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.

libvtv/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* testsuite/Makefile.in: Regenerate.

lto-plugin/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.

4 weeks agoRISC-V: Combine vec_duplicate + vwaddu.wv to vwaddu.wx on GR2VR cost
Pan Li [Fri, 26 Sep 2025 15:08:20 +0000 (23:08 +0800)] 
RISC-V: Combine vec_duplicate + vwaddu.wv to vwaddu.wx on GR2VR cost

This patch would like to combine the vec_duplicate + vwaddu.wv to the
vwaddu.wx.  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       vwaddu.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       vwaddu.wx v1,a2,v3
  ...
  23       bne a3,zero,.L3

Unfortunately, and similar as vwaddu.vv, only widening from uint32_t to
uint64_t has the necessary zero-extend during combine, we loss the extend
op after expand for any other types.

gcc/ChangeLog:

* config/riscv/autovec-opt.md (*widen_waddu_wx_<mode>): Add new
pattern to match vwaddu.wx.

Signed-off-by: Pan Li <pan2.li@intel.com>
4 weeks agoMatch: Refactor unsigned SAT_MUL form 1 mul and widen-mul by for [NFC]
Pan Li [Thu, 25 Sep 2025 04:59:07 +0000 (12:59 +0800)] 
Match: Refactor unsigned SAT_MUL form 1 mul and widen-mul by for [NFC]

Inspired by the previous patch, the form 1 of unsigned SAT_MUL
can be mul or widen-mul based.  So we can leverage the keyword
for to group it, and avoid the pattern duplication.

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

gcc/ChangeLog:

* match.pd: Refactor the form 1 of SAT_MUL by keyword for.

Signed-off-by: Pan Li <pan2.li@intel.com>
4 weeks agoISC-V: Add test for vec_duplicate + vwaddu.wv signed combine with GR2VR cost 0, 1...
Pan Li [Fri, 26 Sep 2025 15:12:27 +0000 (23:12 +0800)] 
ISC-V: Add test for vec_duplicate + vwaddu.wv signed combine with GR2VR cost 0, 1 and 15

Add asm dump check and run test for vec_duplicate + vwaddu.wv
combine to vwaddu.wx, 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 vwaddu.wx.
* 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-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-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_widen.h: Add test helper
macros.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_widen_data.h: Add test
helper macros and data.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_widen_wx_run.h: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/wx_vwaddu-run-1-u64.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
4 weeks agoc++/modules: Avoid ICE when redefining a type reachable via import [PR122053]
Nathaniel Shead [Fri, 26 Sep 2025 12:10:15 +0000 (22:10 +1000)] 
c++/modules: Avoid ICE when redefining a type reachable via import [PR122053]

This shouldn't be an error (see PR c++/99000), but we can at least avoid
the ICE by ensuring that we load any pending type definition before
calling pushdecl, so that we error before committing to filling in the
class definition.

Something like this will probably still be helpful even for implementing
textual deduplication as we now at least ensure check_module_override is
called for this case.

PR c++/122053

gcc/cp/ChangeLog:

* name-lookup.cc (pushtag): Load any imported definition of type
before calling pushdecl.

gcc/testsuite/ChangeLog:

* g++.dg/modules/pr122053_a.C: New test.
* g++.dg/modules/pr122053_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
4 weeks agoc++/modules: Also check conflicting internal-linkage entities
Nathaniel Shead [Fri, 26 Sep 2025 12:03:24 +0000 (22:03 +1000)] 
c++/modules: Also check conflicting internal-linkage entities

While investigating another issue I noticed that the condition in
check_module_override seems incorrect: the wording in [basic.link] p11
has no exceptions for internal-linkage entities.

gcc/cp/ChangeLog:

* name-lookup.cc (check_module_override): Remove check for
TREE_PUBLIC when checking mergeable entities.

gcc/testsuite/ChangeLog:

* g++.dg/modules/namespace-1_c.C: Adjust to expect errors.
* g++.dg/modules/namespace-2_b.C: Likewise.
* g++.dg/modules/namespace-3_a.C: Removed.
* g++.dg/modules/namespace-3_b.C: Removed.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
4 weeks agoAda: Fix assertion failure on allocators for discriminated type with default
Franck Behaghel [Sun, 5 Oct 2025 10:17:10 +0000 (12:17 +0200)] 
Ada: Fix assertion failure on allocators for discriminated type with default

This is an incorrect node sharing for allocators built for a discriminated
type with default values.

gcc/ada/
PR ada/110314
* sem_ch4.adb (Analyze_Allocator): Add call to New_Copy_Tree.

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

4 weeks agoAda: Report that -gnatyz is included in -gnatyg
Eric Botcazou [Sun, 5 Oct 2025 09:10:17 +0000 (11:10 +0200)] 
Ada: Report that -gnatyz is included in -gnatyg

gcc/ada/
PR ada/112446
* usage.adb (Usage): Add 'z' to the list of 'g' style.

4 weeks agoAdd testcase for PR ada/113536
Eric Botcazou [Sun, 5 Oct 2025 08:42:25 +0000 (10:42 +0200)] 
Add testcase for PR ada/113536

gcc/testsuite/
PR ada/113536
* gnat.dg/reduce2.adb: New test.

4 weeks agoAda: Remove useless Makefile variable
Eric Botcazou [Sun, 5 Oct 2025 08:25:14 +0000 (10:25 +0200)] 
Ada: Remove useless Makefile variable

gcc/ada
PR ada/118343
* Makefile.rtl (LLVM_BUILD): Delete.

4 weeks agoFortran: fix issue with I/O of array pointer [PR107968]
Harald Anlauf [Fri, 3 Oct 2025 19:16:19 +0000 (21:16 +0200)] 
Fortran: fix issue with I/O of array pointer [PR107968]

PR fortran/107968

gcc/fortran/ChangeLog:

* trans-io.cc (gfc_trans_transfer): Also scalarize I/O of section
of an array pointer.

gcc/testsuite/ChangeLog:

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

4 weeks agoforwprop: Refine when TODO_update_address_taken is set [PR122143]
Andrew Pinski [Sat, 4 Oct 2025 00:51:33 +0000 (17:51 -0700)] 
forwprop: Refine when TODO_update_address_taken is set [PR122143]

As requested in https://inbox.sourceware.org/gcc-patches/CAFiYyc162F+i=majzQqutFcq1y=DtRoJVC4z+V3gP8N7uTnFLA@mail.gmail.com/T/#u.
This refines when TODO_update_address_taken is set so it only set when folding of a call.
This should speed up compile time slightly if we don't fold a call during the last forwprop.

Boostrapped and tested on x86_64-linux-gnu.

PR tree-optimization/122143
gcc/ChangeLog:

* tree-ssa-forwprop.cc (pass_forwprop::execute): Restrict setting
TODO_update_address_taken only when the statement was a call before fold_stmt.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 weeks agophiopt: allow store placement of `= {}` [PR122153]
Andrew Pinski [Fri, 3 Oct 2025 21:09:57 +0000 (14:09 -0700)] 
phiopt: allow store placement of `= {}` [PR122153]

Currently cselim and cselim-limited are able to
handle stores which have a rhs of a ssa name or a constant.
This extends that support to also allow `= {}`.
The sink pass will also commonalize the store but in some
cases this is too late in the pipeline. Doing it in phiopt1
allows for better inlining estimates too.

This is also the first step in improving/fixing PR 122083
such that we do an early inlining which is now not happening
for GCC 15+.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/122153

gcc/ChangeLog:

* tree-ssa-phiopt.cc (cond_if_else_store_replacement_1): Handle
stores of empty constructors too.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 weeks ago[PATCH][PR tree-optimization/117760] `a != b` implies that a or b is also non-zero
Matteo Nicoli [Sat, 4 Oct 2025 15:22:54 +0000 (09:22 -0600)] 
[PATCH][PR tree-optimization/117760] `a != b` implies that a or b is also non-zero

Implements a match.pd pattern to optimize the cases found in PR 117760.

PR tree-optimization/117760
gcc/
* match.pd: Add simplifications that exploit implied values after
logical tests.

gcc/testsuite
* gcc.dg/int-bwise-opt-1.c: New test.
* gcc.dg/int-bwise-opt-2.c: New test.

4 weeks agowidening_mul: Reset flow sensitive info in maybe_optimize_guarding_check [PR122104]
Jakub Jelinek [Sat, 4 Oct 2025 15:06:16 +0000 (17:06 +0200)] 
widening_mul: Reset flow sensitive info in maybe_optimize_guarding_check [PR122104]

In PR95852 I've added an optimization where next to just pattern
recognizing r = x * y; r / x != y or r = x * y; r / x == y
as .MUL_OVERFLOW or negation thereof it also recognizes
r = x * y; x && (r / x != y) or r = x * y; !x || (r / x == y)
by optimizing the guarding condition to always true/false.

The problem with that is that some value ranges recorded for
the SSA_NAMEs in the formerly conditional, now unconditional
basic block can be invalid.

This patch fixes it by calling reset_flow_sensitive_info_in_bb
if we optimize the guarding condition.

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

PR tree-optimization/122104
* tree-ssa-math-opts.cc (maybe_optimize_guarding_check): Call
reset_flow_sensitive_info_in_bb on bb when optimizing out the
guarding condition.

* gcc.target/i386/pr122104.c: New test.

4 weeks ago[PATCH v2] RISC-V: Fix type of CFA during stack probe [PR122114]
Raphael Moreira Zinsly [Sat, 4 Oct 2025 14:36:48 +0000 (08:36 -0600)] 
[PATCH v2] RISC-V: Fix type of CFA during stack probe [PR122114]

Changes since v1:
- Limit test to rv64.

-->8--

frame.total_size may not be a constant, this patch changes the type of
the stored cfa offset to avoid errors trying to convert the frame size.

PR target/122114
gcc/ChangeLog:
* config/riscv/riscv.cc
(riscv_allocate_and_probe_stack_space): Change initial_cfa_offset
type.

gcc/testsuite/ChangeLog:
* gcc.target/riscv/pr122114.c: New test.

4 weeks ago[RISC-V][PR target/122147] Avoid creating (subreg (mem)) in RISC-V port
Jeff Law [Sat, 4 Oct 2025 14:33:19 +0000 (08:33 -0600)] 
[RISC-V][PR target/122147] Avoid creating (subreg (mem)) in RISC-V port

So another fun bug.  Utterly amazed we didn't trip over this in some form or
another until now.

We're generating a (subreg (mem)) expression during combine because
"move_operand" accepts it as a valid operand.  We've discouraged those kinds of
expressions for a long time, even though they're generally expected to act like
registers due to reloading.

In this case reloading just goes into an infinite loop 🙁   Rather than
try to fix this in LRA, let's just avoiding creating the problematical subreg
to begin with.  That's accomplished by being a bit more selective in what
move_operand allows.  I'm not particularly happy with what I saw in
move_operand, but I'm inclined to let it be right now.

Tested on rv32 and rv64.  Bootstraps on the Pioneer and BPI will run later
today.  I'll push once the pre-commit CI system has done its thing.

PR target/122147
gcc/
* config/riscv/predicates.md (move_operand): Only allow a REG as the
operand of a SUBREG.

gcc/testsuite/

* gcc.target/riscv/pr122147.c: New test.