Jim Lin [Wed, 8 Jul 2026 13:59:30 +0000 (07:59 -0600)]
[PATCH] RISC-V: Fix dead cpop reservation for spacemit-x60
The type "cpop" was listed in both spacemit_x60_alu (latency 1) and the
dedicated spacemit_x60_alu2c reservation (latency 2). Since
spacemit_x60_alu appears first, it always matched cpop and left
spacemit_x60_alu2c dead, so cpop was scheduled with the wrong latency.
Remove cpop from spacemit_x60_alu so the dedicated 2-cycle reservation
takes effect.
gcc/ChangeLog:
* config/riscv/spacemit-x60.md (spacemit_x60_alu): Remove cpop
from the type list.
Richard Biener [Wed, 8 Jul 2026 11:57:17 +0000 (13:57 +0200)]
tree-optimization/126150 - ICE with replace_uses_by
replace_uses_by triggers eventual BB removal from inside a
FOR_EACH_IMM_USE_STMT iteration. That's a no-go since we might
eliminate uses in the list we are currently processing. The
fix is to defer EH edge purging.
PR tree-optimization/126150
* tree-cfg.cc (replace_uses_by): Delay purging of EH edges
until after FOR_EACH_IMM_USE_STMT finished.
Martin Uecker [Sun, 28 Jun 2026 17:29:48 +0000 (19:29 +0200)]
c: harmonize handling of arrays of zero size
Use common functions for creating and detecting arrays of zero size.
The function to detect arrays of zero size is changed to also accept
C++ style representation that are somtimes created (at least in
complete_array_type). A future change may switch to only use this
representation. Other code is refactored to use the new helper functions
and to use flexible_array_member_type_p to properly distinguish between
the two cases (instead of checking for TYPE_MAX_VALUE being NULL_TREE).
As part of this, the explict check for complete types is removed from
composite_type_internal, which may be helpful when potentially allowing
arrays with incomplete element type (which alsoC occur already for
built-in va_arg types).
gcc/c/ChangeLog:
* c-tree.h (zero_length_array_type_p,
c_build_array_type_zero_size) Add prototypes.
* c-decl.cc (zero_length_array_type_p): External linkage.
(c_build_array_type_zero_size): New.
(grokdeclarator): Use new function.
* c-typeck.cc (c_verify_type): New consistency checks.
(c_build_array_type_zero_size): New function
(composite_type_internal): Refactor.
(comptypes_internal): Refactor.
Martin Uecker [Sun, 28 Jun 2026 18:04:14 +0000 (20:04 +0200)]
c: harmonize checking for flex array member type
We already have a helper function to detect the type of a flexible
array member. Rename it for consistency and move it to tree.cc.
Also use the function for some additional cases instead of using a
direct test. In digest_init the change removes the warning for
zero-sized arrays, but it is misleading and redundant as we already
warn for excess initializers (and with -Wpedantic also for the use
of zero-sized arrays).
gcc/c/ChangeLog:
* c-decl.cc (grokdeclarator): Add assertion.
(add_flexible_array_elts_to_size): Adapt.
(is_flexible_array_member_p): Adapt.
(verify_counted_by_attribute): Adapt.
(finish_struct): Adapt.
* c-typeck.cc (check_counted_by_attribute): Adapt.
(build_counted_by_ref): Adapt.
(build_access_with_size_for_counted_by): Adapt.
(handle_counted_by_for_component_ref): Adapt.
(c_incomplete_type_error): Use new helper function.
(digest_init): Use new helper function.
(pop_init_level): Use new helper function.
gcc/ChangeLog:
* tree.h (flexible_array_member_type_p): New helper function.
* tree.cc (flexible_array_member_type_p): New helper function.
(flexible_array_type_p): Use new helper function.
Richard Biener [Wed, 8 Jul 2026 08:06:40 +0000 (10:06 +0200)]
tree-optimization/126159 - handle unions in data dependence analysis
The following implements minimal handling of union accesses in
data reference analysis, namely accesses to non-aggregate fields,
in particular those we are not adding additional subsetting on.
PR tree-optimization/126159
* tree-data-ref.cc (dr_analyze_indices): Handle non-aggregate
union field accesses.
(access_fn_component_p): Adjust.
* gcc.dg/vect/vect-pr126159-1.c: New testcase.
* gcc.dg/vect/vect-pr126159-2.c: Likewise.
Mikael Morin [Mon, 22 Jun 2026 14:53:30 +0000 (16:53 +0200)]
fortran: Create a dedicated type for ranks and array dimensions
This patch adds a type to represent ranks and array dimension, using the
same base type as originally used for the rank in array descriptors
(signed char), but with the stricter bounds (0 to GFC_MAX_DIMENSIONS)
brought to the knowledge of the middle-end. The new type is used for
the rank in array descriptors, and in various places in the compiler as
well, such as loops on array dimensions. Conversions to signed char
are added in places where negative intermediary results were possible,
and loops on array dimensions where the new type is used have been
double-checked to not step backwards (in which case the iteration index
would reach -1 after the last iteration).
gcc/fortran/ChangeLog:
* trans-types.h (gfc_array_dim_rank_type): New type node
declaration.
* trans-types.cc (gfc_array_dim_rank_type): Likewise.
(gfc_init_types) : Initialize the new type node.
(get_dtype_type_node): Use the new type for the rank field.
* trans-descriptor.cc (gfc_conv_descriptor_rank): Likewise.
* trans-const.h (gfc_index_zero_node, gfc_index_one_node): Make
each macro a separate node declaration.
* trans-const.cc (gfc_index_zero_node, gfc_index_one_node):
Declare new nodes.
(gfc_init_constants): Initialize them. Use the new type for the
constants of the gfc_rank_cst array.
* trans-array.cc (gfc_tree_array_size): Use the new type for the
RANK, IDX and DIM variables. Avoid negative intermediary value
in comparison using the new type.
(gfc_conv_array_parameter): Use the new type when assigning a
value to the descriptor's rank. Use the new type for the IDX
variable.
* trans-decl.cc (gfc_conv_cfi_to_gfc): Use the new type for the
rank, and the dimension index variable (including loop initial
value and step).
* trans-expr.cc (gfc_conv_gfc_desc_to_cfi_desc): Likewise.
(gfc_conv_variable): Use the new type for the rank variable.
(gfc_trans_structure_assign): Use the new type when assigning a
value to the descriptor's rank.
* trans-openmp.cc (gfc_omp_get_array_size): Use the new type
for the dimension index variable and the loop initialization,
bound and step.
* trans-intrinsic.cc (gfc_conv_intrinsic_bound): Use the new
type for the DIM argument and the rank.
(conv_intrinsic_cobound): Likewise.
(trans_this_image): Likewise. Use the new type for the loop
variable, initialization, bound and step.
(gfc_conv_intrinsic_sizeof): Likewise.
* trans-stmt.cc (gfc_trans_select_rank_cases): Use signed char
as type for the select value.
Pengfei Li [Mon, 6 Jul 2026 13:11:32 +0000 (13:11 +0000)]
match.pd: Fold SAD_EXPR with identical inputs
Normally, SAD_EXPRs with identical first and second operands are not
constructed, since the absolute difference value is zero. However, this
can still appear when vectorizing small iteration-count reduction loops
with an absolute difference operation.
This patch adds a match.pd rule to fold the redundant SAD_EXPR to its
accumulator operand.
Bootstrapped and tested on aarch64-linux-gnu and x86_64-linux-gnu.
notice how _22 and and the actual vector pointer vectp_x.6_25 start at the
same offset but have a different base. This happens because in
vect_create_addr_base_for_vector_ref we fold the offset into the base very
early and so we can't form or share the address computation anymore with the
scalar address which needs to be there for the alignment checks.
The patch delays this and forms an explicit base + offset and keeping base as
a separate value. This allows VN at the end of vect to share the computations
and we get
Tamar Christina [Wed, 8 Jul 2026 07:34:33 +0000 (08:34 +0100)]
vect: replace iterations bounded to length to for_each
Replace uses of iterators over length of SLP_TREE_SCALAR_STMTS and
SLP_TREE_SCALAR_OPS with for-each loops when the .length () was just being used
as an index.
This is because we are trying to get rid of the notion of the number of scalar
statement or ops determining the number of lanes in the SLP tree and such
iterators are confusing.
i.e. it was a numbered for each.
gcc/ChangeLog:
* tree-vect-data-refs.cc (vect_slp_analyze_store_dependences,
vect_slp_analyze_load_dependences,
vect_slp_analyze_instance_dependence): Use for-each over for with len.
* tree-vect-slp.cc (vect_mark_slp_stmts_relevant,
,vect_find_last_scalar_stmt_in_slp, vect_find_first_scalar_stmt_in_slp,
vect_build_slp_store_interleaving, vect_analyze_slp,
vect_slp_prune_covered_roots, vect_bb_partition_graph_r,
vect_remove_slp_scalar_calls): Likewise.
Richard Biener [Tue, 7 Jul 2026 06:54:45 +0000 (08:54 +0200)]
Improve variadic function call handling in PTA
The following fixes handling of __builtin_va_start handling and
implements .VA_ARG handling in PTA constraint generation to
improve precision around variadic calls. I've added a testcase
for IPA PTA involving an indirect variadic call verifying precision.
The pr99679-1.C no longer emits an expected error that was triggered
by PTA calling aggregate_value_p on the .VA_ARG call which we no
longer do.
* gimple-ssa-pta-constraints.cc (find_func_aliases_for_builtin_call):
Correctly use SCALAR rhs from the variadic argument part of
the function info or from NONLOCAL in case of intra-PTA.
(find_func_aliases_for_call): Handle .VA_ARG.
Philipp Tomsich [Wed, 8 Jul 2026 06:46:25 +0000 (08:46 +0200)]
aarch64: populate issue_info for the ampere1 family
The ampere1, ampere1a and ampere1b tunes leave the vector issue_info
in cpu_vector_cost as NULL, so determine_suggested_unroll_factor bails
out early and reduction loops are never multi-accumulator-unrolled on
these cores. Fill it in from the ampere1 optimization guide (L1D two
128-bit loads plus one store per cycle, four general ops per cycle).
gcc/ChangeLog:
* config/aarch64/tuning_models/ampere1.h (ampere1_scalar_issue_info)
(ampere1_advsimd_issue_info, ampere1_vec_issue_info): New.
(ampere1_vector_cost): Use ampere1_vec_issue_info for issue_info.
* config/aarch64/tuning_models/ampere1b.h (ampere1b_scalar_issue_info)
(ampere1b_advsimd_issue_info, ampere1b_vec_issue_info): New.
(ampere1b_vector_cost): Use ampere1b_vec_issue_info for issue_info.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/ampere1-reduction-unroll-1.c: New test.
there is no need for ix86_expand_call to add clobbers for when one ABI
calls another ABI.
ABI_ALTERNATE is the alternate function ABI from the system ABI. If
ix86_abi is SYSV_ABI, ABI_ALTERNATE is the function ABI for MS_ABI.
Otherwise, ABI_ALTERNATE is the function ABI for SYSV_ABI.
This target hook also properly marks the implicit __tls_get_addr call:
PR target/124798
PR target/125436
* config/i386/i386-expand.cc: Include "function-abi.h".
(x86_64_ms_sysv_extra_clobbered_registers): Removed.
(ix86_expand_call): Don't add explicit call and ABI-switch
clobbers.
* config/i386/i386-features.cc (ix86_emit_tls_call): Call
ix86_tls_get_addr_abi to get GNU TLS ABI and use it, instead of
default_function_abi, for registers clobbered by GNU TLS call.
(ix86_place_single_tls_call): Set CALL_INSN_ABI_ID on TLS calls.
* config/i386/i386-options.cc (ix86_set_current_function): Don't
call reinit_regs.
* config/i386/i386-protos.h
(ix86_type_no_callee_saved_registers_p): Removed.
(ix86_tls_get_addr_abi): New.
* config/i386/i386.cc (ix86_alternate_abi): New prototype.
(ix86_conditional_register_usage): Changed to describe the
system ABI.
(ix86_type_no_callee_saved_registers_p): Make it static.
(ix86_function_value_regno_p): Replace ix86_cfun_abi () with
ix86_abi.
(ix86_save_reg): Only check TYPE_NO_CALLEE_SAVED_REGISTERS as
a special case.
(ix86_tls_get_addr_abi): New.
(legitimize_tls_address): Set CALL_INSN_ABI_ID on TLS calls.
Call ix86_alternate_abi to initialize the alternate function ABI.
(ix86_initialize_abi): New function.
(ix86_no_callee_saved_abi): Likewise.
(ix86_no_caller_saved_abi): Likewise.
(ix86_standard_abi): Likewise.
(ix86_alternate_abi): Likewise.
(ix86_function_abi_id): Likewise.
(ix86_fntype_abi): Likewise.
(ix86_hard_regno_call_part_clobbered): Handle newly added ABIs.
(TARGET_FNTYPE_ABI): New.
* config/i386/i386.md: Add ABI_ALTERNATE, ABI_NO_CALLEE_SAVED,
ABI_NO_CALLER_SAVED_RETURN_VOID, ABI_NO_CALLER_SAVED_RETURN_AX,
ABI_NO_CALLER_SAVED_RETURN_AX_DX,
ABI_NO_CALLER_SAVED_RETURN_AX_XMM0,
ABI_NO_CALLER_SAVED_RETURN_XMM0 and
ABI_NO_CALLER_SAVED_RETURN_XMM0_XMM1.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Co-Authored-by: Richard Sandiford <rdsandiford@googlemail.com> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
call_used_regs is a legacy interface that targets use to tell
init_reg_sets_1 about the default (system) ABI. In x86 terms,
that means the ABI associated with ix86_abi.
Targets can continue to read call_used_regs directly if they
don't have multiple ABIs. But now that x86 does, it's better
to be explicit about which ABI is being queried. This is
currently a nop but becomes important with the upcoming
function_abi patch.
As the comment in ix86_emit_tls_call says:
/* TLS_GD and TLS_LD_BASE instructions are normal functions which
clobber caller-saved registers. [...]
So that function really is querying the system ABI.
Similarly, x86_order_regs_for_local_alloc is called when initialising
a target, rather than once per function, so it too should query the
system ABI.
ix86_save_reg and x86_64_select_profile_regnum ask about the
current function's ABI, which is crtl->abi.
gcc/
* config/i386/i386-features.cc: Include function-abi.h.
(ix86_emit_tls_call): Use default_function_abi instead of
call_used_regs.
* config/i386/i386.cc (x86_order_regs_for_local_alloc): Likewise.
(ix86_save_reg, x86_64_select_profile_regnum): Use crtl->abi
instead of call_used_regs.
i386: Split out call_saved_registers_type detection
There are currently two places that want to query a function's
call_saved_registers_type: ix86_set_func_type (when setting up
cfun->machine) and ix86_type_no_callee_saved_registers_p
(a derived query). The upcoming function_abi patch will add
another one, so this patch splits the code out into a subroutine.
ix86_set_func_type did some of the detection first, into
no_callee_saved_registers, but then ignored the result if
cfun->machine->func_type had already been set. The patch therefore
moves all of the detection after the cfun->machine->func_type test,
rather than moving all of it before.
gcc/
* config/i386/i386-protos.h (ix86_fntype_call_saved_registers):
Declare.
* config/i386/i386-options.cc (ix86_fntype_call_saved_registers): New
function, split out from...
(ix86_set_func_type): ...here. Avoid calling it if the result
would be ignored.
* config/i386/i386.cc (ix86_type_no_callee_saved_registers_p): Use
ix86_fntype_call_saved_registers instead of querying attributes
directly.
Pan Li [Wed, 1 Jul 2026 05:48:17 +0000 (13:48 +0800)]
RISC-V: Add test cases for vzext.vf2 reg overlap
Add test cases for vzext.vf2 register group overlap, please
note it is not overlap as much as possible.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u16-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u16-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u16-m4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u16-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u16-mf4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u32-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u32-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u32-m4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u32-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u8-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u8-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u8-m4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u8-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u8-mf4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vzext_vf2-u8-mf8.c: New test.
Pan Li [Wed, 1 Jul 2026 05:39:43 +0000 (13:39 +0800)]
RISC-V: Add test cases for vsext.vf2 reg overlap
Add test cases for vsext.vf2 register group overlap, please
note it is not overlap as much as possible.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/rvv.exp: Add group_overlap folder.
* gcc.target/riscv/rvv/autovec/group_overlap/group_overlap.h: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf2-i16-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf2-i16-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf2-i16-m4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf2-i16-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf2-i16-mf4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf2-i32-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf2-i32-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf2-i32-m4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf2-i32-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf2-i8-m1.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf2-i8-m2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf2-i8-m4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf2-i8-mf2.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf2-i8-mf4.c: New test.
* gcc.target/riscv/rvv/autovec/group_overlap/vsext_vf2-i8-mf8.c: New test.
Pan Li [Tue, 7 Jul 2026 03:52:34 +0000 (11:52 +0800)]
RISC-V: Allow RVV register overlap for v[sz]ext.vf2
According to the RVV 1.0 spec, the widening ops like vzext.vf2
could have the source registers overlap on constraint, aka:
`
The destination EEW is greater than the source EEW, the source
EMUL is at least 1, and the overlap is in the highest-
numbered part of the destination register group.
`
However, the lra for now doesn't try to overlap as much as
possible. The overlap rvv register pair(s) in the constraint
is avaiable but the lra is the final decicsion maker to pick
the avaiable register pairs.
Therefore, from the test cases we can see, not all registers
in rvv will overlap for insn vsext.vf, even if it could
overlap up to a point.
gcc/ChangeLog:
* config/riscv/constraints.md (Wtt): Rename to Wvr to
indicate widen vector register constraint.
* config/riscv/riscv-protos.h (riscv_widen_overlap_ok): Rename
from...
(riscv_vector_mode_p): Add new decl for riscv-v.cc visibile.
(riscv_hard_regno_nregs): Ditto.
(riscv_v_widen_constraint_ok): Rename to...
* config/riscv/riscv-v.cc (riscv_v_widen_constraint_ok): Rename
to... and take care of Wvr constraint.
* config/riscv/riscv.cc (riscv_vector_mode_p): Remove static.
(riscv_hard_regno_nregs): Ditto.
(riscv_widen_overlap_ok): Remove.
* config/riscv/vector.md: Rename to Wvr.
can_convert_eh implements the [except.handle] matching rules, but did
not cover the case of a std::nullptr_t exception being caught by a
handler of pointer or pointer-to-member type. Add it.
gcc/cp/ChangeLog:
* except.cc (can_convert_eh): Handle a nullptr_t exception
caught by a pointer or pointer-to-member handler.
gcc/testsuite/ChangeLog:
* g++.dg/eh/can-convert-nullptr.C: New test.
c++: fix unevaluated operand context for typeid [PR125886]
Per [expr.typeid]/4-5, a typeid operand is unevaluated by default and
is evaluated only for a glvalue of polymorphic class type whose dynamic
type is not known at compile time. Previously GCC always parsed the
operand in an evaluated context, which broke unevaluated uses (declval,
non-static data members per DR613, function parameters) and missed
lambda capture diagnostics for evaluated polymorphic operands.
Implement a two-pass parse: first under cp_unevaluated, then - if
typeid_evaluated_p says the operand is evaluated - roll back and
re-parse under cp_evaluated. Share the evaluated/unevaluated predicate
via typeid_evaluated_p in rtti.cc, used from the parser, tsubst_expr,
and build_typeid.
Also fixes PR c++/68604 and PR c++/116385, and removes a now-stale xfail
in g++.dg/coroutines/unevaluated.C.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/pr125886.C: New test.
* g++.dg/rtti/typeid14.C, g++.dg/rtti/typeid15.C: New tests.
* g++.dg/coroutines/unevaluated.C: Drop stale xfail.
aarch64: Remove +mpamv2 and support for MPAMV2_VID.
There are no known implementations of the MPAMV2_VID extension, and
Arm has decided to remove it from the AArch64 architecture specification.
This patch implements that withdrawal. The only purpose of the +mpamv2
architectural feature extension was to enable the instructions added
by MPAMV2_VID in the assembler and these have also been removed. The
feature extension is thus redundant and has been removed. The sysreg
specifications have been updated to conform with similar sysregs that
have no associated instructions in the feature.
gcc/ChangeLog:
* config/aarch64/aarch64-option-extensions.def (AARCH64_OPT_EXTENSION):
Remove +mpamv2.
* config/aarch64/aarch64-sys-regs.def: Remove sysregs associated
with MPAMv2_VID and adjust other related sysregs to use the
base permitted architecture.
* doc/invoke.texi (aarch64: +mpamv2): Remove option.
Jerry DeLisle [Tue, 7 Jul 2026 01:30:05 +0000 (18:30 -0700)]
fortran: [PR103367] Followup patch to fix related test cases
PR fortran/103367
gcc/fortran/ChangeLog:
* expr.cc (simplify_const_ref): Hoist the call to
remove_subobject_ref up a level.
* primary.cc (gfc_match_rvalue): Don't copy the value expr
if the type is an EXPR_VARIABLE.
not
* trans-array.cc (gfc_conv_array_initializer): Only copy the expr
value if it does not have a ref.
gcc/testsuite/ChangeLog:
* gfortran.dg/pr103367_2.f90: New test.
* gfortran.dg/pr103367_3.f90: New test.
* gfortran.dg/pr103367_4.f90: New test.
Dhruv Chawla [Tue, 19 May 2026 05:45:28 +0000 (05:45 +0000)]
aarch64: Add support for -mcpu=rigel
This adds support for the NVIDIA Rigel core to the AArch64 backend. The
initial patch does not add any special tuning decisions, and those may come
later.
Bootstrapped and tested on aarch64-none-linux-gnu.
[PATCH v5] RISC-V: Add small loop unrolling support via -munroll-only-small-loops
This patch introduces a conservative loop unrolling heuristic for the
RISC-V backend, controlled by the new -munroll-only-small-loops option.
When -munroll-only-small-loops is active, only small loops (those whose
body does not exceed a per-tune instruction threshold) are unrolled, and
the unroll factor is capped by a per-tune parameter, so that tight loops
benefit from unrolling without exposing larger loops to its code-size and
instruction-cache costs.
Mirroring the i386 model, -funroll-loops and -munroll-only-small-loops are
enabled by default at -O2 and above (for speed). An explicit -funroll-loops
(or -funroll-all-loops) turns -munroll-only-small-loops off, so a user who
explicitly asks for unrolling still gets loops of any size unrolled. The
size threshold and the maximum unroll factor come from the -mtune tuning
parameters.
Since -funroll-loops is now enabled by default at -O2 and above, a number
of pre-existing RISC-V tests that scan for a specific code sequence change
their output once loops are unrolled. As those tests do not aim to exercise
unrolling, add -fno-unroll-loops to their options so they keep validating
their intended property regardless of the unrolling decision.
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc (riscv_option_optimization_table):
Enable -funroll-loops and -munroll-only-small-loops at -O2 and above.
* config/riscv/riscv.cc (struct riscv_tune_param): Add fields
small_loop_unroll_ninsns and small_loop_unroll_factor.
(xt_c9501_tune_info): Set them.
(riscv_loop_unroll_adjust): New function.
(riscv_option_override): Turn off -munroll-only-small-loops when
-funroll-loops or -funroll-all-loops is explicitly given.
(TARGET_LOOP_UNROLL_ADJUST): Define.
* config/riscv/riscv.opt (munroll-only-small-loops): New option.
* config/riscv/riscv.opt.urls: Regenerate.
* doc/invoke.texi (RISC-V Options): Document -munroll-only-small-loops.
libstdc++: Validate user-provided stride values for layout_stride.
Converting the __strides values using __index_type_cast asserts
that they are non-negative and each value is representable as
index_type.
libstdc++-v3/ChangeLog:
* include/std/mdspan
(layout_stride::mapping::mapping(const extent_type&, span<...>)):
Convert strides using __index_type_cast, which bring asserts
for negative and unrepresentable values.
* testsuite/23_containers/mdspan/layouts/stride_neg.cc: New test.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Tomasz Kamiński [Tue, 23 Jun 2026 08:00:01 +0000 (10:00 +0200)]
libstdc++: Gracefully handle unrecognized _Arg_t values in basic_format_arg.
Implementing features from later revision of the standard, may require
extending the set of types stored directly in _Arg_value (without
changing in size and aliment), and thus expanding the values in _Arg_t.
However, any such value would be unrecognized by the TUs compiled with
older release, and would lead to UB (call to __builtin_unreachable).
This patch addresses above by introducing _M_handle_unrecognized method,
that is called instead. As specializations of this method for all
context supported at runtime (format_context and wformat_context) are
exported from libstdc++.so, the newest version (supporting all _Arg_t
values introduced later) will be picked (this is ensured by not providing
template definition in header in such case).
In consequence, the implementation may return handle object referencing
new alternatives (such wrapping is already required to provide standard
compliant behavior of visit_format_arg).
As no new _Arg_t were introduced since GCC16, this method simply throws
format_error now, and contains appropriate comment.
Note that the above is not required for formatting when __do_vformat_to
is exported (Unicode literal encoding and C++20). It remains necessary
in remaining cases or when visit on basic_format_arg is called by user.
In consequence addition of new argument types stored directly does not
have negative impact on performance in most common case.
This patch also removes the __type parameter from the _M_visit and
_M_visit_user, and uses _M_type member instead. This prevents misuse,
as the provided type was always required to match _M_type.
libstdc++-v3/ChangeLog:
* config/abi/pre/gnu.ver (GLIBCXX_3.4.36): Export basic_format_arg
_M_handle_unrecognized method of specializations of
format_context and wformat_context.
* include/std/format (basic_format_arg::_M_handle_unrecognized):
Declare with explicit specializations for (w)format_context
if _GLIBCXX_EXTERN_TEMPLATE, and define otherwise.
(basic_format_arg::_M_visit): Remove __type parameter, and use
_M_type instead. Call _M_handle_unrecognized for unrecognized
_Arg_t values.
(basic_format_arg::_M_visit_user): Remove __type parameter,
and use _M_type instead. Adjust calls to _M_visit.
(basic_format_arg::visit, std::visit_format_arg)
(__format::__visit_format_arg): Remove _M_type argument from
_M_visit(_user) calls.
* src/c++20/format-inst.cc
(basic_format_arg::_M_handle_unrecognized): Define and export
explicit specializations for (w)format_context.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Kyrylo Tkachov [Wed, 17 Jun 2026 09:03:41 +0000 (02:03 -0700)]
aarch64: Fix ICE in aarch64_function_arg_alignment with may_alias [PR124146]
aarch64_function_arg_alignment returns the ABI alignment of an argument.
For scalars and vectors this is the natural alignment of the type,
ignoring any user-specified alignment. The code obtains the natural
alignment from the TYPE_MAIN_VARIANT, relying on the main variant having
no user alignment. PR108910 showed that this does not hold for pointers,
and that case is handled explicitly.
PR124146 is another counterexample. An attribute that affects type
identity, such as may_alias, makes a type its own TYPE_MAIN_VARIANT, so
the main variant retains the user alignment requested by the aligned
attribute. TYPE_MAIN_VARIANT therefore does not strip the alignment and
the gcc_assert (!TYPE_USER_ALIGN (type)) fires.
In the testcase the may_alias+aligned type reaches the argument-passing
code because foo is inlined into bar and forwprop propagates the value
of that type directly into the recursive call to bar.
Fix it by ignoring user alignment explicitly: when the type still has
user alignment, use the natural alignment of its mode, exactly as the
!type path at the top of the function already does. Behaviour is
unchanged for the existing (non-user-aligned) cases, since the natural
alignment of a scalar or vector equals its mode alignment. This also
gives the natural alignment when a may_alias typedef lowers the
alignment of a 16-byte type, matching the AAPCS64 (and Clang).
The same applies to _BitInt, which is covered by pr124146-4.c: user
alignment is ignored so a _BitInt up to 64 bits uses a single register,
one between 65 and 128 bits uses a 16-byte two-register container, and
one wider than 128 bits is passed by reference.
Bootstrapped and tested on aarch64-none-linux-gnu.
gcc/
PR target/124146
* config/aarch64/aarch64.cc (aarch64_function_arg_alignment):
Ignore user alignment left on a type's main variant; use the
mode's natural alignment instead.
gcc/testsuite/
PR target/124146
* gcc.target/aarch64/pr124146.c: New test.
* gcc.target/aarch64/pr124146-2.c: New test.
* gcc.target/aarch64/pr124146-3.c: New test.
* gcc.target/aarch64/pr124146-4.c: New test.
rs6000: Add vector uncompress and unpack builtins for -mcpu=future [RFC02691]
Add support for vector uncompress and unpack instructions
proposed in RFC02691. These instructions may or may not be added to a future
Power processor, and the names of the builtins may change in the future.
The instructions are exposed through new builtins and intrinsics
interfaces and are enabled when compiling with -mcpu=future.
This patch adds RTL patterns for vector uncompress (nibble, byte, and
halfword) and unpack operations in altivec.md, along with the
corresponding builtin definitions in rs6000-builtins.def and overload
entries in rs6000-overload.def.
The following new builtins are provided:
vector unsigned short vec_uncompresshn (vector unsigned char,
vector unsigned int)
vector unsigned int vec_uncompresshb (vector unsigned short,
vector unsigned short)
vector unsigned long long vec_uncompresshh (vector unsigned int,
vector unsigned char)
vector unsigned short vec_uncompressln (vector unsigned char,
vector unsigned int)
vector unsigned int vec_uncompresslb (vector unsigned short,
vector unsigned short)
vector unsigned long long vec_uncompresslh (vector unsigned int,
vector unsigned char)
vector signed char vec_unpack_hsn_to_byte (vector unsigned long long)
vector signed char vec_unpack_lsn_to_byte (vector unsigned long long)
vector unsigned char vec_unpack_int4_to_bf16 (vector unsigned short,
const int<2>)
vector unsigned char vec_unpack_int8_to_bf16 (vector unsigned short,
const int<1>)
vector float vec_unpack_int4_to_fp32 (vector unsigned int, const int<3>)
vector float vec_unpack_int8_to_fp32 (vector unsigned int, const int<2>)
2026-06-23 Kishan Parmar <kishan@linux.ibm.com>
gcc/ChangeLog:
* config/rs6000/altivec.md (UNSPEC_VUCMPRHN): New unspec entry.
(UNSPEC_VUCMPRLN): Likewise.
(UNSPEC_VUCMPRHB): Likewise.
(UNSPEC_VUCMPRLB): Likewise.
(UNSPEC_VUCMPRHH): Likewise.
(UNSPEC_VUCMPRLH): Likewise.
(UNSPEC_VUPKHSNTOB): Likewise.
(UNSPEC_VUPKLSNTOB): Likewise.
(UNSPEC_VUPKINT4TOBF16): Likewise.
(UNSPEC_VUPKINT8TOBF16): Likewise.
(UNSPEC_VUPKINT4TOFP32): Likewise.
(UNSPEC_VUPKINT8TOFP32): Likewise.
(vu_hl): New attribute.
(vu_lh): Likewise.
(VUPKNTOB): New int iterator.
(altivec_vupkhsntob): New define_insn.
(altivec_vupklsntob): Likewise.
(altivec_vupkint4tobf16): Likewise.
(altivec_vupkint8tobf16): Likewise.
(altivec_vupkint4tofp32): Likewise.
(altivec_vupkint8tofp32): Likewise.
(vucmpr_splat): New attribute.
(vucmpr_pcv): Likewise.
(vucmpr_uim): Likewise.
(VUCMPR_N): New int iterator.
(VUCMPR_B): Likewise.
(VUCMPR_H): Likewise.
(altivec_vucmpr<vu_hl>n): New define_expand.
(altivec_vucmpr<vu_hl>n_direct): New define_insn for vucmpr<vu_hl>n.
(altivec_vucmpr<vu_hl>b): New define_expand.
(altivec_vucmpr<vu_hl>b_direct): New define_insn for vucmpr<vu_hl>b.
(altivec_vucmpr<vu_hl>h): New define_expand.
(altivec_vucmpr<vu_hl>h_direct): New define_insn for vucmpr<vu_hl>h.
* config/rs6000/rs6000-builtins.def: Add vector uncompress and unpack
builtins under [future].
* config/rs6000/rs6000-overload.def: Add vec_uncompress* and vec_unpack*
interfaces.
Richard Earnshaw [Thu, 25 Jun 2026 17:02:47 +0000 (18:02 +0100)]
MAINTAINERS: Add a script to create a new entry in the mainainers data
This script is intended to help with the most common case of creating
a new entry in the MAINTAINERS.yml data - adding the basic data for a
new account. It takes care of creating the entry in the canonical
location within the file and collecting the basic data. It only adds
the write-after role, but it should be trivial to add any additional
roles if necessary following the examples elsewhere.
contrib/download_prerequisites: Use gettext-1.0.tar.gz
gettext-0.22 has some configure tests which dump cores, making it so
that building GCC with in-tree gettext triggers core collection
mechanisms like systemd-coredump and pollutes them with useless
coredumps.
This issue appears to be gone in gettext-1.0 so update to that.
We might as well use the new version anyway.
contrib/ChangeLog:
* download_prerequisites (gettext): Set gettext source file to
gettext-1.0.tar.gz.
* prerequisites.md5: Update gettext hash.
* prerequisites.sha512: Update gettext hash.
or1k: Stop allowing referring to SR_F in SImode and fix cmov
We were seeing compiler errors such as:
x.c:8:1: error: insn does not satisfy its constraints:
8 | }
| ^
(insn 33 28 35 2 (set (reg:SI 34 ?sr_f)
(reg:SI 16 r17 [52])) "x.c":6:7 discrim 1 28 {*movsi_internal}
(nil))
during RTL pass: postreload
This was being caused by previous commit c0694f95f59 ("or1k: Fix ICE in
libgcc caused by recent validate_subreg changes") and commit 710581c80b2
("or1k: Allow SImode for condition flag register") which allow
referecing SR_F in SImode to avoid errors during if conversion.
We can completely avoid this by reverting the changes to allow
referencing SR_F in SImode and fixing the
or1k_noce_conversion_profitable_p function to allow cmov expansion even
when TARGET_CMOV is not enabled. The *cmov split logic can take care of
lowering the *cmov instructions if l.cmov is not supported during the
later split passes.
gcc/
PR target/126081
* config/or1k/or1k.cc (or1k_hard_regno_mode_ok): Stop allowing
SImode for FLAG_REGS.
(or1k_can_change_mode_class): Stop allowing SImode for
FLAG_REGS.
(or1k_noce_conversion_profitable_p): Always check
or1k_is_cmov_insn.
gcc/testsuite/
PR target/126081
* gcc.target/or1k/pr126081.c: New test.
tree-optimization: Extend CDCE memset shrink-wrapping to {0, N} ranges [PR102202]
The patch extends the CDCE shrink-wrapping support added for PR102202.
The existing transform handles memset calls whose length is known to be
in [0, 1]. It bypasses the call for length zero and specializes the
nonzero path to a constant length of one.
Extend this to exact two-value length ranges {0, N}, where N is a
nonzero integer constant. The zero-length path is still bypassed and
the nonzero path is specialized to the constant N. In particular, the
transform does not accept an ordinary interval [0, N] since such an
interval can contain values other than zero and N.
The range query now returns the nonzero member of either a [0, 1] range
or an exact {0, N} range. The existing [0, 1] behavior is preserved.
gcc/ChangeLog:
PR tree-optimization/102202
* tree-call-cdce.cc: Include "value-query.h" and "value-range.h".
(len_has_boolean_range_p): Remove.
(get_len_nonzero_value): New function. Return the nonzero member of
LEN's value range when it is a boolean range [0, 1] or an exact
two-value set {0, N}.
(can_shrink_wrap_len_p): Replace len_has_boolean_range_p call with
get_len_nonzero_value. Add NONZERO_LEN output parameter and set it
to the returned nonzero value on success.
(shrink_wrap_len_call): Use it to pin the length argument on the
guarded call path instead of build_one_cst.
(shrink_wrap_conditional_dead_built_in_calls): Declare local
nonzero_len and pass it to can_shrink_wrap_len_p and forward it to
shrink_wrap_len_call.
(pass_call_cdce::execute): Pass nullptr as NONZERO_LEN to
can_shrink_wrap_len_p.
gcc/testsuite/ChangeLog:
PR tree-optimization/102202
* gcc.dg/pr102202-3.c: New test.
* gcc.dg/pr102202-4.c: New test.
Andrew MacLeod [Tue, 30 Jun 2026 14:43:07 +0000 (10:43 -0400)]
Ranger stmt prefill should process dependencies first.
Rangers stmt prefill is designed to prevent deep recursion through the
normal range_of_stmt/range_of_expr/Range_on_entry cycle when
dependencies have not yet been processed. It neglects to do this for
PHI arguments and if the order is wrong, it can undo everything it is
suppose to solve.
Do a proper DFS stack simulation to process all operands properly.
PR tree-optimization/125758
gcc/
* gimple-range.cc (gimple_ranger::gimple_ranger): Create prefill stack.
(gimple_ranger::gimple_ranger): Dispose of prefill stack.
(gimple_ranger::prefill_name): Maybe push name on prefill stack.
(gimple_ranger::prefill_stmt_dependencies): Implement a DFS
stack for dependency satisfaction.
* gimple-range.h (struct prefill_frame): New.
(m_prefill_stack): New.
(prefill_name): Sadjust parameters.
(m_active_prefill): New.
Andrew MacLeod [Thu, 18 Jun 2026 16:23:42 +0000 (12:23 -0400)]
Split ranger timestamp into 2 values.
Ranger's cache currently uses a timestamp to determine if a value is out
of date and needs recalculating. This patch splits the timestmap into
2 timestamps:
- one for when the value was stored last, and
- one for when the vlaue was last calculated.
This allows us to differentiate when a value is recalculated and does not
change from one which did change the resulting value.
PR tree-optimization/125758
gcc/
* gimple-range-cache.cc (struct time_stamp): New.
(set_timestamp): Deleted.
(set_timestamp_stored): New.
(set_timestamp_calc): New.
(set_always_current): Remove a parameter.
(temporal_value): Remove.
(temporal_value_stored): New.,
(temporal_value_calc): New.
(m_timestamp): Change to vector of struct time_stamp.
(temporal_cache::temporal_cache): Adjust.
(temporal_cache::current_p): Use both timestamps.
(temporal_cache::set_always_current): 0 means always current.
(temporal_cache::always_current_p): Check for 0.
(ranger_cache::get_global_range): adjust params.
(ranger_cache::update_consumers): Set stored timestamp.
(ranger_cache::set_global_range): Use new timestamps.
Philipp Tomsich [Fri, 3 Jul 2026 18:16:38 +0000 (20:16 +0200)]
tree-optimization/124545 - fix pr124545-2.c on ilp32 targets
The uns_carry() helper used "unsigned int" (32-bit) as the narrow type
and "unsigned long" as the wide type.
Switch to __UINT32_TYPE__ / __UINT64_TYPE__ throughout so that the
narrow-vs-wide test is target-independent.
PR tree-optimization/124545
gcc/testsuite/ChangeLog:
* gcc.dg/pr124545-2.c: Use __UINT32_TYPE__ / __UINT64_TYPE__
instead of unsigned int/long/long long so the runtime check
works on ILP32 targets.
Harald Anlauf [Mon, 6 Jul 2026 18:50:18 +0000 (20:50 +0200)]
Fortran: degree trigonometric functions and procedure pointers [PR121366]
While libgfortran already provides an implementation of the degree
trigonometric functions and their inverses with argument passed by value,
some situations (e.g. when used as procedure pointer target) need the
variant with Fortran calling conventions where the argument is passed by
reference. Provide the appropriate specific wrappers.
PR fortran/121366
gcc/fortran/ChangeLog:
* intrinsic.texi: Remove documentation of GNU intrinsic extensions
(CCOSD,ZCOSD,CDCOSD) that were never implemented.
* iresolve.cc (gfc_resolve_trig): Fix resolution of degree
trigonometric functions and generate references to the proper
library functions.
(gfc_resolve_trig2): Likewise.
* trans-decl.cc (gfc_get_extern_function_decl): Ensure that isym
is set when resolving intrinsic procedures.
libgfortran/ChangeLog:
* Makefile.am: Add dependency on wrappers to degree trigonometric
functions.
* Makefile.in: Regenerate.
* gfortran.map: Add references to new wrapper functions.
* intrinsics/trigd_specific.F90: New file.
James K. Lowden [Sun, 5 Jul 2026 18:32:08 +0000 (14:32 -0400)]
cobol: Correct "included from" location.
When an error occurred in a copybook, the diagnostic reported the
location of the COPY directive incorrectly. It now reports the
line of the directive.
The symbol table was recording paragraph/section relationships
incorrectly, which was only a problem if the last section PERFORMed.
Corrected.
test_half_sign_needed is a negative test expecting a sign-extending
halfword load (lh). With *p >> 8 on a 16-bit short only the high byte
is needed, so the compiler emits a sign-extending byte load (lb) and the
lh match fails. Use *p >> 4 so the full halfword load is required.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/ext-dce-4.c (test_half_sign_needed): Shift
by 4 instead of 8 to keep the lh load.
Jim Lin [Mon, 6 Jul 2026 15:37:25 +0000 (09:37 -0600)]
[PATCH] RISC-V: Skip shift-shift-7.c under -Og
At -Og the a << 1 is kept as a separate slliw instead of being folded
into the zero_extendsidi2_shifted sequence, so the "slli" regex matches
both slliw and slli and the scan-assembler-times "slli" 1 check fails.
Skip the test under -Og.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/shift-shift-7.c: Skip under -Og.
Marek Polacek [Fri, 26 Jun 2026 15:32:47 +0000 (11:32 -0400)]
c++/reflection: check type traits preconditions [PR125901]
This PR laments that our meta::is_trivially_copyable_type gives the wrong
result when its argument is a reflection of an uninstantiated template,
because its TYPE_HAS_* flags haven't been properly set. They are set in
finish_struct_1, called while instantiating the template.
This led to a much broader problem: we're not checking Preconditions in
[meta.unary.prop] and Comments in [meta.rel]. Jason pointed out to me
that check_trait_type and its KIND parameter already does this kind of
checking; our Reflection code just wasn't using it fully. With this patch
we give an error when finish_trait_expr returns an error node.
finish_trait_expr and check_trait_type need a complain parameter. Many
metafuncions weren't using the finish_trait_expr mechanism as they
should. The rest of the patch is adding the extra arguments.
I found PR126073, XFAILd for now.
PR c++/125901
gcc/cp/ChangeLog:
* cp-tree.h (finish_trait_expr): Adjust declaration.
* reflect.cc (eval_constant_of): Adjust the call to
eval_is_array_type.
(eval_reflect_object): Adjust the call to eval_is_object_type.
(eval_type_trait): Emit a diagnostic when finish_trait_expr
returns error_mark_node and set *non_constant_p. Adjust the
call to eval_type_trait.
(eval_is_array_type): Adjust the call to eval_type_trait.
(eval_is_pointer_type): Likewise.
(eval_is_member_object_pointer_type): Likewise.
(eval_is_member_function_pointer_type): Likewise.
(eval_is_enum_type): Likewise.
(eval_is_union_type): Likewise.
(eval_is_class_type): Likewise.
(eval_is_reference_type): Likewise.
(eval_is_member_pointer_type): Likewise.
(eval_is_object_type): Likewise.
(eval_is_trivially_copyable_type): Use eval_type_trait.
(eval_is_standard_layout_type): Likewise.
(eval_is_empty_type): Adjust the call to eval_type_trait.
(eval_is_polymorphic_type): Likewise.
(eval_is_abstract_type): Use eval_type_trait.
(eval_is_final_type): Adjust the call to eval_type_trait.
(eval_is_aggregate_type): Use eval_type_trait.
(eval_is_structural_type): Adjust the call to eval_type_trait.
(eval_is_bounded_array_type): Likewise.
(eval_is_constructible_type): Use eval_type_trait.
(eval_is_default_constructible_type): Likewise.
(eval_is_copy_constructible_type): Likewise.
(eval_is_move_constructible_type): Likewise.
(eval_is_assignable_type): Adjust the call to eval_type_trait.
(eval_is_copy_assignable_type): Use eval_type_trait.
(eval_is_move_assignable_type): Use eval_type_trait.
(eval_is_destructible_type): Adjust the call to eval_type_trait.
(eval_is_trivially_constructible_type): Use eval_type_trait.
(eval_is_trivially_default_constructible_type): Likewise.
(eval_is_trivially_copy_constructible_type): Likewise.
(eval_is_trivially_move_constructible_type): Likewise.
(eval_is_trivially_assignable_type): Adjust the call to
eval_type_trait.
(eval_is_trivially_copy_assignable_type): Use eval_type_trait.
(eval_is_trivially_move_assignable_type): Likewise.
(eval_is_trivially_destructible_type): Adjust the call to
eval_type_trait.
(eval_is_nothrow_constructible_type): Use eval_type_trait.
(eval_is_nothrow_default_constructible_type): Likewise.
(eval_is_nothrow_copy_constructible_type): Likewise.
(eval_is_nothrow_move_constructible_type): Likewise.
(eval_is_nothrow_assignable_type): Adjust the call to
eval_type_trait.
(eval_is_nothrow_copy_assignable_type): Use eval_type_trait.
(eval_is_nothrow_move_assignable_type): Likewise.
(eval_is_nothrow_destructible_type): Adjust the call to
eval_type_trait.
(eval_is_implicit_lifetime_type): Use eval_type_trait.
(eval_has_virtual_destructor): Likewise.
(eval_has_unique_object_representations): Likewise.
(eval_reference_constructs_from_temporary): Adjust the call to
eval_type_trait.
(eval_reference_converts_from_temporary): Likewise.
(eval_extent): Adjust the call to eval_is_bounded_array_type.
Check != boolean_true_node rather than == boolean_false_node when
checking eval_is_bounded_array_type.
(eval_is_same_type): Adjust the call to eval_type_trait.
(eval_is_base_of_type): Likewise.
(eval_is_virtual_base_of_type): Likewise.
(eval_is_convertible_type): Likewise.
(eval_is_nothrow_convertible_type): Likewise.
(eval_is_layout_compatible_type): Likewise.
(eval_is_pointer_interconvertible_base_of_type): Likewise.
(eval_is_invocable_type): Use eval_type_trait.
(eval_is_nothrow_invocable_type): Likewise.
(eval_data_member_spec): Adjust the calls to eval_is_array_type
and eval_is_object_type. Check != boolean_true_node rather than
== boolean_false_node when checking eval_is_object_type.
(eval_extract): Adjust the call to eval_is_reference_type.
(process_metafunction): Adjust the calls to various
metafunctions.
* semantics.cc (check_trait_type): Remove a default argument.
Add a complain parameter. If not emitting error messages, always
return false for incomplete types.
(finish_trait_expr): Add a complain parameter. Use it. Call
complete_type_or_maybe_complain instead of
complete_type_or_else.
gcc/testsuite/ChangeLog:
* g++.dg/reflect/type_trait16.C: New test.
* g++.dg/reflect/type_trait17.C: New test.
* g++.dg/reflect/type_trait18.C: New test.
Jason Merrill [Wed, 1 Jul 2026 15:49:39 +0000 (11:49 -0400)]
c++: naming typedef and incomplete class [PR126031]
We can't look at the bases and members of a forward-declared nested class,
and such a forward declaration can't contain problematic constructs, so
treat it as OK.
Jim Lin [Mon, 6 Jul 2026 14:59:30 +0000 (08:59 -0600)]
[PATCH] RISC-V: Skip zbb-min-max-05.c under -funroll-loops
With -funroll-loops the loop body is duplicated, emitting more than one
minu and breaking the scan-assembler-times {\mminu} 1 expectation. Skip
the test when -funroll-loops is present, matching zbb-min-max-04.c.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/zbb-min-max-05.c: Skip under -funroll-loops.
Mark Zhuang [Mon, 6 Jul 2026 14:41:11 +0000 (08:41 -0600)]
[PATCH] RISC-V: Update spacemit-x60 to use rva22u64 profile
From: Mark Zhuang <mark.zhuang@spacemit.com>
Replace the hand-written base with rva22u64 profile shorthand,
aligning with RVA22 standard and X60 hardware capabilities.
This also adds previously unlisted extensions.
gcc/ChangeLog:
* config/riscv/riscv-cores.def (spacemit-x60): Use rva22u64
profile shorthand, add missing entries.
gcc/testsuite/
* gcc.target/riscv/mcpu-spacemit-x60.c: New test.
Andrew Stubbs [Fri, 19 Jun 2026 15:35:04 +0000 (15:35 +0000)]
amdgcn: Add vec_set*ti instructions
The TImode vector vec_set instructions were missing, leading to an ICE
compiling testcase gcc.dg/pr78526.c (although it only shows with other patches
not yet committed).
gcc/ChangeLog:
* config/gcn/gcn-valu.md (*vec_set<mode>): Ad TImode instruction.
Kyrylo Tkachov [Tue, 30 Jun 2026 12:04:02 +0000 (14:04 +0200)]
Remove the path-splitting pass and deprecate -fsplit-paths [PR120892]
pass_split_paths duplicates the join block of an IF-THEN-ELSE that feeds a
loop latch, splitting the two paths to the backedge. It runs only at -O3.
In practice it interacts badly with later optimizations: it duplicates the
loop body before loads have been commoned and before if-conversion runs, so
it can block both loop unrolling (PR120892) and if-conversion of the
duplicated diamond, while its own heuristic already declines about half of
all candidate blocks, most often to avoid spoiling if-conversion.
Remove the pass and deprecate the -fsplit-paths option. The option is kept
accepted for backward compatibility via the Ignore flag and now does nothing,
matching how other optimization options have been retired (for example
-ftree-lrs). param_max_jump_thread_duplication_stmts is retained as it is
shared with the jump-threading passes.
Statistics from the pass on SPEC CPU 2026 (intrate + fprate, counted from the
split-paths dump):
The pass splits about half of the blocks it considers and declines the rest,
most often to avoid spoiling if-conversion. The duplication grows .text by
0.32% at -O3 and 0.24% at -O3 -flto=auto.
Andrea and Jeff indicated in PR120892 that removing -fsplit-paths may be
the way to go there.
-fsplit-paths also complicates the control-flow and defeats the
load-commoning necessary to get good if-conversion of the hot loop from
Snappy from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125557#c13 .
Bootstrapped and tested on aarch64-none-linux-gnu and x86_64-linux.
gcc/ChangeLog:
PR tree-optimization/120892
* gimple-ssa-split-paths.cc: Remove.
* passes.def (pass_split_paths): Remove.
* tree-pass.h (make_pass_split_paths): Remove.
* Makefile.in (OBJS): Remove gimple-ssa-split-paths.o.
* timevar.def (TV_SPLIT_PATHS): Remove.
* opts.cc (default_options_table): Remove the OPT_LEVELS_3_PLUS entry
for OPT_fsplit_paths.
* common.opt (fsplit-paths): Make it a deprecated no-op using Ignore.
* doc/invoke.texi (-fsplit-paths): Document as deprecated and remove it
from the option summary and the -O3 list.
H.J. Lu [Tue, 7 Apr 2026 15:16:38 +0000 (23:16 +0800)]
x86: Rewrite ix86_find_max_used_stack_alignment
Revert changes in ix86_find_max_used_stack_alignment
7b39d7b3b84 Correct x86: Call ix86_access_stack_p only for larger alignment c8a84242e4b Update x86: Call ix86_access_stack_p only for larger alignment f511bf93f94 x86: Call ix86_access_stack_p only for larger alignment a7cce1afee8 x86: Call ix86_access_stack_p only with symbolic constant load b54533a2863 x86: Update stack alignment only if stack is used b9ea3b2ef98 x86: Properly find the maximum stack slot alignment
Rewrite ix86_find_max_used_stack_alignment based on RTL points-to info
with find_base_term and static_reg_base_value. If RTL points-to info
isn't available,
1. Use ix86_decompose_address to check for symbolic displacement.
2. Check MEM_EXPR for incoming parameter reference and non-local reference.
Update the maximum stack slot alignment from memory alignment only if its
base may point to stack or frame pointers.
The compile times of PR target/124165 and PR target/124684 test are
unchanged.
PR target/109780
PR target/109093
PR target/123210
PR target/124098
PR target/124165
PR target/124684
PR target/124759
PR target/124789
* alias.cc (static_reg_base_value): Moved to rtl.h.
(find_base_term): Remove static.
* alias.h (find_base_term): New prototype.
* function.cc (thread_prologue_and_epilogue_insns): Call
init_alias_analysis and end_alias_analysis.
* rtl.h (static_reg_base_value): Moved from alias.cc.
* config/i386/i386.cc (stack_access_data): Removed.
(ix86_find_all_reg_uses_1): Likewise.
(ix86_find_all_reg_uses): Likewise.
(ix86_access_stack_p): Likewise.
(ix86_need_alignment_p_2): Likewise.
(ix86_need_alignment_p_1): Likewise.
(ix86_need_alignment_p): Likewise.
(ix86_update_stack_alignment_2): New function.
(ix86_update_stack_alignment_1): Likewise.
(ix86_update_stack_alignment): Rewrite.
(ix86_find_max_used_stack_alignment): If check_stack_slot is
true, call ix86_update_stack_alignment on each INSN.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Co-Authored-By: Richard Biener <rguenther@suse.de>
Thomas Schwinge [Sat, 4 Jul 2026 10:06:41 +0000 (10:06 +0000)]
libstdc++: Avoid '-Wtype-limits' warnings in 'libstdc++-v3/config/locale/generic/ctype_members.cc'
In a GCC/AIX build I ran into:
ctype_members.cc: In member function 'virtual char std::ctype<wchar_t>::do_narrow(wchar_t, char) const':
ctype_members.cc:212:14: error: comparison is always true due to limited range of data type [-Werror=type-limits]
212 | if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
| ~~~~~^~~~
ctype_members.cc: In member function 'virtual const wchar_t* std::ctype<wchar_t>::do_narrow(const wchar_t*, const wchar_t*, char, char*) const':
ctype_members.cc:226:21: error: comparison is always true due to limited range of data type [-Werror=type-limits]
226 | if (*__lo >= 0 && *__lo < 128)
| ~~~~~~^~~~
cc1plus: all warnings being treated as errors
make[5]: *** [Makefile:685: ctype_members.lo] Error 1
make[5]: Target 'all' not remade because of errors.
make[5]: Leaving directory '[...]/build-gcc/powerpc-ibm-aix7.3.1.0/libstdc++-v3/src/c++11'
That's '[...]/ctype_members.cc' ->
'[...]/source-gcc/libstdc++-v3/config/locale/generic/ctype_members.cc'.
Apply to that file the very same patch as had been applied to
'libstdc++-v3/config/locale/gnu/ctype_members.cc' in
commit 975025de350bb8cc264fef0a5f88f71abe5b3791
"libstdc++: Avoid -Wtype-limits warnings in locale/gnu/ctype_members.cc".
libstdc++-v3/
* config/locale/generic/ctype_members.cc (use_table): New function.
(ctype<wchar_t>::do_narrow): Use use_table.
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
i386: Enable 512-bit byte dot-product only under AVX512BW [PR126098]
The byte sdot_prod/udot_prod expanders used the VI1_AVX512VNNIBW
iterator, which enabled V64QI under AVX512BW || AVX512VNNI. But VNNI
has no same-sign byte instruction (VPDPBUSD is mixed-sign, i.e. usdot),
so the same-sign byte case always emulates via vec_unpacks/vec_unpacku,
and for V64QI that widening is vpmov[sz]xbw, which needs AVX512BW. With
-mavx512vnni alone the optab was offered but couldn't be emulated:
(set (reg:V32HI) (sign_extend:V32HI (reg:V32QI)))
fails to match, ICEing in extract_insn during vregs.
Use the VI1_AVX512 iterator instead (V64QI under AVX512BW), matching the
sibling usdot_prod, and drop VI1_AVX512VNNIBW. The word sdot_prod uses a
separate iterator (VI2_AVX512VNNIBW) and is left unchanged: its V32HI VNNI
path is vpdpwssd on the 16-bit inputs directly, so no widening is needed.
gcc/ChangeLog:
PR target/126098
* config/i386/sse.md (VI1_AVX512VNNIBW): Remove.
(sdot_prod<ssedvecmodelower><mode>): Use VI1_AVX512 instead of
VI1_AVX512VNNIBW so V64QI is enabled only under AVX512BW.
(udot_prod<ssedvecmodelower><mode>): Likewise.
gcc/testsuite/ChangeLog:
PR target/126098
* gcc.target/i386/pr126098.c: New test.
Roger Sayle [Sun, 5 Jul 2026 20:19:17 +0000 (21:19 +0100)]
aarch64: [PR126094] Update aarch64_cmtst* patterns for new simplifications.
The recent patch to simplify/canonicalize (not (neg (eq x y))) as
(neg (ne x y)) [when the relevant STORE_FLAG_VALUE is 1] causes
aarch64's aarch64_cmtst* patterns to fail as they were expecting
the old canonical RTL. This patch adds the new canonical forms
to aarch64-simd.md which corrects the testsuite failure of
gcc.target/aarch64/mvn-cmeq0-1.c.
Sorry for any inconvenience.
2026-07-05 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR target/126094
* config/aarch64/aarch64-simd.md (aarch64_cmtst<mode><vczle><vczbe>):
Update pattern to match recent RTL simplification.
(*aarch64_cmtst<mode><vczle><vczbe>): Preserve the original.
(*aarch64_cmtst_same_<mode><vczle><vczbe>): Additional variant.
Jakub Jelinek [Sun, 5 Jul 2026 14:47:47 +0000 (16:47 +0200)]
testsuite: Add C++ testcase for the recent PTA bug
On Wed, Jul 01, 2026 at 09:47:46AM +0200, Eric Botcazou wrote:
> this is a regression present on mainline, 16, 15 and 14 branches introduced by
> the fix for PR tree-optimization/112653 (PTA and return). What happens is
> that DSE incorrectly eliminates a call to __builtin_memcpy, whose destination
> is obtained from (an equivalent of) malloc and is ultimately returned from the
> function. But this happens only when the dynamic allocation is conditional.
For us Ada illiterate, here is a C++ testcase which got fixed by this too.
Objective-C metadata communicates the properties of a compiled module
to the runtime (for example the structure of classes).
These data are compile-time literals, and (from the perspective of the
compiler) read-only. However, they are not compile-time constants, and
may not be placed into read-only memory - since the runtime will update
them as needed.
They must be preserved even if (at LTO-time) they might appear to be
unused - for the same reason, the runtime does use them.
Throughout the implementation these are represented by CONSTRUCTORS
and the problem reported was that these were lacking suitable indices
(which might be a numerical constant in the case of arrays, or a ref
to a structure member in the case of structure intializer). Further
the initializers should be typed appropriately.
We also take this opportunity to identify that we are building
metdata objects by renaming the internal APIs accordingly.
While this change is relatively large, it is a repetitive one - add the
indices and type information (and to use the renamed APIs for this).
PR objc/124260
gcc/objc/ChangeLog:
* objc-act.cc (objc_build_constructor): Check sanity of arguments.
Remove special-casing for Objective-C++.
* objc-gnu-runtime-abi-01.cc (build_selector_table_decl,
gnu_runtime_abi_01_class_decl,gnu_runtime_abi_01_metaclass_decl,
gnu_runtime_abi_01_category_decl, gnu_runtime_abi_01_protocol_decl,
gnu_runtime_abi_01_string_decl,
gnu_runtime_abi_01_build_typed_selector_reference,
gnu_runtime_abi_01_get_protocol_reference,
gnu_runtime_abi_01_build_const_string_constructor,
generate_classref_translation_entry, handle_impent,
build_protocol_initializer, generate_protocol_list,
generate_v1_meth_descriptor_table, generate_protocols,
generate_dispatch_table, build_category_initializer,generate_category,
build_shared_structure_initializer, generate_ivars_list,
generate_class_structures, handle_class_ref,
build_gnu_selector_translation_table,generate_static_references,
init_def_list, init_objc_symtab, generate_objc_symtab_decl): Use
revised names for meta-data decl start/finish. Add integer indicies
to array and field ids to aggregate constructors.
* objc-next-runtime-abi-01.cc (next_runtime_abi_01_class_decl,
next_runtime_abi_01_metaclass_decl, next_runtime_abi_01_category_decl,
next_runtime_abi_01_protocol_decl, next_runtime_abi_01_string_decl,
build_class_reference_decl, build_selector_reference_decl,
build_objc_method_call, next_runtime_abi_01_get_protocol_reference,
next_runtime_abi_01_build_const_string_constructor,
generate_v1_meth_descriptor_table, generate_v1_objc_protocol_extension,
build_v1_property_table_initializer, generate_v1_property_table,
generate_v1_protocol_list, build_v1_protocol_initializer,
generate_v1_protocols, generate_dispatch_table,
build_v1_category_initializer, generate_v1_category,
generate_objc_class_ext, build_v1_shared_structure_initializer,
generate_ivars_list, generate_v1_class_structs, init_def_list,
init_objc_symtab, generate_objc_symtab_decl,
generate_classref_translation_entry,
next_sjlj_build_try_catch_finally): Likewise.
* objc-next-runtime-abi-02.cc (create_extern_decl) Renamed to
create_extern_meta. (create_hidden_decl): Renamed to create_hidden_meta.
(create_global_decl): Renamed to create_global_meta.
(next_runtime_02_initialize, next_runtime_abi_02_class_decl,
next_runtime_abi_02_metaclass_decl, next_runtime_abi_02_category_decl,
next_runtime_abi_02_protocol_decl, next_runtime_abi_02_string_decl,
build_v2_class_reference_decl, build_selector_reference_decl,
build_v2_message_reference_decl, build_v2_protocollist_ref_decl,
objc_v2_build_ivar_ref, build_v2_superclass_ref_decl,
next_runtime_abi_02_setup_const_string_class_decl,
next_runtime_abi_02_build_const_string_constructor,
build_v2_message_ref_translation_table, build_v2_classrefs_table,
build_v2_super_classrefs_table, build_v2_address_table,
build_v2_protocol_list_translation_table,
build_v2_protocol_list_address_table, generate_v2_protocol_list,
build_v2_descriptor_table_initializer,
generate_v2_meth_descriptor_table, generate_v2_meth_type_list,
build_v2_property_table_initializer, generate_v2_property_table,
build_v2_protocol_initializer, generate_v2_protocols,
generate_v2_dispatch_table, build_v2_category_initializer,
generate_v2_category, ivar_offset_ref, build_v2_ivar_list_initializer,
generate_v2_ivars_list, build_v2_class_t_initializer,
build_v2_class_ro_t_initializer, generate_v2_class_structs,
build_v2_ivar_offset_ref_table, objc_generate_v2_next_metadata,
objc2_build_ehtype_initializer, build_ehtype,
build_v2_eh_catch_objects, next_runtime_02_eh_type):Use revised
names for meta-data decl start/finish. Add integer indicies
to array and field ids to aggregate constructors.
* objc-runtime-shared-support.cc (build_sized_array_type): Update to
use newer APIs.
(start_var_decl): Renamed to start_meta_decl. Updated to handle
constructors that have indices and are typed.
(finish_var_decl): Renamed to finish_meta_decl. Updated to handle
constructors that have indices and are typed.
(build_method_list_template, build_descriptor_table_initializer,
build_dispatch_table_initializer, init_module_descriptor,
build_module_descriptor, build_ivar_list_initializer,
build_next_selector_translation_table,
generate_strings): Use revised names for meta-data decl start/finish.
Add integer indicies to array and field ids to aggregate constructors.
* objc-runtime-shared-support.h (start_var_decl): Renamed to
start_meta_decl.
(finish_var_decl): Renamed to finish_meta_decl.
(first_type_field, next_type_field): New.
gcc/objcp/ChangeLog:
* objcp-decl.h (finish_decl): Update to set the flag indicating
that the constructor is a constant init.
a68: avoid non-unique test names in the Algol 68 testsuite
The contrib/compare_tests script was reporting a few duplicated test
names in the Algol 68 testsuite. These were all genuine mistakes in
the test cases.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/testsuite/ChangeLog
* algol68/compile/module-extracts-1.a68: Fix expected regexp for
priority extract.
* algol68/compile/module-pub-mangling-7.a68: Fix expected regexp
for mangled operator name.
* algol68/compile/module-pub-mangling-9.a68: Likewise.
Hardcode Solaris v2 mapfile syntax with Solaris ld
GCC uses two linker mapfiles for Solaris ld: clearcap.map and
libgcc-unwind.map. Currently, both the original v1 mapfile syntax and
the new v2 one are supported, distinguished with configure checks.
However, the v2 mapfile syntax was already introduced in Solaris 11.0,
so with only Solaris 11.4 supported the checks are no longer necessary.
Besides, when doing non-bootstrap builds where the build compiler's
configured linker and the stage1 compiler differ (ld -> gld), the build
compiler was probed for mapfile syntax support, which breaks the stage1
compiler.
Now, the mapfiles are used unconditionally if the freshly built compiler
uses Solaris ld.
Bootstrapped without regressions on i386-pc-solaris2.11 and
sparc-sun-solaris2.11 with ld and gld, and x86_64-pc-linux-gnu.
a68: support for decimal radix in bits denotations
Values of mode LONGSETY bits are often used in order to convey
unsigned quantities which would require a different precision (number
of bits) if they were conveyed in values of mode LONGSETY int. The
need to do so arises particularly in transput in and in FFI. In these
cases, it is useful to be able to specify values in decimal.
This commit adds support for radix 10r in bits denotations,
implementing the GNU extension GNU68-2026-003-decimal-radices, and
also adds a compile-time diagnostic that complains about invalid
radices in bits denotations.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog
* ga68.vw: Add syntax for the GNU68-2026-003-decimal-radices
language extension.
* a68-parser-scanner.cc (get_next_token): Recognize decimal bits
denotations.
(get_next_token): Emit an error if an invalid radix is found in a
bits denotation.
For an fp-constant loaded from the constant pool, there is only one
movsf_ie alternative with the multi-class constraint "fy".
Change the FPUL alternative to '*y' so that IRA costs it as FP_REGS.
LRA still accepts the FPUL variant when it is really needed but treats
it as more expensive, which discourages FPUL usage for regular fp-regs.
gcc/ChangeLog:
PR target/116709
* config/sh/sh.md (movsf_ie): Mark constant-pool load FPUL
alternative with '*'.
r15-3802-gbdf41d627c13bc added a dependency on md-unwind-def.h to
unwind-dw2.h, which is included in unwind-dw2.c. However the pre-
requisites in t-darwin-ehs were not updated. Unfortunately, for
most normal builds (j >= 2) this gets hidden by satisfaction of
the dependency via an alterate path.
This fixes non-parallel builds.
PR libgcc/123976
libgcc/ChangeLog:
* config/t-darwin-ehs: Add md-unwind-def.h as a
pre-requisite.
Thomas Koenig [Sat, 4 Jul 2026 17:03:26 +0000 (19:03 +0200)]
Fix two issues with unused/unset variable warnings.
This patch fixes an ICE and adds correct diagnostics for reading/writing
variables via namelist, plus sets error variables for STOP as used
so incorrect warnings are avoided.
gcc/fortran/ChangeLog:
PR fortran/126058
PR fortran/126090
* gfortran.h (gfc_dt): Add member nml_where.
* io.cc (match_dt_element): Set nml_where.
(gfc_resolve_dt): Mark variable in namelist to be read with
correct locus and VALUE_READ. Mark expression in write namelist as
used.
(match_io): Set nml_where for data transfer.
* resolve.cc: Mark code->expr1 as used for PAUSE, STOP and ERROR
STOP.
gcc/testsuite/ChangeLog:
PR fortran/126058
PR fortran/126090
* gfortran.dg/warn_undefined_vars_5.f90: New test.
* gfortran.dg/warn_undefined_vars_6.f90: New test.
Pan Li [Tue, 30 Jun 2026 06:25:32 +0000 (14:25 +0800)]
RISC-V: Add testcase for unsigned scalar SAT_MUL form 19
The form 19 of unsigned scalar SAT_MUL has supported from
the previous change. Thus, add the test cases to make sure
it works well
gcc/testsuite/ChangeLog:
* gcc.target/riscv/sat/sat_arith.h: Add test helper macros.
* gcc.target/riscv/sat/sat_u_mul-20-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-20-u16-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-20-u16-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-20-u16-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-20-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-20-u32-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-20-u32-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-20-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-20-u8-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-20-u8-from-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-20-u8-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-20-u8-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-20-u8-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-20-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-20-u16-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-20-u16-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-20-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-20-u32-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-20-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-20-u8-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-20-u8-from-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-20-u8-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-20-u8-from-u64.c: New test.
Pan Li [Tue, 30 Jun 2026 06:21:58 +0000 (14:21 +0800)]
RISC-V: Add testcase for unsigned scalar SAT_MUL form 18
The form 18 of unsigned scalar SAT_MUL has supported from
the previous change. Thus, add the test cases to make sure
it works well.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/sat/sat_arith.h: Add test helper macros.
* gcc.target/riscv/sat/sat_u_mul-19-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-19-u16-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-19-u16-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-19-u16-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-19-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-19-u32-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-19-u32-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-19-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-19-u8-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-19-u8-from-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-19-u8-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-19-u8-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-19-u8-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-19-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-19-u16-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-19-u16-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-19-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-19-u32-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-19-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-19-u8-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-19-u8-from-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-19-u8-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-19-u8-from-u64.c: New test.
Pan Li [Tue, 30 Jun 2026 06:18:31 +0000 (14:18 +0800)]
RISC-V: Add testcase for unsigned scalar SAT_MUL form 17
The form 17 of unsigned scalar SAT_MUL has supported from
the previous change. Thus, add the test cases to make sure
it works well
gcc/testsuite/ChangeLog:
* gcc.target/riscv/sat/sat_arith.h: Add test helper macros.
* gcc.target/riscv/sat/sat_u_mul-18-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-18-u16-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-18-u16-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-18-u16-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-18-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-18-u32-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-18-u32-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-18-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-18-u8-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-18-u8-from-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-18-u8-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-18-u8-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-18-u8-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-18-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-18-u16-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-18-u16-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-18-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-18-u32-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-18-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-18-u8-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-18-u8-from-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-18-u8-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-18-u8-from-u64.c: New test.
Pan Li [Tue, 30 Jun 2026 06:01:18 +0000 (14:01 +0800)]
RISC-V: Add testcase for unsigned scalar SAT_MUL form 16
The form 16 of unsigned scalar SAT_MUL has supported from
the previous change. Thus, add the test cases to make sure
it works well.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/sat/sat_arith.h: Add test helper macros.
* gcc.target/riscv/sat/sat_u_mul-17-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-17-u16-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-17-u16-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-17-u16-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-17-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-17-u32-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-17-u32-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-17-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-17-u8-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-17-u8-from-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-17-u8-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-17-u8-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-17-u8-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-17-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-17-u16-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-17-u16-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-17-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-17-u32-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-17-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-17-u8-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-17-u8-from-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-17-u8-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-17-u8-from-u64.c: New test.
Andrew Pinski [Sat, 4 Jul 2026 02:59:19 +0000 (19:59 -0700)]
testsuite: Fix pr94589-5a.c
I did test this testcase but I must have missed it failing somehow.
Anyways the problem is the scan-tree-dump is missing checking for u< and u>
which can show up in some cases.
Pushed as obvious after a quick test to make sure there is no failure any more.
gcc/testsuite/ChangeLog:
* gcc.dg/pr94589-5a.c: Allow for `u<` and `u>` in the scan too.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Philipp Tomsich [Fri, 8 May 2026 17:24:58 +0000 (19:24 +0200)]
tree-optimization/122569 - recognize CLZ via isolated MSB DeBruijn lookup
Recognize a CLZ idiom where the OR-cascade is followed by
(value - (value >> 1)) to isolate the MSB as a power of two (2^k), then
a DeBruijn multiply-and-shift maps 2^k back to k:
value |= value >> 1;
...
value |= value >> 32;
result = table[((value - (value >> 1)) * MAGIC) >> 58];
After the cascade value is 2^(k+1) - 1, so (value - (value >> 1)) is 2^k
and the multiply-and-shift is a CTZ-style DeBruijn lookup whose table
satisfies table[(magic << k) >> shift] == k.
Add match.pd pattern clz_msb_iso_table_index on top of the
msb_or_cascade_64 helper, so it only spells out the (s - (s >> 1))
isolation and the DeBruijn shape. simplify_count_zeroes validates the
table with the existing CTZ checkfn (the direct-form check) but emits
IFN_CLZ; both forms store MSB positions, so the CLZ path including
zero_val pre-compensation is unchanged.
Relax the element-type check from "precision <= 32" to "integral and
precision <= 64" so tables declared as unsigned long (64-bit on LP64)
are accepted; the values are bit positions and fit any integer type.
Only a 64-bit variant is added; all known uses (Stockfish, zstd,
cpython, the PR122569 comment 3 reproducer) are 64-bit.
gcc/ChangeLog:
PR tree-optimization/122569
* match.pd (clz_msb_iso_table_index): New match pattern.
* tree-ssa-forwprop.cc (gimple_clz_msb_iso_table_index): Declare.
(simplify_count_zeroes): Recognize the new pattern; route its
table validation through the CTZ checkfn. Relax the element
type check to accept integer types up to 64 bits.
gcc/testsuite/ChangeLog:
PR tree-optimization/122569
* gcc.dg/tree-ssa/pr122569-3.c: New test.
Philipp Tomsich [Fri, 8 May 2026 17:22:04 +0000 (19:22 +0200)]
match.pd: factor MSB OR-cascade out of clz_table_index
Factor the 5- and 6-stage MSB OR-cascade -- which sets every bit from 0
to the input's MSB -- into two helper match patterns msb_or_cascade_32
and msb_or_cascade_64, and rewrite the 32-bit and 64-bit clz_table_index
patterns as one-liners over them. The helpers retain the
integral/unsigned/precision and shift-constant checks, so this is a
no-functional-change refactor.
It prepares a follow-up that recognises a CLZ idiom isolating the MSB
before the DeBruijn multiply, which reuses msb_or_cascade_64 directly.
gcc/ChangeLog:
* match.pd (msb_or_cascade_32, msb_or_cascade_64): New match
helpers.
(clz_table_index): Rewrite the 32-bit and 64-bit forms to use
the cascade helpers.
Andrew Pinski [Tue, 30 Jun 2026 19:13:05 +0000 (12:13 -0700)]
match: Simplify `(a CMP1 b) AND/IOR (a CMP2 b)` [PR126042]
This finishes up simplifications of most comparisons
outside of reassociation. Including but not limited to
many floating point comparisons.
Instead of redoing what is done in fold-cost.cc's combine_comparisons,
this reuses combine_comparisons to find the new CMP.
In the case of `-fno-trapping-math`, this allows to optimize `<=>`
which it was not before.
Changes since v1:
* v2: Fix some typos. Add a C testcase.
* fold-const.cc (combine_comparisons): Split into
2 versions. Also handle BIT_AND_EXPR and BIT_IOR_EXPR.
* fold-const.h (combine_comparisons): New declaration.
* match.pd (`(a CMP1 b) BITOP (a CMP2 b)`): New pattern.
gcc/testsuite/ChangeLog:
* g++.dg/opt/pr94589-5a.C: New test.
* gcc.dg/pr94589-5.c: Explictly enable -ftrapping-math.
* gcc.dg/pr94589-5a.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Jakub Jelinek [Fri, 3 Jul 2026 18:45:07 +0000 (20:45 +0200)]
c++: Fix structured binding mangling during error recovery [PR126057]
The following testcase ICEs during error recovery. We try to
mangle a structured binding base variable, but because it has
been erroneous, the mangling ICEs as it can't find the corresponding
structured bindings.
Now, we already have a hack in cp_finish_decomp when things are erroneous,
we set assembler name to <decomp> so that mangling isn't done.
But we do that only for DECL_NAMESPACE_SCOPE_P bases and
block scope static structured bindings can be mangled too,
and during instantiation, if tsubst_decomp_names fails, we don't
call cp_finish_decomp at all, so in that case we need to also
avoid the mangling of the structured binding base.
2026-07-03 Jakub Jelinek <jakub@redhat.com>
PR c++/126057
* decl.cc (cp_finish_decomp): Set assembler name to
<decomp> during error recovery whenever TREE_STATIC
rather than just DECL_NAMESPACE_SCOPE_P.
* pt.cc (tsubst_stmt): If tsubst_decomp_names fails,
set assembler name to <decomp>.
The following patch attempts to implement the C++29 P2953R5
Adding restrictions to defaulted assignment operator functions
paper.
The paper seems to be misnamed to me because it changes the validity
of defaulted constructors as well in some cases.
What the patch does is that it calls maybe_delete_defaulted_fn
also for the FUNCTION_RVALUE_QUALIFIED case for C++29, and then in
maybe_delete_defaulted_fn for C++29 errors rather than making the
function deleted in most cases, with the exception of
[dcl.fct.def.default]/(2.5) case which ought to be still deleted
rather than ill-formed (but only if that is the sole change that
is not on the whitelist of possible differences).
I've tried to include all the tests I found in the paper (referenced or
directly in it) with the exception of the https://gcc.gnu.org/PR86646
case, added some further ones and tweaked anything in the existing
test that behaves differently for -std=c++29 with the patch.
2026-07-03 Jakub Jelinek <jakub@redhat.com>
PR c++/125826
* method.cc: Implement C++29 P2953R5 - Adding restrictions to
defaulted assignment operator functions.
(maybe_delete_defaulted_fn): For C++29, error instead of
deleting always, with the exception of F1 having parmtype
const C & and F2 having implicit_parmtype C & and no other
non-permitted changes. Move checks whether defaulted fn
should be deleted or ill-formed at all from defaulted_late_check
to this function. Also error for C++29 if
FUNCTION_RVALUE_QUALIFIED.
(defaulted_late_check): Call maybe_delete_defaulted_fn
unconditionally.
* g++.dg/cpp0x/defaulted51.C: Adjust expected diagnostics
for C++29.
* g++.dg/cpp0x/defaulted55.C: Likewise.
* g++.dg/cpp0x/defaulted56.C: Likewise.
* g++.dg/cpp0x/defaulted57.C: Likewise.
* g++.dg/cpp0x/defaulted63.C: Likewise.
* g++.dg/cpp0x/defaulted64.C: Likewise.
* g++.dg/cpp0x/defaulted65.C: Likewise.
* g++.dg/cpp0x/defaulted66.C: Likewise.
* g++.dg/cpp0x/defaulted67.C: Likewise.
* g++.dg/cpp0x/defaulted68.C: Likewise.
* g++.dg/cpp1y/defaulted2.C: Likewise.
* g++.dg/cpp29/defaulted1.C: New test.
* g++.dg/cpp29/defaulted2.C: New test.
* g++.dg/cpp29/defaulted3.C: New test.
* g++.dg/cpp29/defaulted4.C: New test.
* g++.dg/cpp29/defaulted5.C: New test.
* g++.dg/cpp29/defaulted6.C: New test.
Jakub Jelinek [Fri, 3 Jul 2026 18:41:45 +0000 (20:41 +0200)]
c++: Fix up ICEs with some metafns with non-dependent args in templates [PR126036]
The following testcase ICEs, because potential_constant_expression_1 handles
some forms of CAST_EXPR, but cxx_eval_constant_expression doesn't.
Normally, if we have e.g. a non-dependent compound literal in a template,
finish_compound_literal will create a CAST_EXPR, but
fold_non_dependent_expr_template -> instantiate_non_dependent_expr_internal
will fold that away, so constexpr.cc evaluation doesn't see it.
reflect.cc calls finish_compound_literal in 3 spots, one is to create
std::array <type, 0> {}, another one is when creating the
std::meta::exception object to throw and the last one when creating
std::vector <std::meta::info> object to return from various metafns.
If that is done with processing_template_decl, finish_compound_literal
will again return a CAST_EXPR, but unlike the usual case it is during
constant evaluation and so instantiate_non_dependent_expr_internal
will not be invoked on it to clean that up.
Now, in the get_meta_exception_object case, we already have
/* Don't throw in a template. */
if (processing_template_decl)
{
*non_constant_p = true;
return NULL_TREE;
}
This patch uses the same thing (i.e. avoid folding even non-dependent
metafn calls that would need finish_compound_literal during
processing_template_decl) to fix this.
I think in both cases it is fine to defer the constant evaluation,
the return type from those metafns is not dependent (std::meta::info
in the reflect_constant_array case, std::vector <std::meta::info>
otherwise).
2026-07-03 Jakub Jelinek <jakub@redhat.com>
PR c++/126036
* reflect.cc (get_range_elts): Avoid calling finish_compound_literal
when processing_template_decl, instead set *non_constant_p and
return NULL_TREE.
(process_metafunction): Likewise.
AVR: Adding +/-1 to a lower reg doesn't need a scratch.
Adding +/-1 to a lower register can be performed by sequences like
sec
adc r14, __zero_reg__
adc r15, __zero_reg__
resp.
sec
sbc r14, __zero_reg__
sbc r15, __zero_reg__
that don't need a scratch reg. The code size is unchanged but
the register pressure goes down.
gcc/
* config/avr/avr.cc (avr_out_plus_1): Handle +/-1 on the
lower regs without needing a scratch.
* config/avr/avr.md (add<mode>3_clobber, *add<mode>3_clobber)
(add<mode>3, *add<mode>3, addpsi3, *addpsi3): Add constraint
alternative "Y01 Ym1" for +/-1 without scratch.
libstdc++: fix allocate_at_least test for small alignments [PR126072]
A test for P0401 allocate_at_least fails on target cris-elf,
which has a default allocator with alignment 4. This patch
adjusts tests to accommodate alignments down to 1, and removes
assumptions about short int.
Tested on x86 -m64 and -m32. Need assistance for cris-elf.