]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 months agotree: Canonical order for ADDR
Andrew Pinski [Wed, 14 May 2025 16:01:07 +0000 (09:01 -0700)] 
tree: Canonical order for ADDR

This is the followup based on the review at
https://inbox.sourceware.org/gcc-patches/CAFiYyc3xeG75dsWaF63Zbu5uELPEAEoHwGfoGaVyDWouUJ70Mg@mail.gmail.com/
.
We should put ADDR_EXPR last instead of just is_gimple_invariant_address ones.

Note a few match patterns needed to be updated for this change but we get a decent improvement
as forwprop-38.c is now able to optimize during CCP rather than taking all the way to forwprop.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* fold-const.cc (tree_swap_operands_p): Put ADDR_EXPR last
instead of just is_gimple_invariant_address ones.
* match.pd (`a ptr+ b !=\== ADDR`, `ADDR !=/== ssa_name`):
Move the ADDR to the last operand. Update comment.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 months agoEnhance -fopt-info-vec vectorized loop diagnostic
Richard Biener [Wed, 14 May 2025 14:45:08 +0000 (16:45 +0200)] 
Enhance -fopt-info-vec vectorized loop diagnostic

The following includes whether we vectorize an epilogue, whether
we use loop masking and what vectorization factor (unroll factor)
we use.  So it's now

t.c:4:21: optimized: loop vectorized using 64 byte vectors and unroll factor 32
t.c:4:21: optimized: epilogue loop vectorized using masked 64 byte vectors and unroll factor 32

for a masked epilogue with AVX512 and HImode data for example.  Rather
than

t.c:4:21: optimized: loop vectorized using 64 byte vectors
t.c:4:21: optimized: loop vectorized using 64 byte vectors

I verified we don't translate opt-info messages and thus excessive
use of %s to compose the strings should be OK.

* tree-vectorizer.cc (vect_transform_loops): When diagnosing
a vectorized loop indicate whether we vectorized an epilogue,
whether we used masked vectors and what unroll factor was
used.

* gcc.target/i386/pr110310.c: Adjust.

2 months agoFix regression from x86 multi-epilogue tuning
Richard Biener [Wed, 14 May 2025 14:36:29 +0000 (16:36 +0200)] 
Fix regression from x86 multi-epilogue tuning

With the avx512_two_epilogues tuning enabled for zen4 and zen5
the gcc.target/i386/vect-epilogues-5.c testcase below regresses
and ends up using AVX2 sized vectors for the masked epilogue
rather than AVX512 sized vectors.  The following patch rectifies
this and adds coverage for the intended behavior.

* config/i386/i386.cc (ix86_vector_costs::finish_cost):
Do not suggest a first epilogue mode for AVX512 sized
main loops with X86_TUNE_AVX512_TWO_EPILOGUES as that
interferes with using a masked epilogue.

* gcc.target/i386/vect-epilogues-1.c: New testcase.
* gcc.target/i386/vect-epilogues-2.c: Likewise.
* gcc.target/i386/vect-epilogues-3.c: Likewise.
* gcc.target/i386/vect-epilogues-4.c: Likewise.
* gcc.target/i386/vect-epilogues-5.c: Likewise.

2 months agoUpdate libbid according to the latest Intel Decimal Floating-Point Math Library.
liuhongt [Tue, 13 May 2025 01:26:13 +0000 (18:26 -0700)] 
Update libbid according to the latest Intel Decimal Floating-Point Math Library.

The Intel Decimal Floating-Point Math Library is available as open-source on Netlib[1].

[1] https://www.netlib.org/misc/intel/

libgcc/config/libbid/ChangeLog:

* bid128_string.c (MIN_DIGITS): New macro.
(bid128_from_string): Bug fix. Conversion from very long input
string to decimal.

2 months agoDaily bump.
GCC Administrator [Thu, 15 May 2025 00:19:47 +0000 (00:19 +0000)] 
Daily bump.

2 months agoUpdate gcc sv.po
Joseph Myers [Wed, 14 May 2025 21:11:50 +0000 (21:11 +0000)] 
Update gcc sv.po

* sv.po: Update.

2 months agoUpdate cpplib es.po
Joseph Myers [Wed, 14 May 2025 20:25:27 +0000 (20:25 +0000)] 
Update cpplib es.po

* es.po: Update.

2 months agoc++: Add testcase for issue fixed in GCC 15 [PR120126]
Simon Martin [Wed, 14 May 2025 18:29:57 +0000 (20:29 +0200)] 
c++: Add testcase for issue fixed in GCC 15 [PR120126]

Patrick noticed that this PR's testcase has been fixed by the patch for
PR c++/114292 (r15-7238-gceabea405ffdc8), more specifically the part
that walks the type of DECL_EXPR DECLs.

This simply adds the case to the testsuite.

PR c++/120126

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/lambda/lambda-ice33.C: New test.

2 months agoFix explicit arrays with non-constant size for -fc-prototypes.
Thomas Koenig [Wed, 14 May 2025 18:11:48 +0000 (20:11 +0200)] 
Fix explicit arrays with non-constant size for -fc-prototypes.

gcc/fortran/ChangeLog:

PR fortran/120139
* dump-parse-tree.cc (get_c_type_name): If no constant
size of an array exists, output an asterisk.

2 months agoDo not dump non-interoperable types with -fc-prototypes.
Thomas Koenig [Tue, 13 May 2025 17:02:06 +0000 (19:02 +0200)] 
Do not dump non-interoperable types with -fc-prototypes.

gcc/fortran/ChangeLog:

PR fortran/120107
* dump-parse-tree.cc (write_type): Do not dump non-interoperable
types.

2 months agoOpenMP: Fix mapping of zero-sized arrays with non-literal size: map(var[:n]), n = 0
Tobias Burnus [Wed, 14 May 2025 18:06:49 +0000 (20:06 +0200)] 
OpenMP: Fix mapping of zero-sized arrays with non-literal size: map(var[:n]), n = 0

For map(ptr[:0]), the used map kind is GOMP_MAP_ATTACH_ZERO_LENGTH_ARRAY_SECTION
and it is permitted that 'ptr' does not exist. 'ptr' is set to the device
pointee if it exists or to the host value otherwise.

For map(ptr[:3]), the variable is first mapped and then ptr is updated to point
to the just-mapped device data; the attachment uses GOMP_MAP_ATTACH.

For map(ptr[:n]), generates always a GOMP_MAP_ATTACH, but when n == 0, it
was failing with:
   "pointer target not mapped for attach"

The solution is not to fail but first to check whether it was mapped before.
It turned out that for the mapping part, GCC adds a run-time check whether
n == 0 - and uses GOMP_MAP_ZERO_LEN_ARRAY_SECTION for the mapping.
Thus, we just have to check whether there such a mapping for the address
for which the GOMP_MAP_ATTACH. was requested. And, if there was, the
error diagnostic can be skipped.

Unsurprisingly, this issue occurs in real-world code; it was detected in
a code that distributes work via MPI and for some processes, some bounds
ended up to be zero.

libgomp/ChangeLog:

* target.c (gomp_attach_pointer): Return bool; accept additional
bool to optionally silence the fatal pointee-not-found error.
(gomp_map_vars_internal): If the pointee could not be found,
check whether it was mapped as GOMP_MAP_ZERO_LEN_ARRAY_SECTION.
* libgomp.h (gomp_attach_pointer): Update prototype.
* oacc-mem.c (acc_attach_async, goacc_enter_data_internal): Update
calls.
* testsuite/libgomp.c/target-map-zero-sized.c: New test.
* testsuite/libgomp.c/target-map-zero-sized-2.c: New test.
* testsuite/libgomp.c/target-map-zero-sized-3.c: New test.

2 months agoRemove the mixed stmt_vec_info/SLP node record_stmt_cost overload
Richard Biener [Tue, 13 May 2025 08:08:36 +0000 (10:08 +0200)] 
Remove the mixed stmt_vec_info/SLP node record_stmt_cost overload

The following changes the record_stmt_cost calls in
vectorizable_load/store to only pass the SLP node when costing
vector stmts.  For now we'll still pass the stmt_vec_info,
determined from SLP_TREE_REPRESENTATIVE, so this merely cleans up
the API.

* tree-vectorizer.h (record_stmt_cost): Remove mixed
stmt_vec_info/SLP node inline overload.
* tree-vect-stmts.cc (vectorizable_store): For costing
vector stmts only pass SLP node to record_stmt_cost.
(vectorizable_load): Likewise.

2 months agoUse vectype from SLP node for vect_get_{load,store}_cost if possible
Richard Biener [Tue, 13 May 2025 07:50:36 +0000 (09:50 +0200)] 
Use vectype from SLP node for vect_get_{load,store}_cost if possible

The vect_get_{load,store}_cost API is used from both vectorizable_*
where we've done SLP analysis and from alignment peeling analysis
with is done before this and thus only stmt_vec_infos are available.
The following patch makes sure we pick the vector type relevant
for costing from the SLP node when available.

* tree-vect-stmts.cc (vect_get_store_cost): Compute vectype based
on whether we got SLP node or stmt_vec_info and use the full
record_stmt_cost API.
(vect_get_load_cost): Likewise.

2 months agoRISC-V: Fix uninit riscv_subset_list::m_allow_adding_dup issue
Kito Cheng [Tue, 13 May 2025 02:34:34 +0000 (10:34 +0800)] 
RISC-V: Fix uninit riscv_subset_list::m_allow_adding_dup issue

We forgot to initialize m_allow_adding_dup in the constructor of
riscv_subset_list, then that will be a random value...that will lead
to a random behavior of the -march may accpet duplicate extension.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc
(riscv_subset_list::riscv_subset_list): Init m_allow_adding_dup.
Reviewed-by: Christoph Müllner <christoph.muellner@vrull.eu>
2 months agoRISC-V: Add augmented hypervisor series extensions.
Jiawei [Tue, 13 May 2025 07:23:39 +0000 (15:23 +0800)] 
RISC-V: Add augmented hypervisor series extensions.

The augmented hypervisor series extensions 'sha'[1] is a new profile-defined
extension series that captures the full set of features that are mandated to
be supported along with the 'H' extension.

[1] https://github.com/riscv/riscv-profiles/blob/main/src/rva23-profile.adoc#rva23s64-profile

Version log: Update implements, fix testcase format.

gcc/ChangeLog:

* config/riscv/riscv-ext.def: New extension defs.
* config/riscv/riscv-ext.opt: Ditto.
* doc/riscv-ext.texi: Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/arch-55.c: New test.

2 months agoRISC-V: Drop duplicate build rule for riscv-ext.opt [NFC]
Kito Cheng [Wed, 14 May 2025 15:19:38 +0000 (23:19 +0800)] 
RISC-V: Drop duplicate build rule for riscv-ext.opt [NFC]

gcc/ChangeLog:

* config/riscv/t-riscv: Drop duplicate build rule for
riscv-ext.opt.

2 months agoRISC-V: Regen riscv-ext.opt.urls
Kito Cheng [Wed, 14 May 2025 15:19:17 +0000 (23:19 +0800)] 
RISC-V: Regen riscv-ext.opt.urls

gcc/ChangeLog:

* config/riscv/riscv-ext.opt.urls: Regenerate.

2 months agogimple: Move canonicalization of bool==0 and bool!=1 to cleanupcfg
Andrew Pinski [Tue, 13 May 2025 21:27:12 +0000 (14:27 -0700)] 
gimple: Move canonicalization of bool==0 and bool!=1 to cleanupcfg

This moves the canonicalization of `bool==0` and `bool!=1` from
forwprop to cleanupcfg. We will still need to call it from forwprop
so we don't need to call forwprop a few times to fp comparisons in some
cases (forwprop-16.c was added originally for this code even).

This is the first step in removing forward_propagate_into_gimple_cond
and forward_propagate_into_comparison.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-cfgcleanup.cc (canonicalize_bool_cond): New function.
(cleanup_control_expr_graph): Call canonicalize_bool_cond for GIMPLE_COND.
* tree-cfgcleanup.h (canonicalize_bool_cond): New declaration.
* tree-ssa-forwprop.cc (forward_propagate_into_gimple_cond):
Call canonicalize_bool_cond.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 months agogimple: Add assert for code being a comparison in gimple_cond_set_code
Andrew Pinski [Tue, 13 May 2025 20:50:24 +0000 (13:50 -0700)] 
gimple: Add assert for code being a comparison in gimple_cond_set_code

