Luke Zhuang [Thu, 25 Jun 2026 05:45:16 +0000 (13:45 +0800)]
RISC-V: Declare TLSDESC clobbers for vector registers and CSRs per psABI
Per the RISC-V psABI, the TLSDESC resolver clobbers a0 and t0 in the
base case. With the new psABI update
(https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/496),
when the V extension is enabled, it additionally clobbers all vector
registers and vector CSRs.
This patch updates the clobbering of tlsdesc define_insn: clobbering
not only a0 and t0, but also all V-regs (using 4 x LMUL8 reg
groups covering all 32 physical V-regs), and 4 vector CSRs
(vl/vtype/vxrm/vxstat).
Three new tests are added covering GPR, vector register, and vector
CSR clobber behavior.
gcc/ChangeLog:
* config/riscv/riscv.md (VXSAT_REGNUM): New constant.
(@tlsdesc<mode>): update clobbering.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/tlsdesc_clobber.c: New test.
* gcc.target/riscv/tlsdesc_clobber_v.c: New test.
* gcc.target/riscv/tlsdesc_clobber_v_csr.c: New test.
H.J. Lu [Mon, 13 Jul 2026 01:12:13 +0000 (09:12 +0800)]
x86-64: Add missing SSE and AVX zero-extend patterns
1. Add round_zext and round_saeonly_zext to subst.md.
2. Use them to add missing SSE and AVX zero-extend patterns.
3. Add tests to check for newly added SSE and AVX zero-extend patterns.
The x+x -> x*2 simplication obviously requires that 2 is representable
in type, so that rules out unsigned _BitInt(1) and signed _BitInt(2)
(and 1 too in C2Y, ditto unsigned:1 and signed:2 and :1), otherwise
we don't multiply by 2 but by 0 or -2.
While perhaps we could transform in those cases x+x to x<<1, I'm not
convinced it is worth it.
2026-07-15 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/126257
* match.pd (x+x -> x*2): Only optimize if 2 is representable in the
type.
Jakub Jelinek [Wed, 15 Jul 2026 07:21:41 +0000 (09:21 +0200)]
c++: In attributes expect _Clang namespace rather than __clang__ [PR120635]
Apparently in clang __clang__ is a predefined macro (predefined to 1).
Because of that, clang doesn't have alternate spelling of its scoped
attributes as
[[__clang__::__something__]]
but
[[_Clang::__something__]]
The former isn't accepted even with -U__clang__.
For GNU attributes they do handle
[[__gnu__::__something__]]
like GCC does (if they support a particular attribute).
So, I'm afraid if we want to stay compatible with this mess, we need
to do the same thing.
The following patch does that.
It emits a warning when one attempts to use the __clang__ attribute
namespace suggesting to use _Clang instead (clang++ does that too),
but in __has_cpp_attribute/__has_attribute doesn't do that, just ensures
that 0 is returned in that case (i.e. it is not canonicalized in that
case), just canonicalizes _Clang to clang.
2026-07-15 Jakub Jelinek <jakub@redhat.com>
PR c++/120635
gcc/
* doc/extend.texi: Document variant spelling of
standard attributes and that alternate namespace
spelling for clang namespace is _Clang rather
than __clang__. For no_specializations use
_Clang:: rather than __clang__::.
gcc/c-family/
* c-lex.cc (c_common_has_attribute): For __clang__
namespace don't call canonicalize_attr_name and for
_Clang use clang instead.
gcc/cp/
* parser.cc (cp_parser_std_attribute): Add
canonicalize_attr_ns_name lambda and use it instead of
canonicalize_attr_name for namespaces. Emit a warning
on __clang__::.
(cp_parser_std_attribute_spec): Emit a warning on
using __clang__:.
gcc/testsuite/
* g++.dg/cpp0x/attr-trivial_abi8.C: Add further tests.
* g++.dg/cpp0x/attr-trivial_abi11.C: New test.
* g++.dg/ext/attr-no_specializations1.C: Use _Clang:: instead of
__clang__.
* g++.dg/ext/attr-no_specializations2.C: Likewise.
* g++.dg/ext/attr-no_specializations6.C: Likewise.
* g++.dg/ext/attr-no_specializations7.C: Likewise.
* g++.dg/ext/attr-no_specializations8.C: Likewise.
* g++.dg/ext/attr-no_specializations10.C: Add further tests.
* g++.dg/ext/attr-no_specializations12.C: New test.
When 'device_type(host)' is specified on a target region, no offload code
is generated for the outlined region. Additionally, it is honored for
implicit 'declare target'.
The code is executed as if 'device(omp_initial_device)' were present
(i.e. also no issus with OMP_TARGET_OFFLOAD=mandatory).
gcc/ChangeLog:
* omp-expand.cc (expand_omp_target): For 'device_type(host)',
invoke with device(omp_initial_device)'.
* omp-low.cc (create_omp_child_function): Take host_only
argument to prevent generating offload code.
(scan_omp_parallel, scan_omp_task, scan_omp_target, scan_omp_teams,
lower_omp_target): Update call.
* omp-offload.cc (omp_discover_declare_target_tgt_fn_r,
omp_discover_declare_target_fn_r): Do not add implicit 'declare
target' to target regions with 'device_type(host)'.
libgomp/ChangeLog:
* libgomp.texi (Implementations status): Mark 'device_type'
clause on target as implemented.
* testsuite/libgomp.c/target-device-type-3.c: New test.
middle-end: use tree mode for masked cbranch operand [PR126221]
emit_cmp_and_jump_insns used GET_MODE (expand_normal (masked_op)) to select the
mask mode. For vector boolean constants that expand to CONST_INT, this produces
VOIDmode and triggers the assert mode != VOID_mode in maybe_legitimize_operand.
Use TYPE_MODE (TREE_TYPE (masked_op)), so the constant can be materialized in
the right mask mode.
gcc/ChangeLog:
PR middle-end/126203
PR middle-end/126221
PR middle-end/126232
* optabs.cc (emit_cmp_and_jump_insns): Take the masked_op mode
from TREE_TYPE (masked_op).
The parsing support was already there, this just adds code to handle
'nohost' in the middle end.
That's handled by adding if-else code to the target's structure block
using the omp_is_initial_device builtin in the condition that is
replaced by a constant (late) during compilation. Thus, with optimization
turned on, only the error message or the target body remains for the host
and the nonhost region, respectively.
Note that 'device_type(host)' is not yet implemented.
Note also there is no change to implicit handling, i.e. functions called
in the region will implicitly 'declare target' with 'device_type(any)',
i.e. there is no attempt made to add those with 'nohost', which is also
the most sensible.
gcc/ChangeLog:
* gimplify.cc (gimplify_omp_workshare): Handle 'device_type(nohost)'
on 'target'.
* omp-low.cc (lower_omp_target): Remove sorry for this case.
libgomp/ChangeLog:
* error.c (GOMP_error): When passing msglen == (size_t) -2,
do not show 'error directive encountered:' in the message.
* libgomp.texi (Implementation Status): Mark target + device_type
as partially implemented.
* testsuite/libgomp.c/target-device-type-1.c: New test.
* testsuite/libgomp.c/target-device-type-2.c: New test.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/target-device-type-1.c: Update dg-sorry
as now only device_type(host) remains unimplemented.
* gfortran.dg/gomp/target-device-type-1.f90: Likewise.
In some of the older testcases, the main function is declared like
main (int, void **). It is frequently useful (especially with the
Darwin port) to compare the output of clang with that of GCC (since
clang is the de-facto standard for Objective-C). Clang complains
about the void** so let's set that to be char ** as usual.
Karl Meakin [Wed, 1 Jul 2026 12:16:40 +0000 (12:16 +0000)]
aarch64: Relax type-checking assert [PR126064]
Comparing `arg_type` and `TREE_TYPE (b)` by pointer address causes an
assertion failure when one type is a `typedef` for the other (eg
`uint32x2_t` and `__Uint32x2_t`. Fix by using a more relaxed comparison.
gcc/ChangeLog:
PR target/126064
* config/aarch64/aarch64-neon-builtins-base.cc: Compare
`arg_type` and `TREE_TYPE (b)` using `types_compatible_p` rather
than comparing their pointer addresses.
gcc/testsuite/ChangeLog:
PR target/126064
* gcc.target/aarch64/pr126064.c: New test.
Add arm_v8_1m_mve_link to check that the options selected by
arm_v8_1m_mve_ok can link successfully.
Without a link test, the board specific ldflags might contain flags that
are incompatible with the linkage of the test case, for example the
built testglue.c from dejagnu is known to cause issues.
Cem Akgok [Mon, 13 Jul 2026 14:21:46 +0000 (17:21 +0300)]
vect: Fix wrong code with SLP IV reuse [PR126225]
vectorizable_induction reduces the number of generated SLP induction
IVs when group_size is evenly divisible by const_nunits. Existing
code did this without checking that the vector chunks being folded have
the same scalar initial values and steps with their counterparts.
If either differed, reusing an earlier IV produced wrong code.
Compute the unreduced IV count first and use the reduced count only when
each folded chunk has initial values and steps equal to its corresponding
earlier chunk.
Added tests for mismatched initial values, mismatched steps, and a valid
multi-IV reuse pattern.
gcc/ChangeLog:
PR tree-optimization/126225
* tree-vect-loop.cc (vect_slp_induction_reuse_p): New function.
(vectorizable_induction): Validate SLP induction IV reuse. Reuse
generated IVs cyclically when filling the SLP group.
gcc/testsuite/ChangeLog:
PR tree-optimization/126225
* gcc.dg/vect/vect-iv-12.c: New test.
* gcc.dg/vect/vect-iv-13.c: New test.
* gcc.dg/vect/vect-iv-14.c: New test.
Compute kth weight using __fw(_M_int[k]) as required by standard,
instead of __fw(_M_int[k] + __delta), i.e. __fw(_M_int[k + 1]).
For __nw == 1, this was already corrected by r17-509-g7bed7d9276c11b.
In both cases, previous behavior can be restored by defining
_GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS.
Tomasz Kamiński [Tue, 26 May 2026 13:43:00 +0000 (15:43 +0200)]
libstdc++: Change piecewise distribution densities to return vector<result_type> [PR82749]
This implements the interface changes from
LWG1439, "Return from densities() functions?".
Due the ABI concerns, we cannot change the the element_type of member
(_M_den, _M_cp, and _M_m) vectors, and we convert the _M_den values
to result_type when function is invoked. However, as the usage of
distributions with types other than float, double, and long double
is either undefined (pre C++26) or implementaiton-defined (post C++26),
this limitation de-fact applies to float, and long double (if it's
different size than double).
To handle above we introduce the __piecewise_distributions_storage<_Tp>
struct, whose type nested typedef points to double in above two cases,
and _Tp otherwise. The _StorageType is defined in terms of
__piecewise_distributions_storage_t alias to above, and is then used
in defintion of _M_den, _M_cp, and _M_m members. In consequence for
extended floating point types (__float128, std::float16, ...) for which
ABI can be changed, we store densitiees (and other values) as result_type.
To avoid symbol conflicts, the param_type::densities member functions
are marked with "__rt" ABI tag. The corresponding members of the
distributions are modified to invoke param_type method, and marked
as always_inline. For consistency intervals methods are adjusted same
way.
To preserve current behavior, the operators>> load densities
as values of _StorageType.
Finally, we introduce _GLIBCXX_USE_OLD_PICEWISE_DISTRIBUTIONS, that
revers above changes, restoring old behavior for all floating point
types. Additionally for the users accept above ABI change,
we introduce a macro _GLIBCXX_USE_RESULT_TYPE_FOR_PIECEWISE_DENSITIES,
that result in __piecewise_distributions_storage_t being unconditionally
defined as _Tp, and thus adjust internal storage also for float and long
double.
PR libstdc++/82749
libstdc++-v3/ChangeLog:
* doc/xml/manual/using.xml
(_GLIBCXX_USE_OLD_PICEWISE_DISTRIBUTIONS): Add entry.
(_GLIBCXX_USE_RESULT_TYPE_FOR_PIECEWISE_DENSITIES): Add entry.
* doc/html/manual/using_macros.html: Regenerate.
* include/bits/random.h
(__detail::__piecewise_distributions_storage)
(__detail::__piecewise_distributions_storage_t)
(piecewise_constant_distribution::_StorageType)
(piecewise_linear_distribution::_StorageType): Define.
(piecewise_constant_distribution::param_type::_M_den)
(piecewise_constant_distribution::param_type::_M_cp)
(piecewise_linear_distribution::param_type::_M_den)
(piecewise_linear_distribution::param_type::_M_cp)
(piecewise_linear_distribution::param_type::_M_m): Use _StorageType
as element type.
(piecewise_constant_distribution::param_type::densities)
(piecewise_linear_distribution::param_type::densities)
[!_GLIBCXX_USE_OLD_PICEWISE_DISTRIBUTIONS]: Change return type
to vector<result_type>, mark with "__rt" ABI tag, and adjust
implementation.
(piecewise_constant_distribution::param_type::intervals)
(piecewise_linear_distribution::param_type::intervals): Use
result_type alias in return type.
(piecewise_constant_distribution::densities)
(piecewise_linear_distribution::densities): Delegate to param_type
method, additional change return type and mark as always_inline
if _GLIBCXX_USE_OLD_PICEWISE_DISTRIBUTIONS is not defined.
(piecewise_constant_distribution::intervals)
(piecewise_linear_distribution::intervals): Delegate to param_type
method and use result_type alias in return type.
* include/bits/random.tcc
(operator<<(basic_ostream&, const piecewise_constant_distribution&))
(operator<<(basic_ostream&, const piecewise_linear_distribution&)):
Parse vector of _StorageType for densities, to preserve behavior.
* testsuite/26_numerics/random/piecewise_constant_distribution/operators/accessors.cc:
New test.
* testsuite/26_numerics/random/piecewise_linear_distribution/operators/accessors.cc:
New test.
* testsuite/26_numerics/random/piecewise_constant_distribution/operators/accessors_exact.cc:
Run accessors.cc with _GLIBCXX_USE_RESULT_TYPE_FOR_PIECEWISE_DENSITIES.
* testsuite/26_numerics/random/piecewise_linear_distribution/operators/accessors_exact.cc:
Likewise.
* testsuite/26_numerics/random/piecewise_constant_distribution/operators/accessors_fallback.cc:
Run accessors.cc with _GLIBCXX_USE_OLD_PICEWISE_DISTRIBUTIONS.
* testsuite/26_numerics/random/piecewise_linear_distribution/operators/accessors_fallback.cc:
Likewise.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Jakub Jelinek [Tue, 14 Jul 2026 08:41:08 +0000 (10:41 +0200)]
c-family: Use CAS loop instead of RMW atomics on small _BitInt with padding on targets which need to extend [PR124948]
Some atomic/sync builtins don't sign or zero extend _BitInt values
with padding in it.
IMNSHO this is solely about some of the type-generic atomic/sync builtins
(those documented to take TYPE * arguments) and needs to be handled in the
FE, likely in gcc/c-family/c-common.cc (resolve_overloaded_builtin).
There already is code to transform various type-generic builtins into a CAS
loop for say unsigned _BitInt(253), so I think it should be used also for
the case where the type is BITINT_TYPE with any padding bits in the
extend other than bitint_ext_undef mode.
2026-07-14 Jakub Jelinek <jakub@redhat.com>
PR target/124948
* c-common.cc (sync_resolve_size): Return -1 for fetch ops
on _BitInt types with padding bits where the target requires
extension into the padding bits.
(atomic_bitint_fetch_using_cas_loop): Handle also __sync_*
fetch builtins.
tree-optimization: Fold length-one memset through arbitrary pointers [PR102202]
gimple_fold_builtin_memset currently folds constant-length memset calls
into scalar stores only when the destination is an ADDR_EXPR. Calls
through an arbitrary pointer, such as a function parameter are left as
library calls and non-constant fill values are rejected even for the
length-one case where byte replication is unnecessary.
Add a dedicated folding path for length-one memset calls through
arbitrary pointer destinations. Since the access is exactly one byte,
use unsigned_char_type_node for the store. This supports both constant
and non-constant fill values: constant fills are converted with
fold_convert while non-constant fills use gimple_convert. Volatile
qualification is preserved from the pointed-to type and the store is
emitted as a MEM_REF at offset zero using the usual ref-all character
pointer type.
Defer this new arbitrary-pointer fold until after object-size analysis
has run so that the original memset remains available to object-size
based diagnostics. The existing ADDR_EXPR-based folding path for other
constant lengths is unchanged.
gcc/ChangeLog:
PR tree-optimization/102202
* gimple-fold.cc (gimple_fold_builtin_memset): Hoist
tree_to_uhwi (len) before the INTEGER_CST guard. Fold
length-one memset calls through arbitrary pointer destinations.
Build a ref-all MEM_REF at offset zero and preserve the call
result when it is used.
gcc/testsuite/ChangeLog:
PR tree-optimization/102202
* gcc.dg/pr102202-fold.c: New test.
Jakub Jelinek [Tue, 14 Jul 2026 08:39:55 +0000 (10:39 +0200)]
bitintlower: Handle .ASAN_POISON and .ASAN_POISON_USE with large/huge _BitInt [PR126084]
If we have
.ASAN_MARK (UNPOISON, &a, 24);
.ASAN_MARK (UNPOISON, &b, 24);
p_7 = &a;
q_8 = &b;
.ASAN_MARK (POISON, &a, 24);
.ASAN_MARK (POISON, &b, 24);
_1 = *p_7;
_2 = *q_8;
_3 = _1 + _2;
<retval> = _3;
return <retval>;
or
.ASAN_MARK (UNPOISON, &a, 24);
.ASAN_MARK (UNPOISON, &b, 24);
p_4 = &a;
q_5 = &b;
.ASAN_MARK (POISON, &a, 24);
.ASAN_MARK (POISON, &b, 24);
*p_4 = 1;
*q_5 = 2;
return;
which represent load or store uses after scope and decide not to make the
vars addressable anymore, we turn that into
a_10 = .ASAN_POISON ();
b_11 = .ASAN_POISON ();
_1 = a_10 + b_11;
<retval> = _1;
return <retval>;
or
a_8 = .ASAN_POISON ();
b_9 = .ASAN_POISON ();
.ASAN_POISON_USE (a_8);
.ASAN_POISON_USE (b_9);
return;
These 2 internal fns are something that is normally lowere during
sanopt. Now, if the involved vars are large/huge _BitInt, the bitintlower
pass doesn't handle them and we end up with invalid IL (we try to change
the lhs of .ASAN_POISON from SSA_NAME to a var etc. which violates what
sanopt expects and get an extra .ASAN_POISON_USE while doing that etc.
I thought what would be the best way to deal with these, e.g. try to replace
them with something tracking just one limb in those (although it is nicer to
report the proper sizes in asan rather than just small part of it), but
the .ASAN_POISON () uses can be also PHI args and some PHI args could be
.ASAN_POISON () uses while others could be unrelated SSA_NAMEs, so we'd
need to change those uses to be extensions from the .ASAN_POISONed limb
into full size on all edges and what to do with abnormal edges etc.
So, in the end I've decided instead to just perform what sanopt pass does
for these 2 ifns if large/huge _BitInt is involved at the start of the
bitintlower pass (similarly how we lower switches there).
The asan.cc changes are needed so that we can properly report 24 bytes
or 568 bytes etc. READs or WRITEs after scope.
2026-07-14 Jakub Jelinek <jakub@redhat.com>
PR middle-end/126084
* gimple-lower-bitint.cc: Include "attribs.h" and "asan.h".
(gimple_lower_bitint): Use asan_expand_poison_ifn to lower
.ASAN_POISON calls with large/huge _BitInt lhs.
* asan.cc (report_error_func): Set *nargs and use _n builtin
even if size is not a power of two or larger than 16.
(asan_expand_poison_ifn): Handle nargs == 2.
* gcc.dg/asan/bitint-1.c: New test.
* gcc.dg/asan/bitint-2.c: New test.
Jakub Jelinek [Tue, 14 Jul 2026 08:37:03 +0000 (10:37 +0200)]
cfgexpand: Align the whole asan var block to crtl->stack_alignment_needed [PR120201]
If crtl->stack_alignment_needed / BITS_PER_UNIT is larger than
data.asan_alignb, we can end up with misaligned stack for further
allocations (e.g. to spill SSA_NAMEs with vector modes and large
alignment).
This patch increments data.asan_alignb in that case.
2026-07-14 Jakub Jelinek <jakub@redhat.com>
H.J. Lu <hjl.tools@gmail.com>
PR tree-optimization/120201
* cfgexpand.cc (expand_used_vars): Set data.asan_alignb to
maximum of itself and crtl->stack_alignment_needed
/ BITS_PER_UNIT.
out-of-SSA: use the spill predicate for partition decls [PR123625, PR121957]
Changes in v2:
- Match the exact expansion spill predicate instead of using BLKmode.
- Add a non-BLKmode -ffloat-store regression.
Out-of-SSA can leave several partitions sharing one base VAR_DECL when its
SSA versions have overlapping live ranges. If those partitions are spilled,
set_mem_attributes gives every stack slot the same MEM_EXPR at offset zero.
MEM_EXPR-based disambiguation can then combine accesses from distinct slots.
Split the overlapping partitions after TER, using the same
use_register_for_decl predicate as expansion rather than approximating the
memory decision with BLKmode. Keep the default-definition partition tied to
the original decl and give the other partitions artificial decls with debug
expressions referring back to it.
Bootstrapped and tested on aarch64-none-linux-gnu and x86_64-linux.
gcc/ChangeLog:
PR target/123625
PR target/121957
* tree-outof-ssa.cc (split_overlapping_partition_decls): New function.
Use use_register_for_decl to identify memory partitions.
(remove_ssa_form): Call split_overlapping_partition_decls.
gcc/testsuite/ChangeLog:
PR target/123625
PR target/121957
* gcc.c-torture/execute/pr121957.c: New test.
* gcc.c-torture/execute/pr123625.c: New test.
* gcc.c-torture/execute/pr123625-2.c: New test.
* gcc.c-torture/execute/pr123625-3.c: New test.
* gcc.dg/pr123625-1.c: New test.
Richard Biener [Mon, 13 Jul 2026 08:03:55 +0000 (10:03 +0200)]
tree-optimization/126194 - bogus PTA with C++ delete
We currently ignore all delete calls from delete expressions for
the purpose of generating PTA constraints. That's in error from r11-3612-g4f4ced28826ece which did a tree-wide change to clarify
and improve eliding of new/delete pairs. The following restores
the original restriction of only ignoring calls to the standard
library copy of delete. This also adds a check on
-fassume-sane-operators-new-delete (which is the default).
PR tree-optimization/126194
* gimple-ssa-pta-constraints.cc (find_func_aliases_for_call):
Only ignore calls to delete if DECL_IS_REPLACEABLE_OPERATOR.
Jakub Jelinek [Tue, 14 Jul 2026 06:00:30 +0000 (08:00 +0200)]
c++: Default deallocating functions to noexcept for C++11
https://eel.is/c++draft/except.spec#9 says
A deallocation function with no explicit noexcept-specifier has a non-throwing
exception specification.
and something like that is there back to C++11.
We only imply noexcept for destructors though (in
deduce_noexcept_on_destructor).
The following patch does that for operator delete/operator delete[]
both for :: namespace ones and for class member functions.
On Mon, Jul 13, 2026 at 04:34:12PM -0400, Jason Merrill wrote:
> Does this affect mangling?
I've tried to compile
struct A {};
void operator delete (void *, A) {}
struct B {};
void operator delete (void *, B) {}
struct C {
static void operator delete (void *);
};
void C::operator delete (void *) {}
struct D {};
void operator delete (void *, D) noexcept (true) {}
template <bool B>
struct E {
template <typename T>
static void operator delete (void *, T) noexcept (B) {}
};
auto f1 () { return &E <true>::operator delete<int>; }
auto f2 () { return &E <false>::operator delete<int>; }
with g++ 15, vanilla trunk and patched trunk and everything is identical
except .ident, mangled names
If I add
template <typename T>
void bar () {}
void baz () { bar <decltype (C::operator delete)> (); }
to that testcase, then there is a difference, _Z3barIFvPvEEvv
vs. _Z3barIDoFvPvEEvv. Isn't that desirable though?
Note, clang++ mangles it the same as the patched g++, it is unlikely
anybody does this in real-world code and they do actually want to
test in that case whether it is explicitly or implicitly noexcept or not.
Like when one uses reflection and tests is_noexcept, or uses noexcept
on the destroying delete.
2026-07-14 Jakub Jelinek <jakub@redhat.com>
* decl.cc (grokfndecl): If raises is NULL_TREE for C++11
deallocation function, use noexcept_true_spec instead.
* g++.dg/cpp0x/dealloc1.C: New test.
* g++.dg/cpp0x/dealloc2.C: New test.
* g++.dg/cpp2a/destroying-delete7.C: New test.
* g++.dg/reflect/is_noexcept5.C: New test.
* g++.dg/cpp1z/aligned-new3.C (operator delete): Don't expect
a warning.
Pan Li [Sat, 11 Jul 2026 14:35:14 +0000 (22:35 +0800)]
RISC-V: Add test cases for vzext.vf8 reg overlap
Add test cases for vzext.vf8 register group overlap, please
note it is not overlap as much as possible.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf8-u8-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf8-u8-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf8-u8-mf4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf8-u8-mf8.c: New test.
Pan Li [Sat, 11 Jul 2026 14:34:29 +0000 (22:34 +0800)]
RISC-V: Add test cases for vsext.vf8 reg overlap
Add test cases for vsext.vf8 register group overlap, please
note it is not overlap as much as possible.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf8-i8-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf8-i8-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf8-i8-mf4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf8-i8-mf8.c: New test.
Jerry DeLisle [Mon, 13 Jul 2026 18:26:13 +0000 (11:26 -0700)]
fortran: [PR126234] Fix regression in SPEC benchmarks.
The fix for pr126170 broke one of the SPEC tests. The orginal fix
used gfc_find_symbol which had a side effect of causing the error.
The gfc_find_symbol calls gfc_find_sym_tree which then calls
ambiguous_symbol where the error is issued.
PR fortran/126234
gcc/fortran/ChangeLog:
* module.cc (read_module): Walk the symtree instead of
using gfc_find_symbol.
c++: Avoid duplicate trivial_abi cleanup in cdtor clones [PR125066]
Constructor and destructor clones already have a genericized copy of the
original body, including parameter cleanups. Do not add another front-end
CLEANUP_STMT while processing a clone.
gcc/cp/ChangeLog:
PR c++/125066
* decl.cc (store_parm_decls): Do not register trivial_abi parameter
cleanups for cloned functions.
gcc/testsuite/ChangeLog:
PR c++/125066
* g++.dg/cpp0x/attr-trivial_abi10.C: New test.
c++: Keep type variants consistent for trivial_abi [PR125064]
Removing trivial_abi from only the main type can leave qualified variants
with different attributes despite sharing a canonical type. Remove the
rejected attribute from all variants.
gcc/cp/ChangeLog:
PR c++/125064
* tree.cc (validate_trivial_abi_attribute): Remove a rejected
trivial_abi attribute from all variants.
gcc/testsuite/ChangeLog:
PR c++/125064
* g++.dg/cpp0x/attr-trivial_abi9.C: New test.
Sunil Dora [Mon, 13 Jul 2026 21:19:48 +0000 (15:19 -0600)]
testsuite: Fix unstable duplicate test names in pr111527.exp [PR111527]
pr111527.exp does not call runtest_file_p, so with parallel make
check more than one runtest instance can run it and the number of
duplicate test names varies from run to run. Take the
gcc_parallel_test_run_p lock like linkage.exp does so the tests
run only once.
gcc/testsuite/ChangeLog:
PR driver/111527
* gcc.misc-tests/pr111527.exp: Serialize with
gcc_parallel_test_run_p to avoid duplicate test names.
Signed-off-by: Sunil Dora <sunilkumar.dora@windriver.com>
i386: Add -mtune=generic to highpart multiplication tests
The check-function-bodies patterns in bmi2-mulx-highpart-1.c and
mulq-highpart.c expect the instruction order produced with generic
tuning. With -march=cascadelake the scheduler swaps the movl and
movabsq instructions, so pin -mtune=generic.
gcc/testsuite/ChangeLog:
* gcc.target/i386/bmi2-mulx-highpart-1.c: Add -mtune=generic
to dg-options.
* gcc.target/i386/mulq-highpart.c: Likewise.
Make -Wuse-after-free alias for -Wuse-after-free=1 [PR124058]
GCC currently treats -Wuse-after-free and -Wuse-after-free= as separate
options internally, with OPT_Wuse_after_free for no argument and
OPT_Wuse_after_free_ with argument. Make -Wuse-after-free an alias for
-Wuse-after-free=1 so both forms go through the same option code.
Switch the warning and suppression sites to OPT_Wuse_after_free_ so
pragmas, diagnostic classification, and suppression all refer to the same
option.
Document that -Wuse-after-free is equivalent to -Wuse-after-free=1.
On Arm AAPCS targets, constructors and destructors return this. In
maybe_prepare_return_this, suppressing OPT_Wuse_after_free for this records
the suppression under NW_OTHER, since OPT_Wuse_after_free is not explicitly
mapped to a diagnostic group. That can suppress unrelated NW_OTHER
warnings, such as -Wdeprecated-declarations. OPT_Wuse_after_free_ is
mapped to NW_DANGLING, so using it keeps the suppression scoped to the
use-after-free warning.
PR driver/124058
gcc/ChangeLog:
* common.opt (Wuse-after-free): Make an alias for
-Wuse-after-free=1.
* doc/invoke.texi: Document alias.
* gimple-ssa-warn-access.cc (pass_waccess::warn_invalid_pointer):
Use OPT_Wuse_after_free_.
gcc/cp/ChangeLog:
* decl.cc (maybe_prepare_return_this): Use OPT_Wuse_after_free_.
[PR120165, LRA]: Prevent equivalence substitution resulting in wrong reloads
The PR is about wrong generation of insn involving memory-memory move
with sp predecrement, another address post-increment, and input and
output memory reloads with the address reg eliminated to sp. As
elimination offset is updated in LRA once per insn, the output reload
insn uses the wrong offset. As implementation of the separate offset
updates requires a lot of changes in LRA code and using equivalence (a
memory) actually is not profitable, we just prevent equivalence
substitution in such cases. There is no test case for the patch as
m68k port is in transition to LRA and it requires -mlra option which
will be probably removed.
gcc/ChangeLog:
PR target/120165
* lra-constraints.cc (virtual_reg_p, contains_virtual_reg_p): New.
(reg_has_incdec_p): Ditto.
(lra_constraints): Use reg_has_incdec_p and contains_virtual_reg_p
to switch off the equiv.
gcc/
* print-rtl.cc (rtx_writer::print_rtx_operand_code_i): Don't
fallback to UNSPEC enums if there are any UNSPECV enums.
(print_exp): Print unspec/unspecv name, when available.
Jakub Jelinek [Mon, 13 Jul 2026 16:33:37 +0000 (18:33 +0200)]
c++: Implement clang::no_specializations attribute and -Winvalid-specialization warning [PR120635]
The following patch implements the clang::no_specializations attribute
(in all of
[[clang::no_specializations]]
[[clang::no_specializations ("reason")]]
__attribute__((no_specializations))
__attribute__((no_specializations ("reason")))
forms), which can appertain to class, variable and function templates
(though, not to their specializations), and if the attribute is
present on the template, there is an error (that is what clang++
implements, not warning) if one attempts to partially or fully
specialize it. The error can be disabled either with
-Wno-invalid-specialization on the command line
or #pragma GCC diagnostic ignored "-Winvalid-specialization" around
the specialization or turned into warning instead of error with
-Wno-error=invalid-specialization.
This is intended mainly for libstdc++, so that it can diagnose
various nits in the standard like
https://cplusplus.github.io/LWG/issue3990
etc.
2026-07-13 Jakub Jelinek <jakub@redhat.com>
PR c++/120635
gcc/
* doc/extend.texi (no_specializations): Document new
attribute.
* doc/invoke.texi (-Wno-invalid-specialization): Document new
warning.
gcc/c-family/
* c.opt (Winvalid-specialization): New option.
* c.opt.urls: Regenerate.
* c-lex.cc (c_common_has_attribute): Don't advertise
gnu::no_specializations attribute availability.
gcc/cp/
* tree.cc (cxx_gnu_attributes): Add "no_specializations" entry.
(cxx_clang_attributes): Likewise.
(handle_no_specializations_attribute,
handle_gnu_no_specializations_attribute): New functions.
* decl2.cc (is_late_template_attribute): Return false for
"no_specializations" attribute, even on dependent types. Don't
differentiate between the completely unknown and dependent
cases, for the 5 template attributes return always false, for
others true if dependent type and false otherwise.
* parser.cc (cp_parser_std_attribute): Use
uneval_string_attr even for clang::no_specializations attribute.
* pt.cc: Include "escaped_string.h".
(maybe_diagnose_no_specializations): New function.
(maybe_process_partial_specialization): Use it.
(check_explicit_specialization): Likewise.
gcc/testsuite/
* g++.dg/ext/attr-no_specializations1.C: New test.
* g++.dg/ext/attr-no_specializations2.C: New test.
* g++.dg/ext/attr-no_specializations3.C: New test.
* g++.dg/ext/attr-no_specializations4.C: New test.
* g++.dg/ext/attr-no_specializations5.C: New test.
* g++.dg/ext/attr-no_specializations6.C: New test.
* g++.dg/ext/attr-no_specializations7.C: New test.
* g++.dg/ext/attr-no_specializations8.C: New test.
* g++.dg/ext/attr-no_specializations9.C: New test.
* g++.dg/ext/attr-no_specializations10.C: New test.
* g++.dg/ext/attr-no_specializations11.C: New test.
Marek Polacek [Tue, 7 Jul 2026 20:52:39 +0000 (16:52 -0400)]
c++: ICE with requires and -Wsequence-point [PR126066]
We trip on the assert in lvalue_kind/MODOP_EXPR whose comment says
that we expect to see MODOP_EXPRs only during template processing.
In this test we get there with processing_template_decl==0. The
MODOP_EXPR is created in:
but we're not in a template when calling maybe_convert_cond which
calls verify_sequence_points which ends up calling lvalue_p on
the MODOP_EXPR.
verify_sequence_points is walking the unevaluated operand of a requires
because verify_tree assumes that all unknown expressions are evaluated, and
REQUIRES_EXPR looks like a normal expression (tcc_expression).
This patch changes REQUIRES_EXPR to tcc_exceptional. That means that
the generic code (such as verify_tree) sees that it's magic and doesn't
try to walk into it.
PR c++/126066
gcc/c-family/ChangeLog:
* c-common.cc (verify_tree): Add a comment.
gcc/cp/ChangeLog:
* constraint.cc (tsubst_requires_expr): Use
REQUIRES_EXPR_LOCATION.
(satisfaction_cache::get): Use cp_expr_location.
(satisfaction_cache::save): Likewise.
(finish_requires_expr): Use make_node and set REQUIRES_EXPR_*.
* cp-objcp-common.cc (cp_tree_size): Handle REQUIRES_EXPR.
(cp_common_init_ts): Change REQUIRES_EXPR from MARK_TS_EXP to
MARK_TS_TYPED.
* cp-tree.def (REQUIRES_EXPR): Make it tcc_exceptional with no
operands.
* cp-tree.h (struct tree_requires_expr): New.
(REQUIRES_EXPR_PARMS): Adjust.
(REQUIRES_EXPR_REQS): Likewise.
(REQUIRES_EXPR_EXTRA_ARGS): Likewise.
(REQUIRES_EXPR_LOCATION): New.
(enum cp_tree_node_structure_enum): Add TS_CP_REQUIRES_EXPR.
(union lang_tree_node): Add tree_requires_expr.
(cp_expr_location): Handle REQUIRES_EXPR.
* cxx-pretty-print.cc (pp_cxx_requires_expr): Use
REQUIRES_EXPR_REQS.
* decl.cc (cp_tree_node_structure): Handle REQUIRES_EXPR.
* error.cc (print_requires_expression_info): Use
REQUIRES_EXPR_PARMS.
* mangle.cc (write_tparms_constraints): Use cp_expr_location.
* module.cc (trees_out::core_vals): Handle REQUIRES_EXPR
specially.
(trees_in::core_vals): Likewise.
* pt.cc (iterative_hash_template_arg): Handle REQUIRES_EXPR.
* tree.cc (strip_typedefs_expr): Likewise.
(cp_tree_equal): Likewise.
This patch teaches match.pd to recognize the branchless conditional negate
idiom (x ^ -cmp) + cmp when cmp is known to be zero or one. The
expression is folded to a conditional negate form.
For the sign-test spelling based on x < 0, the patch exposes ABS_EXPR.
PR tree-optimization/113894
gcc/ChangeLog:
* match.pd: Add simplifications for branchless conditional negate
and sign-test absolute value idioms.
GCC could return __int128 values in SSE (%xmm0) on Windows x64 instead
of following the MS x64 ABI. Root cause: return classification allowed
128-bit integer-like scalars to be treated as direct register returns.
This patch updates the Windows x64 return-classification and codegen to
treat int128 as an indirect return (caller-provided slot passed as first
argument, pointer returned in RAX).
gcc:
PR target/78799
* config/i386/i386.cc (function_value_ms_64): Do not treat
integral 16-byte values as SSE returns.
(ix86_return_in_memory): Likewise avoid treating integral 16-byte
values as XMM returns.
gcc/testsuite:
* gcc.target/i386/pr78799.c: New test.
Signed-off-by: Oleg Tolmatcev <oleg.tolmatcev@gmail.com> Signed-off-by: Jonathan Yong <10walls@gmail.com>
c++: Fix conversion to enum with fixed bool underlying type [PR96496]
For an enumeration with a fixed underlying type, [expr.static.cast]/8
requires the operand to be converted to the underlying type first, and
then to the enumeration type.
Previously, ocp_convert would convert the operand directly to the
enumeration type via convert_to_integer_maybe_fold. For non-bool
underlying types this gives the required value, but for an underlying
type of bool it truncates the operand to the enum's 1-bit precision,
keeping only the low bit and contradicting [conv.bool]: e.g.
converting 2 yielded the enum value corresponding to false.
This patch fixes it by following the specification and converting
operands with a fixed underlying type to that type first, then to the
enumeration type. For bool this routes the operand through the
existing boolean-handling code with its truth value conversion, so it
now goes through -Wint-in-bool-context diagnostics just like a cast to
bool. The conversion now no longer emits -Wconversion if the operand
is out of range since the value is converted first through well-defined
conversions, consistent with explicit casts to the underlying type
itself. This patch also includes tests for the changed warning
behavior.
PR c++/96496
gcc/cp/ChangeLog:
* cvt.cc (ocp_convert): For an enumeration type with a fixed
underlying type, convert the operand to that type first, as
specified by [expr.static.cast]/8. Update the comment quoting
[expr.static.cast]/8.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/enum-bool-conv.C: New test.
* g++.dg/warn/Wconversion-enum-fixed.C: New test.
* g++.dg/warn/Wint-in-bool-context-bool-enum.C: New test.
Introduce the new opaque mode `TDOmode` for the `__dmr1024` type, which
may be supported on a future Power processor, and treat it similarly
to the existing MMA opaque types when diagnosing invalid function
parameter and return values. Update the diagnostics to distinguish
between Dense Math and MMA types in error messages.
Tomasz Kamiński [Tue, 7 Jul 2026 08:27:33 +0000 (10:27 +0200)]
libstdc++: Assert that produced layout_stride::mapping is unique.
This add an assertions checking if the combination of strides
and extents passed to layout_stride::mapping is unique.
To avoid excessive performance impact, in non-debug mode only
checks that are are O(rank) (i.e. similar cost as operator())
are performed. To achieve that, for the ranks greater or equal,
we perform two separate checks:
* required_span_size() > mdspan::__size(_M_extents) - this is
a necessary but not sufficient condition, that is O(rank) and
is always performed.
* building a permutation using insertion-sort based algorithm,
this is O(rank^2) and is performed only in debug modes.
The check for non-zero stride values (performed for all non-zero
ranks) is done only if the size of the multidimensional index space
is not empty. This follows the resolution of LWG4603, and provides
consistent behavior for constructing layout_stride mapping from
layout_left/right directly or from strides extracted from it.
libstdc++-v3/ChangeLog:
* include/std/mdspan (layout_stride::mapping::_M_check_unique):
Define.
(layout_stride::mapping(const extents_type&, span<....>)):
Add __glibcxx_assert on _M_check_unique.
* testsuite/23_containers/mdspan/layouts/stride_neg.cc:
Test for the new added assertions.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
The folding checked by vrp102.c is already computed by ranger during
evrp. Scan the evrp dump instead of vrp1 so the test observes the
property where it is established and does not require the diamond to
survive until vrp1.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/vrp102.c: Scan evrp instead of vrp1.
middle-end: Eliminate redundant scalar duplication at different vector widths
The fix to improve the folding of low-to-highpart builtins resulted
in redundant duplication instructions. The compiler was placing the
uniform vector arguments for low/highpart intrinsics in separate
registers despite them duplicating the same scalar value. This turns
out to be a result of the ordering of the duplication instructions,
when a narrow duplication of a scalar value appears before a wider
duplication of that same scalar the compiler is unable to link them
together into a single operation.
It is desirable in this case to create a single wider vector and
take the lower half for narrower uses of the same vector, since we
can then use a single load instruction. This patch fixes this logic
within CSE by matching vector duplicates during 'cse_prescan', if
they are duplicating the same pseudo into vectors of different
widths but the same element size. In 'cse_main' these matches are
processed and the wider vector duplicate insn is emitted before
all matching duplications, narrower duplicate insns will
be converted to a SUBREG of this initial duplication and duplicates
of the same width will reuse it.
Two test cases were updated to be more flexible with regexs since
hardcoded values were causing unnecessary failures despite the
code being logically correct.
gcc/ChangeLog:
* cse.cc (struct cse_vec_duplicate_match): New struct.
(struct cse_basic_block_data): New member added.
(cse_prescan_cache_vec_dup): New function to cache any vector
duplications and check for potential matches.
(cse_prescan_path): Extended pre_scan loop to cache vector
duplication matches + New loop added to assign a list of
matches to a block of data inside new struct member.
(cse_main): New loop to emit wider vector duplication earlier
and update narrower vector duplicate to SUBREG insn.
The current helper function folding calls to lowpart builtins into
highpart builtins calls does not handle cases where we have a 64b
wide uniform vector, which can be extended to 128b, used for
high part operations requiring 128b vector inputs. This change
adds an additional check on the statement arguments and widens
uniform vectors before adding to the 'call_args' of the new call
to the equivalent highpart builtin. Relevant function comments were
also updated.
gcc/ChangeLog:
* config/aarch64/aarch64-builtins.cc (aarch64_fold_lo_call_to_hi):
New branch to check for uniform vectors, extend and then add
them to the new highpart builtin call.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/simd/fold_to_highpart_7.c: New test.
Josef Melcr [Tue, 23 Jun 2026 15:46:08 +0000 (17:46 +0200)]
ipa: Add missing call to duplication hooks [PR ipa/125121]
This patch adds a missing call to edge duplication hooks in
cgraph_edge::make_callback.
In PR125121, we get an ICE in ipa-sra when compiling with -fno-ipa-cp,
because the analysis in ipa-prop runs after sra generates its summaries.
Because of the missing call to the hooks, the summaries required by sra
don't get copied over for the newly added callback edges, leading to
segfaults. This patch adds the call to the hooks to remedy this. It
also changes some of the initialization logic for summaries for callback
edges to make it a little more consistent.
PR ipa/125121
gcc/ChangeLog:
* cgraph.cc (cgraph_edge::make_callback): Add missing call to
duplication hooks.
* ipa-prop.cc (init_callback_edge_summary): Remove function.
(ipa_compute_jump_functions_for_edge): Remove call to
init_callback_edge_summary, fix comment.
(ipa_edge_args_sum_t::duplicate): Fix the initialization of jump
functions vector for callback edges.
Hardcode Solaris v2 mapfile syntax with Solaris ld
the clearcap.map linker map file was installed with a wrong name. This
is only noticed when testing an installed compiler with a part of the
testsuite that excercises the -mclear-hwcap option.
gcc/ChangeLog
* doc/invoke.texi (Options Summary) [C Language Options]:
Group --ansi with -ansi since they are documented together.
Correctly alphabetize -ffso-struct.
(C Dialect Options): Likeise correctly alphabetize -ffso-struct.
Arsen spotted that the introductory paragraph for the -fdeps-* options
appeared under -fpermitted-flt-eval-methods because of the way @table
elements are formatted. I've rearranged the text to fix that. I also
added a reference for -fdeps-format and tried to clarify what useful
values for -fdeps-target=@var{file} are. This group of options was
also missing entries in the Option Summary, and finally the options
in this section are (mostly) alphabetized so I moved the whole chunk
of text to the right place.
gcc/ChangeLog
* doc/invoke.texi (Option Summary): Add -fdeps-file, -fdeps-format,
and -fdeps-target.
(C Dialect Options): Properly alphabetize entries for the above
options, group them together, move the introductory paragraph
into the discussion of this group of items, and make the docs
more descriptive.
James K. Lowden [Sat, 11 Jul 2026 21:56:58 +0000 (17:56 -0400)]
cobol: Accept FD name as CALL parameter.
A nonstandard extension CALL may pass an FD. On the mainframe the
called cannot be a COBOL program and the passed parameter is the
file's DCB. With this patch the parser is accepts an FD name as a
CALL parameter and interprets it, for now, as a buffer name, with a
warning. Without -dialect ibm it is an error [Wcall-fd]. Further
development is needed to emulate mainframe semantics. Begins to
address RT 3619.
Also introduce __funcsig__ as a debugging convenience to print the
full name of __PRETTY_FUNCTION__ without type and parameters.
gcc/cobol/ChangeLog:
* cbldiag.h (enum cbl_diag_id_t): Add IbmCallFd.
* cobol1.cc (cobol_langhook_handle_option): Handle Wcall-fd.
* gcobol.1: Document Wcall-fd.
* lang-specs.h: Add Wcall-fd.
* lang.opt: Same
* messages.cc: Add Wcall-fd as IBM dialect option.
* parse.y: Use was_fd_name() to prevent misuse.
* parse_ante.h (field_find): Add incompatible semantics warning.
(parser_move_carefully): Same.
* symbols.cc (symbols_update): Add FD name to symbol map.
* symbols.h (update_symbol_map2): Declare overload for file.
(was_fd_name): Declare function.
* symfind.cc (struct funcname): Define to minimize __PRETTY_FUNCTION__.
(__funcsig__): Define function-name macro.
(class sym_name_t): Redefine public members as const.
(class symbol_file_names_t) Define maps for FD names.
(update_symbol_map2): Define overload for file.
(was_fd_name): Define.
(symbol_find): Use new symbol_file_names class.
Jin Ma [Fri, 10 Jul 2026 09:43:40 +0000 (17:43 +0800)]
RISC-V: Remove scratch register from bitfield extract splitter
The early-clobber scratch in *<any_extract>3 is unnecessary: slli
reads its source before writing, so the destination register can
safely hold the intermediate value. This reduces register pressure
and makes the split output simpler.
gcc/ChangeLog:
* config/riscv/riscv.md (*<any_extract:optab><GPR:mode>3):
Remove (clobber (match_scratch)) and use operand 0 as the
intermediate destination for the shift-left half of the split.
gcc/fortran
PR fortran/101951
PR fortran/101967
* match.cc (gfc_match_allocate): It is an error if the type-spec
derived type or the source expr has a coarray ultimate component.
Substitute 'typespec' with 'type-spec' in error messages for
consistency with standards.
gcc/testsuite/
PR fortran/101951
* gfortran.dg/f2018c937.f90: New test.
PR fortran/101967
* gfortran.dg/f2018c949.f90: New test.
* gfortran.dg/allocate_alloc_opt_4.f90: Substitute 'typespec' with
'type-spec' in error checks.
* gfortran.dg/allocate_derived_1.f90: Ditto.
Add the -mdense-math/-mno-dense-math compiler option to control emission
of Dense Math Facility (DMF) instructions. The option is backed by
OPTION_MASK_DMF and exposes a TARGET_DMF macro for use throughout the
backend.
When -mcpu=future is specified and -mdense-math is not mentioned
explicitly, DMF is enabled automatically. Explicitly requesting
-mdense-math on a non-future target is a hard error.
gcc:
* config/rs6000/rs6000-cpus.def (FUTURE_MASKS_SERVER): Add OPTION_MASK_DMF.
(POWERPC_MASKS): Likewise.
* config/rs6000/rs6000.cc (rs6000_option_override_internal): Enable
OPTION_MASK_DMF by default when TARGET_FUTURE is set and the
flag was not explicitly given; emit an error and clear the flag
when -mdense-math is requested on a non-future target.
(rs6000_opt_masks): Add "dense-math" entry for OPTION_MASK_DMF.
* config/rs6000/rs6000.opt (mdense-math): New option backed by Mask(DMF).
* config/rs6000/rs6000.opt.urls: Regenerated.
* doc/invoke.texi: Add -mdense-math.
Manuel Jacob [Sun, 12 Jul 2026 04:42:04 +0000 (22:42 -0600)]
build: Preserve all *_FOR_TARGET environment variables if already set.
Some of the *_FOR_TARGET environment variables (e.g. CC_FOR_TARGET) were
already preserved because they use the NCN_STRICT_CHECK_TARGET_TOOLS macro
directly. Other *_FOR_TARGET environment variables (e.g. AS_FOR_TARGET) use the
ACX_CHECK_INSTALLED_TARGET_TOOL macro, which falls back to
NCN_STRICT_CHECK_TARGET_TOOLS but overwrote the environment variable in some
cases before that. E.g. in the case `$build != $host`, the environment variable
was not preserved.
With this patch, each of the *_FOR_TARGET environment variables and their
unsuffixed (“for host”) correspondents are handled consistently in the sense
that a non-empty value takes precedence over:
- cached values
- values inferred by checking for a suitable program in PATH
- tools in the directory passed to --with-build-time-tools (applies only to *_FOR_TARGET)
Changelog
* configure: Regenerated.
config
* acx.m4 (ACX_CHECK_INSTALLED_TARGET_TOOL): Fix handling of
environment variables.
i386: Add BMI2 MULX pattern for highpart-only multiplication
Add a new instruction pattern that uses MULX to compute only the high
part of an unsigned multiplication on BMI2 targets. Previously, when
only the high part was needed, GCC would emit MULQ followed by a MOV
to retrieve the result from RDX. With this pattern, MULX writes the
high part directly to the destination register, saving one instruction.
This benefits unsigned 32-bit integer division by constants that require
33-bit magic multipliers (e.g., division by 7), reducing the sequence
from 4 instructions to 3 on BMI2 targets.
Jeff Law [Sun, 12 Jul 2026 04:36:11 +0000 (22:36 -0600)]
expmed: Optimize 32-bit unsigned division by constants on 64-bit targets
For 32-bit unsigned integer division by constants that require a wider
magic multiplier (mh != 0), use a pre-shifted magic constant in a mode
twice as wide and a single high-part multiply instead of the traditional
sub/shift/add sequence, when that is no more expensive.
The (size+1)-bit magic constant (2^size + ml) is pre-shifted by
(size - post_shift) bits so that the quotient is obtained directly from
the high part of the widened multiply, then truncated back to the
original mode. The widened sequence is only used when its cost, measured
with seq_cost, does not exceed that of the classic sub/shift/add sequence.
This reduces the instruction count for divisions like x/7 from 7
instructions to 4 on x86_64.
* expmed.cc (expand_wide_mulh_udiv): New function.
(expand_divmod): Use it for unsigned constant division needing a
wide multiplier on 64-bit targets, when no more expensive than the
sub/shift/add sequence.
Jerry DeLisle [Sat, 11 Jul 2026 17:35:29 +0000 (10:35 -0700)]
fortran: [PR126210] Restrict host-assoc symbol skip to derived types
The fix for PR126170 made read_module() skip re-importing any
symbol already visible via host association from the same
module, matched only by name.
PR fortran/126210
gcc/fortran/ChangeLog:
* module.cc (read_module): Only skip re-importing a symbol
already visible via host association from the same module
when that symbol is a derived type.
Add the -mdense-math/-mno-dense-math compiler option to control emission
of Dense Math Facility (DMF) instructions. The option is backed by
OPTION_MASK_DMF and exposes a TARGET_DMF macro for use throughout the
backend.
When -mcpu=future is specified and -mdense-math is not mentioned
explicitly, DMF is enabled automatically. Explicitly requesting
-mdense-math on a non-future target is a hard error.
gcc:
* config/rs6000/rs6000-cpus.def (FUTURE_MASKS_SERVER): Add OPTION_MASK_DMF.
(POWERPC_MASKS): Likewise.
* config/rs6000/rs6000.cc (rs6000_option_override_internal): Enable
OPTION_MASK_DMF by default when TARGET_FUTURE is set and the
flag was not explicitly given; emit an error and clear the flag
when -mdense-math is requested on a non-future target.
(rs6000_opt_masks): Add "dense-math" entry for OPTION_MASK_DMF.
* config/rs6000/rs6000.opt (mdense-math): New option backed by Mask(DMF).
* doc/invoke.texi: Add -mdense-math.
Andrew Pinski [Fri, 10 Jul 2026 23:55:19 +0000 (16:55 -0700)]
vect: Add back testcases for trapping math with comparisons [PR36190]
These were originally renamed to no-trapping-math-vect-*.c in r0-87196-g04b03edb56633f
but were fixed in r0-107313-gf9613c9a919462 but never added back to the
trapping versions.
This adds them back this time with an explict -ftrapping-math. Note vect-ifcvt-11.c
already exists now so need to name it vect-ifcvt-11a.c.
Committed as obvious after testing these testcases work on x86_64-linux-gnu.
PR testsuite/36190
gcc/testsuite/ChangeLog:
* gcc.dg/vect/vect-111.c: New test.
* gcc.dg/vect/vect-ifcvt-11a.c: New test.
* gcc.dg/vect/vect-ifcvt-12.c: New test.
* gcc.dg/vect/vect-ifcvt-13.c: New test.
* gcc.dg/vect/vect-ifcvt-14.c: New test.
* gcc.dg/vect/vect-ifcvt-15.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Roger Sayle [Fri, 10 Jul 2026 22:09:04 +0000 (23:09 +0100)]
PR tree-optimization/57371: Improved comparison of integers to FP constants.
This patch improves the tree-level optimization of (fptype)ivar != CST
in match.pd (historically tracked under PR 57371). Joseph Myers'
description in comment #1 provides an excellent overview of the issues,
that historically it's the trapping behaviour of (fptype)ivar conversion
that is the primary concern, which is why the current code in match.pd
checks fmt.can_represent_integral_type_p (itype). The first of the
improvements with this patch is to check flag_trapping_math to control
whether FP_OVERFLOW/FP_INEXACT needs to be preserved.
The main optimization concerns checking whether the comparison
against CST is unambiguous allowing it to be replaced with a integer
comparison. For reference, consider the table below which shows the
default conversion of integers to IEEE 32-bit float.
Observe that it's safe to optimize (float)i == 16777212.0f to the
equivalent i == 16777212 (as this is the only integer that can
convert to that floating point constant), but that it's unsafe to
optimize (float)i == 16777220.0f, as with default rounding there
are three possible integer values that FLOAT_EXPR to 16777220.0f.
The pragmatic check used in this patch is to confirm that (float)(i-1)
and (float)(i+1) are both distinct from (float)i before simplifying
the comparison to an integer-typed comparison.
Finally, this patch also handles non-default rounding modes.
In the table above, it's safe to optimize (float)i == 16777222.0f
in IEEE's default rounding mode, but not in all FP rounding modes.
This eventuality is handled by testing whether the (float)i, the
(float)(i-1) and the (float)(i+1) are all exactly rounded when
-frounding-math is specified.
The original motivation for this patch was Claudiu's issue/analysis at
https://github.com/foss-for-synopsys-dwc-arc-processors/gcc/issues/118
which predicted a dramatic +26% performance improvement on EEMBC's
iirflt01 benchmark.
2026-07-10 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR tree-optimization/57371
* fold-const.cc (fold_cmp_float_cst_p): New helper function.
* fold-const.h (fold_cmp_float_cst_p): Prototype here.
* match.pd ((FTYPE) N CMP CST): Use the new helper
fold_cmp_float_cst_p to check that transformation to an integer
comparison is safe.
gcc/testsuite/ChangeLog
PR tree-optimization/57371
* c-c++-common/pr57371-6.c: New test case.
* c-c++-common/pr57371-7.c: Likewise.
* c-c++-common/pr57371-8.c: Likewise.
* c-c++-common/pr57371-9.c: Likewise.
* c-c++-common/pr57371-10.c: Likewise.
Roger Sayle [Fri, 10 Jul 2026 22:04:03 +0000 (23:04 +0100)]
PR target/48609: Improve RTL expansion of complex value return.
This patch address the inefficient return of complex values (with the x86
ABI) where the result is returned to the caller in an integer register.
Currently this results in RTL expansion spilling the value to memory
and reloading it in an integer register. The patch below recognizes
this case, and composes the real and imaginary parts using shifts and
addition. The real part always appears first in memory, so is lowpart
on little-endian targets, and the highpart on big-endian targets.
bar: movss mem(%rip), %xmm0
movss %xmm0, -8(%rsp)
movss mem+4(%rip), %xmm0
movss %xmm0, -4(%rsp)
movq -8(%rsp), %xmm0
ret
With this patch, we now generate:
foo: ret
bar: movl mem+4(%rip), %edx
movl mem(%rip), %eax
salq $32, %rdx
addq %rdx, %rax
movq %rax, %xmm0
ret
For those folks noticing that bar could be improved further, I've
a follow-up patch to the i386's STV2 pass, to perform concatsidi2 in
SSE registers.
2026-07-10 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR target/48609
* expr.cc (emit_group_load_1): When passing a complex value in an
integer mode of the same size, explicitly construct (hi<<N)+lo to
avoid spilling to memory before reload.
gcc/testsuite/ChangeLog
PR target/48609
* gcc.target/i386/pr48609-2.c: New test case.
Roger Sayle [Fri, 10 Jul 2026 21:59:24 +0000 (22:59 +0100)]
PR target/99668: Improved complex to vector RTL expansion.
This patch improves the RTL expansion of casts (VIEW_CONVERT_EXPR)
from complex numbers to two-component vectors with the same inner
type. Currently, expand spills the complex number to memory to
perform this conversion. With the patch below we now convert the
V_C_E into the equivalent of (v2x){__real__ z,__imag__ z}, using
the backend's vec_init_optab.
To: movq 4(%esp), %xmm0
movhpd 12(%esp), %xmm0
ret
2026-07-10 Roger Sayle <roger@nextmovesoftware.com>
Richard Biener <rguenther@suse.de>
gcc/ChangeLog
PR target/99668
* expr.cc (try_expand_complex_as_vector): Try to use vec_init_optab
to convert a complex number to a two-component vector with the same
inner type.
(expand_expr_real_1) <case VIEW_CONVERT_EXPR>: Check whether the
above function can be used to implement this VIEW_CONVERT_EXPR.
gcc/testsuite/ChangeLog
PR target/99668
* gcc.target/i386/pr99668.c: New test case.
Robert Dubner [Fri, 10 Jul 2026 18:47:11 +0000 (14:47 -0400)]
cobol: Address endian issues.
There are on the order of four ways that endianness impacts the COBOL front end
and the libgcobol.so library.
1) The COBOL BINARY data type is always big-endian; the COMP-5 data type takes
on the endianness of the target architecture.
2) The options -fexec-charset and -fexec-national-charset specify the character
sets used for DISPLAY and NATIONAL variables. Those can independently be
multi-byte little-endian or big-endian, and they are independent of the
endianness of the target architecture.
3) The host machine can be either big-e or little-e.
4) The target machine likewise.
We got this far with the compiler because I assumed -- without even knowing I
was assuming -- the machine architectures were little-endian. So, when tested
with single-byte-coded ASCII or EBCDIC, or with little-endian UTF-16LE and
UTF-32LE, I could get things working without too much trouble.
I am not going to attempt to detail the myriad ways my code didn't work when
I specified "-fexec-charset=utf-16be". Nor am I going to describe what
happened when I first tried to create GCOBOL on a big-endian IBM System Z.
But that explains the size of this patch. With these changes, GCOBOL is able
to handle "-fexec-charset=utf-16be" on the x86_64. With these changes GCOBOL
is beginning to be able to handle single-byte-encoded ASCII or EBCDIC on the
System Z.
gcc/cobol/ChangeLog:
* Make-lang.in: Copy charmaps.cc and valconv.cc without using SED to
alter their contents.
* cbldiag.h (struct cbl_loc_t): Mollify cppcheck.
* compare.cc (alpha_compare_figconst): Endianness.
(alpha_compare): Endianness.
* genapi.cc (get_class_condition_string): Endianness.
(parser_statement_end): Fix initialization.
(initialize_variable_internal): Likewise.
(leave_section_internal): Likewise.
(parser_init_list): Likewise.
(parser_alphabet): Pass "cbl_alphabet_t *" instead of
"cbl_alphabet_t &"
(parser_alphabet_use): Likewise.
(program_end_stuff): Endianness.
(establish_using): Endianness; use out-of-band metadata to handle
passing intermediate_e variables BY VALUE.
(parser_trim): Endianness.
(parser_sort): Change call to parser_alphabet_use().
(parser_file_sort): Likewise.
(parser_file_merge): Likewise.
(create_and_call): Change handling of BY VALUE; handle RETURN-CODE
properly for dialects IBM, MF, and GNU.
(actually_create_the_static_field): Endianness.
(parser_symbol_add): Endianness.
* genapi.h (parser_alphabet): Change declaration.
(parser_alphabet_use): Likewise.
(parser_file_merge): Make a couple of formal parameters "const".
* genmath.cc: Incorporate cobol-endian.h.
* genutil.cc (binary_from_numdisp): Endianness.
(get_binary_value): Endianness.
(safe_cast): Prevent aliasing.
(safe_assign): New routine that extracts the binary value from a
numeric source, and assigns it to the target, converting as
necessary based on the target's TREE_TYPE.
* genutil.h (safe_assign): New declaration.
* messages.cc: Incorporate cobol-endian.h.
* move.cc (mh_source_is_literalN): Use streamlined, endian-safe
routines.
* parse.y: Incorporate cobol-endian.h; set big_endian_e for
FldNumericBin5 when the target machine is big-endian.
* parse_ante.h (mode_syntax_only): Formatting.
(struct prototype_type_t): Likewise.
(is_allowed_name): Likewise.
(prototype_args): Likewise.
(verify_args): Likewise.
(valid_pointer_relop): Likewise.
(blankit): Eliminate.
(cbl_field_t::blank_initial): Handle multi-byte characters.
(cbl_field_t::set_initial): Formatting.
(data_division_ready): Likewise.
(field_binary_usage): Likewise.
(ast_end_program): Likewise.
* parse_util.h (intrinsic_invalid_parameter): Eliminate FldIndex as
an invalid parameter type.
* symbols.cc (symbols_alphabet_set): Remove FldIndex from list of
invalid types.
(cbl_alphabet_t::reencode): Handle big-endian multi-byte charsets.
(iconv_cd): Use helpful_iconv_open().
(symbol_label_add): Eliminate overwritten assignment.
* util.cc (cbl_field_t::encode_numeric): Handle big-endian
numeric-display values.
Jerry DeLisle [Fri, 10 Jul 2026 02:24:49 +0000 (19:24 -0700)]
fortran: [PR126170] Fix LTO ICE in copy_function_or_variable
A redundant USE of a module already visible via host association,
written inside a contained procedure, caused gfortran's module
reader to create a second copy of that module's derived
type.
PR fortran/126170
gcc/fortran/ChangeLog:
PR fortran/126170
* class.cc (gfc_find_derived_vtab): Fix up a stale
non-use-associated duplicate vtab symbol.
(gfc_is_finalizable): Same fix-up, for the finalizer wrapper
symbol.
* module.cc (read_module): Skip re-importing a symbol already
visible via host association from the same module.
gcc/testsuite/ChangeLog:
PR fortran/126170
* gfortran.dg/lto/pr126170_0.f90: New test.
* gfortran.dg/lto/pr126170_1.f90: New test.
testsuite: Fix gcc.target/x86_64/abi tests on NetBSD
Several of the gcc.target/x86_64/abi tests FAIL on NetBSD/amd64:
FAIL: gcc.target/x86_64/abi/ms-sysv/ms-sysv.c -mcall-ms2sysv-xlogues -O0 -g3 "-DGEN_ARGS=-p0\ --omit-rbp-clobbers" (test for excess errors)
Excess errors:
gcc.target/x86_64/abi/ms-sysv/ms-sysv.c:394:19: warning: array subscript has type 'char' [-Wchar-subscripts]
FAIL: gcc.target/x86_64/abi/ms-sysv/ms-sysv.c -O2 "-DGEN_ARGS=-p1" (test for ex
cess errors)
Excess errors:
gcc.target/x86_64/abi/ms-sysv/ms-sysv.c:394:19: warning: array subscript has type 'char' [-Wchar-subscripts]
gcc/ms-sysv/ms-sysv-generated.h:42:1: error: bp cannot be used in 'asm' here
The first issue is fixed by casting the isspace arg to unsigned char,
the second matches the fix for FreeBSD/amd64:
apparently by simply matching what FreeBSD and OpenBSD do. However,
NetBSD doesn't use those notes: TARGET_ASM_FILE_END isn't defined and
the bundled GCC 10.5.0 doesn't emit it either.
Therefore this patch omits it.
The same issue is still present in upstream DMD in
druntime/src/core/thread/fiber/switch_context_asm.S.
Bootstapped without regressions on amd64-pc-netbsd10.1.
Jim Lin [Fri, 10 Jul 2026 16:43:04 +0000 (10:43 -0600)]
RISC-V: Don't drop multilibs matching the default march/mabi
A multilib entry that shares march/mabi with the default may
differ in other options such as mcmodel, so it is not equivalent
to the default multilib. Stop returning false for these entries
in riscv_multi_lib_info_t::parse so they are still recorded.
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc
(riscv_multi_lib_info_t::parse): Remove early-out for multilibs
matching only the default march/mabi.
Pengfei Li [Tue, 7 Jul 2026 15:09:53 +0000 (15:09 +0000)]
match.pd: Eliminate dead operand in vector permute and insert patterns
When shifting a vector by one element and then inserting a new element
into the vacated lane, GIMPLE can contain a VEC_PERM_EXPR followed by a
BIT_INSERT_EXPR. For example, the testcase in this patch has:
Here the zero vector is only used to fill the lane that is immediately
overwritten by the insertion.
This patch adds a match.pd pattern to detect when all live lanes of the
VEC_PERM_EXPR result come from a single source operand, and replaces the
other operand if the updated VEC_PERM_EXPR is still supported by the
target. This avoids materializing a zero filler vector. After this
patch, GCC will generate:
ext v0.16b, v0.16b, v0.16b, #4
ins v0.s[3], w0
Bootstrapped and tested on aarch64-linux-gnu and x86_64-linux-gnu.
gcc/ChangeLog:
* match.pd: Simplify vector permute and insert patterns.
[PATCH] match: Use tree_expr_nonnegative_p for (X / Y) (==, !=) 0 -> X (<,>=) Y [PR125738]
TYPE_UNSIGNED did not cover non-negative X and Y so use tree_expr_nonnegative_p
to relax condition on optimizations.
gcc/testsuite/gcc.dg/tree-ssa/pr64130.c fails because match.pd optimize funsigned () before
evrp pass. Fix this by removing funsigned () and one scan-tree-dump.
[PATCH] gm2,sel-sched-ir: Remove Unused Declarations from GCC.
Good evening,
The two declarations mentioned below are not used.
This patch removes them from the code.
* current_succs was introduced in e855c69, and
it is not used since then. Perhaps a previous
working version of the code used it and was
refactored away. One may note that there is
only one commit for 'git log -S current_succs',
and that it was featured on Jan's "Unused Vars"
e-mail from the year after it was added:
If I might speculate, the comment suggests it was
supposed to hold the value of compute_succs_info,
but in the productive code, the value is simply
returned.
* ggc_force_collect is an old variable, which
was made into a parameter of ggc_collect in 0edf2e81. An 'extern' declaration for it was
later added in 1eee94d, when merging the gm2
front-end into this repository.
Jonathan Wakely [Fri, 5 Jun 2026 14:51:23 +0000 (15:51 +0100)]
libstdc++: Fix Cylindrical Bessel functions for infinity [PR119143]
The result should be zero at infinity.
libstdc++-v3/ChangeLog:
PR libstdc++/119143
* include/tr1/bessel_function.tcc (__cyl_bessel_jn_asymp):
Return zero for infinite x.
* testsuite/special_functions/08_cyl_bessel_j/check_inf.cc: New
test.
* testsuite/special_functions/10_cyl_neumann/check_inf.cc: New
test.
* testsuite/tr1/5_numerical_facilities/special_functions/11_cyl_neumann/check_inf.cc:
New test.
* testsuite/tr1/5_numerical_facilities/special_functions/09_cyl_bessel_j/check_inf.cc:
New test.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Jonathan Wakely [Tue, 7 Jul 2026 17:59:30 +0000 (18:59 +0100)]
libstdc++: Adjust error handling for filesystem::read_symlink on Windows
Do not set errno in the helper functions __open_for_stat and
__check_handle_type, because those are used from std::filesystem APIs
which should set a std::error_code instead of changing errno. Move
setting errno into the Windows-specific __stat_windows function and
change the helper functions to use a std::error_code parameter instead.
Also simplify the Windows implementation of fs::read_symlink by moving
the error handling for non-symlinks into windows_read_symlink_handle.
libstdc++-v3/ChangeLog:
* src/c++17/fs_ops.cc (windows_read_symlink_handle): Use
__detail::__is_handle_symlink and report an error for
non-symlinks.
(filesystem::read_symlink): Remove error handling for
non-symlinks.
* src/filesystem/ops-common.h (__detail::__open_for_stat): Use
std::error_code parameter to report errors instead of setting
errno.
(__detail::__check_handle_type): Likewise.
(__detail::__is_handle_symlink): Likewise.
(__detail::__stat_windows): Pass std::error_code to helper
functions and set errno to report errors.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>