]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 hours agoPR modula2/121164 Modula 2 build failure master trunk
Gaius Mulley [Fri, 18 Jul 2025 21:06:54 +0000 (22:06 +0100)] 
PR modula2/121164 Modula 2 build failure

This patch fixes the 2nd parameter name mismatch in
ARRAYOFCHAR.mod.

gcc/m2/ChangeLog:

PR modula2/121164
* gm2-libs/ARRAYOFCHAR.mod (Write): Rename 2nd parameter
name a to str.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
4 hours agoFortran: fix bogus runtime error with optional procedure argument [PR121145]
Harald Anlauf [Fri, 18 Jul 2025 19:12:03 +0000 (21:12 +0200)] 
Fortran: fix bogus runtime error with optional procedure argument [PR121145]

PR fortran/121145

gcc/fortran/ChangeLog:

* trans-expr.cc (gfc_conv_procedure_call): Do not create pointer
check for proc-pointer actual passed to optional dummy.

gcc/testsuite/ChangeLog:

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

6 hours agotestsuite/vec: Fix vect-reduc-cond-[12].c for non vect_condition targets [PR121153]
Andrew Pinski [Fri, 18 Jul 2025 17:07:34 +0000 (10:07 -0700)] 
testsuite/vec: Fix vect-reduc-cond-[12].c for non vect_condition targets [PR121153]

I missed this when I added the two testcase vect-reduc-cond-[12].c. These testcases
require support of vectorization of `a ? b : c` which some targets (e.g. sparc) does
not support.

Pushed as obvious after a quick test.

PR testsuite/121153
gcc/testsuite/ChangeLog:

* gcc.dg/vect/vect-reduc-cond-1.c: Require vect_condition.
* gcc.dg/vect/vect-reduc-cond-2.c: Likewise.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
6 hours agolibstdc++: Remove Paolo from list of people to contact about contributing
Jonathan Wakely [Fri, 18 Jul 2025 16:44:45 +0000 (17:44 +0100)] 
libstdc++: Remove Paolo from list of people to contact about contributing

Paolo has not been active for some time.

libstdc++-v3/ChangeLog:

* doc/xml/manual/appendix_contributing.xml: Remove Paolo from
list of maintainers to contact about contributing.
* doc/html/manual/appendix_contributing.html: Regenerate.

6 hours agolibstdc++: Document new generated header
Jonathan Wakely [Fri, 18 Jul 2025 16:43:08 +0000 (17:43 +0100)] 
libstdc++: Document new generated header

libstdc++-v3/ChangeLog:

* doc/xml/manual/build_hacking.xml: Document that
windows_zones-map.h is a generated file.
* doc/html/manual/appendix_porting.html: Regenerate.

9 hours agoRISC-V: Support RVVDImode for avg3_ceil auto vect
Pan Li [Wed, 16 Jul 2025 13:40:14 +0000 (21:40 +0800)] 
RISC-V: Support RVVDImode for avg3_ceil auto vect

Like the avg3_floor pattern, the avg3_ceil has the
similar issue that lack of the RVV DImode support.

Thus, this patch would like to support the DImode by
the standard name, with the iterator V_VLSI_D.

The below test suites are passed for this patch series.
* The rv64gcv fully regression test.

gcc/ChangeLog:

* config/riscv/autovec.md (avg<mode>3_ceil): Add new pattern
of avg3_ceil for RVV DImode

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/avg_data.h: Adjust the test data.
* gcc.target/riscv/rvv/autovec/avg_ceil-1-i64-from-i128.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i64-from-i128.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 hours agolibstdc++: Qualify addressof calls in inplace_vector [PR119137]
Tomasz Kamiński [Fri, 18 Jul 2025 13:32:04 +0000 (15:32 +0200)] 
libstdc++: Qualify addressof calls in inplace_vector [PR119137]

PR libstdc++/119137

libstdc++-v3/ChangeLog:

* include/std/inplace_vector (inplace_vector::operator=):
Qualify call to std::addressof.

10 hours agolibstdc++: Fixed localized empty-spec formatting for months/weekdays [PR121154]
Tomasz Kamiński [Fri, 18 Jul 2025 09:30:22 +0000 (11:30 +0200)] 
libstdc++: Fixed localized empty-spec formatting for months/weekdays [PR121154]

Previously for localized output, if _M_debug option was set, the _M_check_ok
completed succesfully and _M_locale_fmt was called for months/weekdays that
are !ok().

This patch lifts debug checks from each conversion function into _M_check_ok,
that in case of !ok() values return a string_view containing the kind of
calendar data, to be included after "is not a valid" string. The localized
output (_M_locale_fmt) is not used if string is non-empty. Emitting of this
message is now handled in _M_format_to, further reducing each specifier
function.

To handle weekday (%a,%A) and month (%b,%B), _M_check_ok now accepts a
mutable reference to conversion specifier, and updates it to corresponding
numeric value (%w, %m). Extra care needs to be taken to handle a month(0)
that needs to be printed as single digit in debug format.

Finally, the _M_time_point is replaced with _M_needs_ok_check member, that
indicates if input contains any user-suplied values that are checked for
being ok() and these values are referenced in chrono-specs.

PR libstdc++/121154

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (_ChronoSpec::_M_time_point): Remove.
(_ChronoSpec::_M_needs_ok_check): Define
(__formatter_chrono::_M_parse): Set _M_needs_ok_check.
(__formatter_chrono::_M_check_ok): Check values also for debug mode,
and return __string_view.
(__formatter_chrono::_M_format_to): Handle results of _M_check_ok.
(__formatter_chrono::_M_wi, __formatter_chrono::_M_a_A)
(__formatter_chrono::_M_b_B, __formatter_chrono::_M_C_y_Y)
(__formatter_chrono::_M_d_e, __formatter_chrono::_M_F):
Removed handling of _M_debug.
(__formatter_chrono::__M_m): Print zero unpadded in _M_debug mode.
(__formatter_duration::_S_spec_for): Remove _M_time_point refernce.
(__formatter_duration::_M_parse): Override _M_needs_ok_check.
* testsuite/std/time/month/io.cc: Test for localized !ok() values.
* testsuite/std/time/weekday/io.cc: Test for localized !ok() values.

12 hours agoamdgcn, libgomp: Remove unused variable (PR121156)
Andrew Stubbs [Thu, 17 Jul 2025 13:30:04 +0000 (13:30 +0000)] 
amdgcn, libgomp: Remove unused variable (PR121156)

There's a new compiler warning breaking the build.  This fixes it.  The
variable appears to be genuinely vestigial.

libgomp/ChangeLog:

PR target/121156
* config/gcn/bar.c (gomp_team_barrier_wait_end): Remove unused
"generation" variable.
(gomp_team_barrier_wait_cancel_end): Likewise.

12 hours agotree-sra: Fix grp_covered flag computation when totally scalarizing (PR117423)
Martin Jambor [Fri, 18 Jul 2025 10:42:11 +0000 (12:42 +0200)] 
tree-sra: Fix grp_covered flag computation when totally scalarizing (PR117423)

Testcase of PR 117423 shows a flaw in the fancy way we do "total
scalarization" in SRA now.  We use the types encountered in the
function body and not in type declaration (allowing us to totally
scalarize when only one union field is ever used, since we effectively
"skip" the union then) and can accommodate pre-existing accesses that
happen to fall into padding.

In this case, we skipped the union (bypassing the
totally_scalarizable_type_p check) and the access falling into the
"padding" is an aggregate and so not a candidate for SRA but actually
containing data.  Arguably total scalarization should just bail out
when it encounters this situation (but I decided not to depend on this
mainly because we'd need to detect all cases when we eventually cannot
scalarize, such as when a scalar access has children accesses) but the
actual bug is that the detection if all data in an aggregate is indeed
covered by replacements just assumes that is always the case if total
scalarization triggers which however may not be the case in cases like
this - and perhaps more.

This patch fixes the bug by just assuming that all padding is taken
care of when total scalarization triggered, not that every access was
actually scalarized.

gcc/ChangeLog:

2025-07-17  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/117423
* tree-sra.cc (analyze_access_subtree): Fix computation of grp_covered
flag.

gcc/testsuite/ChangeLog:

2025-07-17  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/117423
* gcc.dg/tree-ssa/pr117423.c: New test.

13 hours agotree-optimization/121126 - properly verify live LC PHIs
Richard Biener [Fri, 18 Jul 2025 06:28:59 +0000 (08:28 +0200)] 
tree-optimization/121126 - properly verify live LC PHIs

The following makes sure we analyze live LC PHIs not part of
a double reduction.

PR tree-optimization/121126
* tree-vect-stmts.cc (vect_analyze_stmt): Analyze the
live lane extract for LC PHIs that are vect_internal_def.

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

14 hours agolibstdc++: Fix hash<__int128> test for x32 [PR121150]
Jonathan Wakely [Fri, 18 Jul 2025 08:55:13 +0000 (09:55 +0100)] 
libstdc++: Fix hash<__int128> test for x32 [PR121150]