We have code later on that verifies the code is a comparison. So let's
try to catch it earlier. So it is easier to debug where the incorrect code
gets set.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* gimple.h (gimple_cond_set_code): Add assert of the code
being a comparison.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 months agoforwprop: Change an if into an assert
Andrew Pinski [Tue, 13 May 2025 20:04:32 +0000 (13:04 -0700)] 
forwprop: Change an if into an assert

Since the merge of the tuples branch (r0-88576-g726a989a8b74bf), the
if:
```
  if (TREE_CODE_CLASS (gimple_cond_code (stmt)) != tcc_comparison)
```
Will always be false so let's change it into an assert.

gcc/ChangeLog:

* tree-ssa-forwprop.cc (forward_propagate_into_gimple_cond): Assert
that gimple_cond_code is always a comparison.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 months agogimple: allow fold_stmt without setting cfun in case of GIMPLE_COND folding
Andrew Pinski [Tue, 13 May 2025 16:56:13 +0000 (09:56 -0700)] 
gimple: allow fold_stmt without setting cfun in case of GIMPLE_COND folding

This is the followup mentioned in https://gcc.gnu.org/pipermail/gcc-patches/2025-May/683444.html .
It adds the check for cfun before accessing function specific flags.
We handle the case where !cfun as conservative in that it the function might throw.

gcc/ChangeLog:

* gimple-fold.cc (replace_stmt_with_simplification): Check cfun before
accessing cfun.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 months agoforwprop: Move around the marking bb for eh to after the local non-fold_stmt optimiza...
Andrew Pinski [Mon, 21 Apr 2025 23:33:04 +0000 (16:33 -0700)] 
forwprop: Move around the marking bb for eh to after the local non-fold_stmt optimizations

When moving the optimize_memcpy_to_memset optimization to forwprop from fold_stmt, the marking
of the bb to purge for eh cleanup was not happening for the local optimizations but only after
the fold_stmt, this causes g++.dg/torture/except-2.C to fail.
So this patch moves the marking of the bbs for cleanups after the local forwprop optimizations
instead of before.

There was already code to add to to_purge after forward_propagate_into_comparison and removes
that as it is now redundant.

gcc/ChangeLog:

* tree-ssa-forwprop.cc (pass_forwprop::execute): Move marking of to_purge bb
and marking of fixup statements to after the local optimizations.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 months agoforwprop: Fix looping after fold_stmt and some forwprop local folds happen
Andrew Pinski [Tue, 22 Apr 2025 03:15:42 +0000 (20:15 -0700)] 
forwprop: Fix looping after fold_stmt and some forwprop local folds happen

r10-2587-gcc19f80ceb27cc added a loop over the current statment if there was
a change. Except in some cases it turns out changed will turn from true to false
because instead of doing |= after the fold_stmt, there was an just an `=`.
This fixes that and now we loop even if fold_stmt changed the statement and
there was a local fold that happened.

gcc/ChangeLog:

* tree-ssa-forwprop.cc (pass_forwprop::execute): Use `|=` for
changed on the local folding.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 months agolibiberty: remove duplicated declaration of mkstemps
Andreas Schwab [Wed, 14 May 2025 13:12:16 +0000 (15:12 +0200)] 
libiberty: remove duplicated declaration of mkstemps

* libiberty.h (mkstemps): Remove duplicate.

2 months agoThis transitions vect_model_simple_cost to SLP only
Richard Biener [Mon, 12 May 2025 13:02:42 +0000 (15:02 +0200)] 
This transitions vect_model_simple_cost to SLP only

As part of the vector cost API cleanup this transitions
vect_model_simple_cost to only record costs with SLP node.
For this to work the patch adds an overload to record_stmt_cost
only passing in the SLP node.

The vect_prologue_cost_for_slp adjustment is one spot that
needs an eye with regard to re-doing the whole thing.

* tree-vectorizer.h (record_stmt_cost): Add overload with
only SLP node and no vector type.
* tree-vect-stmts.cc (record_stmt_cost): Use
SLP_TREE_REPRESENTATIVE for stmt_vec_info.
(vect_model_simple_cost): Do not get stmt_vec_info argument
and adjust.
(vectorizable_call): Adjust.
(vectorizable_simd_clone_call): Likewise.
(vectorizable_conversion): Likewise.
(vectorizable_assignment): Likewise.
(vectorizable_shift): Likewise.
(vectorizable_operation): Likewise.
(vectorizable_condition): Likewise.
(vectorizable_comparison_1): Likewise.
* tree-vect-slp.cc (vect_prologue_cost_for_slp): Use
full-blown record_stmt_cost.

2 months agoRemove a sanity check comment now that the sanity check has been removed
Ville Voutilainen [Wed, 14 May 2025 13:39:09 +0000 (16:39 +0300)] 
Remove a sanity check comment now that the sanity check has been removed

gcc/cp/ChangeLog:

* cp-gimplify.cc (cp_fold): Remove a remnant comment.

2 months agolibstdc++: Renamed bits/move_only_function.h to bits/funcwrap.h [PR119125]
Tomasz Kamiński [Mon, 12 May 2025 09:06:34 +0000 (11:06 +0200)] 
libstdc++: Renamed bits/move_only_function.h to bits/funcwrap.h [PR119125]

The file now includes copyable_function in addition to
move_only_function.

PR libstdc++/119125

libstdc++-v3/ChangeLog:
* include/bits/move_only_function.h: Move to...
* include/bits/funcwrap.h: ...here.
* doc/doxygen/stdheader.cc (init_map): Replaced move_only_function.h
with funcwrap.h, and changed include guard to use feature test macro.
Move bits/version.h include before others.
* include/Makefile.am: Likewise.
* include/Makefile.in: Likewise.
* include/std/functional: Likewise.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agoConsider frequency in cost estimation when converting scalar to vector.
liuhongt [Wed, 18 Dec 2024 06:32:31 +0000 (22:32 -0800)] 
Consider frequency in cost estimation when converting scalar to vector.

n some benchmark, I notice stv failed due to cost unprofitable, but the igain
is inside the loop, but sse<->integer conversion is outside the loop, current cost
model doesn't consider the frequency of those gain/cost.
The patch weights those cost with frequency.

gcc/ChangeLog:

PR target/120215
* config/i386/i386-features.cc
(scalar_chain::mark_dual_mode_def): Weight
cost of integer<->sse move with bb frequency when it's
optimized_for_speed_p.
(general_scalar_chain::compute_convert_gain): Ditto, and
adjust function prototype to return true/false when cost model
is profitable or not.
(timode_scalar_chain::compute_convert_gain): Ditto.
(convert_scalars_to_vector): Adjust after the upper two
function prototype are changed.
* config/i386/i386-features.h (class scalar_chain): Change
n_integer_to_sse/n_sse_to_integer to cost_sse_integer, and add
weighted_cost_sse_integer.
(class general_scalar_chain): Adjust prototype to return bool
intead of int.
(class timode_scalar_chain): Ditto.

2 months agolibstdc++: Implement C++26 copyable_function [PR119125]
Tomasz Kamiński [Mon, 12 May 2025 08:01:22 +0000 (10:01 +0200)] 
libstdc++: Implement C++26 copyable_function [PR119125]

This patch implements C++26 copyable_function as specified in P2548R6.
It also implements LWG 4255 that adjust move_only_function so constructing
from empty copyable_function, produces empty functor. This falls from
existing checks, after specializing __is_polymorphic_function_v for
copyable_function specializations.

For compatible invoker signatures, the move_only_function may be constructed
from copyable_funciton without double indirection. To achieve that we derive
_Cpy_base from _Mo_base, and specialize __is_polymorphic_function_v for
copyable_function. Similary copyable_functions with compatible signatures
can be converted without double indirection.

As we starting to use _Op::_Copy operation from the _M_manage function,
invocations of that functions may now throw exceptions, so noexcept needs
to be removed from the signature of stored _M_manage pointers. This also
affects operations in _Mo_base, however we already wrap _M_manage invocations
in noexcept member functions (_M_move, _M_destroy, swap).

PR libstdc++/119125

libstdc++-v3/ChangeLog:

* doc/doxygen/stdheader.cc: Addded cpyfunc_impl.h header.
* include/Makefile.am: Add bits cpyfunc_impl.h.
* include/Makefile.in: Add bits cpyfunc_impl.h.
* include/bits/cpyfunc_impl.h: New file.
* include/bits/mofunc_impl.h: Mention LWG 4255.
* include/bits/move_only_function.h: Update header description
and change guard to also check __glibcxx_copyable_function.
(_Manager::_Func): Remove noexcept.
(std::__is_polymorphic_function_v<move_only_function<_Tp>>)
(__variant::_Never_valueless_alt<std::move_only_function<_Signature...>>)
(move_only_function) [__glibcxx_move_only_function]: Adjust guard.
(std::__is_polymorphic_function_v<copyable_function<_Tp>>)
(__variant::_Never_valueless_alt<std::copyable_function<_Signature...>>)
(__polyfunc::_Cpy_base, std::copyable_function)
[__glibcxx_copyable_function]: Define.
* include/bits/version.def: Define copyable_function.
* include/bits/version.h: Regenerate.
* include/std/functional: Define __cpp_lib_copyable_function.
* src/c++23/std.cc.in (copyable_function)
[__cpp_lib_copyable_function]: Export.
* testsuite/20_util/copyable_function/call.cc: New test based on
move_only_function tests.
* testsuite/20_util/copyable_function/cons.cc: New test based on
move_only_function tests.
* testsuite/20_util/copyable_function/conv.cc: New test based on
move_only_function tests.
* testsuite/20_util/copyable_function/copy.cc: New test.
* testsuite/20_util/copyable_function/move.cc: New test based on
move_only_function tests.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agolibstdc++: Avoid double indirection in move_only_function when possible [PR119125]
Tomasz Kamiński [Thu, 8 May 2025 06:08:43 +0000 (08:08 +0200)] 
libstdc++: Avoid double indirection in move_only_function when possible [PR119125]

Based on the provision in C++26 [func.wrap.general] p2 this patch adjust the generic
move_only_function(_Fn&&) constructor, such that when _Fn refers to selected
move_only_function instantiations, the ownership of the target object is directly
transfered to constructor object. This avoid cost of double indirection in this situation.
We apply this also in C++23 mode.

We also fix handling of self assignments, to match behavior required by standard,
due use of copy and swap idiom.

An instantiations MF1 of move_only_function can transfer target of another
instantiation MF2, if it can be constructed via usual rules (__is_callable_from<_MF2>),
and their invoker are convertible (__is_invoker_convertible<MF2, MF1>()), i.e.:
* MF1 is less noexcept than MF2,
* return types are the same after stripping cv-quals,
* adujsted parameters type are the same (__poly::_param_t), i.e. param of types T and T&&
  are compatible for non-trivially copyable objects.
Compatiblity of cv ref qualification is checked via __is_callable_from<_MF2>.

To achieve above the generation of _M_invoke functions is moved to _Invoker class
templates, that only depends on noexcept, return type and adjusted parameter of the
signature. To make the invoker signature compatible between const and mutable
qualified signatures, we always accept _Storage as const& and perform a const_cast
for locally stored object. This approach guarantees that we never strip const from
const object.

Another benefit of this approach is that move_only_function<void(std::string)>
and move_only_function<void(std::string&&)> use same funciton pointer, which should
reduce binary size.

The _Storage and _Manager functionality was also extracted and adjusted from
_Mofunc_base, in preparation for implementation for copyable_function and
function_ref. The _Storage was adjusted to store functions pointers as void(*)().
The manage function, now accepts _Op enum parameter, and supports additional
operations:
 * _Op::_Address stores address of target object in destination
 * _Op::_Copy, when enabled, copies from source to destination
Furthermore, we provide a type-independent mamange functions for handling all:
 * function pointer types
 * trivially copyable object stored locally.
Similary as in case of invoker, we always pass source as const (for copy),
and cast away constness in case of move operations, where we know that source
is mutable.

Finally, the new helpers are defined in __polyfunc internal namespace.

PR libstdc++/119125

libstdc++-v3/ChangeLog:

