Mohamed Ali [Sat, 7 Mar 2026 06:15:48 +0000 (08:15 +0200)]
gccrs: intrinsic: Add ctlz and ctlz_nonzero intrinsics
This commit introduces the `ctlz` and `ctlz_nonzero` intrinsics for counting leading zeros
in integer types.
The implementation includes handlers for both intrinsics, which validate input types and utilize
GCC built-ins for the actual computation.
Addresses: Rust-GCC#658
gcc/rust/ChangeLog:
* backend/rust-compile-intrinsic.cc: Register ctlz and ctlz_nonzero intrinsics.
* backend/rust-intrinsic-handlers.cc (ctlz_handler): Implement ctlz_handler.
(ctlz_nonzero_handler): Implement ctlz_nonzero_handler.
* backend/rust-intrinsic-handlers.h (ctlz_handler): Add decl for ctlz_handler.
(ctlz_nonzero_handler): Add decl for ctlz_nonzero_handler.
* util/rust-intrinsic-values.h: map ctlz_nonzero to its name.
gcc/testsuite/ChangeLog:
* rust/compile/ctlz.rs: New test.
* rust/compile/ctlz_nonzero.rs: New test.
* rust/execute/torture/ctlz.rs: New test.
* rust/execute/torture/ctlz_nonzero.rs: New test.
Signed-off-by: Mohamed Ali <mohmedali1462005@gmail.com>
This patch replaces std::strtol with GNU MP (GMP) for arbitrary-precision
parsing to properly support 128-bit literals.
Additionally, it refactors the lexer by removing the redundant
`existent_str` parameter from `parse_non_decimal_int_literal`. The base
is now passed directly, and the parsed digits are collected internally,
making the previous prefix-passing logic ("0x", "0b", "0o") obsolete
and ensuring cleaner compatibility with mpz_set_str.
gcc/rust/ChangeLog:
* lex/rust-lex.cc (Lexer::parse_non_decimal_int_literal): Use GMP
for base conversion to support 128-bit literals. Remove existent_str
parameter.
(Lexer::parse_non_decimal_int_literals): Remove prefix string
initialization and update function calls.
* lex/rust-lex.h (Lexer::parse_non_decimal_int_literal): Update
function signature to remove existent_str.
gcc/testsuite/ChangeLog:
* rust/execute/non_decimal_128_saturation.rs: New test.
Owen Avery [Mon, 9 Mar 2026 04:24:22 +0000 (00:24 -0400)]
gccrs: Add enum items to value namespace as well
gcc/rust/ChangeLog:
* resolve/rust-finalize-imports-2.0.cc
(GlobbingVisitor::visit_enum_container): Conditionally insert
into value namespace as well.
* resolve/rust-forever-stack.hxx (ForeverStack::insert_variant):
Add template specialization for value namespace.
* resolve/rust-name-resolution-context.cc
(NameResolutionContext::insert_variant): Allow insertion into
value namespace.
* resolve/rust-name-resolution-context.h
(NameResolutionContext::insert_variant): Likewise.
* resolve/rust-toplevel-name-resolver-2.0.cc
(TopLevel::insert_enum_variant_or_error_out): Likewise.
(TopLevel::visit): Use tweaked insert_enum_variant_or_error_out
properly for all enum item kinds.
* resolve/rust-toplevel-name-resolver-2.0.h
(TopLevel::insert_enum_variant_or_error_out): Tweak function
signature.
rust-GCC/gccrs#3555, rust-GCC/gccrs#3591, rust-GCC/gccrs#3597,
rust-GCC/gccrs#3651, rust-GCC/gccrs#3670 & rust-GCC/gccrs#3672 were all
fixed long ago by some of my older patches, adding test cases to conclude
the issues properly.
gcc/testsuite/ChangeLog:
* rust/compile/issue-3555.rs: New test case.
* rust/compile/issue-3591.rs: New test case.
* rust/compile/issue-3597.rs: New test case.
* rust/compile/issue-3651.rs: New test case.
* rust/compile/issue-3670.rs: New test case.
* rust/compile/issue-3672.rs: New test case.
Owen Avery [Sat, 7 Feb 2026 01:11:20 +0000 (20:11 -0500)]
gccrs: Improve path resolution
This makes path resolution less dependent on templates for path
handling.
gcc/rust/ChangeLog:
* resolve/rust-forever-stack.h: Include more headers.
(class ResolutionPath): New class for representing paths.
(ForeverStack::resolve_path): Change function signature.
(ForeverStack::find_starting_point): Likewise.
(ForeverStack::resolve_segments): Likewise.
(ForeverStack::SegIterator): Change type alias.
* resolve/rust-forever-stack.hxx (check_leading_kw_at_start):
Change function signature.
(ForeverStack::find_starting_point): Likewise.
(ForeverStack::resolve_segments): Likewise.
(ForeverStack::resolve_path): Likewise.
* resolve/rust-name-resolution-context.h: Tweak include guard,
include "rust-name-resolution.h".
(NameResolutionContext::resolve_path): Use ResolutionPath and
ResolutionBuilder.
(class NameResolutionContext::ResolutionBuilder): New class.
(class Usage): Move this...
(class Definition): ...and this...
* resolve/rust-name-resolution.h: ...to new file.
* util/rust-unwrap-segment.h: Add include guard.
Patrick Palka [Tue, 14 Apr 2026 19:32:13 +0000 (15:32 -0400)]
c++: identity of A<^^alias> [PR124544]
Since a reflection of an alias represents the alias itself, not the
underlying type, cp_tree_equal needs to compensate for that since it
otherwise generally looks through aliases. And strip_typedefs_expr
needs to not strip the alias in e.g. A<^^alias>.
PR c++/124544
gcc/cp/ChangeLog:
* tree.cc (strip_typedefs_expr) <case REFLECT_EXPR>: Don't
recurse into a type operand.
(cp_tree_equal) <case REFLECT_EXPR>: For a reflection of an
alias, also compare TYPE_NAMEs directly.
gcc/testsuite/ChangeLog:
* g++.dg/reflect/alias1.C: New test.
* g++.dg/reflect/alias2.C: New test.
Marek Polacek [Tue, 14 Apr 2026 14:13:11 +0000 (10:13 -0400)]
c++: introduce reflection_function_template_p
As discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2026-April/712156.html>,
this patch introduces a new predicate to be used instead of
really_overloaded_fn when we're checking for a function template in the
Reflection code.
gcc/cp/ChangeLog:
* cp-tree.h (reflection_function_template_p): Declare.
* parser.cc (cp_parser_splice_expression): Use
reflection_function_template_p instead of really_overloaded_fn.
* reflect.cc (check_splice_expr): Likewise.
(reflection_function_template_p): New.
Richard Earnshaw [Tue, 14 Apr 2026 13:45:38 +0000 (14:45 +0100)]
arm: apply stronger checks on conditional-compare patterns [PR123102]
If a conditional compare operation is generated during expand, then
combine may try to substitute into it in order to generate better code;
but if it does so, we need to validate that the optimized sequence is
still a valid conditional compare. We were skipping those checks and
that can lead to wrong code being generated.
gcc/ChangeLog:
PR target/123102
* config/arm/arm.md (*cmp_ite0): Apply stricter checks on the
comparison mode.
(*cmp_ite1, *cmp_and, *cmp_ior): Likewise.
Tomasz Kamiński [Tue, 14 Apr 2026 14:30:36 +0000 (16:30 +0200)]
libstdc++: Define __cpp_lib_stdbit_h and __cpp_lib_stdckdint_h feature test macros.
This implements LWG4550: Need new feature test macros for <stdckdint.h>
and <stdbit.h>.
libstdc++-v3/ChangeLog:
* include/bits/version.def (stdbit_h, stdckdint_h): Define.
* include/bits/version.h: Regenerate.
* include/c_compatibility/stdbit.h (__cpp_lib_stdbit_h): Define
and use it in guards.
* include/c_compatibility/stdckdint.h (__cpp_lib_stdckdint_h):
Define and use it in guards.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Martin Jambor [Tue, 14 Apr 2026 15:00:05 +0000 (17:00 +0200)]
ipa: Type-convert constants in jump functions during inlining (PR124777)
PR 124777 revealed that update_jump_functions_after_inlining does not
properly fold_convert constants when it propagates them from constant
jump functions to formerly pass-through ones, leading to expectations
of wrong constants in parameters leading to inserting bogus
builtin_unreachables during inlining.
This patch fixes it by calling ipacp_value_safe_for_type which is what
IPA-CP uses during its propagation and moved handling of the case to a
separate function.
gcc/ChangeLog:
2026-04-07 Martin Jambor <mjambor@suse.cz>
PR ipa/124777
* ipa-cp.h (ipacp_value_safe_for_type): Declare.
* ipa-cp.cc (ipacp_value_safe_for_type): Make public.
* ipa-prop.cc (ipa_set_jf_cst_copy): Fix comment.
(ipa_convert_prop_cst_jf): New function.
(update_jump_functions_after_inlining): Handle the constant to
pass-through case by calling ipa_convert_prop_cst_jf.
Tomasz Kamiński [Fri, 10 Apr 2026 08:24:19 +0000 (10:24 +0200)]
libstdc++: Test for using non-ascii unicode fill with non-unicode encoding.
This checks if format string using as fill character an Unicode code-point,
that is encoded as multiple code units, is rejected when literal encoding
is not Unicode.
libstdc++-v3/ChangeLog:
* testsuite/std/format/fill.cc: New test.
* testsuite/std/format/fill_nonunicode.cc: New test.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Gaius Mulley [Tue, 14 Apr 2026 12:49:07 +0000 (13:49 +0100)]
PR modula2/105408 ICE in output_constructor_regular_field, at varasm.cc:5515
This patch fixes an ICE reported as PR modula2/105408. It manifests on
big endian system when an ISO WORD is assigned a constant. An ISO WORD
is an array of LOC and the constant array elements are created in reverse
indice order (for big endian). This fix corrects the indice order and
also fixes calls to builtin_memcpy when used during assignment. It uses
memcpy during assignment for arrays of constants.
Bootstrapped on sparc64, aarch64, x86_64 and POWER10.
gcc/m2/ChangeLog:
PR modula2/105408
* Make-lang.in (GM2-COMP-BOOT-MODS): Remove duplicate NameKey.mod.
* gm2-compiler/M2GenGCC.mod (import): Remove BuildAssignmentTree.
Add CopyMemcpy.
(IsSystemTypeBecomes): New procedure function.
(CodeAssignment): Rewrite using CopyMemcpy and IsSystemTypeBecomes.
* gm2-gcc/m2convert.cc (const_to_ISO_aggregate_type): Reverse
array elements if BYTES_BIG_ENDIAN.
* gm2-gcc/m2pp.cc (ps): New function.
* gm2-gcc/m2pp.h (pf): Added comment.
(pe): Ditto.
(pt): Ditto.
(ptl): Ditto.
(pv): Ditto.
(ptcl): Ditto.
* gm2-gcc/m2statement.cc (copy_memcpy): Replace with ...
(m2statement_CopyMemcpy): ... this.
(CopyByField_Lower): Call m2statement_CopyMemcpy instead of copy_memcpy.
(m2statement_BuildAssignmentTree): Tidied up comment.
Add test for ARRAY_TYPE CONSTRUCTOR expr and use
m2statement_CopyMemcpy.
Return type changed to void.
* gm2-gcc/m2statement.def (BuildAssignmentTree): Rewrite declaration.
(CopyMemcpy): New procedure declaration.
* gm2-gcc/m2statement.h (m2statement_BuildAssignmentTree): Replace
return type with void.
(m2statement_CopyMemcpy): New function declaration.
* gm2-gcc/m2type.cc (m2type_ReverseArrayConstructorElements): New
function.
* gm2-gcc/m2type.def (ReverseArrayConstructorElements): New
procedure function declaration.
* gm2-gcc/m2type.h (m2type_ReverseArrayConstructorElements): New
function declaration.
gcc/testsuite/ChangeLog:
PR modula2/105408
* gm2/iso/run/pass/testgeneric.mod: Corrected printf arguments.
* gm2/iso/run/pass/printsize.mod: New test.
* gm2/iso/run/pass/testgeneric2.mod: New test.
* gm2/iso/run/pass/testgeneric3.mod: New test.
* gm2/iso/run/pass/testgeneric4.mod: New test.
* gm2/iso/run/pass/testgeneric5.mod: New test.
Tomasz Kamiński [Tue, 7 Apr 2026 15:03:25 +0000 (17:03 +0200)]
libstdc++: Runtime fallback for constant_wrapper subscript and call operators.
This implements P3978R3: constant_wrapper should unwrap on call and subscript.
The operator() and operator[] are now fallback to calling corresponding
operation on value, if either arguments are not constant_wrapper like, or
the result of the invocation is not usable as non-type template argument
(non-constant). The call operator is also now defined in terms of invoke,
to support member pointers.
The noexcept specification is simplified, by observing that creating a
default constructed (constant_wrapper<value(....)>{}) is never throwing
operation. Nested requires expr is used for short-circuting, and thus
avoid checking viability of the operation on the value with
constant_wrapper only (see PoisonedAdd, PoisonedIndex in tests).
libstdc++-v3/ChangeLog:
* include/bits/version.def (constant_wrapped): Updated to 202603L.
* include/bits/version.h: Regenerate.
* include/bits/utility.h (_CwOperators::operator())
(_CwOperators:operator[]): Delete, they are now provided by...
(constant_wrapper::operator(), constant_wrapper::operator[]):
Define.
* testsuite/20_util/constant_wrapper/generic.cc: Add additional
test cases for invoke and subscript.
* testsuite/20_util/constant_wrapper/version.cc: Update tested
value.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Richard Biener [Tue, 14 Apr 2026 07:06:11 +0000 (09:06 +0200)]
tree-optimization/124875 - re-instantiate alias-set code in PRE
The following re-instantiates the alias-set compatibility check in PRE
that I removed based on lack of test coverage. As with the alignment
and access size compatibility checks this is now done in prefer
which is used to prune the expression set considered for PRE and
code hoisting. Compared to the previous code this does not alter
expressions but instead ceases to do PRE or code hoisting if the
expressions representing the value can not be made compatible by
chosing one.
PR tree-optimization/124875
* tree-ssa-pre.cc (prefer): Also compare TBAA set and base_set.
Refactor computing the final prefered expression, do early outs
and allow same prefered expressions.
(sorted_array_from_bitmap_set): Fix thinko that prevented
the last expression in the set of being excluded.
Soumya AR [Tue, 10 Mar 2026 07:28:10 +0000 (07:28 +0000)]
aarch64: Add RTL pass to narrow 64-bit GP reg writes to 32-bit
This patch adds a new AArch64 RTL pass that converts 64-bit X-register
operations to 32-bit W-register equivalents when the upper 32 bits are
provably zero.
This patch is active at O2 and above but not enabled by default, except for
-mcpu=olympus.
This is beneficial for the Olympus core, which benefits from using 32-bit
W-registers over 64-bit X-registers if possible. This is recommended by the
updated Olympus Software Optimization Guide, which will be published soon.
For example:
uint64_t foo(uint64_t a) {
return (a & 255) + 3;
}
Without this pass, compiles to:
and x0, x0, 255
add x0, x0, 3
ret
But can be optimized to:
and x0, x0, 255
add w0, w0, 3
ret
----
The pass makes a single forward sweep over EBBs in RPO:
- Computes a nonzero-bit mask for every GP register definition using
nonzero_bits().
- At control-flow joins, combine_mask_from_phi ORs the masks of all phi
inputs; inputs not yet processed (e.g. backedges) receive a conservative
mode mask.
- Instructions whose results fit in 32 bits are narrowed after verifying
with rtl_ssa::recog and rtl_ssa::change_is_worthwhile.
- Both plain SET and flag-setting PARALLEL patterns (ADDS, SUBS, ANDS,
etc.) are handled.
----
nonzero_bits(src, DImode) is a function defined in rtlanal.cc that recursively
analyzes RTL expressions to compute a bitmask. However, nonzero_bits has a
limitation: when it encounters a register, it conservatively returns the mode
mask (all bits potentially set). Since this pass tracks masks for all GP
register definitions, this information can be used to refine the analysis.
The pass maintains a hash map of computed bit masks and overrides the
reg_nonzero_bits RTL hook to consult this map when encountering a register.
When a definition is in a narrower mode than its use, RTL semantics say the
upper bits are undefined. The hook conservatively marks those bits as
potentially nonzero by ORing the mask with ~GET_MODE_MASK of the def's mode.
----
PHI nodes require special handling to merge masks from all inputs. This is done
by combine_mask_from_phi, which ORs together the known masks from all phi
inputs. For each input:
1. If the input has a definition already in nzero_map, we use its mask.
2. If the input has no definition or has not yet been processed
(e.g. a backedge), we conservatively assume the full mode mask.
----
The pass handles two instruction forms:
Single SET instructions: if the nonzero-bit mask fits in 32 bits, the source
is narrowed to SImode via narrow_dimode_src (which recursively narrows operands
beyond a plain lowpart_subreg), then wrapped in a ZERO_EXTEND back to DImode.
This is needed because RTL semantics say an SImode write leaves the upper 32
bits undefined, even though AArch64 W-register writes zero them. Without the
ZERO_EXTEND, a later pass could treat the narrowed write as redundant and
silently lose the upper-bit clearing.
simplify_gen_unary is used for the ZERO_EXTEND wrapping so the result is
canonical RTL. For CONST_INT or ZERO_EXTEND sources, this effectively
round-trips back to the original instruction, and therefore they are skipped.
PARALLEL instructions (compare + arith): flag-setting patterns like ADDS, SUBS,
and ANDS are narrowed when the COMPARE operand matches the SET source. The SET
part gets the same ZERO_EXTEND-to-DImode wrapping as single SET instructions.
The required mask depends on the condition code mode:
- CC_Zmode: upper 32 bits must be zero.
- CC_NZmode / CC_NZVmode: upper 33 bits must be zero (bit 31 included because
narrowing moves the sign bit from bit 63 to bit 31, which would flip the N
flag if bit 31 were set).
Both routines always track nonzero bits for GP register definitions before
checking whether narrowing applies. This ensures we get mask information for
all GP defs, even for instructions we don't end up narrowing.
----
The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
OK for GCC16?
Signed-off-by: Soumya AR <soumyaa@nvidia.com> Co-authored-by: Kyrylo Tkachov <ktkachov@nvidia.com>
gcc/ChangeLog:
* gcc.target/aarch64/narrow-gp-writes-1.c: New test.
* gcc.target/aarch64/narrow-gp-writes-2.c: New test.
* gcc.target/aarch64/narrow-gp-writes-3.c: New test.
* gcc.target/aarch64/narrow-gp-writes-4.c: New test.
* gcc.target/aarch64/narrow-gp-writes-5.c: New test.
* gcc.target/aarch64/narrow-gp-writes-6.c: New test.
* gcc.target/aarch64/narrow-gp-writes-7.c: New test.
Jakub Jelinek [Tue, 14 Apr 2026 07:27:09 +0000 (09:27 +0200)]
bitintlower: Handle BIT_FIELD_REF load [PR124826]
The following testcase ends up with a BIT_FIELD_REF from a VECTOR_TYPE union
member to _BitInt(256). gimple-lower-bitint.cc already contains code to
handle BIT_FIELD_REFs with SSA_NAME first operand to BITINT_TYPE (for
constant index limb access by adjusting the BIT_FIELD_REF to use different
bitsize and index, for variable index (huge _BitInt with limbs accessed in a loop)
by forcing the SSA_NAME into memory), but that doesn't trigger here, because
gimple_assign_load_p predicate is true on it and so it is handled as load
and not BIT_FIELD_REF. Anyway, the problem is that we end up with
_7 = VIEW_CONVERT_EXPR<unsigned long[4]>(BIT_FIELD_REF <u.v, 256, 0>)[_2];
which tree-cfg.cc verifier doesn't like because BIT_FIELD_REF is not
toplevel reference in there. The following patch just strips the
BIT_FIELD_REF away if it has zero bit offset, that is the only case I've
managed to reproduce, and in that case we are still later on using VCE to
convert to array and using ARRAY_REF on that. If offset could be non-zero
but multiple of BITS_PER_UNIT, another approach would be to replace
BIT_FIELD_REF with a MEM_REF. Anyway, as I haven't managed to reproduce
it with anything but 0, the following patch is enough.
2026-04-14 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/124826
* gimple-lower-bitint.cc (bitint_large_huge::handle_load): Look through
BIT_FIELD_REF with zero bit offset.
* gcc.dg/bitint-128.c: New test.
Reviewed-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
The path isolation code mishandles the case where in the same block
there's both a return of a local variable and a dereference of zero
but from different edges. In this case we re-use the produced block
copy for both isolated paths, causing a trap on the path to the
return of a non-local.
The least intrusive change I came up with separates both causes
and transforms, first isolating NULL dereferences and then
isolating returns of non-NULL. This will skip the latter transform
on paths which will now not return anyway.
To avoid duplicate diagnostics the handle_return_addr_local_phi_arg
only diagnoses cases in blocks dominated by the original block, not in
copies which still need SSA update and thus are falsely visited.
PR tree-optimization/124868
* gimple-ssa-isolate-paths.cc (handle_return_addr_local_phi_arg):
Do not diagnose returns in blocks not dominated by the PHI.
(find_implicit_erroneous_behavior): Do two sweeps over PHIs,
first for NULL dereferences and then for local address returns.
H.J. Lu [Tue, 14 Apr 2026 03:06:31 +0000 (11:06 +0800)]
x86: Zero ZMM16-31 when zeroing all call used registers
When zeroing all call used registers with AVX512F enabled, zero ZMM16-31
explicitly since vzeroall doesn't touch ZMM16-31. Also add a test for
zeroing all call used registers with both AVX512F and APX enabled.
gcc/
PR target/124876
* config/i386/i386.cc (ix86_zero_call_used_regs): Zero ZMM16-31
if needed.
gcc/testsuite/
PR target/124876
* gcc.target/i386/zero-scratch-regs-23.c: Scan vpxord on ZMM16-31.
* gcc.target/i386/zero-scratch-regs-33.c: New test.
This patch adds a mangling for dependent splices. Since the ABI discussion
at <https://github.com/itanium-cxx-abi/cxx-abi/issues/208> hasn't gelled
yet, this mangling might change in the future. In this patch I'm adding
<splice> ::= DS <expression> [ <template-args> ] E
for all dependent splices.
When we have ^^T::x, we can't say what kind of reflection this
will be, so this patch emits the "de" prefix. For template template
parameters we emit "tt".
PR c++/123237
PR c++/124771
PR c++/124842
gcc/cp/ChangeLog:
* mangle.cc (write_splice): New.
(write_prefix): Call write_splice for SPLICE_SCOPE.
(write_type): Likewise.
(write_expression): Call write_splice for dependent_splice_p.
(write_reflection): Handle the "tt" and "de" prefixes.
* reflect.cc (reflection_mangle_prefix): For
DECL_TEMPLATE_TEMPLATE_PARM_P, use the prefix "tt". For
dependent reflections, use "de".
gcc/testsuite/ChangeLog:
* g++.dg/reflect/mangle2.C: New test.
* g++.dg/reflect/mangle3.C: New test.
* g++.dg/reflect/mangle4.C: New test.
* g++.dg/reflect/mangle5.C: New test.
fortran: Fix ICE in remap_type with deferred-length character in OMP target [PR101760, PR102314]
For deferred-length character types such as character(:), allocatable,
TYPE_SIZE and TYPE_SIZE_UNIT contain SAVE_EXPRs wrapping the string
length variable (created by variable_size in finalize_type_size).
In gfc_omp_finish_clause, when computing OMP_CLAUSE_SIZE for implicitly
mapped variables, the code previously used TYPE_SIZE_UNIT directly.
Gimplifying this shared SAVE_EXPR resolves it in place, embedding a
gimple temporary into the type's size expression. When the enclosing
function is later inlined, remap_type_1 walks TYPE_SIZE and encounters
the stale temporary as an unmappable SSA name, causing an ICE in
make_ssa_name_fn.
Fix by computing the clause size from the array domain bounds and
element size rather than using the type's SAVE_EXPR directly, so
that the type's size expressions remain untouched.
PR fortran/101760
PR fortran/102314
gcc/fortran/ChangeLog:
* trans-openmp.cc (gfc_omp_finish_clause): Compute OMP_CLAUSE_SIZE
from the array domain bounds and element size for VLA types instead
of using TYPE_SIZE_UNIT directly, to avoid corrupting the type.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/pr101760.f90: New test.
* gfortran.dg/gomp/pr102314.f90: New test.
Signed-off-by: Christopher Albert <albert@tugraz.at>
Marek Polacek [Thu, 9 Apr 2026 23:52:15 +0000 (19:52 -0400)]
c++/reflection: fn call with splice in decltype rejected [PR124835]
Here we reject the valid
decltype([:^^foo<int>:](42))
saying that a ')' is expected. [dcl.type.decltype] says "if E is an
unparenthesized splice-expression, decltype(E) is..." and we handle it
by calling _splice_expression and setting id_expression_or_member_access_p.
But for the code above we shouldn't do this, because the [: :] isn't
the sole operand of decltype. _nth_token_starts_splice_without_nns_p
checks that there's no :: after the :] but here we want to check that
the [: :] is followed by a ')'.
PR c++/124835
gcc/cp/ChangeLog:
* parser.cc (cp_parser_decltype_expr): Check that [: :] is
followed by a close paren before declaring it an unparenthesized
splice-expression.
Jason Merrill [Mon, 13 Apr 2026 16:46:33 +0000 (12:46 -0400)]
c++: local class in lambda in default targ [PR123566]
Since we started to clear processing_template_parmlist within a lambda, we
started to ICE on a local class in such a lambda where previously we would
give a (wrong) error. Let's sorry instead of ICE.
The failure mode is that in a parmlist current_template_args() is a 0-length
TREE_VEC, and so tsubst thinks that the type is not dependent, and returns
the type unchanged. We need to overhaul our handling of local classes (and
enums) in lambdas so that they are regenerated along with the lamba itself;
instantiating them based on the surrounding template parms happens to
work in some cases but is generally wrong; see also PR100198.
PR c++/103901
PR c++/123566
gcc/cp/ChangeLog:
* pt.cc (push_template_decl): Sorry on local class in lambda in
template parm list.
Jakub Jelinek [Mon, 13 Apr 2026 11:28:34 +0000 (13:28 +0200)]
testsuite: Uncommented some type_trait13.C tests [PR124246]
These were commented out because of bogus errors, but that was fixed by r16-8132-g8655ef0b65515b8 PR124472 fix.
2026-04-13 Jakub Jelinek <jakub@redhat.com>
PR c++/124246
* g++.dg/reflect/type_trait13.C: Uncomment commented out is_swappable_type and
is_nothrow_swappable_type assertions with std::priority_queue.
This implements P3886R0: Wording for AT1-057, by defining the
__cpp_lib_replaceable_contract_violation_handler. The macro is defined
only if contracts are supported (i.e. under same conditions as
__cpp_lib_contracts).
GCC supports providing custom violation handler by providing an separate
defintion of handle_contract_violation. This is supported on the targets
that uses ELF format, so the macro is defined for with non-zero value
for them.
libstdc++-v3/ChangeLog:
* include/bits/version.def (replaceable_contract_violation_handler)
[(__cplusplus > 202302L) && (__cpp_contracts >= 202502L)]:
Define to 202603 for ELF targets, and 0 otherwise.
* include/bits/version.h: Regenerate.
* include/std/contracts: Define
__cpp_lib_replaceable_contract_violation_handler.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Tomasz Kamiński [Wed, 8 Apr 2026 20:42:12 +0000 (22:42 +0200)]
libstdc++: Fix duplicated export on basic_string::_M_disjunct on Solaris.
The patterns for cow_string that were split to exclude starts_with,
ends_with, did not include name starting with _:
_ZNKSs[0-9][0-9][a-z]*;
_ZNKSbIwSt11char_traitsIwESaIwEE[0-9][0-9][a-z]*;
This was not caught on x86_64-linux as _M_disjunt was already exported
in 3.4 version (when HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT
is defined).
libstdc++-v3/ChangeLog:
* config/abi/pre/gnu.ver (GLIBCXX_3.4): Remove _ZNKSs11_[MS]_*
and _ZNKSbIwSt11char_traitsIwESaIwEE11_[MS]_* patterns.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Before callback edges were implemented, if foo got put into a COMDAT
group and subsequently virtually cloned (by ipa-cp, for example), then
the OpenMP kernel wouldn't be put into the same COMDAT group, since it
would be referred to by functions both inside and outside said COMDAT
group.
With callback edges, the kernel may be cloned as well. If both foo and
foo._omp_fn get cloned, foo's clone will be redirected to the cloned
kernel. This allows us to put foo._omp_fn into the same COMDAT group as
foo via ipa-comdat. As the kernel is artificial, it becomes
comdat-local.
However, this redirection is not immediate, leading to the situation in
the PR, where the clones are properly redirected in the call graph, but
the corresponding gimple call is not yet updated. If one calls
rebuild_references during this time on cloned foo, the reference that
gets rebuilt will still point to the old kernel, which is now in a
COMDAT group, thus creating a reference to a comdat-local symbol outside
of its COMDAT group, leading to a checking ICE. This patch remedies
that by checking for this case and building a reference to the correct
kernel.
PR ipa/124700
gcc/ChangeLog:
* cgraph.cc (cgraph_node::is_clone_of): New method, determines
whether a node is a descendant of another in the clone tree.
* cgraph.h (struct cgraph_node): Add decl of is_clone_of.
* cgraphbuild.cc (mark_address): Fix reference creation for
cloned callback functions.
The AVX10.2 saturation conversion instructions vcvttps2[u]qqs,
vcvttsd2[u]sis and vcvttss2[u]sis are missing operand size modifiers in
their Intel syntax output templates. This causes assembler errors when
using -masm=intel with memory operands, because Intel Syntax output
wrong memory size.
gcc/ChangeLog:
PR target/124710
* config/i386/sse.md (iptrps2qq): New mode attribute for
ps2qq Intel syntax memory operand size override.
(avx10_2_vcvttps2<sat_cvt_sign_prefix>qqs<mode><mask_name><round_saeonly_name>):
Use %<iptrps2qq>1 in Intel syntax to emit qword ptr for V2DI (128-bit)
memory operands.
(avx10_2_vcvttsd2<sat_cvt_sign_prefix>sis<mode><round_saeonly_name>):
Use %q1 in Intel syntax to emit qword ptr for scalar double memory
operands.
(avx10_2_vcvttss2<sat_cvt_sign_prefix>sis<mode><round_saeonly_name>):
Use %k1 in Intel syntax to emit dword ptr for scalar single memory
operands.
gcc/testsuite/ChangeLog:
PR target/124710
* gcc.target/i386/pr124710-1.c: New test.
* gcc.target/i386/pr124710-2.c: Ditto.
Jason Merrill [Mon, 13 Apr 2026 06:04:35 +0000 (02:04 -0400)]
c++: lambda capture scope and requires [PR122884]
I spent quite a while working on improving our representation of early
capture proxies, which was enough to make the noexcept work, but eventually
realized that for constraints, since they are substituted before we start to
build the actual function declaration, we need to handle reconstructing
capture proxies during substitution like we already do for parameters. So
this patch only does that; the early proxy representation changes can wait
for stage 1.
PR c++/122884
gcc/cp/ChangeLog:
* pt.cc (reconstruct_lambda_capture_pack): New.
(tsubst_pack_expansion): Use it.
(tsubst_decl): Handle capture proxy.
(tsubst): Handle lambda closure.
(tsubst_expr): Handle closure field.
(tsubst_lambda_expr): Copy closure location.
* constraint.cc (satisfy_declaration_constraints): Set up
local_specializations for a lambda.
gcc/testsuite/ChangeLog:
* g++.dg/cpp23/lambda-scope10.C: New test.
* g++.dg/cpp23/lambda-scope10a.C: New test.
fortran: Fix ICE in expand_oacc_for with private derived type [PR93554]
Using a derived type with an allocatable component in a private clause
on an OpenACC loop caused an ICE in expand_oacc_for because the
finalization code for the allocatable component inserted additional
basic blocks between the loop's continuation/entry blocks and the exit
block, violating the strict CFG assertions.
The assertions checked that BRANCH_EDGE(entry_bb)->dest == exit_bb and
FALLTHRU_EDGE(cont_bb)->dest == exit_bb, but with finalization blocks
these edges can point to intermediate blocks rather than directly to
the exit. Relax the assertions to only verify the expected edge count
(two successors) without requiring specific destinations.
PR fortran/93554
gcc/ChangeLog:
* omp-expand.cc (expand_oacc_for): Relax entry_bb and cont_bb
assertions to allow intermediate blocks from finalization code.
Remove exit_bb predecessor count assertion.
gcc/testsuite/ChangeLog:
* gfortran.dg/goacc/pr93554.f90: New test.
Signed-off-by: Christopher Albert <albert@tugraz.at>
fortran: Fix ICE in build_entry_thunks with CHARACTER bind(c) ENTRY [PR93814]
When a CHARACTER function with bind(c) has an ENTRY also with bind(c),
the entry master function returns CHARACTER by reference (void return,
result passed as pointer + length arguments), but the individual bind(c)
entry thunks return CHARACTER(1) by value and have no such arguments.
build_entry_thunks unconditionally forwarded result-reference arguments
from the thunk's own parameter list to the master call. For bind(c)
CHARACTER thunks this accessed DECL_ARGUMENTS of a function with no
arguments, causing a segfault.
Create local temporaries for the result buffer and character length in
the thunk when the master returns by reference but the thunk does not.
After calling the master (which writes through the reference), load
the character value from the local buffer and return it by value.
PR fortran/93814
gcc/fortran/ChangeLog:
* trans-decl.cc (build_entry_thunks): Create local result buffer
and length temporaries for bind(c) CHARACTER entry thunks when the
master returns by reference but the thunk returns by value.
gcc/testsuite/ChangeLog:
* gfortran.dg/pr93814.f90: New test.
Signed-off-by: Christopher Albert <albert@tugraz.at>
Harald Anlauf [Fri, 10 Apr 2026 21:01:49 +0000 (23:01 +0200)]
Fortran: defined assignment and vector subscripts [PR120140]
Fortran allows array sections with vector subscripts as actual arguments to
elemental procedures (e.g. F2023: 15.5.2.5):
(21) If the procedure is nonelemental, the dummy argument does not have
the VALUE attribute, and the actual argument is an array section having
a vector subscript, the dummy argument is not definable and shall not
have the ASYNCHRONOUS, INTENT (OUT), INTENT (INOUT), or VOLATILE
attributes.
Adjust the checking accordingly to allow vector subscripts in defined
assignment.
PR fortran/120140
gcc/fortran/ChangeLog:
* dependency.cc (gfc_check_argument_var_dependency): For elemental
subroutines skip the dependency check for array references.
Correct description of function return value.
* interface.cc (gfc_compare_actual_formal): Allow array sections
with vector subscripts as actual arguments to elemental procedures
in accordance with the Fortran standard.
gcc/testsuite/ChangeLog:
* gfortran.dg/defined_assignment_13.f90: New test.
Jakub Jelinek [Fri, 10 Apr 2026 19:52:48 +0000 (21:52 +0200)]
testsuite: Fix up g++.dg/reflect/type_trait14.C for -fimplicit-constexpr [PR124844]
The g++.dg/reflect/type_trait14.C test FAILs with -fimplicit-constexpr,
because in that case NLType is actually a literal type rather than
non-literal type and so is structural type too.
Fixed by making sure it is not a literal type even with
-fimplicit-constexpr.
2026-04-10 Jakub Jelinek <jakub@redhat.com>
PR c++/124844
* g++.dg/reflect/type_trait14.C (NLType::~NLType): Move definition out
of the class.
Jakub Jelinek [Fri, 10 Apr 2026 16:49:00 +0000 (18:49 +0200)]
c++: Include anon enum types in namespace members_of [PR124831]
As the testcase shows, we have similar problem with namespace scope
anonymous enums like we have with namespace scope anonymous unions.
Because they are anonymous, in neither case we emit anything into the
namespace bindings but we should still list those.
Now, for anonymous union this is done by adding it (once only) when
seeing corresponding DECL_ANON_UNION_VAR_P (and it doesn't work when there
is anon union without any members but that is a pedwarn anyway).
The following patch handles it similarly for anon enums, namespace scope
enum {}; is still ignored (but that is a pedwarn as well, so not a big deal)
and when there is at least one enumerator in it, we add it when seeing
the CONST_DECL (but again, just once for the whole members_of call).
2026-04-10 Jakub Jelinek <jakub@redhat.com>
PR c++/124831
* reflect.cc (namespace_members_of): Append reflection of anon unions
when we see it first time as CP_DECL_CONTEXT of some CONST_DECL in
the namespace.
fortran: Avoid bogus do-subscript warnings in skipped inner loops [PR94978]
Do not warn from an outer-loop bound substitution when a nested inner loop may
be zero-trip after that substitution, because the guarded array reference may
then be unreachable.
gcc/fortran/ChangeLog:
PR fortran/94978
* frontend-passes.cc (evaluate_loop_bound): New helper.
(inner_loop_may_be_skipped): New helper.
(do_subscript): Skip outer-loop bound warnings when nested inner loops
may be zero-trip for the substituted bound.
gcc/testsuite/ChangeLog:
PR fortran/94978
* gfortran.dg/pr94978.f90: New test.
Signed-off-by: Christopher Albert <albert@tugraz.at>
A few years ago Martin moved for unknown reasons -Winvalid-memory-model
diagnostics from expansion to the gimple-ssa-warn-access middle end warning
black hole.
A recent change limited the second instance of the pass to only a small
subset of warnings.
This regressed diagnostics of -Winvalid-memory-model with -fsanitize=thread,
because invalid cases are not warned about anymore during waccess2 and
during waccess3 we've already transformed those builtins into corresponding
tsan builtins.
The following patch fixes that regression by handling the tsan atomic
builtins as well. While doing that, I've also fixed formatting and noticed
other bogosities in the code, e.g. existance of xchg_models. No idea
where Martin got that from, neither C11, nor C23, nor various versions of
C++ nor GCC documentation have any restrictions on what memory models can be
used for atomic_exchange_explicit, so why is it trying to prevent
__ATOMIC_ACQUIRE?
And incorrectly so, __atomic_exchange_N has 3 arguments, and suc_arg is 0
based, so setting it to 3 meant it didn't check anything because the 4th
argument doesn't exist. So fixed to use all_models with the correct arg
index.
Besides this, there is another problem that we fold some atomic builtins
into IFN_ATOMIC* internal functions. That isn't a 16 Regression though,
could be fixed by also diagnosing this stuff for the IFN_ATOMIC_* calls,
but I'm not doing it right now because there is yet another problem.
C++17 in https://wg21.link/p0418r2 dropped some of the restrictions, in
particular that for the compare and exchange cases failure mode can't be
stronger than success mode. So I'm hesistant to add further warnings for
16 (beyond just fixing the -fsanitize=thread inconsistency), unsure if
we should somehow mark the atomic builtins from the C++ <atomic> APIs
that the no stronger checking shouldn't be done for those, or simply
mark those for all of C++17 and later, something else?
C23/C2Y I think still require it and it is reasonable requirement,
2026-04-10 <jakub@redhat.com>
PR middle-end/124827
* gimple-ssa-warn-access.cc (xchg_models): Remove.
(pass_waccess::check_atomic_builtin): Fix up sucs_arg for
BUILT_IN_ATOMIC_EXCHAGE_* and use all_models instead of xchg_models.
Handle BUILT_IN_TSAN_ATOMIC*. Formatting fixes.
Jakub Jelinek [Fri, 10 Apr 2026 07:47:36 +0000 (09:47 +0200)]
testsuite: Fix up g++.dg/lto/20091022-2_0.C test [PR124828]
From what I can see, this test was added for PR41791 where we didn't stream
in/out the system header flags for LTO. The test isn't perfect, because
even when we actually do stream those flags, whether it fails or not depends
on the exact decisions of the inliner whether it decides to inline all
inline/constexpr functions or not (maybe it would help to use some
--params to request inlining as few functions as possible).
Anyway, guess at some point we simply started to inline everything that was
used and so whether the test stopped failing even if it would use
-Wsystem-headers. Now, when not using installed gcc testing, we use
libstdc++-v3/scripts/testsuite_flags script which uses -I options rather
than -isystem, but the headers still had #pragma GCC system_header pragmas.
Except that r15-3859 guarded those pragmas with a macro which isn't defined
by default and needs to be defined only when we want to make sure the
headers are treated as system headers.
And later on the recent changes for C++20 stable string exports started
seeing a constexpr (thus implicitly inline for -Winline purposes) being too
large for default inlining and so the test started to fail again.
The following patch fixes it by making sure the libstdc++ headers are
treated as system headers, so the test tests again what it was supposed to
test.
2026-04-10 Jakub Jelinek <jakub@redhat.com>
PR lto/124828
* g++.dg/lto/20091022-2_0.C (_GLIBCXX_SYSHDR): Define before including
<string>.
Jakub Jelinek [Fri, 10 Apr 2026 06:46:16 +0000 (08:46 +0200)]
c++: Unshare expr in get_template_parm_object [PR124792]
The following testcase is miscompiled due to incorrect CONSTRUCTOR sharing.
For reflect_constant_array elts which aren't integral we call
convert_reflect_constant_arg (but reflect_constant etc. do the same) and
that eventually indirectly calls get_template_parm_object which creates
the TPO VAR_DECL with DECL_INITIAL. Unfortunately, some CONSTRUCTORs
in that DECL_INITIAL can be shared with whatever we use during constant
expression evaluation later on, so when we evaluate ~vector, we modify
those and with that modify also the CONSTRUCTORs inside of TPO
DECL_INITIAL CONSTRUCTOR.
So we need to unshare it somewhere.
This patch unshares in get_template_parm_object, i.e. the lowest level,
and only when not reusing previously created TPO.
2026-04-10 Jakub Jelinek <jakub@redhat.com>
PR c++/124792
* pt.cc (get_template_parm_object): Call unshare_expr_without_location
on expr if check_init.
Tomasz Kamiński [Thu, 9 Apr 2026 14:54:10 +0000 (16:54 +0200)]
libstdc++: Add default template parameters for uninitialized_fill(_n).
This implements P3217R0 and adds default argument for the value type
templater parameter for uninitialized_fill, uninitialized_fill_n and
their ranges counterpart.
libstdc++-v3/ChangeLog:
* include/bits/ranges_uninitialized.h
(__uninitialized_fill_fn::operator())
(__uninitialized_fill_fn_n::operator()): Add default argument
for _Tp parameter.
* include/bits/stl_uninitialized.h (std::unitialized_fill)
(std::unitialized_fill_n): Likewise.
* include/pstl/glue_memory_defs.h (std::unitialized_fill)
(std::unitialized_fill_n): Likewise.
* include/bits/version.def (algorithm_default_value_type):
Bump to 202603.
* include/bits/version.h: Regenerate.
* testsuite/25_algorithms/default_template_value.cc:
Test for new algorithms.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
RISC-V: Update RVV intrinsic version to ratified v1.0
The RVV intrinsic implementation already matches the ratified v1.0
interface, but GCC still advertises __riscv_v_intrinsic as v0.12 and
the manual still points users at the stale v0.11.x documentation.
Update __riscv_v_intrinsic to v1.0, adjust the related tests, and
update the manual to say that GCC supports the ratified v1.0 RVV
intrinsic specification and point at the v1.0-ratified release.
gcc/ChangeLog:
* config/riscv/riscv-c.cc (riscv_cpu_cpp_builtins): Set
__riscv_v_intrinsic to v1.0.
* doc/extend.texi (RISC-V Vector Intrinsics): Document the
ratified v1.0 RVV intrinsic specification and update the link.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/predef-__riscv_v_intrinsic.c: Update expected
__riscv_v_intrinsic value.
* gcc.target/riscv/rvv/base/pr114017-1.c: Update version check and
expected warning text to v1.0.
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
We check this in cp_parser_splice_expression. But when the splice
is dependent, we don't check it when instantiating, thus missing
the error in
template [: N == 0 ? ^^foo : ^^:: :] (0);
This patch introduces SPLICE_EXPR_TEMPLATE_P and SPLICE_EXPR_TARGS_P,
and moves the checking into check_splice_expr. It also adds a missing
check for DECL_TYPE_TEMPLATE_P in case we have a splice-expression of
the form template splice-specialization-specifier.
PR c++/123998
gcc/cp/ChangeLog:
* cp-tree.h (SPLICE_EXPR_TEMPLATE_P): Define.
(SET_SPLICE_EXPR_TEMPLATE_P): Define.
(SPLICE_EXPR_TARGS_P): Define.
(SET_SPLICE_EXPR_TARGS_P): Define.
(check_splice_expr): Adjust.
* parser.cc (cp_parser_splice_expression): Do
SET_SPLICE_EXPR_TEMPLATE_P and SET_SPLICE_EXPR_TARGS_P. Adjust
the call to check_splice_expr. Move the template_p checking into
check_splice_expr.
* pt.cc (tsubst_splice_expr): Do SET_SPLICE_EXPR_TEMPLATE_P and
SET_SPLICE_EXPR_TARGS_P. Adjust the call to check_splice_expr.
* reflect.cc (eval_constant_of): Adjust the call to
check_splice_expr.
(check_splice_expr): Two new bool parameters. Add the template_p
checking from cp_parser_splice_expression. Allow
variable_template_p in the assert. Add a check for
DECL_TYPE_TEMPLATE_P.
fortran: Diagnose invalid array initializer after parameter substitution [PR103367]
Keep the trunk fallback from r16-8509, but turn it into a real
constant-expression error instead of silently returning an empty
constructor. This avoids the ICE from PR103367 without regressing
the more specific diagnostics discussed in the Bugzilla follow-up.
PR fortran/103367
gcc/fortran/ChangeLog:
* trans-array.cc (gfc_conv_array_initializer): Emit an error for
invalid residual initializer expressions before returning a safe
empty constructor.
gcc/testsuite/ChangeLog:
* gfortran.dg/pr103367.f90: Expect a constant-expression error and
prune the legacy-extension warning.
Signed-off-by: Christopher Albert <albert@tugraz.at>
testsuite: arm: xfail test unless SP and DP FP [PR113276]
gcc/testsuite/ChangeLog:
PR testsuite/113276
* gcc.dg/torture/fp-double-convert-float-1.c: Xfail test for arm*
unless single- and double-precision FP.
* lib/target-supports.exp (check_effective_target_arm_mixed_fp):
New function.
Alex Coplan [Fri, 27 Mar 2026 16:54:24 +0000 (16:54 +0000)]
aarch64: Add some missing dependencies to t-aarch64 [PR122483]
A subsequent patch adds a new target hook; I noticed while testing an
incremental build that some aarch64 object files which invoke target
hooks are missing dependencies on target.def. This patch fixes that by
adjusting the relevant object files to depend on TARGET_H instead of
TM_H; the former includes the latter but additionally depends on
target.def.
I verified that these changes fixed test failures (ICEs) in
aarch64-sme.exp seen due to the missed dependencies in an incremental
build with later patches.
gcc/ChangeLog:
PR target/122483
* config/aarch64/t-aarch64: Replace instances of TM_H with
TARGET_H where appropriate, add missing dependency on TARGET_H
for aarch64-early-ra.cc.
Dhruv Chawla [Thu, 12 Feb 2026 04:06:03 +0000 (04:06 +0000)]
aarch64: AutoFDO: Add support for ARM SPE to autoprofiledbootstrap
This patch adds support for ARM SPE as a profiler to gcc-auto-profile
and the corresponding detection required for passing the
--profiler=perf_spe option to create_gcov when creating the GCOV files.
The patch also modifies the create_gcov invocation to make sure that the
corresponding component's profile is actually included in the perf.data
file. This is because some of the profiles end up not including invocations of
one of cc1, cc1plus or lto1 and trying to use them to generate the GCOV with the
missing binary ends up failing the create_gcov command. This is expected and is
not an error condition.
* Makefile.in (AFDO_PROFILER): New variable.
(PERF): Likewise.
* config/aarch64/gcc-auto-profile: Detect and use ARM SPE events when
invoking perf record.
* configure: Regenerate.
* configure.ac: Detect whether build has perf utility available and
check for ARM SPE-based profiling support when building on AArch64.
gcc/c/ChangeLog:
* Make-lang.in (create_fdas_for_cc1): Use $(AFDO_PROFILER) when passing
--profiler to create_gcov. Ensure that perf.data contains profile for
cc1. Make the console output more useful.
gcc/cp/ChangeLog:
* Make-lang.in (create_fdas_for_cc1plus): Use $(AFDO_PROFILER) when
passing --profiler to create_gcov. Ensure that perf.data contains
profile for cc1plus. Make the console output more useful.
gcc/lto/ChangeLog:
* Make-lang.in (create_fdas_for_lto1): Use $(AFDO_PROFILER) when passing
--profiler to create_gcov. Ensure that perf.data contains profile for
lto1. Make the console output more useful.
gcc/testsuite/ChangeLog:
* lib/profopt.exp (profopt-execute): Add support for profiler type
detection.
Only Zbs provides the bseti/binvi support that can directly handle a
large single-bit immediate in scalar IOR/XOR operations. Zbkb alone
does not, but synthesize_ior_xor treated Zbkb as sufficient and
returned false for such constants.
On RV32 with -march=rv32gc_zbkb this leaves an unmatchable
(ior:SI reg (const_int 0x20000)) RTL insn, which later triggers an ICE
in extract_insn during virtual register instantiation.
Restrict the single-bit fast path to Zbs and add an RV32 Zbkb
regression test for the reduced reproducer.
PR target/124818
gcc/ChangeLog:
* config/riscv/riscv.cc (synthesize_ior_xor): Do not treat
TARGET_ZBKB as sufficient for single-bit immediate IOR/XOR.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/pr124818.c: New test.
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
Tamar Christina [Thu, 9 Apr 2026 08:27:15 +0000 (09:27 +0100)]
vect: replace vect_scalar_cost_multiplier with param_vect_allow_possibly_not_worthwhile_vectorizations
The parameter vect_scalar_cost_multiplier was added in order to make it possible
to apply a scaling factor to the cost of a scalar loop in order to make
vectorization more or less profitable.
However because of the way the costing currently works, increasing the cost of a
scalar loop does not always result in vectorization because in some cases when
the cost of vectorization is very low we switch to looking at only the cost of
the epilog and prologs.
One case where this fell apart was uncounted loops. As a result this patch
replaces the parameter with
param_vect_allow_possibly_not_worthwhile_vectorizations which just ignores the
result of costing.
Xi Ruoyao [Mon, 6 Apr 2026 20:03:09 +0000 (04:03 +0800)]
ifcvt: reject use of ctrap post reload [PR 105192]
The ctrap expanders of several targets can end up creating pseudos. And
it would be really counter-intuitive to disallow a define_expand to
generate pseudos. So don't invoke the expander post reload.
PR target/105192
gcc/
* ifcvt.cc (find_if_header): Don't attempt to use ctrap expander
after reload.
fortran: Fix false explicit-interface-required for ENTRY with volatile [PR96986]
When resolving a call to an ENTRY procedure, the entry lookup that
replaces the master procedure's def_sym with the specific entry symbol
was inside the 'resolved != -1' block. During recursive resolution the
namespace is marked resolved == -1, so the lookup was skipped and the
explicit interface check used the master procedure's combined formal
argument list instead of the entry's own formals.
Move the entry lookup after the resolution block so it runs regardless
of the namespace resolution state.
PR fortran/96986
gcc/fortran/ChangeLog:
* resolve.cc (resolve_global_procedure): Move entry symbol
lookup outside the resolved != -1 block.
gcc/testsuite/ChangeLog:
* gfortran.dg/pr96986.f90: New test.
Signed-off-by: Christopher Albert <albert@tugraz.at>
Marek Polacek [Wed, 18 Mar 2026 17:48:40 +0000 (13:48 -0400)]
c++/reflection: ICE with invalid splice in member access expr [PR123726]
This patch fixes a crash on invalid code. In a class member access
with a splice, the splice cannot designate something that is not
a member of the object we're accessing. check_splice_expr could also
detect more invalid splices, such as accessing a class template or
alias template member with . or ->.
PR c++/123726
gcc/cp/ChangeLog:
* reflect.cc (check_splice_expr): Detect accessing a class template
or alias template with . or ->.
* typeck.cc (finish_class_member_access_expr): Check if the scope of
the spliced entity in a member access expression is of a class type.
Allow variable_template_p for context_for_name_lookup.
gcc/testsuite/ChangeLog:
* g++.dg/reflect/member1.C: Adjust dg-error.
* g++.dg/reflect/member22.C: New test.
Co-authored-by: Boris Staletic <boris.staletic@protonmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
Marek Polacek [Tue, 31 Mar 2026 20:52:10 +0000 (16:52 -0400)]
c++/reflection: spurious error with constrained return types [PR124457]
Here we are emitting a bogus error in get_reflection because it
got something for which is_auto was true: the constrained auto
coming from make_constrained_auto. We represent the
return-type-requirement as a constrained auto which is in fact
a placeholder, but in this case we don't want the error.
We can move the error from get_reflection to the parser to avoid
emitting the error.
Marek Polacek [Wed, 18 Mar 2026 21:51:35 +0000 (17:51 -0400)]
c++/reflection: allow fns/arrays as annotation values [PR124177]
With an annotation like [[=func]] gcc ends up calling
handle_annotation_attribute with TREE_VALUE (args) being
a VIEW_CONVERT_EXPR, whose type is a FUNCTION_TYPE. That kind of
annotation value should be decayed before checking if the type is
structural.
PR c++/124177
gcc/cp/ChangeLog:
* tree.cc (handle_annotation_attribute): Decay annotation
values. Turn if !type_dependent_expression_p into an assert.
gcc/testsuite/ChangeLog:
* g++.dg/reflect/annotations18.C: New test.
Co-authored-by: Boris Staletic <boris.staletic@protonmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
and do get_reflection -> resolve_nondeduced_context for ^^visit<0>,
we should already have substituted F, otherwise we only substitute
I with 0 and are left with a partial specialization. F should have
been substituted in tsubst_expr/REFLECT_EXPR, but the reflection is
REFLECT_EXPR<TEMPLATE_ID_EXPR<OVERLOAD, 0>>
and tsubst_expr doesn't do much with an OVERLOAD. This thing should
be
so that we go to tsubst_baselink and properly substitute the
TEMPLATE_DECL in the OVERLOAD.
cp_parser_reflect_expression doesn't call finish_id_expression which
would add the BASELINK for reason mentioned in the comment there. So
I think we can do the following: just call baselink_for_fns to create
the BASELINK if needed.
Richard Biener [Wed, 8 Apr 2026 07:27:41 +0000 (09:27 +0200)]
tree-optimization/124810 - ICE with loop fixup
The following fixes fix_loop_placements to properly consider
re-parenting only outer loops of a nest.
PR tree-optimization/124810
* cfgloopmanip.cc (fix_loop_placements): Do not stop
iterating when an inner loop didn't get re-parented.
Compute the outermost loop we have to consider re-parenting.
Matthias Kretz [Tue, 11 Nov 2025 15:27:34 +0000 (16:27 +0100)]
libstdc++: Remove non_type and replace it with constant_wrapper in function_ref
This implements P3948R1: constant_wrapper is the only tool needed
for passing constant expressions via function arguments.
This changes function_ref from nontype_t to constant_wrapper and
implements the ambiguity check (static_asert in function_ref
from constant_wrapper constructor).
In addition to P3948R1 this also includes the (forgotten) deduction
guide changes suggested in the draft PR [1].
[1] https://github.com/cplusplus/draft/pull/8878
libstdc++-v3/ChangeLog:
* include/bits/funcref_impl.h (function_ref::function_ref):
Change nontype_t parameter to constant_wrapper, and adjust
accordingly. Add static_assert detecting ambigous semantics.
(function_ref::operator=): Detect constant_wrapper rather than
nontype_t.
* include/bits/funcwrap.h (function_ref): Change nontype_t
parameter to constant_wrapper in deduction guides.
* include/bits/utility.h (std::nontype_t, std::nontype)
(std::__is_nontype_v): Remove.
(std::__is_constant_wrapper_v): Define.
* src/c++23/std.cc.in (std::nontype_t, std::nontype):
Remove exports.
* testsuite/20_util/function_ref/cw_cons_neg.cc: New tests
for ambiguity check.
* testsuite/20_util/function_ref/assign.cc: Replace nontype_t
with constant_wrapper and nontype with std::cw.
* testsuite/20_util/function_ref/call.cc: Likewise.
* testsuite/20_util/function_ref/cons.cc: Likewise.
* testsuite/20_util/function_ref/cons_neg.cc: Likewise.
* testsuite/20_util/function_ref/dangling.cc: Likewise.
* testsuite/20_util/function_ref/deduction.cc: Likewise.
* testsuite/20_util/function_ref/mutation.cc: Likewise.
Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com> Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Matthias Kretz <m.kretz@gsi.de> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>