The signature of iconv in SUSv2 and legacy systems used const char** for
the second parameter. We already have a workaround for this in the
<ext/codecvt_specializations.h> header, but were not handling this when
using iconv in src/c++20/format.cc.
Define a concept to check that we can call iconv with a char** and then
use that to decide which type we cast the input pointer to.
libstdc++-v3/ChangeLog:
PR libstdc++/125956
* src/c++20/format.cc [_GLIBCXX_HAVE_ICONV] (iconv_input): New
concept.
(__encoding::conv) [_GLIBCXX_HAVE_ICONV]: Use iconv_input to
decide which type to cast the input pointer to.
Reviewed-by: Tomasz KamiĆski <tkaminsk@redhat.com>
tail-merge: Combine conditions of merged blocks for ccmp [PR102793]
After tail merging combines duplicate blocks, their predecessors
branch to the same successor. Combine the sequential conditions
leading to the merged block using the ifcombine infrastructure; on
targets with conditional compares this lets the backend emit ccmp.
Whether combining is profitable is left to ifcombine's own cost model.
The candidate selection identifies predecessor blocks of the merged
block that have conditional branches, excluding the immediate
dominator. After the tail-merge loop completes, dominance info is
(re)computed, SSA names that may be undefined are marked, and
tree_ssa_ifcombine_bb is called for each candidate.
Combining the scalar conditions that guard a loop would turn the
loop's analyzable entry test into a boolean one, defeating the
number-of-iterations analysis (and thus passes such as ivopts); extend
ifcombine's existing niter-safety check to leave loop guards alone
too.
gcc/ChangeLog:
PR tree-optimization/102793
* tree-ssa-ifcombine.cc (bb_guards_loop_p): New function.
(ifcombine_ifandif): Use it to avoid combining the conditions
guarding a loop.
* tree-ssa-tail-merge.cc: Include tree-ssa-ifcombine.h and
tree-ssa.h.
(ifcombine_candidate_bbs): New static bitmap.
(apply_clusters): Collect the merged block's predecessors as
ifcombine candidates.
(tail_merge_optimize): Run tree_ssa_ifcombine_bb on the candidates;
return TODO_cleanup_cfg when it changed the CFG.
gcc/testsuite/ChangeLog:
PR tree-optimization/102793
* g++.dg/tree-ssa/pr117123.C: --param logical-op-non-short-circuit=0.
* gcc.dg/tree-ssa/pr102793-1.c: New test.
* gcc.dg/tree-ssa/pr102793-2.c: New test.
* gcc.dg/uninit-pred-13.c: New test.
uninit: Relax PHI def predicate by maybe-undef edge conditions
When ifcombine has combined the conditions guarding a definition, the
guard that distinguishes the defined value from the undefined one can
end up on the maybe-undef incoming edge of the merge PHI rather than
on the use's control-dependence chain. The definition-predicate
superset test in uninit_analysis::is_use_guarded then fails on that
conjunct and a bogus -Wmaybe-uninitialized warning is emitted.
When the superset test fails, drop from a copy of the definition
predicate any conjunct implied by the incoming-edge condition of every
maybe-undef operand, and retry. Such a conjunct cannot make the use
unsafe: when it is false the maybe-undef edge is not taken either, so
no undefined value reaches the PHI. The edge condition is found by
walking up single-predecessor forwarder blocks to the controlling
conditional.
gcc/ChangeLog:
* gimple-predicate-analysis.cc (get_pred_info_from_cond_edge):
New function.
(predicate::init_from_control_deps): Use it.
(predicate::drop_conjuncts_implied_by): New method.
(uninit_analysis::is_use_guarded): Retry the superset test
after relaxing the definition predicate by the maybe-undef
edge conditions.
* gimple-predicate-analysis.h (class predicate): Declare
drop_conjuncts_implied_by.
ifcombine: Add tree-ssa-ifcombine.h and update function signatures
This patch adds the tree-ssa-ifcombine.h header file, with the function
declarations for `recognize_if_then_else` and `tree_ssa_ifcombine_bb` and
removes 'static' from the definitions in tree-ssa-ifcombine.cc, so that they
can be used in other passes.
gcc/ChangeLog:
* tree-ssa-ifcombine.cc: Include tree-ssa-ifcombine.h.
(recognize_if_then_else): Removed 'static'.
(tree_ssa_ifcombine_bb): Removed 'static'.
* tree-ssa-ifcombine.h: New file.
AArch64/SVE: Relax the expectations of the popcnt-sve test
When predicated tails are enabled for basic block SLP vectorization,
the assembly language generated by GCC when compiling popcnt-sve.c
will change. Relax the regular expressions used by this test in
preparation.
Currently, analysis of f_v8hi succeeds with vector mode V16QI and the
following GIMPLE is produced:
vector(8) short unsigned intD.19 vect__1.18D.4648;
...
vect__1.18_69 = MEM <vector(8) short unsigned intD.19>
[(short unsigned intD.19 *)vectp.17_68 clique 1 base 1];
vect_patt_60.19_70 = .POPCOUNT (vect__1.18_69);
With predicated tails, analysis instead succeeds with a variable-length
vector mode and the following GIMPLE is produced:
for which aarch64_simd_mov instruction variant taking sub-64-bit vector
operands there is no (w,r) alternative and things blow up later during
reload.
This is a problem specifically in the case of reg-reg transfers and only
when transfer cost between relevant register classes is 2, which, as I've
learned thanks to Andrea's writeup at [0] (and as is confirmed by e.g.
gcc/lra-constraints.cc:4245), is a magic value that tells LRA/reload to not
try different reloads which would have helped here.
The testcase added is a blend between those provided in PR125716 and in
PR125947. As stable as affected tuning models may be, I've opted to
create a dedicated JSON file for this test to guarantee a GP2FP cost of 2.
Bootstrapped and regtested on aarch64-linux-gnu with and without
-mtune=octeontx81.
Jakub Jelinek [Thu, 25 Jun 2026 09:06:37 +0000 (11:06 +0200)]
libstdc++: Fix up bits/std.cc symlink installation
> * src/c++23/Makefile.am (libstdc++.modules.json): Rewrite
> without abspath make function.
> (stamp-modules-bits): Likewise.
> * src/c++23/Makefile.in: Rebuilt.
This change broke various module tests (and got backported even to 15 :( ).
I'm using objdir as a subdirectory of the gcc tree, so ../configure ...
> @@ -57,7 +57,9 @@ std.compat.cc: std.compat.cc.in std-clib.cc.in
> # Also put the interface units in the build-includes bits directory.
> stamp-modules-bits: $(includebits_DATA)
> @-mkdir -p $(top_builddir)/include/bits
> - -cd $(top_builddir)/include/bits && $(LN_S) $(abspath $?) . 2>/dev/null
> + -for f in $(includebits_DATA); do \
> + $(LN_S) $(abs_srcdir)/$$f $(top_builddir)/include/bits; \
> + done 2>/dev/null
> @$(STAMP) $@
>
> all-local: stamp-module-manifest stamp-modules-bits
Before this change, the
/home/jakub/src/gcc/obj38/x86_64-pc-linux-gnu/libstdc++-v3/include/bits
std.cc symlink used to point to
/home/jakub/src/gcc/obj38/x86_64-pc-linux-gnu/libstdc++-v3/src/c++23/std.cc
Now it points to
/home/jakub/src/gcc/obj40/x86_64-pc-linux-g~-v3/../../../libstdc++-v3/src/c++23/std.cc
which doesn't exist, the source directory only has std.cc.in file from which
the std.cc file is generated in the build directory.
The following patch fixes it by using abs_builddir instead of abs_srcdir.
Fixes up
-FAIL: g++.dg/modules/compile-std1.C -std=c++29 (test for excess errors)
-FAIL: g++.dg/modules/compile-std1.C -std=c++29 module-cmi std (gcm.cache/std.gcm)
-FAIL: g++.dg/modules/compile-std1.C -std=c++29 module-cmi std.compat (gcm.cache/std.compat.gcm)
-FAIL: g++.dg/plugin/std-module-exports-c++20.C -fplugin=./std_module_exports_plugin.so (test for excess errors)
-FAIL: g++.dg/plugin/std-module-exports-c++23.C -fplugin=./std_module_exports_plugin.so (test for excess errors)
-FAIL: g++.dg/plugin/std-module-exports-c++26.C -fplugin=./std_module_exports_plugin.so (test for excess errors)
2026-06-25 Jakub Jelinek <jakub@redhat.com>
* src/c++23/Makefile.am (stamp-modules-bits): Use abs_builddir instead
of abs_srcdir.
* src/c++23/Makefile.in: Regenerate.
Xi Ruoyao [Tue, 23 Jun 2026 14:07:34 +0000 (22:07 +0800)]
mips: fix unintialized operand use in sync_{old,new}_<optab>_12 [PR 125628]
In GCC, if the RTL template of define_insn has multiple elements, it's
treated as a parallel expression. And, "in parallel" means that first
all the values used in the invidiviual side-effects are computed, and
second all the actual side-effects are performed. So when the value of
operand 1 (the output reg) is used, it's not set yet.
When optimization is enabled, the uninitialized value is replaced with 0
and then for e.g. if atomic_hiqi_op is plus, (plus (0) (val)) is folded
to simply (val). Now the RTL template happens to be matched by
sync_old_nand_12 (of which the RTL is written in a really inconsistent
way), causing "0 + 1 = -1".
So fix the uninitialized operand use, i.e. (match_dup 0) should be
(match_dup 1). Also slightly alter the source of the set for the memory
in sync_new_<optab>_12 to make it clear the value in the reg and in the
memory should be same after the operation.
gcc/
PR target/125628
* config/mips/sync.md (sync_old_<optab><mode>): Fix
uninitialized operand use.
(sync_new_<optab><mode>): Fix uninitialized operand use, use the
same expression for the set source of operand 0 and 1.
Xi Ruoyao [Sun, 24 May 2026 13:24:37 +0000 (21:24 +0800)]
MIPS: harden SSP set and test routines [PR 125077]
Add the stack_protect_combined_{set,test} expanders to expand the
routines as unsplitable insns which does not leave any sensitive data
(the canary value, the canary address, and all the intermediate values
used materializing the address) in a register. This prevents the
attacker from defeating SSP by probing the canary value from the
register context or overwriting the address spilled onto the stack.
PR target/125077
gcc/
* config/mips/predicates.md (ssp_gp_operand): New
define_predicate.
(ssp_operand): New define_predicate.
(ssp_normal_operand): New define_predicate.
* config/mips/constraints.md (ZA): New define_constraint.
(ZB): New define_constraint.
* config/mips/mips.md (UNSPEC_SSP): New unspec.
(UNSPEC_SSP_GP): New unspec.
(cbranch<mode>4): Add '@' to generate the helper function taking
mode as a parameter.
(@stack_protect_combined_set_normal_<mode>): New define_insn.
(stack_protect_combined_set_abs64): New define_insn.
(@stack_protect_combined_test_internal_<mode>): New define_insn.
(stack_protect_combined_set): New define_expand.
(stack_protect_combined_test): New define_expand.
* config/mips/mips-protos.h (mips_canary_expose_gp_use):
Declare.
(mips_output_asm_load_canary): Declare.
* config/mips/mips.cc (mips_small_data_pattern_1): Don't rewrite
GP-relative symbol wrapped in UNSPEC_SSP_GP.
(mips_canary_expose_gp_use): Implement.
(mips_output_asm_load_canary): Implement.
(mips_print_operand): Allow 'w' to print d/w for DImode/SImode.
Richard Biener [Wed, 24 Jun 2026 06:45:37 +0000 (08:45 +0200)]
tree-optimization/125953 - ICE with vector pattern stmts range query
Vectorizer pattern recog eventually feeds range_of_expr with both
pattern def expressions and pattern context stmts. While that's
IMO not OK the ranger code has some existing defenses against
defs that do not reside in the IL. Just those are incomplete.
The following makes them more robust. I will cleanup the vectorizer
side of things on trunk.
I have documented gimple_ranger::range_of_expr as to how I understand
it works (the different range_of_* APIs seem to behave slightly
different - I find this confusing). Esp. range_of_expr requires
a valid 'r' input range and the return value isn't always reflecting
that something was done.
PR tree-optimization/125953
* gimple-range.cc (gimple_ranger::range_of_expr): Document.
Fall back to global ranges if 'stmt' is not in the IL.
Richard Biener [Wed, 24 Jun 2026 08:43:38 +0000 (10:43 +0200)]
Improve vect_recog_divmod_pattern use of ranger
As we now have a ranger active during vectorization there's no need
to create a new one. And the stmt argument of range_of_expr is for
the context of the range. Passing the def stmt of expr is equal
to asking for global ranges only (passing NULL as stmt).
* tree-vect-patterns.cc (vect_recog_divmod_pattern): Pass
the division stmt as context for the range query on op0.
Use the active ranger.
Richard Biener [Wed, 24 Jun 2026 13:13:31 +0000 (15:13 +0200)]
Forward declare tree_code in coretypes.h
The following changes the reassociation_width target hook to take
a tree_code after recognizing the x86 hook compares against rtx_code PLUS.
Like rtx_code we can now forward declare tree_code to achieve that.
Martin Uecker [Thu, 1 Jan 2026 15:01:31 +0000 (16:01 +0100)]
Built-ins to access code pointer and static chain of nested function.
This patch adds two new built-ins, __builtin_call_code_address and
__builtin_call_static chain, to extract the code address and the static
chain pointer from a (nested) function, respectively. Those can then be
used to call the nested function using the existing built-in
__builtin_call_with_static_chain. This feature can be used to avoid the
creation of trampolines and often allows writing more efficient
code, e.g. where trampolines prevent devirtualization (PR49666).
gcc/ChangeLog:
* builtins.def (BUILT_IN_CALL_CODE_ADDRESS,
BUILT_IN_CALL_STATIC_CHAIN): New.
* builtins.cc (expand_builtin): Emit errors for invalid uses.
(is_simple_builtin): Add new built-in functions.
* gimple-fold.cc (gimple_fold_builtin_call_info): New function.
(gimple_fold_builtin): Expand new built-ins for non-nested functions.
* tree-nested.cc (convert_tramp_reference_stmt): Ingore new built-ins.
(convert_gimple_call): Expand built-ins for nested functions.
* tree-inline.cc (initialize_inlined_parameters): Set a missing
static chain to NULL.
gcc/ChangeLog:
* doc/extend.texi (Constructing Calls): Document
__builtin_call_static_chain and __builtin_call_code_address
and update __builtin_call_with_static_chain.
(Nested Functions): Update.
gcc/testsuite/ChangeLog:
* gcc.dg/builtin-call-info-1.c: New test.
* gcc.dg/builtin-call-info-2.c: New test.
* gcc.dg/builtin-call-info-3.c: New test.
Jan Beulich [Thu, 25 Jun 2026 06:23:42 +0000 (08:23 +0200)]
RISC-V: don't use Python f"..." syntax
While commit fc8e2846c24b ("Fix riscv build, no longer works with
python2") kind of suggests any Python3 is okay to use, the f"..." syntax
has appeared only in Python 3.6. Convert to the traditional "..." % (...)
way of expressing this.
Robert Dubner [Thu, 25 Jun 2026 02:46:34 +0000 (22:46 -0400)]
cobol: Improve MOVE BINARY/COMP-5 to PACKED-DECIMAL and NUMERIC-DISPLAY
These are more efficient algorithms for converting binary values to
packed-decimal and zoned decimal byte strings. There is also an
improved routine that generates GENERIC to do COBOL rounding during
such moves.
gcc/cobol/ChangeLog:
* gengen.cc (gg_abs): Use fold_build1().
* genutil.cc (scale_and_round): Remove function.
(round_this_value): New function for rounding.
* genutil.h (scale_and_round): Remove function.
(round_this_value): New declaration.
* move.cc (cobol_wider_type_with_x_signedness): New function.
(mh_binary_to_numdisp): Faster routine.
(mh_binary_to_packed): Faster routine.
(move_helper): Use the faster routines.
* cobol.dg/group1/simple-classes.cob:
* cobol.dg/group1/simple-if.cob:
* cobol.dg/group2/Rounding_from_BINARY_signable_and_negative.cob: New test.
* cobol.dg/group2/Rounding_from_BINARY_signable_and_negative.out: New test.
* cobol.dg/group2/Rounding_from_BINARY_signable_and_positive.cob: New test.
* cobol.dg/group2/Rounding_from_BINARY_signable_and_positive.out: New test.
* cobol.dg/group2/Rounding_from_BINARY_unsignable.cob: New test.
* cobol.dg/group2/Rounding_from_BINARY_unsignable.out: New test.
Jose E. Marchesi [Wed, 24 Jun 2026 21:57:38 +0000 (23:57 +0200)]
a68: fix comparison of pack element names in packs_ordering
Entry names of packs (struct fields, union alternatives, procedure
parameter list) cannot be compared purely by pointer value. This
patch fixes the union alternative sorting code to not rely on this
false assumption.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog
* a68-moids-sorting.cc (packs_ordering): Do not rely on pointer
comparison when comparing pack element names.
Thomas Schwinge [Wed, 24 Jun 2026 21:26:37 +0000 (23:26 +0200)]
openmp: Add GOMP_loop_static_worksharing and GOMP_distribute_static_worksharing: Adjust 'gcc.dg/autopar/runtime-auto.c'
Fix-up for commit 31ba6ead0d5083010698d9fc0d45c31a4ae1f61d
"openmp: Add GOMP_loop_static_worksharing and GOMP_distribute_static_worksharing",
which (assuming ISL available) regressed:
Jonathan Wakely [Wed, 24 Jun 2026 18:02:35 +0000 (19:02 +0100)]
libstdc++: Disable tests for targets without symlink support
These tests for filesystem::copy_symlink should be disabled on targets
that don't support symlinks (or where the target does, but our
std::filesystem doesn't, such as mingw-w64).
Andrew MacLeod [Tue, 23 Jun 2026 20:11:16 +0000 (16:11 -0400)]
prange zero_p() should never have points to.
Intersection sometimes produced a [0, 0] range with a points to field.
PR tree-optimization/125910
gcc/
* value-range.cc (prange::set_pt): Do not set PT when zero.
(prange::intersect): If the result is zero_p, clear PT.
(prange::verify_range): Verify points-to range is valid.
* value-range.h (zero_p): Do not assert, move to verify range.
(prange::set_pt): Only set PT when the range valid.
Jerry DeLisle [Tue, 23 Jun 2026 19:56:24 +0000 (12:56 -0700)]
fortran: [PR125761] Unlimited-poly character array section base
When a CLASS(*) array section carrying a CHARACTER payload is passed
as the base of an array reference, build_array_ref and
gfc_build_array_ref computed the element span from the dynamic type's
vptr size alone, ignoring the unlimited-polymorphic object's _len
field. For a deferred-length character payload this gave the wrong
element size, so the section's data pointer was offset incorrectly by
the lower bound, producing wrong code (no ICE needed to reproduce: a
section of a CLASS(*) character array passed to a procedure reads from
the wrong address).
PR fortran/125761
gcc/fortran/ChangeLog:
* trans-array.cc (build_array_ref): When the descriptor's
canonical type is a class type, pass the class container as
'decl' to gfc_build_array_ref for genuine array element
references (rank > 0), so the element size can be corrected
for an unlimited-polymorphic character payload.
* trans-types.cc (gfc_typenode_for_spec): Move setting the
GFC_CLASS_TYPE_P bit to..
(gfc_get_derived_type): .. and use attr.is_class.
(gfc_get_derived_type): Move setting the GFC_CLASS_TYPE_P bit
as the last step before returning the derived->backend_decl
if the derived->attr.is_class is true.
Marek Polacek [Tue, 23 Jun 2026 21:39:29 +0000 (17:39 -0400)]
c++/reflection: type traits and reference collapsing [PR125939]
This PR shows that some of our meta type traits don't work with
references: we emit bogus
error: 'const' qualifiers cannot be applied to 'int&'
errors. The problem is that build_stub_type is trying to add
const to a reference, which you can only do through a typedef,
but here we don't have a typedef.
Resolved by passing tf_ignore_bad_quals to cp_build_qualified_type.
The new build_const_lref helper is to spruce up the code a bit.
Vineet Gupta [Wed, 24 Jun 2026 16:19:46 +0000 (09:19 -0700)]
dwarf: fix inconsistency in type chains traversal [PR125421]
typedef chain traversal could sometimes skip an intermediate type.
This could happen when two DIEs have a common underlying type but diverge
due to presence of additional attribute in one case and a qualifier in
other.
In the example from testcase, variable "perm" typechain misses interim u16.
What makes this issue worse is depending on the order in which the types
are specified in source, and processed, the problem may or maynot show up.
So in the test code above if lines 3 and 4 are swppaed, "perm" gets the
missing type u16 as expected.
The issue is in modified_type_die (), get_qualified_type (type) returned
pointer may not be identical to dtype: TREE_TYPE (TYPE_NAME (qualified_type))
while having the same underlying base type. And due to the failed
pointer identity test, subsequent usage of DECL_ORIGINAL_TYPE () for recursive
chain processing can peel away the needed type.
The implications are for a multi CU build, structurally similar but
non identical variants of types (due to an embedded member getting a
different chained typdef) can be generated and accumulate at link time
in the final .debug_info.
This would be OK / unnoticed for usual dwarf debugging purposes.
However in BFP workflow: kernel binary linking invokes pahole to process
the dwarf and dedup it for btf generation (gcc can emit btf directly but
thats not been done currently for other reasons). The slightly different
variations of same structure due to thi issue cause combinatiorial explosion
in pahole dedup processing trying to match and failing repeatedly in what
seems like infinite recursion. The problem showed up and was excerbated
when trying to enable attr btf_type_tag in kernel with gcc for the first
time as that is the key ingredient to trigger the latent issue.
Fix is to handle qualified_type != dtype as if they were identical when
they are different variant nodes of the same underlying typedef.
Bootstrapped and regtested on x86 and aarch64.
PR debug/125421
gcc/ChangeLog:
* dwarf2out.cc (modified_type_die): Handle qualified_type being
a variant of dtype as if they were identical to avoid peeling a
typdef.
For named types, use dentry unconditionally as that is valid for
both cases of qualified_type == and != dentry.
Tomasz KamiĆski [Tue, 23 Jun 2026 17:12:01 +0000 (19:12 +0200)]
libstdc++: Correct export checks for _GLIBCXX_EXTERN_TEMPLATE
Replace a basic_string specific _GLIBCXX_EXTERN_TEMPLATE > 0 with
simple check for _GLIBCXX_EXTERN_TEMPLATE. This make sure that
extern definition is also use for -O0 (default).
Exported declarations are also important for future extensibility,
as they always pick latest implementation.
libstdc++-v3/ChangeLog:
* include/std/format (__do_vformat_to): Change the preprocessor
check for __do_vformat_to.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz KamiĆski <tkaminsk@redhat.com>
Alexandre Oliva [Wed, 24 Jun 2026 13:47:25 +0000 (10:47 -0300)]
work around ppc-vx6 make limitations
libstdc++-v3 in gcc-15 gained uses of a make function that was added
in GNU make 3.81, but ppc-vx6 is GNU make 3.80, so calling the
function returns an empty string, and the build fails.
gcc/doc/install.texi states GCC requires make 3.80 to build, so
rewrite those bits to avoid the new function.
Install locations don't need abspath because they're already supposed
to be absolute, since installation can't work with relative paths and
DESTDIR is supposed to be prependable.
$? may gain the srcdir VPATH, which would complicate dropping abspath,
so iterate over the two filenames.
for libstdc++-v3/ChangeLog
* src/c++23/Makefile.am (libstdc++.modules.json): Rewrite
without abspath make function.
(stamp-modules-bits): Likewise.
* src/c++23/Makefile.in: Rebuilt.
Alexandre Oliva [Wed, 24 Jun 2026 13:47:22 +0000 (10:47 -0300)]
libstdc++: vxworks: enable gthread_yield
ac_has_sched_yield is a bit of a misnomer in libstdc++-v3, as it
guards the __gthread_yield call. That call is implemented on VxWorks,
even where it doesn't support POSIX sched_yield() proper. So enable
it.
openmp: Add GOMP_reduction_start and GOMP_reduction_end
When lowering reduction clauses, the compiler brackets the critical section
around the accumulation step with calls to GOMP_atomic_start and
GOMP_atomic_end. These are the same entry points used for `#pragma omp atomic'
constructs, so OMPT cannot distinguish reductions from user atomics.
Introduce dedicated GOMP_reduction_start and GOMP_reduction_end entry
points in libgomp. Update omp-low to emit calls to the new builtins
instead.
Also register the new builtins as memory barriers to avoid illegal optimisations
in later passes.
gcc/ChangeLog:
* omp-builtins.def (BUILT_IN_GOMP_REDUCTION_START): New builtin.
(BUILT_IN_GOMP_REDUCTION_END): New builtin.
* omp-low.cc (lower_reduction_clauses): Replace
BUILT_IN_GOMP_ATOMIC_START / BUILT_IN_GOMP_ATOMIC_END with
BUILT_IN_GOMP_REDUCTION_START / BUILT_IN_GOMP_REDUCTION_END.
(lower_omp_sections): Likewise.
(lower_omp_scope): Likewise.
(lower_omp_for): Likewise.
* tree-ssa-alias.cc (check_fnspec): Handle
BUILT_IN_GOMP_REDUCTION_START and BUILT_IN_GOMP_REDUCTION_END as
memory barriers.
libgomp/ChangeLog:
* atomic.c (GOMP_reduction_start): New function.
(GOMP_reduction_end): New function.
* libgomp.map (GOMP_6.0.2): Export GOMP_reduction_start and
GOMP_reduction_end.
* libgomp_g.h (GOMP_reduction_start): New declaration.
(GOMP_reduction_end): New declaration.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/atomic-builtins-1.c: New test.
* c-c++-common/gomp/reduction-builtins-1.c: New test.
openmp: Add barrier kind to GOMP_barrier and GOMP_barrier_cancel
GOMP_barrier is called for at least three distinct purposes: implicit
barriers at the end of parallel/teams regions, implicit barriers at the
end of worksharing constructs, and explicit `#pragma omp barrier'
directives. OMPT requires distinguishing these in its sync-region
callbacks.
Create new, semantically equivalent functions GOMP_barrier_ext and
GOMP_barrier_cancel_ext with an integer `kind' parameter. Update all compiler
call sites to pass the appropriate constant. Preserve now unused functions
GOMP_barrier and GOMP_barrier_cancel for backward compatibility.
The `kind' parameter is accepted but not yet acted upon in libgomp; it
is reserved for future OMPT instrumentation.
gcc/c-family/ChangeLog:
* c-omp.cc (c_finish_omp_barrier): Pass GOMP_BARRIER_EXPLICIT to
GOMP_barrier_ext.
gcc/cp/ChangeLog:
* semantics.cc (finish_omp_barrier): Push GOMP_BARRIER_EXPLICIT
onto the argument vector.
gcc/fortran/ChangeLog:
* trans-openmp.cc (gfc_trans_omp_barrier): Pass GOMP_BARRIER_EXPLICIT
to GOMP_barrier_ext.
gcc/ChangeLog:
* omp-builtins.def (BUILT_IN_GOMP_BARRIER): Change function to
GOMP_barrier_ext and type to BT_FN_VOID_INT.
(BUILT_IN_GOMP_BARRIER_CANCEL): Change function to
GOMP_barrier_cancel_ext and type to BT_FN_VOID_INT.
* omp-expand.cc (expand_omp_for_static_nochunk): Pass
GOMP_BARRIER_IMPLICIT_WORKSHARE to omp_build_barrier.
(expand_omp_for_static_chunk): Likewise.
(expand_omp_single): Likewise.
* omp-general.cc (omp_build_barrier): Add kind parameter; pass it
to GOMP_barrier_ext or GOMP_barrier_cancel_ext.
* omp-general.h (omp_build_barrier): Update declaration to add
kind parameter.
* omp-low.cc (lower_rec_input_clauses): Determine barrier kind from
the enclosing gimple statement code and pass it to omp_build_barrier.
(lower_omp_for_scan): Pass GOMP_BARRIER_IMPLICIT_WORKSHARE to
omp_build_barrier.
include/ChangeLog:
* gomp-constants.h (GOMP_BARRIER_IMPLICIT_PARALLEL): New macro.
(GOMP_BARRIER_IMPLICIT_WORKSHARE): New macro.
(GOMP_BARRIER_EXPLICIT): New macro.
libgomp/ChangeLog:
* barrier.c (GOMP_barrier_ext): New function.
(GOMP_barrier_cancel_ext): Likewise.
* libgomp_g.h (GOMP_barrier_ext): Declare.
(GOMP_barrier_cancel_ext): Likewise.
* libgomp.map (GOMP_6.0.2): Add GOMP_barrier_ext and
GOMP_barrier_cancel_ext.
* testsuite/libgomp.c/barrier-1.c: Update GOMP_barrier_ext calls to pass
GOMP_BARRIER_EXPLICIT.
gcc/testsuite/ChangeLog:
* g++.dg/gomp/barrier-1.C: Update scan dump.
* g++.dg/gomp/tpl-barrier-1.C: Likewise.
* gcc.dg/gomp/barrier-1.c: Likewise.
* c-c++-common/gomp/implicit-barrier-1.c: New test.
* gfortran.dg/gomp/lastprivate-allocatable-barrier-1.f90: New test.
openmp: Add GOMP_loop_static_worksharing and GOMP_distribute_static_worksharing
For static-schedule worksharing loops (`omp for schedule(static)') the
compiler emits two separate calls -- omp_get_thread_num() and
omp_get_num_threads() -- to obtain the thread id and count. Similarly,
for `omp distribute' constructs, it emits omp_get_team_num() and
omp_get_num_teams(). Because these are public OpenMP API routines, OMPT
cannot distinguish them from user-level queries.
Introduce two new libgomp entry points:
- GOMP_loop_static_worksharing(): returns both the thread id and the thread
count packed into a single complex value.
- GOMP_distribute_static_worksharing(): same, but for team id and team
count.
Using a single return value rather than two output-pointer arguments
preserves optimisations in later passes.
gcc/ChangeLog:
* builtin-types.def (BT_COMPLEX_INT, BT_FN_COMPLEX_INT): New types.
* omp-builtins.def (BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING): New
builtin.
(BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING): Likewise.
* omp-expand.cc (expand_omp_for_static_nochunk): Replace separate calls
to public API functions with a single call to
GOMP_loop_static_worksharing or GOMP_distribute_static_worksharing, then
unpack id and count.
(expand_omp_for_static_chunk): Likewise.
gcc/fortran/ChangeLog:
* types.def (BT_COMPLEX_INT): New type.
(BT_FN_COMPLEX_INT): New function type.
libgomp/ChangeLog:
* config/gcn/teams.c (GOMP_distribute_static_worksharing): New
function.
* config/nvptx/teams.c (GOMP_distribute_static_worksharing): Likewise.
* libgomp.map (GOMP_6.0.2): Export GOMP_loop_static_worksharing and
GOMP_distribute_static_worksharing.
* libgomp_g.h (GOMP_loop_static_worksharing): New declaration.
(GOMP_distribute_static_worksharing): Likewise.
* parallel.c (GOMP_loop_static_worksharing): New function.
* teams.c (GOMP_distribute_static_worksharing): Likewise.
For the `omp master' and `omp masked filter(x)' constructs, the compiler lowers
the filter check by emitting omp_get_thread_num() == filter. Because
omp_get_thread_num is a public OpenMP API function, OMPT cannot distinguish this
internal check from a user-level thread-number query.
Introduce GOMP_has_masked_thread_num(int tid), a new libgomp entry point that
encapsulates the thread id check, and update lower_omp_master to call it instead
of building the comparison inline.
gcc/ChangeLog:
* omp-builtins.def (BUILT_IN_GOMP_HAS_MASKED_THREAD_NUM): New builtin.
* omp-low.cc (lower_omp_master): Call it.
libgomp/ChangeLog:
* libgomp.map (GOMP_6.0.2): New symbol version. Export
GOMP_has_masked_thread_num.
* libgomp_g.h (GOMP_has_masked_thread_num): New declaration.
* parallel.c (GOMP_has_masked_thread_num): New function.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/masked-1.c: Add scan directives verifying that
GOMP_has_masked_thread_num is emitted and omp_get_thread_num is not.
* g++.dg/gomp/master-3.C: Update scan-tree-dump-times to look for
GOMP_has_masked_thread_num instead of omp_get_thread_num.
* gcc.dg/gomp/master-3.c: Likewise.
* gfortran.dg/gomp/masked-1.f90: Add scan directive for
GOMP_has_masked_thread_num.
The following expands the RMW bit clear/set pattern detection to
also cover VIEW_CONVERT_EXPR as it appears when generic word_mode
vectorization is involved.
PR tree-optimization/110743
* tree-ssa-uninit.cc (maybe_warn_operand): Also cover
VIEW_CONVERT_EXPR uses for RMW bit clear/set pattern
detection.
This patch adds support for VSX vector arithmetic instructions that may
be added to future PowerPC processors. Note that the names of these
builtins may change in the future.
New VSX patterns are added for vector add, subtract, multiply, and
multiply-high instructions guarded by TARGET_FUTURE. A new builtin
enablement stanza future-vsx is added for builtins requiring
both -mcpu=future and -mvsx.
gcc/
* config/rs6000/altivec.md (V16QI_V2DI): New mode iterator.
(add<mode>3): Split into two patterns to support future ISA
alternatives.
(sub<mode>3): Likewise.
* config/rs6000/vsx.md (VIArith): New mode iterator.
(vsx_mul<mode>3): New insn pattern.
(smul<mode>3_highpart): Split into mode-specific patterns.
(umul<mode>3_highpart): Likewise.
(smulv8hi3_highpart): New insn pattern.
(smulv4si3_highpart): Likewise.
(smulv2di3_highpart): Likewise.
(umulv8hi3_highpart): Likewise.
(umulv4si3_highpart): Likewise.
(umulv2di3_highpart): Likewise.
* config/rs6000/rs6000-builtins.def (__builtin_vsx_xvmulhuh): New
builtin.
(__builtin_vsx_xvmulhsh): Likewise.
* config/rs6000/rs6000-overload.def (__builtin_vec_mulh): Add
overloads for vector multiply-high signed/unsigned halfword.
* config/rs6000/rs6000-gen-builtins.cc (enum bif_stanza): Add entry for
BSTZ_FUTURE_VSX.
(stanza_map): Add future-vsx stanza mapping.
(enable_string): Add ENB_FUTURE_VSX.
(write_decls): Add ENB_FUTURE_VSX to the bif_enable enum in the
generated header file.
* config/rs6000/rs6000.md (define_attr "isa"): Add future to the list
of ISA values.
(define_attr "enabled"): Add check for future ISA.
* config/rs6000/rs6000-builtin.cc (rs6000_invalid_builtin): Handle
ENB_FUTURE_VSX and issue a diagnostic requiring -mcpu=future and -mvsx.
(rs6000_builtin_is_supported): Return TARGET_FUTURE && TARGET_VSX
for ENB_FUTURE_VSX built-ins.
* doc/extend.texi (PowerPC AltiVec/VSX Built-in Functions Available
on Future ISA): Document new functions.
AArch64/SVE: Optimize vec_init for partial SVE vector modes
When basic block vectorization is extended to support predicated
vector tails, it attempts to vectorize more stores. This is only
done if the cost model deems it profitable, but the cost model
assumes that vec_init is cheap; in practice, that was not always
true.
which is not yet optimal but is a great improvement.
To achieve that, "vec_init<mode><Vel>" was modified to
accept all SVE vector modes, which means that the
associated function aarch64_sve_expand_vector_init
must now handle all partial modes (namely, VNx8QI, VNx4QI,
VNx2QI, VNx4HI, VNx2HI, VNx2SI, VNx2HF, VNx4HF, VNx2SF,
VNx2BF, VNx4BF).
I verified that the following dependencies already
handle partial vector modes:
- "@aarch64_sve_<perm_insn><mode>" (for ZIP1)
- "*vec_duplicate<mode>_reg"
- maybe_code_for_aarch64_sve_rev
I did not verify that emit_move_insn (which is a dependency
of aarch64_sve_expand_vector_init_handle_trailing_constants)
handles partial vector modes, but it seems highly likely.
"vec_shl_insert_<mode>" has been modified to accept SVE_ALL
instead of only SVE_FULL and operate on container instead of
element types.
gcc/ChangeLog:
* config/aarch64/aarch64-sve.md: Update
vec_init<mode><Vel> and vec_shl_insert_<mode> to
accept all SVE vector modes.
Increase the branch misprediction scale for generic tuning from
COSTS_N_INSNS (2) to COSTS_N_INSNS (2) + 3.
Modern CPUs have deeper pipelines, making branch mispredictions more
expensive. Increasing this cost encourages if-conversion, avoiding
pipeline stalls from mispredicted branches.
This improves 544.nab_r (-O2) by 12.7% on GNR and 12.1% on Znver5 with
single-copy.
gcc/ChangeLog:
* config/i386/x86-tune-costs.h (generic_cost): Increase branch
mispredict scale from COSTS_N_INSNS (2) to COSTS_N_INSNS (2) + 3.
Tobias Burnus [Wed, 24 Jun 2026 05:15:04 +0000 (07:15 +0200)]
libgomp: Move internal NUMA function to a separate file [PR125940]
At the previous location (affinity.c), the real and the fallback
implementation of the NUMA functions were both in that file when
HAVE_PTHREAD_AFFINITY_NP was unset. Solved by moving the internal
NUMA functions into a separate file. Follow up to commit r17-1702-g8af1592882509f.
libgomp/ChangeLog:
PR libgomp/125940
* Makefile.am (libgomp_la_SOURCES): Add numa.c.
* Makefile.in: Regenerate.
* affinity.c (gomp_get_current_numa_node,
gomp_get_numa_distance): Move to ...
* numa.c: ... this new file.
* config/linux/affinity.c (gomp_get_current_numa_node,
gomp_get_numa_distance): Move to ...
* config/linux/numa.c: ... this new file.
Tobias Burnus [Wed, 24 Jun 2026 04:30:25 +0000 (06:30 +0200)]
libgomp: Handle omp_default_device in the fallback case [PR125951]
Support for omp_default_device was added before the commit r17-1702-g8af1592882509f for the Linux case, but for the fallback
case, it was missed - such that the testcase failed on all
non-Linux systems.
libgomp/ChangeLog:
PR libgomp/125951
* target.c (omp_get_device_distances): Handle omp_default_device
in the fallback code.
Jason Merrill [Tue, 23 Jun 2026 21:28:36 +0000 (17:28 -0400)]
c++/modules: dependent ADL laziness [PR125334]
I was digging into modules for another bug and remembered an earlier thought
that a possible further improvement for this PR would be to just mark the
ADL functions as reachable, not actual dependencies of the current entity.
This turns out to be as simple as removing the call to add_dependency; the
test still passes, but now the ADL functions are loaded lazily because they
have their own dependency groups instead of being tightly coupled to the
call site.
This provides a speed-up of about 24% on the performance test in this PR
with my debugging build of trunk.
Here A<S> is not instantiated in _a, so the exported a_s typedef is to an
incomplete type. It's instantiated in _b, but when marking things reachable
we get as far as the imported typedef and stop, so we don't write out the
instantiation. Then in _c we read in the definition of Outer with an
incomplete type for 'sub', and ICE when trying to initialize it in the
constructor.
Fixed by looking into the DECL_ORIGINAL_TYPE of an imported typedef when
gathering dependencies.
PR c++/125768
gcc/cp/ChangeLog:
* module.cc (trees_out::decl_node): When not streaming,
recurse into DECL_ORIGINAL_TYPE of an imported typedef.
gcc/testsuite/ChangeLog:
* g++.dg/modules/alias-3_a.C: New test.
* g++.dg/modules/alias-3_b.C: New test.
* g++.dg/modules/alias-3_c.C: New test.
* c-parser.cc (c_parser_omp_iterators): Use iterator constructors
and macros for accessing iterator elements.
(c_parser_omp_clause_affinity): Likewise.
(c_parser_omp_clause_depend): Likewise.
(c_parser_omp_clause_map): Likewise.
(c_parser_omp_clause_from_to): Likewise.
* c-typeck.cc (c_omp_finish_iterators): Likewise.
gcc/cp/
* parser.cc (cp_parser_omp_iterators): Use iterator constructors
and macros for accessing iterator elements.
(cp_parser_omp_clause_affinity): Likewise.
(cp_parser_omp_clause_depend): Likewise.
(cp_parser_omp_clause_from_to): Likewise.
(cp_parser_omp_clause_map): Likewise.
* pt.cc (tsubst_omp_clause_decl): Likewise.
* semantics.cc (cp_omp_finish_iterators): Likewise.
gcc/fortran/
* trans-openmp.cc (gfc_trans_omp_array_section): Use macros for
accessing iterator elements.
(handle_iterator): Likewise, plus the iterator constructor.
(gfc_trans_omp_clauses): Likewise.
gcc/
* gimplify.cc (gimplify_omp_affinity): Use macros for accessing
iterator elements.
(compute_omp_iterator_count): Likewise.
(build_omp_iterator_loop): Likewise.
(copy_omp_iterator): Use a boolean to force creation of an
expanded iterator vector, instead of specifying the length explicitly.
(remove_unused_omp_iterator_vars): Use accessor macros.
(build_omp_iterators_loops): Likewise.
(enter_omp_iterator_loop_context_1): Likewise.
(extract_base_bit_offset): Likewise.
* omp-low.cc (lower_omp_map_iterator_expr): Likewise.
(lower_omp_map_iterator_size): Likewise.
* tree-inline.cc (copy_tree_body_r): Likewise.
* tree-pretty-print.cc (dump_omp_iterators): Likewise.
* tree.h (OMP_ITERATOR_VAR, OMP_ITERATOR_BEGIN, OMP_ITERATOR_END,
OMP_ITERATOR_STEP, OMP_ITERATOR_ORIG_STEP, OMP_ITERATOR_BLOCK,
OMP_ITERATOR_LABEL, OMP_ITERATOR_INDEX, OMP_ITERATOR_ELEMS,
OMP_ITERATOR_COUNT, OMP_ITERATOR_EXPANDED_P): New macros.
(make_omp_iterator, make_expanded_omp_iterator): New constructor
functions.
James K. Lowden [Tue, 23 Jun 2026 20:36:41 +0000 (16:36 -0400)]
cobol: accept CDF PROCESS directive
If the IBM PROCESS directive appears before IDENTIFICATION DIVISION
with -dialect ibm, it is now a warning. In all other cases it is an
error. Controlled by -Wibm-cdf. Fixes RT 3609.
Jerry DeLisle [Fri, 19 Jun 2026 21:54:00 +0000 (14:54 -0700)]
fortran: Fix memory leak for array structure-constructor element [PR121972]
Fix the remaining leak in pdt_86.f03. Added a new test in asan to avoid it.
PR fortran/121972
gcc/fortran/ChangeLog:
* trans-array.cc (has_class_alloc_comp): New helper; returns true if
derived type DER has any CLASS component.
(gfc_trans_array_ctor_element): Also free allocatable components when
the element expression is EXPR_STRUCTURE, skipping types that contain
CLASS components to avoid freeing stack-allocated _data pointers.
(gfc_constructor_is_owned_alloc_comp): Likewise treat EXPR_STRUCTURE
elements as owned only when the derived type has no CLASS components.
* trans-expr.cc (gfc_trans_alloc_subarray_assign): Free allocatable
components of the component's temporary descriptor before nulling its
data pointer, for non-variable source expressions.
Harald Anlauf [Mon, 22 Jun 2026 20:07:43 +0000 (22:07 +0200)]
Fortran: -fc-prototypes, deferred shape and deferred length dummies [PR125902]
PR fortran/125902
gcc/fortran/ChangeLog:
* dump-parse-tree.cc (get_c_type_name): Use CFI_cdesc_t also for
deferred shape and deferred length dummies, as well as for
assumed-length scalar character dummies.
James K. Lowden [Tue, 23 Jun 2026 16:00:25 +0000 (12:00 -0400)]
cobol: Elevate keyword priority.
Move keyword patterns higher in the lexer file, giving them higher
priority than user-defined names. Fix tests that allowed keywords for
Program-ID, which must be a user-defined name. Fixes PR 119933.
gcc/cobol/ChangeLog:
* parse.y: Restrict Program-ID as name to top-level.
* scan.l: Elevate keyword priority in lexer.
Robin Dapp [Thu, 30 Apr 2026 10:07:13 +0000 (12:07 +0200)]
ira: Add dependent filter handling.
This adds dependent-filter handling to ira in a similar way register
filters where added. The actual querying of the filter is partially
routed to the lra routines introduced before.
gcc/ChangeLog:
* ira-build.cc (ira_create_allocno): Initialize dependent
filters.
(copy_dependent_filters): New function to copy filters.
(create_cap_allocno): Use new function.
(propagate_allocno_info): Ditto.
(propagate_some_info_from_allocno): Ditto.
* ira-color.cc (ira_dependent_filter): New function that
calls lra_get_dependent_filter.
(assign_hard_reg): Use new function.
(improve_allocation): Ditto.
(fast_allocation): Ditto.
* ira-conflicts.cc (dependent_filter_same_reg_ok_p): New
function to check if a dependent filter allows the same reg.
(can_use_same_reg_p): Use new function.
* ira-int.h (struct ira_dependent_filter): New struct holding
allocno-specific dependent-filter properties.
(ALLOCNO_DEPENDENT_FILTERS): New accessor.
(ira_add_dependent_filter): Declare.
* ira-lives.cc (ira_add_dependent_filter): New function.
(process_dependent_filters): New function.
(process_bb_node_lives): Call new function.
* ira.cc (ira): Reset filters.
Robin Dapp [Wed, 29 Apr 2026 07:37:19 +0000 (09:37 +0200)]
RISC-V: Example dependent filter for RVV widen overlap.
This is an example of how a dependent filter would look like.
In RVV sources of widening instructions cannot overlap the
destination except in the highest-numbered part (for EMUL>1).
The dependent filter attached to the constraint "Wtt" is
implemented in riscv_widen_operand_ok.
gcc/ChangeLog:
* config/riscv/constraints.md (TARGET_VECTOR ? V_REGS : NO_REGS):
Add widen overlap dependent constraint.
* config/riscv/riscv-protos.h (riscv_widen_overlap_ok): Declare.
* config/riscv/riscv.cc (riscv_widen_operand_ok): New function.
* config/riscv/vector.md: Use new constraint.
Robin Dapp [Wed, 29 Apr 2026 08:02:05 +0000 (10:02 +0200)]
lra: Support dependent filters.
This patch adds dependent-filter support to lra. As with register
filters, this is the part that ensures correctness, while the later
ira patch improves register allocation.
As dependent filters can be expensive, the patch adds a hash-table
cache that is integrated into lra_get_dependent_filter.
In order to keep track of dependent filters during pseudo phases, the
patch adds a vector of them to lra_reg. It is filled after reloading
and queried in find_hard_regno_for_1 so we can fold it into
conflict_set.
gcc/ChangeLog:
* lra-assigns.cc (find_hard_regno_for_1): Query dependent
filter of current pseudo.
* lra-constraints.cc (struct dependent_filter_cache_hasher): New
hasher.
(lra_init_dependent_filter_cache): New function.
(lra_finish_dependent_filter_cache): Ditto.
(lra_reset_dependent_filters): Ditto.
(lra_get_dependent_filter): New function to query (and add)
a dependent filter from/to the cache.
(lra_add_dependent_filter): New function to add a dependent
filter to an lra_reg.
(get_dependent_filter): New function to get a dependent filter
from a constraint.
(process_dependent_filters): New function to get all dependent
filters from the current insn's constraints.
(process_alt_operands): Initialize dependent-filter regset.
(curr_insn_transform): Fill lra_reg dependent filters.
* lra-int.h (struct dependent_filter): Declare.
(struct dependent_filter_entry): Ditto.
(lra_init_dependent_filter_cache): Ditto.
(lra_finish_dependent_filter_cache): Ditto.
* lra.cc (initialize_lra_reg_info_element): New function.
(finish_reg_info): Release dependent-filter vector.
(lra_init_once): Init hash table.
(lra_finish_once): Clear hash table.
* lra.h (lra_reset_dependent_filters): Declare.
Robin Dapp [Wed, 29 Apr 2026 07:53:46 +0000 (09:53 +0200)]
recog: Handle dependent filters.
This patch adds dependent-filter handling to recog.
When verifying the constraints of an instruction, just after register
filters are checked, it calls eval_dependent_filter for the operand and
its referenced operand.
gcc/ChangeLog:
* recog.cc (preprocess_constraints): Initialize dependent
filter.
(test_dependent_filter): New function wrapping
eval_dependent_filter.
(constrain_operands): Test dependent filter in strict mode.
* recog.h (struct operand_alternative): Declare
dependent_filters.
(alternative_dependent_filters): New function.
Robin Dapp [Wed, 29 Apr 2026 08:01:56 +0000 (10:01 +0200)]
genpreds: Dependent, dynamic register filters.
This patch adds foundational support for register filters that depend on
or reference another operand. The patch borrows heavily from Richard's
work on register filters.
As opposed to register filters, dependent filters need a runtime
evaluation function that dispatches to a target function (usually).
Common code can then evaluate the filter via
eval_dependent_filter (id, ...);
Robin Dapp [Fri, 10 Apr 2026 08:17:49 +0000 (10:17 +0200)]
vect: Do not use grouped gather for single pieces.
Right now, we even use a grouped gather/scatter for single pieces, i.e.
when there is no stride involved. This patch guards grouped gather with
>= 2 pieces.
gcc/ChangeLog:
* tree-vect-stmts.cc (vect_use_grouped_gather): Only use when
there are at least two pieces.
Jonathan Wakely [Sat, 6 Jun 2026 20:44:37 +0000 (21:44 +0100)]
libstdc++: Remove STLport link from docs
libstdc++-v3/ChangeLog:
* doc/xml/manual/debug_mode.xml: Remove 404 link to stlport
website and modernise some text about debug modes in other
implementations.
* doc/html/manual/debug_mode_design.html: Regenerate.
Richard Earnshaw [Tue, 23 Jun 2026 12:24:43 +0000 (13:24 +0100)]
MAINTAINERS: Add missing write-after accounts
A small number of accounts associated with maintainer roles were missing an
entry in the write-after section of the MAINTAINERS file with the
associated sourceware account.
ChangeLog:
* MAINTAINERS (Write After): Add details for Robert Dubner,
Ben Kosnik, James Lowden, Yunhai Shang and Andrew Waterman.
(CPU Ports, nds32): Remove Shiva Chen - stepped down.
This patch adds support for the RISC-V Zvabd (Vector Absolute Difference)
extension, based on the current draft specification:
https://github.com/riscv/integer-vector-absolute-difference/pull/1
Zvabd is now in the "Specification in Freeze" state:
https://riscv.atlassian.net/browse/RVS-3896
It adds patterns for:
- vabs
- vabd/vabdu
- vwabda/vwabdau
Alex Coplan [Thu, 18 Jun 2026 14:05:07 +0000 (15:05 +0100)]
aarch64: Fix unsharing in svset_impl::fold [PR125818]
svset_impl::fold lowers svset intrinsics into a copy of the entire tuple
and then a subsequent update of the given tuple member to the new vector
value, e.g.:
D.14149 = svset2_f32 (a, 0, v);
gets lowered into:
D.14149 = a;
D.14149.__val[0] = v;
. Because both stmts use the lhs of the original call stmt, the code
unshares the expressions. As svset_impl::fold notes:
/* [...]
The fold routines expect the replacement statement to have the
same lhs as the original call, so return the copy statement
rather than the field update. */
and notably the unshare_expr means that the pointer equality test above
fails. For VAR_DECLs (as above) it happens to work, since those aren't
unshared. mostly_copy_tree_r (called from unshare_expr) has:
/* Stop at types, decls, constants like copy_tree_r. */
else if (TREE_CODE_CLASS (code) == tcc_type
|| TREE_CODE_CLASS (code) == tcc_declaration
|| TREE_CODE_CLASS (code) == tcc_constant)
*walk_subtrees = 0;
but for MEM_EXPRs (as with the tescase in the PR) we *do* actually
unshare them, and thus trip the assert in gsi_replace (or since r17-1237-g4fb2541debcca1, ICE in completely_unused, but the root cause
is the same).
We want the stmt returned from svset_impl::fold (copy) to have a
pointer-identical lhs as the original stmt, so this patch just changes
which use of f.lhs is unshared. We keep copy's use as per the original
stmt, and unshare the use in the update stmt instead.
gcc/ChangeLog:
PR target/125818
* config/aarch64/aarch64-sve-builtins-base.cc (svset_impl::fold): Fix
unsharing to ensure the returned stmt has the exact same lhs as the
original.
gcc/testsuite/ChangeLog:
PR target/125818
* gcc.target/aarch64/torture/pr125818.c: New test.
Sarvesh Chandra [Tue, 23 Jun 2026 06:50:01 +0000 (12:20 +0530)]
i386: Emit vunpcklpd for register V4DF/V8DF movddup [PR107057]
The avx512f_movddup512 and avx_movddup256 patterns only accepted a
memory source operand, so an even-lane duplicate of a value already in
a register forced that register to be spilled to the stack and
reloaded with vmovddup.
Add a register source alternative that emits vunpcklpd, which performs
the same even-lane interleave directly on a register operand. A
genuine memory source still selects vmovddup.
The register alternative duplicates a single source operand
(vunpcklpd %1, %1, %0), so it is typed sselog1, the single-source SSE
logical type, while the memory alternative keeps ssemov.
gcc/ChangeLog:
PR target/107057
* config/i386/sse.md (avx512f_movddup512<mask_name>): Add a
register source alternative that emits vunpcklpd.
(avx_movddup256<mask_name>): Likewise.
gcc/testsuite/ChangeLog:
PR target/107057
* gcc.target/i386/avx512-movedup.c: New test.
Paul Thomas [Tue, 23 Jun 2026 09:21:47 +0000 (10:21 +0100)]
Fortran: Fix memory leaks in PDT tests. [PR121972]
2026-06-22 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/121972
* decl.cc (build_struct): Convert the PDT template before the
call to gfc_build_class_symbol.
gcc/testsuite/
PR fortran/121972
* gfortran.dg/pdt_77.f03: Add 'finalalize_navier_stokes', which
tests that the 'navier_stokes' component 'p' is pointed to the
correct vtable in both tests. Check that VIEW_CONVERT_EXPR does
not appear in the tree dump.
Add ix86_output_lcp_stall_peephole to generate LCP stall peepholes with
the previous scratch register:
1. Scan backward for the previous scratch register definition with
the same immediate operand in the same basic block.
2. The previous scratch register is unusable if it is set between the
previous scratch register definition and the current instruction.
3. If a usable previous scratch register is found, ignore the allocated
scratch register and use the previous scratch register. Otherwise, use
the allocated scratch register.
so that the same scratch register can be reused if possible:
1. When bootstrapping GCC 16 with only C and C++ enabled, this optimization
triggers 54 times. No regressions.
2. When building glibc 2.44, this optimization triggers 33 times. No
regressions.
3. When building Linux kernel 7.1.1, this optimization triggers 2099 times.
Kernel boots correctly.
Richard Biener [Fri, 19 Jun 2026 09:45:46 +0000 (11:45 +0200)]
tree-optimization/110743 - do not warn for bit sets/clears to uninit memory
The following avoids diagnosing bit sets/clears that involve RMW
cycles to uninitialized memory. This is for example exposed by
__builtin_clear_padding lowering which suppresses diagnostics but
those can re-surface with vectorization.
Hu, Lin1 [Tue, 2 Jun 2026 07:13:52 +0000 (00:13 -0700)]
dojump: use simplify_expand_binop for vector boolean mask
When either op0 or op1 is a constant, expand_binop can emit an extra AND
during expansion. Use simplify_expand_binop here to avoid creating it in
the first place.
gcc/ChangeLog:
* dojump.cc (do_compare_rtx_and_jump): Use simplify_expand_binop
instead of expand_binop.
* doc/md.texi (vec_cbranch_all<mode>): Clarify how the
middle-end invoke the pattern.
(cond_vec_cbranch_all<mode>): Ditto.
(cond_len_vec_cbranch_all<mode>): Ditto.
This patch adds infrastructure support for future-altivec as a
builtin-stanza predicate for PowerPC. This provides a framework for
defining builtins that require both -mcpu=future and -maltivec options.
The future-altivec stanza can be used to add AltiVec-specific builtins for
future PowerPC ISA extensions.
2026-06-23 Kishan Parmar <kishan@linux.ibm.com>
gcc/ChangeLog:
* config/rs6000/rs6000-builtin.cc (rs6000_invalid_builtin): Handle
ENB_FUTURE_ALTIVEC and issue a diagnostic requiring -mcpu=future
and -maltivec.
(rs6000_builtin_is_supported): Check TARGET_FUTURE && TARGET_ALTIVEC
for ENB_FUTURE_ALTIVEC built-ins.
* config/rs6000/rs6000-gen-builtins.cc (enum bif_stanza): Add
BSTZ_FUTURE_ALTIVEC entry.
(stanza_map): Add future-altivec stanza mapping.
(enable_string): Add ENB_FUTURE_ALTIVEC.
(write_decls): Add ENB_FUTURE_ALTIVEC to the bif_enable enum in the
generated header file.
Andrew Pinski [Mon, 22 Jun 2026 19:14:39 +0000 (12:14 -0700)]
cs-elim: Don't set TODO_TODO_update_ssa_only_virtuals
Now after r17-1753-g2e5184c4a93c4b0d4067, all parts of
cs-elim manually keeps the VOPS up todate and don't need
any renaming, don't return TODO_TODO_update_ssa_only_virtuals
when something is inserted.
Pushed as obvious after a bootstrap/test on x86_64-linux-gnu.
Xin Liu [Tue, 23 Jun 2026 02:01:13 +0000 (02:01 +0000)]
i386: Add HYGON c86-4g-m8 support
Add c86-4g-m8 as a new HYGON Family 18h model 8 processor. It
inherits the c86-4g-m7 ISA set and most tuning decisions, including
the same processor costs and scheduling model baseline.
The patch wires c86-4g-m8 into the common x86 processor tables,
driver CPU detection, target macros, --with-arch/--with-cpu handling,
builtin CPU detection and documentation. It also extends the c86-4g
tuning masks that already special-case c86-4g-m7 to cover c86-4g-m8.
For scheduling, rename the shared scheduling description file from
gcc/config/i386/c86-4g-m7.md to gcc/config/i386/c86-4g-m7m8.md and
reuse the c86-4g-m7 scheduling reservations for c86-4g-m8 where the
latency and resource usage are the same. Add separate c86-4g-m8
reservations for the few operations with different latency. This patch
does not affect genautomata build time.
Here we issue a bogus -Wrange-loop-construct warning because the
is_trivially_xible check uses `const pair<int>` which makes it seem
like `pair<T>::pair(const pair<_U1> &&)` would actually be used,
which is non-trivial, while the loop would actually use a trivial
copy. Fixed by using `const pair<int> &` for the is_trivially_xible
check.
PR c++/125697
gcc/cp/ChangeLog:
* cp-tree.h (trivially_copy_constructible_p): Declare.
* parser.cc (warn_for_range_copy): Use it.
* reflect.cc (eval_is_trivially_copy_constructible_type): Use it.
* tree.cc (trivially_copy_constructible_p): New.
Andrew Pinski [Sun, 21 Jun 2026 23:10:15 +0000 (16:10 -0700)]
phiopt: Reject instead of assert that the 2 vuse of the loads are the same [PR125923]
So it turns out I thought we would always get a virtual phi when there was a store
in front of the load. This is correct for all normal code except if heading into
an infinite loop where there are no stores/loads. Since this is leading to
an infinite loop, rejecting this case does not change performance at all.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/125923
gcc/ChangeLog:
* tree-ssa-phiopt.cc (factor_out_conditional_load): Change
assert of the vuse being the same to rejecting if they are
different without a virtual phi.
gcc/testsuite/ChangeLog:
* gcc.dg/torture/pr125923-1.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Andrew Pinski [Sun, 21 Jun 2026 18:40:33 +0000 (11:40 -0700)]
cselim: manually keep upto date the vops
While working on related code I noticed that we can keep
the vops up todate so rename ssa does not need to do anything here.
This manually updates the 2 inserted statements, the load on the edge
and the store in the join bb. This should be a small compile
time optimization.
Boostrapped and tested on x86_64-linux-gnu.
gcc/ChangeLog:
* tree-ssa-phiopt.cc (cond_store_replacement): Update
the vuse on the new load and the vuse/vdef on the new
store.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Andrew Pinski [Sun, 21 Jun 2026 18:22:09 +0000 (11:22 -0700)]
cselim: Just use gsi_insert_before instead of checking if it is the end [PR125917]
This code dates before tuples so it used to do some tricks to try to insert
at the begining of the basic block. Now post tuples, to insert at the begining
of the basic block, you just need to use gsi_after_labels followed by
gsi_insert_before. This changes to do just that and simplifies the code
slightly.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/125917
gcc/ChangeLog:
* tree-ssa-phiopt.cc (cond_store_replacement): Just call
gsi_insert_before instead of checking gsi_end_p.
(cond_if_else_store_replacement_1): Likewise.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Remove %I from the spec string because gcobol does not use the C
preprocessor library and does not search include/ or include-fixed/
directories. Instead, system copybooks (as they're called) follow the
runtime library and are installed into the LIBSUBDIR, similarly to
Modula-2's .def files.
For compilations relying on non-standard paths (i.e., outside the
installation prefix), -B is already handled by the cobol1 compiler.
Georg-Johann Lay [Mon, 22 Jun 2026 16:36:36 +0000 (18:36 +0200)]
Remove -*- C++ -*- tags for Emacs from .cc files.
There are still some -*- C++ -*- markers in .cc files.
They were needed after GCC transitioned to C++ but still
used .c extensions for C++ files.
These tags are no more needed, and this patch removes these
tags from some .cc files that still have them.
The preferred way of letting Emacs chose a major mode is by
means of file-name based rules. Such tags can be annoying
when you have a different rule for .cc files, for example
when .cc files are bound to GNU style but default C++ style isn't.
Kanishka Solanki [Mon, 22 Jun 2026 12:28:40 +0000 (17:58 +0530)]
a68: return alias set 0 for Algol 68
Hi,
Following review feedback, this version adds the requested commit
subject prefix and an explanatory comment before the return statement
in a68_get_alias_set.
The frontend builds successfully and make check-algol68 passes with this
change.
Thanks,
Kanishka Solanki
[4. text/x-patch; 0001-a68-return-alias-set-0-for-Algol-68.patch]...
From daf6fde806010dcff462d4078992621646d841ae Mon Sep 17 00:00:00 2001
From: Kanishka Solanki <kanishkasolanki456s@gmail.com>
Date: Sun, 21 Jun 2026 21:34:40 +0530
Subject: [PATCH] a68: return alias set 0 for Algol 68
The default LANG_HOOKS_GET_ALIAS_SET implementation returns -1,
causing GCC to use its default alias set machinery.
Override LANG_HOOKS_GET_ALIAS_SET in the Algol 68 frontend and
return 0 so all objects are treated as potentially aliasing.
gcc/algol68/ChangeLog
* a68-lang.cc (a68_get_alias_set): New function.
(LANG_HOOKS_GET_ALIAS_SET): Define to a68_get_alias_set.