I incorrectly assumed that all targets that support __int128 use the
LP64 ABI, so size_t is a 64-bit type. But x32 uses ILP32 and still
supports __int128 (because it's an ILP32 target on 64-bit hardware).

Add casts to the tests so that we get the correct expected values using
size_t type.

libstdc++-v3/ChangeLog:

PR libstdc++/121150
* testsuite/20_util/hash/int128.cc: Cast expected values to
size_t.

14 hours agolibstdc++: Implement reverse iteration for _Utf_view
Jonathan Wakely [Mon, 14 Jul 2025 19:15:12 +0000 (20:15 +0100)] 
libstdc++: Implement reverse iteration for _Utf_view

This implements the missing functions in _Utf_iterator to support
reverse iteration. All existing tests pass when the view is reversed, so
that the same code units are seen when iterating forwards or backwards.

libstdc++-v3/ChangeLog:

* include/bits/unicode.h (_Utf_iterator::operator--): Reorder
conditions and update position after reading a code unit.
(_Utf_iterator::_M_read_reverse): Define.
(_Utf_iterator::_M_read_utf8): Return extracted code point.
(_Utf_iterator::_M_read_reverse_utf8): Define.
(_Utf_iterator::_M_read_reverse_utf16): Define.
(_Utf_iterator::_M_read_reverse_utf32): Define.
* testsuite/ext/unicode/view.cc: Add checks for reversed views
and reverse iteration.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
14 hours agolibstdc++: Optimize _Utf_iterator for size
Jonathan Wakely [Wed, 16 Jul 2025 23:11:49 +0000 (00:11 +0100)] 
libstdc++: Optimize _Utf_iterator for size

This reorders the data members of _Utf_iterator to avoid padding bytes
between members due to alignment requirements. For x86_64 the previous
layout had padding after _M_buf and after _M_to_increment for the common
case where the iterators and sentinel types are pointers, so the size
shrinks from 40 bytes to 32 bytes.  (For i686 there's no change, it's
still 20 bytes).

We could compress the three uint8_t members into one byte by using
bit-fields:

uint8_t _M_buf_index : 2;    // [0,3]
uint8_t _M_buf_last  : 3;    // [0,4]
uint8_t _M_to_increment : 3; // [0,4]

But there doesn't seem to be any point, because it will just be slower
to access them and there will be tail padding so the size isn't any
smaller. We could also reduce _M_buf_last and _M_to_increment to 2 bits
because the 0 value is only used for a default constructed iterator, and
we don't actually care about the values in that case. Again, this
doesn't seem worth doing.

libstdc++-v3/ChangeLog:

* include/bits/unicode.h (_Utf_iterator): Reorder data members
to be more compact.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
14 hours agoRemove non-SLP path from vectorizable_live_operation
Richard Biener [Fri, 18 Jul 2025 07:37:01 +0000 (09:37 +0200)] 
Remove non-SLP path from vectorizable_live_operation

This removes paths gated by !slp_node and propagates out ncopies == 1,
thereby reducing the vectorizable_live_operation_1 API.

* tree-vect-loop.cc (vectorizable_live_operation_1):
Remove stmt_info and ncopies parameters.  Remove !slp_node
paths.
(vectorizable_live_operation): Remove !slp_node paths.

15 hours agotree-optimization/120924 - up --param uninit-max-chain-len
Richard Biener [Fri, 18 Jul 2025 07:02:09 +0000 (09:02 +0200)] 
tree-optimization/120924 - up --param uninit-max-chain-len

The PR shows that the uninit analysis limits are set too low in
cases we lower switches to ifs as happens on s390x for a linux
kernel TU.  This causes false positive uninit diagnostics as we
abort the attempt to prove that a value is initialized on all
paths.  The new testcase only would require upping to 9.

PR tree-optimization/120924
* params.opt (uninit-max-chain-len): Up from 8 to 12.

* gcc.dg/uninit-pr120924.c: New testcase.

15 hours agoada: Spurious actual/formal matching check failure for formal derived type.
Steve Baird [Thu, 26 Jun 2025 19:23:53 +0000 (12:23 -0700)] 
ada: Spurious actual/formal matching check failure for formal derived type.

In some cases involving a generic with two formal parameters, a formal package
and a formal derived type that is derived from an interface type declared in
the formal package, a legal instantiation of that generic is rejected with a
message incorrectly stating that the second actual parameter does not implement
the required interface.

gcc/ada/ChangeLog:

* sem_ch12.adb (Validate_Derived_Type_Instance): Cope with the case
where the ancestor type for a formal derived type is declared in
an earlier formal package but Get_Instance_Of does not return the
corresponding type from the corresponding actual package.

15 hours agoada: Back out change to Tbuild.Unchecked_Convert_To
Bob Duff [Fri, 27 Jun 2025 16:00:54 +0000 (12:00 -0400)] 
ada: Back out change to Tbuild.Unchecked_Convert_To

...because it breaks one test that uses --RTS=light.
"Is_Composite_Type" is needed; "not Is_Scalar_Type"
was wrong.

gcc/ada/ChangeLog:

* tbuild.adb (Unchecked_Convert_To): Back out
change.

15 hours agoada: Do not inline function returning on the secondary stack
Marc Poulhiès [Fri, 20 Jun 2025 14:10:25 +0000 (16:10 +0200)] 
ada: Do not inline function returning on the secondary stack

When inlining function calls that return on the secondary stack used as
function actual or in a return statement, the compiler creates an
invalid GNAT Tree with a variable of an unconstrained type without an
initializer.

Also add an extra assertion to catch problematic cases directly in
Expand_Inlined_Call.

gcc/ada/ChangeLog:

* exp_ch6.adb (Convert): Do not call Expand_Inlined_Call for
unsupported cases.
* inline.adb (Expand_Inlined_Call): Add assert to catch unsupported
case.

Co-authored-by: Eric Botcazou <botcazou@adacore.com>
15 hours agoada: Incorrect resolution of prefixed calls with overriding private subprogram
Gary Dismukes [Tue, 17 Jun 2025 21:55:58 +0000 (21:55 +0000)] 
ada: Incorrect resolution of prefixed calls with overriding private subprogram

The compiler incorrectly treats an overriding private subprogram that
should not be visible outside a package (because it only overrides in
the private part) as a possible interpretation for a call using prefixed
notation outside of the package. This can result in an ambiguity if there
is another subprogram with the same name but a different profile declared
in the visible part of the package, or can result in resolving to the
private operation in cases where it shouldn't resolve. This happens due
to the compiler improperly concluding that the private overriding subprogram
overrides an inherited subprogram in the package visible part, even though
the only inherited subprogram is in the private part, as a result of
a misuse of the Overridden_Operation field, which, contrary to what
its name suggests, actually refers to operations of the parent type,
rather than to the operations derived from the parent's operations.

gcc/ada/ChangeLog:

* einfo.ads: Document new field Overridden_Inherited_Operation and
list it as a field for the entity kinds that it applies to.
* gen_il-fields.ads (type Opt_Field_Enum): Add new literal
Overridden_Inherited_Operation to the type.
* gen_il-gen-gen_entities.adb: Add Overridden_Inherited_Operation as
a field of entities of kinds E_Enumeration_Literal and Subprogram_Kind.
* sem_ch4.adb (Is_Callable_Private_Overriding): Change name (was
Is_Private_Overriding). Replace Is_Hidden test on Overridden_Operation
with test of Is_Hidden on the new field Overridden_Inherited_Operation.
* sem_ch6.adb (New_Overloaded_Entity): Set the new field
Overridden_Inherited_Operation on an operation derived from
an interface to refer to the inherited operation of a private
extension that's overridden by the derived operation. Also set
that field in the more common cases of an explicit subprogram
that overrides, to refer to the inherited subprogram that is
overridden. (Contrary to its name, the Overridden_Operation
field of the overriding subprogram, which is also set in these
places, refers to the *parent* subprogram from which the inherited
subprogram is derived.) Also, remove a redundant Present (Alias (S))
test in an if_statement and the dead "else" part of that statement.

15 hours agoada: Elaboration entity must not be ghost in ghost generic instances
Piotr Trojanek [Thu, 26 Jun 2025 12:57:14 +0000 (14:57 +0200)] 
ada: Elaboration entity must not be ghost in ghost generic instances

For non-instance units GNAT builds elaboration entities before the ghost mode
is inherited from those units. However, for generic instances GNAT was building
elaboration entities with ghost mode inherited from those instances, which
effectively caused elaboration entities to become ghost objects.

This patch add ghost management to routine that builds elaboration entities,
which seems simpler and more robust than adjusting the ghost mode in all
callers of this routine.

gcc/ada/ChangeLog:

* sem_util.adb (Build_Elaboration_Entity): Set ghost mode to none
before creating the elaboration entity; restore the ghost mode
afterwards.

15 hours agoada: Array aggregates of mutably tagged objects (part 2)
Javier Miranda [Tue, 17 Jun 2025 13:09:11 +0000 (13:09 +0000)] 
ada: Array aggregates of mutably tagged objects (part 2)

gcc/ada/ChangeLog:

* exp_aggr.adb (Gen_Assign): Code cleanup.
(Initialize_Component): Do not adjust the tag when the type of
the aggregate components is a mutably tagged type.

15 hours agolibstdc++: Add std::inplace_vector for C++26 (P0843R14) [PR119137]
Jonathan Wakely [Thu, 5 Jun 2025 11:05:19 +0000 (12:05 +0100)] 
libstdc++: Add std::inplace_vector for C++26 (P0843R14) [PR119137]

Implement std::inplace_vector as specified in P0843R14, without follow
up papers, in particular P3074R7 (trivial unions). In consequence
inplace_vector<T, N> can be used inside constant evaluations only
if T is trivial or N is equal to zero.

We provide a separate specialization for inplace_vector<T, 0> to meet
the requirements of N5008 [inplace.vector.overview] p5. In particular
objects of such types needs to be empty.

To allow constexpr variable of inplace_vector v, where v.size() < v.capacity(),
we need to guaranteed that all elements of the storage array are initialized,
even ones in range [v.data() + v.size(), v.data() + v.capacity()). This is
perfoirmed by _M_init function, that is called by each constructor. By storing
the array in anonymous union, we can perform this initialization in constant
evaluation, avoiding the impact on runtime path.

The size() function conveys the information that _M_size <= _Nm to compiler,
by calling __builtin_unreachable(). In particular this allows us to eliminate
FP warnings by using _Nm - size() instead of _Nm - _M_size, when computing
available elements.

The included test cover almost all code paths at runtime, however some
compile time evaluation test are not yet implemented:
* operations on range, they depend on making testsuite_iterators constexpr
* negative test for invoking operations with preconditions at compile time,
  especially for zero size specialization.

PR libstdc++/119137

libstdc++-v3/ChangeLog:

* doc/doxygen/user.cfg.in (INPUT): Add new header.
* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/bits/stl_iterator_base_types.h (__any_input_iterator):
Define.
* include/bits/version.def (inplace_vector): Define.
* include/bits/version.h: Regenerate.
* include/precompiled/stdc++.h: Include new header.
* src/c++23/std.cc.in: Export contents if new header.
* include/std/inplace_vector: New file.
* testsuite/23_containers/inplace_vector/access/capacity.cc: New file.
* testsuite/23_containers/inplace_vector/access/elem.cc: New file.
* testsuite/23_containers/inplace_vector/access/elem_neg.cc: New file.
* testsuite/23_containers/inplace_vector/cons/1.cc: New file.
* testsuite/23_containers/inplace_vector/cons/from_range.cc: New file.
* testsuite/23_containers/inplace_vector/cons/throws.cc: New file.
* testsuite/23_containers/inplace_vector/copy.cc: New file.
* testsuite/23_containers/inplace_vector/erasure.cc: New file.
* testsuite/23_containers/inplace_vector/modifiers/assign.cc: New file.
* testsuite/23_containers/inplace_vector/modifiers/erase.cc: New file.
* testsuite/23_containers/inplace_vector/modifiers/multi_insert.cc:
New file.
* testsuite/23_containers/inplace_vector/modifiers/single_insert.cc:
New file.
* testsuite/23_containers/inplace_vector/move.cc: New file.
* testsuite/23_containers/inplace_vector/relops.cc: New file.
* testsuite/23_containers/inplace_vector/version.cc: New file.
* testsuite/util/testsuite_iterators.h (input_iterator_wrapper::base):
Define.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
16 hours agotree-optimization/121048 - move check for only having vector(1)
Richard Biener [Thu, 17 Jul 2025 06:51:11 +0000 (08:51 +0200)] 
tree-optimization/121048 - move check for only having vector(1)

The following moves rejecting loop vectorization with vector(1)
typed vectors from the initial vector type determining to after
SLP discovery when we can check whether there's any instance
with other than vector(1) vectors.  For RVV at least vector(1)
instances serve as a limited way to support partial loop vectorization.
The following restores this.

PR tree-optimization/121048
* tree-vect-loop.cc (vect_determine_vectype_for_stmt_1):
Remove rejecting vector(1) vector types.
(vect_set_stmts_vectype): Likewise.
* tree-vect-slp.cc (vect_make_slp_decision): Only
count instances with non-vector(1) root towards whether
we have any interesting instances to vectorize.

16 hours agogimple-fold: Fix up big endian _BitInt adjustment [PR121131]
Jakub Jelinek [Fri, 18 Jul 2025 07:20:30 +0000 (09:20 +0200)] 
gimple-fold: Fix up big endian _BitInt adjustment [PR121131]

The following testcase ICEs because SCALAR_INT_TYPE_MODE of course
doesn't work for large BITINT_TYPE types which have BLKmode.
native_encode* as well as e.g. r14-8276 use in cases like these
GET_MODE_SIZE (SCALAR_INT_TYPE_MODE ()) and TREE_INT_CST_LOW (TYPE_SIZE_UNIT
()) for the BLKmode ones.
In this case, it wants bits rather than bytes, so I've used
GET_MODE_BITSIZE like before and TYPE_SIZE otherwise.

Furthermore, the patch only computes encoding_size for big endian
targets, for little endian we don't really adjust anything, so there
is no point computing it.

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

PR tree-optimization/121131
* gimple-fold.cc (fold_nonarray_ctor_reference): Use
TREE_INT_CST_LOW (TYPE_SIZE ()) instead of
GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE ()) for BLKmode BITINT_TYPEs.
Don't compute encoding_size at all for little endian targets.

* gcc.dg/bitint-124.c: New test.

23 hours agoDaily bump.
GCC Administrator [Fri, 18 Jul 2025 00:19:21 +0000 (00:19 +0000)] 
Daily bump.

29 hours agogcse: Skip hardreg pre when the hardreg is never live [PR121095]
Andrew Pinski [Wed, 16 Jul 2025 16:31:35 +0000 (09:31 -0700)] 
gcse: Skip hardreg pre when the hardreg is never live [PR121095]

r15-6789-ge7f98d9603808b added a new RTL pass for hardreg PRE for the hard register
of FPM_REGNUM, this pass could get expensive if you have a large number of basic blocks
and the hard register was never live so it does nothing in the end.
In the aarch64 case, FPM_REGNUM is only used for FP8 related code so it has a high probability
of not being used. So skipping the pass for that register can improve both compile time and memory
usage.

Build and tested for aarch64-linux-gnu.

PR middle-end/121095
gcc/ChangeLog:

* gcse.cc (execute_hardreg_pre): Skip if the hardreg which is never live.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
32 hours agolibstdc++: Document change in __int128 traits [PRPR96710]
Jonathan Wakely [Thu, 17 Jul 2025 11:25:17 +0000 (12:25 +0100)] 
libstdc++: Document change in __int128 traits [PRPR96710]

libstdc++-v3/ChangeLog:

PR libstdc++/96710
* doc/xml/manual/evolution.xml: Document change or __int128.
* doc/html/manual/api.html: Regenerate.

33 hours agolibstdc++: Fix forwarding of custom IndexType in mdspan [PR121061]
Luc Grosheintz [Wed, 16 Jul 2025 13:45:45 +0000 (15:45 +0200)] 
libstdc++: Fix forwarding of custom IndexType in mdspan [PR121061]

The second bug report in PR121061 is that the conversion of custom
OtherIndexType to IndexType is incorrectly not done via r-value
references.

This commit fixes the forwarding issue, adds a custom IndexType called
RValueInt, which only allows conversion to int via r-value reference.

PR libstdc++/121061

libstdc++-v3/ChangeLog:

* include/std/mdspan (extents::extents): Perform conversion to
index_type of an r-value reference.
(layout_left::mapping::operator()): Ditto.
(layout_right::mapping::operator()): Ditto.
(layout_stride::mapping::operator()): Ditto.
* testsuite/23_containers/mdspan/extents/custom_integer.cc: Add
tests for RValueInt and MutatingInt.
* testsuite/23_containers/mdspan/int_like.h (RValueInt): Add.
* testsuite/23_containers/mdspan/layouts/mapping.cc: Test with
RValueInt.
* testsuite/23_containers/mdspan/mdspan.cc: Ditto.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
33 hours agolibstdc++: Fix constraint for custom integer types in mdspan [PR121061]
Luc Grosheintz [Wed, 16 Jul 2025 13:45:44 +0000 (15:45 +0200)] 
libstdc++: Fix constraint for custom integer types in mdspan [PR121061]

PR121061 consists of two bugs for mdspan related code. This commit fixes
the first one. Namely, when passing custom IndexType as an array or
span, the conversion to int must be const. Prior to this commit the
constraint incorrectly also allowed non-const conversion. This commit
updates all related constraints to check

  __valid_index_type<const OtherIndexType&, index_type>

in those cases. Also adds a MutatingInt to int_like.h which only
supports non-const conversion to int and updates the tests.

PR libstdc++/121061

libstdc++-v3/ChangeLog:

* include/std/mdspan (extents::extents): Fix constraint to
prevent non-const conversion to index_type.
(layout_stride::mapping::mapping): Ditto.
(mdspan::mdspan): Ditto.
(mdspan::operator[]): Ditto.
* testsuite/23_containers/mdspan/extents/custom_integer.cc: Add
test for MutatingInt.
* testsuite/23_containers/mdspan/int_like.h (MutatingInt): Add.
* testsuite/23_containers/mdspan/layouts/mapping.cc: Add test for
MutatingInt.
* testsuite/23_containers/mdspan/layouts/stride.cc: Ditto.
* testsuite/23_containers/mdspan/mdspan.cc: Ditto.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
33 hours agoc++: constexpr array testcase [PR87097]
Jason Merrill [Thu, 17 Jul 2025 13:46:35 +0000 (09:46 -0400)] 
c++: constexpr array testcase [PR87097]

This seems to have been fixed by r15-7260 for PR118285, but is sufficiently
different to merit its own test.

PR c++/87097

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-array29.C: New test.

33 hours agolibstdc++: Refactor mdspan tests [PR121061]
Luc Grosheintz [Wed, 16 Jul 2025 13:45:43 +0000 (15:45 +0200)] 
libstdc++: Refactor mdspan tests [PR121061]

PR121061 shows that the test coverage for custom integer types is
insufficient. Custom IndexTypes are passed to mdspan related objects in
one of two ways:

  * as a template parameter pack,
  * or as an array/span.

These two cases have different requirements on the (constness of) custom
IndexTypes. Therefore, the tests are restructured as follows:

  * allow testing with different custom integers,
  * separate code that tests the two cases described above,
  * use int_like.h for all tests with custom integers.

The affected tests are for:

  * creating extents, layout_stride::mapping and mdspan from
  custom integers,

  * mapping::operator() and mdspan::operator[].

PR libstdc++/121061

libstdc++-v3/ChangeLog:

* testsuite/23_containers/mdspan/extents/custom_integer.cc:
Enable checking with different custom integers. Improve
checking non-existence of overloads for incompatible custom
integers.
* testsuite/23_containers/mdspan/layouts/mapping.cc: ditto. Also
improve reuse of int_like.h.
* testsuite/23_containers/mdspan/layouts/stride.cc: ditto.
* testsuite/23_containers/mdspan/mdspan.cc: ditto.
* testsuite/23_containers/mdspan/extents/int_like.h: Rename (old
name).
* testsuite/23_containers/mdspan/int_like.h: Rename (new name).
(ThrowingInt): Add.
(NotIntLike): 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>
34 hours agotree-ssa-structalias / pta: Fix *more* GNU coding style deviations
Filip Kastl [Thu, 17 Jul 2025 12:52:59 +0000 (14:52 +0200)] 
tree-ssa-structalias / pta: Fix *more* GNU coding style deviations

This continues my previous commit, where I fixed some deviations from
GNU coding style in pta files.  This should fix all the remaining issues
that contrib/check_GNU_style.py can detect (excluding false positives).

Commiting as obvious.

gcc/ChangeLog:

* tree-ssa-structalias.cc (lookup_vi_for_tree): Fix GNU style.
(process_constraint): Fix GNU style.
(get_constraint_for_component_ref): Fix GNU style.
(get_constraint_for_1): Fix GNU style.
(get_function_part_constraint): Fix GNU style.
(handle_lhs_call): Fix GNU style.
(find_func_aliases_for_builtin_call): Fix GNU style.
(find_func_aliases): Fix GNU style.
(find_func_clobbers): Fix GNU style.
(struct shared_bitmap_hasher): Fix GNU style.
(shared_bitmap_hasher::hash): Fix GNU style.
(pt_solution_includes_global): Fix GNU style.
(init_base_vars): Fix GNU style.
(visit_loadstore): Fix GNU style.
(compute_dependence_clique): Fix GNU style.
(struct pt_solution): Fix GNU style.
(ipa_pta_execute): Fix GNU style.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
34 hours agoGCN, nvptx offloading: Restrain 'WARNING: program timed out.' while in 'dynamic_cast...
Thomas Schwinge [Wed, 16 Jul 2025 20:13:46 +0000 (22:13 +0200)] 
GCN, nvptx offloading: Restrain 'WARNING: program timed out.' while in 'dynamic_cast' only for effective-target 'offload_device' [PR119692]

In PR119692 "C++ 'typeinfo', 'vtable' vs. OpenACC, OpenMP 'target' offloading":

