]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 weeks agoRISC-V: Declare TLSDESC clobbers for vector registers and CSRs per psABI
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.

2 weeks agox86-64: Add missing SSE and AVX zero-extend patterns
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.

gcc/

PR target/126231
* config/i386/i386.md (*fix_trunc<mode>si_sse_zext): New.
* config/i386/sse.md (*avx512fp16_vcvtsh2<sseintconvertsignprefix>si<round_zext_name>):
Likewise.
(*avx512fp16_vcvtsh2<sseintconvertsignprefix>si_2_zext): Likewise.
(*unspec_avx512fp16_fix<vcvtt_uns_suffix>_truncsi2<round_saeonly_zext_name>): Likewise.
(*sse_cvtss2si<round_zext_name>): Likewise.
(*sse_cvtss2si_2_zext): Likewise.
(*unspec_sse_cvttss2si<round_saeonly_zext_name>): Likewise.
(*sse_cvttss2si<round_saeonly_zext_name>): Likewise.
(*avx512f_vcvtss2usi<round_zext_name>): Likewise.
(*unspec_avx512f_vcvttss2usi<round_saeonly_zext_name>): Likewise.
(*avx512f_vcvttss2usi<round_saeonly_zext_name>): Likewise.
(*avx512f_vcvtsd2usi<round_zext_name>): Likewise.
(*unspec_avx512f_vcvttsd2usi<round_saeonly_zext_name>):
Likewise.
(*avx512f_vcvttsd2usi<round_saeonly_zext_name>): Likewise.
(*sse2_cvtsd2si<round_zext_name>): Likewise.
(*sse2_cvtsd2si_2_zext): Likewise.
(*unspec_sse2_cvttsd2si<round_saeonly_zext_name>): Likewise.
(*sse2_cvttsd2si<round_saeonly_zext_name>): Likewise.
(*avx10_2_vcvttsd2<sat_cvt_sign_prefix>sissi<round_saeonly_zext_name>):
Likewise.
(*avx10_2_vcvttss2<sat_cvt_sign_prefix>sissi<round_saeonly_zext_name>):
Likewise.
* config/i386/subst.md (round_zext_name): Likewise.
(round_zext_constraint): Likewise.
(round_zext_constraint2): Likewise.
(round_zext_nimm_predicate): Likewise.
(round_zext_nimm_scalar_predicate): Likewise.
(round_zext_op2): Likewise.
(round_zext): Likewise.
(round_saeonly_zext_name): Likewise.
(round_saeonly_zext_constraint): Likewise.
(round_saeonly_zext_constraint2): Likewise.
(round_saeonly_zext_nimm_scalar_predicate): Likewise.
(round_saeonly_zext_op2): Likewise.
(round_saeonly_zext): Likewise.

gcc/testsuite/

PR target/126231
* gcc.target/i386/zext-avx10-1.c: New test.
* gcc.target/i386/zext-avx512f-1.c: Likewise.
* gcc.target/i386/zext-avx512fp16-1.c: Likewise.
* gcc.target/i386/zext-sse-1.c: Likewise.
* gcc.target/i386/zext-sse-2.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 weeks agomatch.pd: Guard x+x -> x*2 simplification [PR126257]
Jakub Jelinek [Wed, 15 Jul 2026 08:27:56 +0000 (10:27 +0200)] 
match.pd: Guard x+x -> x*2 simplification [PR126257]

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.

* gcc.dg/torture/bitint-101.c: New test.

Reviewed-by: Richard Biener <rguenth@suse.de>
2 weeks agoc++: In attributes expect _Clang namespace rather than __clang__ [PR120635]
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.

Reviewed-by: Jason Merrill <jason@redhat.com>
2 weeks agoOpenMP: Handle 'device_type(host)' on 'target'
Tobias Burnus [Wed, 15 Jul 2026 06:43:26 +0000 (08:43 +0200)] 
OpenMP: Handle 'device_type(host)' on 'target'

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.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/target-device-type-1.c: Remove dg-sorry.
* gfortran.dg/gomp/target-device-type-1.f90: Likewise.

2 weeks agomiddle-end: use tree mode for masked cbranch operand [PR126221]
Hu, Lin1 [Mon, 13 Jul 2026 06:51:22 +0000 (14:51 +0800)] 
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).

gcc/testsuite/ChangeLog:

PR middle-end/126203
PR middle-end/126221
PR middle-end/126232
* gcc.target/i386/pr126221-1.c: New test.
* gcc.target/i386/pr126221-2.c: Ditto.
* gfortran.dg/pr126221.f90: Ditto.

2 weeks agoDaily bump.
GCC Administrator [Wed, 15 Jul 2026 00:16:41 +0000 (00:16 +0000)] 
Daily bump.

2 weeks agoOpenMP: Handle 'device_type(nohost)' on 'target'
Tobias Burnus [Tue, 14 Jul 2026 19:44:48 +0000 (21:44 +0200)] 
OpenMP: Handle 'device_type(nohost)' on 'target'

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.

2 weeks agolibstdc++: [_GLIBCXX_DEBUG] Make constant evaluation compatible
François Dumont [Tue, 14 Jul 2026 18:57:54 +0000 (20:57 +0200)] 
libstdc++: [_GLIBCXX_DEBUG] Make constant evaluation compatible

Cleanup _Safe_iterator and _Safe_local_iterator implementations.

Use base constructor for the special _Unchecked constructor.

Remove intermediate typedefs, use directly the template parameter type and
the base class.

libstdc++-v3/ChangeLog:

* include/debug/safe_iterator.h
(_Safe_iterator::_Iter_base, _Safe_iterator::_Safe_base): Remove.
(_Safe_iterator(const _Safe_iterator&, _Unchecked)): Delegate to correct base classes
constructors.
* include/debug/safe_local_iterator.h
(_Safe_local_iterator::_Iter_base, _Safe_local_iterator::_Safe_base): Remove.
(_Safe_local_iterator(const _Safe_local_iterator&, _Unchecked)): Delegate to the correct
base classes constructors.

2 weeks agoObjective-C: Fix parameter types to main ().
Iain Sandoe [Tue, 14 Jul 2026 11:16:33 +0000 (12:16 +0100)] 
Objective-C: Fix parameter types to main ().

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.

gcc/testsuite/ChangeLog:

* objc.dg/gnu-api-2-class.m: Replace void ** with char **
in the main function signature.
* objc.dg/gnu-api-2-ivar.m: Likewise.
* objc.dg/gnu-api-2-method.m: Likewise.
* objc.dg/gnu-api-2-objc.m: Likewise.
* objc.dg/gnu-api-2-objc_msg_lookup.m: Likewise.
* objc.dg/gnu-api-2-object.m: Likewise.
* objc.dg/gnu-api-2-property.m: Likewise.
* objc.dg/gnu-api-2-protocol.m: Likewise.
* objc.dg/gnu-api-2-resolve-method.m: Likewise.
* objc.dg/gnu-api-2-sel.m: Likewise.
* objc.dg/gnu-runtime-2.m: Likewise.
* objc.dg/gnu-runtime-3.m: Likewise.
* objc.dg/pr48177.m: Likewise.
* objc.dg/torture/strings/string1.m: Likewise.
* objc.dg/torture/strings/string2.m: Likewise.
* objc.dg/torture/strings/string3.m: Likewise.
* objc.dg/torture/strings/string4.m: Likewise.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2 weeks agoaarch64: Relax type-checking assert [PR126064]
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.

