Sandra Loosemore [Thu, 20 Nov 2025 21:45:09 +0000 (21:45 +0000)]
OpenMP: C++ front end support for "begin declare variant"
This patch implements C++ support for the "begin declare variant"
construct. The OpenMP specification is hazy on interaction of this
feature with C++ language features. Variant functions in classes are
supported but must be defined as members in the class definition,
using an unqualified name for the base function which also must be
present in that class. Similarly variant functions in a namespace can
only be defined in that namespace using an unqualified name for a base
function already declared in that namespace. Variants for template
functions or inside template classes seem to (mostly) work.
Sandra Loosemore [Thu, 20 Nov 2025 21:45:08 +0000 (21:45 +0000)]
OpenMP: Add flag for code elision to omp_context_selector_matches.
The "begin declare variant" has different rules for determining
whether a context selector cannot match for purposes of code elision
than we normally use; it excludes the case of a constant false
"condition" selector for the "user" set.
gcc/ChangeLog
* omp-general.cc (omp_context_selector_matches): Add an optional
bool argument for the code elision case.
* omp-general.h (omp_context_selector_matches): Likewise.
Sandra Loosemore [Thu, 20 Nov 2025 21:45:08 +0000 (21:45 +0000)]
OpenMP: Support functions for nested "begin declare variant"
This patch adds functions for variant name mangling and context selector
merging that are shared by the C and C++ front ends.
The OpenMP specification says that name mangling is supposed to encode
the context selector for the variant, but also provides for no way to
reference these functions directly by name or from a different
compilation unit. It also gives no guidance on how dynamic selectors
might be encoded across compilation units.
The GCC implementation of this feature instead treats variant
functions as if they have no linkage and uses a simple counter to
generate names. The exception is variants declared in a module interface,
which are given module linkage.
Jakub Jelinek [Sat, 22 Nov 2025 11:39:09 +0000 (12:39 +0100)]
c++: Fix up [[maybe_unused]] handling on expansion stmts [PR122788]
This PR complains that [[maybe_unused]] attribute is ignored on
the range-for-declaration of expansion-statement.
We copy DECL_ATTRIBUTES and apply late attributes, but early attributes
don't have their handlers called again, so some extra flags need to be
copied as well.
This copies TREE_USED and DECL_READ_P flags.
2025-11-22 Jakub Jelinek <jakub@redhat.com>
PR c++/122788
* pt.cc (finish_expansion_stmt): Or in TREE_USED and DECL_READ_P
flags from range_decl to decl or from corresponding structured binding
to this_decl.
Jakub Jelinek [Sat, 22 Nov 2025 11:24:35 +0000 (12:24 +0100)]
c++: Readd type checks for cp_fold -ffold-simple-inlines foldings [PR122185]
In GCC15, cp_fold -ffold-simple-inlines code contained
if (INDIRECT_TYPE_P (TREE_TYPE (x))
&& INDIRECT_TYPE_P (TREE_TYPE (r)))
check around the optimization, but as std::to_underlying has been
added to the set, it got removed.
Now, the check isn't needed when using correct libstdc++-v3 headers,
because the function template types ensure the converted types are sane
(so for most of them both are some kind of REFERENCE_TYPEs, for addressof
one REFERENCE_TYPE and one POINTER_TYPE, for to_underlying one ENUMERAL_TYPE
and one INTEGRAL_TYPE_P).
But when some fuzzer or user attempts to implement one or more of those
std:: functions and does it wrong (sure, such code is invalid), we can ICE
because build_nop certainly doesn't handle all possible type conversions.
So, the following patch readds the INDIRECT_REF_P && INDIRECT_REF_P check
for everything but to_underlying, for which it checks ENUMERAL_TYPE to
INTEGRAL_TYPE_P. That way we don't ICE on bogus code.
Though, I wonder about 2 things, whether the CALL_EXPR_ARG in there
shouldn't be also guarded just in case somebody tries to compile
namespace std { int to_underlying (); }; int a = std::to_underlying ();
and also whether this to_underlying folding doesn't behave differently
from the libstdc++-v3 implementation if the enum is
enum A : bool { B, C };
I think -fno-fold-simple-inlines will compile it as != 0, while
the -ffold-simple-inlines code just as a cast. Sure, enum with underlying
bool can't contain enumerators with values other than 0 and 1, but it is
still 8-bit at least and so what happens with other values?
2025-11-22 Jakub Jelinek <jakub@redhat.com>
PR c++/122185
* cp-gimplify.cc (cp_fold) <case CALL_EXPR>: For -ffold-simple-inlines
restore check that both types are INDIRECT_TYPE_P, except for
"to_underlying" check that r has ENUMERAL_TYPE and x has
INTEGRAL_TYPE_P.
Deng Jianbo [Fri, 14 Nov 2025 02:22:10 +0000 (10:22 +0800)]
LoongArch: Optimize statement to use bstrins.{w|d}
For statement (a << imm1) | (b & imm2), in case the imm2 equals to
(1 << imm1) - 1, it can be optimized to use bstrins.{w|d} instruction.
gcc/ChangeLog:
* config/loongarch/loongarch.md
(*bstrins_w_for_ior_ashift_and_extend): New template.
(*bstrins_d_for_ior_ashift_and): New template.
* config/loongarch/predicates.md (const_uimm63_operand): New
predicate.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/bstrins-5.c: New test.
* gcc.target/loongarch/bstrins-6.c: New test.
zhaozhou [Fri, 14 Nov 2025 03:18:46 +0000 (11:18 +0800)]
LoongArch: Optimize V4SImode vec_construct for load index length of two.
Under the V4SImode, the vec_construct with the load index {0, 1, 0, 1}
use vldrepl.d, the vec_construct with the load index {0, 1, 0, 0} use
vldrepl.d and vshuf4i, reduced the usage of scalar load and vinsgr2vr.
Kees Cook [Fri, 21 Nov 2025 18:24:34 +0000 (10:24 -0800)]
aarch64: Extract aarch64_indirect_branch_asm for sibcall codegen
Extract indirect branch assembly generation into a new function
aarch64_indirect_branch_asm, paralleling the existing
aarch64_indirect_call_asm function. Replace the open-coded versions in
the sibcall patterns (*sibcall_insn and *sibcall_value_insn) so there
is a common helper for indirect branches where things like SLS mitigation
need to be handled.
gcc/ChangeLog:
* config/aarch64/aarch64-protos.h (aarch64_indirect_branch_asm):
Declare.
* config/aarch64/aarch64.cc (aarch64_indirect_branch_asm): New
function to generate indirect branch with SLS barrier.
* config/aarch64/aarch64.md (*sibcall_insn): Use
aarch64_indirect_branch_asm.
(*sibcall_value_insn): Likewise.
Daniele Sahebi [Wed, 19 Nov 2025 16:03:05 +0000 (17:03 +0100)]
c++: fix ICE with consteval functions in template decls [PR122658]
Currently, build_over_call calls build_cplus_new in template decls, generating
a TARGET_EXPR that it then passes to fold_non_dependent_expr, which ends up
calling tsubst_expr, and since tsubst_expr doesn't handle TARGET_EXPRs, it ICEs.
Since there is no way for this code path to be executed without causing an
ICE, I believe it can be removed.
PR c++/122658
gcc/cp/ChangeLog:
* call.cc (build_over_call): Don't call build_cplus_new in
template declarations.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/consteval42.C: New test.
Co-authored-by: Jakub Jelinek <jakub@redhat.com> Signed-off-by: Daniele Sahebi <daniele@mkryss.me> Reviewed-by: Marek Polacek <polacek@redhat.com> Reviewed-by: Patrick Palka <ppalka@redhat.com>
[PR118358, LRA]: Decrease pressure after issuing input reload insns
LRA can generate sequence of reload insns for one input operand using
intermediate pseudos. Register pressure when reload insn for another
input operand is placed before the sequence is more than when the
reload insn is placed after the sequence. The problem report reveals
a case when several such sequences increase the pressure for input
reload insns beyond available registers and as a consequence this
results in LRA cycling.
gcc/ChangeLog:
PR target/118358
* lra-constraints.cc (curr_insn_transform): Move insn reloading
constant into a register right before insn using it.
Jonathan Wakely [Wed, 19 Nov 2025 19:04:05 +0000 (19:04 +0000)]
libstdc++: Implement LWG 4406 and LWG 3424 for std::optional and std::expected
This adjusts the return statements of optional::value_or and
expected::value_or to not perform explicit conversions, so that the
actual conversion performed matches the requirements expressed in the
Mandates: elements (LWG 4406).
Also adjust the return types to remove cv-qualifiers (LWG 3424).
libstdc++-v3/ChangeLog:
* include/std/expected (expected::value_or): Use remove_cv_t for
the return type. Do not use static_cast for return statement.
Adjust static_assert conditions to match return statements.
* include/std/optional (optional::value_or): Likewise.
(optional<T&>::value_or): Likewise.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Yuao Ma [Sun, 2 Nov 2025 07:39:38 +0000 (15:39 +0800)]
libstdc++: Implement P3223R2 Making std::istream::ignore less surprising
libstdc++-v3/ChangeLog:
* include/std/istream (ignore): Add an overload for char.
* testsuite/27_io/basic_istream/ignore/char/93672.cc: Adjust
expected behaviour for C++26 mode.
* testsuite/27_io/basic_istream/ignore/char/4.cc: New test.
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
Jonathan Wakely [Fri, 21 Nov 2025 14:33:29 +0000 (14:33 +0000)]
libstdc++: Update some old docs about predefined feature macros
libstdc++-v3/ChangeLog:
* doc/xml/faq.xml: Refresh information on _GNU_SOURCE and
_XOPEN_SOURCE being predefined.
* doc/xml/manual/internals.xml: Remove outdated paragraph about
_POSIX_SOURCE in libstdc++ source files.
* doc/html/*: Regenerate.
Jakub Jelinek [Fri, 21 Nov 2025 15:25:58 +0000 (16:25 +0100)]
libcody: Make it buildable by C++11 to C++26
The following builds with -std=c++11 and c++14 and c++17 and c++20 and c++23
and c++26.
I see the u8 string literals are mixed e.g. with strerror, so in
-fexec-charset=IBM1047 there will still be garbage, so am not 100% sure if
the u8 literals everywhere are worth it either.
2025-11-21 Jakub Jelinek <jakub@redhat.com>
* cody.hh (S2C): For __cpp_char8_t >= 201811 use char8_t instead of
char in argument type.
(MessageBuffer::Space): Revert 2025-11-15 change.
(MessageBuffer::Append): For __cpp_char8_t >= 201811 add overload
with char8_t const * type of first argument.
(Packet::Packet): Similarly for first argument.
* client.cc (CommunicationError, Client::ProcessResponse,
Client::Connect, ConnectResponse, PathnameResponse, OKResponse,
IncludeTranslateResponse): Cast u8 string literals to (const char *)
where needed.
* server.cc (Server::ProcessRequests, ConnectRequest): Likewise.
Richard Biener [Fri, 21 Nov 2025 11:14:46 +0000 (12:14 +0100)]
Fix OMP SIMD clone mask register and query
The following removes the confusion around num_mask_args that was
added to properly "guess" the number of mask elements in a AVX512
mask that's just represented as int. The actual mistake lies in
the mixup of 'ncopies' which is used to track the number of
OMP SIMD calls to be emitted rather than the number of input
vectors. So this reverts the earlier r16-5374-g5c2fdfc24e343c,
uses the proper 'ncopies' for loop mask record/query and adjusts
the guessing of the SIMD arg mask elements.
PR tree-optimization/122762
PR tree-optimization/122736
PR tree-optimization/122790
* cgraph.h (cgraph_simd_clone_arg::linear_step): Document
use for SIMD_CLONE_ARG_TYPE_MASK.
* omp-simd-clone.cc (simd_clone_adjust_argument_types):
Record the number of mask arguments in linear_step if
mask_mode is not VOIDmode.
* tree-vect-stmts.cc (vectorizable_simd_clone_call):
Remove num_mask_args computation, use a proper ncopies
to query/register loop masks, use linear_step for the
number of mask arguments when determining the number of
mask elements in a mask argument.
Richard Biener [Fri, 21 Nov 2025 09:32:12 +0000 (10:32 +0100)]
tree-optimization/122778 - missed loop masking in OMP SIMD call handling
For AVX512 style masking we fail to apply loop masking to a conditional
OMP SIMD call.
PR tree-optimization/122778
* tree-vect-stmts.cc (vectorizable_simd_clone_call): Honor
a loop mask when passing the conditional mask with AVX512
style masking.
* gcc.dg/vect/vect-simd-clone-22.c: New testcase.
* gcc.dg/vect/vect-simd-clone-22a.c: Likewise.
Marek Polacek [Thu, 20 Nov 2025 18:57:43 +0000 (13:57 -0500)]
c++: make __reference_*_from_temporary honor access [PR120529]
This PR reports that our __reference_*_from_temporary ignore access
control. The reason is that we only check if implicit_conversion
works, but not if the conversion can actually be performed, via
convert_like.
Jakub Jelinek [Fri, 21 Nov 2025 13:17:01 +0000 (14:17 +0100)]
c++: Fix up build_data_member_initialization [PR121445]
The following testcase ICEs, because the constexpr ctor in C++14
or later doesn't contain any member initializers and so the
massage_constexpr_body -> build_constexpr_constructor_member_initializers
-> build_data_member_initialization member initialization discovery
looks at the ctor body instead. And while it has various
cases where it punts, including COMPONENT_REF with a VAR_DECL as first
operand on lhs of INIT_EXPR, here there is COMPONENT_REF with
several COMPONENT_REFs and VAR_DECL only inside the innermost.
The following patch makes sure we punt on those as well, instead of
blindly assuming it is anonymous union member initializer or asserting
it is a vtable store.
An alternative to this would be some flag on the INIT_EXPRs created
by perform_member_init and let build_data_member_initialization inspect
only INIT_EXPRs with that flag set.
2025-11-21 Jakub Jelinek <jakub@redhat.com>
PR c++/121445
* constexpr.cc (build_data_member_initialization): Just return
false if member is COMPONENT_REF of COMPONENT_REF with
VAR_P get_base_address.
PR target/122275
* config/i386/32/dfp-machine.h (DFP_GET_ROUNDMODE): Change `_frnd_orig` to
`unsigned short` for x87 control word.
(DFP_SET_ROUNDMODE): Manipulate the x87 control word as `unsigned short`,
and manipulate the MXCSR as `unsigned int`.
As mentioned in the PR, the COND_SH{L,R} internal fns are expanded without
fallback, their expansion must succeed, and furthermore they don't
differentiate between scalar and vector shift counts, so again both have
to be supported. That is the case of the {ashl,lshr,ashr}v*[hsd]i
patterns which use nonimmediate_or_const_vec_dup_operand predicate for
the shift count, so if the argument isn't const vec dup, it can be always
legitimized by loading into a vector register.
This is not the case of the QImode element conditional vector shifts,
there is no fallback for those and we emit individual element shifts
in that case when not conditional and shift count is not a constant.
So, I'm afraid we can't announce such an expander because then the
vectorizer etc. count with it being fully available.
As I've tried to show in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122598#c9
even without this pattern we can sometimes emit
vgf2p8affineqb $0, .LC0(%rip), %ymm0, %ymm0{%k1}
etc. instructions.
In the testcases, the kernels scheduled on queues 11, 12, 13, 14 have
data dependencies on, respectively, 'b', 'c', 'd', and 'e', as they
write to them.
However, they also have a data dependency on 'a' and 'N', as they read
those.
Previously, the testcases exited 'a' on queue 10 and 'N' on queue 15,
meaning that it was possible for the aforementioned kernels to execute
and to have 'a' and 'N' pulled under their feet.
This patch adds waits for each of the kernels onto queue 10 before
freeing 'a', guaranteeing that 'a' outlives the kernels, and the same on
'N'.
libgomp/ChangeLog:
* testsuite/libgomp.oacc-c-c++-common/data-2-lib.c (explanatory
header): Fix typo.
(main): Insert waits on kernels reading 'a' into queue 10 before
exiting 'a', and waits on kernels reading 'N' into queue 15
before exiting 'N'.
* testsuite/libgomp.oacc-c-c++-common/data-2.c: Ditto.
Jakub Jelinek [Fri, 21 Nov 2025 10:25:27 +0000 (11:25 +0100)]
gimplify: Fix ICE in collect_fallthrough_labels [PR122773]
In r16-4212 I had to tweak two spots in the gimplifier to ignore
gotos jumping to labels with the new VACUOUS_INIT_LABEL_P flag
(set by C++ FE when implementing goto/case interceptors with
extra .DEFERRED_INIT calls, so that jumps over vacuous initialization
are handled properly with the C++26 erroneous behavior requirements).
Except as the following testcase shows, the checks blindly assumed
that gimple_goto_dest operand is a LABEL_DECL, which is not the case
for computed jumps.
The following patch checks that gimple_goto_dest argument is a LABEL_DECL
before testing VACUOUS_INIT_LABEL_P flag on it.
2025-11-21 Jakub Jelinek <jakub@redhat.com>
PR middle-end/122773
* gimplify.cc (collect_fallthrough_labels): Check whether
gimple_goto_dest is a LABEL_DECL before testing VACUOUS_INIT_LABEL_P.
(expand_FALLTHROUGH_r): Likewise.
Loeka Rogge [Fri, 21 Nov 2025 09:45:01 +0000 (11:45 +0200)]
arc: emit clobber of CC for -mcpu=em x >> 31
Address PR target/120375
Devices without a barrel shifter end up using a sequence of
instructions. These can use the condition codes and/or loop count
register, so those need to be marked as 'clobbered'. These clobbers were
previously added only after split1, which is too late. This patch adds
these clobbers from the beginning, in the define_expand.
Previously, define_insn_and_split *<insn>si3_nobs would match any shift or
rotate instruction and would generate the necessary patterns to emulate a
barrel shifter, but it did not have any output assembly for itself.
In many cases this would create a loop with parallel clobbers. This pattern
is then matched by the <insn>si3_loop pattern.
Leading to an issue: the add.f instructions overwrites CC but beq expects
CC to contain an earlier value indicating mag == 0x7f800000.
Now, these are combined in define_insn_and_split <insn>si3_loop that is
explicitly emitted in the define_expand and already contains the clobbers.
This can then be split into another pattern or remain the loop pattern.
* config/arc/arc.md (*<insn>si3_nobs): merged with <insn>si3_loop.
(<insn>si3_loop): splits to relevant pattern or emits loop assembly.
(<insn>si3_cnt1_clobber): Removes clobber for shift or rotate by
const1.
gcc/testsuite/ChangeLog:
* gcc.target/arc/no-barrel-shifter.c: New test.
Co-authored-by: Keith Packard <keithp@keithp.com> Signed-off-by: Loeka Rogge <loeka@synopsys.com>
Bob Duff [Wed, 12 Nov 2025 19:53:17 +0000 (14:53 -0500)]
ada: Follow-on for duplicate formal iterator names
A previous fix titled "Avoid incorrect errors for duplicate formal
iterator names" caused regressions. This patch cleans it up.
In particular, the previous patch involved calling Preanalyze on
a block statement in order to get the scope created, and then
later calling Analyze on the same block statement. This caused
certain temps created inside the block statement to be
incorrectly duplicated. The fix here is to avoid setting
the Statements of the block until after it has been
preanalyzed.
gcc/ada/ChangeLog:
* exp_ch5.adb (Expand_Formal_Container_Loop):
Preanalyze block with empty statements; then set
the statements later before doing Analyze of the
block.
Eric Botcazou [Wed, 12 Nov 2025 15:13:03 +0000 (16:13 +0100)]
ada: Remove obsolete call to Establish_Transient_Scope
There is a preceding call to Establish_Transient_Scope in the procedure for
the cases where it is required, and we no longer build the aggregate on the
stack before copying it to the heap for an allocator.
gcc/ada/ChangeLog:
* exp_aggr.adb (Expand_Array_Aggregate): Remove obsolete call to
Establish_Transient_Scope for an allocator in a loop.
* exp_ch7.adb (Establish_Transient_Scope): Adjust description.
Piotr Trojanek [Wed, 5 Nov 2025 19:14:33 +0000 (20:14 +0100)]
ada: Sort cross-reference table using heap and not stack
Cross-references are used by GNATprove for code that is not in SPARK. They are
sorted using an auxiliary array. This array should be allocated on the heap and
not on stack, because it can be arbitrarily large, especially for
auto-generated code.
gcc/ada/ChangeLog:
* lib-xref.adb (Output_References): Put local array object on the heap.
Is_Redundant_Error_Message is used to filter diagnostic messages
that would appear on the same line to avoid the noise comming from
cascading error messages. However we still want to trigger an error
even if the line already had a warning or a non-serious error at the
same location so that we now that a fatal error has occured and the
compiler knows how to exit correctly in that scenario.
Eric Botcazou [Tue, 11 Nov 2025 20:12:54 +0000 (21:12 +0100)]
ada: Fix warnings given by static analyzer on Exp_Ch4
gcc/ada/ChangeLog:
* exp_ch4.adb (Expand_N_Op_Eq): Use No instead of not Present.
(Optimize_Length_Comparison): Initialize Is_Zero and Comp variables.
(Safe_In_Place_Array_Op): Do not use local variable to pass data to
nested function Is_Safe_Operand.
Javier Miranda [Tue, 11 Nov 2025 19:00:22 +0000 (19:00 +0000)]
ada: No extra formals on anonymous access types of C subprograms
Extra formals must not be added to anonymous access to subprogram
types defined in the profile of imported C subprograms.
gcc/ada/ChangeLog:
* sem_ch6.adb (Create_Extra_Formals): Do not add extra formals to
anonymous access to subprogram types defined in the profile of
subprograms that have foreign convention.
Eric Botcazou [Tue, 11 Nov 2025 09:35:54 +0000 (10:35 +0100)]
ada: Fix memory leak for unconstrained limited arrays in anonymous contexts
A change made a long time ago has introduced a leak of the secondary stack
at run time for unconstrained limited non-controlled arrays in anonymous
contexts, because of the lack of a transient scope in these contexts.
The large comment preceding the call to Establish_Transient_Scope in the
Resolve_Call procedure explains the strategy for build-in-place functions,
so the best course of action is probably to revert the commit and to fix
the original problem along the lines of the comment.
gcc/ada/ChangeLog:
* exp_ch3.adb (Expand_N_Object_Declaration): Delete ancient comment.
* exp_ch6.adb (Expand_Call_Helper): Do not establish a transient
scope for build-in-place functions in anonymous contexts here...
(Make_Build_In_Place_Call_In_Anonymous_Context): ...but here instead.
* sem_attr.adb (Resolve_Attribute) <Attribute_Range>: Remove obsolete
code dealing with transient scopes.
* sem_res.adb (Resolve_Actuals): Likewise.
(Resolve_Call): Adjust comment on the strategy for transient scopes.
Bob Duff [Mon, 10 Nov 2025 18:21:02 +0000 (13:21 -0500)]
ada: Avoid incorrect errors for duplicate formal iterator names
This patch fixes the following bug: If a type has an Iterable aspect
(as in the formal containers), and two or more cursor loops of the
form "for C in ..." occur in the same scope, and the cursor type has
discriminants without defaults, the compiler complains incorrectly
about duplicate names "Tc".
This is because the generated declaration of the C object was being
analyzed in the wrong scope. In the discriminated case, an internal
subtype name TcS is generated for each C. Errout "helpfully" removes "S"
in the error message, resulting in a complaint about "Tc". The fix is
to push the correct scope (that of the generated surrounding block
statement) when analyzing the declaration of C.
gcc/ada/ChangeLog:
* exp_ch5.adb (Expand_Formal_Container_Loop):
Analyze Init_Decl in the correct scope. Remove patch-up
code that was needed because we were using the wrong scope.
* exp_ch7.adb (Process_Object_Declaration):
Remove code to unique-ify the name of Master_Node_Id;
no longer needed because of change to exp_ch5.adb.
* sem_warn.adb (Check_References):
Suppress warnings during preanalysis, because we don't
have complete information yet; otherwise, the new Preanalyze
call in exp_ch5.adb generates bogus warnings.
Steve Baird [Mon, 10 Nov 2025 22:36:33 +0000 (14:36 -0800)]
ada: Improve Append performance for Ada.Containers.Bounded_Vectors
In (any instance of) Ada.Containers.Bounded_Vectors, for the procedure
overload of Append that takes parameters of types Vector and Element_Type,
improve performance in the case where either of the GNAT-defined checks
Container_Checks or Tampering_Check are suppressed.
gcc/ada/ChangeLog:
* libgnat/a-cobove.adb
(Append): Add an equivalent fast path for the case where tampering
checks are suppressed.
Eric Botcazou [Mon, 10 Nov 2025 11:44:47 +0000 (12:44 +0100)]
ada: Remove suspicious entries generated by -gnatR for generic formal types
Generic formal type parameters may have an unspecified layout when they are
processed for the -gnatR output, so it's better to skip them entirely.
The change also reverts an earlier change that would output "??" for an
unknown alignment on a type, which is inconsistent and undocumented.
gcc/ada/ChangeLog:
* repinfo.adb (List_Location): Do not output the final comma.
(List_Common_Type_Info): Adjust to above change. Do not output
"??" for an unknown alignment.
(List_Entities): Do not output generic types.
(List_Object_Info): Adjust to above change.
(List_Subprogram_Info): Likewise.
Viljar Indus [Thu, 16 Jan 2025 19:40:54 +0000 (21:40 +0200)]
ada: Ensure a limited type is marking the packing as used
gcc/ada/ChangeLog:
* sem_ch4.adb (Analyze_Call): ensure we generate a reference to the
non limited view of the return type to avoid scenarios where
the with-ed unit is not considered referenced.
Josef Melcr [Thu, 20 Nov 2025 22:57:57 +0000 (23:57 +0100)]
ipa: Remove LTO requirement for builtin callback carriers.
Due to the if statement in ipa_compute_jump_functions_for_bb, callback
edges were never constructed for builtin functions unless LTO was
enabled. This patch corrects this behavior, allowing GCC to optimize
callbacks more broadly. It also extends our testing capabilities.
gcc/ChangeLog:
* attr-callback.cc (callback_edge_callee_has_attr): New
function.
* attr-callback.h (callback_edge_callee_has_attr): New function
decl.
* ipa-prop.cc (ipa_compute_jump_functions_for_bb): Don't skip
callback carriers when calculating jump functions.
Josef Melcr [Thu, 20 Nov 2025 22:46:38 +0000 (23:46 +0100)]
ipa: Rewrite callback_edge_useful_p heuristic.
This function is used to determine whether a callback edge should be
kept or not. It was supposed to capture the idea that a callback edge
has been redirected at some point, however, it only considered
redirecting to some clone. However, an edge may not always be
redirected to a clone. For example, common function bodies produced by
icf are not clones. This version of this function should cover all
cases, at least for the time being.
gcc/ChangeLog:
PR ipa/122768
* attr-callback.cc (callback_edge_useful_p): Rewrite the
heuristic, now consider clones as well as icf bodies.
Deng Jianbo [Mon, 17 Nov 2025 07:28:19 +0000 (15:28 +0800)]
LoongArch: Add more numbers supported for {x}vldi
When the most significant bit of the 13 bit immediate value in LoongArch
{x}vldi isntruction is set 1, it can generate different numbers based on
the algorithm. This patch adds to support these numbers to be
generated by {x}vldi instruction.
gcc/ChangeLog:
* config/loongarch/constraints.md: Update constraint YI to support
more numbers.
* config/loongarch/loongarch-protos.h
(loongarch_const_vector_vrepli): Rename.
(loongarch_const_vector_vldi): Ditto.
* config/loongarch/loongarch.cc (VLDI_NEG_MASK): New macro.
(loongarch_parse_vldi_const): New function to check if numbers can
be generated by {x}vldi instruction.
(loongarch_const_vector_vrepli): Rename.
(loongarch_const_vector_vldi): Use above function.
(loongarch_const_insns): Call renamed function.
(loongarch_split_vector_move_p): Ditto.
(loongarch_output_move): Ditto.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/vector/lasx/lasx-builtin.c: Replace xvrepli
with xvldi.
* gcc.target/loongarch/vector/lasx/lasx-vec-init-2.c: Fix test.
* gcc.target/loongarch/vector/lsx/lsx-builtin.c: Repalce vrepli with
vldi.
* gcc.target/loongarch/vrepli.c: Ditto.
* gcc.target/loongarch/vector/lasx/lasx-xvldi-2.c: New test.
* gcc.target/loongarch/vector/lsx/lsx-vldi-2.c: New test.
zhaozhou [Fri, 14 Nov 2025 03:09:13 +0000 (11:09 +0800)]
LoongArch: Fix operands[2] predicate of lsx_vreplvei_mirror.
UNSPEC_LSX_VREPLVEI_MIRROR describes the mirroring operation that copies
the lower 64 bits of a 128-bit register to the upper 64 bits. So in any
mode, the value range of op2 can only be 0 or 1 for the vreplvei.d insn.
Andrew MacLeod [Thu, 20 Nov 2025 17:10:25 +0000 (12:10 -0500)]
Improve PHI analyzer performance
Only do iterative analysis if it might be worthwhile.
PR tree-optimization/121345
gcc/
* gimple-range-phi.cc (phi_group::calculate_using_modifier): Restore
performance loss by being more selective when iterating.
François Dumont [Thu, 20 Nov 2025 06:01:53 +0000 (07:01 +0100)]
libstdc++: [_GLIBCXX_DEBUG] Fix std::erase_if behavior for __gnu_debug::vector
When using directly __gnu_debug::vector the std::erase_if is called with a
reference to the std::vector base class and so is missing the invalidation
of the iterators implied by this operation.
To fix this provide a std::erase_if overload dedicated to __gnu_debug::vector.
Doing so we can cleanup the implementation dedicated to std::vector from any
_GLIBCXX_DEBUG consideration.
libstdc++-v3/ChangeLog:
* include/debug/vector (std::erase_if, std::erase): New overloads for
std::__debug::vector instances.
* include/std/vector (std::erase_if, std::erase): Make overloads specific
to normal std::vector implementation.
* testsuite/23_containers/vector/debug/erase.cc: New test case.
* testsuite/23_containers/vector/debug/invalidation/erase.cc: New test case.
Luc Grosheintz [Tue, 18 Nov 2025 14:24:52 +0000 (15:24 +0100)]
libstdc++: Prepare mdspan-related code for submdspan.
The changes needed for submdspan are:
* In submdspan related code the user-defined integer-like
types need to be copy- and move-constructable.
* The traits for writing tests that work with both left- and right,
possibly padded, layouts will also be useful for submdspan.
Therefore, this code is moved up and generalized.
* Move __offset further up in <mdspan> and fix some formatting
mistakes.
Kito Cheng [Wed, 5 Nov 2025 09:55:39 +0000 (17:55 +0800)]
RISC-V: Add RTL pass to combine cm.popret with zero return value
This patch implements a new RTL pass that combines "li a0, 0" and
"cm.popret" into a single "cm.popretz" instruction for the Zcmp
extension.
This optimization cannot be done during prologue/epilogue expansion
because it would cause shrink-wrapping to generate incorrect code as
documented in PR113715. The dedicated RTL pass runs after shrink-wrap
but before branch shortening, safely performing this combination.
Changes since v2:
- Apply Jeff's comment
- Use CONST0_RTX rather than const0_rtx, this make this pass able to
handle (const_double:SF 0.0) as well.
- Adding test case for float/double zero return value.
Changes since v1:
- Tweak the testcase.
gcc/ChangeLog:
* config/riscv/riscv-opt-popretz.cc: New file.
* config/riscv/riscv-passes.def: Insert pass_combine_popretz before
pass_shorten_branches.
* config/riscv/riscv-protos.h (make_pass_combine_popretz): New
declaration.
* config/riscv/t-riscv: Add riscv-opt-popretz.o build rule.
* config.gcc (riscv*): Add riscv-opt-popretz.o to extra_objs.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/pr113715.c: New test.
* gcc.target/riscv/rv32e_zcmp.c: Update expected output for
test_popretz.
* gcc.target/riscv/rv32i_zcmp.c: Likewise.
Pan Li [Thu, 20 Nov 2025 15:16:10 +0000 (08:16 -0700)]
[PATCH v1] RISC-V: Fix missed zero extend for unsigned scalar SAT_TRUNC [PR122692]
When the input of the scalar unsigned SAT_TRUNC is not Xmode,
the rtx need to zero extend to Xmode before the underlying
code gen. Most of other SAT_* code gen has leveraged
the API riscv_extend_to_xmode_reg but still have the ustrunc
missed. Then results in the failures mentioned in PR.
The below test suites are passed for this patch series.
* The rv64gcv fully regression test.
PR target/122692
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_expand_ustrunc): Leverage
riscv_extend_to_xmode_reg to take care of src rtx.
gcc/testsuite/ChangeLog:
* g++.target/riscv/pr122692-run-1.C: New test.
* g++.target/riscv/pr122692-run-2.C: New test.
Tamar Christina [Thu, 20 Nov 2025 14:14:59 +0000 (14:14 +0000)]
middle-end: add target hook for isel
This adds a new target hook to gimple-sel to allow targets to
do target specific massaging of the gimple IL to prepare for
expand.
Tejas will be sending up part 2 of this soon to help convert
SVE packed boolean VEC_COND_EXPR into something that we can
handle more efficiently if expanded in a different order.
We also want to use this to e.g. for Adv. SIMD prefer avoiding
!= vector compare expressions because the ISA doesn't have
this instruction and so we expand to == + ~ but changing the
expression from a MIN to MAX only for VECTOR_BOOLEAN_TYPE_P
and flipping the operands we can expand more efficient.
These are the kind of things we want to use the hook for,
not generic changes that apply to all target.
gcc/ChangeLog:
* target.def (instruction_selection): New.
* doc/tm.texi.in: Document it.
* doc/tm.texi: Regenerate
* gimple-isel.cc (pass_gimple_isel::execute): Use it.
* targhooks.cc (default_instruction_selection): New.
* targhooks.h (default_instruction_selection): New.
Josef Melcr [Thu, 20 Nov 2025 12:32:45 +0000 (13:32 +0100)]
ipa: Add early return when the hashed edge is a callback-carrying edge.
The inclusion of this early return statement has been discussed before,
it was ultimately left out of the original patch, but it turns out to be
necessary.
When a callback edge is being created, it is first created by
symbol_table::create_edge, which is where it is added to the call site
hash. However, its callback flag is not set at that point, so the early
return for callback edges doesn't affect it. This causes the wrong edge
to be hashed, ultimately leading to segfaults and ICEs. This happens
many times in the testsuite, the one I noticed first was
libgomp.fortran/simd7.f90.
gcc/ChangeLog:
PR ipa/122358
* cgraph.cc (cgraph_add_edge_to_call_site_hash): Add an early
return when the hashed edge is a callback-carrying edge.
Arsen Arsenović [Thu, 20 Nov 2025 11:17:38 +0000 (12:17 +0100)]
gcc/doc: Fix usages of @itemize with named items in Regs and Memory
The old usage lead to makeinfo emitting text like "pseudo registers This
is the most common case. Most subregs have pseudo regs as their first
operand." when, clearly, "pseudo registers" was intended to be the name
of an item, and the rest of the paragraph a description. This is
because @itemize was used, which does not support "naming" items.
Now, the paragraph used as an example above looks like this:
pseudo registers
This is the most common case. Most ‘subreg’s have pseudo
‘reg’s as their first operand.
gcc/ChangeLog:
* doc/rtl.texi (Regs and Memory): Use @table instead of @itemize
for lists with named items.
Xinhui Yang [Tue, 11 Nov 2025 02:19:35 +0000 (10:19 +0800)]
gcc: check if target install name equals the full driver name
When a major version program suffix is specified, along with
--with-gcc-major-version-only, GCC tries to install $TRIPLE-gcc-tmp into
the destination BINDIR and link it to TRIPLE-gcc-SUFFIX. However this
executable is installed in the previous step, thus leaving the gcc-tmp
unmodified.
This is because when --program-suffix=15 (any major version) and
--with-gcc-major-version-only, $(version) will be the major version
number, thus making FULL_DRIVER_NAME and GCC_TARGET_INSTALL_NAME
identical to each other. We check if these two is identical and skip the
latter step if they are.
gcc/
PR bootstrap/105664
* Makefile.in (install-driver): detect name collision when
installing the driver program.
Rainer Orth [Thu, 20 Nov 2025 09:34:13 +0000 (10:34 +0100)]
Switch from USE_GAS/GLD to HAVE_GNU_AS/LD
We currently have two ways to distinguish GNU and non-GNU assemblers and
linkers:
* USE_GAS and USE_GLD, defined via gcc/config/usegas.h and usegld.h
which are included via config.gcc
* HAVE_GNU_AS and HAVE_GNU_LD, determined from gcc/configure.ac
This is confusing and leads to weird mistakes like combining both into
an undefined USE_GNU_LD. Since both are based on the same info ($gas
resp. $gnu_ld in gcc/configure.ac), it seems best to standardise on one
of them. Since the USE_* form is almost exclusively used in
Solaris-specific contexts, it's clearer to use the HAVE_GNU_* forms
instead.
This is what this patch does.
Most of the changes are either Solaris-specific or border on obvious.
Outside of Solaris code, there are only two cases:
* gcc/config/ia64/hpux.h has one macro guarded by !USE_GAS. This wasn't
defined before since the configuration for this target doesn't include
usegas.h. However, the code is still needed, so the HAVE_GNU_AS form is
now used.
* Uses of usegas.h in various powerpc*-*-* configurations in
gcc/config.gcc. Those make no difference since USE_GAS isn't used in any
of the affected files.
Bootstrapped without regressions on i386-pc-solaris2.11 and
sparc-sun-solaris2.11 (as/ld, gas/ld, and gas/gld configurations).
Rainer Orth [Thu, 20 Nov 2025 09:31:56 +0000 (10:31 +0100)]
driver: Simplify LINK_ARCH*_SPEC on Solaris
The various LINK_ARCH*_SPECs proved to be way more complex than
necessary:
* All uses of -YP,* can just go: they match the Solaris and GNU ld
defaults. In addition, the /usr/lib/libp entries are now superfluous:
they only contain compatiblity symlinks to their counterparts in
/usr/lib. The %R parts are superceded by the -z sysroot/--sysroot
options.
* With those options gone, LINK_ARCH{32,64}_SPEC_BASE are now identical
and can be merged.
* It's no longer necessary to use arch-specific versions of the Solaris
ld map.below4G linker map: with the new v2 mapfile syntax a single
file can be used for all of SPARC, and x86, 32 and 64-bit.
* Similarly, with LINK_ARCH{32,64,DEFAULT}_SPEC being identical, a
common LINK_ARCH_SPEC can be used with the single difference (erroring
out on the non-default multilib in non-multilib configurations,
e.g. -m64 for -m32-only configs) moved to a separate
LINK_ARCH_ERROR_SPEC.
Bootstrapped without regressions on {i386,amd64}-pc-solaris2.11,
sparc{,v9}-sun-solaris2.11 with as/ld, gas/ld, and gas/gld plus
--disable-multilib builds of those.
Xi Ruoyao [Sun, 16 Nov 2025 11:57:35 +0000 (19:57 +0800)]
LoongArch: NFC: Simplify logic of vec_perm{v32qi,v16hi}
De-duplicate the login by introducing gen_lasx_xvpermi_d (mode, ...)
with "@". Also remove the merge_two label: we should really not (ab)use
goto when avoiding it is trivial.
* config/loongarch/lasx.md (lasx_xvpermi_d): Add "@".
* config/loongarch/loongarch.cc (loongarch_expand_vec_perm_1):
Use gen_lasx_xvpermi_d instead of
gen_lasx_xvpermi_d_{v32qi,v16hi} to deduplicate the logic. Do
structrual programming instead of goto and label.
Xi Ruoyao [Sun, 16 Nov 2025 11:38:02 +0000 (19:38 +0800)]
LoongArch: Micro-optimize the blend step for vec_perm<LASX>
Clamp the selector using the actual number of elements 2w instead of the
fixed value 0x1f. So we can simply compare the clamped selector and w
to generate the mask for blending.
gcc/
* config/loongarch/loongarch.cc (loongarch_expand_vec_perm_1):
Clamp the selector using the twice of actual number of elements.
Compare the clamped selector with the element number to get the
blending mask.
Xi Ruoyao [Sun, 16 Nov 2025 09:04:13 +0000 (17:04 +0800)]
LoongArch: NFC: Simplify vec_permv8sf logic
gcc/
* config/loongarch/lasx.md (lasx_xvperm_<lasxfmt_f_wd>): Add
"@" for gen_lasx_xvperm helper.
* config/loongarch/loongarch.cc (loongarch_expand_vec_perm_1):
Call gen_lasx_xvperm to unify V8SF and V8SI handling.
Jakub Jelinek [Thu, 20 Nov 2025 07:19:32 +0000 (08:19 +0100)]
c++: Fix error recovery ICE in tsubst_baselink [PR120876]
The following testcase ICEs since r12-6080. The problem is that
lookup_fnfields can return NULL_TREE on failure, but the maybe_incomplete
handling was added before the if (!baselink) handling and assumes that
baselink is non-NULL (and BASELINK).
The following patch reorders the if (maybe_incomplete) handling with
if (!baselink).
2025-11-20 Jakub Jelinek <jakub@redhat.com>
PR c++/120876
* pt.cc (tsubst_baselink): Move maybe_incomplete handling after
!baselink handling.
Jakub Jelinek [Thu, 20 Nov 2025 06:59:13 +0000 (07:59 +0100)]
c++: Fix error recovery for enums with bad underlying type [PR122540]
The r16-4698 patch to use fold_convert in finish_enum_value_list instead
of copy_node + set TREE_TYPE caused UB in the compiler as detected e.g.
by valgrind on the g++.dg/parse/pr96442.C g++.dg/cpp0x/auto9.C testcases.
If underlying type is valid, start_enum does:
else if (CP_INTEGRAL_TYPE_P (underlying_type))
{
copy_type_enum (enumtype, underlying_type);
ENUM_UNDERLYING_TYPE (enumtype) = underlying_type;
}
and the copy_type_enum ensures the ENUMERAL_TYPE has the same
TYPE_PRECISION, TYPE_SIZE etc. But if the underlying type is erroneous,
it errors and for error recovery sets
ENUM_UNDERLYING_TYPE (enumtype) = integer_type_node;
This means TYPE_PRECISION on the ENUMERAL_TYPE remains 0, TYPE_SIZE NULL
etc. and then later on when we try to fold_convert the enumerator values
to that type, we invoke UB in the wide_int code because it really doesn't
like casts to 0 precision integral types.
The following patch fixes it by calling also copy_type_enum from
integer_type_node when we set such underlying type.
2025-11-20 Jakub Jelinek <jakub@redhat.com>
PR c++/122540
* decl.cc (start_enum): When setting ENUM_UNDERLYING_TYPE
to integer_type_node during error recovery, also call copy_type_enum.
Marek Polacek [Tue, 18 Nov 2025 20:23:20 +0000 (15:23 -0500)]
c++: fix ICE when comparing targs [PR119580]
In r10-7816, cp_tree_equal/TEMPLATE_ID_EXPR was changed to use
comp_template_args to compare the targs. This makes sense, but
comp_template_args won't deal with an error_mark_node. We created
a BASELINK for S::foo<T::value_type>, but since value_type couldn't
be looked up, we ended up with an error_mark_node instead of a TREE_VEC
of arguments for the TEMPLATE_ID_EXPR in the BASELINK.
It seems reasonable not to create such a TEMPLATE_ID_EXPR by checking
the result of tsubst_template_args like we do in so many other places.
This changes the diagnostic in three tests, but it's only the followup
error message after complaining about the type/value mismatch.
PR c++/119580
gcc/cp/ChangeLog:
* pt.cc (tsubst_baselink): Return error_mark_node if
tsubst_template_args returned error_mark_node.
Andrew Pinski [Wed, 19 Nov 2025 02:16:02 +0000 (18:16 -0800)]
gimple: fix strlen+more for references
I found that the strlen pass ignores stores via references.
This shows up with C++ code more than C.
A simple:
```
int g(void)
{
std::string a="a";
return __builtin_strlen(a.c_str());
}
```
Should be optimized to just `return 1` but does not
currently due to use of references.
The problem in the code is direct comparison with POINTER_TYPE instead
of using POINTER_TYPE_P.
This fixes the cases I found all related to strings passes. All of them
were added by Martin Sebor which makes me think this was an oversight on his
part.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/122754
gcc/ChangeLog:
* gimple-fold.cc (get_range_strlen_tree): Use POINTER_TYPE_P instead
of direct comparing to POINTER_TYPE.
* gimple-ssa-sprintf.cc (format_integer): Likewise.
* gimple-ssa-warn-access.cc (maybe_warn_nonstring_arg): Likewise.
* gimple-ssa-warn-restrict.cc (pass_wrestrict::check_call): Likewise.
* tree-ssa-strlen.cc (maybe_set_strlen_range): Likewise.
(is_strlen_related_p): Likewise.
(strlen_pass::handle_assign): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/tree-ssa/string-strlen-1.C: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Andrew Pinski [Tue, 18 Nov 2025 20:57:24 +0000 (12:57 -0800)]
libstdc++: store the length after the store of the null character
This improves the code generation slightly for std::string because of
aliasing. In many cases the length will be read again and the store of
the null character will cause the length to be re-read due to aliasing
requirements of the char type. So swapping around the stores will allow
the length not to have to be reloaded from memory and will allow
for more optimizations.
Bootstrapped and tested on x86_64-linux-gnu.
libstdc++-v3/ChangeLog:
* include/bits/basic_string.h (basic_string::M_set_length): Swap
around the order of traits_type::assign and _M_length so that
_M_length is at the end.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Andrew Pinski [Fri, 14 Nov 2025 01:27:06 +0000 (17:27 -0800)]
dce: Use FOR_EACH_IMM_USE_FAST instead of FOR_EACH_IMM_USE_STMT in simple_dce_from_worklist
When I wrote this code I forgot about FOR_EACH_IMM_USE_FAST. Since this code does not change
any of the uses inside of the loop using FOR_EACH_IMM_USE_FAST will be slightly faster.
Bootstrapped and tested on x86_64-linux-gnu.
gcc/ChangeLog:
* tree-ssa-dce.cc (simple_dce_from_worklist): Use FOR_EACH_IMM_USE_FAST instead of
FOR_EACH_IMM_USE_STMT.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Alfie Richards [Wed, 19 Nov 2025 11:47:09 +0000 (11:47 +0000)]
aarch64: Fix ICE when laying out arguments of size 0 [PR 122763]
When laying out arguments of size 0, previously would return the next argument
passing register, without checking that there was a next one.
This was fine for AAPCS as it used R0-R7 for argument passing and R9 would be
occasionally be assigned, but never used.
However, with the introduction of preserve_none PCS there is no obvious "next
register" to use as aaaa dummy value, and so when laying out in the
"next register" when there were no more, an assert triggered an ICE.
This patch fixes this ICE by instead using NULL_RTX for arguments of size 0.
PR target/122763
gcc/ChangeLog:
* config/aarch64/aarch64.cc (aarch64_layout_arg): Return NULL_RTX for
arguments of size 0.
(aarch64_function_arg_advance): Remove assert.
Patrick Palka [Wed, 19 Nov 2025 16:10:38 +0000 (11:10 -0500)]
c++: current inst name lookup within noexcept-spec [PR122668]
Since we don't implement deferred noexcept-spec parsing of a friend
declaration, the r15-2117 change diagnosing name lookup failure for the
current instantiation ahead of time needs to be suppressed in this case.
PR c++/122668
PR c++/114764
gcc/cp/ChangeLog:
* pt.cc (dependentish_scope_p): Return true for the current
instantiation from within an immediately parsed noexcept-spec.
Luc Grosheintz [Wed, 19 Nov 2025 13:52:04 +0000 (14:52 +0100)]
libstdc++: Make <mdspan> compatible with clang.
These three changes are needed to make <mdspan> compatible with Clang:
- the type alias _Storage must occur before its first use.
- the friend declarations of function must match exactly, including
noexcept and constexpr.
- the 'template' in typename T::template type<double>.
libstdc++-v3/ChangeLog:
* include/std/mdspan (extents::_Storage): Move type alias before
its first use.
(__mdspan::__static_extents): Add missing noexcept and constexpr
to friend declaration in extents.
(__mdspan::__dynamic_extents): Ditto.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
svint16_t sub_neon_i16_sve_bridged(svint8_t a, svint8_t b) {
return svset_neonq_s16(svundef_s16(),
vsubq_s16(vmovl_high_s8(svget_neonq(a)),
vmovl_high_s8(svget_neonq(b))));
}
we generate:
sub_neon_i16_sve_bridged(__SVInt8_t, __SVInt8_t):
sxtl2 v0.8h, v0.16b
ssubw2 v0.8h, v0.8h, v1.16b
ret
instead of just
sub_neon_i16_sve_bridged(__SVInt8_t, __SVInt8_t):
ssubl2 v0.8h, v0.16b, v1.16b
ret
Commit g:abf865732a7313cf79ffa325faed3467ed28d8b8 added a framework to fold
uses of instrinsics combined with lo/hi extractions into the appropriate low
or highpart instructions.
However this doesn't trigger because the Adv.SIMD from SVE extraction code for
vmovl_high_s8(svget_neonq(a))
does not have one argument as constant and only supports folding 2 insn, not 3
into 1.
Since the SVE and the Adv. SIMD modes are tieable this is a valid instruction to
make, however it's suboptimal in that we can't fold this into the existing
instruction patterns. Eventually early-ra will split off the SVE reg from the
patterns but by then we're passed combine and insn foldings so we miss all the
optimizations.
This patch introduces vec_extract optabs for 128-bit and 64-bit Adv.SIMD vector
extraction from SVE registers and emits an explicit separate instruction for the
subregs. This then gives combine and rtl folding the opportunity to form the
combined instructions and if not we arrive at the same RTL after early-ra.
Richard Biener [Tue, 18 Nov 2025 14:20:44 +0000 (15:20 +0100)]
tree-optimization/122722 - better SLP reduction group discovery
The following improves the all-or-nothing discovery of reduction
groups to consider sub-groups by trying toplevel "matches" candidates
for this. For simplicity and to limit compile-time failed sub-group
matches are not decomposed further, only the originally failed part
is tried again to discover more sub-groups. Any remaining fails
get picked up by the current single-reduction handling.
PR tree-optimization/122722
* tree-vect-slp.cc (vect_analyze_slp_reductions): New
function, split out from vect_analyze_slp. Try SLP
sub-groups.
(vect_analyze_slp_reduction_group): New helper.
Christophe Lyon [Mon, 17 Nov 2025 11:05:10 +0000 (11:05 +0000)]
arm: testsuite: fix vgetq_lane tests for c++
Surpringly these tests were lacking the extern "C" that other MVE
intrinsics have, making them fail when tested in C++ mode.
While fixing that:
- remove useless dg-skip-if
- remove hardcoded -mfloat-abi=hard from s64 and u64 versions
- add check-function-bodies to s64 and u64 versions, such that these
tests no longer appear as duplicates.
Richard Biener [Wed, 19 Nov 2025 09:33:05 +0000 (10:33 +0100)]
tree-optimization/122747 - fix masking of loops with conditional reduction ops
The following amends the earlier fix in r16-5372-gfacb92812a4ec5 to
also cover the case we're not doing the merge to a single cycle
but go via vectorizable_call.
PR tree-optimization/122747
* tree-vect-stmts.cc (vectorizable_call): Handle reduction
operations that are already conditional.
* gcc.target/i386/vect-epilogues-10.c: New testcase.
Jakub Jelinek [Wed, 19 Nov 2025 10:52:16 +0000 (11:52 +0100)]
tree-ssanames: Fix pasto in get_known_nonzero_bits function comment
get_known_nonzero_bits_1 function comment a few lines earlier says
correctly it returns 0 for unknown (unlike get_nonzero_bits{,_1}
which return -1 for unknown).
2025-11-19 Jakub Jelinek <jakub@redhat.com>
* tree-ssanames.cc (get_known_nonzero_bits): Fix a pasto in
function comment, this function returns 0 if unknown rather
than -1.