> --- Comment #8 from Rainer Orth <ro at gcc dot gnu.org> ---
> The last commit made things worse on sparc-sun-solaris2.11: since that one
> (dg-timeout 10) I regularly get
>
> WARNING: libgomp.c++/target-exceptions-bad_cast-1.C (test for excess errors)
> program timed out.
> FAIL: libgomp.c++/target-exceptions-bad_cast-1.C (test for excess errors)
> UNRESOLVED: libgomp.c++/target-exceptions-bad_cast-1.C compilation failed to produce executable
> UNRESOLVED: libgomp.c++/target-exceptions-bad_cast-1.C scan-tree-dump-times optimized "gimple_call <__cxa_bad_cast, " 1
>
> Before that, the test had no issue.  Compiling the test on an unloaded system
> usually takes less than 1 sec, but when fully loaded, times can go up.

To keep things simple, let's restrict this temporary (yeah...) workaround to
apply only for effective-target 'offload_device', just like the
'dg-xfail-run-if' itself.

PR target/119692
libgomp/
* testsuite/libgomp.c++/pr119692-1-4.C: '{ dg-timeout 10 { target offload_device } }'.
* testsuite/libgomp.c++/pr119692-1-5.C: Likewise.
* testsuite/libgomp.c++/target-exceptions-bad_cast-1.C: Likewise.
* testsuite/libgomp.c++/target-exceptions-bad_cast-2.C: Likewise.
* testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C: Likewise.
* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C: Likewise.

35 hours agotree-ssa-structalias / pta: Fix some GNU coding style deviations
Filip Kastl [Thu, 17 Jul 2025 12:30:11 +0000 (14:30 +0200)] 
tree-ssa-structalias / pta: Fix some GNU coding style deviations

Fix some deviations from GNU coding style in pta files as reported by
contrib/check_GNU_style.py.  Most of these are "dot, space, space, end
of comment".

Commiting as obvious.

gcc/ChangeLog:

* pta-andersen.cc (struct constraint_graph): Fix GNU style.
(constraint_equal): Fix GNU style.
(set_union_with_increment): Fix GNU style.
(insert_into_complex): Fix GNU style.
(merge_node_constraints): Fix GNU style.
(unify_nodes): Fix GNU style.
(do_ds_constraint): Fix GNU style.
(scc_info::scc_info): Fix GNU style.
(find_indirect_cycles): Fix GNU style.
(equiv_class_lookup_or_add): Fix GNU style.
(label_visit): Fix GNU style.
(dump_pred_graph): Fix GNU style.
(perform_var_substitution): Fix GNU style.
(eliminate_indirect_cycles): Fix GNU style.
(solve_graph): Fix GNU style.
(solve_constraints): Fix GNU style.
* tree-ssa-structalias.cc (first_vi_for_offset): Fix GNU style.
(debug_constraint): Fix GNU style.
* tree-ssa-structalias.h (struct constraint_expr): Fix GNU
style.
(struct variable_info): Fix GNU style.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
35 hours agox86: Don't change mode for XOR in ix86_expand_ternlog
H.J. Lu [Sun, 2 Mar 2025 01:10:57 +0000 (09:10 +0800)] 
x86: Don't change mode for XOR in ix86_expand_ternlog

There is no need to change mode for XOR in ix86_expand_ternlog now.
Whatever reasons for it in the first place no longer exist.  Tested
on x86-64 with -m32.  There are no regressions.

* config/i386/i386-expand.cc (ix86_expand_ternlog): Don't change
mode for XOR.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
35 hours agotree-ssa-structalias: Put solver into its own file
Filip Kastl [Thu, 17 Jul 2025 11:29:50 +0000 (13:29 +0200)] 
tree-ssa-structalias: Put solver into its own file

This patch cuts out the points-to solver from tree-ssa-structalias.cc
and places it into a new file pta-andersen.cc.  It is the first part of
my effort to split tree-ssa-structalias.cc into smaller parts.

I had to give external linkage to some static functions and variables.
I put those in the new header files tree-ssa-structalias.h and
pta-andersen.h.  Those header files are meant as an internal interface
between parts of the points-to analyzer.

Some functions and variables already had external linkage and were declared in
tree-ssa-alias.h.  I considered moving the declarations to
tree-ssa-structalias.h but decided to leave them as is.  I see those functions
and variables as an external interface -- facing outwards to the rest of the
compiler.

For the internal interface, I made a new namespace "pointer_analysis".
I didn't want to clutter the global namespace and possibly run into ODR
problems.

I wanted to encapsulate the constraint graph within the solver. To achieve
that, I had to make some changes beyond just moving things around. They were
only very small changes, though:
- Add delete_graph() which gets called at the end of solve_constraints()
- Problem: The solver assigns representatives to variables (union-find).  To
  then get the solution for variable v, one has to look up the representative
  of v.  The information needed to look up the representative is part of the
  graph.
- Solution: Let the solver output an array that maps variables to their
  representatives and let this array outlive the graph (array var_rep).
  - Constructing the array means doing find() for every variable.  That should
    amortize to O(size of the union-find structure).  So this won't hurt the
    asymptotic time complexity.
  - We replace all calls to find(var) in tree-ssa-structalias.cc with
    just an array lookup var_rep[var].
- predbitmap_obstack gets initialized in init_graph().

gcc/ChangeLog:

* Makefile.in: Add pta-andersen.o.
* tree-ssa-structalias.cc (create_variable_info_for): Just move
around.
(unify_nodes): Move to pta-andersen.cc.
(struct constraint): Move to tree-ssa-structalias.h.
(EXECUTE_IF_IN_NONNULL_BITMAP): Move to pta-andersen.cc.
(struct variable_info): Move to tree-ssa-structalias.h.
(struct constraint_stats): Move to tree-ssa-structalias.h.
(first_vi_for_offset): External linkage, move to namespace
pointer_analysis.
(first_or_preceding_vi_for_offset): External linkage, move to namespace
pointer_analysis.
(dump_constraint): External linkage, move to namespace
pointer_analysis.
(debug_constraint): External linkage, move to namespace
pointer_analysis.
(dump_constraints): External linkage, move to namespace
pointer_analysis.
(debug_constraints): External linkage, move to namespace
pointer_analysis.
(lookup_vi_for_tree): Move around inside tree-ssa-structalias.cc.
(type_can_have_subvars): Move around inside tree-ssa-structalias.cc.
(make_param_constraints): Move around inside tree-ssa-structalias.cc.
(dump_solution_for_var): External linkage, move to namespace
pointer_analysis.  find (...) -> var_rep[...].
(get_varinfo): Move to tree-ssa-structalias.h.
(debug_solution_for_var): External linkage, move to namespace
pointer_analysis.
(vi_next): Move to tree-ssa-structalias.h.
(dump_sa_stats): External linkage, move to namespace pointer_analysis.
(new_var_info): Just move around.
(dump_sa_points_to_info): External linkage, move to namespace
pointer_analysis.
(debug_sa_points_to_info): External linkage, move to namespace
pointer_analysis.
(get_call_vi): Just move around.
(dump_varinfo): External linkage, move to namespace pointer_analysis.
(lookup_call_use_vi): Just move around.
(lookup_call_clobber_vi): Just move around.
(get_call_use_vi): Just move around.
(get_call_clobber_vi): Just move around.
(enum constraint_expr_type): Move to tree-ssa-structalias.h.
(struct constraint_expr): Move to tree-ssa-structalias.h.
(UNKNOWN_OFFSET): Move to tree-ssa-structalias.h.
(get_constraint_for_1): Just move around.
(get_constraint_for): Just move around.
(get_constraint_for_rhs): Just move around.
(do_deref): Just move around.
(constraint_pool): Just move around.
(struct constraint_graph): Move to pta-andersen.h.
(FIRST_REF_NODE): Move to pta-andersen.cc.
(LAST_REF_NODE): Move to pta-andersen.cc.
(find): Move to pta-andersen.cc.
(unite): Move to pta-andersen.cc.
(new_constraint): Just move around.
(debug_constraint_graph): External linkage, move to namespace
pointer_analysis.
(debug_varinfo): External linkage, move to namespace pointer_analysis.
(debug_varmap): External linkage, move to namespace pointer_analysis.
(dump_constraint_graph): External linkage, move to namespace
pointer_analysis.
(constraint_expr_equal): Move to pta-andersen.cc.
(constraint_expr_less): Move to pta-andersen.cc.
(constraint_less): Move to pta-andersen.cc.
(constraint_equal): Move to pta-andersen.cc.
(constraint_vec_find): Move to pta-andersen.cc.
(constraint_set_union): Move to pta-andersen.cc.
(solution_set_expand): Move to pta-andersen.cc.
(set_union_with_increment): Move to pta-andersen.cc.
(insert_into_complex): Move to pta-andersen.cc.
(merge_node_constraints): Move to pta-andersen.cc.
(clear_edges_for_node): Move to pta-andersen.cc.
(merge_graph_nodes): Move to pta-andersen.cc.
(add_implicit_graph_edge): Move to pta-andersen.cc.
(add_pred_graph_edge): Move to pta-andersen.cc.
(add_graph_edge): Move to pta-andersen.cc.
(init_graph): Move to pta-andersen.cc.  Initialize
predbitmap_obstack here.
(build_pred_graph): Move to pta-andersen.cc.
(build_succ_graph): Move to pta-andersen.cc.
(class scc_info): Move to pta-andersen.cc.
(scc_visit): Move to pta-andersen.cc.
(solve_add_graph_edge): Move to pta-andersen.cc.
(do_sd_constraint): Move to pta-andersen.cc.
(do_ds_constraint): Move to pta-andersen.cc.
(do_complex_constraint): Move to pta-andersen.cc.
(scc_info::scc_info): Move to pta-andersen.cc.
(scc_info::~scc_info): Move to pta-andersen.cc.
(find_indirect_cycles): Move to pta-andersen.cc.
(topo_visit): Move to pta-andersen.cc.
(compute_topo_order): Move to pta-andersen.cc.
(struct equiv_class_hasher): Move to pta-andersen.cc.
(equiv_class_hasher::hash): Move to pta-andersen.cc.
(equiv_class_hasher::equal): Move to pta-andersen.cc.
(equiv_class_lookup_or_add): Move to pta-andersen.cc.
(condense_visit): Move to pta-andersen.cc.
(label_visit): Move to pta-andersen.cc.
(dump_pred_graph): External linkage, move to namespace
pointer_analysis.
(dump_varmap): External linkage, move to namespace pointer_analysis.
(perform_var_substitution): Move to pta-andersen.cc.
(free_var_substitution_info): Move to pta-andersen.cc.
(find_equivalent_node): Move to pta-andersen.cc.
(unite_pointer_equivalences): Move to pta-andersen.cc.
(move_complex_constraints): Move to pta-andersen.cc.
(rewrite_constraints): Move to pta-andersen.cc.
(eliminate_indirect_cycles): Move to pta-andersen.cc.
(solve_graph): Move to pta-andersen.cc.
(set_uids_in_ptset): find (...) -> var_rep[...].
(find_what_var_points_to): find (...) -> var_rep[...].
(init_alias_vars): Don't initialize predbitmap_obstack here.
(remove_preds_and_fake_succs): Move to pta-andersen.cc.
(solve_constraints): Move to pta-andersen.cc.  Call
delete_graph() at the end.
(delete_points_to_sets): Don't delete graph here.  Delete var_rep here.
(visit_loadstore): find (...) -> var_rep[...].
(compute_dependence_clique): find (...) -> var_rep[...].
(ipa_pta_execute): find (...) -> var_rep[...].
* pta-andersen.cc: New file.
* pta-andersen.h: New file.
* tree-ssa-structalias.h: New file.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
36 hours agoaarch64: Adapt unwinder to linux's SME signal behaviour
Richard Sandiford [Tue, 17 Jun 2025 14:20:25 +0000 (15:20 +0100)] 
aarch64: Adapt unwinder to linux's SME signal behaviour

SME uses a lazy save system to manage ZA.  The idea is that,
if a function with ZA state wants to call a "normal" function,
it can leave its state in ZA and instead set up a lazy save buffer.
If, unexpectedly, that normal function contains a nested use of ZA,
that nested use of ZA must commit the lazy save first.

This lazy save system uses a special system register called TPIDR2_EL0.
See:

  https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#66the-za-lazy-saving-scheme

for details.

The ABI specifies that, on entry to an exception handler, the following
things must be true:

* PSTATE.SM must be 0 (the processor must be in non-streaming mode)

* PSTATE.ZA must be 0 (ZA must be off)

* TPIDR2_EL0 must be 0 (there must be no uncommitted lazy save)

This is normally done by making _Unwind_RaiseException & friends
commit any lazy save before they unwind.  This also has the side
effect of ensuring that TPIDR2_EL0 is never left pointing to a
lazy save buffer that has been unwound.

However, things get more complicated with signals.  If:

(a) a signal is raised while ZA is dormant (that is, while there is an
    uncommitted lazy save);

(b) the signal handler throws an exception; and

(c) that exception is caught outside the signal handler

something must ensure that the lazy save from (a) is committed.

This would be simple if the signal handler was entered with ZA and
TPIDR2_EL0 intact.  However, for various good reasons that are out
of scope here, this is not done.  Instead, Linux now clears both
TPIDR2_EL0 and PSTATE.ZA before entering a signal handler, see:

  https://lore.kernel.org/all/20250417190113.3778111-1-mark.rutland@arm.com/

for details.

Therefore, it is the unwinder that must simulate a commit of the lazy
save from (a).  It can do this by reading the previous values of
TPIDR2_EL0 and ZA from the sigcontext.

The SME-related sigcontext structures were only added to linux's
asm/sigcontext.h relatively recently and we can't rely on GCC being
built against such recent kernel header files.  The patch therefore uses
defines relevant macros if they are not defined and provide types that
comply with ABI layout of the corresponding linux types.

The patch includes some ugly casting in an attempt to support big-endian
ILP32, even though SME on big-endian ILP32 linux should never be a thing.
We can remove it if we also remove ILP32 support from GCC.

Co-authored-by: Yury Khrustalev <yury.khrustalev@arm.com>
Reviewed-by: Tamar Christina <tamar.christina@arm.com>
gcc/
* doc/sourcebuild.texi (aarch64_sme_hw): Document.

gcc/testsuite/
* lib/target-supports.exp (add_options_for_aarch64_sme)
(check_effective_target_aarch64_sme_hw): New procedures.
* g++.target/aarch64/sme/sme_throw_1.C: New test.
* g++.target/aarch64/sme/sme_throw_2.C: Likewise.

libgcc/
* config/aarch64/linux-unwind.h (aarch64_fallback_frame_state):
If a signal was raised while there was an uncommitted lazy save,
commit the save as part of the unwind process.

36 hours agos390: Rework signbit optab
Stefan Schulze Frielinghaus [Thu, 17 Jul 2025 10:44:06 +0000 (12:44 +0200)] 
s390: Rework signbit optab

Currently for a signbit operation instructions tc{f,d,x}b + ipm + srl
are emitted.  If the source operand is a MEM, then a load precedes the
sequence.  A faster implementation is by issuing a load either from a
REG or MEM into a GPR followed by a shift.

In spirit of the signbit function of the C standard, the signbit optab
only guarantees that the resulting value is nonzero if the signbit is
set.  The common code implementation computes a value where the signbit
is stored in the most significant bit, i.e., all other bits are just
masked out, whereas the current implementation of s390 results in a
value where the signbit is stored in the least significant bit.
Although, there is no guarantee where the signbit is stored, keep the
current behaviour and, therefore, implement the signbit optab manually.

Since z10, instruction lgdr can be effectively used for a 64-bit
FPR-to-GPR load.  However, there exists no 32-bit pendant.  Thus, for
target z10 make use of post-reload splitters which emit either a 64-bit
or a 32-bit load depending on whether the source operand is a REG or a
MEM and a corresponding 63 or 31-bit shift.  We can do without
post-reload splitter in case of vector extensions since there we also
have a 32-bit VR-to-GPR load via instruction vlgvf.