* include/bits/mofunc_impl.h: (std::move_only_function): Adjusted for
changes in bits/move_only_function.h
(move_only_function::move_only_function(_Fn&&)): Special case
move_only_functions with same invoker.
(move_only_function::operator=(move_only_function&&)): Handle self
assigment.
* include/bits/move_only_function.h (__polyfunc::_Ptrs)
(__polyfunc::_Storage): Refactored from _Mo_func::_Storage.
(__polyfunc::__param_t): Moved from move_only_function::__param_t.
(__polyfunc::_Base_invoker, __polyfunc::_Invoke): Refactored from
move_only_function::_S_invoke.
(__polyfunc::_Manager): Refactored from _Mo_func::_S_manager.
(std::_Mofunc_base): Moved into __polyfunc::_Mo_base with parts
extracted to __polyfunc::_Storage and __polyfunc::_Manager.
(__polyfunc::__deref_as, __polyfunc::__invoker_of)
(__polyfunc::__base_of, __polyfunc::__is_invoker_convertible): Define.
(std::__is_move_only_function_v): Renamed to
__is_polymorphic_function_v.
(std::__is_polymorphic_function_v): Renamed from
__is_move_only_function_v.
* testsuite/20_util/move_only_function/call.cc: Test for
functions pointers.
* testsuite/20_util/move_only_function/conv.cc: New test.
* testsuite/20_util/move_only_function/move.cc: Tests for
self assigment.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agolibstdc++: Preserve the argument type in basic_format_args [PR119246]
Tomasz Kamiński [Wed, 30 Apr 2025 08:37:48 +0000 (10:37 +0200)] 
libstdc++: Preserve the argument type in basic_format_args [PR119246]

This commits adjust the way how the arguments are stored in the _Arg_value
(and thus basic_format_args), by preserving the types of fixed width
floating-point types, that were previously converted to float, double,
long double.

The _Arg_value union now contains alternatives with std::bfloat16_t,
std::float16_t, std::float32_t, std::float64_t that use pre-existing
_Arg_bf16, _Arg_f16, _Arg_f32, _Arg_f32 argument types.

This does not affect formatting, as specialization of formatters for fixed
width floating-point types formats them by casting to the corresponding
standard floating point type.

For the 128bit floating we need to handle the ppc64 architecture,
(_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT) for which the long double may (per TU
basis) designate either __ibm128 and __ieee128 type, we need to store both
types in the _Arg_value and have two _Arg_types (_Arg_ibm128, _Arg_ieee128).
On other architectures we use extra enumerator value to store __float128,
that is different from long double and _Float128. This is consistent with ppc64,
for which __float128, if present, is same type as __ieee128. We use _Arg_float128
_M_float128 names that deviate from _Arg_fN naming scheme, to emphasize that
this flag is not used for std::float128_t (_Float128) type, that is consistenly
formatted via handle.

The __format::__float128_t type is renamed to __format::__flt128_t, to mitigate
visual confusion between this type and __float128. We also introduce __bflt16_t
typedef instead of using of decltype.

We add new alternative for the _Arg_value and allow them to be accessed via _S_get,
when the types are available. However, we produce and handle corresponding _Arg_type,
only when we can format them. See also r14-3329-g27d0cfcb2b33de.

The formatter<_Float128, _CharT> that formats via __format::__flt128_t is always
provided, when type is available. It is still correct when __format::__flt128_t
is _Float128.

We also provide formatter<__float128, _CharT> that formats via __flt128_t.
As this type may be disabled (-mno-float128), extra care needs to be taken,
for situation when __float128 is same as long double. If the formatter would be
defined in such case, the formatter<long double, _CharT> would be generated
from different specializations, and have different mangling:
  * formatter<__float128, _CharT> if __float128 is present,
  * formatter<__format::__formattable_float, _CharT> otherwise.
To best of my knowledge this happens only on ppc64 for __ieee128 and __float128,
so the formatter is not defined in this case. static_assert is added to detect
other configurations like that. In such case we should replace it with constraint.

PR libstdc++/119246

libstdc++-v3/ChangeLog:

* include/std/format (__format::__bflt16_t): Define.
(_GLIBCXX_FORMAT_F128): Separate value for cases where _Float128
is used.
(__format::__float128_t): Renamed to __format::__flt128_t.
(std::formatter<_Float128, _CharT>): Define always if there is
formattable 128bit float.
(std::formatter<__float128, _CharT>): Define.
(_Arg_type::_Arg_f128): Rename to _Arg_float128 and adjust value.
(_Arg_type::_Arg_ibm128): Change value to _Arg_ldbl.
(_Arg_type::_Arg_ieee128): Define as alias to _Arg_float128.
(_Arg_value::_M_f128): Replaced with _M_ieee128 and _M_float128.
(_Arg_value::_M_ieee128, _Arg_value::_M_float128)
(_Arg_value::_M_bf16, _Arg_value::_M_f16, _Arg_value::_M_f32)
(_Arg_value::_M_f64): Define.
(_Arg_value::_S_get, basic_format_arg::_S_to_enum): Handle __bflt16,
_Float16, _Float32, _Float64, and __float128 types.
(basic_format_arg::_S_to_arg_type): Preserve _bflt16, _Float16,
_Float32, _Float64 and __float128 types.
(basic_format_arg::_M_visit): Handle _Arg_float128, _Arg_ieee128,
_Arg_b16, _Arg_f16, _Arg_f32, _Arg_f64.
* testsuite/std/format/arguments/args.cc: Updated to illustrate
that extended floating point types use handles now. Added test
for __float128.
* testsuite/std/format/parse_ctx.cc: Extended test to cover class
to check_dynamic_spec with floating point types and handles.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agoRemove Marcus Shawcroft
Richard Earnshaw [Wed, 14 May 2025 10:28:42 +0000 (11:28 +0100)] 
Remove Marcus Shawcroft

Marcus has stood down as a maintainer and we have no new email address.

ChangeLog:

* MAINTAINERS: Marcus Shawcroft has resigned from the project.

2 months agotree-sra: Do not create stores into const aggregates (PR111873)
Martin Jambor [Wed, 14 May 2025 10:08:24 +0000 (12:08 +0200)] 
tree-sra: Do not create stores into const aggregates (PR111873)

This patch fixes (hopefully the) one remaining place where gimple SRA
was still creating a load into const aggregates.  It occurs when there
is a replacement for a load but that replacement is not type
compatible - typically because it is a single field structure.

I have used testcases from duplicates because the original test-case
no longer reproduces for me.

gcc/ChangeLog:

2025-05-13  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/111873
* tree-sra.cc (sra_modify_expr): When processing a load which has
a type-incompatible replacement, do not store the contents of the
replacement into the original aggregate when that aggregate is
const.

gcc/testsuite/ChangeLog:

2025-05-13  Martin Jambor  <mjambor@suse.cz>

* gcc.dg/ipa/pr120044-1.c: New test.
* gcc.dg/ipa/pr120044-2.c: Likewise.
* gcc.dg/tree-ssa/pr114864.c: Likewise.

2 months agoc++/modules: Fix handling of -fdeclone-ctor-dtor with explicit instantiations [PR120125]
Nathaniel Shead [Thu, 8 May 2025 13:06:13 +0000 (23:06 +1000)] 
c++/modules: Fix handling of -fdeclone-ctor-dtor with explicit instantiations [PR120125]

The attached testcase ICEs in maybe_thunk_body because we haven't
created a node in the cgraph for an imported explicit instantiation yet.

We in fact really shouldn't be emitting calls at all, since an imported
explicit instantiation always exists in the TU we imported it from.  So
this patch adjusts DECL_NOT_REALLY_EXTERN handling to account for this.

PR c++/120125

gcc/cp/ChangeLog:

* module.cc (trees_out::write_function_def): Only set
DECL_NOT_REALLY_EXTERN if the importer might need to emit it.
* optimize.cc (maybe_thunk_body): Don't assume 'fn' has a cgraph
node created.

gcc/testsuite/ChangeLog:

* g++.dg/modules/clone-4_a.C: New test.
* g++.dg/modules/clone-4_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2 months agoc++: Fix OpenMP support with C++20 modules [PR119864]
Nathaniel Shead [Mon, 21 Apr 2025 10:40:29 +0000 (20:40 +1000)] 
c++: Fix OpenMP support with C++20 modules [PR119864]

In r15-2799-gf1bfba3a9b3f31, a new kind of global constructor was added.
Unfortunately this broke C++20 modules, as both the host and target
constructors were given the same mangled name.  This patch ensures that
only the host constructor gets the module name mangling for now, and
stops forcing the creation of the target constructor even when no such
initialization is required.

PR c++/119864

gcc/cp/ChangeLog:

* decl2.cc (start_objects): Only use module initialized for
host.
(c_parse_final_cleanups): Don't always create an OMP offload
init function in modules.

gcc/testsuite/ChangeLog:

* g++.dg/modules/openmp-1.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2 months agoc++/modules: Revert "Remove unnecessary lazy_load_pendings"
Nathaniel Shead [Fri, 9 May 2025 15:12:20 +0000 (01:12 +1000)] 
c++/modules: Revert "Remove unnecessary lazy_load_pendings"

This reverts commit r16-63-g241157eb0858b3.  It turns out that the
'lazy_load_pendings' is necessary if we haven't seen a binding for the
given template name at all in the current TU, as it is also used to find
template instantiations with the given name.

gcc/cp/ChangeLog:

* name-lookup.cc (lookup_imported_hidden_friend): Add back
lazy_load_pendings with comment.

gcc/testsuite/ChangeLog:

* g++.dg/modules/tpl-friend-19_a.C: New test.
* g++.dg/modules/tpl-friend-19_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2 months agoAdd std::to_underlying to the set of stdlib functions that are always folded
Ville Voutilainen [Mon, 12 May 2025 20:16:46 +0000 (23:16 +0300)] 
Add std::to_underlying to the set of stdlib functions that are always folded

gcc/cp/ChangeLog:
* cp-gimplify.cc (cp_fold): Add to_underlying.

gcc/testsuite/ChangeLog:
* g++.dg/opt/pr96780_cpp23.C: New.

libstdc++-v3/ChangeLog:
* include/std/utility (to_underlying): Add the __always_inline__ attribute.

Signed-off-by: Ville Voutilainen <ville.voutilainen@gmail.com>
2 months agos390: Fix tf_to_fprx2
Stefan Schulze Frielinghaus [Wed, 14 May 2025 07:22:00 +0000 (09:22 +0200)] 
s390: Fix tf_to_fprx2

Insn tf_to_fprx2 moves a TF value into a floating-point register pair.
For alternative 0, the input is a vector register, however, in the else
case instruction ldr is emitted which expects floating-point register
operands only.  Thus, this works only for vector registers which overlap
with floating-point registers.  Replace ldr with vlr so that the
remaining vector registers are dealt with, too.  Emitting a vlr instead
of a ldr is fine since the destination register %v0 is part of a
floating-point register pair which means that the low half of %v0 is
ignored in the end anyway and therefore may be clobbered.

gcc/ChangeLog:

* config/s390/vector.md: Fix tf_to_fprx2 by using vlr instead of
ldr.

2 months agoFortran: Fix mpfr_tanu use in gfc_simplify_cotand with mpfr 4.2.0+ [PR120225]
Tobias Burnus [Wed, 14 May 2025 07:18:09 +0000 (09:18 +0200)] 
Fortran: Fix mpfr_tanu use in gfc_simplify_cotand with mpfr 4.2.0+ [PR120225]

Fix commit r16-607-gc91c226762b422.

gcc/fortran/ChangeLog:

PR fortran/120225
* simplify.cc (gfc_simplify_cotand): Fix used argument in
mpfr_tanu call.

2 months agoFortran: Use mpfr_sinu etc. with mpfr 4.2.0+ for degree trigonometric functions ...
Tobias Burnus [Wed, 14 May 2025 07:12:13 +0000 (09:12 +0200)] 
Fortran: Use mpfr_sinu etc. with mpfr 4.2.0+ for degree trigonometric functions [PR120225]

As MPFR 4.2.0 added, support for degree trigonometric functions by via the
mpfr_...u functions (for u = 360), it makes sense to use them if available.
If MPFR is older, the current implementation is used as fallback.

PR fortran/120225

gcc/fortran/ChangeLog:

* simplify.cc: Include "trigd_fe.inc" only with MPFR < 4.2.0.
(rad2deg, rad2deg): Only define if MPFR < 4.2.0.
(gfc_simplify_acosd, gfc_simplify_asind, gfc_simplify_atand,
gfc_simplify_atan2d, gfc_simplify_cosd, gfc_simplify_tand,
gfc_simplify_cotand): Use mpfr_...u functions with MPFR >= 4.2.0.

2 months agoc++: Allow -Wvirtual-move-assign to be more easily ignored
Owen Avery [Tue, 13 May 2025 21:18:28 +0000 (17:18 -0400)] 
c++: Allow -Wvirtual-move-assign to be more easily ignored

This patch makes it easier to selectively disable
-Wvirtual-move-assign by allowing diagnostic pragmas on
base class move assignment operators to suppress such
warnings.

gcc/cp/ChangeLog:

* method.cc (synthesized_method_walk): Check whether
-Wvirtual-move-assign is enabled at the location of a base
class's move assignment operator.

gcc/testsuite/ChangeLog:

* g++.dg/warn/ignore-virtual-move-assign.C: New test.

Co-authored-by: Jason Merrill <jason@redhat.com>
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 months agoExtend vect_recog_cond_expr_convert_pattern to handle floating point type.
liuhongt [Tue, 8 Apr 2025 03:12:00 +0000 (20:12 -0700)] 
Extend vect_recog_cond_expr_convert_pattern to handle floating point type.

For floating point, !flag_trapping_math is needed for the pattern
which transforms 2 conversions to 1 conversion, and may lose 1
potential trap. There shouldn't be any accuracy issue.

gcc/ChangeLog:

PR tree-optimization/103771
* match.pd (cond_expr_convert_p): Extend the match to handle
scalar floating point type.
* tree-vect-patterns.cc
(vect_recog_cond_expr_convert_pattern): Handle floating point
type.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr103771-4.c: New test.

2 months agoDaily bump.
GCC Administrator [Wed, 14 May 2025 00:18:21 +0000 (00:18 +0000)] 
Daily bump.

2 months agogfortran.dg/dec_math.f90: Add comment regarding F2023 [PR113413]
Tobias Burnus [Tue, 13 May 2025 22:53:50 +0000 (00:53 +0200)] 
gfortran.dg/dec_math.f90: Add comment regarding F2023 [PR113413]

gcc/testsuite/ChangeLog:

PR fortran/113413
* gfortran.dg/dec_math.f90: Add comment that degree
functions are part of F2023.

2 months agofortran: map atand(y, x) to atan2d(y, x) [PR113413]
Yuao Ma [Mon, 12 May 2025 15:07:37 +0000 (23:07 +0800)] 
fortran: map atand(y, x) to atan2d(y, x) [PR113413]

According to the Fortran standard, atand(y, x) is equivalent to atan2d(y, x).
However, the current atand(y, x) function produces an error. This patch
includes the necessary intrinsic mapping, related test, and intrinsic
documentation.
The minor comment change in intrinsic.cc is cherry-picked from Steve's previous
work.

PR fortran/113413 - ATAND(Y,X) is unsupported

PR fortran/113413

gcc/fortran/ChangeLog:

* intrinsic.cc (do_check): Minor doc polish.
(add_functions): Add atand(y, x) mapping.
* intrinsic.texi: Update atand example.

gcc/testsuite/ChangeLog:

* gfortran.dg/dec_math.f90: Add atand(y, x) testcase.

Signed-off-by: Yuao Ma <c8ef@outlook.com>
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
2 months agoPR modula2/120253: Error message column numbers should start at 1 not 0
Gaius Mulley [Tue, 13 May 2025 21:54:33 +0000 (22:54 +0100)] 
PR modula2/120253: Error message column numbers should start at 1 not 0

This patch ensures that column numbers start at 1 rather than 0.

gcc/m2/ChangeLog:

PR modula2/120253
* m2.flex (FIRST_COLUMN): New define.
(updatepos): Remove commented code.
(consumeLine): Assign column to FIRST_COLUMN.
(initLine): Ditto.
(m2flex_GetColumnNo): Return FIRST_COLUMN if currentLine is NULL.
(m2flex_GetLineNo): Rewrite for positive logic.
(m2flex_GetLocation): Ditto.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2 months agogimple-fold: Don't replace `tmp = FP0 CMP FP1; if (tmp != 0)` over and over again...
Andrew Pinski [Tue, 22 Apr 2025 16:40:28 +0000 (09:40 -0700)] 
gimple-fold: Don't replace `tmp = FP0 CMP FP1; if (tmp != 0)` over and over again when comparison can throw

with -ftrapping-math -fnon-call-exceptions and:
```
tmp = FP0 CMP FP1;

if (tmp != 0) ...
```
a call fold_stmt on the GIMPLE_COND will replace the above with
a new tmp each time and we even lose the eh informatin on the
previous comparison too.

Changes since v1:
* v2: Use INTEGRAL_TYPE_P instead of a check against BOOLEAN_TYPE.
      Add testcase which shows where losing of landing pad happened.

PR tree-optimization/119903
gcc/ChangeLog:

* gimple-fold.cc (replace_stmt_with_simplification): Reject for
noncall exceptions replacing comparison with itself.
gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/pr119903-1.C: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 months agoverifier: Fix up PAREN_EXPR verification [PR118868]
Andrew Pinski [Tue, 13 May 2025 01:58:32 +0000 (18:58 -0700)] 
verifier: Fix up PAREN_EXPR verification [PR118868]

The verification added in r12-1608-g2f1686ff70b25f, was incorrect
for PAREN_EXPR, pointer types should be valid for PAREN_EXPR.
Also for PAREN_EXPR, aggregate types don't make sense (currently
they ICE much earlier in the gimplifier rather than error message) so
we should disallow them here too.

Bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/118868

gcc/ChangeLog:

* tree-cfg.cc (verify_gimple_assign_unary): Allow pointers
but disallow aggregate types for PAREN_EXPR.

gcc/testsuite/ChangeLog:

* c-c++-common/pr118868-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 months agocfgexpand: Update cache during the original DFS walk
Andrew Pinski [Wed, 4 Dec 2024 02:57:45 +0000 (18:57 -0800)] 
cfgexpand: Update cache during the original DFS walk

This is a small optimization which can improve how many times are need through the update loop.
It can reduce the number of times in the update loop by maybe 1 times.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* cfgexpand.cc (vars_ssa_cache::operator()): Update the cache if the use is already
has a cache.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 months agocfgexpand: Reverse the order of going through the update_cache_list queue.
Andrew Pinski [Tue, 3 Dec 2024 23:57:42 +0000 (15:57 -0800)] 
cfgexpand: Reverse the order of going through the update_cache_list queue.

This is a small optimization, the reversed order of the walk of update_cache_list queue.
The queue is pushed in Pre-order/NLR, reversing the order will reduce how many times we
need to go through the loop as we update the nodes which might have a link back to another
one first.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* cfgexpand.cc (vars_ssa_cache::operator()): Reverse the order of the going
through the update list.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 months agoRemove non-SLP path from vectorizable_induction
Richard Biener [Tue, 13 May 2025 12:16:57 +0000 (14:16 +0200)] 
Remove non-SLP path from vectorizable_induction

This removes the non-SLP path from vectorizable_induction.

* tree-vect-loop.cc (vectorizable_nonlinear_induction):
Remove non-SLP path, use SLP_TREE_VECTYPE.
(vectorizable_induction): Likewise.  Drop ncopies variable
which is always 1.

2 months agoPR modula2/120188: Use existing test for plugin
Gaius Mulley [Tue, 13 May 2025 12:35:00 +0000 (13:35 +0100)] 
PR modula2/120188: Use existing test for plugin

This is a cleanup patch which to use the existing plugin test
rather than check the configure build options.

gcc/testsuite/ChangeLog:

PR modula2/120188
* gm2.dg/doc/examples/plugin/fail/doc-examples-plugin-fail.exp:
Remove call to gm2-dg-frontend-configure-check and replace with
tests for whether plugin variables exist.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2 months agolibfortran: Fix up _gfortran_{,m,s}findloc2_s{1,4} [PR120196]
Jakub Jelinek [Tue, 13 May 2025 12:20:22 +0000 (14:20 +0200)] 
libfortran: Fix up _gfortran_{,m,s}findloc2_s{1,4} [PR120196]

As mentioned in the PR, _gfortran_{,m,s}findloc2_s{1,4} iterate too many
times in the back case if nothing is found.
For !back, the loops are for (i = 1; i <= extent; i++) so i is in the
body [1, extent] if nothing is found, but for back it is
for (i = extent; i >= 0; i--) so i is in the body [0, extent] and compares
one element before the start of the array.
Note, findloc1_s{1,4} uses
          for (n = len; n > 0; n--, src -= delta * len_array)
for the back loop and
          for (n = 1; n <= len; n++, src += delta * len_array)
for !back.  This patch fixes that.
The testcase fails under valgrind without the libgfortran changes and
succeeds with those.

2025-05-13  Jakub Jelinek  <jakub@redhat.com>

PR libfortran/120196
* m4/ifindloc2.m4 (header1, header2): For back use i > 0 rather than
i >= 0 as for condition.
* generated/findloc2_s1.c: Regenerate.
* generated/findloc2_s4.c: Regenerate.

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

2 months agolibfortran: Fix up _gfortran_s{max,min}loc1_{4,8,16}_s{1,4} [PR120191]
Jakub Jelinek [Tue, 13 May 2025 12:19:25 +0000 (14:19 +0200)] 
libfortran: Fix up _gfortran_s{max,min}loc1_{4,8,16}_s{1,4} [PR120191]

There is a bug in _gfortran_s{max,min}loc1_{4,8,16}_s{1,4} which the
following testcase shows.
The functions return but then crash in the caller.
Seems that is because buffer overflows, I believe those functions for
if (mask == NULL || *mask) condition being false are supposed to fill in
the result array with all zeros (or allocate it and fill it with zeros).
My understanding is the result array in that case is integer(kind={4,8,16})
and should have the extents the character input array has.
The problem is that it uses * string_len in the extent multiplication:
      extent[n] = GFC_DESCRIPTOR_EXTENT(array,n) * string_len;
and
      extent[n] =
        GFC_DESCRIPTOR_EXTENT(array,n + 1) * string_len;
which is I guess fine and desirable for the extents of the character array,
but not for the extents of the destination array.  Yet the code uses
that extent array for that purpose (and no other purposes).
Here it uses it to set the dimensions for the case where it needs to
allocate (as well as size):
      for (n = 0; n < rank; n++)
        {
          if (n == 0)
            str = 1;
          else
            str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
          GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
        }
Here it uses it for bounds checking of the destination:
      if (unlikely (compile_options.bounds_check))
        {
          for (n=0; n < rank; n++)
            {
              index_type ret_extent;

              ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n);
              if (extent[n] != ret_extent)
                runtime_error ("Incorrect extent in return value of"
                               " MAXLOC intrinsic in dimension %ld:"
                               " is %ld, should be %ld", (long int) n + 1,
                               (long int) ret_extent, (long int) extent[n]);
            }
        }