2 weeks agolibgomp: Robustify omp_get_device_distances [PR125877]
Tobias Burnus [Tue, 14 Jul 2026 14:09:54 +0000 (16:09 +0200)] 
libgomp: Robustify omp_get_device_distances [PR125877]

libgomp/ChangeLog:

PR libgomp/125877
* config/linux/numa.c (gomp_get_numa_distance): Avoid data race issue
during initalization and handle non-contiguous node numbering.

2 weeks agotestsuite: arm: Add MVE link effective target
Torbjörn SVENSSON [Tue, 14 Jul 2026 09:59:45 +0000 (11:59 +0200)] 
testsuite: arm: Add MVE link effective target

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.

gcc/ChangeLog:

* doc/sourcebuild.texi (arm_v8_1m_mve_link): Document.

gcc/testsuite/ChangeLog:

* gcc.target/arm/pr110268-1.c: Use arm_v8_1m_mve_link.
* gcc.target/arm/pr110268-2.c: Likewise
* lib/target-supports.exp (arm_v8_1m_mve_link): New.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2 weeks agovect: Fix wrong code with SLP IV reuse [PR126225]
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.

Signed-off-by: Cem Akgok <cemakgok@gmail.com>
2 weeks agoDarwin, Objective-C/C++: Globalise protocol ref metadata symbols.
Iain Sandoe [Mon, 13 Jul 2026 08:05:25 +0000 (09:05 +0100)] 
Darwin, Objective-C/C++: Globalise protocol ref metadata symbols.

Newer versions of the system static linker complain if Protocol reference
lists are not introduced with a global symbol.

gcc/ChangeLog:

* config/darwin.cc (darwin_globalize_label): Handle Protocol
references.
(darwin_label_is_anonymous_local_objc_name): Likewise.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2 weeks agoa68: fix typo in ga68-coding-guidelines.texi
Jose E. Marchesi [Tue, 14 Jul 2026 08:51:43 +0000 (10:51 +0200)] 
a68: fix typo in ga68-coding-guidelines.texi

gcc/algol68/ChangeLog

* ga68-coding-guidelines.texi (Conditional clauses): Fix typo
if-parts -> else-parts.