gcc/ChangeLog:

* config/s390/s390.md (signbit_tdc): Rename expander.
(signbit<mode>2): New expander.
(signbit<mode>2_z10): New expander.

gcc/testsuite/ChangeLog:

* gcc.target/s390/isfinite-isinf-isnormal-signbit-2.c: Adapt
scan assembler directives.
* gcc.target/s390/isfinite-isinf-isnormal-signbit-3.c: Ditto.
* gcc.target/s390/signbit-1.c: New test.
* gcc.target/s390/signbit-2.c: New test.
* gcc.target/s390/signbit-3.c: New test.
* gcc.target/s390/signbit-4.c: New test.
* gcc.target/s390/signbit-5.c: New test.
* gcc.target/s390/signbit.h: New test.

36 hours agos390: Adapt GPR<->VR costs
Stefan Schulze Frielinghaus [Thu, 17 Jul 2025 10:44:06 +0000 (12:44 +0200)] 
s390: Adapt GPR<->VR costs

Moving between GPRs and VRs in any mode with size less than or equal to
8 bytes becomes available with vector extensions.  Without adapting
costs for those loads, we typically go over memory.

gcc/ChangeLog:

* config/s390/s390.cc (s390_register_move_cost): Add costing for
vlvg/vlgv.

36 hours agos390: Add implicit zero extend for VLGV
Stefan Schulze Frielinghaus [Thu, 17 Jul 2025 10:44:06 +0000 (12:44 +0200)] 
s390: Add implicit zero extend for VLGV

Exploit the fact that instruction VLGV zeros excessive bits of a GPR.

gcc/ChangeLog:

* config/s390/vector.md (bhfgq): Add scalar modes.
(*movdi<mode>_zero_extend_A): New insn.
(*movsi<mode>_zero_extend_A): New insn.
(*movdi<mode>_zero_extend_B): New insn.
(*movsi<mode>_zero_extend_B): New insn.

gcc/testsuite/ChangeLog:

* gcc.target/s390/vector/vlgv-zero-extend-1.c: New test.

38 hours agolibstdc++: Add comments to __unicode::_Utf_iterator
Jonathan Wakely [Tue, 15 Jul 2025 09:18:11 +0000 (10:18 +0100)] 
libstdc++: Add comments to __unicode::_Utf_iterator

Add comments documenting what it does and how it does it.

Also reorder the if-else in operator++ so that we check whether to
iterate over code units in the local buffer before checking whether to
refill that buffer. That seems the more natural way to structure the
function.

libstdc++-v3/ChangeLog:

* include/bits/unicode.h (__unicode::_Utf_iterator): Add
comments.
(__unicode:_Utf_iterator::operator++()): Check whether to
iterate over the buffer first.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
38 hours agolibstdc++: Use __promote_3 for std::hypot [PR121097]
Jonathan Wakely [Tue, 15 Jul 2025 20:29:33 +0000 (21:29 +0100)] 
libstdc++: Use __promote_3 for std::hypot [PR121097]

The __promoted_t alias is only defined when __cpp_fold_expressions is
defined, which might not be the case for some hypothetical C++17
compilers.

Change the 3-arg std::hypot to just use __gnu_cxx::__promote_3 which is
always available.

libstdc++-v3/ChangeLog:

PR libstdc++/121097
* include/c_global/cmath (hypot): Use __promote_3 instead of
__promoted.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
39 hours agoLoongArch: Fix wrong code generated by TARGET_VECTORIZE_VEC_PERM_CONST [PR121064]
Xi Ruoyao [Mon, 14 Jul 2025 19:01:12 +0000 (03:01 +0800)] 
LoongArch: Fix wrong code generated by TARGET_VECTORIZE_VEC_PERM_CONST [PR121064]

When TARGET_VECTORIZE_VEC_PERM_CONST is called, target may be the
same pseudo as op0 and/or op1.  Loading the selector into target
would clobber the input, producing wrong code like

    vld     $vr0, $t0
    vshuf.w $vr0, $vr0, $vr1

So don't load the selector into d->target, use a new pseudo to hold the
selector instead.  The reload pass will load the pseudo for selector and
the pseudo for target into the same hard register (following our
constraint '0' on the shuf instructions) anyway.

gcc/ChangeLog:

PR target/121064
* config/loongarch/lsx.md (lsx_vshuf_<lsxfmt_f>): Add '@' to
generate a mode-aware helper.  Use <VIMODE> as the mode of the
operand 1 (selector).
* config/loongarch/lasx.md (lasx_xvshuf_<lasxfmt_f>): Likewise.
* config/loongarch/loongarch.cc
(loongarch_try_expand_lsx_vshuf_const): Create a new pseudo for
the selector.  Use the mode-aware helper to simplify the code.
(loongarch_expand_vec_perm_const): Likewise.

gcc/testsuite/ChangeLog:

PR target/121064
* gcc.target/loongarch/pr121064.c: New test.

41 hours agoReject single lane vector types for SLP build
Richard Biener [Thu, 10 Jul 2025 11:04:00 +0000 (13:04 +0200)] 
Reject single lane vector types for SLP build

The following makes us never consider vector(1) T types for
vectorization and ensures this during SLP build.  This is a
long-standing issue for BB vectorization and when we remove
early loop vector type setting we lose the single place we have
that rejects this for loops.

Once we implement partial loop vectorization we should revisit
this, but then use the original scalar types for the unvectorized
parts.

* tree-vect-slp.cc (vect_build_slp_tree_1): Reject
single-lane vector types.

* gcc.dg/vect/bb-slp-39.c: Adjust.

41 hours agotree-optimization/121035 - handle stray VN values without expression
Richard Biener [Wed, 16 Jul 2025 18:19:44 +0000 (20:19 +0200)] 
tree-optimization/121035 - handle stray VN values without expression

When VN iterates we can end up with unreachable inserted expressions
in the expression tables which in turn will not be added to their
value by PREs compute_avail.  This will later ICE when we pick
them up and want to generate them.  Deal with this by giving up.

PR tree-optimization/121035
* tree-ssa-pre.cc (find_or_generate_expression): Handle
values without expression.

* gcc.dg/pr121035.c: New testcase.

47 hours agoDaily bump.
GCC Administrator [Thu, 17 Jul 2025 00:18:50 +0000 (00:18 +0000)] 
Daily bump.

2 days agolibgcc/Makefile.in: Delete dead `MACHMODE_H` variable
John Ericson [Wed, 16 Jul 2025 19:54:24 +0000 (15:54 -0400)] 
libgcc/Makefile.in: Delete dead `MACHMODE_H` variable

This dates back to the creation of top-level `libgcc` in
fa9585134f6f58fa0d3da3ca4ad5493855aea2dc. I strongly suspect that this
does nothing.

Andrew Pinksi adds:

> So looking into this further, MACHMODE_H used part of LIBGCC_DEPS
> because of TM_H and r0-78222-gfa9585134f6f58 moved away from including
> tm.h from libgcc. It was copied over unused.

It is indeed used then.

(For background context, my overall goal here is hoping libgcc can depend on
fewer/no stuff that is generated by `gcc/Makefile`. This is me trying to
pluck some low-hanging fruit -- this is the only direct mention of
`insn-modes.h` in libgcc.)

libgcc/ChangeLog:

* Makefile.in:  Delete dead `MACHMODE_H` variable

2 days agodiagnostics: remove redundant field
David Malcolm [Wed, 16 Jul 2025 22:41:26 +0000 (18:41 -0400)] 
diagnostics: remove redundant field

I stopped using state_diagram::m_show_tags in r16-2211-ga5d9debedd2f46
but forgot to remove the field.  Do so now.

Spotted by Filip Kastl via clang's -Wunused-private-field.

gcc/ChangeLog:
* diagnostic-state-to-dot.cc (state_diagram::m_show_tags): Drop
unused field.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 days agocontrib: add gcc/text-art to Doxygen input
David Malcolm [Wed, 16 Jul 2025 22:41:22 +0000 (18:41 -0400)] 
contrib: add gcc/text-art to Doxygen input

contrib/ChangeLog:
* gcc.doxy (INPUT): Add directory "gcc/text-art".

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 days agoopenmp: Refactor handling of iterators
Kwok Cheung Yeung [Wed, 16 Jul 2025 16:59:54 +0000 (17:59 +0100)] 
openmp: Refactor handling of iterators

Move code to calculate the iteration size and to generate the iterator
expansion loop into separate functions.

Use OMP_ITERATOR_DECL_P to check for iterators in clause declarations.

gcc/c-family/

* c-omp.cc (c_finish_omp_depobj): Use OMP_ITERATOR_DECL_P.

gcc/c/

* c-typeck.cc (handle_omp_array_sections): Use OMP_ITERATOR_DECL_P.
(c_finish_omp_clauses): Likewise.

gcc/cp/

* pt.cc (tsubst_omp_clause_decl): Use OMP_ITERATOR_DECL_P.
* semantics.cc (handle_omp_array_sections): Likewise.
(finish_omp_clauses): Likewise.

gcc/

* gimplify.cc (gimplify_omp_affinity): Use OMP_ITERATOR_DECL_P.
(compute_omp_iterator_count): New.
(build_omp_iterator_loop): New.
(gimplify_omp_depend): Use OMP_ITERATOR_DECL_P,
compute_omp_iterator_count and build_omp_iterator_loop.
* tree-inline.cc (copy_tree_body_r): Use OMP_ITERATOR_DECL_P.
* tree-pretty-print.cc (dump_omp_clause): Likewise.
* tree.h (OMP_ITERATOR_DECL_P): New macro.

2 days agox86: Convert MMX integer loads from constant vector pool
Uros Bizjak [Mon, 14 Jul 2025 21:05:10 +0000 (05:05 +0800)] 
x86: Convert MMX integer loads from constant vector pool

For MMX 16-bit, 32-bit and 64-bit constant vector loads from constant
vector pool:

(insn 6 2 7 2 (set (reg:V1SI 5 di)
        (mem/u/c:V1SI (symbol_ref/u:DI ("*.LC0") [flags 0x2]) [0  S4 A32])) "pr121062-2.c":10:3 2036 {*movv1si_internal}
     (expr_list:REG_EQUAL (const_vector:V1SI [
                (const_int -1 [0xffffffffffffffff])
            ])
        (nil)))

we can convert it to

(insn 12 2 7 2 (set (reg:SI 5 di)
        (const_int -1 [0xffffffffffffffff])) "pr121062-2.c":10:3 100 {*movsi_internal}
     (nil))

Co-Developed-by: H.J. Lu <hjl.tools@gmail.com>
gcc/

PR target/121062
* config/i386/i386.cc (ix86_convert_const_vector_to_integer):
Handle E_V1SImode and E_V1DImode.
* config/i386/mmx.md (V_16_32_64): Add V1SI, V2BF and V1DI.
(mmxinsnmode): Add V1DI and V1SI.
Add V_16_32_64 splitter for constant vector loads from constant
vector pool.
(V_16_32_64:*mov<mode>_imm): Moved after V_16_32_64 splitter.
Replace lowpart_subreg with adjust_address.

gcc/testsuite/

PR target/121062
* gcc.target/i386/pr121062-1.c: New test.
* gcc.target/i386/pr121062-2.c: Likewise.
* gcc.target/i386/pr121062-3a.c: Likewise.
* gcc.target/i386/pr121062-3b.c: Likewise.
* gcc.target/i386/pr121062-3c.c: Likewise.
* gcc.target/i386/pr121062-4.c: Likewise.
* gcc.target/i386/pr121062-5.c: Likewise.
* gcc.target/i386/pr121062-6.c: Likewise.
* gcc.target/i386/pr121062-7.c: Likewise.

2 days agox86: Warn -pg without -mfentry only on glibc targets
H.J. Lu [Wed, 16 Jul 2025 05:49:12 +0000 (22:49 -0700)] 
x86: Warn -pg without -mfentry only on glibc targets

Since only glibc targets support -mfentry, warn -pg without -mfentry only
on glibc targets.

gcc/

PR target/120881
PR testsuite/121078
* config/i386/i386-options.cc (ix86_option_override_internal):
Warn -pg without -mfentry only on glibc targets.

gcc/testsuite/

PR target/120881
PR testsuite/121078
* gcc.dg/20021014-1.c (dg-additional-options): Add -mfentry
-fno-pic only on gnu/x86 targets.
* gcc.dg/aru-2.c (dg-additional-options): Likewise.
* gcc.dg/nest.c (dg-additional-options): Likewise.
* gcc.dg/pr32450.c (dg-additional-options): Likewise.
* gcc.dg/pr43643.c (dg-additional-options): Likewise.
* gcc.target/i386/pr104447.c (dg-additional-options): Likewise.
* gcc.target/i386/pr113122-3.c(dg-additional-options): Likewise.
* gcc.target/i386/pr119386-1.c (dg-additional-options): Add
-mfentry only on gnu targets.
* gcc.target/i386/pr119386-2.c (dg-additional-options): Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 days agoi386: Use various predicates instead of open coding them
Uros Bizjak [Wed, 16 Jul 2025 18:11:10 +0000 (20:11 +0200)] 
i386: Use various predicates instead of open coding them

No functional changes.

gcc/ChangeLog:

* config/i386/i386-expand.cc (ix86_expand_move):
Use MEM_P predicate instead of open coding it.
(ix86_erase_embedded_rounding):
Use NONJUMP_INSN_P predicate instead of open coding it.
* config/i386/i386-features.cc (convertible_comparison_p):
Use REG_P predicate instead of open coding it.
* config/i386/i386.cc (ix86_rtx_costs):
Use SUBREG_P predicate instead of open coding it.

2 days agoi386: Use LABEL_REF_P predicate instead of open coding it
Uros Bizjak [Wed, 16 Jul 2025 18:04:44 +0000 (20:04 +0200)] 
i386: Use LABEL_REF_P predicate instead of open coding it

No functional changes.

gcc/ChangeLog:

* config/i386/i386.cc (symbolic_reference_mentioned_p):
Use LABEL_REF_P predicate instead of open coding it.
(ix86_legitimate_constant_p): Ditto.
(legitimate_pic_address_disp_p): Ditto.
(ix86_legitimate_address_p): Ditto.
(legitimize_pic_address): Ditto.
(ix86_print_operand): Ditto.
(ix86_print_operand_address_as): Ditto.
(ix86_rip_relative_addr_p): Ditto.
* config/i386/i386.h (SYMBOLIC_CONST): Ditto.
* config/i386/i386.md (*anddi_1 to *andsi_1_zext splitter): Ditto.
* config/i386/predicates.md (symbolic_operand): Ditto.
(local_symbolic_operand): Ditto.
(vsib_address_operand): Ditto.

2 days agoi386: Use SYMBOL_REF_P predicate instead of open coding it
Uros Bizjak [Wed, 16 Jul 2025 17:59:07 +0000 (19:59 +0200)] 
i386: Use SYMBOL_REF_P predicate instead of open coding it

No functional changes.

gcc/ChangeLog:

* config/i386/i386-expand.cc (ix86_expand_move):
Use SYMBOL_REF_P predicate instead of open coding it.
(ix86_split_long_move): Ditto.
(construct_plt_address): Ditto.
(ix86_expand_call): Ditto.
(ix86_notrack_prefixed_insn_p): Ditto.
* config/i386/i386-features.cc
(rest_of_insert_endbr_and_patchable_area): Ditto.
* config/i386/i386.cc (symbolic_reference_mentioned_p): Ditto.
(ix86_force_load_from_GOT_p): Ditto.
(ix86_legitimate_constant_p): Ditto.
(legitimate_pic_operand_p): Ditto.
(legitimate_pic_address_disp_p): Ditto.
(ix86_legitimate_address_p): Ditto.
(legitimize_pic_address): Ditto.
(ix86_legitimize_address): Ditto.
(ix86_delegitimize_tls_address): Ditto.
(ix86_print_operand): Ditto.
(ix86_print_operand_address_as): Ditto.
(ix86_rip_relative_addr_p): Ditto.
(symbolic_base_address_p): Ditto.
* config/i386/i386.h (SYMBOLIC_CONST): Ditto.
* config/i386/i386.md (*anddi_1 to *andsi_1_zext splitter): Ditto.
* config/i386/predicates.md (symbolic_operand): Ditto.
(local_symbolic_operand): Ditto.
(local_func_symbolic_operand): Ditto.

2 days agoi386: Use CONST_VECTOR_P predicate instead of open coding it
Uros Bizjak [Wed, 16 Jul 2025 17:46:03 +0000 (19:46 +0200)] 
i386: Use CONST_VECTOR_P predicate instead of open coding it

No functional changes.

gcc/ChangeLog:

* config/i386/i386-expand.cc (ix86_expand_vector_logical_operator):
Use CONST_VECTOR_P instead of open coding it.
(ix86_expand_int_sse_cmp): Ditto.
(ix86_extract_perm_from_pool_constant): Ditto.
(ix86_split_to_parts): Ditto.
(const_vector_equal_evenodd_p): Ditto.
* config/i386/i386.cc (ix86_print_operand): Ditto.
* config/i386/predicates.md (zero_extended_scalar_load_operand): Ditto.
(float_vector_all_ones_operand): Ditto.
* config/i386/sse.md (avx512vl_vextractf128<mode>): Ditto.

2 days agotree-optimization/121049 - avoid loop masking with even/odd reduction
Richard Biener [Wed, 16 Jul 2025 13:07:58 +0000 (15:07 +0200)] 
tree-optimization/121049 - avoid loop masking with even/odd reduction

The following disables loop masking when we are using an even/odd
widening operation in a reduction because the loop mask then aligns
to the wrong elements.

PR tree-optimization/121049
* internal-fn.h (widening_evenodd_fn_p): Declare.
* internal-fn.cc (widening_evenodd_fn_p): New function.
* tree-vect-stmts.cc (vectorizable_conversion): When using
an even/odd widening function disable loop masking.

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

2 days agoifconv: simple factor out operators while doing ifcvt [PR119920]
Andrew Pinski [Tue, 8 Jul 2025 03:01:04 +0000 (20:01 -0700)] 
ifconv: simple factor out operators while doing ifcvt [PR119920]

For possible reductions, ifconv currently handles if the addition
is on one side of the if. But in the case of PR 119920, the reduction
addition is on both sides of the if.
E.g.
```
  if (_27 == 0)
    goto <bb 14>; [50.00%]
  else
    goto <bb 13>; [50.00%]

  <bb 14>
  a_29 = b_14(D) + a_17;
  goto <bb 15>; [100.00%]

  <bb 13>
  a_28 = c_12(D) + a_17;

  <bb 15>
  # a_30 = PHI <a_28(13), a_29(14)>
```

Which ifcvt converts into:
```
  _34 = _32 + _33;
  a_15 = (int) _34;
  _23 = _4 == 0;
  _37 = _33 + _35;
  a_13 = (int) _37;
  a_5 = _23 ? a_15 : a_13;
```

But the vectorizer does not recognize this as a reduction.
To fix this, we should factor out the addition from the `if`.
This allows us to get:
```
  iftmp.0_7 = _22 ? b_13(D) : c_12(D);
  a_14 = iftmp.0_7 + a_18;
```

Which then the vectorizer recognizes as a reduction.

In the case of PR 112324 and PR 110015, it is similar but with MAX_EXPR reduction
instead of an addition.

Note while this should be done in phiopt, there are regressions
due to other passes not able to handle the factored out cases
(see linked bug to PR 64700). I have not had time to fix all of the passes
that could handle the addition being in the if/then/else rather than being outside yet.
So this is I thought it would be useful just to have a localized version in ifconv which
is then only used for the vectorizer.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/119920
PR tree-optimization/112324
PR tree-optimization/110015

gcc/ChangeLog:

* tree-if-conv.cc (find_different_opnum): New function.
(factor_out_operators): New function.
(predicate_scalar_phi): Call factor_out_operators when
there is only 2 elements of a phi.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/vect-reduc-cond-1.c: New test.
* gcc.dg/vect/vect-reduc-cond-2.c: New test.
* gcc.dg/vect/vect-reduc-cond-3.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 days agoifconv: Small improvement to fold_build_cond_expr; lhs and rhs being the same.
Andrew Pinski [Mon, 7 Jul 2025 19:16:54 +0000 (12:16 -0700)] 
ifconv: Small improvement to fold_build_cond_expr; lhs and rhs being the same.

This is a small compile time optimization, as match and simplify will generate
the same thing but with rhs and lhs being the same we can return early instead
of having to go through match and simplify. This might not show up that much
at this point but can/will show up after my patch for PR 119920 where we factor
out common code between the 2 sides of the if statement while in if-conv.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-if-conv.cc (fold_build_cond_expr): Return early if lhs and rhs
are the same.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 days agoifconv: Remove unused array predicated
Andrew Pinski [Sun, 6 Jul 2025 18:40:44 +0000 (11:40 -0700)] 
ifconv: Remove unused array predicated

While starting to improve if-conv, I noticed that predicated
was only being set once inside a loop and accessed right below.
This became this way due to r14-8869-g8636c538b68068 and before
it was needed since it was accessed via 2 loops but now it is only set
and then accessed in the next statement, there is no reason for it being
there.  So let's remove it and just use the value from it instead.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-if-conv.cc (combine_blocks): Remove predicated
dynamic array.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 days agotree-optimization/121116 - avoid _BitInt for vector element init
Richard Biener [Wed, 16 Jul 2025 12:07:48 +0000 (14:07 +0200)] 
tree-optimization/121116 - avoid _BitInt for vector element init

When having a _BitInt induction we should make sure to not create
the step vector elements as _BitInts but as vector element typed.

PR tree-optimization/121116
* tree-vect-loop.cc (vectorizable_induction): Use the
step vector element type for further processing.

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

2 days agolibstdc++: Use basic_string_view for std::bitset deduced types
Jonathan Wakely [Sat, 12 Jul 2025 12:12:09 +0000 (13:12 +0100)] 
libstdc++: Use basic_string_view for std::bitset deduced types

This change was part of by P2697R1 (Interfacing bitset with string_view)
and should be slightly cheaper to instantiate.

We should consider using basic_string_view for C++17, C++20, and C++23
as well. This patch just conservatively changes it for C++26 to match
the working draft. It's conceivable that a program-defined
specialization of basic_string<_CharT> or basic_string_view<_CharT> will
observe a difference and be affected by this change.

libstdc++-v3/ChangeLog:

* include/std/bitset (__bitset::__string) [__cpp_lib_bitset]:
Change alias to refer to basic_string_view instead.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 days agoamdgcn: Fix various unrecognized pattern issues with add<mode>3_vcc_dup
Andrew Stubbs [Wed, 9 Jul 2025 15:00:43 +0000 (15:00 +0000)] 
amdgcn: Fix various unrecognized pattern issues with add<mode>3_vcc_dup

The patterns did not accept inline immediate constants, even though the
hardware instructions do, which has lead to some errors in some patches I'm
working on.

Also the VCC update RTL was using the wrong operands in the wrong places.  This
appears to have been harmless(?) but is definitely not intended.

gcc/ChangeLog:

* config/gcn/gcn-valu.md (add<mode>3_vcc_dup<exec_vcc>): Change
operand 2 to allow gcn_alu_operand.  Swap the operands in the VCC
update RTL.
(add<mode>3_vcc_zext_dup): Likewise.
(add<mode>3_vcc_zext_dup_exec): Likewise.
(add<mode>3_vcc_zext_dup2): Likewise.
(add<mode>3_vcc_zext_dup2_exec): Likewise.

2 days agolibstdc++: Do not define __cpp_lib_constexpr_exceptions [PR121114]
Tomasz Kamiński [Wed, 16 Jul 2025 08:49:48 +0000 (10:49 +0200)] 
libstdc++: Do not define __cpp_lib_constexpr_exceptions [PR121114]

Do not advertise library support for constexpr exceptions, as our
solution to throwing by __throw_* functions from <bits/functexcept.h>,
caues constant evaluation to fail, as these functions are not constexpr.

PR libstdc++/121114

libstdc++-v3/ChangeLog:

* include/bits/version.def (constexpr_exceptions): Add no_stdname
and changed value.
* include/bits/version.h: Regenerated.
* testsuite/18_support/exception/version.cc: Test that macro is
not exported.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kaminski <tkaminsk@redhat.com>
2 days agoaarch64: Fold builtins with highpart args to highpart equivalent [PR117850]
Spencer Abson [Tue, 15 Jul 2025 10:12:08 +0000 (10:12 +0000)] 
aarch64: Fold builtins with highpart args to highpart equivalent [PR117850]

Add a fold at gimple_fold_builtin to prefer the highpart variant of a builtin
if at least one argument is a vector highpart and all others are VECTOR_CSTs
that we can extend to 128-bits.

For example, we prefer to duplicate f0 and use UMULL2 here over DUP+UMULL:

uint16x8_t
foo (const uint8x16_t s)
{
    const uint8x8_t f0 = vdup_n_u8 (4);
    return vmull_u8 (vget_high_u8 (s), f0);
}

gcc/ChangeLog:
PR target/117850
* config/aarch64/aarch64-builtins.cc (LO_HI_PAIRINGS): New, group the
lo/hi pairs from aarch64-builtin-pairs.def.
(aarch64_get_highpart_builtin): New function.
(aarch64_v128_highpart_ref): New function, helper to look for vector
highparts.
(aarch64_build_vector_cst): New function, helper to build duplicated
VECTOR_CSTs.
(aarch64_fold_lo_call_to_hi): New function.
(aarch64_general_gimple_fold_builtin): Add cases for the lo builtins
in aarch64-builtin-pairs.def.
* config/aarch64/aarch64-builtin-pairs.def: New file, declare the
parirs of lowpart-operating and highpart-operating builtins.

gcc/testsuite/ChangeLog:
PR target/117850
* gcc.target/aarch64/simd/vabal_combine.c: Removed.  This is
covered by fold_to_highpart_1.c
* gcc.target/aarch64/simd/fold_to_highpart_1.c: New test.
* gcc.target/aarch64/simd/fold_to_highpart_2.c: Likewise.
* gcc.target/aarch64/simd/fold_to_highpart_3.c: Likewise.
* gcc.target/aarch64/simd/fold_to_highpart_4.c: Likewise.
* gcc.target/aarch64/simd/fold_to_highpart_5.c: Likewise.
* gcc.target/aarch64/simd/fold_to_highpart_6.c: Likewise.

2 days agoAdd get_clone_versions and get_target_version functions.
Alfie Richards [Fri, 31 Jan 2025 10:51:14 +0000 (10:51 +0000)] 
Add get_clone_versions and get_target_version functions.

This is a reimplementation of get_target_clone_attr_len,
get_attr_str, and separate_attrs using string_slice and auto_vec to make
memory management and use simpler.

Adds get_target_version helper function to get the target_version string
from a decl.

gcc/c-family/ChangeLog:

* c-attribs.cc (handle_target_clones_attribute): Change to use
get_clone_versions.

gcc/ChangeLog:

* tree.cc (get_clone_versions): New function.
(get_clone_attr_versions): New function.
(get_version): New function.
* tree.h (get_clone_versions): New function.
(get_clone_attr_versions): New function.
(get_target_version): New function.

2 days agoChange make_attribute to take string_slice.
Alfie Richards [Fri, 31 Jan 2025 10:49:42 +0000 (10:49 +0000)] 
Change make_attribute to take string_slice.

gcc/ChangeLog:

* attribs.cc (make_attribute): Change arguments.
* attribs.h (make_attribute): Change arguments.

2 days agoRemove unnecessary `record` argument from maybe_version_functions.
Alfie Richards [Tue, 28 Jan 2025 15:42:49 +0000 (15:42 +0000)] 
Remove unnecessary `record` argument from maybe_version_functions.

Previously, the `record` argument in maybe_version_function allowed the
call to cgraph_node::record_function_versions to be skipped.  However,
this was only skipped when both decls were already marked as versioned,
in which case we trigger the early exit in record_function_versions
instead. Therefore, the argument is unnecessary.

gcc/cp/ChangeLog:

* class.cc (add_method): Remove argument.
* cp-tree.h (maybe_version_functions): Ditto.
* decl.cc (decls_match): Ditto.
(maybe_version_functions): Ditto.

2 days agoAdd string_slice class.
Alfie Richards [Mon, 24 Mar 2025 10:45:56 +0000 (10:45 +0000)] 
Add string_slice class.

The string_slice inherits from array_slice and is used to refer to a
substring of an array that is memory managed elsewhere without modifying
the underlying array.

For example, this is useful in cases such as when needing to refer to a
substring of an attribute in the syntax tree.

Adds some minimal helper functions for string_slice,
such as a strtok alternative, equality operators, strcmp, and a function
to strip whitespace from the beginning and end of a string_slice.

gcc/c-family/ChangeLog:

* c-format.cc (local_string_slice_node): New node type.
(asm_fprintf_char_table): New entry.
(init_dynamic_diag_info): Add support for string_slice.
* c-format.h (T_STRING_SLICE): New node type.

gcc/ChangeLog:

* pretty-print.cc (format_phase_2): Add support for string_slice.
* vec.cc (string_slice::tokenize): New static method.
(string_slice::strcmp): New static method.
(string_slice::strip): New method.
(test_string_slice_initializers): New test.
(test_string_slice_tokenize): Ditto.
(test_string_slice_strcmp): Ditto.
(test_string_slice_equality): Ditto.
(test_string_slice_inequality): Ditto.
(test_string_slice_invalid): Ditto.
(test_string_slice_strip): Ditto.
(vec_cc_tests): Add new tests.
* vec.h (class string_slice): New class.

gcc/testsuite/ChangeLog
* g++.dg/warn/Wformat-gcc_diag-1.C: Add string_slice "%B" format tests.

2 days agoexpand: Allow fixed-point arithmetic for RDIV_EXPR.
Robin Dapp [Tue, 15 Jul 2025 08:55:36 +0000 (10:55 +0200)] 
expand: Allow fixed-point arithmetic for RDIV_EXPR.

r16-2175-g5aa21765236730 introduced an assert for floating-point modes
when expanding an RDIV_EXPR but forgot fixed-point modes.  This patch
adds ALL_FIXED_POINT_MODE_P to the assert.

PR middle-end/121065

gcc/ChangeLog:

* cfgexpand.cc (expand_debug_expr): Allow fixed-point modes for
RDIV_EXPR.
* optabs-tree.cc (optab_for_tree_code): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/arm/pr121065.c: New test.

2 days agoRISC-V: Fix vsetvl merge rule.
Robin Dapp [Mon, 14 Jul 2025 11:53:12 +0000 (13:53 +0200)] 
RISC-V: Fix vsetvl merge rule.

In PR120297 we fuse
  vsetvl e8,mf2,...
  vsetvl e64,m1,...
into
  vsetvl e64,m4,...

Individually, that's ok but we also change the new vsetvl's demand to
"SEW only" even though the first original one demanded SEW >= 8 and
ratio = 16.

As we forget the ratio after the merge we find that the vsetvl following
the merged one has ratio = 64 demand and we fuse into
  vsetvl e64,m1,..
