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>
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.
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.
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.
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.
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.
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>
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.
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.
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:
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.
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>
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>
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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>
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>
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>
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.
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.
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.
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.
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.
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.
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.
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>
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>
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.
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.
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.
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>
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.
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>
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>
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.
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.