2 weeks agolibstdc++: Fix weight computation for piecewise_linear_distribution(nw, xmin, xmax...
Tomasz Kamiński [Mon, 1 Jun 2026 13:31:11 +0000 (15:31 +0200)] 
libstdc++: Fix weight computation for piecewise_linear_distribution(nw, xmin, xmax, fw) constructor [PR125548]

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.

PR libstdc++/125548

libstdc++-v3/ChangeLog:

* doc/html/manual/using_macros.html:
(_GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS): Mention PR125548
* doc/xml/manual/using.xml: Regenerate
* include/bits/random.tcc
(piecewise_linear_distribution::param_type::param_type(size_t, _RealType, ...)):
Update weight computation.
* testsuite/26_numerics/random/piecewise_linear_distribution/operators/serialize2.cc:
Updated expected values.
* testsuite/26_numerics/random/piecewise_linear_distribution/cons/pr125548.cc:
New test.
* testsuite/26_numerics/random/piecewise_linear_distribution/cons/pr125548_fallback.cc:
Run pr125548.cc with _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 weeks agolibstdc++: Change piecewise distribution densities to return vector<result_type>...
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>
2 weeks agoc-family: Use CAS loop instead of RMW atomics on small _BitInt with padding on target...
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.

* gcc.dg/torture/bitint-100.c: New test.

Reviewed-by: Richard Biener <rguenth@suse.de>
2 weeks agotree-optimization: Fold length-one memset through arbitrary pointers [PR102202]
Naveen [Tue, 14 Jul 2026 08:42:06 +0000 (01:42 -0700)] 
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.

Signed-off-by: Naveen <naveen.siddegowda@oss.qualcomm.com>
2 weeks agobitintlower: Handle .ASAN_POISON and .ASAN_POISON_USE with large/huge _BitInt [PR126084]
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.

Reviewed-by: Richard Biener <rguenth@suse.de>
2 weeks agocfgexpand: Align the whole asan var block to crtl->stack_alignment_needed [PR120201]
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.

* g++.dg/asan/pr120201-1.C: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 weeks agoout-of-SSA: use the spill predicate for partition decls [PR123625, PR121957]
Kyrylo Tkachov [Tue, 7 Jul 2026 10:24:44 +0000 (03:24 -0700)] 
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.

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
2 weeks agotree-optimization/126194 - bogus PTA with C++ delete
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.

* g++.dg/lto/pr126194.h: New testcase.
* g++.dg/lto/pr126194_0.C: Likewise.
* g++.dg/lto/pr126194_1.C: Likewise.
* g++.dg/lto/pr126194_2.C: Likewise.

2 weeks agoc++: Default deallocating functions to noexcept for C++11
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

_ZdlPv1A
_ZdlPv1B
_ZN1CdlEPv
_ZdlPv1D
_Z2f1v
_Z2f2v
_ZN1EILb1EEdlIiEEvPvT_
_ZN1EILb0EEdlIiEEvPvT_

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.

Reviewed-by: Jason Merrill <jason@redhat.com>
2 weeks agoasan: Fix comment typo
Jakub Jelinek [Tue, 14 Jul 2026 05:58:30 +0000 (07:58 +0200)] 
asan: Fix comment typo

This fixes a comment typo in asan.h.

2026-07-14  Jakub Jelinek  <jakub@redhat.com>

* asan.h (asan_var_and_redzone_size): Fix comment typo,
occupis -> occupies.

3 weeks agoRevert "x86: Rewrite ix86_find_max_used_stack_alignment"
H.J. Lu [Mon, 13 Jul 2026 21:25:45 +0000 (05:25 +0800)] 
Revert "x86: Rewrite ix86_find_max_used_stack_alignment"

Revert

commit e754b70fe5470b975d31887fa5647f1c92d6522d
Author:     H.J. Lu <hjl.tools@gmail.com>
AuthorDate: Tue Apr 7 23:16:38 2026 +0800
Commit:     H.J. Lu <hjl.tools@gmail.com>
CommitDate: Mon Jul 6 16:11:45 2026 +0800

    x86: Rewrite ix86_find_max_used_stack_alignment

to fix PR target/126202.

gcc/

PR target/126202
* alias.cc (static_reg_base_value): Revert commit e754b70fe54.
(find_base_term): Likewise.
* alias.h (find_base_term): Likewise.
* function.cc (thread_prologue_and_epilogue_insns): Likewise.
* rtl.h (static_reg_base_value): Likewise.
* config/i386/i386.cc (stack_access_data): Likewise.
(ix86_find_all_reg_uses_1): Likewise.
(ix86_find_all_reg_uses): Likewise.
(ix86_access_stack_p): Likewise.
(ix86_need_alignment_p_2): Likewise.
(ix86_need_alignment_p_1): Likewise.
(ix86_need_alignment_p): Likewise.
(ix86_update_stack_alignment): Likewise.
(ix86_find_max_used_stack_alignment): Likewise.
(ix86_update_stack_alignment_2): Removed.
(ix86_update_stack_alignment_1): Likewise.

gcc/testsuite/

PR target/126202
* g++.target/i386/pr126202-1.C: New test.
* gcc.target/i386/pr126202-1.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 weeks agox86: Add more tests for PR target/110533
H.J. Lu [Mon, 13 Jul 2026 21:06:33 +0000 (05:06 +0800)] 
x86: Add more tests for PR target/110533

PR target/110533
* gcc.target/i386/pr110533-2a.c: New test.
* gcc.target/i386/pr110533-2b.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 weeks agoRISC-V: Adjust test case due to allow vf[sz]ext.vf8 overlap
Pan Li [Sun, 12 Jul 2026 01:56:54 +0000 (09:56 +0800)] 
RISC-V: Adjust test case due to allow vf[sz]ext.vf8 overlap

Remove the xfail due to vf8 changes.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/pr112431-18.c: Remove xfail.

Signed-off-by: Pan Li <pan2.li@intel.com>
3 weeks agoRISC-V: Adjust the scan asm for v[sz]ext.vf2 for v[123]
Pan Li [Sat, 11 Jul 2026 14:36:07 +0000 (22:36 +0800)] 
RISC-V: Adjust the scan asm for v[sz]ext.vf2 for v[123]

The previous match v1 may match the v12 as well, therefore
add the non-num boundary.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u16-m1.c:
Add non-number boundary for reg num check.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u16-m2.c:
Ditto.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u16-mf2.c:
Ditto.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u16-mf4.c:
Ditto.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u32-m1.c:
Ditto.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u32-mf2.c:
Ditto.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u8-m1.c:
Ditto.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u8-m2.c:
Ditto.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u8-mf2.c:
Ditto.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u8-mf4.c:
Ditto.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u8-mf8.c:
Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
3 weeks agoRISC-V: Add test cases for vzext.vf8 reg overlap
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.

Signed-off-by: Pan Li <pan2.li@intel.com>
3 weeks agoRISC-V: Add test cases for vsext.vf8 reg overlap
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.

Signed-off-by: Pan Li <pan2.li@intel.com>
3 weeks agoRISC-V: Allow RVV register overlap for v[sz]ext.vf8
Pan Li [Sat, 11 Jul 2026 14:32:59 +0000 (22:32 +0800)] 
RISC-V: Allow RVV register overlap for v[sz]ext.vf8

Like v[sz]ext.vf4, allow the rvv register overlap
for v[sz]ext.vf8.

gcc/ChangeLog:

* config/riscv/vector.md: Leverage Wvr constraint.

Signed-off-by: Pan Li <pan2.li@intel.com>
3 weeks agofortran: [PR126234] Fix regression in SPEC benchmarks.
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.

gcc/testsuite/ChangeLog:

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

3 weeks agoDaily bump.
GCC Administrator [Tue, 14 Jul 2026 00:16:40 +0000 (00:16 +0000)] 
Daily bump.

3 weeks agoc++: Avoid duplicate trivial_abi cleanup in cdtor clones [PR125066]
Yuxuan Chen [Mon, 13 Jul 2026 21:34:25 +0000 (21:34 +0000)] 
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.

Signed-off-by: Yuxuan Chen <i@yuxuan.ch>
3 weeks agoc++: avoid double resolves_to_fixed_type_p call [PR126207]
Vladislav Semykin [Mon, 13 Jul 2026 22:29:22 +0000 (18:29 -0400)] 
c++: avoid double resolves_to_fixed_type_p call [PR126207]

gcc/cp/ChangeLog:
PR c++/126207
* cp-tree.h (typeid_evaluated_p): Add nonnull out-parameter.
* rtti.cc (typeid_evaluated_p): Likewise; avoid calling
resolves_to_fixed_type_p twice.
(build_typeid): Adjust.

Signed-off-by: Vladislav Semykin <vladislav.semykin@gmail.com>
3 weeks agoc++: Keep type variants consistent for trivial_abi [PR125064]
Yuxuan Chen [Mon, 13 Jul 2026 22:29:22 +0000 (18:29 -0400)] 
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.

Signed-off-by: Yuxuan Chen <i@yuxuan.ch>
3 weeks agotestsuite: Fix unstable duplicate test names in pr111527.exp [PR111527]
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>
3 weeks agolibgomp.texi: Update OpenMP impl status for TR15
Tobias Burnus [Mon, 13 Jul 2026 20:58:51 +0000 (22:58 +0200)] 
libgomp.texi: Update OpenMP impl status for TR15

libgomp/ChangeLog:

* libgomp.texi (OpenMP Implementation Status): Change section
name from TR14 to TR15 and add TR15 additions.

3 weeks agoi386: Add -mtune=generic to highpart multiplication tests
MITSUNARI Shigeo [Mon, 13 Jul 2026 20:33:58 +0000 (14:33 -0600)] 
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.

3 weeks agoFix authorship of recent patch to expmed.cc
Jeff Law [Mon, 13 Jul 2026 20:32:41 +0000 (14:32 -0600)] 
Fix authorship of recent patch to expmed.cc

3 weeks agoFix compilation issue introduced in r17-2365-gc5627f93a82591 [PR124058]
Torbjörn SVENSSON [Mon, 13 Jul 2026 19:43:50 +0000 (21:43 +0200)] 
Fix compilation issue introduced in r17-2365-gc5627f93a82591 [PR124058]

gcc/ChangeLog:

PR driver/124058
* gcc-diagnostic-spec.cc (nowarn_spec_t::nowarn_spec_t):
Remove leftover reference to OPT_Wuse_after_free.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
3 weeks agoMake -Wuse-after-free alias for -Wuse-after-free=1 [PR124058]
Torbjörn SVENSSON [Sun, 12 Jul 2026 18:42:55 +0000 (20:42 +0200)] 
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_.

gcc/testsuite/ChangeLog:

* c-c++-common/Wuse-after-free-8.c: New test.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
3 weeks ago[PR120165, LRA]: Prevent equivalence substitution resulting in wrong reloads
Vladimir N. Makarov [Mon, 13 Jul 2026 19:16:45 +0000 (15:16 -0400)] 
[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.

3 weeks agoShow UNSPEC names on slim rtl dump
Nathan Sidwell [Fri, 10 Jul 2026 18:21:38 +0000 (14:21 -0400)] 
Show UNSPEC names on slim rtl dump

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.

3 weeks agoc++: Implement clang::no_specializations attribute and -Winvalid-specialization warni...
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.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 weeks agoc++: ICE with requires and -Wsequence-point [PR126066]
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:

    /* Parse the requirement body. */
    ++processing_template_decl;
    reqs = cp_parser_requirement_body (parser);
    --processing_template_decl;

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.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-pr126066.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 weeks agomatch.pd: Recognize branchless conditional negate [PR113894]
Odysseas Georgoudis [Mon, 13 Jul 2026 16:09:10 +0000 (10:09 -0600)] 
match.pd: Recognize branchless conditional negate [PR113894]

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/testsuite/ChangeLog:

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

3 weeks agoi386: Fix Win64 __int128 return handling [PR78799]
Oleg Tolmatcev [Sat, 13 Jun 2026 22:22:07 +0000 (00:22 +0200)] 
i386: Fix Win64 __int128 return handling [PR78799]

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>
3 weeks agoc++: Fix conversion to enum with fixed bool underlying type [PR96496]
Joyee Cheung [Mon, 13 Jul 2026 15:35:47 +0000 (11:35 -0400)] 
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.

Signed-off-by: Joyee Cheung <joyee@igalia.com>
3 weeks agors6000: Add TDOmode support
Jeevitha Palanisamy [Thu, 2 Jul 2026 06:31:36 +0000 (01:31 -0500)] 
rs6000: Add TDOmode support

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.

2026-07-13  Jeevitha Palanisamy  <jeevitha@linux.ibm.com>

gcc/
* config/rs6000/rs6000-call.cc (rs6000_return_in_memory): Handle
TDOmode and emit "Dense Math" diagnostics.
(rs6000_function_arg): Reject TDOmode function parameters and
emit "Dense Math" diagnostics.
* config/rs6000/rs6000-modes.def: Add TDOmode.

3 weeks agolibstdc++: Assert that produced layout_stride::mapping is unique.
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>
3 weeks agotestsuite: scan the vrp102.c property in evrp
Kyrylo Tkachov [Wed, 8 Jul 2026 12:16:37 +0000 (12:16 +0000)] 
testsuite: scan the vrp102.c property in evrp

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.

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
3 weeks agomiddle-end: Eliminate redundant scalar duplication at different vector widths
Dylan Rees [Mon, 13 Jul 2026 09:57:18 +0000 (09:57 +0000)] 
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.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/simd/fold_to_highpart_7.c:
Extended test.
* gcc.target/i386/pr81501-9a.c: Updated test.
* gcc.target/i386/pr81501-9b.c: Updated test.

3 weeks agoaarch64: Improve simd highpart builtin folding
Dylan Rees [Mon, 13 Jul 2026 09:57:17 +0000 (09:57 +0000)] 
aarch64: Improve simd highpart builtin folding

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.

3 weeks agoaarch64: Add C++ testcase for aligned may_alias types [PR124146]
Kyrylo Tkachov [Thu, 9 Jul 2026 09:35:26 +0000 (02:35 -0700)] 
aarch64: Add C++ testcase for aligned may_alias types [PR124146]

The existing tests exercise C.  Add a C++ counterpart to the original
reproducer, which ICEs without the fix and compiles successfully with it.

Pushing to trunk.

gcc/testsuite/ChangeLog:

PR target/124146
* g++.target/aarch64/pr124146.C: New test.

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
3 weeks agoipa: Add missing call to duplication hooks [PR ipa/125121]
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.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/pr125121.c: New test.

Signed-off-by: Josef Melcr <josef.melcr@suse.com>
3 weeks agoMAINTAINERS: Add myself to write after approval and DCO
Eikansh Gupta [Mon, 13 Jul 2026 08:30:40 +0000 (14:00 +0530)] 
MAINTAINERS: Add myself to write after approval and DCO

ChangeLog:

* MAINTAINERS.yml: Add myself.
* MAINTAINERS (Write After Approval): Regenerate.
(Contributing under the DCO): Regenerate.

Signed-off-by: Eikansh Gupta <eikansh.gupta@oss.qualcomm.com>
3 weeks agobuild: Fix Solaris clearcap.map installation
Rainer Orth [Mon, 13 Jul 2026 08:08:55 +0000 (10:08 +0200)] 
build: Fix Solaris clearcap.map installation

Since

commit 5f1256233b6a192677dcb4d8a32672c86967120d
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Sun Jul 5 14:59:27 2026 +0200

    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.

Tested on i386-pc-solaris2.11.

2026-07-12  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc:
* config/t-sol2 (install-clearcap-map): Install as clearcap.map.

3 weeks agodoc: Delete some redundant "the"s.
Sandra Loosemore [Mon, 13 Jul 2026 03:06:43 +0000 (03:06 +0000)] 
doc: Delete some redundant "the"s.

gcc/ChangeLog
* doc/extend.texi (Common Attributes): Delete instances of
extra "the".
* doc/invoke.texi (Visium Options): Likewise.
* doc/tree-ssa.texi (SSA Operands): Likewise.

3 weeks agodoc: Fix alphabetization for C Dialect Options
Sandra Loosemore [Mon, 13 Jul 2026 02:58:07 +0000 (02:58 +0000)] 
doc: Fix alphabetization for C Dialect Options

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.

3 weeks agodoc: Clean up documentation for -fdeps-* options
Sandra Loosemore [Mon, 13 Jul 2026 02:42:59 +0000 (02:42 +0000)] 
doc: Clean up documentation for -fdeps-* options

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.

3 weeks agoDaily bump.
GCC Administrator [Mon, 13 Jul 2026 00:16:29 +0000 (00:16 +0000)] 
Daily bump.

3 weeks agocobol: Accept FD name as CALL parameter.
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.

3 weeks agoRISC-V: Remove scratch register from bitfield extract splitter
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.

3 weeks agomatch: Remove redundant build_one_cst (type) [PR104280]
Kael Andrew Alonzo Franco [Sun, 12 Jul 2026 11:53:14 +0000 (07:53 -0400)] 
match: Remove redundant build_one_cst (type) [PR104280]

integer_onep@0 is present, so use @0 instead of build_one_cst (type)
to remove function call.

Bootstrapped and tested on x86_64-pc-linux-gnu.

PR tree-optimization/104280

gcc/ChangeLog:

* match.pd: Remove redundant build_one_cst (type) [PR104280]

Signed-off-by: Kael Andrew Franco <kaelfandrew@gmail.com>
3 weeks agomatch: Remove redundant build_zero_cst (type) [PR114009]
Kael Andrew Alonzo Franco [Sun, 12 Jul 2026 11:52:01 +0000 (07:52 -0400)] 
match: Remove redundant build_zero_cst (type) [PR114009]

Since PR114009 simplify patterns have integer_zerop, integer_zerop@2 can be used
instead of build_zero_cst (type) to remove function call.

Bootstrapped and tested on x86_64-pc-linux-gnu.

PR tree-optimization/114009

gcc/ChangeLog:

* match.pd: Remove redundant build_zero_cst (type) [PR114009]

Signed-off-by: Kael Andrew Franco <kaelfandrew@gmail.com>
3 weeks agomatch: Remove one build_minus_one_cst (type) in r15-6257.
Kael Andrew Alonzo Franco [Sun, 12 Jul 2026 11:50:29 +0000 (07:50 -0400)] 
match: Remove one build_minus_one_cst (type) in r15-6257.

Since all operands has the same type, integer_minus_onep@1 can be used
instead of build_minus_one_cst (type) to remove function call.

Bootstrapped and tested on x86_64-pc-linux-gnu.

gcc/ChangeLog:

* match.pd: Remove one build_minus_one_cst (type) in r15-6257.

Signed-off-by: Kael Andrew Franco <kaelfandrew@gmail.com>
3 weeks agoFortran: Constraints involving coarray ultimate components [PR101951,PR101967]
Paul Thomas [Sun, 12 Jul 2026 11:27:29 +0000 (12:27 +0100)] 
Fortran: Constraints involving coarray ultimate components [PR101951,PR101967]

2026-07-12  Steve Kargl  <kargl@gcc.gnu.org>

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.

3 weeks agoMAINTAINERS: Add myself to MAINTAINERS
Kael Andrew Alonzo Franco [Sun, 12 Jul 2026 10:52:28 +0000 (06:52 -0400)] 
MAINTAINERS: Add myself to MAINTAINERS

Add kael@gcc.gnu.org and kaelfandrew@gmail.com to MAINTAINERS.

ChangeLog:

* MAINTAINERS (Write After Approval): Add myself.
(Contributing under the DCO): Add myself.
* MAINTAINERS.yml: Add myself.

Signed-off-by: Kael Andrew Franco <kaelfandrew@gmail.com>
3 weeks agors6000: Add -mdense-math option
Surya Kumari Jangala [Sun, 12 Jul 2026 08:07:37 +0000 (03:07 -0500)] 
rs6000: Add -mdense-math option

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.

2026-07-09  Surya Kumari Jangala  <jskumari@linux.ibm.com>

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.

3 weeks agobuild: Preserve all *_FOR_TARGET environment variables if already set.
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.

Signed-off-by: Manuel Jacob <me@manueljacob.de>
3 weeks agoi386: Add BMI2 MULX pattern for highpart-only multiplication
MITSUNARI Shigeo [Sun, 12 Jul 2026 04:38:41 +0000 (22:38 -0600)] 
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.

Before:
    movabsq $2635249153617166336, %rcx
    movl    %edi, %eax
    mulq    %rcx
    movl    %edx, %eax

After:
    movabsq $2635249153617166336, %rax
    movl    %edi, %edx
    mulx    %rax, %rax, %rax

gcc/ChangeLog:

* config/i386/i386.md (*bmi2_umul<mode>3_highpart): New pattern.

gcc/testsuite/ChangeLog:

* gcc.target/i386/bmi2-mulx-highpart-1.c: New test.

Signed-off-by: MITSUNARI Shigeo <herumi@nifty.com>
3 weeks agoexpmed: Optimize 32-bit unsigned division by constants on 64-bit 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.

Before (x / 7):
    movl    %edi, %eax
    imulq   $613566757, %rax, %rax
    shrq    $32, %rax
    subl    %eax, %edi
    shrl    %edi
    addl    %edi, %eax
    shrl    $2, %eax

After:
    movabsq $2635249153617166336, %rcx
    movl    %edi, %eax
    mulq    %rcx
    movl    %edx, %eax

gcc/ChangeLog:

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

gcc/testsuite/ChangeLog:

* gcc.target/i386/mulq-highpart.c: New test.

Signed-off-by: MITSUNARI Shigeo <herumi@nifty.com>
3 weeks agoDaily bump.
GCC Administrator [Sun, 12 Jul 2026 00:16:27 +0000 (00:16 +0000)] 
Daily bump.

3 weeks agofortran: [PR126210] Restrict host-assoc symbol skip to derived types
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.

gcc/testsuite/ChangeLog:

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

3 weeks agoRevert "rs6000: Add -mdense-math option"
Surya Kumari Jangala [Sat, 11 Jul 2026 17:22:03 +0000 (12:22 -0500)] 
Revert "rs6000: Add -mdense-math option"

This reverts commit 2601cb4d27364e2ae5c0eb4f53e186e0e0ecadde.

3 weeks agors6000: Add -mdense-math option
Surya Kumari Jangala [Thu, 9 Jul 2026 08:46:23 +0000 (03:46 -0500)] 
rs6000: Add -mdense-math option

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.

2026-07-09  Surya Kumari Jangala  <jskumari@linux.ibm.com>

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.

3 weeks agolibgcc: Support -mcall-ms2sysv-xlogues on NetBSD/x86
Rainer Orth [Sat, 11 Jul 2026 08:31:50 +0000 (10:31 +0200)] 
libgcc: Support -mcall-ms2sysv-xlogues on NetBSD/x86

The gcc.target/x86_64/abi/ms-sysv/ms-sysv.c tests FAIL on NetBSD/x86
with many undefined references to __sse_resms64f etc.  The fix is
identical to

commit df09e09c0bad09421984e4f52344baf5d81a3570
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Fri May 29 16:24:40 2026 +0200

    libgcc: Support -mcall-ms2sysv-xlogues on FreeBSD/x86

However, there's no need to emit .note.GNU-stack sections which are
unused on NetBSD, unlike FreeBSD.

Bootstrapped without regressions on amd64-pc-netbsd10.1 and
x86_64-pc-linux-gnu.

2026-07-05  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libgcc:
* config.host <i[34567]86-*-netbsdelf*> (tmake_file): Add
i386/t-msabi.
<x86_64-*-netbsd*>: Likewise.

3 weeks agocobol: Use snprintf instead of strncpy in charmaps.cc.
Robert Dubner [Sat, 11 Jul 2026 04:09:27 +0000 (00:09 -0400)] 
cobol: Use snprintf instead of strncpy in charmaps.cc.

This change eliminates compiler warnings about strncpy.

libgcobol/ChangeLog:

* charmaps.cc (helpful_iconv_open): Use snprintf() instead of strncpy().

3 weeks agocobol: Use strncpy properly.
Robert Dubner [Sat, 11 Jul 2026 03:48:32 +0000 (23:48 -0400)] 
cobol: Use strncpy properly.

gcc/cobol/ChangeLog:

* copybook.h (class copybook_t): Mollify cppcheck.
* lexio.h (struct filespan_t): Likewise.
* symbols.h (symbol_typedef): Add declaration.

libgcobol/ChangeLog:

* charmaps.cc (helpful_iconv_open): Use strncpy() properly.
(char_from_figconst): Initialize return value.

gcc/testsuite/ChangeLog:

* cobol.dg/group2/BINARY_and_COMP-5.cob: Removed.
* cobol.dg/group2/BINARY_and_COMP-5.out: Removed.
* cobol.dg/group2/Non-numeric_data_in_numeric_items__1_.cob: Removed.
* cobol.dg/group2/Non-numeric_data_in_numeric_items__1_.out: Removed.

3 weeks agoDaily bump.
GCC Administrator [Sat, 11 Jul 2026 00:16:37 +0000 (00:16 +0000)] 
Daily bump.

3 weeks agovect: Add back testcases for trapping math with comparisons [PR36190]
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>
3 weeks agoPR tree-optimization/57371: Improved comparison of integers to FP constants.
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.

(float)16777211 => 16777211.0f;
(float)16777212 => 16777212.0f;
(float)16777213 => 16777213.0f;
(float)16777214 => 16777214.0f;
(float)16777215 => 16777215.0f;
(float)16777216 => 16777216.0f;
(float)16777217 => 16777216.0f;  // rounded
(float)16777218 => 16777218.0f;
(float)16777219 => 16777220.0f;  // rounded
(float)16777220 => 16777220.0f;
(float)16777221 => 16777220.0f;  // rounded
(float)16777222 => 16777222.0f;
(float)16777223 => 16777224.0f;  // rounded
(float)16777224 => 16777224.0f;
(float)16777225 => 16777224.0f;  // rounded
(float)16777226 => 16777226.0f;

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.

3 weeks agoPR target/48609: Improve RTL expansion of complex value return.
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.

Consider the new test case:

_Complex float mem;
_Complex float foo(_Complex float x) { return x; }
_Complex float bar() { return mem; }

Currently, with -O2 GCC generates:

foo:    movss   %xmm0, -8(%rsp)
        shufps  $85, %xmm0, %xmm0
        movss   %xmm0, -4(%rsp)
        movq    -8(%rsp), %xmm0
        ret

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.

3 weeks agoPR target/99668: Improved complex to vector RTL expansion.
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.

The motivating example from the Bugzilla PR is:

typedef double v2df __attribute__((vector_size(16)));
v2df foo (_Complex double x)
{
  return *(v2df *)&x;
}

Currently, with -O2 GCC implements this by spilling to memory:

foo: movsd   %xmm0, -24(%rsp)
        movsd   %xmm1, -16(%rsp)
        movupd  -24(%rsp), %xmm0
        ret

with this enhancement to RTL expansion, we now generate:

foo: unpcklpd        %xmm1, %xmm0
        ret

The improvement with -m32 -msse2 -O2 is even more pronounced.

From:   subl    $28, %esp
        movsd   32(%esp), %xmm1
        movsd   40(%esp), %xmm2
        movsd   %xmm1, (%esp)
        movsd   %xmm2, 8(%esp)
        movupd  (%esp), %xmm0
        addl    $28, %esp
        ret

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.

3 weeks agocobol: Address endian issues.
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.

libgcobol/ChangeLog:

* charmaps.cc (defined): Use conditional compilation to locate .h
files; incorporate cobol-endian.h.
(__gg__iconverter): Conditional use of malloc/xmalloc.
(fixcode): Convert utf16 and utf32 to utf-16le/be and utf-32le/based
on target endianness.  Convert utf16le/be and utf32le/be to
utf-16le/be and utf-32le/be to accommodate FreeBSD, which has only
the hyphenated versions.
(helpful_iconv_open): Use fixcode();
(char_from_figconst): New routine.
* charmaps.h (CHARMAPS_H): Format comment.
(ascii_cr): New definition.
(ascii_lbrace): Likewise.
(ascii_rbrace): Likewise.
(ascii_newline): Likewise.
(ebcdic_return): Likewise.
(ebcdic_newline): Likewise.
(helpful_iconv_open): New declaration.
(DEFAULT_32_ENCODING): Change to...
(HOST_32_ENCODING): New constant, based on host endianness.
(error_msg_direct): Eliminate debugging comment.
(charmap_as_unsigned_chars): New utility.
(charmap_load_unaligned): Likewise.
(charmap_store_unaligned): Likewise.
(store_uint16): Likewise.
(store_uint32): Likewise.
(class cbl_iconv_t): Use helpful_iconv_open().
(class charmap_t): Endianness.
(char_from_figconst): New declaration.
* gfileio.cc (relative_file_delete): Endianness.
(relative_file_start): Endianness.
(relative_file_rewrite): Endianness.
(relative_file_write): Endianness.
(write_a_char): Endianness.
(sequential_file_write): Endianness.
(relative_file_read): Endianness.
* gmath.cc (__gg__pow): Formatting.
(uint128_lo64): Endianness.
(uint128_hi64): Endianness.
(uint128_from_limbs): Endianness.
(int256_get_u128): Endianness.
(int256_set_u128): Endianness.
(int256_is_negative): Endianness.
(int128_abs_as_uint128): Endianness.
(add_int256_to_int256): Endianness.
(negate_int256): Endianness.
(divide_int256_by_int64): Endianness.
(squeeze_int256): Endianness.
(get_int256_from_qualified_field): Endianness.
(__gg__add_fixed_phase1): Endianness.
(__gg__addf1_fixed_phase2): Endianness.
(__gg__fixed_phase2_assign_to_c): Endianness.
(__gg__add_float_phase1): Endianness.
(__gg__addf1_float_phase2): Endianness.
(__gg__addf3): Endianness.
(__gg__subtractf1_fixed_phase2): Endianness.
(__gg__subtractf2_fixed_phase1): Endianness.
(__gg__subtractf1_float_phase2): Endianness.
(__gg__subtractf2_float_phase1): Endianness.
(__gg__subtractf3): Endianness.
(__gg__multiplyf1_phase1): Endianness.
(multiply_int128_by_int128): Endianness.
(__gg__multiplyf1_phase2): Endianness.
(__gg__multiplyf2): Endianness.
(shift_in_place128): Endianness.
(int256_as_decimal): Endianness.
(clz_uint64): Endianness.
(defined): Endianness.
(shift_left_int256): Endianness.
(divide_int128_by_int128): Endianness.
(__gg__dividef1_phase2): Endianness.
(__gg__dividef23): Endianness.
(__gg__dividef45): Endianness.
* inspect.cc (as_chars): Endianness.
(funky_find): Endianness.
(funky_find_wide): Endianness.
(funky_find_wide_backward): Endianness.
(append_normalized_character): Endianness.
(normalize_id): Endianness.
(normalize_id_sbc): Endianness.
(the_alpha_and_omega): Endianness.
(the_alpha_and_omega_sbc): Endianness.
(the_alpha_and_omega_backward): Endianness.
(inspect_backward_format_1): Endianness.
(__gg__inspect_format_1): Endianness.
(inspect_backward_format_2): Endianness.
(__gg__inspect_format_2): Endianness.
(normalize_for_inspect_format_4): Endianness.
(__gg__inspect_format_4): Endianness.
* intrinsic.cc (as_chars): Endianness.
(xrealloc): Compile for both cobol1 and libgcobol.so.
(mconvert_to_c_string): Endianness.
(ensure_char_capacity):  Endianness.
(struct input_state): Allocate buffers using the proper sizes.
(get_all_time): Endianness.
(__gg__char): Endianness.
(__gg__formatted_current_date): Endianness.
(__gg__formatted_date): Endianness.
(__gg__formatted_datetime): Endianness.
(__gg__formatted_time): Endianness.
(change_case): Endianness.
(__gg__median): Endianness.
(numval): Endianness.
(numval_c): Endianness.
(__gg__ord): Endianness.
(__gg__trim_a): Endianness.
(__gg__numval_f): Endianness.
(__gg__test_numval_f): Endianness.
(ismatch): Endianness.
(iscasematch): Endianness.
(strstr): Endianness.
(strcasestr): Endianness.
(strlaststr): Endianness.
(strcaselaststr): Endianness.
(__gg__substitute): Endianness.
(__gg__locale_date): Endianness.
(__gg__locale_time): Endianness.
* io.cc (__compat_file_status_word): Endianness.
* libgcobol.cc (as_chars): Endianness.
(as_unsigned_chars): Endianness.
(load_unaligned): Endianness.
(store_unaligned): Endianness.
(signed_int128_max): Endianness.
(checked_realloc): Endianness.
(collated): Endianness.
(edited_to_binary): Endianness.
(native_to_binary_signed): Endianness.
(native_to_binary_unsigned): Endianness.
(digit_rt): Endianness.
(num_disp_dive_rt): Endianness.
(numeric_display_to_binary): Endianness.
(get_binary_value_local): Endianness.
(__gg__power_of_ten): Endianness.
(value_is_too_big): Endianness.
(binary_to_big_endian): Endianness.
(binary_to_native_binary): Endianness.
(int128_to_field): Endianness.
(__gg__field_from_string): Endianness.
(field_from_ascii): Endianness.
(uber_compare): Endianness.
(__gg__dirty_to_binary): Endianness.
(get_scaled_rdigits): Endianness.
(format_for_display_internal): Endianness.
(compare_88): Endianness.
(get_float128): Endianness.
(__gg__compare_field_class): Endianness.
(compare_strings): Endianness.
(__gg__compare_2): Endianness.
(__gg__double_to_target): Endianness.
(__gg__sort_table): Endianness.
(init_var_both): Endianness.
(alpha_to_alpha_move_from_location): Endianness.
(alpha_to_alpha_move): Endianness.
(__gg__move): Endianness.
(__gg__move_literala): Endianness.
(__gg__sort_workfile): Endianness.
(__gg__merge_files): Endianness.
(move_string): Endianness.
(normalize_for_inspect_format_4): Endianness.
(__gg__string): Endianness.
(display_both): Endianness.
(__gg__float128_from_qualified_field): Endianness.
(float128_to_int128): Endianness.
(float128_to_location): Endianness.
(__gg__onetime_initialization): Endianness.
(is_numeric_display_numeric): Endianness.
(classify_alphabetic_type): Endianness.
(accept_envar): Endianness.
(__gg__set_envar): Endianness.
(command_line_plan_b): Endianness.
(__gg__get_command_line): Endianness.
(__gg__set_pointer): Endianness.
(__gg__alphabet_use): Formatting.
(__gg__fetch_call_by_value_value): Eliminate.
(__gg__unstring): Endianness.
(match_declarative): Formatting.
(default_exception_handler): Formatting.
(__gg__check_fatal_exception): Endianness.
(__gg__float128_from_location): Endianness.
(__gg__adjust_encoding): Endianness.
(__gg__func_exception_file): Endianness.
(__gg__is_float_infinite): Formatting.
(__gg__float32_from_128): Endianness.
(__gg__float32_from_64): Endianness.
(__gg__float64_from_128): Endianness.
(__gg__just_mangle_name): Endianness.
(__gg__function_handle_from_name): Proper initialization.
(__gg__variables_to_init): Likewise.
(__gg__mirror_range): Formatting.
(__gg__allocate): Formatting.
(__gg__module_name): Formatting.
(__gg__set_exception_environment): Formatting.
(__gg__set_env_name): Endianness.
(__gg__set_env_value): Endianness.
(__gg__refer_from_string): Endianness.
(__gg__refer_from_psz): Endianness.
(__gg__compare_string_all): Endianness.
(__gg__compare_string_1): Endianness.
(__gg__compare_string_1a): Endianness.
(__gg__compare_string_2): Endianness.
(__gg__compare_string_2a): Endianness.
(__gg__compare_string_4): Endianness.
(__gg__compare_string_4a): Endianness.
(__gg_compare_string_different): Endianness.
(__gg__compare_numeric_all): Endianness.
(__gg__compare_binary_to_string): Endianness.
* libgcobol.h (defined): Endianness.
(COBOL_BIG_ENDIAN): Endianness.
(COBOL_LITTLE_ENDIAN): Endianness.
* stringbin.cc (__gg__binary_to_string_encoded): Endianness.
(digit_rt): Support for num_disp_dive_rt().
(num_disp_dive_rt): Recurse conversion of numeric-display to binary.
(__gg__numeric_display_to_binary): Use num_disp_dive_rt().
* stringbin.h (__gg__numeric_display_to_binary): Remove declaration.
* valconv.cc (defined): Use IN_GCC_FRONTEND to find .h files;
incorporate cobol-endian.h.
(TOUPPER): Simple toupper() routine.
(__gg__string_to_numeric_edited): Use TOUPPER.
* cobol-endian.h: New file.  Provides access to big-e versus
little-e variables and preprocessor definitions.

gcc/testsuite/ChangeLog:

* cobol.dg/group2/Assorted_SPECIAL-NAMES_CLASS.cob: Modified for
endian neutrality.
* cobol.dg/group2/Non-numeric_data_in_numeric_items__2_.out: Likewise.
* cobol.dg/group2/FUNCTION_TRIM_with_NATIONAL_characters.cob: Likewise.
* cobol.dg/group2/Hexadecimal_literal.cob: Likewise.
* cobol.dg/group2/PACKED-DECIMAL_basic_comp-3_comp-6__2_.cob: Likewise.
* cobol.dg/group2/PACKED-DECIMAL_basic_comp-3_comp-6__2_.out: Likewise.
* cobol.dg/group2/compare_national_to_display.cob: Likewise.
* cobol.dg/group2/Complex_HEX__VALUE_and_MOVE_-_UTF-16.cob: Removed.
* cobol.dg/group2/Complex_HEX__VALUE_and_MOVE_-_UTF-16.out: Removed.
* cobol.dg/group2/DISPLAY__Sign_ASCII.out: Removed.
* cobol.dg/group2/Non-numeric_data_in_numeric_items__2_.cob: Removed.
* cobol.dg/group2/DISPLAY__Sign_ASCII.cob: Removed.
* cobol.dg/group2/BINARY_and_COMP-5__little-endian_.cob: New test.
* cobol.dg/group2/BINARY_and_COMP-5__little-endian_.out: New test.
* cobol.dg/group2/Checking_IS_NUMERIC.cob: New test.
* cobol.dg/group2/Checking_IS_NUMERIC.out: New test.
* cobol.dg/group2/Non-numeric_data_in_numeric-display__1_.cob: New test.
* cobol.dg/group2/Non-numeric_data_in_packed_decimal.cob: New test.
* cobol.dg/group2/Non-numeric_data_in_packed_decimal.out: New test.
* cobol.dg/group2/Numeric-display_sign_encoding__2_.cob: New test.
* cobol.dg/group2/Numeric-display_sign_encoding__2_.out: New test.
* cobol.dg/group2/Numeric-display_sign_encoding_sanity_check.cob: New test.
* cobol.dg/group2/Numeric-display_sign_encoding_sanity_check.out: New test.

3 weeks agofortran: [PR126170] Fix LTO ICE in copy_function_or_variable
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.

3 weeks agotestsuite: Fix gcc.target/x86_64/abi tests on NetBSD
Rainer Orth [Fri, 10 Jul 2026 17:25:24 +0000 (19:25 +0200)] 
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:

commit ffc4b179a3bc254b7303d7f9ddbe3e9291851cec
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Sat Apr 25 05:10:01 2026 +0200

    testsuite: Fix gcc.target/x86_64/abi tests on FreeBSD

Tested on amd64-pc-netbsd10.1, amd64-pc-freebsd15.1, i386-pc-solaris2.11,
and x86_64-pc-linux-gnu.

2026-07-10  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
* gcc.target/x86_64/abi/ms-sysv/ms-sysv.c (long_optarg): Cast
isspace arg to unsigned char.
* gcc.target/x86_64/abi/ms-sysv/ms-sysv.exp (runtest_ms_sysv): Add
--omit-rbp-clobbers on NetBSD.

3 weeks agoc++: modules: Allow for EOPNOTSUPP error from posix_fallocate
Rainer Orth [Fri, 10 Jul 2026 17:12:55 +0000 (19:12 +0200)] 
c++: modules: Allow for EOPNOTSUPP error from posix_fallocate

All g++/modules tests SEGV on NetBSD/amd64 in a ZFS build directory.
This is similar to the FreeBSD case:

commit a94156b8ee7165c32f73f9cd11c9b8f3b8687d3b
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Tue May 5 10:23:12 2026 +0200

    c++: modules: Fix posix_fallocate error handling

However, posix_fallocate returns EOPNOTSUPP here, which is distinct from
ENOTSUP.

This patch allows for both, providing a fallback definition since
EOPNOTSUPP may be missing.

Bootstrapped without regressions on amd64-pc-netbsd10.1,
x86_64-pc-linux-gnu, and i386-pc-solaris2.11.

2026-07-08  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/cp:
* module.cc (EOPNOTSUPP): Provide fallback.
(elf_out::create_mapping) [HAVE_POSIX_FALLOCATE]: Allow for
EOPNOTSUPP result.

3 weeks agolibphobos: Disable .note.GNU-stack on NetBSD
Rainer Orth [Fri, 10 Jul 2026 17:10:16 +0000 (19:10 +0200)] 
libphobos: Disable .note.GNU-stack on NetBSD

When linking with a static libgphobos on NetBSD/amd64, gld 2.46 warns

gld-2.46: warning: /usr/lib/crtn.o: missing .note.GNU-stack section implies executable stack

This is caused by libdruntime/config/common/threadasm.S including the
note on NetBSD.  This was introduced in the original druntime repo with

commit 3d8d4a45c01832fb657c16a656b6e1566d77fb21
Author: Nikolay Tolstokulakov <tolstokulakov.n@laximo.ru>
Date:   Thu Feb 4 13:40:21 2016 +0600

    netbsd patch

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.

2026-07-05  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libphobos:
* libdruntime/config/common/threadasm.S: Don't emit
.note.GNU-stack on NetBSD.

3 weeks agoRISC-V: Don't drop multilibs matching the default march/mabi
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.

3 weeks agomatch.pd: Eliminate dead operand in vector permute and insert patterns
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:

_1 = VEC_PERM_EXPR <v_2(D), { 0, 0, 0, 0 }, { 1, 2, 3, 4 }>;
shifted_4 = BIT_INSERT_EXPR <_1, val_3(D), 96 (32 bits)>;

On AArch64, GCC currently generates:

movi    v31.4s, 0
ext     v0.16b, v0.16b, v31.16b, #4
ins     v0.s[3], w0

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.

gcc/testsuite/ChangeLog:

* gcc.dg/fold-vecperm-insert-1.c: New test.

3 weeks agolibstdc++: Fix typos in comment in start_lifetime_as/neg.cc.
Tomasz Kamiński [Fri, 10 Jul 2026 14:27:34 +0000 (16:27 +0200)] 
libstdc++: Fix typos in comment in start_lifetime_as/neg.cc.

Fix typos in comment pointed by Jakub and remove trailing
whitespaces.

libstdc++-v3/ChangeLog:

* testsuite/std/memory/start_lifetime_as/neg.cc: Fix
typos in comment and remove trailing whitespaces.

3 weeks agocobol: Replace NUL input with space, with diagnostic.
James K. Lowden [Thu, 9 Jul 2026 19:36:50 +0000 (15:36 -0400)] 
cobol: Replace NUL input with space, with diagnostic.

Old-school COBOL input may embed NUL characters in alphanumeric
literals. GNU Flex unfortunately treats NUL as end-of-file marker.

Detect the situation in the lexio file-reader.  Replace NUL with
SPACE, increment error count, and emit message. Fixes RT 3622.

* lexio.h (parse_error_inc): Declare function.
(struct filespan_t::next_line): Detect and remove NUL,

3 weeks ago[PATCH] match: Use tree_expr_nonnegative_p for (X / Y) (==, !=) 0 -> X (<,>=) Y ...
Kael Andrew Franco [Fri, 10 Jul 2026 14:28:13 +0000 (08:28 -0600)] 
[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.

Bootstrapped and tested on x86_64-pc-linux-gnu.

PR tree-optimization/125738
PR tree-optimization/64130

gcc/ChangeLog:

* match.pd: Use tree_expr_nonnegative_p for (X / Y) (==,!=) 0 -> X (<,>=) Y.

gcc/testsuite/ChangeLog:

* gcc.dg/pr125738.c: New test.
* gcc.dg/tree-ssa/pr64130.c: Remove scan-tree-dump [2, 8589934591].
(funsigned): Remove.
(funsigned2): Rename to funsigned.

Signed-off-by: Kael Franco <kaelfandrew@gmail.com>
3 weeks ago[PATCH] gm2,sel-sched-ir: Remove Unused Declarations from GCC.
Léo Hardt [Fri, 10 Jul 2026 14:17:37 +0000 (08:17 -0600)] 
[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:

   https://gcc.gnu.org/legacy-ml/gcc/2010-05/msg00688.html

   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.

Bootstrapped successfully on my machine.

gcc/m2/ChangeLog:

* plugin/m2rte.cc: Removed unused extern bool
ggc_force_collect.

gcc/ChangeLog:

* sel-sched-ir.cc (struct succs_info): Removed
unused variable current_succs.

3 weeks agolibstdc++: Fix Cylindrical Bessel functions for infinity [PR119143]
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>
3 weeks agolibstdc++: Adjust error handling for filesystem::read_symlink on Windows
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>