which obviously doesn't have ratio = 16 any more.

Regtested on rv64gcv_zvl512b.

PR target/120297

gcc/ChangeLog:

* config/riscv/riscv-vsetvl.def: Do not forget ratio demand of
previous vsetvl.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/pr120297.c: New test.

2 days agoaarch64: Use SVE2 BSL2N for vector EON
Kyrylo Tkachov [Fri, 11 Jul 2025 14:23:16 +0000 (07:23 -0700)] 
aarch64: Use SVE2 BSL2N for vector EON

SVE2 BSL2N (x, y, z) = (x & z) | (~y & ~z). When x == y this computes:
(x & z) | (~x & ~z) which is ~(x ^ z).
Thus, we can use it to match RTL patterns (not (xor (...) (...))) for both
Advanced SIMD and SVE modes when TARGET_SVE2.
This patch does that.
For code like:

uint64x2_t eon_q(uint64x2_t a, uint64x2_t b) { return EON(a, b); }
svuint64_t eon_z(svuint64_t a, svuint64_t b) { return EON(a, b); }

We now generate:
eon_q:
        bsl2n   z0.d, z0.d, z0.d, z1.d
        ret

eon_z:
        bsl2n   z0.d, z0.d, z0.d, z1.d
        ret

instead of the previous:
eon_q:
        eor     v0.16b, v0.16b, v1.16b
        not     v0.16b, v0.16b
        ret

eon_z:
        eor     z0.d, z0.d, z1.d
        ptrue   p3.b, all
        not     z0.d, p3/m, z0.d
        ret

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

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
gcc/

* config/aarch64/aarch64-sve2.md (*aarch64_sve2_bsl2n_eon<mode>):
New pattern.
(*aarch64_sve2_eon_bsl2n_unpred<mode>): Likewise.

gcc/testsuite/

* gcc.target/aarch64/sve2/eon_bsl2n.c: New test.

2 days agoaarch64: Use SVE2 NBSL for vector NOR and NAND for Advanced SIMD modes
Kyrylo Tkachov [Fri, 11 Jul 2025 09:50:32 +0000 (02:50 -0700)] 
aarch64: Use SVE2 NBSL for vector NOR and NAND for Advanced SIMD modes

We already have patterns to use the NBSL instruction to implement vector
NOR and NAND operations for SVE types and modes.  It is straightforward to
have similar patterns for the fixed-width Advanced SIMD modes as well, though
it requires combine patterns without the predicate operand and an explicit 'Z'
output modifier.  This patch does so.

So now for example we generate for:

uint64x2_t nand_q(uint64x2_t a, uint64x2_t b) { return NAND(a, b); }
uint64x2_t nor_q(uint64x2_t a, uint64x2_t b) { return NOR(a, b); }

nand_q:
        nbsl    z0.d, z0.d, z1.d, z1.d
        ret

nor_q:
        nbsl    z0.d, z0.d, z1.d, z0.d
        ret

instead of the previous:
nand_q:
        and     v0.16b, v0.16b, v1.16b
        not     v0.16b, v0.16b
        ret

nor_q:
        orr     v0.16b, v0.16b, v1.16b
        not     v0.16b, v0.16b
        ret

The tied operand requirements for NBSL mean that we can generate the MOVPRFX
when the operands fall that way, but I guess having a 2-insn MOVPRFX form is
not worse than the current 2-insn codegen at least, and the MOVPRFX can be
fused by many cores.

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

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
gcc/

* config/aarch64/aarch64-sve2.md (*aarch64_sve2_unpred_nor<mode>):
New define_insn.
(*aarch64_sve2_nand_unpred<mode>): Likewise.

gcc/testsuite/

* gcc.target/aarch64/sve2/nbsl_nor_nand_neon.c: New test.

2 days agoFortran: Fix ICE in ASSOCIATE with user defined operator [PR121060]
Paul Thomas [Wed, 16 Jul 2025 05:16:57 +0000 (06:16 +0100)] 
Fortran: Fix ICE in ASSOCIATE with user defined operator [PR121060]

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

gcc/fortran
PR fortran/121060
* interface.cc (matching_typebound_op): Defer determination of
specific procedure until resolution by returning NULL.

gcc/testsuite/
PR fortran/121060
* gfortran.dg/associate_75.f90: New test.

2 days agoFortran: Fix ICE in F2018 IMPORT statements.
Paul Thomas [Wed, 16 Jul 2025 05:11:25 +0000 (06:11 +0100)] 
Fortran: Fix ICE in F2018 IMPORT statements.

2025-07-16  Steve Kargl  <sgk@troutmask.apl.washington.edu>

gcc/fortran
* decl.cc (gfc_match_import): Correct minor whitespace snafu
and fix NULL pointer dereferences in two places.

gcc/testsuite/
* gfortran.dg/import13.f90: New test.

2 days agoc, c++: Fix unused result for empty types [PR82134]
Jeremy Rifkin [Tue, 15 Jul 2025 22:17:01 +0000 (18:17 -0400)] 
c, c++: Fix unused result for empty types [PR82134]

Hi,
This fixes PR c/82134 which concerns gcc emitting an incorrect unused
result diagnostic for empty types. This diagnostic is emitted from
tree-cfg.cc because of a couple code paths which attempt to avoid
copying empty types, resulting in GIMPLE that isn't using the returned
value of a call. To fix this I've added suppress_warning in three locations
and a corresponding check in do_warn_unused_result.

Cheers,
Jeremy

PR c/82134

gcc/cp/ChangeLog:

* call.cc (build_call_a): Add suppress_warning
* cp-gimplify.cc (cp_gimplify_expr): Add suppress_warning

gcc/ChangeLog:

* gimplify.cc (gimplify_modify_expr): Add suppress_warning
* tree-cfg.cc (do_warn_unused_result): Check warning_suppressed_p

gcc/testsuite/ChangeLog:

* c-c++-common/attr-warn-unused-result-2.c: New test.

Signed-off-by: Jeremy Rifkin <jeremy@rifkin.dev>
2 days agoi386: Decouple AMX-AVX512 from AVX10.2 and imply AVX512F
Haochen Jiang [Tue, 15 Jul 2025 02:44:54 +0000 (10:44 +0800)] 
i386: Decouple AMX-AVX512 from AVX10.2 and imply AVX512F

In ISE058, the AVX10.2 imply is removed from AMX-AVX512. This
leads to re-consideration on the imply for AMX-AVX512.

Since it is using zmm register and using zmm register only, we
need to at least imply AVX512F. AVX512VL is not needed.

On the other hand, if we imply AVX10.1 for AMX-AVX512, it will
cause -mno-avx10.1 disabling AMX-AVX512. This would be a surprise
for users.

Based on the two reasons above, the patch is decoupling AMX-AVX512
from AVX10.2 and imply AVX512F.

gcc/ChangeLog:

* common/config/i386/i386-common.cc
(OPTION_MASK_ISA2_AMX_AVX512_SET): Do not set AVX10.2.
(OPTION_MASK_ISA2_AVX10_2_UNSET): Remove AMX-AVX512 unset.
(OPTION_MASK_ISA2_AVX512F_UNSET): Unset AMX-AVX512.
(ix86_handle_option): Imply AVX512F for AMX-AVX512.

gcc/testsuite/ChangeLog:

* gcc.target/i386/amxavx512-cvtrowd2ps-2.c: Add -mavx512fp16 to
use FP16 related intrins for convert.
* gcc.target/i386/amxavx512-cvtrowps2bf16-2.c: Ditto.
* gcc.target/i386/amxavx512-cvtrowps2ph-2.c: Ditto.
* gcc.target/i386/amxavx512-movrow-2.c: Ditto.

2 days agoRISC-V: Refine the scalar SAT_* test cases
Pan Li [Sat, 12 Jul 2025 14:26:32 +0000 (22:26 +0800)] 
RISC-V: Refine the scalar SAT_* test cases

Per previous discuss with Jeff, we don't do complicated
asm check like scalar saturation alu.  It is somehow
not easy to maintain, as well as fragile.  Thus, we
remove these function-body check, and introduce the
jmp label asm check instead.The code-gen of SAT_*
will never have a jmp, and the other run test will
make sure the correctness of SAT_* code-gen.

The below test suites are passed for this patch series.
* The rv64gcv fully regression test.

The below failed test cases are resolved:
FAIL: gcc.target/riscv/sat/sat_s_add_imm-2-i8.c -Oz
  check-function-bodies sat_s_add_imm_int8_t_fmt_2_1
FAIL: gcc.target/riscv/sat/sat_s_add_imm-2-i8.c -Os
  check-function-bodies sat_s_add_imm_int8_t_fmt_2_1
FAIL: gcc.target/riscv/sat/sat_s_add_imm-2-i8.c -O3
  check-function-bodies sat_s_add_imm_int8_t_fmt_2_1
FAIL: gcc.target/riscv/sat/sat_s_add_imm-2-i8.c -Ofast
  check-function-bodies sat_s_add_imm_int8_t_fmt_2_1
FAIL: gcc.target/riscv/sat/sat_s_add_imm-2-i8.c -O2
  check-function-bodies sat_s_add_imm_int8_t_fmt_2_1

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat/sat_s_add-1-i16.c: Remove function-body
check and add no jmp label asm check.
* gcc.target/riscv/sat/sat_s_add-1-i32.c:
* gcc.target/riscv/sat/sat_s_add-1-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-1-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-2-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-2-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-2-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-2-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-3-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-3-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-3-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-3-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-4-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-4-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-4-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-4-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-1-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-1-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-1-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-1-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-2-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-2-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-2-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-2-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-1-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-1-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-1-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-1-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-2-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-2-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-2-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-2-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-3-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-3-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-3-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-3-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-4-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-4-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-4-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-4-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-1-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-1-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-1-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-1-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-2-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-2-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-2-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-2-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-3-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-3-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-3-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-3-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-4-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-4-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-4-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-4-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-5-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-5-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-5-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-5-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-6-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-6-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-6-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-6-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-7-u16-from-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-7-u16-from-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-7-u32-from-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-7-u8-from-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-7-u8-from-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-7-u8-from-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-1-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-1-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-1-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-1-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-2-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-2-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-2-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-2-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-3-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-3-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-3-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-3-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-4-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-4-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-4-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-4-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_mul-1-u16-from-u128.c: Ditto.
* gcc.target/riscv/sat/sat_u_mul-1-u32-from-u128.c: Ditto.
* gcc.target/riscv/sat/sat_u_mul-1-u64-from-u128.c: Ditto.
* gcc.target/riscv/sat/sat_u_mul-1-u8-from-u128.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-1-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-1-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-1-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-1-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-10-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-10-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-10-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-10-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-11-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-11-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-11-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-11-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-12-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-12-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-12-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-12-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-2-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-2-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-2-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-2-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-3-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-3-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-3-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-3-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-4-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-4-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-4-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-4-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-5-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-5-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-5-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-5-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-6-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-6-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-6-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-6-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-7-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-7-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-7-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-7-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-8-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-8-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-8-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-8-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-9-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-9-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-9-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-9-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u16-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u16-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u16-3.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u16-4.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u32-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u32-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u32-3.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u32-4.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u64-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u64-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u8-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u8-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u8-3.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u8-4.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u16-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u16-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u16-3.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u32-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u32-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u32-3.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u64-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u8-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u8-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u8-3.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u16-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u16-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u32-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u32-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u8-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u8-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u16-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u16-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u32-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u32-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u8-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u8-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-1-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-1-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-1-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-1-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u8.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 days agoRISC-V: Support RVVDImode for avg3_floor auto vect
Pan Li [Tue, 15 Jul 2025 01:45:05 +0000 (09:45 +0800)] 
RISC-V: Support RVVDImode for avg3_floor auto vect

The avg3_floor pattern leverage the add and shift rtl
with the DOUBLE_TRUNC mode iterator.  Aka, RVVDImode
iterator will generate avg3rvvsimode_floor, only the
element size QI, HI and SI are allowed.

Thus, this patch would like to support the DImode by
the standard name, with the iterator V_VLSI_D.

The below test suites are passed for this patch series.
* The rv64gcv fully regression test.

gcc/ChangeLog:

* config/riscv/autovec.md (avg<mode>3_floor): Add new
pattern of avg3_floor for rvv DImode.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/avg.h: Add int128 type when
xlen == 64.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i16-from-i32.c:
Suppress __int128 warning for run test.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i16-from-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i32-from-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i8-from-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i8-from-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i8-from-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_data.h: Fix one incorrect
test data.
* gcc.target/riscv/rvv/autovec/avg_floor-run-1-i16-from-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_floor-run-1-i16-from-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_floor-run-1-i32-from-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_floor-run-1-i8-from-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_floor-run-1-i8-from-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_floor-run-1-i8-from-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_floor-1-i64-from-i128.c: New test.
* gcc.target/riscv/rvv/autovec/avg_floor-run-1-i64-from-i128.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 days agoDaily bump.
GCC Administrator [Wed, 16 Jul 2025 00:18:49 +0000 (00:18 +0000)] 
Daily bump.

3 days agospellcheck.{cc,h}: modernization
David Malcolm [Tue, 15 Jul 2025 20:19:53 +0000 (16:19 -0400)] 
spellcheck.{cc,h}: modernization

No functional change intended.

gcc/ChangeLog:
* spellcheck.cc: Define INCLUDE_ALGORITHM.
(CASE_COST, BASE_COST): Convert to...
(case_cost, base_cost): ...these, in an anonymous namespace.
(get_edit_distance): Update for above.  Use std::min rather than
MIN.
(get_edit_distance_cutoff): Likewise.  Use std::max rather than
MAX.
(selftest::test_edit_distances): Update for BASE_COST renaming.
(selftest::get_old_cutoff): Likewise.  Use std::max.
(selftest::assert_not_suggested_for): Use nullptr.
(selftest::test_find_closest_string): Likewise.
* spellcheck.h: Replace TYPE with StringLikeType in templates,
and use CamelCase.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 days agolibgdiagnostics: add diagnostic_message_buffer [PR120792]
David Malcolm [Tue, 15 Jul 2025 20:19:42 +0000 (16:19 -0400)] 
libgdiagnostics: add diagnostic_message_buffer [PR120792]

This patch extends libgdiagnostics to provide a way to capture
the pp tokens making up a message string, so that SARIF and
HTML sinks can retain information such as event IDs and URLs.
As well as richer output, this improves the round-tripping of such
information through sarif-replay.

This also allows diagnostic messages to be built up in pieces,
with a drop-in replacement for fprintf, which I've found useful when
attempting to port "ld" to use libgdiagnostics.

