AVR: Add 64-bit fixed-point multiplications to libgcc.
This patch adds (un)saturated 64-bit fixed-point multiplications
to libgcc. The saturating functions are just aliases of the
vanilla versions, which are also saturating.
Roger Sayle [Tue, 21 Jul 2026 08:45:15 +0000 (09:45 +0100)]
i386: Split DI<->V2DI patterns before reload with -m32.
While investigating improvements to x86's stv2 pass (to correctly cost
moves between SI<->V4SI and DI<->V2DI), I noticed that we're currently
relatively inefficient for DI mode transfers on 32-bit targets with
SSE2, where reload ultimately decides to perform these moves via the
stack. It's possible to do better by making the highpart and lowpart
registers explicit before reload.
Consider the test case below:
typedef long long v2di __attribute__ ((__vector_size__ (16)));
long long foo(v2di x)
{
return x[0];
}
long long ext();
v2di mem;
void bar()
{
long long x = ext();
mem = (v2di){x,0};
}
where foo tests V2DI->DI mode, and bar tests DI->V2DI mode.
Currently -m32 -O2 -msse2 generates:
bar: subl $12, %esp
call ext
movd %eax, %xmm0
movd %edx, %xmm1
punpckldq %xmm1, %xmm0
movaps %xmm0, mem
addl $12, %esp
ret
2026-07-21 Roger Sayle <roger@nextmovesoftware.com>
Uros Bizjak <ubizjak@gmail.com>
gcc/ChangeLog
* config/i386/sse.md (define_split): Split *vec_extractv2di_0_sse
before reload on !TARGET_64BIT with TARGET_SSE2.
(define_split): Likewise split *vec_concatv2di_0 before reload
on !TARGET_64BIT with TARGET_SSE2.
gcc/testsuite/ChangeLog
* gcc.target/i386/sse2-stv-7.c: New test case.
* gcc.target/i386/sse4_1-stv-13.c: Likewise.
Tomasz Kamiński [Mon, 20 Jul 2026 09:53:48 +0000 (11:53 +0200)]
libstdc++: Introduce GLIBCXX_3.4.37 version for symbols not backported to GCC-16.
As part of the backport of r17-471-ge79f0f818c0e42 and r17-2193-g50cbacfaa1e776),
the corresponding exports of chrono::__detail::__recent_leap_second_info and
specializations of basic_format_arg::_M_handle_unrecognized also need to be
introduced. This also require bump of the libtool_VERSION to 3.4.36.
This patch bumps version again to 3.4.37 and moves remaining symbols defined
in GCC 17 (basic_string's _S_allocate_at_least and _M_create_plus) to it.
libstdc++-v3/ChangeLog:
* acinclude.m4 (libtool_VERSION): Bump version.
* config/abi/pre/gnu.ver (GLIBCXX_3.4.37): Add new symbol
version and move basic_string's _S_allocate_at_least and
_M_create_plus symbols to it.
* config/abi/post/x86_64-linux-gnu/baseline_symbols.txt:
Regenerate and include new 3.4.36 symbols.
* config/abi/post/powerpc64le-linux-gnu/baseline_symbols.txt:
Likewise.
* configure: Regenerate.
* testsuite/util/testsuite_abi.cc: Update known_versions
and latestp.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
H.J. Lu [Wed, 13 May 2026 00:27:50 +0000 (08:27 +0800)]
x86: Don't set cum->preserve_none_abi for x86-64 MS calls
In 64-bit mode, preserve_none attribute uses the same number of integer
parameters passed in registers as SYSV ABI, but with a different set of
6 registers, by setting cum->preserve_none_abi to true. Don't set
cum->preserve_none_abi to true for MS ABI functions with preserve_none
attribute to keep the number of integer parameters passed in registers
unchanged as 4. This treats preserve_none attribute the same way as
no_callee_saved_registers attribute for MS ABI functions.
gcc/
PR target/125297
* config/i386/i386.cc (init_cumulative_args): Don't set
cum->preserve_none_abi to true for MS ABI functions.
* doc/extend.texi: Update x86-64 preserve_none attribute
documentation.
Jakub Jelinek [Mon, 20 Jul 2026 21:32:40 +0000 (23:32 +0200)]
c++: implement CWG3020 - Missing specification for __has_cpp_attribute(indeterminate) [PR126309]
The paper which introduced indeterminate attribute has not added a value
for __has_cpp_attribute, so I've missed it and didn't add it to
c_common_has_attribute. Later CWG issue fixed this up.
chris hermansen [Mon, 20 Jul 2026 16:42:15 +0000 (18:42 +0200)]
a68: new version of proc whole, dependencies and test
A replacement for proc whole provided in the Revised Report on p.159.
Several factors motivated me to propose this replacement for the RR code.
Most importantly, the RR whole fails for an argument value of -max_int - 1, as
well as any short short, short, long or long long equivalents, because the RR
version applies the operator ABS to the argument, and on any hardware using
twos-complement representation, ABS (-max_int - 1) cannot provide a correct
positive value. This replacement code does not apply ABS to the argument and
is therefore immune to this problem.
As well, replacement works on the argument from left to right, rather than
right to left (the approach taken in the RR version). Working from left to
right in this way requires either:
- processing all 10 digits (speaking of 32 bit integers for the time being),
meaning worthless effort for every leading zero digit, or
- determining how many significant digits there are, which means some lookup
code (I believe this is faster but I haven't benchmarked it at this point)
Having determined beforehand how many significant digits there are, we can
allocate a working buffer of exactly the right length, which eliminates:
- the (expensive) digit-by-digit string concatenation approach used in the RR
version
- the need to always ensure a long-enough fixed-length buffer should GNU Algol
68 begin to support longer integers (128, 256, whatever)
- the need to trim a fixed-length buffer to the desired length once the
converted integer is in place
Finally, working left to right
- eliminates the need to apply ABS to the number to be converted, as noted
previously, thereby eliminating the dependency on ABS
- replaces one (expensive) integer division with one (less expensive)
integer multiplication using a looked-up power of 10
van Vliet's proposed whole and subwhole are more efficient than the RR version,
but still depend on ABS delivering a correct value.
Included with this replacement proc whole is a test program to ensure that the
correct results for the extreme values are produced, along with a set of
randomly chosen other values distributed across the range.
Signed-off-by: Chris Hermansen <clhermansen@gmail.com>
libga68/ChangeLog
* standard.a68.in (Integer): New mode.
(whole_max_entry): New variable.
(whole_p10): Likewise.
(whole_stop_after): Likewise.
(whole_powers_of_10): Likewise.
(WHOLEDIGITS): New operator.
(whole): Rewrite.
(subwhole): Likewise.
bpf: TARGET_RTX_COSTS: treat 32-bit CONST_INT as cheap/free
This is to prefer constant return to be setup from imm constant vs.
using a prior reg known to have the same value (by control flow analysis).
While there's nothing wrong with existing approach, it can sometimes leads
to additional sign-extensions and other corner cases which trip up the
bpf kernel verifier bounds checking for return reg.The verifier improvements
are being worked on but lets adjust the cost model anyways so that constants
are favored. There's no additional overhead from new codegen anyways.
* config/bpf/bpf.cc (bpf_rtx_costs): set CONST_INT 0 insns.
* config/bpf/bpf.h (BPF_IMM32_P): New helper macro.
* config/bpf/predicates.md (imm32_operand): Use new macro.
gcc/testsuite/ChangeLog:
* gcc.target/bpf/const-cost-model.c: New test prefers const.
* gcc.target/bpf/const-cost-model-2.c: New test prefers const.
The default cost of MULT/DIV/MOD in rtx_cost () is high: 5,7 insns
respectively. This causes even a trivial mpy by 7 to be synthesized.
Given these have direct equivalents in BPF ISA, fix the cost to generate
native BPF insns.
Note the existing divmod-licall-2.c test was a bit fragile as it forced
cast signed an actual unsigned int which is provably non-negative.
In the new cost model compiler would generate a native unsigned divide
even though it not available for -mcpu=v3, tripping up the test.
Fix by ensuring the arg is actually signed.
Robert Dubner [Mon, 20 Jul 2026 17:17:25 +0000 (13:17 -0400)]
cobol: Insert "Do not edit" text into generated DejaGNU tests.
The tests in gcc/testsuite/cobol.dg/group2 are created by a script from a
larger set of autotest tests. After a brief comedy of procedural errors, we
decided to incorporate "Do not edit" comments into those tests.
Jakub Jelinek [Mon, 20 Jul 2026 17:27:23 +0000 (19:27 +0200)]
passes: Make gcc buildable again with mawk <= 1.3.3
On Wed, Jul 15, 2026 at 12:49:50PM -0400, Nathan Sidwell wrote:
> Fair enough, I committed this
Unfortunately it seems some versions of Debian/Ubuntu use mawk instead
of gawk by default, and mawk pretends to be POSIX compatible, but at least
versions <= 1.3.3 didn't support POSIX character classes.
We don't really need the various UTF-8 fancy blanks, and even this very
own script already uses sub(/^[ \t]*/, "", arg3); elsewhere, so this
patch just replaces [[:blank:]] with [ \t].
2026-07-20 Jakub Jelinek <jakub@redhat.com>
* gen-pass-instances.awk: Use [ \t] instead of [[:blank:]]
for compatibility with mawk <= 1.3.3.
Mikael Morin [Wed, 15 Jul 2026 15:29:38 +0000 (17:29 +0200)]
fortran: Use the setter to update the descriptor data field
A MODIFY_EXPR was generated manually using the data reference returned by
the getter. Just use the setter instead. Fixed in two different places.
gcc/fortran/ChangeLog:
* trans-expr.cc (gfc_conv_class_to_class): Use the data setter
instead of generating a MODIFY_EXPR of the result of the data
getter.
* trans-intrinsic.cc (conv_intrinsic_move_alloc): Likewise.
Fortran, OpenMP: Consolidate iterator group start/finish code
This patch consolidates some repetitive code from gfc_trans_omp_clauses
into new functions, and adds some comments. There are no functional
changes.
gcc/fortran/ChangeLog
* trans-openmp.cc (handle_iterator): Add comments. Rename
iter_block parameter to outer_block, since that's what's actually
being passed; the start/end/step expressions are outside the scope
of the iterator variables.
(start_iterator_group, finish_iterator_group): New functions,
broken out from...
(gfc_trans_omp_clauses): ...here.
Alex Coplan [Fri, 17 Jul 2026 17:40:52 +0000 (18:40 +0100)]
aarch64: Fix up TME deprecation warning
This is a follow-up patch to Richard E's r17-2498-g17f084306c68c4 (#186
on the Forge). As Alice pointed out in her review:
https://gcc.gnu.org/pipermail/gcc-patches/2026-July/724391.html
the original patch missed things like +memtag+tme due to the string
parsing approach. This instead just inspects the parsed feature flags
from aarch64_parse_extension to determine whether to warn in the target
attribute/pragma case.
+tme on the command line is handled as per Richard's original patch (no
change there).
gcc/ChangeLog:
* config/aarch64/aarch64.cc (aarch64_handle_attr_isa_flags):
Warn if +tme is enabled by the target attribute/pragma, relying
on the feature flags from aarch64_parse_extension.
(aarch64_process_target_attr): Drop +tme warning based on custom
string parsing.
testsuite: arm: remove xfail for MVE, NEON and thumb1 [PR124364]
On MVE or NEON capable targers and thumb1 targets, I see these:
XPASS: gcc.dg/Wstringop-overflow-47.c pr97027 (test for warnings, line 72)
XPASS: gcc.dg/Wstringop-overflow-47.c pr97027 (test for warnings, line 77)
XPASS: gcc.dg/Wstringop-overflow-47.c pr97027 note (test for warnings, line 68)
Replace the 5-argument OMPT dispatch builtins and libgomp implementations
(niter, start, incr, chunk_size, istart) with a 2-argument form (start,
iterations) describing the chunk actually being dispatched, which is all the
information OMPT needs.
GOMP_scope_start is emitted only for task reductions without -fopenmp-ompt
(unchanged). With -fopenmp-ompt, both GOMP_scope_start_with_end and
GOMP_scope_end are emitted, whether a task reduction is specified or not.
gcc/ChangeLog:
* omp-builtins.def (BUILT_IN_GOMP_SCOPE_START_WITH_END): New
builtin.
(BUILT_IN_GOMP_SCOPE_END): Likewise.
* omp-low.cc (lower_omp_scope): Emit calls to
GOMP_scope_start_with_end and GOMP_scope_end when -fopenmp-ompt.
libgomp/ChangeLog:
* libgomp.map: Add GOMP_scope_start_with_end and GOMP_scope_end.
* libgomp_g.h (GOMP_scope_start_with_end): Declare.
(GOMP_scope_end): Likewise.
* scope.c (GOMP_scope_start_with_end): New function.
(GOMP_scope_end): New stub.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/scope-7.c: New test.
* c-c++-common/gomp/scope-8.c: New test.
testsuite: skip test for targets that can deref null [PR126261]
As arm-none-eabi targets might have readable memory at address 0,
g++.dg/torture/pr101373.C test will "work" on some targets, while others
might tigger a fault. To avoid the ambiguity, lets skip the test if
target allows null to be dereferenced.
testsuite: arm: xfail crypto tests for -mthumb -mfloat-abi=hard [PR124043]
In r15-1579-g792f97b44ffc5e, a new late-combine pass was introduced that
changes the generated assembler from
ldr r3, [sp]
vdup.32 q8, r3
to
vld1.32 {d16[], d17[]}, [sp]
with -mthumb -mfloat-abi=hard. Due to this changed, the check
Here we have a redundant sign extension and inefficient address arithmetic.
This can be simplified into two instructions, a load and a return.
The lw insn is already doing a sign extension from 32 to 64 bits, making
the separate sext.w unnecessary. Adding a copy of the pattern that
explicitly shows the sign extension in the RTL, with the modes adjusted
accordingly, no longer emits the sext.w insn. I also generalized the pattern to
support both sign and zero extension. These changes have been reflected
on the total store ordering memory consistency model as well. As Zalrsc
doesn't support zero extending load-acquire instructions, I introduced a new
iterator, ensuring zero extend is limited to !TARGET_ZALRSC for load.
The addi and lw are combined into lw a0,4(a5) by adjusting the memory
operand constraint to handle offsets in the load patterns. The validity of
the memory operand constraint depends on the value of operand 2 - the
memory model. I introduced new constraint alternatives, such that the
behavior of the memory operand constraint is triggered on whether the
memory model acquire is being used or not and the Zalrsc or non-Zalrsc
targets accordingly. Similar changes were made for the store patterns
where the inefficient address arithmetic problem was also present.
PR target/124741
gcc/
* config/riscv/constraints.md (B1, B2, B3, B4): New constraints for
atomic loads with and without ZALASR & MEMMODEL_ACQUIRE.
* config/riscv/iterators.md (cond_extend): New iterator to for use
in extending atomic loads.
* config/riscv/sync-rvwmo.md (atomic_load_rvwmo<mode>): Adjust
contraints to enable folding small offsets into memory load.
(atomic_store_rvwmo): Likewise.
(extending atomic_load_rvwmo): New pattern.
* config/riscv/sync-ztso.md (atomic_load_ztso<mode>): Adjust
constraints to enable folding small offsets into memory load.
(atomic_store_ztso): Likewise.
(extending atomic_load_ztso): New pattern.
gcc/testsuite/
* gcc.target/riscv/load-zalasr.c: Testcases for atomic load compiled
with rv64 and zalasr ext.
* gcc.target/riscv/load.c: Testcases for atomic load compiled with
rv64.
* gcc.target/riscv/load32-zalasr.c: Testcases for atomic load
compiled with rv32 and zalasr ext.
* gcc.target/riscv/load32.c: Testcases for atomic load compiled with
rv32.
* gcc.target/riscv/store-zalasr.c: Testcases for atomic store
compiled with rv64 and zalasr ext.
* gcc.target/riscv/store.c: Testcases for atomic store compiled
with rv64.
* gcc.target/riscv/store32-zalasr.c: Testcases for atomic store
compiled with rv32 and zalasr ext.
* gcc.target/riscv/store32.c: Testcases for atomic store compiled
with rv32.
Co-authored-by: Jeff Law <jeffrey.law@oss.qualcomm.com>
When two adjacent Zone lines have different total offsets and the
new line's rule set has a rule firing within jump of the boundary
(where jump = old_total - new_total > 0, i.e. local time goes
backward at the boundary), zic folds that rule into the boundary
itself: the single transition emitted has the rule's save value
already applied, so the new line begins with the post-rule save
rather than briefly using the pre-rule save and then transitioning
again moments later.
Canonical examples handled by the new merge block:
* America/Argentina/Buenos_Aires 1999-10-03: lines change
stdoff -3 → -4 with an Argentina DST rule firing on the same
day. Without the merge, chrono emits a 1-hour stretch of
offset=-4 save=0 and then transitions to offset=-3 save=1;
with the merge, the boundary itself is at offset=-3 save=1.
* Europe/Berlin 1945-05-24: lines split a rule set, with the
So 1945-May-24 rule (save=2, "CEMT") firing at 01:00 UTC in
the new frame, inside the 1h backward window.
Similarly, when the zone expansion algorithm is resumed after DST
span (save = 1h), we will revisit the corresponding STD transition,
for example: given offset +2h, the transition happening at 12:00
local time, will be considered twice:
* 09:00 UT (2h + 1h) - proper ending of DST span
* 10:00 UT (2h) - after re-entry.
Previously this transition were rejected using the (now removed)
rule_start - t < days(1) check, preventing us from emitting the one
hour STD time range followed by rest of same range. In this patch,
we reuse same merge logic, as such STD transition happens during
backward jump from boundary introduced by previous expansion.
This patch address both of the above by computing length of the
backward jump (merge_window) at the start of the expansion (regardless
if initial or re-entry), and then considering initial rule transition
happening in [info.begin + merge_window] to apply at info.begin.
libstdc++-v3/ChangeLog:
PR libstdc++/124854
* src/c++20/tzdb.cc (ZoneInfo::save): Define.
(time_zone::_M_get_sys_info): Fold initial transition if they
occurs in duplicated local time window (merge_window) due move
from DST to STD zone.
* testsuite/std/time/time_zone/wall_cascade.cc (test_next_year):
Test that 1945 Pacific/Auckland transition is properly handled.
(test_negative): Adjust test to avoid zone merge.
* testsuite/std/time/time_zone/zone_merge.cc: New test.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Co-authored-by: Álvaro Begué <alvaro.begue@gmail.com> Signed-off-by: Álvaro Begué <alvaro.begue@gmail.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Mikael Morin [Mon, 20 Jul 2026 09:09:33 +0000 (11:09 +0200)]
fortran: array descriptor: Rename dim subfields internal accessors [PR122521]
Drop the gfc prefix from the internal function giving access to the lbound,
ubound, and stride fields. This aligns the function names with the rest of
the compiler dropping the prefix for static functions.
Mikael Morin [Mon, 20 Jul 2026 09:09:22 +0000 (11:09 +0200)]
fortran: array descriptor: Add a setter for the token field [PR122521]
Add a setter function to set the value of the token field of array
descriptors.
Contrary to the preceding patches touching the other fields, this one
doesn't create a getter and retains direct access to the field. Indeed,
token is special because its address is taken and passed to library
functions to implement coarray behaviour.
PR fortran/122521
gcc/fortran/ChangeLog:
* trans-descriptor.cc (gfc_conv_descriptor_token_set): New function.
* trans-descriptor.h (gfc_conv_descriptor_token_set): New
declaration.
* trans-array.cc (gfc_conv_expr_descriptor,
gfc_conv_array_parameter, gfc_trans_deferred_array): Use
gfc_conv_descriptor_token_set to set the value of the token.
* trans-expr.cc (gfc_conv_derived_to_class,
gfc_trans_subcomponent_assign, gfc_trans_scalar_assign): Likewise.
* trans-intrinsic.cc (conv_intrinsic_move_alloc): Likewise.
Mikael Morin [Mon, 20 Jul 2026 09:09:11 +0000 (11:09 +0200)]
fortran: array descriptor: Remove access to dim field elements [PR122521]
Remove from the public API the function giving direct acces to individual
dimension descriptors. Another function remains giving access to the full
array of dimension descriptors.
PR fortran/122521
gcc/fortran/ChangeLog:
* trans-descriptor.cc (gfc_conv_descriptor_dimension): Make static
and rename ...
(conv_descriptor_dimension): ... to this.
(gfc_conv_descriptor_subfield): Update caller.
* trans-descriptor.h (gfc_conv_descriptor_dimension): Remove
declaration.
Mikael Morin [Mon, 20 Jul 2026 09:08:51 +0000 (11:08 +0200)]
fortran: array descriptor: Add accessors for the dtype field [PR122521]
Use accessor functions to get or set the dtype field of array descriptors
and remove from the public API the function giving direct acces to the
field.
PR fortran/122521
gcc/fortran/ChangeLog:
* trans-descriptor.cc (gfc_conv_descriptor_dtype): Make static and
rename ...
(conv_descriptor_dtype): ... to this.
(conv_descriptor_rank conv_descriptor_version,
conv_descriptor_elem_len, gfc_conv_descriptor_attribute,
conv_descriptor_type): Update callers.
(gfc_conv_descriptor_dtype_get, gfc_conv_descriptor_dtype_set):
New functions.
* trans-descriptor.h (gfc_conv_descriptor_dtype): Remove
declaration.
(gfc_conv_descriptor_dtype_get, gfc_conv_descriptor_dtype_set):
New declarations.
* trans-array.cc (gfc_trans_create_temp_array, gfc_array_init_size,
gfc_conv_expr_descriptor, gfc_resize_assumed_rank_dim_field,
gfc_conv_array_parameter, structure_alloc_comps,
gfc_alloc_allocatable_for_assignment, gfc_trans_class_array,
gfc_trans_deferred_array): Use gfc_conv_descriptor_dtype_get to get
the value of the dtype field and gfc_conv_descriptor_dtype_set to
update it.
* trans-decl.cc (gfc_conv_cfi_to_gfc): Likewise.
* trans-expr.cc (gfc_conv_scalar_to_descriptor,
gfc_class_array_data_assign, gfc_conv_derived_to_class,
gfc_conv_class_to_class, set_dtype_for_unallocated,
gfc_trans_pointer_assignment, fcncall_realloc_result): Likewise.
* trans-intrinsic.cc (conv_isocbinding_subroutine): Likewise.
* trans-stmt.cc (trans_associate_var): Likewise.
Mikael Morin [Mon, 20 Jul 2026 09:08:40 +0000 (11:08 +0200)]
fortran: array descriptor: Add accessors for the type field [PR122521]
Add accessor functions to get or set the value of the type field of array
descriptors, and remove from the public API the function giving direct acces
to the field.
PR fortran/122521
gcc/fortran/ChangeLog:
* trans-descriptor.cc (get_type_field): New function.
(gfc_get_descriptor_field): Use it.
(gfc_conv_descriptor_type): Make static and rename ...
(conv_descriptor_type): ... to this.
(gfc_conv_descriptor_type_get, gfc_conv_descriptor_type_set): New
functions.
* trans-descriptor.h (gfc_conv_descriptor_type): Remove declaration.
(gfc_conv_descriptor_type_get, gfc_conv_descriptor_type_set): New
declarations.
* trans-expr.cc (gfc_conv_gfc_desc_to_cfi_desc): Use
gfc_conv_descriptor_type_get to get the value of the type field.
* trans-decl.cc (gfc_conv_cfi_to_gfc): Use
gfc_conv_descriptor_type_set to set the value of the type field.
Mikael Morin [Mon, 20 Jul 2026 09:08:29 +0000 (11:08 +0200)]
fortran: array descriptor: Add accessors for the rank field [PR122521]
Add accessor functions to get or set the value of the rank field of array
descriptors, and remove from the public API the function giving direct acces
to the field.
PR fortran/122521
gcc/fortran/ChangeLog:
* trans-descriptor.cc (gfc_conv_descriptor_rank): Make static and
rename ...
(conv_descriptor_rank): ... to this.
(gfc_conv_descriptor_rank_get, gfc_conv_descriptor_rank_set): New
functions.
* trans-descriptor.h (gfc_conv_descriptor_rank): Remove declaration.
(gfc_conv_descriptor_rank_get, gfc_conv_descriptor_rank_set): New
declarations.
* trans-array.cc (gfc_trans_create_temp_array,
gfc_conv_ss_startstride, gfc_tree_array_size,
gfc_resize_assumed_rank_dim_field, gfc_conv_array_parameter,
gfc_full_array_size, duplicate_allocatable_coarray): Use
gfc_conv_descriptor_rank_get to get the value of the rank field,
and gfc_conv_descriptor_rank_set to set it.
* trans-decl.cc (gfc_conv_cfi_to_gfc): Likewise.
* trans-expr.cc (gfc_conv_derived_to_class, gfc_conv_variable,
gfc_conv_gfc_desc_to_cfi_desc, conv_null_actual,
gfc_trans_structure_assign): Likewise.
* trans-intrinsic.cc (gfc_conv_intrinsic_rank,
gfc_conv_intrinsic_bound, gfc_conv_intrinsic_sizeof,
gfc_conv_associated): Likewise.
* trans-openmp.cc (gfc_omp_get_array_size): Likewise.
* trans-stmt.cc (gfc_trans_select_rank_cases): Likewise.
Mikael Morin [Mon, 20 Jul 2026 09:08:15 +0000 (11:08 +0200)]
fortran: array descriptor: Add accessors for the version field [PR122521]
Add accessor functions to get or set the value of the version field of array
descriptors, and remove from the public API the function giving direct acces
to the field.
PR fortran/122521
gcc/fortran/ChangeLog:
* trans-descriptor.cc (gfc_conv_descriptor_version): Make static and
rename ...
(conv_descriptor_version): ... to this.
(gfc_conv_descriptor_version_get, gfc_conv_descriptor_version_set):
New functions.
* trans-descriptor.h (gfc_conv_descriptor_version): Remove
declaration.
(gfc_conv_descriptor_version_get, gfc_conv_descriptor_version_set):
New declarations.
* trans.cc (gfc_deallocate_with_status): Use
gfc_conv_descriptor_version_get to get the value of the version
field, and gfc_conv_descriptor_version_set to set it.
* trans-array.cc (gfc_array_allocate, structure_alloc_comps,
gfc_alloc_allocatable_for_assignment): Likewise.
Mikael Morin [Mon, 20 Jul 2026 09:07:59 +0000 (11:07 +0200)]
fortran: array descriptor: Add accessors for the elem_len field [PR122521]
Add accessor functions to get or set the value of the elem_len field of
array descriptors, and remove from the public API the function giving direct
acces to the field.
PR fortran/122521
gcc/fortran/ChangeLog:
* trans-descriptor.cc (gfc_conv_descriptor_elem_len): Make static
and rename ...
(conv_descriptor_elem_len): ... to this.
(gfc_conv_descriptor_elem_len_get,
gfc_conv_descriptor_elem_len_set): New functions.
* trans-descriptor.h (gfc_conv_descriptor_elem_len): Remove
declaration.
(gfc_conv_descriptor_elem_len_get,
gfc_conv_descriptor_elem_len_set): New declarations.
* trans-decl.cc (gfc_conv_cfi_to_gfc): Use
gfc_conv_descriptor_elem_len_get to get the value of the elem_len
field and gfc_conv_descriptor_elem_len_set to set it.
* trans-array.cc (gfc_array_init_size,
gfc_alloc_allocatable_for_assignment): Likewise.
* trans-expr.cc (gfc_conv_scalar_to_descriptor,
gfc_conv_gfc_desc_to_cfi_desc, gfc_trans_pointer_assignment):
Likewise.
* trans-intrinsic.cc (gfc_conv_is_contiguous_expr,
gfc_conv_intrinsic_sizeof): Likewise.
* trans-openmp.cc (gfc_omp_array_size, gfc_omp_deep_mapping_item):
Likewise.
Mikael Morin [Mon, 20 Jul 2026 09:07:41 +0000 (11:07 +0200)]
fortran: array descriptor: Use the setter to modify the offset [PR122521]
Use the setter function to generate code modifying the array descriptor
offset and remove from the public API the function giving direct access to
that field.
PR fortran/122521
gcc/fortran/ChangeLog:
* trans-descriptor.cc (gfc_conv_descriptor_offset): Make static and
rename ...
(conv_descriptor_offset): ... to this.
(gfc_conv_descriptor_offset_get,
gfc_conv_descriptor_offset_set): Update callers.
* trans-descriptor.h (gfc_conv_descriptor_offset): Remove
declaration.
* trans-array.cc (gfc_alloc_allocatable_for_assignment): Use the
setter function to generate a modification of the array descriptor
offset.
Tomasz Kamiński [Mon, 20 Jul 2026 07:10:57 +0000 (09:10 +0200)]
libstc++: Use standard FLT_EVAL_METHOD in piecewise distributions tests.
libstdc++-v3/ChangeLog:
* testsuite/26_numerics/random/piecewise_constant_distribution/operators/serialize2.cc:
Include <cfloat> and use FLT_EVAL_METHOD instead of
__FLT_EVAL_METHOD__.
* testsuite/26_numerics/random/piecewise_linear_distribution/operators/serialize2.cc:
Likewise.
Fortran/OpenMP: Add parsing support for spatial dimensions
Adds 'dim(...)' modifier parsing for spatial dimensions to the num_teams,
thread_limit, and num_threads clauses.
Add strict + relaxed modifier support to the thread_limit and num_threads
clauses. [For teams, the effect of strict/relaxed is provided by the
lower_bound feature.]
For num_threads, support specifying multiple values - to be applicable
for nested parallel constructs.
NOTE: All added features (but 'relaxed') will fail after parsing with
a 'sorry, unimplemented' as only the parsing support has been added and
not the actual feature.
gcc/fortran/ChangeLog:
* dump-parse-tree.cc (show_omp_clauses): Handle spatial dimension
in num_teams and it and strict/relaxed in thread_limits and
num_threads.
* trans-openmp.cc (gfc_trans_omp_clauses, gfc_split_omp_clauses,
gfc_trans_omp_target): Likewise.
* openmp.cc (gfc_free_omp_clauses, gfc_match_omp_clauses,
resolve_omp_clauses): Likewise.
(match_omp_oacc_expr_list): Return current locus for a parse
fail instead of resetting the locus.
* gfortran.h (gfc_omp_clauses): Changed gfc_expr num_threads,
num_teams_lower, num_teams_upper, and thread_limit to
gfc_expr_list num_threads_list, num_teams_list, and thread_limit_list.
Add thread_limit_strict, num_threads_strict, num_teams_dims,
thread_limit_dims, and num_threads_dims.
* frontend-passes.cc (gfc_code_walker): Update for this change.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/spatial-dimensions-1.f90: New test.
* gfortran.dg/gomp/spatial-dimensions-2.f90: New test.
* gfortran.dg/gomp/spatial-dimensions-3.f90: New test.
Tomasz Kamiński [Fri, 17 Jul 2026 19:14:42 +0000 (21:14 +0200)]
libstdc++: Fix condition for stopping lazy zone expansion [PR116110]
At indicated by the pre-existing comment, the lazy zone expansion can be
only resumed from STD (save == 0) zone. However, the current condition
for stopping on DST (save != 0) doesn't ensure that, as some rule specify
transitions between DST zones. For example August 1945 of Y rule used by
America/Dawson only change letters:
Y 1942 o - F 9 2 1 W
Y 1945 o - Au 14 23u 1 P
This patch correct the condition, by using next_rule (i.e. one applying
after last expanded zone): either there is no zone (last expanded range)
or it have save zero.
libstdc++-v3/ChangeLog:
PR libstdc++/116110
* src/c++20/tzdb.cc (time_zone::_M_get_sys_info): Correct
condition for stopping zone expansion before STD zone.
* testsuite/std/time/time_zone/116110.cc (test_dawson):
Add test for America/Dawson August 1945 transition.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Tomasz Kamiński [Fri, 17 Jul 2026 11:21:39 +0000 (13:21 +0200)]
libstdc++: Prevent overflow in find_active_rule to_local conversion. [PR116110]
As when member of Transitions::Entries that do not correspond
to rule activation (rule is empty) is either minimum or maximum
value of sys_seconds, adjusting it to std_offset lead to overflow
(and UB). In practice this caused next.when to have very low value,
and thus considered to be active rule. The to_local conversion now
return local_seconds constucted directly from time_since_epoch
(i.e. minimum and maximum).
In consequence above, the save was still not applied for zones
that specified UNTIL after firing of last rule, that also have
non zero save (e.g. Asia/Bishkek 2005 transition).
libstdc++-v3/ChangeLog:
PR libstdc++/116110
* src/c++20/tzdb.cc (find_active_rule::to_local): Do not
modify min/max values for rules.
* testsuite/std/time/time_zone/wall_cascade.cc: Add test
for last_transition.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Pan Li [Sun, 19 Jul 2026 09:25:21 +0000 (17:25 +0800)]
RISC-V: Add test cases for vfwcvt.f.f.v reg overlap
Add test cases for vfwcvt.f.f.v register group overlap, please
note it is not overlap as much as possible.
Signed-off-by: Pan Li <pan2.li@intel.com>
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_f-f16-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_f-f16-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_f-f16-m4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_f-f16-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_f-f16-mf4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_f-f32-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_f-f32-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_f-f32-m4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_f-f32-mf2.c: New test.
Philipp Tomsich [Sun, 19 Jul 2026 16:26:41 +0000 (18:26 +0200)]
match.pd: Make the (trunc)copysign(extend x, extend y) vector-safe [PR126291]
The (convert (copysigns (convert@2 @0) (convert @1))) rules evaluate
TYPE_PRECISION on the outer and inner types after only types_match, so
a vectorized copysign chain like
trips the vector_type tree check while gimple_simplify evaluates the
guard (the ICE does not require the precision test to hold: evaluating
TYPE_PRECISION on a vector type is what triggers it).
Use element_precision, mirroring the abs fix. No equivalent of the
target_supports_op_p check is needed here, since the existing
direct_internal_fn_supported_p guard already handles vector types
correctly.
The REAL_CST variant cannot match vectors (a vector constant is a
VECTOR_CST), but is converted as well for consistency.
Bootstrapped and regtested on x86_64-pc-linux-gnu.
Philipp Tomsich [Thu, 16 Jul 2026 04:45:03 +0000 (06:45 +0200)]
match.pd: Make the (trunc)abs(extend x) guard vector-safe [PR126291]
The (convert (abs (convert@1 @0))) -> (abs @0) rule added by r17-2276-ge2c4fc6b1cff evaluates TYPE_PRECISION on the outer and inner types
after only types_match, so a vectorized abs-of-narrowed chain like
trips the vector_type tree check when gimple_simplify visits the
outer conversion (ICE during fre). Use element_precision
so the guard is evaluable for vectors, and require target support
for ABS on the narrow vector type before enabling the transform
there.
Bootstrapped and regtested on aarch64-unknown-linux-gnu, x86_64-pc-linux-gnu
and riscv64-unknown-linux-gnu.
PR tree-optimization/126291
gcc/ChangeLog:
* match.pd ((trunc)abs (extend x) -> abs (x)): Use
element_precision. Require target ABS support for the
vector case.
Thomas Koenig [Sun, 19 Jul 2026 14:17:28 +0000 (16:17 +0200)]
Showing ALLOCATE typespecs and walking character lengths in code walker.
This dumps the typespec of an ALLOCATE statement and also walks the charlen
of a character espression and an array if present.
gcc/fortran/ChangeLog:
* dump-parse-tree.cc (show_code_node): Show typespec for
ALLOCATE if present.
* frontend-passes.cc (gfc_expr_walker): Walk the character
typespec length for array expressions.
(gfc_code_walker): Walk the typespec for ALLOCATE if present.
Jeff Law [Sun, 19 Jul 2026 14:11:23 +0000 (08:11 -0600)]
[committed] Improve select across A/A OP C where C is 2^n
Testing for PR125731 exposed a bit of unexpected behavior on loongarch.
Basically the PR125731 patch allows if-conversion to again handle generating
conditional zero based sequences where one of the two operands in the original
sequence was a constant integer. Generating a conditional zero based sequence
usually results in better code than a generalized conditional move.
Discovering those cases better led to a regression on loongarch which seems to
want to generate even more specialized sequences than a conditional select
across 0,2^n for things like conditional add. Consider this loongarch
assembly:
That's a conditional add by 65536. We use the sltu to generate 1/0, shift
that by 16 generating 65536/0, then add that result to the other operand. With
the work for PR125731 we get this instead:
Normally I would prefer the 2nd sequence as the high part load has no
dependencies and can issue whenever is convenient, but loongarch explicitly
prefers the first sequence and I'm willing to assume that was done for a good
reason. For RISC-V it's probably a toss-up. The first form likely compresses
better and doesn't rely on zicond, but the second form has one less incoming
dependency. Barring hard data, I'm going to declare them equivalent and target
the sequence loongarch wants.
Thankfully this is a class of problems that's been on my radar for a while.
Given a select across A and A OP C where C is 2^N we can left shift the result
of the SCC to give us a select across 0 and 2^n, then we emit A OP X (where X
holds the result of that left shift). We can do this add, sub, shifts,
rotates, ior, xor, basically anything where "0" is a neutral operand. That
obviously excludes AND where -1 is the neutral. That's ultimately the same set
of operators as the condzero arithmetic supports except we'd need to filter out
AND.
The implementation is structured similar to store_flag_constants, though
simplified where obviously possible.
If we look at a couple subtests within the loongarch conditional-move-opt-1.c
testcase, but compiling for RISC-V:
extern long lm, lr;
void
test_nez ()
{
if (lm != 0)
lr <<= (1 << 4);
lr += lm;
}
void
test_eqz ()
{
if (lm == 0)
lr >>= (1 << 2);
lr += lm;
}
The relevant conditional move sequences look like this:
Not bad, but with this patch we clearly do better:
snez a3,t0
slli t1,a3,4
sll t2,a4,t1
add a0,t0,t2
and
seqz a3,t0
slli t1,a3,2
sra t2,a4,t1
add a0,t0,t2
Probably the same performance as the czeros can execute in parallel, but it's
smaller from an encoding standpoint and doesn't require zicond.
Bootstrapped and regression tested on x86_64, alpha, armv7, loongarch64,
riscv64 (k3, k1 and c920). Probably others as well, though I didn't check other
natives explicitly to see if it'd picked up the latest version of the patch.
Interestingly enough this does trigger meaningfully during bootstraps on
various targets as I stumbled across multiple failures due to a couple logic
errors in earlier versions.
There's still things that could be improved in here. Most obviously AND
handling, cases where STORE_FLAG_VALUE != 1 (which likely work due to
normalization, but our ability to test is limited), exploiting negated logicals
for things like conditional bit clear, etc. Even with the limitations, this
seems worthwhile to go forward now.
Pushing to the trunk.
PR target/125731
gcc/
* ifcvt.cc (noce_cond_zero_binary_op_supported): Move earlier.
(noce_try_shifted_store_flag): New function.
(noce_process_if_block): Use it.
gcc/testsuite
* gcc.target/riscv/pr125731-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vsetvl-15.c: Drop shift count test.
Andrew MacLeod [Fri, 17 Jul 2026 15:53:51 +0000 (11:53 -0400)]
use vrp_operand_equal_p in points to comparisons.
IPA iunshares points-to info for prange storage objects. This means they
may point to the same logical object, but have different physical pointer
values.
A prange_storage object is a hunk of memory, and it will continue to use
raw pointer comparisons for equality. Otherwise things like hash table
lookups will think there are different hashs for the same item.
Prange however should use vrp_operand_equal_p for comparisons. This will
prevent two prange objects from comparing unequal due to tree unsharing.
Andrew MacLeod [Thu, 16 Jul 2026 15:56:17 +0000 (11:56 -0400)]
Recompute relations during a relation query walk.
While querying relations we do a DOM walk. This patch adds a query that
will recompute potential relations on edges which look promising.
PR tree-optimization/126212
gcc/
* value-relation.cc (dom_oracle::set_one_relation): Start with
first dominator in the dominator search.
(dom_oracle::recomputed_relation): New.
(dom_oracle::find_relation_dom): query recomputed_relation.
* value-relation.h (dom_oracle::recomputed_relation): New prototype.
Luke Zhuang [Sat, 18 Jul 2026 20:29:18 +0000 (14:29 -0600)]
[PATCH] RISC-V: Fix the LRA crashing triggered by TLSDESC clobber updates
An LRA crashing is found by fuzz-testing, and is triggered by
<0748d2c83fc>. We can avoid it by replacing RVVM8QI with RVVM1QI,
and may need to fix the LRA later.
A reduced test is appended as well, demonstrating the crash.
gcc/ChangeLog:
* config/riscv/riscv.md (@tlsdesc<mode>): Use individual
RVVM1QI clobbers instead of four RVVM8QI.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/tlsdesc_clobber_lra.c: New test.
Co-authored-by: Kito Cheng <kito.cheng@sifive.com>
[PATCH] RISC-V: Do not grow complete unrolling at -O2
RISC-V enables -funroll-loops at -O2 for small-loop unrolling. Keep
size-growing complete unrolling disabled unless unrolling is explicitly
requested.
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_override_options_after_change): New
function.
(riscv_option_override): Call it.
(TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE): Define.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/unroll-explicit-attr-cunroll.c: New test.
* gcc.target/riscv/unroll-small-loop-cunroll.c: New test.
[PR target/123883] Inefficient bit manipulation code on RISC-V port
With changes to the RISC-V backend, it's possible to get the desired code
generation for this test with a simple match.pd pattern.
Essentially we have (1 << N) & (1 << N) where each shift is in a different
type. With some constraints, we can collapse that down to just (1 << N) in
the wider type. That in turn allows collapsing the entire sequence down to
a single bit set (6 instructions -> 3 instructions on rv64gcb).
PR target/123883
gcc/ChangeLog:
* match.pd ((1<<N) & (1<<N) with different types): New
pattern.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/pr123883-a.c: New test.
* gcc.target/riscv/pr123883-b.c: New test.
Matt Turner [Sat, 18 Jul 2026 16:32:39 +0000 (10:32 -0600)]
[PATCH] lra: mark the hard frame pointer live when LRA decides it is needed [PR117184]
ira_setup_eliminable_regset calls df_set_regs_ever_live for the hard frame
pointer when it decides frame_pointer_needed. LRA can reach that decision
later instead, in setup_can_eliminate, when it finds the frame pointer to
stack pointer elimination is not possible after all, but it does not mark the
register live there.
A target whose prologue decides which registers to save from
df_regs_ever_live_p then sets up the frame pointer without saving the caller's
value. On alpha this miscompiles pge while bootstrapping the Modula-2 front
end (PR117184): alpha_compute_frame_layout leaves $15 out of the save mask, so
alpha_expand_prologue emits the "mov $30,$15" that clobbers it but no matching
store, while alpha_expand_epilogue restores the register whenever
frame_pointer_needed, from an fp_offset that stayed 0 -- the return address
slot. The caller gets its call-saved $15 back as a code address, which shows
up much later as a NULL dereference, and the Modula-2 runtime turns the
resulting SIGSEGV into an unhandled exception:
terminate called after throwing an instance of 'unsigned int'
The testcase needs the VLA to reach the caller by inlining: a caller with its
own VLA has cfun->calls_alloca set, so IRA already knows a frame pointer is
needed and marks $15 live itself.
Do what IRA does, so the two paths agree.
PR target/117184
gcc/
* lra-eliminations.cc (setup_can_eliminate): Mark the hard frame
pointer live when setting frame_pointer_needed.
gcc/testsuite/
* gcc.target/alpha/frame-pointer-save-1.c: New test.
Xi Ruoyao [Tue, 14 Jul 2026 07:03:19 +0000 (15:03 +0800)]
LoongArch: fix par_const_vector_shf_set_operand for vshuf4i [PR 126200]
The logic of par_const_vector_shf_set_operand (actually,
loongarch_const_vector_shuffle_set_p) expect mode to have the same
element count as the shuffled vector. But the lsx_vshuf4i_<lsxfmt_f>
definition have VOIDmode for the mode of the selector, thus the
predicate actually accepts anything. The issue was somehow latent until
recently fwprop1 seems improved on folding two vec_select into one.
Change par_const_vector_shf_set_operand to a special predicate so we can
specify a mode different from the actual mode of the selector parallel
(in VOIDmode) to the predicate. Then specify VIMODE to satisfy the
expectation of loongarch_const_vector_shuffle_set_p.
PR target/126200
gcc/
* config/loongarch/predicates.md
(par_const_vector_shf_set_operand): Define as special predicate.
* config/loongarch/lsx.md (lsx_vshuf4i_<lsxfmt_f>): Pass VIMODE
to the predicate of selector.
gcc/testsuite/
* gcc.target/loongarch/vector/lsx/pr126200.c: New test.
Pan Li [Thu, 16 Jul 2026 04:57:53 +0000 (12:57 +0800)]
RISC-V: Add test cases for vfwcvtu.xu.f.v reg overlap
Add test cases for vfwcvt.xu.f.v register group overlap, please
note it is not overlap as much as possible.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_xu-f16-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_xu-f16-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_xu-f16-m4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_xu-f16-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_xu-f16-mf4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_xu-f32-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_xu-f32-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_xu-f32-m4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_xu-f32-mf2.c: New test.
Pan Li [Thu, 16 Jul 2026 04:57:02 +0000 (12:57 +0800)]
RISC-V: Add test cases for vfcvt.x.f.v reg overlap
Add test cases for vfwcvt.x.f.v register group overlap, please
note it is not overlap as much as possible.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_x-f16-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_x-f16-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_x-f16-m4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_x-f16-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_x-f16-mf4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_x-f32-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_x-f32-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_x-f32-m4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vfwcvt_x-f32-mf2.c: New test.
Thomas Koenig [Sat, 18 Jul 2026 08:41:23 +0000 (10:41 +0200)]
Show details of attr->allocated with -fdump-fortran-original.
This simple and obvious patch adds output for the var_allocated enum,
to make the status of where the gfortran thinks a potential allocation
came from more clear.
Instead of (example from warn_unused_but_set_variable_4.f90)
OpenMP: docs - improve -fopenmp-ompt(-detailed) description + update impl. status
invoke.texi: Improve the wording for -fopenmp-ompt(-detailed) that was
added in r17-2288-gab0dd7d5e16fcd.
libgomp.texi: Mark OpenMP 5.1's 'device_type(...)' for variables on
'declare target' as partially implemented as parsing support was added for
C/C++ in r10-2342-g77eb117f588686 and for Fortran in r11-2858-gd58e7173ef964d.
(device_type: It actually seems to work fine, even though there is almost no
code to handle 'host' differently; still host/nohost handling should be
improved for vars and funcs; hence, marked as only partial not as fully
supported.)
Arm has sunset the TME extension from the aarch64 architecture since
there are no known implementations. Since this has been present in the
compiler for a while though, we need to go through a deprecation cycle.
This patch starts that process by:
- removing it from the documentation
- warning if the option is used during compilation
- removing the tests for it.
gcc/ChangeLog:
* config/aarch64/aarch64.cc (aarch64_override_options): Warn if
+tme is used as an architecture feature
(aarch64_process_target_attr): Similarly, but only if TME
was previously disabled.
* doc/invoke.texi (aarch64): Remove mentions of +tme.
Matt Turner [Fri, 17 Jul 2026 13:26:12 +0000 (07:26 -0600)]
[PATCH] alpha: do not gate cannot_copy_insn_p on reload_completed
alpha_legitimize_address emits movdi_er_tlsgd and movdi_er_tlsldm together
with their paired call_value_osf_tlsgd/tlsldm at expand time, and both halves
already carry the sequence number that ties the pair together. Those patterns
are marked with the cannot_copy attribute, but alpha_cannot_copy_insn_p
returned false whenever !reload_completed, so the hook had no effect on any
pass running before register allocation.
Unrolling a loop whose body contains such a pair therefore copies the sequence
number along with it. With
extern __thread int tv;
extern int cond (int);
int f (int n)
{
int s = 0;
for (int i = 0; i < n; i++)
if (cond (i))
s += tv;
return s;
}
compiled with -O2 -funroll-loops -fno-move-loop-invariants -fPIC
-ftls-model=global-dynamic, the unroller produces seven copies of !tlsgd!1 and
the assembler rejects the result:
Error: duplicate !tlsgd!1
Error: too many lituse insns for !lituse_tlsgd!1
Drop the reload_completed test. The gpdisp pairs are only created after
reload, so this does not change their handling; it only lets the hook protect
the TLS pairs that already exist before register allocation. This is
independent of the register allocator: the failure reproduces identically with
both reload and LRA.
gcc/
* config/alpha/alpha.cc (alpha_cannot_copy_insn_p): Do not return
false before reload_completed. Update comment.
gcc/testsuite/
* gcc.target/alpha/tlsgd-dup-1.c: New test.
Robert Dubner [Fri, 17 Jul 2026 12:19:51 +0000 (08:19 -0400)]
cobol: Filename-as-device; normalize special registers.
The compiler now parses a new feature where a filename can be
established using the device syntax. It awaits implementation in the
code generator.
The variables "literally_zero" and "literally_zero" are now established
as global constants in libgcobol instead of as constructed temporary
variables.
The initialization of "special registers", and the necessary
coordination between their compile-time cbl_field_t and run-time
cblc_field_t counterparts has been normalized.
gcc/cobol/ChangeLog:
* genapi.cc (parser_file_open): New filename-as-device feature
awaiting implementation.
* lexio.h (struct filespan_t): Variable name change.
* parse.y: Filename-as-device.
* parse_ante.h (field_find): Likewise.
(data_division_ready): _literally_zero and _literally_one global
constants.
* scan.l: Require separate space after '<', '>' and '=' comparison
operators.
* scan_ante.h (update_location): Change debug message text.
* symbols.cc (constq): Eliminate #define in favor of explicit
(constant_e | quoted_e).
(label_cmp): Formatting: eliminate trailing space.
(symbol_elem_cmp): Filename-as-device.
(enum protoreq_t): Formatting: eliminate trailing space.
(cbl_field_t::clear_attr): Likewise.
(symbols_dump): Likewise.
(cbl_field_t::attr_str): Likewise.
(field_str): Likewise.
(symbols_update): Use _literally_zero and _literally_one.
(endian_bit): Compact access to cobol_target_big_endian().
(symbol_table_init): Normalize initialization of "special
registers".
(symbol_registers_add): Likewise.
(cbl_perform_tgt_t::recurses): Formatting: eliminate trailing space.
(symbol_literalA): Replace constq.
(cbl_alphabet_t::reencode): Eliminate trailing space.
(symbol_temporary_alphanumerics): Likewise.
(new_literal_add): Likewise.
(new_temporary_clone): Ensure FldLiteralBin5 has the endian attribute of
the target architecture.
(iconv_cd): Formatting: eliminate trailing space.
(cbl_field_t::encode): Likewise.
(cbl_field_t::set_capacity): Formatting: eliminate trailing space.
(cbl_label_t::str): Likewise.
(cbl_file_t::special_index): New function supporting
filename-as-device.
(cbl_file_t::filename_of): Likewise.
* symbols.h (struct cbl_special_name_t): Support filename as device.
(struct cbl_file_t): Likewise.
(symbol_typedef): Likewise.
(symbol_special_index): Likewise.
libgcobol/ChangeLog:
* charmaps.h (ebcdic_newline): Use just SPACES instead of both
SPACE and SPACES.
* constants.cc (INTEGER_CONSTANT1): Eliminate.
(struct cblc_field_t): Eliminate __gg__data_space.
(INTEGER_CONSTANT2): Eliminate.
(endian): Adjust the initialization of __ggsr__spaces and the
various DEBUG-ITEM components.
* libgcobol.cc (alpha_to_alpha_move_from_location): Correct a comment.
(__gg__codeset_figurative_constants): Normalize using SPACES when SPACE is
specified.
(__gg__get_figconst_data): Likewise.
gcc/testsuite/ChangeLog:
* cobol.dg/group2/INITIALIZE_with_-defaultbyte__ASCII_.cob: Use
"VALUE '-'" instead of "VALUE'-'".
* cobol.dg/group2/INITIALIZE_with_-defaultbyte__EBCDIC_.cob:
Likewise.
* cobol.dg/group2/PR59_RT3586_-_Code_format_heuristic_fails.cob: Removed.
* cobol.dg/group2/RT3609_Unexpected_PROCESS.cob: Removed.
* cobol.dg/group2/DEBUG-ITEM_using_mh_identical.cob: New test.
* cobol.dg/group2/DEBUG-ITEM_using_mh_identical.out: New test.
Jeff Law [Fri, 17 Jul 2026 13:14:13 +0000 (07:14 -0600)]
Fix signed char test assumption [Was Re: [Linaro-TCWG-CI] gcc-17-2261-g649b2a6d9f9f: 7 regressions on arm]
> Dear contributor,
>
> Our automatic CI has detected problems related to your patch(es). Please find some details below.
>
> In armv8l-unknown-linux-gnueabihf native, after:
> | commit gcc-17-2261-g649b2a6d9f9f
> | Author: Jeff Law <jeffrey.law@oss.qualcomm.com>
> | Date: Wed Jul 8 12:30:56 2026 -0600
> |
> | [PR rtl-optimization/126136] Fix dest = cond ? x : -1 when STORE_FLAG_VALUE is -1
> |
> | So a while back I added support for selecting x/-1 into the ifcvt.cc by using
> | scc and a couple ALU operations. That code explicitly rejects STORE_FLAG_VALUE
> | if it is not 1 or -1.
> | ... 20 lines of the commit log omitted.
>
> Produces 7 regressions:
> |
> | regressions.sum:
> | Running gcc:gcc.dg/torture/dg-torture.exp ...
> | FAIL: gcc.dg/torture/pr126136.c -O0 execution test
> | FAIL: gcc.dg/torture/pr126136.c -O1 execution test
> | FAIL: gcc.dg/torture/pr126136.c -O2 execution test
> | FAIL: gcc.dg/torture/pr126136.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test
> | ... and 3 more
>
> Used configuration :
> *CI config* tcwg_gcc_check armv8l-unknown-linux-gnueabihf
> *configure and test flags:* none, autodetected on armv8l-unknown-linux-gnueabihf--disable-multilib --with-float=hard --with-mode=thumb --with-tune=cortex-a9 --with-arch=armv7-a --with-fpu=neon-fp-armv8
>
> We track this bug report under https://linaro.atlassian.net/browse/GNU-1959. (Require Linaro login) Please let us know if you have a fix.
As others noted, this is a case where the test assumed signed chars. The patch
makes the signedness explicit.
Bootstrapped and regression tested on armv7 and verified the test now passes on
that platform. Pushing to the trunk.
gcc/testsuite
* gcc.dg/torture/pr126136.c: Make chars explicitly signed.
Lewis Hyatt [Sat, 11 Jul 2026 18:21:12 +0000 (14:21 -0400)]
lto: Support #pragma GCC diagnostic [PR80922] [PR106823] [PR107936]
After the previous changes in this series, the LTO front end always has an
appropriate linemap structure for interpreting diagnostic pragmas, so it is
straightforward to implement them, as is done here.
The pragmas are streamed out in each linemap section; since all locations
from a given linemap section will be contiguous in the reconstructed
linemap, they are automatically ordered properly for the existing diagnostic
pragma infrastructure to work as-is.
One wrinkle is that a single function may have been streamed out in multiple
sections. (For example, an inline function will be streamed out in all
partitions that need it.) In this case, when merging them, LTO keeps only
one of the sections, as directed by the linker resolution, so the diagnostic
pragmas that will be in force (in case they were not the same for the
different translation units) will be whichever were applicable to the
section LTO decided to keep.
gcc/ChangeLog:
PR middle-end/80922
PR middle-end/106823
PR lto/107936
* lto-streamer-in.cc (lto_create_loc_map): Process diagnostic
pragmas from the linemap sections.
* lto-streamer-out.cc (location_output::produce_linemap_section):
Stream diagnostic pragmas into the linemap section.
gcc/testsuite/ChangeLog:
PR middle-end/80922
PR middle-end/106823
PR lto/107936
* gcc.dg/lto/pr106823_0.c: New test.
* gcc.dg/lto/pr107936_0.c: New test.
* gcc.dg/lto/pr107936_1.c: New test.
* gcc.dg/lto/pr80922-1_0.c: New test.
* gcc.dg/lto/pr80922-1_1.c: New test.
* gcc.dg/lto/pr80922-2_0.c: New test.
* gcc.dg/lto/pr80922-2_1.c: New test.
* gcc.dg/lto/pr80922-2_2.c: New test.
Lewis Hyatt [Sat, 11 Jul 2026 18:21:12 +0000 (14:21 -0400)]
lto: Overhaul approach to location streaming [PR65536]
PR65536 is about location-related issues that arise when the LTO front end
reads one or several large object files and runs out of location_t space to
encode all the locations. The main reason for the potential problem is that
the libcpp linemap is designed to be used for incrementally reading source
files (and their included header files) in the natural order. When it is
used in another way, such as by LTO, which adds locations in the order in
which it happened to read different entities, then the assumptions that
justify its design are no longer applicable, and it is not hard to run out
of location_t values (e.g., because of a large number of file changes, or
lines being added out of order.)
The PR remains open because it is not theoretically resolved, but it has
been resolved for all practical purposes by the following two improvements:
1) The lto_location_cache class now tries hard to optimize the number of
maps that it creates, especially by sorting the locations before
adding them. This approach only goes so far, because it can only work
at the LTO section level, so each function is handled independently
of the others, but it helps a lot with reducing the number of maps
required for a single function.
2) We moved to 64-bit location_t, which means everything is a lot more
forgiving of wasting location_t space.
Point 2) made this not much of an issue in practice, although sufficiently
large files (especially with very long lines) could still trigger a problem
in theory. While locations are now by and large working fine in LTO, there
was an interesting discussion on PR65536, starting around:
about how the location streaming might be optimized by streaming the linemap
structure itself, rather than a (file name, line number, column number)
triplet for each location. In the end, this approach was not taken because
solution 1) above was adequate and less disruptive. But the arguments
presented in favor of streaming the linemap directly are still interesting.
That discussion did not touch on another topic, namely the need to make
`#pragma GCC diagnostic' usable in LTO. Right now, it does not work, because
the diagnostic pragmas are not streamed out. But even if they were streamed
out, the existing approach to locations in the LTO front end is not
compatible with enforcing the pragmas. Diagnostic pragmas require a global
ordering on location_t values, so that the machinery in option-classifier.cc
can determine which pragmas are in force at each location. This requires
remembering the order in which each source line was encountered, and that is
exactly what is encoded in the linemap. This cannot be reconstructed just
from source file names and line numbers; consider, for example, that the
same file might be used in different translation units or multiple times in
the same translation unit with different diagnostic pragmas in place each
time.
These considerations tip the scales in favor of adding linemap streaming as
Manuel proposed on the PR. This patch prepares to support `#pragma GCC
diagnostic' in the LTO front end by changing the approach to location
streaming along these lines. The new approach has these general
characteristics:
o There is a new LTO section (LTO_section_linemap) that contains the
information needed to reconstruct the linemap. There is an entry for
each line_map_ordinary object that was used by at least one
streamed-out location. When the LTO front end reads one of these map
entries, it adds a new map with the corresponding properties to its
own linemap using the new line_map_add_raw_map interface in libcpp.
o When a location needs to be output, we stream out two integers: one to
identify which linemap contains the location, and one containing the
offset from the start of that map to the location.
o When the language front ends stream out their data, they produce a
single linemap section (labeled as linemap.0) that applies to the
whole translation unit. When WPA prepares partitioned files for
LTRANS, it may copy function bodies into the LTRANS files without
reading them, so it needs also to copy the linemap sections they refer
to. Since the same linemap section will often be needed by more than
one partition, this is done by putting all of the linemap sections
into one additional object file, which is provided as input to each
LTRANS process via the new option -fltrans-linemap-file.
o The naming of the LTRANS linemap sections is stable so as not to
inhibit incremental LTO.
o Once the reader has processed the linemap sections, there is no
further overhead associated with inputting a location, unless it is an
adhoc location for the purpose of associating a discriminator or a
tree with the location. For the adhoc location case, the existing
lto_location_cache setup is still useful to avoid creating unneeded
adhoc locations, so this has been left in place as before. The
restriction that there be only one lto_location_cache at a time is no
longer strictly necessary; but it is still useful so that the IPA
passes can access the currently active one simply, so I have not
changed this for now.
With this new setup, PR65536 can be closed. The subsequent patches in this
series will enable support for diagnostic pragmas.
gcc/lto/ChangeLog:
PR lto/65536
* lang.opt: Add -fltrans-linemap-file.
* lto-common.cc (lto_read_in_decl_state): Read the linemap ID from
function sections.
(linemap_section_id): New function.
(create_subid_section_table): Note how many linemap sections were
found in each input section.
(loc_map_decl_data): New GC root.
(lto_file_read): Make ORDER into a static variable so it counts
continuously across all files and sub-files provided on the command
line.
(lto_file_finalize): Handle reading the new LTRANS linemap file.
(read_cgraph_and_symbols): Likewise. Also stop freeing
ALL_FILE_DECL_DATA at the end; the ordered list of files is now
useful later on for lto_copy_linemaps().
* lto.cc (stream_out_linemaps): New function.
(lto_wpa_write_files): Stream out the linemaps for LTRANS to use.
gcc/testsuite/ChangeLog:
PR lto/65536
* gcc.misc-tests/outputs.exp: Adjust LTO -save-temps tests to expect
the new linemap file.
gcc/ChangeLog:
PR lto/65536
* doc/lto.texi: Document the new LTO_section_linemap and the new
option -fltrans-linemap-file.
* lto-opts.cc (lto_write_options): Handle the new option.
* opts.cc (gen_command_line_string): Likewise.
* lto-section-in.cc (lto_section_name[]): Add new name for
LTO_section_linemap.
* lto-streamer-in.cc (get_location_from_idx): New function.
(lto_location_cache::cmp_loc): Remove.
(bp_unpack_delta): New function.
(create_loc_map): New function.
(get_loc_map): New function.
(lto_location_cache::override_loc_map): New function.
(lto_location_cache::apply_location_cache): Pervasive changes to
implement new location streaming format.
(lto_location_cache::input_location_and_block): Likewise.
(lto_location_cache::input_location): Rename argument LOC -> DEST
for clarity.
(lto_read_body_or_constructor): Handle LINEMAP_ID in the decl state.
(lto_data_in_create): Add NEED_LOCATION_CACHE argument. Rename local
variable DATA_IN to D to avoid clash with the type name.
* lto-streamer-out.cc (clear_line_info): Update for change to class
output_block.
(compute_map_hash): New function.
(class location_output): New class.
(location_output::record_location): New function.
(bp_pack_delta): New function.
(location_output::produce_linemap_section): New function.
(lto_output_location_1): Pervasive changes to implement new location
streaming format.
(copy_function_or_variable): Set the LINEMAP_ID in the decl state.
(copy_linemap_section): New function.
(copy_linemap_sections): New function.
(lto_copy_linemaps): New function.
(lto_register_linemap_for_output): New function.
(lto_output_decl_state_refs): Output the LINEMAP_ID for function
decls.
(lto_out_decl_state_written_size): Adapt for new LINEMAP_ID output.
(produce_asm_for_decls): Output the linemap section when needed.
* lto-streamer.cc (lto_get_section_name): Handle linemap sections,
which need an order suffix.
* lto-streamer.h (enum lto_section_type): Fix typo in the
comment. Add LTO_section_linemap.
(struct lto_loc_map): New struct.
(class lto_location_cache): Pervasive changes to implement new
location streaming format.
(struct lto_in_decl_state): Add LINEMAP_ID member.
(struct lto_out_decl_state): Likewise.
(struct lto_file_decl_data): Add LOC_MAP_DECL_DATA, LOC_MAPS,
and NUM_LINEMAP_SECTIONS members.
(lto_linemap_output_id): New function.
(struct output_block): Adjust members for new streaming format.
(data_in::data_in): New function.
(lto_data_in_create): Adjust prototype for new NEED_LOCATION_CACHE
argument.
(lto_register_linemap_for_output): Declare.
(lto_copy_linemaps): Declare.
* lto-wrapper.cc (run_gcc): Pass new argument -fltrans-linemap-file.
* timevar.def (TV_IPA_LTO_LINEMAP_IN): New timevar.
(TV_IPA_LTO_LINEMAP_OUT): New timevar.
(TV_IPA_LTO_LINEMAP_COPY): New timevar.
Lewis Hyatt [Sat, 11 Jul 2026 18:21:12 +0000 (14:21 -0400)]
testsuite: Add { dg-lto-do incr-link } option
Similar to { dg-lto-do ar-link }, which allows testing the combination of
multiple LTO objects into an archive before linking, this new directive
allows testing the incremental linking modes of the LTO front end.
gcc/ChangeLog:
* doc/sourcebuild.texi: Document ar-link and incr-link options to
dg-lto-do directive.
gcc/testsuite/ChangeLog:
* gcc.dg/lto/README: Update to document ar-link and incr-link.
* lib/lto.exp: Support incr-link directive throughout.
In the LTO testsuite, tests run by default with a variety of options. If
the dg-lto-options directive is used, the default list is replaced with just
the requested options, so there is no convenient way, for instance, to add a
given option like -Wall to all of the options being tested.
This will be handy for testing `#pragma GCC diagnostic' in the next patch in
this series, so this patch adds a new directive dg-lto-additional-options
for that purpose. This keeps the list of options to test unchanged, and
just adds the requested options to all of them.
Lewis Hyatt [Sat, 11 Jul 2026 18:21:12 +0000 (14:21 -0400)]
diagnostics: Preparation for LTO diagnostic pragma support
The next patches in this series will enable support for `#pragma GCC
diagnostic' in the LTO streaming code. This requires some minor changes to
the diagnostics interface so that LTO can access what it needs:
1) Make the name of the type option_classifier::classification_change_t
publicly accessible. The actual m_classification_history object is
already public via an accessor function, which was needed for C++
modules; this patch just additionally makes the name of the type
accessible for convenience.
2) Add a trailing member to enum diagnostics::kind indicating the
maximum possible value. This is for the benefit of LTO streaming that
can make use of the range information.
3) The function option_classifier::classify_diagnostic() does some work
to return a value; when a diagnostic kind is changed, it claims to
return the previous kind. The returned value is incorrect, however;
it does not attempt to follow the history of diagnostic pop pragmas
to return the actual previous value, and it could also misinterpret a
pop directive if the pop index happens to match the index of the
option being processed. There is no actual need to compute this
value, and it has never been used by any callers, so remove it
entirely.
This change is not strictly necessary for the rest of this
patch series, but the extra work being done here may be a bigger
concern for LTO, which could potentially have a rather large list of
diagnostic pragmas to work with, so it seemed worthwhile to include
this fix now.
gcc/ChangeLog:
* diagnostic.h (diagnostic_classify_diagnostic): Adapt for removal
of return value in option_classifier::classify_diagnostic.
* diagnostics/context.h: Likewise.
* diagnostics/kinds.h (enum kind): Add trailing element to indicate
the total number of kinds.
* diagnostics/option-classifier.cc
(option_classifier::classify_diagnostic): Remove the return value,
which was not correct and which was not used anyway.
* diagnostics/option-classifier.h (class option_classifier): Adjust
prototype for classify_diagnostic. Make the name of nested strruct
classification_change_t publicly accessible.