Thomas Schwinge [Wed, 8 Jul 2026 21:13:17 +0000 (23:13 +0200)]
gcc/system.h: Allow for '#define INCLUDE_ITERATOR' to '#include <iterator>'
This avoids:
In file included from /gnu/store/jdibb0iw7n0y56pq3rvz9fmzb4j60acr-gcc-5.5.0/include/c++/bits/basic_ios.h:37:0,
from /gnu/store/jdibb0iw7n0y56pq3rvz9fmzb4j60acr-gcc-5.5.0/include/c++/ios:44,
from /gnu/store/jdibb0iw7n0y56pq3rvz9fmzb4j60acr-gcc-5.5.0/include/c++/ostream:38,
from /gnu/store/jdibb0iw7n0y56pq3rvz9fmzb4j60acr-gcc-5.5.0/include/c++/iterator:64,
from ../../source-gcc/gcc/[...]
/gnu/store/jdibb0iw7n0y56pq3rvz9fmzb4j60acr-gcc-5.5.0/include/c++/bits/locale_facets.h:247:53: error: macro "toupper" passed 2 arguments, but takes just 1
toupper(char_type *__lo, const char_type* __hi) const
^
[...]
Mark Wielaard [Fri, 10 Jul 2026 09:25:59 +0000 (11:25 +0200)]
Regenerate i386.opt.urls
riscv also got an -munroll-only-small-loops option. This means that
the doc urls for the existing -munroll-only-small-loops for i386 got
renamed (so they have distinct names). riscv.opt.urls already got
regenerated. Now also regenerate i386.opt.urls
Fixes: d15703b27aa4 RISC-V: Add small loop unrolling support via -munroll-only-small-loops
gcc/ChangeLog:
This patch converts the fold-mem-offsets pass from DF to RTL-SSA.
Along with this conversion, the way the pass collects information was
completely reworked. Instead of visiting each instruction multiple
times, this is now done only once.
Most significant changes are:
* The pass operates mainly on insn_info objects from RTL-SSA.
* Single iteration over all nondebug INSNs for identification
of fold-mem-roots. Then walk of the fold-mem-roots' DEF-chain
to collect foldable constants.
* The class fold_mem_info holds vectors for the DEF-chain of
the to-be-folded INSNs (fold_agnostic_insns, which don't need
to be adjusted, and fold_insns, which need their constant to
be set to zero).
* Introduction of a single-USE mode, which only collects DEFs,
that have a single USE and therefore are safe to transform
(the fold-mem-root will be the final USE). This mode is fast
and will always run (unless disabled via -fno-fold-mem-offsets).
* Introduction of a multi-USE mode, which allows DEFs to have
multiple USEs, but all USEs must be part of any fold-mem-root's
DEF-chain. The analysis of all USEs is expensive and therefore,
this mode is disabled for highly connected CFGs, unless
-fexpensive-optimizations (enabled by default at -O2) forces it on.
Note that multi-USE mode will miss some opportunities that the
single-USE mode finds (e.g. multi-USE mode fails for
fold-mem-offsets-3.c).
The following testing was done:
* Bootstrapped and regtested on aarch64-linux, x86-64-linux and
arm-linux.
* SPEC CPU tested on aarch64.
A compile time analysis with
`/bin/time -v ./install/usr/local/bin/gcc -O2 all.i`
(all.i from PR117922) shows:
* -fno-fold-mem-offsets: 1681 s (user time) 23626232 kBytes (max resident set size)
* -ffold-mem-offsets: 1849 s (user time) 23625708 kBytes (max resident set size)
Multi-USE mode (on by default at -O2 via -fexpensive-optimizations) does
not have an impact on the duration or the memory footprint.
gcc/ChangeLog:
PR rtl-optimization/117922
* fold-mem-offsets.cc (INCLUDE_ALGORITHM): Added definition.
(INCLUDE_FUNCTIONAL): Likewise.
(class pass_fold_mem_offsets): Moved to bottom of file.
(class change_info): New.
(def_shadowed_by_cond_exec_p): New.
(get_single_def_in_bb): Converted to RTL-SSA.
(get_fold_mem_offset_root): Converted to RTL-SSA.
(get_uses): Removed.
(fold_offsets): Converted to RTL-SSA.
(fold_offsets_value): New.
(fold_offsets_1): Converted to RTL-SSA.
(has_foldable_uses_p): Converted to RTL-SSA.
(get_fold_mem_root): Removed.
(insn_uses_not_in_bitmap): New.
(drop_unsafe_candidates): New.
(do_commit_offset): Converted to RTL-SSA.
(do_analysis): Removed.
(do_commit_insn): Converted to RTL-SSA.
(do_fold_info_calculation): Removed.
(sort_changes): New.
(struct regno_changes): New.
(sort_pairs): New.
(do_check_validity): Removed.
(get_last_def): New.
(move_uses_to_prev_def): New.
(compute_validity_closure): Removed.
(change_in_vec_p): New.
(cancel_changes_for_group): New.
(find_keys_to_remove): New.
(free_changes_info): New.
(update_insns): New.
(fold_mem_offsets_1): New.
(pass_fold_mem_offsets::execute): Moved to bottom of file.
(fold_mem_offsets): New.
gcc/testsuite/ChangeLog:
* g++.target/aarch64/fold-mem-offsets.C: New test.
* gcc.target/aarch64/fold-mem-offsets.c: New test.
Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
I've noticed we advertise __has_cpp_attribute (gnu::trivial_abi)
and __has_attribute (gnu::trivial_abi). It is true we have
gnu::trivial_abi in the tables, but solely to give errors on those
when using the gnu:: scope and to suggest [[clang::trivial_abi]]
or __attribute__((trivial_abi)).
Eric Botcazou [Fri, 10 Jul 2026 06:37:12 +0000 (08:37 +0200)]
Ada: Suppress access checks during analysis of expanded dispatching calls
Expanded dispatching calls had been historically analyzed with all checks
disabled, but this was recently changed, thus causing the generation of a
lot of additional and useless access checks.
gcc/ada/
* exp_disp.adb (Expand_Dispatching_Call): Reenable the suppression
of access checks during analysis of expanded dispatching calls.
Pan Li [Wed, 8 Jul 2026 05:57:04 +0000 (13:57 +0800)]
RISC-V: Add test cases for vzext.vf4 reg overlap
Add test cases for vzext.vf4 register group overlap, please
note it is not overlap as much as possible.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf4-u16-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf4-u16-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf4-u16-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf4-u16-mf4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf4-u8-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf4-u8-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf4-u8-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf4-u8-mf4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf4-u8-mf8.c: New test.
Pan Li [Wed, 8 Jul 2026 05:56:19 +0000 (13:56 +0800)]
RISC-V: Add test cases for vsext.vf4 reg overlap
Add test cases for vsext.vf4 register group overlap, please
note it is not overlap as much as possible.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf4-i16-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf4-i16-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf4-i16-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf4-i16-mf4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf4-i8-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf4-i8-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf4-i8-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf4-i8-mf4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf4-i8-mf8.c: New test.
Pan Li [Wed, 8 Jul 2026 12:04:35 +0000 (20:04 +0800)]
RISC-V: Allow RVV register overlap for v[sz]ext.vf4
Like v[sz]ext.vf2, allow the rvv register overlap
for v[sz]ext.vf4.
gcc/ChangeLog:
* config/riscv/riscv-protos.h (is_frac_vlmul_p): Add new func
decl to predicate frac vlmul for a mode.
* config/riscv/riscv-v.cc (is_frac_vlmul_p): Add new func impl
for above.
(riscv_v_widen_constraint_ok): Add Source and Dest lmul less
and equal 1 handling.
* config/riscv/vector.md: Leverage widen constraint Wvr.
Andrew Pinski [Sat, 4 Jul 2026 07:32:03 +0000 (00:32 -0700)]
match: Fix up `((a ^ b) & c) cmp d || a != b` pattern and add support for && case [PR116860]
Turns out it was easy to fix these patterns for
`--param=logical-op-non-short-circuit=0` case after all.
Just add support for `((a ^ b) & c) cmp d && a == b`
which is the same as `!(((a ^ b) & c) cmp d || a != b)`.
So this adds the bit_and case to support exactly that.
Also fixes up some of the `:c` on the operands.
`:c` needs to be on the outer bitop and does not need to be
on the inner one for bit_xor as it will be the same order as ne/eq.
* match.pd (`((a ^ b) & c) cmp d || a != b`): Expand
to support bit_and and fix up the :c.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/fold-xor-and-or-1.c: New test.
* gcc.dg/tree-ssa/fold-xor-or-1.c: New test.
* gcc.dg/tree-ssa/pr102793-1.c: Update for the optimization
happening in pre.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
openmp: Pass iteration count to static worksharing builtins for OMPT
Add parameter to GOMP_{loop,distribute}_static_worksharing{,_start} carrying the
total number of loop iterations. niter is unused for now, pending OMPT
implementation.
The call in omp-expand.cc is moved after the iteration count computation
so that the iteration count is available to pass as the argument.
gcc/ChangeLog:
* builtin-types.def (BT_FN_COMPLEX_INT): Remove.
(BT_FN_COMPLEX_INT_ULONGLONG): New.
* omp-builtins.def (BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING): Use
BT_FN_COMPLEX_INT_ULONGLONG.
(BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_START): Likewise.
(BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING): Likewise.
(BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_START): Likewise.
* omp-expand.cc (expand_omp_for_static_nochunk): Move worksharing
builtin call after iteration count computation; pass n as niter.
(expand_omp_for_static_chunk): Likewise.
openmp: Add OMPT entry points for worksharing-loop, single, and masked constructs
Add two new compiler flags, -fopenmp-ompt and -fopenmp-ompt-detailed, that
cause the compiler to emit OMPT-aware runtime entry points around OpenMP
worksharing constructs. With -fopenmp-ompt, the _start and _end variants
are called instead of the plain worksharing functions; with
-fopenmp-ompt-detailed, a _dispatch stub is additionally called after the
chunk bounds are computed. New stubs are added to libgomp as placeholders
for future OMPT callback invocations.
gcc/ChangeLog:
* common.opt (fopenmp-ompt): New option.
(fopenmp-ompt-detailed): New option.
* common.opt.urls: Regenerate.
* doc/invoke.texi (Option Summary): Add -fopenmp-ompt and
-fopenmp-ompt-detailed.
(OpenMP and OpenACC Options): Document -fopenmp-ompt and
-fopenmp-ompt-detailed.
* omp-builtins.def (BUILT_IN_GOMP_SINGLE_START_WITH_END): New builtin.
(BUILT_IN_GOMP_SINGLE_END): New builtin.
(BUILT_IN_GOMP_MASKED_END): New builtin.
(BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_START): New builtin.
(BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_END): New builtin.
(BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_DISPATCH): New builtin.
(BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_START): New builtin.
(BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_END): New builtin.
(BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_DISPATCH): New builtin.
* omp-expand.cc (expand_omp_for_static_nochunk): With -fopenmp-ompt,
emit _start and _end variants instead of the plain worksharing call;
with -fopenmp-ompt-detailed, also emit _dispatch.
(expand_omp_for_static_chunk): Likewise.
* omp-low.cc (lower_omp_single_simple): With -fopenmp-ompt, use
GOMP_single_start_with_end instead of GOMP_single_start.
(lower_omp_single): With -fopenmp-ompt, emit GOMP_single_end.
(lower_omp_master): With -fopenmp-ompt, emit GOMP_masked_end.
* opts.cc (finish_options): Diagnose -fopenmp-ompt and
-fopenmp-ompt-detailed used without -fopenmp.
libgomp/ChangeLog:
* config/gcn/teams.c (GOMP_distribute_static_worksharing_start,
GOMP_distribute_static_worksharing_dispatch,
GOMP_distribute_static_worksharing_end): New functions.
* config/nvptx/teams.c (GOMP_distribute_static_worksharing_start,
GOMP_distribute_static_worksharing_dispatch,
GOMP_distribute_static_worksharing_end): Likewise.
* libgomp.map (GOMP_6.0.2): Export new entry points.
* libgomp_g.h: Add prototypes for GOMP_loop_static_worksharing,
GOMP_loop_static_worksharing_start, GOMP_loop_static_worksharing_dispatch,
GOMP_loop_static_worksharing_end, GOMP_has_masked_thread_num,
GOMP_masked_end, GOMP_single_start_with_end, GOMP_single_end,
GOMP_distribute_static_worksharing_start,
GOMP_distribute_static_worksharing_dispatch, and
GOMP_distribute_static_worksharing_end.
* loop.c (GOMP_loop_static_worksharing): Move here from parallel.c.
(GOMP_loop_static_worksharing_start): New function.
(GOMP_loop_static_worksharing_dispatch): New stub.
(GOMP_loop_static_worksharing_end): New stub.
(GOMP_has_masked_thread_num): Move here from parallel.c.
(GOMP_masked_end): New stub.
* parallel.c (GOMP_loop_static_worksharing): Move to loop.c.
(GOMP_has_masked_thread_num): Move to loop.c.
* single.c (GOMP_single_start_with_end): New function.
(GOMP_single_end): New stub.
(GOMP_single_copy_start): Fix trailing whitespace.
* teams.c (GOMP_distribute_static_worksharing_start): New function.
(GOMP_distribute_static_worksharing_dispatch): New stub.
(GOMP_distribute_static_worksharing_end): New stub.
* testsuite/libgomp.c-c++-common/for-static-1.c: New test.
* testsuite/libgomp.c-c++-common/for-static-2.c: New test.
* testsuite/libgomp.c-c++-common/for-static-3.c: New test.
* testsuite/libgomp.c-c++-common/for-static.h: New test.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/masked-1.c: Add scan-tree-dump-not check that
GOMP_masked_end is not emitted without -fopenmp-ompt.
* c-c++-common/gomp/for-8.c: Remove; superseded by for-static-*.c.
* c-c++-common/gomp/for-static-1.c: New test; checks that the plain
worksharing builtins are emitted without -fopenmp-ompt.
* c-c++-common/gomp/for-static-2.c: New test; checks that _start and
_end variants are emitted with -fopenmp-ompt.
* c-c++-common/gomp/for-static-3.c: New test; checks that _dispatch is
also emitted with -fopenmp-ompt-detailed.
* c-c++-common/gomp/for-static.h: New shared test header.
* c-c++-common/gomp/masked-3.c: New test for GOMP_masked_end emission
with -fopenmp-ompt.
* c-c++-common/gomp/openmp-ompt-1.c: New test; checks that
-fopenmp-ompt without -fopenmp is diagnosed.
* c-c++-common/gomp/openmp-ompt-2.c: New test; checks that
-fopenmp-ompt-detailed without -fopenmp is diagnosed.
* c-c++-common/gomp/single2.c: New test for GOMP_single_start_with_end
and GOMP_single_end emission with -fopenmp-ompt.
r17-629-g582adc3c97b1e0 shrank cselib_val::hash to 30 bits in order
to free up two bits for new flags. However, I hadn't realised that
cselib_hash_rtx uses zero as an error return and so requires the hash
to be nonzero. In the PR, trimming the hash to 30 bits had the effect
of dropping the only nonzero bits, leading cselib_lookup_1 to fail even
when the "create" parameter was true.
Rather than fight against the system, it seemed better to restore the
hash to 32 bits and get the space another way: by moving the uid field
from cselib_val to the u2 field of the VALUE rtx. This slightly
complicates some uses and slightly simplifies others.
There is currently a 1:1 mapping between VALUEs and cselib_vals.
The only time val_rtx is set is in new_cselib_val:
e->val_rtx = (rtx_def*) value_pool.allocate ();
and the only times CSELIB_VAL_PTR is set are in new_cselib_val:
CSELIB_VAL_PTR (e->val_rtx) = e;
and discard_useless_values:
CSELIB_VAL_PTR (v->val_rtx) = NULL;
If in future we allowed multiple VALUEs to point to the same cselib_val
(e.g. for canonical_cselib_val), we would need to copy CSELIB_VAL_UID at
the same time as copying CSELIB_VAL_PTR.
gcc/
PR debug/126169
* rtl.h (rtx_def::u2): Add value_uid to the union.
(CSELIB_VAL_UID): New macro.
* cselib.h (cselib_val::HASH_MASK): Delete.
(cselib_val::hash): Restore to a full int.
(cselib_val::uid): Delete.
(canonical_cselib_val): Use CSELIB_VAL_UID instead of cselib_val::uid.
* alias.cc (refs_newer_value_p): Likewise.
* dse.cc (canon_address): Likewise.
* print-rtl.cc (rtx_writer::print_rtx_operand_code_0): Likewise.
* var-tracking.cc (dv_uid, canon_value_cmp): Likewise.
(variable_post_merge_new_vals): Likewise.
* cselib.cc (new_elt_loc_list, new_cselib_val): Likewise.
(cselib_lookup): Likewise.
(cselib_find_slot): Remove use of cselib_val::HASH_MASK.
Andreas Schwab [Thu, 9 Jul 2026 18:24:35 +0000 (20:24 +0200)]
m68k: Properly model bset/bclr on memory
When operating on memory the bset and bclr insns use only the low 3 bits
of the bit number.
PR target/126121
gcc/
* config/m68k/m68k.md (bsetmemqi, *bsetmemqi_ext, bclrmemqi)
(*bclrmemqi_ext): Add AND with 7 around bit number.
gcc/testsuite/
* gcc.dg/torture/pr126121.c: New test.
Karl Meakin [Thu, 9 Jul 2026 14:04:49 +0000 (14:04 +0000)]
Remove uses of `CONSTEXPR` macro
The `CONSTEXPR` macro was used to support building GCC with compiler
that don't support `constexpr`, but we have required GCC to be built
with in C++14 mode for a few years now, so any compiler will have to
support `constexpr` anyway.
Karl Meakin [Tue, 7 Jul 2026 16:53:26 +0000 (16:53 +0000)]
aarch64: Ignore vcopy_lane_indices.c on 32-bit targets
The `vcopy_lane` family of intrinsics are only available on AArch64
targets (ie not on 32-bit targets), so the test should be ignored on
those targets.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/advsimd-intrinsics/vcopy_lane_indices.c:
Don't test this file on 32-bit targets.
Andrew Stubbs [Thu, 9 Jul 2026 16:27:54 +0000 (16:27 +0000)]
amdgcn: Testsuite cond_fmaxnm fixups
These testcases had a typo that means they scan for SFmode twice, and DFmode
never. They were also incompatible with the pattern names in my address vector
patches (not yet committed).
Philipp Tomsich [Thu, 9 Jul 2026 16:08:08 +0000 (18:08 +0200)]
tree-ssa-math-opts: separate FMA-deferring trigger from reassoc reorder
param_avoid_fma_max_bits gates two independent transforms: the
widening_mul FMA-deferring in tree-ssa-math-opts.cc, which leaves a
loop-carried multiply-add as fmul + fadd, and the reassoc
loop-carried-FMA reorder added in r14-5779-g746344dd538
(PR tree-optimization/110279), which parallelises 3+ operand chains.
Both fire when TYPE_SIZE (elt) <= avoid-fma-max-bits, so for a given
type they switch on at the same threshold and a target cannot keep one
while dropping the other.
This hurts the AArch64 AVOID_CROSS_LOOP_FMA cores (the Ampere-1
family): a 2-operand reduction such as an sgemm inner K-loop is left as
fmul + fadd, slower than fmadd on their dispatch-bound pipeline, yet
setting avoid-fma-max-bits to 0 to avoid it also disables the reorder.
Add a new --param=widening-mul-defer-fma (default 1) that gates only the
widening_mul deferring; avoid-fma-max-bits keeps gating the reorder
alone. The AVOID_CROSS_LOOP_FMA callback sets the param to 0. No other
target and no default behaviour changes.
gcc/ChangeLog:
* doc/params.texi (widening-mul-defer-fma): Document.
* params.opt (-param=widening-mul-defer-fma=): New param.
* tree-ssa-math-opts.cc (math_opts_dom_walker::after_dom_children):
Gate fma_deferring_state's enable predicate on
param_widening_mul_defer_fma on top of param_avoid_fma_max_bits.
* config/aarch64/aarch64-tuning-flags.def (AVOID_CROSS_LOOP_FMA):
Update the comment for the widening-mul-defer-fma effect.
* config/aarch64/aarch64.cc (aarch64_override_options_internal):
Inside the AARCH64_EXTRA_TUNE_AVOID_CROSS_LOOP_FMA block, set
param_widening_mul_defer_fma to 0.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/widening-mul-defer-fma-1.c: New test.
* gcc.target/aarch64/widening-mul-defer-fma-2.c: New test.
* gcc.target/aarch64/widening-mul-defer-fma-3.c: New test.
Nathan Sidwell [Mon, 22 Jun 2026 18:26:07 +0000 (14:26 -0400)]
Allow tm files to add generator programs
gcc/
* Makefile.in (genprogrtl, genprogmd, genprogerr, genprog): Append,
rather than set.
* config/riscv/t-riscv: Delete genrvv-type-indexer workaround rule,
it is no longer needed.
Martin Jambor [Thu, 9 Jul 2026 15:17:50 +0000 (17:17 +0200)]
ipa-cp: Only create all-context nodes for local cgraph nodes (PR125207)
IPA-CP contains special logic to create specially marked clones with
constants that come from all callees (that are constant in all
contexts). In the past that was the only case in which the heuristics
tried to assess the effect of multiple constants at once (that is no
longer true since GCC 16) and they are also useful when we realize we
can refine them still further in the case of recursive calls (such as
in testsuite/gcc.dg/ipa/pr93707.c) turn to carry more constants after
the initial "all-context" clone is created.
Unfortunately, the code creating the clones simply redirects all
incoming call graph edges which may include those which were indirect
in the phase of the algorithm which gathered IPA-CP lattices and the
arguments in these calls might contain different values than all
initially known ones, leading to miscompilations like the one in
PR125207.
Since GCC 16 already feeds the heuristics with all known constants
that are passed along with the constant the evaluation was initiated
for, the all-context nodes are really only necessary for the recursive
refinement cases described above. It seems appropriate to only create
them when they are what they are called, when there can be no indirect
or unknown calls to them, i.e. when they are local. This has the nice
effect of simplifying decide_whether_version_node somewhat.
There is some testsuite fallout. First, IPA-CP will now no longer
clone a non-static function to only remove a (non-constant) parameter.
This likely only makes sense with tiny values of param
ipa-cp-eval-threshold or very small functions which are likely going
to be inlined anyway. But gcc.dg/vla-1.c expected that to happen so I
made the function to be cloned static.
The testcase libgomp.c/ipcp-cb-spec1.c stopped working for the same
reason (the outlined task body has its address taken) but looking into
the dumps the test does not seem to test what it is supposed to, the
test function was completely eliminated before IPA. I have therefore
changed it to really propagate constants.
gcc/ChangeLog:
2026-06-02 Martin Jambor <mjambor@suse.cz>
PR ipa/125207
* ipa-cp.cc (decide_about_value): Add detailed dumping about skipping
a value when there are no edges for it. Make dumping about skipping
because of growth limit violation consistent with other cases.
(decide_whether_version_node): Only create all-context nodes for local
nodes, remove the logic doing it in other cases, allow cloning for
single constant lattices for non-local nodes. Adjust dumping.
gcc/testsuite/ChangeLog:
2026-06-02 Martin Jambor <mjambor@suse.cz>
PR ipa/125207
* gcc.dg/ipa/pr125207.c: New test.
* gcc.dg/vla-1.c (f1): Make function f1 static.
James K. Lowden [Thu, 9 Jul 2026 14:42:42 +0000 (10:42 -0400)]
cobol: prevent invalid TYPE reference, and define YYLOCATION_PRINT
gcc/cobol/ChangeLog:
PR cobol/126105
* parse.y: Remove unnecessary test and improve diagnostic message.
* parse_ante.h (yylocation_print): New function.
(YYLOCATION_PRINT): Define, because user-defined cbl_loc_t location.
* symbols.cc (symbol_typedef): Exclude current field from type search.
* symbols.h (symbol_typedef): Delete unused overload.
In riscv_vector_expand_block_move, the memcpy path (!movmem_p) compared
the length against riscv_memcpy_size_threshold but gated the check on
riscv_memmove_size_threshold >= 0. Both params default to -1, so the
memcpy threshold was honored only when the unrelated memmove param was
set, and when memmove was set but memcpy left at -1 the "length > -1"
test rejected every constant-length copy.
Gate the memcpy path on riscv_memcpy_size_threshold, matching the
memmove branch above.
gcc/ChangeLog:
* config/riscv/riscv-string.cc (riscv_vector_expand_block_move):
Gate the memcpy path on riscv_memcpy_size_threshold instead of
riscv_memmove_size_threshold.
Add a pattern for `(trunc)copysign ((extend)x, CST)`. Only the sign of
CST matters, not its value, so it can be simplified to
`copysign (x, -1.0/1.0)` depending on the sign of CST.
For unsigned operands, a widened multiplication compared against the maximum
value of the narrow type is an overflow check when the widened type is at
least twice as precise as the operand type.
Canonicalize the shifted high-half form to the widened comparison form, then
fold the comparison form to IFN_MUL_OVERFLOW when the target has direct
unsigned multiply-overflow support.
gcc/
* match.pd: Canonicalize shifted high-half unsigned multiply
overflow checks to widened comparisons. Simplify widened unsigned
multiply comparison against the narrow type maximum to IFN_MUL_OVERFLOW.
gcc/testsuite/
* g++.target/i386/mul-overflow-widen-1.C: New test.
* g++.target/i386/mul-overflow-widen-2.C: New test.
This patch removes -m31 support and as a consequence -mesa support.
Using the respective command line options result in errors whereas -m64
and -mzarch are still accepted for the sake of backwards compatibility
but do not have any additional effect anymore since those are the
defaults and only options, now.
Since a 64-bit GAS defaults to -m64, do not explicitly specify -m64
-mzarch anymore.
ChangeLog:
* configure: Regenerate.
* configure.ac: Remove deprecation warning for -m31.
contrib/ChangeLog:
* compare-all-tests: Remove opts -m31 and so on.
* config-list.mk: Remove s390-linux-gnu.
gcc/ChangeLog:
* config.gcc: Remove target s390-*. Don't accept
--with-mode=esa anymore.
* config.host: Remove target s390-*.
* config/host-linux.cc (TRY_EMPTY_VM_SPACE): Remove definition
for s390.
* config/s390/2827.md: Remove scheduling information for
mnemonics which are only used by -m31 but not by -m64.
* config/s390/2964.md: Ditto.
* config/s390/3906.md: Ditto.
* config/s390/3931.md: Ditto.
* config/s390/8561.md: Ditto.
* config/s390/9175.md: Ditto.
* config/s390/constraints.md (ZL): Remove TARGET_64BIT test.
* config/s390/driver-native.cc (s390_host_detect_local_cpu):
Remove handling for -mesa/-mzarch.
* config/s390/htmxlintrin.h (__TM_failure_address): Remove
-m31 part.
* config/s390/linux.h: Remove -m31 parts.
* config/s390/predicates.md: Ditto.
* config/s390/s390-builtins.def: Rename RTL expander name for
s390_vsce[fg].
* config/s390/s390-c.cc (s390_cpu_cpp_builtins): Remove
TARGET_{64BIT,ZARCH} tests.
* config/s390/s390-d.cc (s390_d_target_versions): Remove
TARGET_64BIT test.
* config/s390/s390.cc: Remove -m31 parts. In particular, there
is no need to distinguish between 64-bit registers in ABI
contexts anymore which is why UNITS_PER_WORD and UNITS_PER_LONG
always equal, now. Hence, replace UNITS_PER_LONG by
UNITS_PER_WORD.
* config/s390/s390.h: Ditto.
* config/s390/s390.md: Ditto. Mode iterator GPR is replaced by
DSI. Likewise, DGPR by new mode iterator TDSI. Remove mode
iterators P, DW, W because they are singletons, now.
* config/s390/s390.opt: Keep -m64 and -mzarch for backwards
compatibility. Mark -m31 and -mesa as undocumented.
* config/s390/s390.opt.urls: Regenerate.
* config/s390/t-linux64: Remove -m31 parts.
* config/s390/tpf.h (POINTERS_EXTEND_UNSIGNED): This is only
required for TPF which is why it is moved from s390.h here.
(TARGET_DEFAULT): Remove MASK_64BIT and MASK_ZARCH.
* config/s390/vector.md: Remove -m31 parts.
* config/s390/vx-builtins.md
(vec_scatter_element<V_HW_2:mode>_SI): There is no need for
multiplexing different address sizes for vec_scatter_element
anymore.
(vec_scatter_element<V_HW_32_64:mode>): Ditto.
* configure: Regenerate.
* configure.ac: Remove target s390-*.
* doc/install.texi: Remove mentions of s390 without also
referring to s390x.
* doc/invoke.texi: Remove options -m31 and -mesa. Document that
-m64 and -mzarch are the defaults, now, and that they don't have
any additional effect when explicitly specified.
* config/s390/s390x.h: Removed.
Jim Lin [Wed, 8 Jul 2026 23:56:19 +0000 (17:56 -0600)]
[PATCH] RISC-V: Enable TARGET_SFB_ALU for andes-45-series
Enable short forward branch (SFB) ALU support for the andes-45-series
tune, matching the existing sfb_alu scheduling reservation already
present in andes-45-series.md.
Jerry DeLisle [Wed, 8 Jul 2026 17:22:04 +0000 (10:22 -0700)]
fortran: [PR126116] Internal file I/O corrupts NEWUNIT state
Before this fix, Performing an internal file I/O
(such as WRITE to a character variable) incorrectly corrupts
the internal unit management table in libgfortran.
This patch adds a bool to the gfc_unit structure to allow
tracking whether a gfc_unit was created for purposes of
internal I/O to avoid the breakage.
PR libfortran/126116
libgfortran/ChangeLog:
* io/io.h (struct gfc_unit): Add bool for tracking.
Fix some white space problems.
* io/unit.c (close_unit_1): Add a declaration for this
function so it can be called before it has been defined.
Use the new bool.
(is_internal_reserved): New helper function. Returns true
only if the unit is not null and the internal unit kind is zero
meaning its not a character string.
(find_unit): Use the new helper function
(find_or_create_unit): Use the new helper.
(get_unit): Set the new bool.
(close_unit): Update the close_unit_1 argument list.
(close_units): Likewise.
Nathan Myers [Fri, 5 Jun 2026 03:42:11 +0000 (23:42 -0400)]
libstdc++: make trees hetero equal_range O(lg n) [PR118851]
As shipped, the heterogeneous-key members equal_range of rbtree
containers map, multimap, set, and multiset walk the entire range
calling the predicate, in violation of the requirement for
logarithmic complexity. This patch revises them to match the
behavior of the non-heterogeneous multimap and multiset members,
and provides tests to verify it.
libstdc++-v3/Changelog:
PR libstdc++/118851
* include/bits/stl_tree.h (_M_equal_range_tr): Rewrite to match
non-heterogeneous equal_range implementation.
* testsuite/23_containers/map/operations/hetero/equal_range.cc:
New test.
* testsuite/23_containers/multimap/operations/hetero/equal_range.cc:
Same.
* testsuite/23_containers/multiset/operations/hetero/equal_range.cc:
Same.
* testsuite/23_containers/set/operations/hetero/equal_range.cc: Same.
James K. Lowden [Wed, 8 Jul 2026 19:41:04 +0000 (15:41 -0400)]
cobol: Support non-unique section names.
Correct section->paragraph map in the symbol table. Allow section
names to be repeated and for paragraphs in them to be PERFORMed if the
name-pair is unique. Verify all referenced procedures are defined.
gcc/cobol/ChangeLog:
* genapi.cc (parser_call_targets_dump): Remove function.
* genapi.h (parser_call_targets_dump): Same.
* parse.y: Instantiate forward labels consistently.
(label_add) Capture forward references for efficiency.
(paragraph_reference) Use forward reference.
(label_add_once): New function.
* parse_ante.h (label_add_once): Declare function.
(label_instantiate): New function.
(ast_enter_exit_section): Improve debug message.
* symbols.cc (label_cmp): Allow forward reference to have a parent.
(cbl_label_ref_t): Remove class.
(symbol_label): Whitespace.
(symbols_dump): Add information to output.
(symbol_add): Remove program label symbol-assignment to symbol_label_add.
(cbl_label_t::str): Add information to output.
(symbol_label_add): Assign id to program label.
* symbols.h (class cbl_label_ref_t): Remove.
(struct symbol_elem_t): Remove struct keyword.
(struct cbl_label_t): Same.
(struct cbl_special_name_t): Same.
(struct cbl_field_t): Same.
(symbol_typedef): Same.
(symbol_field): Same.
(symbol_label): Same.
(symbol_function): Same.
(symbol_function_any): Same.
(symbol_program): Same.
(symbol_literalA): Same.
(symbol_special): Same.
(symbol_locale): Same.
(symbol_alphabet): Same.
(symbol_file): Same.
(symbol_file_record): Same.
(struct cbl_section_t): Same.
(symbol_section): Same.
(parent_of): Same.
* util.cc: (match_proc::find) Use only section and paragraph names.
Harald Anlauf [Tue, 7 Jul 2026 18:06:35 +0000 (20:06 +0200)]
Fortran: fix resolution of user-defined operators in named BLOCK [PR126127]
PR fortran/126127
gcc/fortran/ChangeLog:
* interface.cc (find_symtree0): Check for NULL pointer.
(gfc_find_sym_in_symtree): Also search user-defined operator list
when the symbol refers to a function.
i386: Fix ccmp support checks for floating-point modes [PR126148]
The ccmp expansion code allowed DFmode, SFmode and HFmode comparisons
without verifying that the corresponding floating-point instruction
set was available. This could result in attempts to generate ccmp
sequences for comparisons that cannot be emitted as a single instruction
under the selected target options.
Restrict XFmode support to x87 targets, DFmode/SFmode support to
targets with either x87 or SSE with SSE math enabled, and HFmode
support to targets with AVX512FP16 enabled.
PR target/126148
gcc/ChangeLog:
* config/i386/i386-expand.cc (ix86_gen_ccmp_first): Restrict
floating-point modes accepted for ccmp according to the
available floating-point instruction set.
Jeff Law [Wed, 8 Jul 2026 18:30:56 +0000 (12:30 -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.
The "1" case has been working well. But -1 has been buggy since inception --
the affected platforms are m68k and gcn, so not getting a ton of testing.
In the "1" case we have to subtract one from the output of the SCC insn to give
us a 0/-1 value for T/F. In the -1 case the SCC naturally gives us the -1
value, so we don't need that subtract one step. But the tense is inverted, ie
-1/0 for T/F and I failed to account for the inverted tense.
This patch obviously fixes the code to handle that inverted tense.
Bootstrapped and regression tested on x86, riscv and m68k. Pushing to the
trunk.
PR rtl-optimization/126136
gcc/
* ifcvt.cc (noce_try_store_flag_logical): Fix for STORE_FLAG_VALUE
of -1.
gcc/testsuite
* gcc.dg/torture/pr126136.c: New test.
Lucas Ly Ba [Sun, 28 Jun 2026 16:04:29 +0000 (18:04 +0200)]
gccrs: add missing_abi lint
Warn on an `extern` block written without an explicit ABI string, such as
a bare `extern { ... }`, which silently defaults to the C ABI. Rust
deprecates this in favour of spelling the ABI out, e.g. `extern "C"`.
The HIR `ExternBlock` only stored the resolved ABI enum, which always
collapses a missing ABI to the C default, so it could not tell a bare
`extern` from `extern "C"`. Carry the AST's `has_abi` flag through
lowering so the lint can distinguish the two.
gcc/rust/ChangeLog:
* hir/tree/rust-hir-item.h (ExternBlock): Track whether the ABI
was explicit and expose it through has_abi.
* hir/tree/rust-hir-item.cc (ExternBlock::ExternBlock): Likewise.
(ExternBlock::operator=): Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_extern_block):
Forward the AST has_abi flag to the HIR node.
* checks/lints/unused/rust-unused-checker.cc (UnusedChecker::visit):
New.
* checks/lints/unused/rust-unused-checker.h (UnusedChecker::visit):
New.
gcc/testsuite/ChangeLog:
* rust/compile/missing-abi_0.rs: New test.
Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
During vtable generation in `compute_address_for_trait_item`, the
compiler was picking the first `impl` block that satisfied the trait
predicate, without verifying if the `impl` block actually belonged to
the target receiver type. This caused dynamic dispatch to call the
wrong methods when multiple types implemented the same trait in the
same scope.
This patch adds a comparison between the impl block's resolved type and
the `receiver` type to ensure we compute the address of the correct
associated function.
gcc/rust/ChangeLog:
* backend/rust-compile.cc
(HIRCompileBase::compute_address_for_trait_item): Ensure the
impl block type matches the receiver type.
gcc/testsuite/ChangeLog:
* rust/execute/trait-multi-impl.rs: New test.
* rust/execute/trait-multi-impl-generic.rs: New test.
* rust/execute/trait-multi-impl-generic2.rs: New test.
Enes Cevik [Tue, 30 Jun 2026 07:14:36 +0000 (10:14 +0300)]
gccrs: intrinsic: Add min_align_of_val
This patch adds the min_align_of_val intrinsic to the compiler. This
intrinsic evaluates the align of a value at runtime, including
Dynamically Sized Types (DSTs).
gcc/rust/ChangeLog:
* backend/rust-compile-intrinsic.cc (generic_intrinsics): Add
min_align_of_val_handler to the map.
* backend/rust-intrinsic-handlers.cc (min_align_of_val_handler):
New function.
* backend/rust-intrinsic-handlers.h (min_align_of_val_handler):
New declaration.
* typecheck/rust-hir-type-check-intrinsic.cc
(IntrinsicChecker::intrinsic_rules): Add min_align_of_val
signature rule to the map.
* util/rust-intrinsic-values.h (class Intrinsics): Add
MIN_ALIGN_OF_VAL constexpr.
Enes Cevik [Mon, 29 Jun 2026 13:03:44 +0000 (16:03 +0300)]
gccrs: intrinsic: Add size_of_val
This patch adds the size_of_val intrinsic to the compiler. This
intrinsic evaluates the size of a value at runtime, including
Dynamically Sized Types (DSTs).
gcc/rust/ChangeLog:
* backend/rust-compile-intrinsic.cc (generic_intrinsics): Add
size_of_val_handler to the map.
* backend/rust-intrinsic-handlers.cc (size_of_val_handler): New
function.
* backend/rust-intrinsic-handlers.h (size_of_val_handler): New
declaration.
* typecheck/rust-hir-type-check-intrinsic.cc
(IntrinsicChecker::intrinsic_rules): Add size_of_val signature
rule to the map.
* util/rust-intrinsic-values.h (class Intrinsics): Add
SIZE_OF_VAL constexpr.
João Novo [Tue, 31 Mar 2026 15:05:03 +0000 (16:05 +0100)]
gccrs: rust: Fix ICE with infer type used in struct attribute
When visiting a struct declaration, add check for when a struct's
attribute is declared as an infer type, emitting an error if true.
Fixes Rust-GCC#3583
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit):
Add check for infer type on struct's attribute or its subtypes.
* typecheck/rust-tyty.cc (BaseType::contains_infer):
Add check for an array type's capacity being an infer type.
gcc/testsuite/ChangeLog:
* rust/compile/infer-type-issue-3583.rs: New test.
Signed-off-by: João Novo <joao.c.novo@tecnico.ulisboa.pt>
Lishin [Fri, 26 Jun 2026 17:54:46 +0000 (17:54 +0000)]
gccrs: Add tests for local binding LIFO and nested block scopes
The new tests verify that multiple local bindings in the
same scope are dropped in LIFO order, and nested block scopes
drop inner bindings before outer bindings.
gcc/testsuite/ChangeLog:
* rust/execute/drop-local-binding-lifo.rs: New test.
* rust/execute/drop-nested-block-scope.rs: New test.
Lishin [Tue, 16 Jun 2026 15:44:11 +0000 (15:44 +0000)]
gccrs: Refactor CompileDrop and add DropBuilder
Refactor CompileDrop to keep Context as a member
instead of passing it to each method.
Move the drop candidate note/peek operations from
Context to DropBuilder. This keeps the drop-specific
API off the compile Context.
gcc/rust/ChangeLog:
* Make-lang.in: Add rust-compile-drop-builder.o.
* backend/rust-compile-base.cc
(HIRCompileBase::compile_function_body):
Update CompileDrop calls.
* backend/rust-compile-block.cc (CompileBlock::visit):
Update CompileDrop calls.
* backend/rust-compile-context.h (Context): Allow
DropBuilder to access drop candidate storage and move
drop candidate APIs to DropBuilder.
* backend/rust-compile-drop.cc (CompileDrop::CompileDrop):
Add constructor.
(CompileDrop::type_has_drop_impl): Use stored Context member.
(CompileDrop::compile_drop_call): Likewise.
(CompileDrop::emit_current_scope_drop_calls): Use stored
Context member and get drop candidates from DropBuilder.
* backend/rust-compile-drop.h: Store Context as a member.
* backend/rust-compile-pattern.cc (CompilePatternLet::visit):
Use DropBuilder and update CompileDrop calls.
* backend/rust-compile-drop-builder.cc: New file.
* backend/rust-compile-drop-builder.h: New file.
Enes Cevik [Tue, 23 Jun 2026 15:42:17 +0000 (18:42 +0300)]
gccrs: backend: Refactor dynamic object fat pointers and vtable generation
Previously, the compiler incorrectly embedded the vtable as an array
directly inside the fat pointer. Furthermore, it lacked essential trait
object metadata such as 'size', 'align' and 'drop_in_place'.
Now, the fat pointer is strictly fixed to 2 words. The vtable is
generated as a separate global static struct and it's structure
correctly includes 'drop_in_place', 'size' and 'align' fields, followed
by trait methods. Also implemented a caching mechanism in the
compilation context to prevent duplicate vtable generation and linker
conflicts for the same Type-Trait combinations.
gcc/rust/ChangeLog:
* backend/rust-compile-context.h (class Context): Add
insert_vtable and lookup_vtable methods.
* backend/rust-compile-expr.cc
(CompileExpr::get_fn_addr_from_dyn): Change access method
array access to struct field access.
* backend/rust-compile-type.cc
(TyTyResolveCompile::create_dyn_obj_record): Create vtable type
as a record instead of an array.
* backend/rust-compile.cc
(HIRCompileBase::coerce_to_dyn_object): Change vtable structure.
Enes Cevik [Fri, 26 Jun 2026 13:40:51 +0000 (16:40 +0300)]
gccrs: intrinsic: Add arith_offset
This patch implements the 'arith_offset' compiler intrinsic. It moves a
pointer forward or backward by a given number of elements. It does not
cause Undefined Behavior if the pointer goes out of bounds.
Lucas Ly Ba [Sat, 27 Jun 2026 19:15:51 +0000 (21:15 +0200)]
gccrs: fix ICE on break with a label and a value
A `break 'label value` expression looks up a temporary variable
associated with the labeled loop to hold the value, but labeled loops
never registered that temporary, leading to an ICE in the code
generator. Register the loop result temporary against the label.
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::visit): Associate the loop
result temporary with the loop label.
gcc/testsuite/ChangeLog:
* rust/compile/break-label-loop.rs: New test.
Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
Lucas Ly Ba [Sat, 27 Jun 2026 19:15:27 +0000 (21:15 +0200)]
gccrs: fix ICE on generic type aliases
A type alias with generic parameters never resolved those parameters
into the type context, so the reachability pass asserted when looking
up their types. Resolve the generic parameters, as the other items do.
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Resolve
the generic parameters of a type alias.
gcc/testsuite/ChangeLog:
* rust/compile/type-alias-generic-params.rs: New test.
Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
Owen Avery [Sun, 28 Jun 2026 04:37:27 +0000 (00:37 -0400)]
gccrs: Detect errors in macro eager expansion
gcc/rust/ChangeLog:
* expand/rust-macro-expand.cc
(MacroExpander::expand_eager_invocations): Handle errors during
eager expansion.
(MacroExpander::expand_invoc): Avoid expanding macros which have
pending eager invocations and return error fragments in more
cases.
gcc/testsuite/ChangeLog:
* rust/compile/macros/builtin/eager4.rs: New test.
gcc/rust/ChangeLog:
* util/rust-lang-item.h (LangItem::Kind): New CSTR kind.
* util/rust-lang-item.cc (LangItem::lang_items): Ditto.
* backend/rust-compile-type.cc (visit(TyTy::ReferenceType)): Add specific record
type for CStr.
* typecheck/rust-tyty.h (ReferenceType): Add function definition for is_dyn_cstr_type.
* typecheck/rust-tyty.cc (ReferenceType::is_dyn_object): Update to include
is_dyn_cstr_type.
(ReferenceType::is_dyn_cstr_type): Add implementation to check whether the
ReferenceType is of type CStr.
* typecheck/rust-hir-type-check-base.cc(resolve_literal): Update C_STRING case to
resolve to the CStr language item instead.
gcc/testsuite/ChangeLog:
* rust/execute/torture/c_string.rs: Add CStr language item definition.
* rust/compile/c_string_null_byte_check.rs: Ditto.
* rust/execute/torture/c_string_ensure_null_term.rs: New test.
gccrs: Add new compiler flag for parsing & compiling C-style string literals
gcc/rust/ChangeLog:
* lang.opt: Add new -frust-c-style-string-literals option.
* parse/rust-parse.h: Import options.h for reading flag_c_style_string_literals.
* parse/rust-parse-impl-expr.hxx (Parser<ManagedTokenSource>::parse_literal_expr):
Abort parsing C-style string literals if flag_c_style_string_literals is not set.
(Parser<ManagedTokenSource>::null_denotation_not_path): Ditto.
gcc/testsuite/ChangeLog:
* rust/execute/torture/c_string.rs: Set -frust-c-style-string-literals.
* rust/compile/c_string_null_byte_check.rs: Set -frust-c-style-string-literals.
Current behaviour is similar to normal string literals, except they are type-checked
as slice types instead of array, and the compiled fat pointer has +1 to size to
include the null terminator.
gcc/rust/ChangeLog:
* lex/rust-token.h (RS_TOKEN_LIST): Add C_STRING_LITERAL and RAW_C_STRING_LITERAL
(unused for now).
* lex/rust-lex.h (Lexer): Define new parse_c_string function.
* lex/rust-lex.cc (Lexer::build_token): Implement lexing for C-style string
literals.
(Lexer::parse_c_string): Add implementation.
* hir/tree/rust-hir-literal.h (HIR::Literal): Define new C_STRING LitType.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_literal): Add new case for
C_STRING.
* parse/rust-parse-impl-attribute.hxx (Parser<ManagedTokenSource>::parse_attr_input):
Add new case for C_STRING.
* parse/rust-parse-impl-expr.hxx (Parser<ManagedTokenSource>::parse_literal_expr):
Add new case for parsing C_STRING.
(Parser<ManagedTokenSource>::null_denotation_not_path): Add new case for C_STRING.
* ast/rust-ast.h (Token::is_string_lit): Add new case for C_STRING_LITERAL.
* ast/rust-ast.cc (AttributeParser::parse_meta_item_inner): Add new case for
C_STRING_LITERAL.
* ast/rust-ast-collector.cc (TokenCollector::visit): Add new case for
C_STRING_LITERAL.
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::resolve_literal):
Implement type checking for the new C_STRING type.
* backend/rust-compile-expr.h (CompileExpr): Define new function
compile_c_string_literal.
* backend/rust-compile-expr.cc (CompileExpr::visit(LiteralExpr)): Add new case
for C_STRING.
(CompileExpr::compile_c_string_literal): Implement compilation of C-style string
literals.
Philip Herron [Wed, 24 Jun 2026 15:28:11 +0000 (16:28 +0100)]
gccrs: Fix ICE when trying to resolve const expr
We cannot resolve N + 1 a this stage since N has no default and is const
generic, rustc makes a more precise error diag here but our one is
completely fine for now.
Fixes Rust-GCC#4302
gcc/rust/ChangeLog:
* backend/rust-compile-resolve-path.cc: use error_mark_node
gcc/testsuite/ChangeLog:
* rust/compile/issue-4302.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Philip Herron [Mon, 22 Jun 2026 20:27:53 +0000 (21:27 +0100)]
gccrs: Implment proper generic associated types
This patch adds in GATs using proper projection types instead of mutating
associated type placeholders during resolution which rapidly becomes very
messy.
The simple case is trait impl handling, entering a trait impl block we first
walk the associated type items and build an ImplTraitFrame for that impl.
This frame records the trait, the impl self type and the mapping from trait
associated items to the impl associated type values. While typechecking
items in that impl we can then look through the active impl trait context
to resolve projections such as `<Self as Trait>::Item`.
The more complex cases need lazy evaluation. A projection can appear
outside the impl body, inside a where-clause binding, behind another
projection, or after substitution has rebound Self and the trait arguments.
For those cases we keep associated types as ProjectionType values carrying
the trait ref, associated item, Self type and substitutions, then normalize
them when the type is actually used. This avoids global associated type
mutation and lets generic associated type arguments compose through
substitution, unification and backend lowering.
Fixes Rust-GCC#4293
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::generate_closure_fntype):
Stop eagerly setting FnOnce::Output
* backend/rust-compile-item.cc (CompileItem::visit): Push impl-trait
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Normalize
projection types
* backend/rust-intrinsic-handlers.cc (discriminant_value): Handle
projection
* checks/errors/privacy/rust-privacy-reporter.cc
(PrivacyReporter::check_base_type_privacy): Skip unresolved
* typecheck/rust-hir-type-check-intrinsic.cc (IntrinsicChecker::check_type): make permissive
* typecheck/rust-autoderef.cc: remove old
* typecheck/rust-hir-impl-trait-context.h: New file.
* typecheck/rust-hir-trait-reference.cc (TraitReference::on_resolved):
Pass the trait reference into item resolution.
(TraitReference::clear_associated_types): Remove.
(TraitReference::clear_associated_type_projections): Remove.
(AssociatedImplTrait::AssociatedImplTrait): Store an impl trait frame
(AssociatedImplTrait::get_frame): New function.
* typecheck/rust-hir-trait-reference.h: Add impl trait context
* typecheck/rust-hir-trait-resolve.cc (TraitItemReference::on_resolved):
Pass trait reference
(TraitItemReference::resolve_item): Represent associated types as
projection types
(TraitItemReference::associated_type_set): Remove.
(TraitItemReference::associated_type_reset): Remove.
(AssociatedImplTrait::setup_raw_associated_types): Remove.
(AssociatedImplTrait::bind_impl_for_projection): New function.
(AssociatedImplTrait::bind_impl_for_bound): New function.
(AssociatedImplTrait::reset_associated_types): Remove.
* typecheck/rust-hir-type-check-base.cc
(TypeCheckBase::ResolvePredicateFromBound): New function.
* typecheck/rust-hir-type-check-base.h
(TypeCheckBase::ResolvePredicateFromBound): Declare.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
Handle projection
(TypeCheckExpr::resolve_fn_trait_call): monomorphized
* typecheck/rust-hir-type-check-implitem.cc
(TypeCheckImplItemWithTrait::visit): Store impl associated types as
projections
* typecheck/rust-hir-type-check-item.cc
(TypeCheckItem::ResolveImplBlockSubstitutions): New function.
(TypeCheckItem::ResolveImplTraitAssociatedTypes): New function.
(TypeCheckItem::validate_trait_impl_block): cleanup
(TypeCheckItem::visit): Split inherent and trait impl handling.
(TypeCheckItem::resolve_impl_block): New function.
(TypeCheckItem::resolve_trait_impl_block): New function.
(TypeCheckItem::resolve_impl_block_substitutions): cleanup
* typecheck/rust-hir-type-check-item.h: helpers
* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::visit):
cleanup
(TypeCheckExpr::resolve_segments): Use lazy projection normalization
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit):
Normalize type path projections and build qualified associated types
* typecheck/rust-hir-type-check.h (class ScopedPush): New class.
(class ImplTraitFrameGuard): New class.
* typecheck/rust-type-util.cc (query_type): Push impl trait frames
while resolving impl items.
(rebind_projection_self_from_fn): New function.
(normalize_projection): New function.
* typecheck/rust-type-util.h (normalize_projection): Declare.
(rebind_projection_self_from_fn): Declare.
* typecheck/rust-typecheck-context.cc
(TypeCheckContext::find_matching_impl_trait_frame): New function.
(TypeCheckContext::have_impl_trait_context): New function.
(TypeCheckContext::push_impl_trait_context): New function.
(TypeCheckContext::pop_impl_trait_context): New function.
(TypeCheckContext::peek_impl_trait_context): New function.
* typecheck/rust-tyty-bounds.cc
(TypeBoundPredicate::apply_argument_mappings): Stop mutating
associated type items for binding arguments.
(TypeBoundPredicateItem::get_tyty_for_receiver): Rebase projections
using trait substitution coordinates.
(TypeBoundPredicate::handle_substitions): Stop mutating associated
type items for binding arguments.
* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Rebind
projection self types after function monomorphization.
* typecheck/rust-tyty-subst.cc
(SubstitutionParamMapping::fill_param_ty): Guard recursive
(SubstitutionRef::get_mappings_from_generic_args): Account for outer
GAT parameters.
(SubstitutionRef::prepare_higher_ranked_bounds): Remove.
(SubstitutionRef::monomorphize): Bind matching impls
* typecheck/rust-tyty-subst.h
(SubstitutionRef::get_outer_param_count): New function.
(SubstitutionRef::prepare_higher_ranked_bounds): Remove.
* typecheck/rust-tyty.cc (BaseType::satisfies_bound): Check
associated type bindings through projection types.
(BaseType::destructure): Stop destructuring through projections.
(BaseType::monomorphized_clone): Normalize projection clones.
(BaseType::is_concrete): Handle projections
(ClosureType::setup_fn_once_output): Remove.
(destructure_through_projections): New function.
(ReferenceType::is_dyn_slice_type): Normalize projections
(ReferenceType::is_dyn_str_type): Likewise.
(ReferenceType::is_dyn_obj_type): Likewise.
(PointerType::is_dyn_slice_type): Likewise.
(PointerType::is_dyn_str_type): Likewise.
(PointerType::is_dyn_obj_type): Likewise.
(ParamType::get_name): Guard recursive
(PlaceholderType::set_associated_type): Remove
(PlaceholderType::clear_associated_type): Remove
(ProjectionType::ProjectionType): Track projection self type and
inherited trait substitutions.
(ProjectionType::is_trait_position): New function
(ProjectionType::get): Handle non-trait-position projections
(ProjectionType::get_self): New function.
(ProjectionType::get_trait_ref): New function.
(ProjectionType::get_item_defid): New function.
(ProjectionType::as_string): Include projection self and trait
(ProjectionType::clone): Clone projection self and preserve bounds
(ProjectionType::handle_substitions): Substitute projection self
* typecheck/rust-tyty.h: Update projection
* typecheck/rust-unify.cc (UnifyRules::go): Normalize projections
(UnifyRules::expect_projection): Support projection-to-projection
gcc/testsuite/ChangeLog:
* rust/compile/gat1.rs: Add lang item setup.
* rust/compile/gat2.rs: Use no_core setup.
* rust/compile/issue-2036.rs: Remove obsolete type inference error.
* rust/compile/issue-2905-2.rs: Enable iterator impl coverage.
* rust/compile/torture/traits18.rs: Move to...
* rust/compile/torture/traits18.rs.disabled: ...here.
* rust/compile/gat3.rs: New test.
* rust/compile/gat4.rs: New test.
* rust/compile/gat5.rs: New test.
* rust/compile/gat6.rs: New test.
* rust/compile/gat7.rs: New test.
* rust/compile/gat8.rs: New test.
* rust/compile/issue-4293.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Jim Lin [Wed, 8 Jul 2026 13:59:30 +0000 (07:59 -0600)]
[PATCH] RISC-V: Fix dead cpop reservation for spacemit-x60
The type "cpop" was listed in both spacemit_x60_alu (latency 1) and the
dedicated spacemit_x60_alu2c reservation (latency 2). Since
spacemit_x60_alu appears first, it always matched cpop and left
spacemit_x60_alu2c dead, so cpop was scheduled with the wrong latency.
Remove cpop from spacemit_x60_alu so the dedicated 2-cycle reservation
takes effect.
gcc/ChangeLog:
* config/riscv/spacemit-x60.md (spacemit_x60_alu): Remove cpop
from the type list.
Richard Biener [Wed, 8 Jul 2026 11:57:17 +0000 (13:57 +0200)]
tree-optimization/126150 - ICE with replace_uses_by
replace_uses_by triggers eventual BB removal from inside a
FOR_EACH_IMM_USE_STMT iteration. That's a no-go since we might
eliminate uses in the list we are currently processing. The
fix is to defer EH edge purging.
PR tree-optimization/126150
* tree-cfg.cc (replace_uses_by): Delay purging of EH edges
until after FOR_EACH_IMM_USE_STMT finished.
Martin Uecker [Sun, 28 Jun 2026 17:29:48 +0000 (19:29 +0200)]
c: harmonize handling of arrays of zero size
Use common functions for creating and detecting arrays of zero size.
The function to detect arrays of zero size is changed to also accept
C++ style representation that are somtimes created (at least in
complete_array_type). A future change may switch to only use this
representation. Other code is refactored to use the new helper functions
and to use flexible_array_member_type_p to properly distinguish between
the two cases (instead of checking for TYPE_MAX_VALUE being NULL_TREE).
As part of this, the explict check for complete types is removed from
composite_type_internal, which may be helpful when potentially allowing
arrays with incomplete element type (which alsoC occur already for
built-in va_arg types).
gcc/c/ChangeLog:
* c-tree.h (zero_length_array_type_p,
c_build_array_type_zero_size) Add prototypes.
* c-decl.cc (zero_length_array_type_p): External linkage.
(c_build_array_type_zero_size): New.
(grokdeclarator): Use new function.
* c-typeck.cc (c_verify_type): New consistency checks.
(c_build_array_type_zero_size): New function
(composite_type_internal): Refactor.
(comptypes_internal): Refactor.
Martin Uecker [Sun, 28 Jun 2026 18:04:14 +0000 (20:04 +0200)]
c: harmonize checking for flex array member type
We already have a helper function to detect the type of a flexible
array member. Rename it for consistency and move it to tree.cc.
Also use the function for some additional cases instead of using a
direct test. In digest_init the change removes the warning for
zero-sized arrays, but it is misleading and redundant as we already
warn for excess initializers (and with -Wpedantic also for the use
of zero-sized arrays).
gcc/c/ChangeLog:
* c-decl.cc (grokdeclarator): Add assertion.
(add_flexible_array_elts_to_size): Adapt.
(is_flexible_array_member_p): Adapt.
(verify_counted_by_attribute): Adapt.
(finish_struct): Adapt.
* c-typeck.cc (check_counted_by_attribute): Adapt.
(build_counted_by_ref): Adapt.
(build_access_with_size_for_counted_by): Adapt.
(handle_counted_by_for_component_ref): Adapt.
(c_incomplete_type_error): Use new helper function.
(digest_init): Use new helper function.
(pop_init_level): Use new helper function.
gcc/ChangeLog:
* tree.h (flexible_array_member_type_p): New helper function.
* tree.cc (flexible_array_member_type_p): New helper function.
(flexible_array_type_p): Use new helper function.
Richard Biener [Wed, 8 Jul 2026 08:06:40 +0000 (10:06 +0200)]
tree-optimization/126159 - handle unions in data dependence analysis
The following implements minimal handling of union accesses in
data reference analysis, namely accesses to non-aggregate fields,
in particular those we are not adding additional subsetting on.
PR tree-optimization/126159
* tree-data-ref.cc (dr_analyze_indices): Handle non-aggregate
union field accesses.
(access_fn_component_p): Adjust.
* gcc.dg/vect/vect-pr126159-1.c: New testcase.
* gcc.dg/vect/vect-pr126159-2.c: Likewise.
Mikael Morin [Mon, 22 Jun 2026 14:53:30 +0000 (16:53 +0200)]
fortran: Create a dedicated type for ranks and array dimensions
This patch adds a type to represent ranks and array dimension, using the
same base type as originally used for the rank in array descriptors
(signed char), but with the stricter bounds (0 to GFC_MAX_DIMENSIONS)
brought to the knowledge of the middle-end. The new type is used for
the rank in array descriptors, and in various places in the compiler as
well, such as loops on array dimensions. Conversions to signed char
are added in places where negative intermediary results were possible,
and loops on array dimensions where the new type is used have been
double-checked to not step backwards (in which case the iteration index
would reach -1 after the last iteration).
gcc/fortran/ChangeLog:
* trans-types.h (gfc_array_dim_rank_type): New type node
declaration.
* trans-types.cc (gfc_array_dim_rank_type): Likewise.
(gfc_init_types) : Initialize the new type node.
(get_dtype_type_node): Use the new type for the rank field.
* trans-descriptor.cc (gfc_conv_descriptor_rank): Likewise.
* trans-const.h (gfc_index_zero_node, gfc_index_one_node): Make
each macro a separate node declaration.
* trans-const.cc (gfc_index_zero_node, gfc_index_one_node):
Declare new nodes.
(gfc_init_constants): Initialize them. Use the new type for the
constants of the gfc_rank_cst array.
* trans-array.cc (gfc_tree_array_size): Use the new type for the
RANK, IDX and DIM variables. Avoid negative intermediary value
in comparison using the new type.
(gfc_conv_array_parameter): Use the new type when assigning a
value to the descriptor's rank. Use the new type for the IDX
variable.
* trans-decl.cc (gfc_conv_cfi_to_gfc): Use the new type for the
rank, and the dimension index variable (including loop initial
value and step).
* trans-expr.cc (gfc_conv_gfc_desc_to_cfi_desc): Likewise.
(gfc_conv_variable): Use the new type for the rank variable.
(gfc_trans_structure_assign): Use the new type when assigning a
value to the descriptor's rank.
* trans-openmp.cc (gfc_omp_get_array_size): Use the new type
for the dimension index variable and the loop initialization,
bound and step.
* trans-intrinsic.cc (gfc_conv_intrinsic_bound): Use the new
type for the DIM argument and the rank.
(conv_intrinsic_cobound): Likewise.
(trans_this_image): Likewise. Use the new type for the loop
variable, initialization, bound and step.
(gfc_conv_intrinsic_sizeof): Likewise.
* trans-stmt.cc (gfc_trans_select_rank_cases): Use signed char
as type for the select value.
Pengfei Li [Mon, 6 Jul 2026 13:11:32 +0000 (13:11 +0000)]
match.pd: Fold SAD_EXPR with identical inputs
Normally, SAD_EXPRs with identical first and second operands are not
constructed, since the absolute difference value is zero. However, this
can still appear when vectorizing small iteration-count reduction loops
with an absolute difference operation.
This patch adds a match.pd rule to fold the redundant SAD_EXPR to its
accumulator operand.
Bootstrapped and tested on aarch64-linux-gnu and x86_64-linux-gnu.
notice how _22 and and the actual vector pointer vectp_x.6_25 start at the
same offset but have a different base. This happens because in
vect_create_addr_base_for_vector_ref we fold the offset into the base very
early and so we can't form or share the address computation anymore with the
scalar address which needs to be there for the alignment checks.
The patch delays this and forms an explicit base + offset and keeping base as
a separate value. This allows VN at the end of vect to share the computations
and we get
Tamar Christina [Wed, 8 Jul 2026 07:34:33 +0000 (08:34 +0100)]
vect: replace iterations bounded to length to for_each
Replace uses of iterators over length of SLP_TREE_SCALAR_STMTS and
SLP_TREE_SCALAR_OPS with for-each loops when the .length () was just being used
as an index.
This is because we are trying to get rid of the notion of the number of scalar
statement or ops determining the number of lanes in the SLP tree and such
iterators are confusing.
i.e. it was a numbered for each.
gcc/ChangeLog:
* tree-vect-data-refs.cc (vect_slp_analyze_store_dependences,
vect_slp_analyze_load_dependences,
vect_slp_analyze_instance_dependence): Use for-each over for with len.
* tree-vect-slp.cc (vect_mark_slp_stmts_relevant,
,vect_find_last_scalar_stmt_in_slp, vect_find_first_scalar_stmt_in_slp,
vect_build_slp_store_interleaving, vect_analyze_slp,
vect_slp_prune_covered_roots, vect_bb_partition_graph_r,
vect_remove_slp_scalar_calls): Likewise.
Richard Biener [Tue, 7 Jul 2026 06:54:45 +0000 (08:54 +0200)]
Improve variadic function call handling in PTA
The following fixes handling of __builtin_va_start handling and
implements .VA_ARG handling in PTA constraint generation to
improve precision around variadic calls. I've added a testcase
for IPA PTA involving an indirect variadic call verifying precision.
The pr99679-1.C no longer emits an expected error that was triggered
by PTA calling aggregate_value_p on the .VA_ARG call which we no
longer do.
* gimple-ssa-pta-constraints.cc (find_func_aliases_for_builtin_call):
Correctly use SCALAR rhs from the variadic argument part of
the function info or from NONLOCAL in case of intra-PTA.
(find_func_aliases_for_call): Handle .VA_ARG.
Philipp Tomsich [Wed, 8 Jul 2026 06:46:25 +0000 (08:46 +0200)]
aarch64: populate issue_info for the ampere1 family
The ampere1, ampere1a and ampere1b tunes leave the vector issue_info
in cpu_vector_cost as NULL, so determine_suggested_unroll_factor bails
out early and reduction loops are never multi-accumulator-unrolled on
these cores. Fill it in from the ampere1 optimization guide (L1D two
128-bit loads plus one store per cycle, four general ops per cycle).
gcc/ChangeLog:
* config/aarch64/tuning_models/ampere1.h (ampere1_scalar_issue_info)
(ampere1_advsimd_issue_info, ampere1_vec_issue_info): New.
(ampere1_vector_cost): Use ampere1_vec_issue_info for issue_info.
* config/aarch64/tuning_models/ampere1b.h (ampere1b_scalar_issue_info)
(ampere1b_advsimd_issue_info, ampere1b_vec_issue_info): New.
(ampere1b_vector_cost): Use ampere1b_vec_issue_info for issue_info.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/ampere1-reduction-unroll-1.c: New test.
there is no need for ix86_expand_call to add clobbers for when one ABI
calls another ABI.
ABI_ALTERNATE is the alternate function ABI from the system ABI. If
ix86_abi is SYSV_ABI, ABI_ALTERNATE is the function ABI for MS_ABI.
Otherwise, ABI_ALTERNATE is the function ABI for SYSV_ABI.
This target hook also properly marks the implicit __tls_get_addr call:
PR target/124798
PR target/125436
* config/i386/i386-expand.cc: Include "function-abi.h".
(x86_64_ms_sysv_extra_clobbered_registers): Removed.
(ix86_expand_call): Don't add explicit call and ABI-switch
clobbers.
* config/i386/i386-features.cc (ix86_emit_tls_call): Call
ix86_tls_get_addr_abi to get GNU TLS ABI and use it, instead of
default_function_abi, for registers clobbered by GNU TLS call.
(ix86_place_single_tls_call): Set CALL_INSN_ABI_ID on TLS calls.
* config/i386/i386-options.cc (ix86_set_current_function): Don't
call reinit_regs.
* config/i386/i386-protos.h
(ix86_type_no_callee_saved_registers_p): Removed.
(ix86_tls_get_addr_abi): New.
* config/i386/i386.cc (ix86_alternate_abi): New prototype.
(ix86_conditional_register_usage): Changed to describe the
system ABI.
(ix86_type_no_callee_saved_registers_p): Make it static.
(ix86_function_value_regno_p): Replace ix86_cfun_abi () with
ix86_abi.
(ix86_save_reg): Only check TYPE_NO_CALLEE_SAVED_REGISTERS as
a special case.
(ix86_tls_get_addr_abi): New.
(legitimize_tls_address): Set CALL_INSN_ABI_ID on TLS calls.
Call ix86_alternate_abi to initialize the alternate function ABI.
(ix86_initialize_abi): New function.
(ix86_no_callee_saved_abi): Likewise.
(ix86_no_caller_saved_abi): Likewise.
(ix86_standard_abi): Likewise.
(ix86_alternate_abi): Likewise.
(ix86_function_abi_id): Likewise.
(ix86_fntype_abi): Likewise.
(ix86_hard_regno_call_part_clobbered): Handle newly added ABIs.
(TARGET_FNTYPE_ABI): New.
* config/i386/i386.md: Add ABI_ALTERNATE, ABI_NO_CALLEE_SAVED,
ABI_NO_CALLER_SAVED_RETURN_VOID, ABI_NO_CALLER_SAVED_RETURN_AX,
ABI_NO_CALLER_SAVED_RETURN_AX_DX,
ABI_NO_CALLER_SAVED_RETURN_AX_XMM0,
ABI_NO_CALLER_SAVED_RETURN_XMM0 and
ABI_NO_CALLER_SAVED_RETURN_XMM0_XMM1.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Co-Authored-by: Richard Sandiford <rdsandiford@googlemail.com> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
call_used_regs is a legacy interface that targets use to tell
init_reg_sets_1 about the default (system) ABI. In x86 terms,
that means the ABI associated with ix86_abi.
Targets can continue to read call_used_regs directly if they
don't have multiple ABIs. But now that x86 does, it's better
to be explicit about which ABI is being queried. This is
currently a nop but becomes important with the upcoming
function_abi patch.
As the comment in ix86_emit_tls_call says:
/* TLS_GD and TLS_LD_BASE instructions are normal functions which
clobber caller-saved registers. [...]
So that function really is querying the system ABI.
Similarly, x86_order_regs_for_local_alloc is called when initialising
a target, rather than once per function, so it too should query the
system ABI.
ix86_save_reg and x86_64_select_profile_regnum ask about the
current function's ABI, which is crtl->abi.
gcc/
* config/i386/i386-features.cc: Include function-abi.h.
(ix86_emit_tls_call): Use default_function_abi instead of
call_used_regs.
* config/i386/i386.cc (x86_order_regs_for_local_alloc): Likewise.
(ix86_save_reg, x86_64_select_profile_regnum): Use crtl->abi
instead of call_used_regs.
i386: Split out call_saved_registers_type detection
There are currently two places that want to query a function's
call_saved_registers_type: ix86_set_func_type (when setting up
cfun->machine) and ix86_type_no_callee_saved_registers_p
(a derived query). The upcoming function_abi patch will add
another one, so this patch splits the code out into a subroutine.
ix86_set_func_type did some of the detection first, into
no_callee_saved_registers, but then ignored the result if
cfun->machine->func_type had already been set. The patch therefore
moves all of the detection after the cfun->machine->func_type test,
rather than moving all of it before.
gcc/
* config/i386/i386-protos.h (ix86_fntype_call_saved_registers):
Declare.
* config/i386/i386-options.cc (ix86_fntype_call_saved_registers): New
function, split out from...
(ix86_set_func_type): ...here. Avoid calling it if the result
would be ignored.
* config/i386/i386.cc (ix86_type_no_callee_saved_registers_p): Use
ix86_fntype_call_saved_registers instead of querying attributes
directly.
Pan Li [Wed, 1 Jul 2026 05:48:17 +0000 (13:48 +0800)]
RISC-V: Add test cases for vzext.vf2 reg overlap
Add test cases for vzext.vf2 register group overlap, please
note it is not overlap as much as possible.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u16-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u16-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u16-m4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u16-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u16-mf4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u32-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u32-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u32-m4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u32-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u8-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u8-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u8-m4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u8-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u8-mf4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u8-mf8.c: New test.