gcc/ChangeLog:
PR sarif-replay/120792
* auto-obstack.h: New file, based on material taken from
pretty-print.cc.
* diagnostic-digraphs.h
(diagnostics::digraphs::digraph::set_description): New.
(diagnostics::digraphs::node::set_label): New.
* doc/libgdiagnostics/topics/compatibility.rst: Add
LIBGDIAGNOSTICS_ABI_4.
* doc/libgdiagnostics/topics/diagnostics.rst
(diagnostic_finish_via_msg_buf): Document new entrypoint.
* doc/libgdiagnostics/topics/execution-paths.rst
(diagnostic_execution_path_add_event_via_msg_buf): Document new
entrypoint.
* doc/libgdiagnostics/topics/index.rst: Add message-buffers.rst.
* doc/libgdiagnostics/topics/message-buffers.rst: New file.
* doc/libgdiagnostics/topics/message-formatting.rst: Add note
about message buffers.
* doc/libgdiagnostics/topics/physical-locations.rst
(diagnostic_add_location_with_label_via_msg_buf): Add.
* doc/libgdiagnostics/tutorial/07-execution-paths.rst: Link to
next section.
* doc/libgdiagnostics/tutorial/08-message-buffers.rst: New file.
* doc/libgdiagnostics/tutorial/index.rst: Add
08-message-buffers.rst.
* libgdiagnostics++.h (libgdiagnostics::message_buffer): New
class.
(libgdiagnostics::execution_path::add_event_via_msg_buf): New.
(libgdiagnostics::diagnostic::add_location_with_label): New.
(libgdiagnostics::diagnostic::finish_via_msg_buf): New.
(libgdiagnostics::graph::set_description): New overload.
(libgdiagnostics::graph::add_edge): New overload.
(libgdiagnostics::node::set_label): New overload.
* libgdiagnostics-private.h
(private_diagnostic_execution_path_add_event_2): Drop decl.
(private_diagnostic_execution_path_add_event_3): New decl.
* libgdiagnostics.cc:  Include "pretty-print-format-impl.h",
"pretty-print-markup.h", and "auto-obstack.h".
(class copying_token_printer): New.
(struct diagnostic_message_buffer): New.
(class pp_element_message_buffer): New.
(libgdiagnostics_path_event::libgdiagnostics_path_event): Replace
params "gmsgid" and "args" with "msg_buf".
(libgdiagnostics_path_event::print_desc): Reimplement using
pp_element_message_buffer to replay m_msg_buf into "pp".
(libgdiagnostics_path_event::m_desc_uncolored): Drop field.
(libgdiagnostics_path_event::m_desc_colored): Drop field.
(libgdiagnostics_path_event::msg_buf): New field.
(diagnostic_execution_path::add_event_va): Reimplement.
(diagnostic_execution_path::add_event_via_msg_buf): New.
(diagnostic::add_location_with_label): New overload, using
msg_buf.
(diagnostic_manager::emit): Reimplement with...
(diagnostic_manager::emit_va): ...this.
(diagnostic_manager::emit_msg_buf): New.
(FAIL_IF_NULL): Rename "p" to "ptr_arg".
(diagnostic_finish_va): Update to use diagnostic_manager::emit_va.
(diagnostic_graph::add_node_with_id): Rename "id" to "node_id".
(diagnostic_graph_add_node): Likewise.
(diagnostic_graph_add_edge): Rename "id" to "edge_id".
(diagnostic_graph_get_node_by_id): Rename "id" to "node_id".
(diagnostic_graph_get_edge_by_id): Rename "id" to "edge_id".
(private_diagnostic_execution_path_add_event_2): Delete.
(diagnostic_message_buffer_new): New public entrypoint.
(diagnostic_message_buffer_release): Likewise.
(diagnostic_message_buffer_append_str): Likewise.
(diagnostic_message_buffer_append_text): Likewise.
(diagnostic_message_buffer_append_byte): Likewise.
(diagnostic_message_buffer_append_printf): Likewise.
(diagnostic_message_buffer_append_event_id): Likewise.
(diagnostic_message_buffer_begin_url): Likewise.
(diagnostic_message_buffer_end_url): Likewise.
(diagnostic_message_buffer_begin_quote): Likewise.
(diagnostic_message_buffer_end_quote): Likewise.
(diagnostic_message_buffer_begin_color): Likewise.
(diagnostic_message_buffer_end_color): Likewise.
(diagnostic_message_buffer_dump): Likewise.
(diagnostic_finish_via_msg_buf): Likewise.
(diagnostic_add_location_with_label_via_msg_buf): Likewise.
(diagnostic_execution_path_add_event_via_msg_buf): Likewise.
(diagnostic_graph_set_description_via_msg_buf): Likewise.
(diagnostic_graph_add_edge_via_msg_buf): Likewise.
(diagnostic_node_set_label_via_msg_buf): Likewise.
(private_diagnostic_execution_path_add_event_3): New private
entrypoint.
* libgdiagnostics.h (LIBGDIAGNOSTICS_PARAM_FORMAT_STRING): New macro.
(LIBGDIAGNOSTICS_PARAM_PRINTF_FORMAT_STRING): New macro.
(diagnostic_message_buffer): New typedef.
(LIBDIAGNOSTICS_HAVE_diagnostic_message_buffer): New define.
(diagnostic_message_buffer_new): New decl.
(diagnostic_message_buffer_release): New decl.
(diagnostic_message_buffer_append_str): New decl.
(diagnostic_message_buffer_append_text): New decl.
(diagnostic_message_buffer_append_byte): New decl.
(diagnostic_message_buffer_append_printf): New decl.
(diagnostic_message_buffer_append_event_id): New decl.
(diagnostic_message_buffer_begin_url): New decl.
(diagnostic_message_buffer_end_url): New decl.
(diagnostic_message_buffer_begin_quote): New decl.
(diagnostic_message_buffer_end_quote): New decl.
(diagnostic_message_buffer_begin_color): New decl.
(diagnostic_message_buffer_end_color): New decl.
(diagnostic_message_buffer_dump): New decl.
(diagnostic_finish_via_msg_buf): New decl.
(diagnostic_add_location_with_label_via_msg_buf): New decl.
(diagnostic_execution_path_add_event_via_msg_buf): New decl.
(diagnostic_graph_set_description_via_msg_buf): New decl.
(diagnostic_graph_add_edge_via_msg_buf): New decl.
(diagnostic_node_set_label_via_msg_buf): New decl.
* libgdiagnostics.map (LIBGDIAGNOSTICS_ABI_3): Drop
private_diagnostic_execution_path_add_event_2.
(LIBGDIAGNOSTICS_ABI_4): New.
* libsarifreplay.cc (class annotation): Use
libgdiagnostics::message_buffer rather than label_text.
(add_any_annotations): Likewise.
(sarif_replayer::handle_result_obj): Likewise.
(make_plain_text_within_result_message): Likewise.
(handle_thread_flow_location_object): Likewise.
(handle_location_object): Likewise.
(sarif_replayer::handle_graph_object): Likewise.
(sarif_replayer::handle_node_object): Likewise.
(sarif_replayer::handle_edge_object): Likewise.
* pretty-print-format-impl.h (pp_token_list::push_back_byte): New
decl.
* pretty-print-markup.h (pp_markup::context::begin_url): New decl.
(pp_markup::context::end_url): New decl.
(pp_markup::context::add_event_id): New decl.
* pretty-print.cc: Include "auto-obstack.h".
(pp_token_list::push_back_byte): New.
(struct auto_obstack): Move to auto-obstack.h.
(default_token_printer): Make non-static.
(pp_markup::context::begin_url): New.
(pp_markup::context::end_url): New.
(pp_markup::context::add_event_id): New.

gcc/testsuite/ChangeLog:
PR sarif-replay/120792
* libgdiagnostics.dg/sarif.py: Delete duplicate script.
* libgdiagnostics.dg/test-message-buffer-c.py: New test script.
* libgdiagnostics.dg/test-message-buffer.c: New test.
* libgdiagnostics.dg/test-warning-with-path-c.py: Update expected
output to reflect that SARIF for event messages now contains JSON
pointers when referring to other events by ID.
* sarif-replay.dg/2.1.0-valid/3.11.6-embedded-links.sarif: Add
HTML and SARIF output, and call out to Python scripts to verify
the output.  Add example of a result with a link in its message.
* sarif-replay.dg/2.1.0-valid/embedded-links-check-html.py: New
test script.
* sarif-replay.dg/2.1.0-valid/embedded-links-check-sarif-roundtrip.py:
New test script.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 days agolibstdc++: Constrain std::swap using concepts in C++20
Jonathan Wakely [Mon, 14 Jul 2025 10:13:54 +0000 (11:13 +0100)] 
libstdc++: Constrain std::swap using concepts in C++20

This is a minor compile-time optimization for C++20.

libstdc++-v3/ChangeLog:

* include/bits/move.h (swap): Replace enable_if with concepts
when available, and with __enable_if_t alias otherwise.

3 days agolibstdc++: Make ranges::advance(it, n, bound) follow standard more strictly
Jonathan Wakely [Mon, 14 Jul 2025 10:21:24 +0000 (11:21 +0100)] 
libstdc++: Make ranges::advance(it, n, bound) follow standard more strictly

The standard specifies some of the effects of ranges::advance in terms
of "Equivalent to:" and it's observable that our current implementation
deviates from the precise specification in the standard.  This was
causing some failures in the libc++ testsuite.

For the sized_sentinel_for<I, S> case I optimized our implementation to
avoid redundant calls when we have already checked that there's nothing
to do.  We were eliding `advance(i, bound)` when the iterator already
equals the sentinel, and eliding `advance(i, n)` when `n` is zero. In
both cases, removing the seemingly redundant calls is not equivalent to
the spec because `i = std::move(bound)` or `i += 0` operations can be
observed by program-defined iterators. This patch inlines the observable
side effects of advance(i, bound) or advance(i, 0) without actually
calling those functions.

For the non-sized sentinel case, `if (i == bound || n == 0)` is
different from `if (n == 0 || i == bound)` for the case where n is zero
and a program-defined iterator observes the number of comparisons.
This patch changes it to do `n == 0` first. I don't think this is
required by the standard, as this condition is not "Equivalent to:" any
observable sequence of operations, but testing `n == 0` first is
probably cheaper anyway.

libstdc++-v3/ChangeLog:

* include/bits/ranges_base.h (ranges::advance(i, n, bound)):
Ensure that observable side effects on iterators match what is
specified in the standard.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 days agolibstdc++: Add missing initializers for __maybe_present_t members [PR119962]
Patrick Palka [Tue, 15 Jul 2025 19:17:23 +0000 (15:17 -0400)] 
libstdc++: Add missing initializers for __maybe_present_t members [PR119962]

Data members of type __maybe_present_t where the conditionally present
type might be an aggregate or fundamental type need to be explicitly
value-initialized (rather than implicitly default-initialized), so that
default-initialization of the containing class always results in an
completely initialized object.

PR libstdc++/119962

libstdc++-v3/ChangeLog:

* include/std/ranges (join_view::_Iterator::_M_outer): Initialize.
(lazy_split_view::_OuterIter::_M_current): Initialize.
(join_with_view::_Iterator::_M_outer_it): Initialize.
* testsuite/std/ranges/adaptors/join.cc (test15): New test.
* testsuite/std/ranges/adaptors/join_with/1.cc (test05): New test.
* testsuite/std/ranges/adaptors/lazy_split.cc (test13): New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
3 days agoc++: don't mark void exprs as read [PR44677]
Jason Merrill [Mon, 14 Jul 2025 22:29:17 +0000 (18:29 -0400)] 
c++: don't mark void exprs as read [PR44677]

In Jakub's patch for PR44677 he added code to prevent mark_exp_read on
e.g. (void)++i from marking i as read, but it seems to me that we can
generalize that to avoid looking any farther into any void expression;
you can't read a void value, and an explicit cast will have already called
mark_exp_read on its operand in convert_to_void.

For testing I added an assert to catch places where we were trying to mark
void expressions as read, and fix a few that it found.  But there were
several other places (such as check_return_expr) where we could have a void
expression but always calling mark_exp_read makes sense, so I dropped the
assert from the final commit.

PR c++/44677

gcc/cp/ChangeLog:

* cp-gimplify.cc (cp_fold) [CLEANUP_POINT_EXPR]: Don't force rvalue.
[COMPOUND_EXPR]: Likewise.
* cvt.cc (convert_to_void): Call mark_exp_read later.
* expr.cc (mark_use): Turn off read_p for any void argument.
(mark_exp_read): Return early for void argument.

3 days ago[PATCH v5] RISC-V: Mips P8700 Conditional Move Support.
Umesh Kalappa [Tue, 15 Jul 2025 16:35:44 +0000 (10:35 -0600)] 
[PATCH v5] RISC-V: Mips P8700 Conditional Move Support.

Updated the test for rv32 accordingly and no regress found for runs like
"runtest --tool gcc --target_board='riscv-sim/-march=rv32gc_zba_zbb_zbc_zbs/-mabi=ilp32d/-mcmodel=medlow' riscv.exp" and
"runtest --tool gcc --target_board='riscv-sim/-march=rv64gc_zba_zbb_zbc_zbs/-mabi=lp64d/-mcmodel=medlow' riscv.exp"

lint warnings can be ignored for riscv-cores.def and riscv-ext-mips.def

gcc/ChangeLog:

* config/riscv/riscv-cores.def (RISCV_CORE): Updated the supported march.
* config/riscv/riscv-ext-mips.def (DEFINE_RISCV_EXT):
New file added for mips conditional mov extension.
* config/riscv/riscv-ext.def: Likewise.
* config/riscv/t-riscv: Generates riscv-ext.opt
* config/riscv/riscv-ext.opt: Generated file.
* config/riscv/riscv.cc (riscv_expand_conditional_move): Updated for mips cmov
and outlined some code that handle arch cond move.
* config/riscv/riscv.md (mov<mode>cc): updated expand for MIPS CCMOV.
* config/riscv/mips-insn.md: New file for mips-p8700 ccmov insn.
* doc/riscv-ext.texi: Updated for mips cmov.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/mipscondmov.c: Test file for mips.ccmov insn.

3 days agolibgcc: Fix aarch64 build
Andrew Pinski [Tue, 15 Jul 2025 15:56:31 +0000 (08:56 -0700)] 
libgcc: Fix aarch64 build

For aarch64, libgcc is built with -Werror, after the latest
-Wunused-but-set* commit (r16-2258-g0eac9cfee8cb0b21d), a new warning
showed up:
```
../../../gcc/libgcc/config/libbid/bid_binarydecimal.c: In function
‘__binary32_to_bid128’:
../../../gcc/libgcc/config/libbid/bid_binarydecimal.c:130:31: error:
variable ‘c3’ set but not used [-Werror=unused-but-set-variable=]
  130 | { unsigned long long c0,c1,c2,c3;                               \
      |                               ^~
../../../gcc/libgcc/config/libbid/bid_binarydecimal.c:146842:5: note:
in expansion of macro ‘__mul_10x256_to_256’
146842 |     __mul_10x256_to_256 (z.w[5], z.w[4], z.w[3], z.w[2],
z.w[5], z.w[4],
       |     ^~~~~~~~~~~~~~~~~~~
```

This fixes it by casting c3 to void after the last __mul_10x64 in
__mul_10x256_to_256 macro to mark it as being "used".

libgcc/config/libbid/ChangeLog:

* bid_binarydecimal.c (__mul_10x256_to_256): Mark c3 as being
used.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
3 days agolibstdc++: Implement std::chrono::current_zone() for Windows [PR108409]
Björn Schäpers [Thu, 10 Jul 2025 07:48:19 +0000 (09:48 +0200)] 
libstdc++: Implement std::chrono::current_zone() for Windows [PR108409]

On Windows there is no API to get the current time zone as IANA name,
instead Windows has its own zones. But there exists a mapping provided
by the Unicode Consortium. This patch adds a script to convert the XML
file with the mapping to a lookup table and adds a Windows code path to
use that mapping.

libstdc++-v3/Changelog:

Implement std::chrono::current_zone() for Windows

PR libstdc++/108409
* scripts/gen_windows_zones_map.py: New file, generates
windows_zones-map.h.
* src/c++20/windows_zones-map.h: New file, contains the look up
table.
* src/c++20/tzdb.cc (tzdb::current_zone): Add Windows code path.

Signed-off-by: Björn Schäpers <bjoern@hazardy.de>
3 days agolibstdc++: Search for tzdata on Windows (msys)
Björn Schäpers [Mon, 7 Jul 2025 22:43:34 +0000 (00:43 +0200)] 
libstdc++: Search for tzdata on Windows (msys)

Windows does not provide a tzdata.zi, but msys does. Use this, if
available, instead of the embedded (and possibly outdated) database.