and here to find out how many retarray elements to actually fill in each
dimension:
  while(1)
    {
      *dest = 0;
      count[0]++;
      dest += dstride[0];
      n = 0;
      while (count[n] == extent[n])
        {
          /* When we get to the end of a dimension, reset it and increment
             the next dimension.  */
          count[n] = 0;
          /* We could precalculate these products, but this is a less
             frequently used path so probably not worth it.  */
          dest -= dstride[n] * extent[n];
Seems maxloc1s.m4 and minloc1s.m4 are the only users of ifunction-s.m4,
so we can change SCALAR_ARRAY_FUNCTION in there without breaking anything
else.

2025-05-13  Jakub Jelinek  <jakub@redhat.com>

PR fortran/120191
* m4/ifunction-s.m4 (SCALAR_ARRAY_FUNCTION): Don't multiply
GFC_DESCRIPTOR_EXTENT(array,) by string_len.
* generated/maxloc1_4_s1.c: Regenerate.
* generated/maxloc1_4_s4.c: Regenerate.
* generated/maxloc1_8_s1.c: Regenerate.
* generated/maxloc1_8_s4.c: Regenerate.
* generated/maxloc1_16_s1.c: Regenerate.
* generated/maxloc1_16_s4.c: Regenerate.
* generated/minloc1_4_s1.c: Regenerate.
* generated/minloc1_4_s4.c: Regenerate.
* generated/minloc1_8_s1.c: Regenerate.
* generated/minloc1_8_s4.c: Regenerate.
* generated/minloc1_16_s1.c: Regenerate.
* generated/minloc1_16_s4.c: Regenerate.

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

2 months agolibfortran: Fix up _gfortran_s{max,min}loc2_{4,8,16}_s{1,4} [PR120191]
Jakub Jelinek [Tue, 13 May 2025 12:18:10 +0000 (14:18 +0200)] 
libfortran: Fix up _gfortran_s{max,min}loc2_{4,8,16}_s{1,4} [PR120191]

I've tried to write a testcase for the BT_CHARACTER maxloc/minloc with named
or unnamed arguments and indeed the just posted patch fixed the arguments
in there in multiple cases to match what the library expects.
But the testcase still fails, due to library problems.

One dealt with in this patch are _gfortran_s{max,min}loc2_{4,8,16}_s{1,4}
functions.  Those are trivial wrappers around
_gfortrani_{max,min}loc2_{4,8,16}_s{1,4} which should call those functions
if the scalar mask is true and just return 0 otherwise.
The two bugs I see there is that the back, len arguments are swapped,
which means that it always acts as back=.true. and for len will use
character length of 1 or 0 instead of the desired one.
The _gfortrani_{max,min}loc2_{4,8,16}_s{1,4} functions have prototypes like
GFC_INTEGER_4
maxloc2_4_s1 (gfc_array_s1 * const restrict array, GFC_LOGICAL_4 back, gfc_charlen_type len)
so back comes before len, ditto for the
GFC_INTEGER_4
smaxloc2_4_s1 (gfc_array_s1 * const restrict array,
               GFC_LOGICAL_4 *mask, GFC_LOGICAL_4 back, gfc_charlen_type len)
The other problem is that it was just testing if (mask).  In my limited
Fortran understanding that means that the optional argument mask was
supplied but nothing about its actual value.  Other scalar mask generated
routines use if (mask == NULL || *mask) as the condition when to call the
non-masked function, i.e. when mask is not supplied (then it should act like
.true. mask) or when it is supplied and evaluates to .true.).

2025-05-13  Jakub Jelinek  <jakub@redhat.com>

PR fortran/120191
* m4/maxloc2s.m4: For smaxloc2 call maxloc2 if mask is NULL or *mask.
Swap back and len arguments.
* m4/minloc2s.m4: Likewise.
* generated/maxloc2_4_s1.c: Regenerate.
* generated/maxloc2_4_s4.c: Regenerate.
* generated/maxloc2_8_s1.c: Regenerate.
* generated/maxloc2_8_s4.c: Regenerate.
* generated/maxloc2_16_s1.c: Regenerate.
* generated/maxloc2_16_s4.c: Regenerate.
* generated/minloc2_4_s1.c: Regenerate.
* generated/minloc2_4_s4.c: Regenerate.
* generated/minloc2_8_s1.c: Regenerate.
* generated/minloc2_8_s4.c: Regenerate.
* generated/minloc2_16_s1.c: Regenerate.
* generated/minloc2_16_s4.c: Regenerate.

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

2 months agofortran: Fix up minloc/maxloc lowering [PR120191]
Jakub Jelinek [Tue, 13 May 2025 12:14:55 +0000 (14:14 +0200)] 
fortran: Fix up minloc/maxloc lowering [PR120191]

We need to drop the kind argument from what is passed to the
library, but need to do it not only when one uses the argument name
for it (so kind=4 etc.) but also when one passes all the arguments
to the intrinsics.

The following patch uses what gfc_conv_intrinsic_findloc uses,
which looks more efficient and cleaner, we already set automatic
vars to point to the kind and back actual arguments, so we can just
free/clear expr on the former and set name to "%VAL" on the latter.

And similarly clears dim argument for the BT_CHARACTER case when using
maxloc2/minloc2, again regardless of whether it was named or not.

2025-05-13  Jakub Jelinek  <jakub@redhat.com>
    Daniil Kochergin  <daniil2472s@gmail.com>
    Tobias Burnus  <tburnus@baylibre.com>

PR fortran/120191
* trans-intrinsic.cc (strip_kind_from_actual): Remove.
(gfc_conv_intrinsic_minmaxloc): Don't call strip_kind_from_actual.
Free and clear kind_arg->expr if non-NULL.  Set back_arg->name to
"%VAL" instead of a loop looking for last argument.  Remove actual
variable, use array_arg instead.  Free and clear dim_arg->expr if
non-NULL for BT_CHARACTER cases instead of using a loop.

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

2 months agoRemove -q quiet option from some GNAT bootstrap command lines
Nicolas Boulenguez [Tue, 13 May 2025 08:28:54 +0000 (10:28 +0200)] 
Remove -q quiet option from some GNAT bootstrap command lines

gcc/ada/
PR ada/87778
* Make-generated.in: Remove -q gnatmake option.
* gcc-interface/Makefile.in: Likewise.

2 months agolibiberty: Fix off-by-one when collecting range expression
Andreas Schwab [Wed, 7 May 2025 07:46:19 +0000 (09:46 +0200)] 
libiberty: Fix off-by-one when collecting range expression

Fixes this error during build of fixincludes:

In function ‘byte_regex_compile’,
    inlined from ‘xregcomp’ at ../libiberty/../../libiberty/regex.c:7973:11:
../libiberty/../../libiberty/regex.c:3477:29: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 3477 |                     str[c1] = '\0';
      |                             ^
../libiberty/../../libiberty/regex.c: In function ‘xregcomp’:
../libiberty/../../libiberty/regex.c:3454:35: note: at offset 128 into destination object ‘str’ of size 128
 3454 |                     unsigned char str[128];     /* Should be large enough.  */
      |                                   ^

* regex.c (regex_compile): Don't write beyond array bounds when
collecting range expression.

2 months agolibgcobol: Allow for lack of LOG_PERROR
Rainer Orth [Tue, 13 May 2025 07:43:48 +0000 (09:43 +0200)] 
libgcobol: Allow for lack of LOG_PERROR

The libgcobol build is broken again on Solaris:

/vol/gcc/src/hg/master/local/libgcobol/libgcobol.cc: In function ‘void
default_exception_handler(ec_type_t)’:
/vol/gcc/src/hg/master/local/libgcobol/libgcobol.cc:11196:44: error:
‘LOG_PERROR’ was not declared in this scope; did you mean ‘LOG_ERR’?
11196 | static int priority = LOG_INFO, option = LOG_PERROR, facility =
LOG_USER;
      |                                            ^~~~~~~~~~
      |                                            LOG_ERR
/vol/gcc/src/hg/master/local/libgcobol/libgcobol.cc:11202:28: error:
‘facility’ was not declared in this scope
11202 |     openlog(ident, option, facility);
      |                            ^~~~~~~~

LOG_PERROR is a BSD extension not present on Solaris due to its System V
heritage, and Linux syslog(3) documents:

       LOG_PERROR     (Not in POSIX.1-2001 or  POSIX.1-2008.)   Also  log  the
                      message to stderr.

This patch provides a fallback definition, just the minimum to unbreak
the build.

Tested on amd64-pc-solaris2.11, sparcv9-sun-solaris2.11, and
x86_64-pc-linux-gnu.

2025-05-12  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libgcobol:
* libgcobol.cc [!LOG_PERROR] (LOG_PERROR): Provide fallback.

2 months agoRISC-V: Drop riscv_ext_flag_table in favor of riscv_ext_info_t data
Kito Cheng [Wed, 7 May 2025 13:27:20 +0000 (21:27 +0800)] 
RISC-V: Drop riscv_ext_flag_table in favor of riscv_ext_info_t data

Refactor extension flag handling by removing the old riscv_ext_flag_table and
sourcing all flag definitions directly from the flags field of the unified
riscv_ext_info_t structures generated from riscv-ext.def.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc (riscv_extra_ext_flag_table_t):
New.
(riscv_ext_flag_table): Rename to ...
(riscv_extra_ext_flag_table): this, and drop most of definitions
that can obtained from the flags field of the riscv_ext_info_t
structures.
(apply_extra_extension_flags): Use riscv_ext_info_t.
(riscv_ext_is_subset): Ditto.

2 months agoRISC-V: Drop riscv_ext_version_table in favor of riscv_ext_info_t data
Kito Cheng [Thu, 8 May 2025 08:23:29 +0000 (16:23 +0800)] 
RISC-V: Drop riscv_ext_version_table in favor of riscv_ext_info_t data

This commit drops the riscv_ext_version_table and instead uses the
riscv_ext_info_t data structure to provide the version information
for RISC-V extensions.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc (riscv_ext_version_table):
Remove.
(standard_extensions_p): Use riscv_ext_info_t.
(get_default_version): Use riscv_ext_info_t.
(riscv_arch_help): Ditto.

2 months agoRISC-V: Drop riscv_implied_info and riscv_combine_info in favor of riscv_ext_info_t...
Kito Cheng [Wed, 7 May 2025 13:21:01 +0000 (21:21 +0800)] 
RISC-V: Drop riscv_implied_info and riscv_combine_info in favor of riscv_ext_info_t data

Consolidate implied-extension logic by removing the old `riscv_implied_info`
array and using the `implied_exts` field in the unified riscv_ext_info_t
structures generated from `riscv-ext.def`.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc
(riscv_implied_info::riscv_implied_info_t): Remove unused
variant.
(struct riscv_implied_info_t): Remove unsued field.
(riscv_implied_info::match): Remove unused variant, and adjust
the logic.
(get_riscv_ext_info): New.
(riscv_implied_info): Remove.
(riscv_ext_info_t::apply_implied_ext): New.
(riscv_combine_info). Remove.
(riscv_subset_list::handle_implied_ext): Use riscv_ext_info_t
rather than riscv_implied_info.
(riscv_subset_list::check_implied_ext): Ditto.
(riscv_subset_list::handle_combine_ext): Use riscv_ext_info_t
rather than riscv_combine_info.
(riscv_minimal_hwprobe_feature_bits): Use riscv_ext_info_t
rather than riscv_implied_info.

2 months agoRISC-V: Introduce riscv_ext_info_t to hold extension metadata
Kito Cheng [Wed, 7 May 2025 12:59:15 +0000 (20:59 +0800)] 
RISC-V: Introduce riscv_ext_info_t to hold extension metadata

Define a new riscv_ext_info_t struct to aggregate all ISA extension fields
(name, version, flags, implied extensions, bitmask and extra flags) generated
from riscv-ext.def.

Also adjust riscv_ext_flag_table_t and riscv_implied_info_t to make it
able to not hold extension name, this part will refactor in later
patchs.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc (riscv_ext_info_t): New
struct.
(opt_var_ref_t): Adjust order.
(cl_opt_var_ref_t): Ditto.
(riscv_ext_flag_table_t): Adjust order, and add a new construct
that not hold the extension name.
(riscv_version_t): New struct.
(riscv_implied_info_t): Adjust order, and add a new construct that not
hold the extension name.
(apply_extra_extension_flags): New function.
(riscv_ext_infos): New.
(riscv_implied_info): Adjust.
* config/riscv/riscv-opts.h (EXT_FLAG_MACRO): New macro.
(BITMASK_NOT_YET_ALLOCATED): New macro.

2 months agoRISC-V: Adjust riscv_can_inline_p
Kito Cheng [Wed, 7 May 2025 10:30:34 +0000 (18:30 +0800)] 
RISC-V: Adjust riscv_can_inline_p

We don't hold any extenison flags in `target_flags`, so no need to
gather the extenison flags in `target_flags`.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc (riscv_can_inline_p): Drop
extension flags check from `target_flags`.
* config/riscv/riscv-subset.h (riscv_x_target_flags_isa_mask):
Remove.
* config/riscv/riscv.cc (riscv_x_target_flags_isa_mask): Remove.

2 months agoRISC-V: Generate extension table in documentation from riscv-ext.def
Kito Cheng [Wed, 7 May 2025 13:10:53 +0000 (21:10 +0800)] 
RISC-V: Generate extension table in documentation from riscv-ext.def

Automatically build the ISA extension reference table in invoke.texi from
the unified riscv-ext.def metadata, ensuring documentation stays in sync
with extension definitions and reducing manual maintenance.

gcc/ChangeLog:

* doc/invoke.texi: Replace hand‑written extension table with
`@include riscv-ext.texi` to pull in auto‑generated entries.
* doc/riscv-ext.texi: New generated definition file
containing formatted documentation entries for each extension.
* Makefile.in: Add riscv-ext.texi to the list of files to be
processed by the Texinfo generator.
* config/riscv/gen-riscv-ext-texi.cc: New.
* config/riscv/t-riscv: Add rule for generating riscv-ext.texi.

2 months agoRISC-V: Use riscv-ext.def to generate target options and variables
Kito Cheng [Wed, 7 May 2025 10:28:18 +0000 (18:28 +0800)] 
RISC-V: Use riscv-ext.def to generate target options and variables

Leverage the centralized riscv-ext.def definitions to auto-generate
the target option parsing and associated internal flags, replacing
manual listings in riscv.opt; `riscv_ext_flag_table` part will remove in
later patch.

gcc/ChangeLog:

* config/riscv/gen-riscv-ext-opt.cc: New.
* config/riscv/riscv.opt: Drop manual entries for target
options, and include riscv-ext.opt.
* config/riscv/riscv-ext.opt: New.
* config/riscv/riscv-ext.opt.urls: New.
* config.gcc: Add riscv-ext.opt to the list of target options files.
* common/config/riscv/riscv-common.cc (riscv_ext_flag_table): Adjsut target
option variable entry.
(riscv_set_arch_by_subset_list): Adjust target option variable.
* config/riscv/riscv-c.cc (riscv_ext_flag_table): Adjust target
option variable entry.
* config/riscv/riscv-vector-builtins.cc (pragma_intrinsic_flags):
Adjust variable name.
(riscv_pragma_intrinsic_flags_pollute): Adjust variable name.
(riscv_pragma_intrinsic_flags_restore): Ditto.
* config/riscv/t-riscv: Add the rule for generating
riscv-ext.opt.
* config/riscv/riscv-opts.h (TARGET_MIN_VLEN): Update.
(TARGET_MIN_VLEN_OPTS): Update.

2 months agoRISC-V: Introduce riscv-ext*.def to define extensions
Kito Cheng [Wed, 7 May 2025 10:02:10 +0000 (18:02 +0800)] 
RISC-V: Introduce riscv-ext*.def to define extensions

Adding a new ISA extension to RISC-V GCC requires modifying several places:
1. riscv_ext_version_table for the extension version.
2. riscv.opt for the target option and variable.
3. riscv_ext_flag_table to bind the extension to its target option.
4. riscv_combine_info if this extension is just a macro extension.
5. riscv_implied_info if this extension implies other extensions.
6. invoke.texi for documentation (this one is often forgotten - even by me...).
7. riscv-ext-bitmask.def if this extension has been allocated a bitmask in
   `__riscv_feature_bits`.

And now, we've integrated all the information into riscv-ext.def and generate
(almost) everything from that!

Some of the fields, like URL, are not used yet. They are planned to be updated
later and used for improving the documentation.

Changes since v1:
- Rebase for including new extensions
- Fix MASK_VECTOR handling

gcc/ChangeLog:

* config/riscv/riscv-ext.def: New file; define extension metadata table.
* config/riscv/riscv-ext-corev.def: New.
* config/riscv/riscv-ext-sifive.def: New.
* config/riscv/riscv-ext-thead.def: New.
* config/riscv/riscv-ext-ventana.def: New.

2 months agodiagnostics: improvements to experimental-html output [PR116792]
David Malcolm [Tue, 13 May 2025 01:45:36 +0000 (21:45 -0400)] 
diagnostics: improvements to experimental-html output [PR116792]

Add barebones support for
* diagnostic metadata rules
* quoted source
* generated patches
* execution paths

gcc/ChangeLog:
PR other/116792
* diagnostic-format-html.cc: Include "diagnostic-format-text.h",
"pretty-print-urlifier.h" and "edit-context.h".
(html_builder::html_builder): Fix indentation in decl.
(html_builder::make_element_for_diagnostic): Split out metadata
code into make_element_for_metadata.  Call
make_element_for_source, make_element_for_path, and
make_element_for_patch.
(html_builder::make_element_for_source): New.
(html_builder::make_element_for_path): New.
(html_builder::make_element_for_patch): New.
(html_builder::make_metadata_element): New.
(html_builder::make_element_for_metadata): New.
(html_output_format::get_builder): New.
(selftest::test_html_diagnostic_context::get_builder): New.
(selftest::test_simple_log): Update test to print a quoted string,
and verify that it uses a "gcc-quoted-text" span.
(selftest::test_metadata): New.
(selftest::diagnostic_format_html_cc_tests): Call it.

gcc/testsuite/ChangeLog:
PR other/116792
* gcc.dg/html-output/missing-semicolon.py: Verify that we don't
have an empty "gcc-annotated-source" and we do have a
"gcc-generated-patch".
* gcc.dg/plugin/diagnostic-test-metadata-html.c: New test.
* gcc.dg/plugin/diagnostic-test-metadata-html.py: New test script.
* gcc.dg/plugin/diagnostic-test-paths-2.c: Add
"-fdiagnostics-add-output=experimental-html" to options. Add
invocation of diagnostic-test-paths-2.py.
* gcc.dg/plugin/diagnostic-test-paths-2.py: New test script.
* gcc.dg/plugin/plugin.exp (plugin_test_list): Add
diagnostic-test-metadata-html.c.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 months agoDaily bump.
GCC Administrator [Tue, 13 May 2025 00:18:32 +0000 (00:18 +0000)] 
Daily bump.

2 months agoRemove negative ranges using trailing zero masks.
Andrew MacLeod [Fri, 9 May 2025 00:28:11 +0000 (20:28 -0400)] 
Remove negative ranges using trailing zero masks.

When there are trailing 0's in the bitmask, set_range_from_bitmask () removes
the lower positive ranges which do not match the value.  This reworks it to
provide the same functionailty for the negative ranges in signed types.
If the lower 4 bits are all 0:
  int [-INF, +INF] MASK 0xfffffff0 VALUE 0x0
becomes:
  int [-INF,  -16][0, 0][16, 2147483632] MASK 0xfffffff0 VALUE 0x0

gcc/
* tree-ssanames.cc (set_bitmask): Use int_range_max for temps.
* value-range.cc (irange::set_range_from_bitmask): Handle all
trailing zero values.

gcc/testsuite/
* gcc.dg/tree-ssa/vrp124.c: New.

2 months agoRISC-V: Add testcases for vector unsigned integer SAT_ADD form 7
Pan Li [Mon, 28 Apr 2025 12:35:10 +0000 (20:35 +0800)] 
RISC-V: Add testcases for vector unsigned integer SAT_ADD form 7

This patch will add testcase for unsigned integer SAT_ADD form 7:

  #define DEF_VEC_SAT_U_ADD_FMT_9(WT, T)                                      \
  void __attribute__((noinline))                                              \
  vec_sat_u_add_##WT##_##T##_fmt_9 (T *out, T *op_1, T *op_2, unsigned limit) \
  {                                                                           \
    unsigned i;                                                               \
    T max = -1;                                                               \
    for (i = 0; i < limit; i++)                                               \
      {                                                                       \
        T x = op_1[i];                                                        \
        T y = op_2[i];                                                        \
        WT val = (WT)x + (WT)y;                                               \
        out[i] = val > max ? max : (T)val;                                    \
      }                                                                       \
  }

  DEF_VEC_SAT_U_ADD_FMT_9(uint64_t, uint32_t)

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

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/sat/vec_sat_arith.h: Add test helper macros.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-9-u16-from-u32.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-9-u16-from-u64.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-9-u32-from-u64.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-9-u8-from-u16.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-9-u8-from-u32.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-9-u8-from-u64.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-9-u16-from-u32.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-9-u16-from-u64.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-9-u32-from-u64.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-9-u8-from-u16.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-9-u8-from-u32.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-run-9-u8-from-u64.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 months agoRISC-V: Add testcases for scalar unsigned integer SAT_ADD form 7
Pan Li [Mon, 28 Apr 2025 12:35:09 +0000 (20:35 +0800)] 
RISC-V: Add testcases for scalar unsigned integer SAT_ADD form 7

This patch will add testcase for unsigned integer SAT_ADD form 7:

  #define DEF_SAT_U_ADD_FMT_7(WT, T)     \
  T __attribute__((noinline))            \
  sat_u_add_##WT##_##T##_fmt_7(T x, T y) \
  {                                      \
    T max = -1;                          \
    WT val = (WT)x + (WT)y;              \
    return val > max ? max : (T)val;     \
  }

  DEF_SAT_U_ADD_FMT_7(uint64_t, uint32_t)

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

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat/sat_arith.h: Add test helper macros.
* gcc.target/riscv/sat/sat_u_add-7-u16-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_add-7-u16-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_add-7-u32-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_add-7-u8-from-u16.c: New test.
* gcc.target/riscv/sat/sat_u_add-7-u8-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_add-7-u8-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_add-run-7-u16-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_add-run-7-u16-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_add-run-7-u32-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_add-run-7-u8-from-u16.c: New test.
* gcc.target/riscv/sat/sat_u_add-run-7-u8-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_add-run-7-u8-from-u64.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 months agoMatch: Support form 7 for unsigned integer SAT_ADD
Pan Li [Mon, 28 Apr 2025 12:35:08 +0000 (20:35 +0800)] 
Match: Support form 7 for unsigned integer SAT_ADD

This patch would like to support the form 7 of the unsigned
integer SAT_ADD, aka below example.

  #define DEF_SAT_U_ADD_FMT_7(WT, T)     \
  T __attribute__((noinline))            \
  sat_u_add_##WT##_##T##_fmt_7(T x, T y) \
  {                                      \
    T max = -1;                          \
    WT val = (WT)x + (WT)y;              \
    return val > max ? max : (T)val;     \
  }

  DEF_SAT_U_ADD_FMT_7(uint64_t, uint32_t)

If we take -O3 build with -fdump-tree-optimized, we will have

Before this patch:
   5   │ __attribute__((noinline))
   6   │ uint32_t sat_u_add_uint64_t_uint32_t_fmt_7 (uint32_t x, uint32_t y)
   7   │ {
   8   │   uint64_t val;
   9   │   long unsigned int _1;
  10   │   long unsigned int _2;
  11   │   uint32_t _3;
  12   │   uint32_t _7;
  13   │
  14   │   <bb 2> [local count: 1073741824]:
  15   │   _1 = (long unsigned int) x_4(D);
  16   │   _2 = (long unsigned int) y_5(D);
  17   │   val_6 = _1 + _2;
  18   │   if (val_6 <= 4294967295)
  19   │     goto <bb 3>; [65.00%]
  20   │   else
  21   │     goto <bb 4>; [35.00%]
  22   │
  23   │   <bb 3> [local count: 697932184]:
  24   │   _7 = x_4(D) + y_5(D);
  25   │
  26   │   <bb 4> [local count: 1073741824]:
  27   │   # _3 = PHI <4294967295(2), _7(3)>
  28   │   return _3;
  29   │
  30   │ }

After this patch:
   4   │ __attribute__((noinline))
   5   │ uint32_t sat_u_add_uint64_t_uint32_t_fmt_7 (uint32_t x, uint32_t y)
   6   │ {
   7   │   uint32_t _3;
   8   │
   9   │   <bb 2> [local count: 1073741824]:
  10   │   _3 = .SAT_ADD (x_4(D), y_5(D)); [tail call]
  11   │   return _3;
  12   │
  13   │ }

This change also effects on vector mode too.

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

gcc/ChangeLog:

* match.pd: Add form 7 matching pattern for unsigned integer
SAT_ADD.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 months agoaarch64: Remove cmov<mode>6 patterns
Andrew Pinski [Mon, 12 May 2025 17:23:01 +0000 (17:23 +0000)] 
aarch64: Remove cmov<mode>6 patterns

Since the cmov optab is not used and is being removed,
the `cmov<mode>6` patterns from the aarch64 backend can
also be removed.

gcc/ChangeLog:
* config/aarch64/aarch64.md (cmov<mode>6): Remove.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 months agooptabs: Remove cmov optab [PR120230]
Andrew Pinski [Mon, 12 May 2025 05:11:38 +0000 (22:11 -0700)] 
optabs: Remove cmov optab [PR120230]

cmov optab was added back in r0-24110-g1c0290eaac4094
(https://gcc.gnu.org/pipermail/gcc-patches/1999-September/018596.html)
but it was never used. movcc is used instead and since r0-93453-gf90b7a5a7913cc (cond-optab),
movcc becomes what cmov_optab was going to be; in having a combined compare and move optab.

Note the only target which seems to have implemented this optab is aarch64; will remove
that in a different patch.

Bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/120230
gcc/ChangeLog:

* optabs.cc (can_compare_p): Remove support for ccp_cmov.
* optabs.def (cmov_optab): Remove.
* optabs.h (can_compare_purpose): Remove ccp_cmov.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 months agoAdd dispatch for casts between integer and float.
Andrew MacLeod [Mon, 12 May 2025 15:41:37 +0000 (11:41 -0400)] 
Add dispatch for casts between integer and float.

GCC currently does not implement range operators for casting between
integers and float.  This patch adds the missing dispatch patterns and
routines to facilitate implmenting these casts.

PR tree-optimization/120231
* range-op-float.cc (operator_cast::fold_range): New variants.
(operator_cast::op1_range): Likewise.
* range-op-mixed.h (operator_cast::fold_range): Likewise.
(operator_cast::op1_range): Likewise
* range-op.cc (range_op_handler::fold_range): Add RO_FIF dispatch.
(range_op_handler::op1_range): Add RO_IFF and RO_FII patterns.
(range_operator::fold_range): Provide new variant default.
(range_operator::op1_range): Likewise.
* range-op.h (range_operator): Add new variant methods.

2 months agoc+: -Wabi false positive [PR120012]
Jason Merrill [Mon, 12 May 2025 15:53:03 +0000 (11:53 -0400)] 
c+: -Wabi false positive [PR120012]

The warning compares the position of a field depending on whether or not the
previous base/field is considered a POD for layout, but failed to consider
whether the previous base/field is empty; layout of an empty base doesn't
consider PODness.

PR c++/120012

gcc/cp/ChangeLog:

* class.cc (check_non_pod_aggregate): Check is_empty_class.

gcc/testsuite/ChangeLog:

* g++.dg/abi/base-defaulted2.C: New test.

2 months agoUpdate cpplib es.po
Joseph Myers [Mon, 12 May 2025 17:55:12 +0000 (17:55 +0000)] 
Update cpplib es.po

* es.po: Update.

2 months agoUpdate gcc sv.po
Joseph Myers [Mon, 12 May 2025 17:37:12 +0000 (17:37 +0000)] 
Update gcc sv.po

* sv.po: Update.

2 months agoPR modula2/120188: documented example does not work assignvalue m2plugin
Gaius Mulley [Mon, 12 May 2025 16:59:00 +0000 (17:59 +0100)] 
PR modula2/120188: documented example does not work assignvalue m2plugin

This patch corrects the gm2 command line used in the documentation
to invoke the m2-plugin.  The patch also includes the documentation
example in dejagnu test code with an expect script to check whether
plugins were enabled.

gcc/ChangeLog:

PR modula2/120188
* doc/gm2.texi (Semantic checking): Add -fm2-plugin command line option.

gcc/testsuite/ChangeLog:

PR modula2/120188
* lib/gm2-dg.exp (gm2-dg-frontend-configure-check): New function.
(gm2-dg-runtest): Add -O2 to the option_list.
* gm2.dg/doc/examples/plugin/fail/assignvalue.mod: New test.
* gm2.dg/doc/examples/plugin/fail/doc-examples-plugin-fail.exp: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2 months agoGCN, nvptx offloading: Restrain 'WARNING: program timed out.' while in 'dynamic_cast...
Thomas Schwinge [Fri, 9 May 2025 12:49:03 +0000 (14:49 +0200)] 
GCN, nvptx offloading: Restrain 'WARNING: program timed out.' while in 'dynamic_cast'" [PR119692]

PR target/119692
libgomp/
* testsuite/libgomp.c++/pr119692-1-4.C: '{ dg-timeout 10 }'.
* 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.

2 months agonvptx: Support '-march=sm_61'
Thomas Schwinge [Wed, 7 May 2025 14:02:16 +0000 (16:02 +0200)] 
nvptx: Support '-march=sm_61'

gcc/
* config/nvptx/nvptx-sm.def: Add '61'.
* config/nvptx/nvptx-gen.h: Regenerate.
* config/nvptx/nvptx-gen.opt: Likewise.
* config/nvptx/nvptx.cc (first_ptx_version_supporting_sm): Adjust.
* config/nvptx/nvptx.opt (-march-map=sm_61, -march-map=sm_62):
Likewise.
* config.gcc: Likewise.
* doc/invoke.texi (Nvidia PTX Options): Document '-march=sm_61'.
* config/nvptx/gen-multilib-matches-tests: Extend.
gcc/testsuite/
* gcc.target/nvptx/march-map=sm_61.c: Adjust.
* gcc.target/nvptx/march-map=sm_62.c: Likewise.
* gcc.target/nvptx/march=sm_61.c: New.
libgomp/
* testsuite/libgomp.c/declare-variant-3-sm61.c: New.
* testsuite/libgomp.c/declare-variant-3.h: Adjust.

2 months agonvptx: Support '-mptx=5.0'
Thomas Schwinge [Wed, 7 May 2025 13:37:17 +0000 (15:37 +0200)] 
nvptx: Support '-mptx=5.0'

gcc/
* config/nvptx/nvptx-opts.h (enum ptx_version): Add
'PTX_VERSION_5_0'.
* config/nvptx/nvptx.cc (ptx_version_to_string)
(ptx_version_to_number): Adjust.
* config/nvptx/nvptx.h (TARGET_PTX_5_0): New.
* config/nvptx/nvptx.opt (Enum(ptx_version)): Add 'EnumValue'
'5.0' for 'PTX_VERSION_5_0'.
* doc/invoke.texi (Nvidia PTX Options): Document '-mptx=5.0'.
gcc/testsuite/
* gcc.target/nvptx/mptx=5.0.c: New.

2 months agoGCN, nvptx libstdc++: Force use of '__atomic' builtins: revert 'atomicity_dir=cpu...
Thomas Schwinge [Mon, 12 May 2025 09:06:47 +0000 (11:06 +0200)] 
GCN, nvptx libstdc++: Force use of '__atomic' builtins: revert 'atomicity_dir=cpu/generic/atomicity_builtins' hard-coding [PR119645]"

Thanks to commit 86627faec10da53d7532805019e5296fcf15ac09
"libstdc++: Rewrite atomic builtin checks [PR70560]", for both GCN, nvptx
we now get:

    +configure:16060: checking for atomic builtins for _Atomic_word
    +[...]
    +configure:16073: result: yes

..., and thus may revert the 'atomicity_dir=cpu/generic/atomicity_builtins'
hard-coding added in commit 059b5509c14904b55c37f659170240ae0d2c1c8e
"GCN, nvptx libstdc++: Force use of '__atomic' builtins [PR119645]".

PR target/119645
libstdc++-v3/
* configure.host [GCN, nvptx] (atomicity_dir): Don't set.

2 months agotestsuite: arm: Fix unsigned-extend-2.c [PR116445]
Christophe Lyon [Tue, 8 Apr 2025 16:24:18 +0000 (16:24 +0000)] 
testsuite: arm: Fix unsigned-extend-2.c [PR116445]

The test was designed to pass with thumb2, but code generation changed
with the introduction of Low Overhead Loops, so the test can fail if
one overrides the flags when running the testsuite.

In addition, useless subtract / extension instructions require -O2 to
remove them (-O is not sufficient), so replace -O with -O2 in
dg-options.

arm_thumb2_ok_no_arm_v8_1m_lob does not do what the test needs (it can
fail because some flags conflict, rather than because lob are
supported, and we do not need to check runtime support in this test
anyway), so the patch reverts back to arm_thumb2_ok.

Finally, replace the scan-assembler directives with
check-function-bodies, checking both types of code generation (with
and without LOL).  Depending on architecture version, the two insns
    and     r0, r1, r0, lsr #1
    ands    r3, r3, #255
can be swapped, so accept both orders.

gcc/testsuite/ChangeLog:

PR target/116445
* gcc.target/arm/unsigned-extend-2.c: Fix dg directives.

2 months agoRISC-V: Minimal support for ssnpm, smnpm and smmpm extensions.
Dongyan Chen [Mon, 12 May 2025 09:19:24 +0000 (17:19 +0800)] 
RISC-V: Minimal support for ssnpm, smnpm and smmpm extensions.

This patch support ssnpm, smnpm, smmpm, sspm and supm extensions[1].
To enable GCC to recognize and process ssnpm, smnpm, smmpm, sspm and
supm extensions correctly at compile time.

[1]https://github.com/riscv/riscv-j-extension/blob/master/zjpm/instructions.adoc

Changes for v5:
- Fix the testsuite error in arch-50.c.
Changes for v4:
- Fix the code based on the commit id 9b13bea07706a7cae0185f8a860d67209308c050.
Changes for v3:
- Fix the error messages in gcc/testsuite/gcc.target/riscv/arch-46.c
Changes for v2:
- Add the sspm and supm extensions.
- Add the check_conflict_ext function to check the compatibility of ssnpm, smnpm, smmpm, sspm and supm extensions.
- Add the test cases for ssnpm, smnpm, smmpm, sspm and supm extensions.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc
(riscv_subset_list::check_conflict_ext): New extension.
* config/riscv/riscv.opt: Ditto.

gcc/testsuite/ChangeLog:

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

2 months agoRISC-V: Support for zilsd and zclsd extensions.
Dongyan Chen [Mon, 17 Mar 2025 14:23:18 +0000 (22:23 +0800)] 
RISC-V: Support for zilsd and zclsd extensions.

This patch support zilsd and zclsd[1] extensions.
To enable GCC to recognize and process zilsd and zclsd extension correctly at compile time.

[1] https://github.com/riscv/riscv-zilsd

Changes for v2:
- Remove the addition of zilsd extension in gcc/common/config/riscv/riscv-ext-bitmask.def
- Fix a bug with zilsd and zclsd extension dependency in gcc/common/config/riscv/riscv-common.cc

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc
(riscv_subset_list::check_conflict_ext): New extension.
* config/riscv/riscv.opt: Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/arch-zilsd-1.c: New.
* gcc.target/riscv/arch-zilsd-2.c: New.
* gcc.target/riscv/arch-zilsd-3.c: New.

2 months agolibstdc++: Fix constraint recursion in std::expected's operator== [PR119714]
Patrick Palka [Mon, 12 May 2025 13:15:34 +0000 (09:15 -0400)] 
libstdc++: Fix constraint recursion in std::expected's operator== [PR119714]

This std::expected friend operator== is prone to constraint recursion
after CWG 2369 for the same reason as basic_const_iterator's comparison
operators were before the r15-7757-g4342c50ca84ae5 workaround.  This
patch works around the constraint recursion here in a similar manner,
by making the function parameter of type std::expected dependent in a
trivial way.

PR libstdc++/119714
PR libstdc++/112490

libstdc++-v3/ChangeLog:

* include/std/expected (expected::operator==): Replace
non-dependent std::expected function parameter with a dependent
one of type expected<_Vp, _Er> where _Vp matches _Tp.
* testsuite/20_util/expected/119714.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2 months agolibstdc++: Remove #warning from <ciso646> for C++17 [PR120187]
Jonathan Wakely [Fri, 9 May 2025 09:23:05 +0000 (10:23 +0100)] 
libstdc++: Remove #warning from <ciso646> for C++17 [PR120187]

Although <ciso646> was removed from C++20, it was not formally
deprecated in C++17. In contrast, <ctgmath>, <cstdalign>, etc. were
formally deprecated in C++17 before being removed in C++20.

Due to the widespread convention of including <ciso646> to detect
implementation-specific macros (such as _GLIBCXX_RELEASE) it causes
quite a lot of noise to issue deprecation warnings in C++17 mode. The
recommendation to include <version> instead does work for recent
compilers, even in C++17 mode, but isn't portable to older compilers
that don't provide <version> yet (e.g. GCC 8).

There are also potential objections to including <version> pre-C++20
when it wasn't defined by the standard. I don't have much sympathy for
this position, because including <ciso646> for implementation-specific
macros wasn't part of the C++17 standard either. It's no more
non-standard to rely on <version> being present and defining those
macros than to rely on <ciso646> defining them, and __has_include can be
used to detect whether <version> is present. However, <ciso646> is being
used in the wild by popular libraries like Abseil and we can't change
versions of those that have already been released.

This removes the #warning in <ciso646> for C++17 mode, so that we only
emit diagnostics for C++20 and later. With this change, including
<ciso646> in C++20 or later gives an error if _GLIBCXX_USE_DEPRECATED is
defined to zero, otherwise a warning if -Wdeprecated is enabled,
otherwise no diagnostic is given.

This also adds "@since C++11 (removed in C++20)" to the Doxygen @file
comments in all the relevant headers.

The test for <ciso646> needs to be updated to no longer expect a warning
for c++17_only. A new test is added to ensure that we get a warning
instead of an error when -D_GLIBCXX_USE_DEPRECATED=0 is not used.

libstdc++-v3/ChangeLog:

PR libstdc++/120187
* include/c_global/ciso646: Only give deprecated warning for
C++20 and later.
* include/c_global/ccomplex: Add @since to Doxygen comment.
* include/c_global/cstdalign: Likewise.
* include/c_global/cstdbool: Likewise.
* include/c_global/ctgmath: Likewise.
* testsuite/18_support/headers/ciso646/macros.cc: Remove
dg-warning for c++17_only effective target.
* testsuite/18_support/headers/ciso646/macros-2.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agolibstdc++: Update C++23 status table
Jonathan Wakely [Thu, 8 May 2025 14:35:43 +0000 (15:35 +0100)] 
libstdc++: Update C++23 status table

This should have been updated for the GCC 15.1 release.

libstdc++-v3/ChangeLog:

* doc/xml/manual/status_cxx2023.xml: Update status of proposals
implemented after GCC 14.2 release.
* doc/html/manual/status.html: Regenerate.

2 months agolibstdc++: Restore std::scoped_lock for non-gthreads targets [PR120198]
Jonathan Wakely [Fri, 9 May 2025 16:50:52 +0000 (17:50 +0100)] 
libstdc++: Restore std::scoped_lock for non-gthreads targets [PR120198]

This was a regression introduced with using version.def to define
feature test macros (r14-3248-g083b7f2833d71d). std::scoped_lock doesn't
need to depend on gthreads and so can be defined unconditionally, even
for freestanding.

libstdc++-v3/ChangeLog:

PR libstdc++/120198
* include/bits/version.def (scoped_lock): Do not depend on
gthreads or hosted.
* include/bits/version.h: Regenerate.
* include/std/mutex (scoped_lock): Update comment.
* testsuite/30_threads/scoped_lock/requirements/typedefs.cc:
Remove dg-require-gthreads and use custom lockable type instead
of std::mutex. Check that typedef is only present for a single
template argument.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agosync LTO streaming and hashing for accelerators and vector type mode
Richard Biener [Mon, 3 Mar 2025 09:09:25 +0000 (10:09 +0100)] 
sync LTO streaming and hashing for accelerators and vector type mode

The following syncs up LTO tree hashing and streaming of TYPE_MODE
and DECL_MODE which long had a discrepancy for vector types and
recently got special-casing of streaming for offloading.  Failure
to handle this results in less possible type merging to occur.
Note the compare step will still use TYPE_MODE and DECL_MODE.

* lto-streamer-out.cc (hash_tree): Hash TYPE_MODE_RAW.
When offloading hash modes as VOIDmode for aggregates
and vectors.

2 months agoarm: doc: cleanup documentation references to iWMMXT extensions
Richard Earnshaw [Thu, 8 May 2025 09:33:55 +0000 (10:33 +0100)] 
arm: doc: cleanup documentation references to iWMMXT extensions

Now that the iwmmxt extensions have been removed, clean up the
references to it in the documentation.  We keep the
-mcpu/-mtune/-march references as these are still accepted by the
driver.

gcc/ChangeLog:

* doc/extend.texi: Remove the iwmmxt intrinsics.
* doc/md.texi: Remove the iwmmxt-related constraints.

2 months agoarm: remove iwmmxt registers from allocator tables
Richard Earnshaw [Wed, 30 Apr 2025 17:13:43 +0000 (18:13 +0100)] 
arm: remove iwmmxt registers from allocator tables

These registers can no-longer be allocated, so remove them from the
various tables.

gcc/ChangeLog:

* config/arm/aout.h (REGISTER_NAMES): Remove iwmmxt registers.
* config/arm/arm.h (FIRST_IWMMXT_REGNUM): Delete.
(LAST_IWMMXT_REGNUM): Delete.
(FIRST_IWMMXT_GR_REGNUM): Delete.
(LAST_IWMMXT_GR_REGNUM): Delete.
(IS_IWMMXT_REGNUM):  Delete.
(IS_IWMMXT_GR_REGNUM): Delete.
(FRAME_POINTER_REGNUM): Define relative to CC_REGNUM.
(ARG_POINTER_REGNUM): Define relative to FRAME_POINTER_REGNUM.
(FIRST_PSEUDO_REGISTER): Adjust.
(WREG): Delete.
(WGREG): Delete.
(REG_ALLOC_ORDER): Remove iWMMX registers.
(enum reg_class): Remove iWMMX register classes.
(REG_CLASS_NAMES): Likewise.
(REG_CLASS_CONTENTS):  Remove iWMMX registers.
* config/arm/arm.md (CC_REGNUM): Adjust value.
(VFPCC_RENGUM): Likewise.
(APSRQ_REGNUM): Likewise.
(APSRGE_REGNUM): Likewise.
(VPR_REGNUM): Likewise.
(RA_AUTH_CODE): Likewise.

2 months agoarm: remove most remaining iwmmxt code.
Richard Earnshaw [Wed, 30 Apr 2025 16:12:52 +0000 (17:12 +0100)] 
arm: remove most remaining iwmmxt code.

Remove most of the remaining code for iWMMXT support, except for the
register allocation table entries.

gcc/ChangeLog:

* config/arm/arm-cpus.in (feature iwmmxt, feature iwmmxt2):  Delete.
* config/arm/arm-protos.h (arm_output_iwmmxt_shift_immediate): Delete.
(arm_output_iwmmxt_tinsr): Delete.
(arm_arch_iwmmxt): Delete.
(arm_arch_iwmmxt2): Delete.
* config/arm/arm.h (TARGET_IWMMXT): Delete.
(TARGET_IWMMXT2): Delete.
(TARGET_REALLY_IWMMXT): Delete.
(TARGET_REALLY_IWMMXT2): Delete.
(VALID_IWMMXT_REG_MODE): Delete.
(ARM_HAVE_V8QI_ARITH): Remove iWMMXT.
(ARM_HAVE_V4HI_ARITH): Likewise.
(ARM_HAVE_V2SI_ARITH): Likewise.
(ARM_HAVE_V8QI_LDST): Likewise.
(ARM_HAVE_V4HI_LDST): Likewise.
(ARM_HAVE_V2SI_LDST): Likewise.
(SECONDARY_OUTPUT_RELOAD_CLASS):  Remove iWMMXT cases.
(SECONDARY_INPUT_RELOAD_CLASS): Likewise.
* config/arm/arm.cc (arm_arch_iwmmxt): Delete.
(arm_arch_iwmmxt2): Delete.
(arm_option_reconfigure_globals): Don't initialize them.
(arm_register_move_cost): Remove costs for iwmmxt.
(struct minipool_node):  Update comment.
(output_move_double): Likewise
(output_return_instruction): Likewise.
(arm_print_operand, cases 'U' and 'w'): Report an error if
used.
(arm_regno_class): Remove iWMMXT cases.
(arm_debugger_regno): Remove iWMMXT cases.
(arm_output_iwmmxt_shift_immediate): Delete.
(arm_output_iwmmxt_tinsr): Delete.

2 months agoarm: remove dead predefines when using WMMX
Richard Earnshaw [Wed, 30 Apr 2025 12:52:31 +0000 (13:52 +0100)] 
arm: remove dead predefines when using WMMX

Since we no-longer enable iWMMXT, these predefines are no-longer enabled
when preprocessing C.  Remove them.

gcc/ChangeLog:

* config/arm/arm-c.cc (arm_cpu_builtins):  Remove predefines
for __IWWMXT__, __IWMMXT2__ and __ARM_WMMX.

2 months agoarm: cleanup iterators.md after removing iwmmxt
Richard Earnshaw [Wed, 30 Apr 2025 12:49:13 +0000 (13:49 +0100)] 
arm: cleanup iterators.md after removing iwmmxt

Mostly this is just removing references to iWMMXT in comments, but also remove
some now unused iterators and attributes.

gcc/ChangeLog:

* config/arm/iterators.md (VMMX, VMMX2): Remove mode iterators.
(MMX_char): Remove mode iterator attribute.

2 months agoarm: remove iwmmxt-related attributes from machine description
Richard Earnshaw [Wed, 30 Apr 2025 10:45:28 +0000 (11:45 +0100)] 
arm: remove iwmmxt-related attributes from machine description

Since we no-longer have any iwmxxt instructions, the iwmmxt-related
attributes can never be set.  Consequently, the marvel-f-iwmmxt
scheduler is redundant as none of the pipes are ever used now.

gcc/ChangeLog:

* config/arm/arm.md (core_cycles): Remove iwmmxt attributes.
* config/arm/types.md (autodetect_type): Likewise.
* config/arm/marvell-f-iwmmxt.md: Removed.
* config/arm/t-arm: Remove marvell-f-iwmmxt.md

2 months agoarm: Remove iwmmxt support from arm.cc
Richard Earnshaw [Mon, 28 Apr 2025 16:48:51 +0000 (17:48 +0100)] 
arm: Remove iwmmxt support from arm.cc

TARGET_IWMMXT, TARGET_IWMMXT2 and their _REALLY_ equivalents are never
true now, so the code using them can be simplified.

gcc/ChangeLog:

* config/arm/arm.cc (arm_option_check_internal): Remove
IWMMXT check.
(arm_options_perform_arch_sanity_checks): Likewise.
(use_return_insn): Likewise.
(arm_init_cumulative_args): Likewise.
(arm_legitimate_index_p): Likewise.
(thumb2_legitimate_index_p): Likewise.
(arm_compute_save_core_reg_mask): Likewise.
(output_return_instruction): Likewise.
(arm_compute_frame_layout): Likewise.
(arm_save_coproc_regs): Likewise.
(arm_hard_regno_mode_ok): Likewise.
(arm_expand_epilogue_apcs_frame): Likewise.
(arm_expand_epilogue): Likewise.
(arm_vector_mode_supported_p): Likewise.
(arm_preferred_simd_mode): Likewise.
(arm_conditional_register_usage): Likewise.

2 months agoarm: remove support for the iwmmxt ABI variant.
Richard Earnshaw [Mon, 28 Apr 2025 16:15:45 +0000 (17:15 +0100)] 
arm: remove support for the iwmmxt ABI variant.

The iwmmxt ABI is a variant of the ABI that supported passing certain
parameters and results in iwmmxt registers.  But since we no-longer
support the instructions that can read and write these registers, the
ABI variant can no-longer be used.

gcc/ChangeLog:

* config.gcc (arm, --with-abi): Remove iwmmxt abi option.
* config/arm/arm.opt (enum ARM_ABI_IWMMXT): Remove.
* config/arm/arm.h (TARGET_IWMMXT_ABI): Delete.
(enum arm_pcs): Remove ARM_PCS_AAPCS_IWMMXT.
(FUNCTION_ARG_REGNO_P): Remove IWMMXT ABI support.
(CUMULATIVE_ARGS): Remove iwmmxt_nregs.
* config/arm/arm.cc (arm_options_perform_arch_sanity_checks):
Remove IWMMXT ABI checks.
(arm_libcall_value_1): Likewise.
(arm_function_value_regno_p): Likewise.
(arm_apply_result_size): Remove adjustment for IWMMXT ABI.
(arm_function_arg): Remove IWMMXT ABI support.
(arm_arg_partial_bytes): Likewise.
(arm_function_arg_advance): Likewise.
(arm_init_cumulative_args): Don't initialize iwmmxt_nregs.
* doc/invoke.texi (arm -mabi): Remove mention of the iwmmxt
ABI option.
* config/arm/arm-opts.h (enum arm_abi_type): Remove ARM_ABI_IWMMXT.