libstdc++-v3/Changelog:

Use msys provided time zone information.

* src/c++20/tzdb.cc (zoneinfo_file): On Windows look relative
from the DLL path for the time zone information.

Signed-off-by: Björn Schäpers <bjoern@hazardy.de>
3 days agoc++: constexpr uninitialized union [PR120577]
Jason Merrill [Sat, 12 Jul 2025 09:15:01 +0000 (05:15 -0400)] 
c++: constexpr uninitialized union [PR120577]

This was failing for two reasons:

1) We were wrongly treating the basic_string constructor as
zero-initializing the object, which it doesn't.
2) Given that, when we went to look for a value for the anonymous union,
we concluded that it was value-initialized, and trying to evaluate that
broke because we weren't setting ctx->ctor for it.

This patch fixes both issues, #1 by setting CONSTRUCTOR_NO_CLEARING and #2
by inserting a new CONSTRUCTOR for the member rather than evaluate it out of
context, which is consistent with cxx_eval_store_expression.

PR c++/120577

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_call_expression): Set
CONSTRUCTOR_NO_CLEARING on initial value for ctor.
(cxx_eval_component_reference): Make value-initialization
of an aggregate member explicit.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/constexpr-union9.C: New test.

3 days agoc++: decomp25 vs -fimplicit-constexpr [PR117784]
Jason Merrill [Tue, 15 Jul 2025 14:46:41 +0000 (10:46 -0400)] 
c++: decomp25 vs -fimplicit-constexpr [PR117784]

Avoid diagnostic changes from -fimplicit-constexpr.

PR c++/117784

gcc/testsuite/ChangeLog:

* g++.dg/cpp26/decomp25.C: Add -fno-implicit-constexpr.

3 days agoopenmp, fortran: Fix ICE when the procedure name cannot be found in declare variant...
Kwok Cheung Yeung [Tue, 15 Jul 2025 14:26:26 +0000 (15:26 +0100)] 
openmp, fortran: Fix ICE when the procedure name cannot be found in declare variant directives [PR104428]

The result of searching for the procedure name symbol should be checked in
case the symbol cannot be found to avoid a null dereference.

gcc/fortran/

PR fortran/104428
* trans-openmp.cc (gfc_trans_omp_declare_variant): Check that proc_st
is non-NULL before dereferencing.  Add line number to error message.

gcc/testsuite/

PR fortran/104428
* gfortran.dg/gomp/pr104428.f90: New.

3 days agoasf: Fix offset check in base reg initialization for big-endian targets
Konstantinos Eleftheriou [Tue, 3 Jun 2025 07:16:17 +0000 (09:16 +0200)] 
asf: Fix offset check in base reg initialization for big-endian targets

During the base register initialization, in the case that we are
eliminating the load instruction, we are using `offset == 0` in order
to find the store instruction that has the same offset as the
load. This would not work on big-endian targets where byte 0 would be
the MS byte.

This patch updates the condition to take into account the target's
endianness.

We are, also, removing the adjustment of the starting position for the
bitfield insertion, when BYTES_BIG_ENDIAN != BITS_BIG_ENDIAN. This is
supposed to be handled inside `store_bit_field` and it's not needed
anymore after the offset fix.

Bootstrapped/regtested on AArch64 LE, x86_64 and PowerPC LE.

gcc/ChangeLog:

* avoid-store-forwarding.cc (generate_bit_insert_sequence):
Remove adjustment of bitfield insertion's starting position
when BYTES_BIG_ENDIAN != BITS_BIG_ENDIAN.
(process_store_forwarding): Update offset check in base reg
initialization to take into account the target's endianness.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/avoid-store-forwarding-be.c: New test.

3 days agoaarch64: Enable selective LDAPUR generation for cores with RCPC2
Soumya AR [Tue, 15 Jul 2025 13:58:44 +0000 (19:28 +0530)] 
aarch64: Enable selective LDAPUR generation for cores with RCPC2

This patch adds the ability to fold the address computation into the addressing
mode for LDAPR instructions using LDAPUR when RCPC2 is available.

LDAPUR emission is enabled by default when RCPC2 is available, but can be
disabled using the avoid_ldapur tune flag on a per-core basis.

Currently, it is disabled for neoverse-v2, neoverse-v3, cortex-x925, and
architecutres before armv8.8-a.

Earlier, the following code:

uint64_t
foo (std::atomic<uint64_t> *x)
{
  return x[1].load(std::memory_order_acquire);
}

would generate:

foo(std::atomic<unsigned long>*):
add     x0, x0, 8
ldapr   x0, [x0]
ret

but now generates:

foo(std::atomic<unsigned long>*):
ldapur  x0, [x0, 8]
ret

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

Signed-off-by: Soumya AR <soumyaa@nvidia.com>
gcc/ChangeLog:

* config/aarch64/aarch64-tuning-flags.def (AARCH64_EXTRA_TUNING_OPTION):
Add AVOID_LDAPUR tuning flag.
* config/aarch64/aarch64.cc (aarch64_adjust_generic_arch_tuning):
Set AVOID_LDAPUR for architectures before armv8.8-a.
(aarch64_override_options_internal): Apply generic tuning adjustments
to generic_armv8_a_tunings and generic_armv9_a_tunings.
* config/aarch64/aarch64.h (TARGET_ENABLE_LDAPUR): New macro to
control LDAPUR usage based on RCPC2 and tuning flags.
* config/aarch64/aarch64.md: Add enable_ldapur attribute.
* config/aarch64/atomics.md (aarch64_atomic_load<mode>_rcpc): Modify
to emit LDAPUR for cores with RCPC2.
(*aarch64_atomic_load<ALLX:mode>_rcpc_zext): Likewise.
(*aarch64_atomic_load<ALLX:mode>_rcpc_sext): Update constraint to Ust.
* config/aarch64/tuning_models/cortexx925.h: Add AVOID_LDAPUR flag.
* config/aarch64/tuning_models/neoversev2.h: Likewise.
* config/aarch64/tuning_models/neoversev3.h: Likewise.
* config/aarch64/tuning_models/neoversev3ae.h: Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/ldapr-sext.c: Update expected output to include
offsets.
* gcc.target/aarch64/ldapur.c: New test for LDAPUR.
* gcc.target/aarch64/ldapur_avoid.c: New test for AVOID_LDAPUR flag.

3 days agolibstdc++: Tweak dg-error patterns for C++26 constexpr changes
Jonathan Wakely [Fri, 11 Jul 2025 22:49:05 +0000 (23:49 +0100)] 
libstdc++: Tweak dg-error patterns for C++26 constexpr changes

libstdc++-v3/ChangeLog:

* testsuite/25_algorithms/copy/debug/constexpr_neg.cc:
* testsuite/25_algorithms/copy_backward/debug/constexpr_neg.cc:
* testsuite/25_algorithms/equal/debug/constexpr_neg.cc:
* testsuite/25_algorithms/lower_bound/debug/constexpr_partitioned_neg.cc:
* testsuite/25_algorithms/lower_bound/debug/constexpr_partitioned_pred_neg.cc:
* testsuite/25_algorithms/lower_bound/debug/constexpr_valid_range_neg.cc:
* testsuite/25_algorithms/upper_bound/debug/constexpr_partitioned_neg.cc:
* testsuite/25_algorithms/upper_bound/debug/constexpr_partitioned_pred_neg.cc:
* testsuite/25_algorithms/upper_bound/debug/constexpr_valid_range_neg.cc:

3 days agotree-optimization/121059 - fixup loop mask query
Richard Biener [Mon, 14 Jul 2025 12:09:28 +0000 (14:09 +0200)] 
tree-optimization/121059 - fixup loop mask query

When we opportunistically mask an operand of a AND with an already
available loop mask we need to query that set with the correct number
of masks we expect.

PR tree-optimization/121059
* tree-vect-stmts.cc (vectorizable_operation): Query
scalar_cond_masked_set with the correct number of masks.

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

Co-Authored-By: Richard Sandiford <richard.sandiford@arm.com>
3 days agoc, c++: Extend -Wunused-but-set-* warnings [PR44677]
Jakub Jelinek [Tue, 15 Jul 2025 13:00:33 +0000 (15:00 +0200)] 
c, c++: Extend -Wunused-but-set-* warnings [PR44677]

The -Wunused-but-set-* warnings work by using 2 bits on VAR_DECLs &
PARM_DECLs, TREE_USED and DECL_READ_P.  If neither is set, we typically
emit -Wunused-variable or -Wunused-parameter warning, that is for variables
which are just declared (including initializer) and completely unused.
If TREE_USED is set and DECL_READ_P is unset, -Wunused-but-set-* warnings
are emitted, i.e. for variables which can appear on the lhs of an assignment
expression but aren't actually used elsewhere.  The DECL_READ_P marking is
done through mark_exp_read called from lots of places (e.g. lvalue to rvalue
conversions etc.).

LLVM has an extension on top of that in that it doesn't count pre/post
inc/decrements as use (i.e. DECL_READ_P for GCC).

The following patch does that too, though because we had the current
behavior for 11+ years already and lot of people is -Wunused-but-set-*
warning free in the current GCC behavior and not in the clang one (including
GCC sources), it allows users to choose.
Furthermore, it implements another level, where also var @= expr uses of var
(except when it is also used in expr) aren't counted as DECL_READ_P.

I think it would be nice to also handle var = var @ expr or var = expr @ var
but unfortunately mark_exp_read is then done in both FEs during parsing of
var @ expr or expr @ var and the code doesn't know it is rhs of an
assignment with var as lhs.

The patch works mostly by checking if DECL_READ_P is clear at some point and
then clearing it again after some operation which might have set it.

-Wunused or -Wall or -Wunused -Wextra or -Wall -Wextra turn on the 3 level
of the new warning (i.e. the one which ignores also var++, ++var etc. as
well as var @= expr), so does -Wunused-but-set-{variable,parameter}, but
users can use explicit -Wunused-but-set-{variable,parameter}={1,2} to select
a different level.

2025-07-15  Jakub Jelinek  <jakub@redhat.com>
    Jason Merrill  <jason@redhat.com>

PR c/44677
gcc/
* common.opt (Wunused-but-set-parameter=, Wunused-but-set-variable=):
New options.
(Wunused-but-set-parameter, Wunused-but-set-variable): Turn into
aliases.
* common.opt.urls: Regenerate.
* diagnostic-spec.cc (nowarn_spec_t::nowarn_spec_t): Use
OPT_Wunused_but_set_variable_ instead of OPT_Wunused_but_set_variable
and OPT_Wunused_but_set_parameter_ instead of
OPT_Wunused_but_set_parameter.
* gimple-ssa-store-merging.cc (find_bswap_or_nop_1): Remove unused
but set variable tmp.
* ipa-strub.cc (pass_ipa_strub::execute): Cast named_args to
(void) if ATTR_FNSPEC_DECONST_WATERMARK is not defined.
* doc/invoke.texi (Wunused-but-set-parameter=,
Wunused-but-set-variable=): Document new options.
(Wunused-but-set-parameter, Wunused-but-set-variable): Adjust
documentation now that they are just aliases.
gcc/c-family/
* c-opts.cc (c_common_post_options): Change
warn_unused_but_set_parameter and warn_unused_but_set_variable
from 1 to 3 if they were set only implicitly.
* c-attribs.cc (build_attr_access_from_parms): Remove unused
but set variable nelts.
gcc/c/
* c-parser.cc (c_parser_unary_expression): Clear DECL_READ_P
after default_function_array_read_conversion for
-Wunused-but-set-{parameter,variable}={2,3} on
PRE{IN,DE}CREMENT_EXPR argument.
(c_parser_postfix_expression_after_primary): Similarly for
POST{IN,DE}CREMENT_EXPR.
* c-decl.cc (pop_scope): Use OPT_Wunused_but_set_variable_
instead of OPT_Wunused_but_set_variable.
(finish_function): Use OPT_Wunused_but_set_parameter_
instead of OPT_Wunused_but_set_parameter.
* c-typeck.cc (mark_exp_read): Handle {PRE,POST}{IN,DE}CREMENT_EXPR
and don't handle it when cast to void.
(build_modify_expr): Clear DECL_READ_P after build_binary_op
for -Wunused-but-set-{parameter,variable}=3.
gcc/cp/
* cp-gimplify.cc (cp_fold): Clear DECL_READ_P on lhs of MODIFY_EXPR
after cp_fold_rvalue if it wasn't set before.
* decl.cc (poplevel): Use OPT_Wunused_but_set_variable_
instead of OPT_Wunused_but_set_variable.
(finish_function): Use OPT_Wunused_but_set_parameter_
instead of OPT_Wunused_but_set_parameter.
* expr.cc (mark_use): Clear read_p for {PRE,POST}{IN,DE}CREMENT_EXPR
cast to void on {VAR,PARM}_DECL for
-Wunused-but-set-{parameter,variable}={2,3}.
(mark_exp_read): Handle {PRE,POST}{IN,DE}CREMENT_EXPR and don't handle
it when cast to void.
* module.cc (trees_in::fn_parms_fini): Remove unused but set variable
ix.
* semantics.cc (finish_unary_op_expr): Return early for
PRE{IN,DE}CREMENT_EXPR.
* typeck.cc (cp_build_unary_op): Clear DECL_READ_P
after mark_lvalue_use for -Wunused-but-set-{parameter,variable}={2,3}
on PRE{IN,DE}CREMENT_EXPR argument.
(cp_build_modify_expr): Clear DECL_READ_P after cp_build_binary_op
for -Wunused-but-set-{parameter,variable}=3.
gcc/go/
* gofrontend/gogo.cc (Function::export_func_with_type): Remove
unused but set variable i.
gcc/cobol/
* gcobolspec.cc (lang_specific_driver): Remove unused but set variable
n_cobol_files.
gcc/testsuite/
* c-c++-common/Wunused-parm-1.c: New test.
* c-c++-common/Wunused-parm-2.c: New test.
* c-c++-common/Wunused-parm-3.c: New test.
* c-c++-common/Wunused-parm-4.c: New test.
* c-c++-common/Wunused-parm-5.c: New test.
* c-c++-common/Wunused-parm-6.c: New test.
* c-c++-common/Wunused-var-7.c (bar, baz): Expect warning on a.
* c-c++-common/Wunused-var-19.c: New test.
* c-c++-common/Wunused-var-20.c: New test.
* c-c++-common/Wunused-var-21.c: New test.
* c-c++-common/Wunused-var-22.c: New test.
* c-c++-common/Wunused-var-23.c: New test.
* c-c++-common/Wunused-var-24.c: New test.
* g++.dg/cpp26/name-independent-decl1.C (foo): Expect one
set but not used warning.
* g++.dg/warn/Wunused-parm-12.C: New test.
* g++.dg/warn/Wunused-parm-13.C: New test.
* g++.dg/warn/Wunused-var-2.C (f2): Expect set but not used warning
on parameter x and variable a.
* g++.dg/warn/Wunused-var-40.C: New test.
* g++.dg/warn/Wunused-var-41.C: New test.
* gcc.dg/memchr-3.c (test_find): Change return type from void to int,
and add return n; statement.
* gcc.dg/unused-9.c (g): Move dg-bogus to the correct line and expect
a warning on i.

3 days agoaarch64: fixup: Implement sme2+faminmax extension.
Alfie Richards [Fri, 4 Jul 2025 15:37:10 +0000 (15:37 +0000)] 
aarch64: fixup: Implement sme2+faminmax extension.

Fixup to the SME2+FAMINMAX intrinsics commit.

gcc/ChangeLog:

* config/aarch64/aarch64-sme.md (@aarch64_sme_<faminmax_uns_op><mode>):
Change gating and comment.