]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
99 min agoMake SLP discovery more verbose master trunk
Richard Biener [Mon, 6 Jul 2026 07:26:22 +0000 (09:26 +0200)] 
Make SLP discovery more verbose

The following dumps the first root stmt when analyzing a BB reduction.

* tree-vect-slp.cc (vect_build_slp_instance): For BB reductions
note the first root stmt.

2 hours agoamdgcn: Add vec_set*ti instructions
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.

2 hours agoRemove obsolete support for ADA_LONG_TYPE_SIZE
Eric Botcazou [Sat, 4 Jul 2026 08:13:13 +0000 (10:13 +0200)] 
Remove obsolete support for ADA_LONG_TYPE_SIZE

The macro was only defined for VMS and VMS is no longer supported in Ada.

gcc/
* config/vms/vms.h (ADA_LONG_TYPE_SIZE): Delete.
* doc/tm.texi.in (ADA_LONG_TYPE_SIZE): Likewise.
* doc/tm.texi: Regenerate.
* system.h (ADA_LONG_TYPE_SIZE): Poison.

gcc/ada/
* gnatlink.adb: Remove clause for System.CRTL.
(Store_File_Context): Remove clause for System.CRTL.long.
* gcc-interface/targtyps.cc (ADA_LONG_TYPE_SIZE): Delete.
(get_target_long_size): Use LONG_TYPE_SIZE.
* libgnat/i-c.ads: Remove clause for System.Parameters.
(long): Declare as derived from Long_Integer.
* libgnat/i-cstrin.ads: Add clause for System.Parameters.
* libgnat/s-crtl.ads: Remove clause for System.Parameters.
(long): Declare as subtype of Long_Integer.
* libgnat/s-parame.ads (long_bits): Delete.
* libgnat/s-parame__hpux.ads (long_bits): Likewise.
* libgnat/s-parame__vxworks.ads (long_bits): Likewise.

2 hours agoRemove left-overs of WIDEST_HARDWARE_FP_SIZE
Eric Botcazou [Sat, 4 Jul 2026 08:03:34 +0000 (10:03 +0200)] 
Remove left-overs of WIDEST_HARDWARE_FP_SIZE

This removes the single remaining use of WIDEST_HARDWARE_FP_SIZE in GCC,
which has been anectodal for a long time, and all the associated bits.

gcc/
* config/aarch64/aarch64.h (WIDEST_HARDWARE_FP_SIZE): Delete.
* config/alpha/alpha.h (WIDEST_HARDWARE_FP_SIZE): Likewise.
* config/i386/i386.h (WIDEST_HARDWARE_FP_SIZE): Likewise.
* config/ia64/vms.h (WIDEST_HARDWARE_FP_SIZE): Likewise.
* config/pa/pa.h (WIDEST_HARDWARE_FP_SIZE): Likewise.
* config/rs6000/rs6000.h (WIDEST_HARDWARE_FP_SIZE): Likewise.
* config/s390/s390.h (WIDEST_HARDWARE_FP_SIZE): Likewise.
* config/sparc/sparc.h (WIDEST_HARDWARE_FP_SIZE): Likewise.
* config/visium/visium.h (WIDEST_HARDWARE_FP_SIZE): Likewise.
* doc/tm.texi.in (WIDEST_HARDWARE_FP_SIZE): Likewise.
* doc/tm.texi: Regenerate.
* system.h (WIDEST_HARDWARE_FP_SIZE): Poison.

gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_entity): Use the precision of
longest_float_type_node to compute the maximum size of FP types.

2 hours agoRemove the path-splitting pass and deprecate -fsplit-paths [PR120892]
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):

                    candidates   splits   declined   to protect if-conversion
  -O3                  122894    62050     60844           37166
  -O3 -flto=auto        52423    21257     31166           21822

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.

gcc/testsuite/ChangeLog:

PR tree-optimization/120892
* gcc.dg/tree-ssa/split-path-1.c: Move to...
* gcc.c-torture/execute/split-path-1.c: ...here.  Adjust to a plain
compile and run test without the split-paths dump scan.
* gcc.dg/tree-ssa/split-path-2.c: Move to...
* gcc.c-torture/compile/split-path-2.c: ...here.  Adjust to a
compile-only test without the split-paths dump scan.
* gcc.dg/tree-ssa/split-path-3.c: Move to...
* gcc.c-torture/compile/split-path-3.c: ...here.  Likewise.
* gcc.dg/tree-ssa/split-path-4.c: Move to...
* gcc.c-torture/compile/split-path-4.c: ...here.  Likewise.
* gcc.dg/tree-ssa/split-path-5.c: Move to...
* gcc.c-torture/compile/split-path-5.c: ...here.  Likewise.
* gcc.dg/tree-ssa/split-path-6.c: Move to...
* gcc.c-torture/compile/split-path-6.c: ...here.  Likewise.
* gcc.dg/tree-ssa/split-path-7.c: Move to...
* gcc.c-torture/compile/split-path-7.c: ...here.  Likewise.
* gcc.dg/tree-ssa/split-path-8.c: Move to...
* gcc.c-torture/compile/split-path-8.c: ...here.  Likewise.
* gcc.dg/tree-ssa/split-path-9.c: Move to...
* gcc.c-torture/compile/split-path-9.c: ...here.  Likewise.
* gcc.dg/tree-ssa/split-path-10.c: Move to...
* gcc.c-torture/compile/split-path-10.c: ...here.  Likewise.
* gcc.dg/tree-ssa/split-path-11.c: Move to...
* gcc.c-torture/compile/split-path-11.c: ...here.  Likewise.
* gcc.dg/tree-ssa/split-path-12.c: Move to...
* gcc.c-torture/compile/split-path-12.c: ...here.  Likewise.
* gcc.dg/tree-ssa/split-path-13.c: Move to...
* gcc.c-torture/compile/split-path-13.c: ...here.  Likewise.
* gcc.dg/tree-ssa/pr69270.c: Move to...
* gcc.c-torture/compile/pr69270.c: ...here.  Likewise.
* g++.dg/tree-ssa/pr88797.C: Move to...
* g++.dg/torture/pr88797.C: ...here.  Adjust to a compile-only test.
* gcc.target/i386/pr106450.c: Remove -fsplit-paths from dg-options.

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
3 hours agox86: Rewrite ix86_find_max_used_stack_alignment
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>
3 hours agolibstdc++: Avoid '-Wtype-limits' warnings in 'libstdc++-v3/config/locale/generic...
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>
8 hours agoi386: Enable 512-bit byte dot-product only under AVX512BW [PR126098]
liuhongt [Fri, 3 Jul 2026 13:46:32 +0000 (06:46 -0700)] 
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.

11 hours agoDaily bump.
GCC Administrator [Mon, 6 Jul 2026 00:16:33 +0000 (00:16 +0000)] 
Daily bump.

15 hours agoaarch64: [PR126094] Update aarch64_cmtst* patterns for new simplifications.
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.

18 hours agomatch: Fix #ifdef GIMPLE typo [PR125641]
Kael Andrew Alonzo Franco [Sun, 5 Jul 2026 02:02:25 +0000 (22:02 -0400)] 
match: Fix #ifdef GIMPLE typo [PR125641]

r17-1683-g43356828d897ad uses #ifdef GIMPLE but it should be #if GIMPLE.

Bootstrapped and tested on x86_64-pc-linux-gnu.

PR tree-optimization/125641

gcc/ChangeLog:

* match.pd: Fix #ifdef GIMPLE typo.

Signed-off-by: Kael Franco <kaelfandrew@gmail.com>
20 hours agotestsuite: Add C++ testcase for the recent PTA bug
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.

2026-07-05  Jakub Jelinek  <jakub@redhat.com>

* g++.dg/opt/20260703-1.C: New test.

Reviewed-by: Richard Biener <rguenth@suse.de>
21 hours agoObjective-C,C++: Rework metadata generation [PR124260].
Iain Sandoe [Sun, 1 Mar 2026 00:12:04 +0000 (00:12 +0000)] 
Objective-C,C++: Rework metadata generation [PR124260].

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.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
21 hours agoFortran: Fix ICE-on-invalid in trans_code.
Sandra Loosemore [Sat, 4 Jul 2026 13:58:42 +0000 (13:58 +0000)] 
Fortran: Fix ICE-on-invalid in trans_code.

gcc/fortran/ChangeLog
* trans.cc (trans_code): Do not try to set location on non-expr
tree expressions, e.g. error_mark_node.

21 hours agoa68: avoid non-unique test names in the Algol 68 testsuite
Jose E. Marchesi [Sun, 5 Jul 2026 13:24:33 +0000 (15:24 +0200)] 
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.

22 hours agoHardcode Solaris v2 mapfile syntax with Solaris ld
Rainer Orth [Sun, 5 Jul 2026 12:59:27 +0000 (14:59 +0200)] 
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.

2026-06-25  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc:
* configure.ac (gcc_cv_ld_clearcap): Remove.
Link clearcap.map to config/sol2-clearcap.map with Solaris ld.

* configure: Regenerate.
* config.in: Likewise.
* config/sol2-clearcap.map: Remove.
* config/sol2-clearcapv2.map: Rename to sol2-clearcap.map.
* config/t-sol2 (install-clearcap-map): Install source file
directly.
* config/sol2.h (LINK_CLEARCAP_SPEC): Guard with HAVE_SOLARIS_LD.

libgcc:
* configure.ac (solaris_ld_v2_maps): Remove.
* configure: Regenerate.
* Makefile.in (solaris_ld_v2_maps): Remove.
* config/t-slibgcc-sld (libgcc-unwind.map): Remove
solaris_ld_v2_maps handling.

23 hours agoa68: check for overflow in bits denotations
Jose E. Marchesi [Sun, 5 Jul 2026 10:25:28 +0000 (12:25 +0200)] 
a68: check for overflow in bits denotations

Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog

* a68-low-units.cc (a68_lower_denotation): Check for denotations
too big for bits modes.

gcc/testsuite/ChangeLog

* algol68/compile/error-bits-denotation-1.a68: New test.
* algol68/execute/and-bits-1.a68: Fix invalid bits denotations.
* algol68/execute/bits-shift-2.a68: Likewise.
* algol68/execute/bits-shift-3.a68: Likewise.
* algol68/execute/not-bits-1.a68: Likewise.
* algol68/execute/or-bits-1.a68: Likewise.

23 hours agoa68: support for decimal radix in bits denotations
Jose E. Marchesi [Sun, 5 Jul 2026 11:00:37 +0000 (13:00 +0200)] 
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.

gcc/testsuite/ChangeLog

* algol68/compile/error-radix-5.a68: New test.
* algol68/compile/error-radix-6.a68: Likewise.
* algol68/compile/error-radix-7.a68: Likewise.
* algol68/execute/bits-radix-ten-1.a68: Likewise.

26 hours agoSH: Fix PR 67643 amendment of commit b6b9318ac9e72d6e
Oleg Endo [Sun, 5 Jul 2026 09:10:04 +0000 (18:10 +0900)] 
SH: Fix PR 67643 amendment of commit b6b9318ac9e72d6e

gcc/ChangeLog:
PR target/67643
PR target/126117
* config/sh/sh.cc (fpscr_set_from_mem): Add missing argument to
get_free_reg invocation.

26 hours agoAdd warnings about deleted PAUSE feature to test case.
Thomas Koenig [Sun, 5 Jul 2026 08:12:34 +0000 (10:12 +0200)] 
Add warnings about deleted PAUSE feature to test case.

gcc/testsuite/ChangeLog:

PR fortran/126090
* gfortran.dg/warn_undefined_vars_6.f90: Add warnings
about deleted feature.

27 hours agoSH: Fix PR 67643
Oleg Endo [Sun, 5 Jul 2026 07:23:26 +0000 (16:23 +0900)] 
SH: Fix PR 67643

gcc/ChangeLog:
PR target/67643
* config/sh/sh.cc (fpscr_set_from_mem): Specify a post-inc memory
operand for lds_fpscr after RA.

gcc/testsuite/ChangeLog:
PR target/67643
* gcc.target/sh/pr67643.c: New test.

31 hours agoSH: Remove remaining LRA transition helpers.
Oleg Endo [Sat, 4 Jul 2026 08:59:12 +0000 (17:59 +0900)] 
SH: Remove remaining LRA transition helpers.

gcc/ChangeLog:
PR target/55212
* config/sh/sh-protos.h (sh_lra_p): Remove.
(sh_legitimize_reload_address): Remove.
* config/sh/sh.h (LEGITIMIZE_RELOAD_ADDRESS): Remove.
* config/sh/sh.cc (sh_legitimize_reload_address): Remove.
(prepare_move_operands, broken_move): Remove sh_lra_p uses.
* config/sh/constraints.md (Rab, Rai, Ssd): Likewise.
* config/sh/sh.md: Likewise.  Remove reload-only *addsi3 patterns.

gcc/testsuite/ChangeLog:
PR target/55212
* gcc.target/sh/pr64366.c: Remove -mlra option.
* g++.target/sh/torture/pr55212-c311.C: Likewise.
* g++.target/sh/torture/pr55212-c333.C: Likewise.
* g++.target/sh/torture/pr55212-c373.C: Likewise.
* g++.target/sh/torture/pr55212-c384.C: Likewise.
* g++.target/sh/torture/pr55212-c413.C: Likewise.

31 hours agoSH: Add test case for PR69765
Oleg Endo [Sat, 4 Jul 2026 07:46:38 +0000 (16:46 +0900)] 
SH: Add test case for PR69765

gcc/testsuite/ChangeLog:

PR target/69765
* gcc.target/sh/pr69765.c: New test.

31 hours agoSH: Inline emit_fpu_switch into its only caller fpscr_set_from_mem
Oleg Endo [Fri, 3 Jul 2026 16:35:12 +0000 (01:35 +0900)] 
SH: Inline emit_fpu_switch into its only caller fpscr_set_from_mem

PR target/55212
* config/sh/sh.cc (emit_fpu_switch): Delete and merge into...
(fpscr_set_from_mem): ...this.

31 hours agoSH: Avoid FPUL for fp-constant loads
Oleg Endo [Sat, 4 Jul 2026 06:07:48 +0000 (15:07 +0900)] 
SH: Avoid FPUL for fp-constant loads

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 '*'.

31 hours agoSH: Fix T bit set expressions of addc and subc insns.
Oleg Endo [Fri, 3 Jul 2026 16:22:41 +0000 (01:22 +0900)] 
SH: Fix T bit set expressions of addc and subc insns.

gcc/ChangeLog:

PR target/67459
PR target/122948
* config/sh/sh.md (addc): Fix T bit set expression.
(subc): Likewise.

gcc/testsuite/ChangeLog:

PR target/67459
PR target/122948
* gcc.target/sh/pr122948.c: New test.

31 hours agoSH: Fix PR 124778
Oleg Endo [Fri, 3 Jul 2026 12:17:52 +0000 (21:17 +0900)] 
SH: Fix PR 124778

The lower-subreg pass would bail out in decompose_multiword_subregs because of
the ordering of the insn patterns.

gcc/ChangeLog:

PR target/124778
* config/sh/sh.md (extend<mode>si2_short_mem_disp_z): Move after
'*extend<mode>si2_compact_mem_disp' patterns.

35 hours agoDaily bump.
GCC Administrator [Sun, 5 Jul 2026 00:16:30 +0000 (00:16 +0000)] 
Daily bump.

40 hours agolibgcc, Darwin: Fix missing prerequisite [PR123976].
Iain Sandoe [Sat, 4 Jul 2026 18:24:56 +0000 (19:24 +0100)] 
libgcc, Darwin: Fix missing prerequisite [PR123976].

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.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
42 hours agoFix two issues with unused/unset variable warnings.
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.

2 days agoi386.cc: Add a missing override specifier
Filip Kastl [Sat, 4 Jul 2026 06:01:03 +0000 (08:01 +0200)] 
i386.cc: Add a missing override specifier

When compiling i386.cc, Clang complains that
better_epilogue_loop_than_p is not marked override.  Add the specifier.

Bootstrapped on x86_64 linux.  Committed as obvious.

gcc/ChangeLog:

* config/i386/i386.cc: Add override specifier for
better_epilogue_loop_than_p.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
2 days agoRISC-V: Add testcase for unsigned scalar SAT_MUL form 19
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.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 days agoRISC-V: Add testcase for unsigned scalar SAT_MUL form 18
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.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 days agoRISC-V: Add testcase for unsigned scalar SAT_MUL form 17
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.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 days agoRISC-V: Add testcase for unsigned scalar SAT_MUL form 16
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.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 days agotestsuite: Fix pr94589-5a.c
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>
2 days agoDaily bump.
GCC Administrator [Sat, 4 Jul 2026 00:16:37 +0000 (00:16 +0000)] 
Daily bump.

2 days agotree-optimization/122569 - recognize CLZ via isolated MSB DeBruijn lookup
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.

2 days agomatch.pd: factor MSB OR-cascade out of clz_table_index
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.

2 days agomatch: Simplify `(a CMP1 b) AND/IOR (a CMP2 b)` [PR126042]
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.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/106164
PR tree-optimization/126042
PR tree-optimization/94589

gcc/ChangeLog:

* 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>
2 days agoc++: Fix structured binding mangling during error recovery [PR126057]
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>.

* g++.dg/cpp2a/decomp11.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2 days agoc++: Implement C++29 P2953R5 - Adding restrictions to defaulted assignment operator...
Jakub Jelinek [Fri, 3 Jul 2026 18:43:22 +0000 (20:43 +0200)] 
c++: Implement C++29 P2953R5 - Adding restrictions to defaulted assignment operator functions [PR125826]

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.

Reviewed-by: Jason Merrill <jason@redhat.com>
2 days agoc++: Fix up ICEs with some metafns with non-dependent args in templates [PR126036]
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.

* g++.dg/reflect/pr126036.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2 days agoAVR: Adding +/-1 to a lower reg doesn't need a scratch.
Georg-Johann Lay [Fri, 3 Jul 2026 15:30:04 +0000 (17:30 +0200)] 
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.

2 days agolibstdc++: fix allocate_at_least test for small alignments [PR126072]
Nathan Myers [Thu, 2 Jul 2026 01:00:04 +0000 (21:00 -0400)] 
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.

libstdc++-v3/Changelog:
PR libstdc++/126072
* testsuite/20_util/allocator/allocate_at_least.cc: Fix.

2 days agoOpenMP, Fortran: Fix indentation in resolve_omp_clauses_aff_dep_map_cache
Sandra Loosemore [Fri, 3 Jul 2026 15:33:50 +0000 (15:33 +0000)] 
OpenMP, Fortran: Fix indentation in resolve_omp_clauses_aff_dep_map_cache

Commit basepoints/gcc-17-1747-ga7724fcb5f4 moved a large block of code
from resolve_omp_clauses to a new function.  I noticed that the
indentation of some nested switch statements looked odd when trying to
rebase some patches on top of this, and Tobias independently had
addressed this as part of his own WIP followup patch posted at
https://gcc.gnu.org/pipermail/gcc-patches/2026-June/721741.html.  This
patch addresses just the indentation problem and doesn't include any
functional changes.

gcc/fortran/ChangeLog
* openmp.cc (resolve_omp_clauses_aff_dep_map_cache): Fix
indentation.
Co-authored-by: Tobias Burnus <tburnus@baylibre.com>
2 days agolibssp: Include 'stdlib.h' for using alloca(3) [PR116547]
WHR [Sat, 31 Aug 2024 06:26:02 +0000 (06:26 +0000)] 
libssp: Include 'stdlib.h' for using alloca(3) [PR116547]

As GCC now treating implicit declaration of function as an error instead of
warning, compilation of libssp has been broken on some operating systems.
The following error is from an x86_64-unknown-freebsd11 system:

    [...]/libssp/ssp.c: In function 'fail':
    [...]/libssp/ssp.c:134:17: error: implicit declaration of function 'alloca' [-Wimplicit-function-declaration]
      134 |       p = buf = alloca (len);
          |                 ^~~~~~

Similarly: amd64-unknown-openbsd7.9.

Most operating systems specifies that 'stdlib.h' should be included to get
the declaration of alloca(3).

PR other/116547
* ssp.c: Include stdlib.h for alloca(3).

Co-authored-by: Thomas Schwinge <tschwinge@baylibre.com>
2 days agolibstdc++: Reserve _Pres_type value for prefixed hexadecimal floating presentation
Tomasz Kamiński [Wed, 24 Jun 2026 15:16:45 +0000 (17:16 +0200)] 
libstdc++: Reserve _Pres_type value for prefixed hexadecimal floating presentation

The LWG4515, "format: a and A should insert the 0x or 0X prefix",
points that format currently does not provide ability to emit
prefixed hexadecimal presentation for floating-point. While changing
the output for a/A was not approved during Brno meeting, producing
a printf equivalent output is desired functionality.

This patch pre-emptively introduces and handles additional _Pres_type
values for the purpose of expressing this implementation. The values
are not currently user-facing (there is no corresponding format
specifier), but adding them now will avoid problems caused by linking
TU from older versions and allow the change to be handled as DR
(if necessary).

Currently _Pres_p/_Pres_P are used as placeholders for the values
(matching their behavior for pointers), however they can renamed
in future  (only value is relevant).

Note, that for __formatter_int, the behavior of P/p can be already
expressed by setting _Pres_X/_Pres_x and _M_alt. In consequence the
existing uses of this name (as aliases to X/x) in __formatter_ptr
were adjusted accordingly.

libstdc++-v3/ChangeLog:

* include/std/format (_Pres_type::_Pres_p, _Pres_type::_Pres_P):
Change the values to which they are defined.
(__formatter_fp::format): Append 0x/0X if _M_type is _Pres_p/_Pres_P
respectively.
(__formatter_fp::_M_localize): Add __offset parameter representing
start of number value (after sign and prefix).
(__formatter_ptr::parse, __formatter_ptr::_M_default)
(__formatter_ptr::__formatter_ptr): Remove unused __type parameter,
and replace use of _Pres_p/P with _Pres_x/X.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 days ago[RISC-V] Utilize shNadd.uw during ADD synthesis
Jeff Law [Fri, 3 Jul 2026 13:50:13 +0000 (07:50 -0600)] 
[RISC-V] Utilize shNadd.uw during ADD synthesis

So this is the next area to improve in the ALU synthesis code.  In this case
we're looking to improve ADD synthesis.  In particular we're missing the
ability to utilize the shNadd.uw instructions.  In RTL these look like:

(define_insn "*shNadduw"
  [(set (match_operand:DI 0 "register_operand" "=r")
        (plus:DI
          (and:DI (ashift:DI (match_operand:DI 1 "register_operand" "r")
                             (match_operand:QI 2 "imm123_operand" "Ds3"))
                 (match_operand 3 "immediate_operand" "n"))
          (match_operand:DI 4 "register_operand" "r")))]
  "TARGET_64BIT && TARGET_ZBA
   && (INTVAL (operands[3]) >> INTVAL (operands[2])) == 0xffffffff"

In particular note the masking.  Essentially we're zero extending the shifted
operand from SI to DI before shifting.  That's the only difference from the
more common shNadd insns.  Since we already support using shNadd for ADD
synthesis the number of opportunities to exploit the .uw variant is relatively
limited. Given x + C the relevant values of C have bit 31+N set (where N is 1,
2 or 3) and bits 32+N clear.  Additionally the low 12+N bits must be clear.
Otherwise there are other ways to synthesize the addition.  But for those
limited constants we can use lui+shNadd.uw sequence.  Concretely consider:

unsigned long foo(unsigned long src) { return src + 0x1ffffe000; }

That currently generates:

        li      a5,-4096
        slli.uw a5,a5,1
        add     a0,a0,a5

Instead we want to generate:

        li      a5,-4096
        sh1add.uw       a0,a5,a0

You could legitimately ask why this isn't a simple combine pattern to squash
the slliw and add together.  Enter our friend mvconst_internal.  Its existence
encourages GCC to use the constant 0x1ffffe000 as-is in the RTL.  So we end up
with the original x+C case again and mvconst_internal expands the constant back
into li+slli.uw after combine.

And that's also the reason why this has no testcase.  We get the code we want
during expansion, combine+mvconst_internal do their thing and undo our
carefully crafted RTL, at least in the small isolated tests I've looked at.  So
at this time the patch is largely a NOP, but it's a step on the path to
mvconst_internal as it's another set of complex constants we can avoid
synthesizing at least some of the time.  It's also possible the early code
generation survives in larger contexts, I haven't really looked at that.

Given the difficulty in testing, I've mostly relied on looking at the expansion
code manually.  Not great.  But just in case this has been tested on
riscv32-elf & riscv64-elf without regressions.  It's also bootstrapped and
regression tested on the c920 and k3.  Waiting on pre-commit CI before moving
forward.

gcc/
* config/riscv/riscv.cc (synthesize_add): Utilize shNadd.uw when
appropriate.

2 days ago[RISC-V] Improve AND synthesis
Jeff Law [Fri, 3 Jul 2026 13:47:09 +0000 (07:47 -0600)] 
[RISC-V] Improve AND synthesis

So a couple changes to AND synthesis.

First much like the ADD, IOR/XOR cases we should be using riscv_integer_cost
rather than riscv_const_insns.  This results in improvement for the exact same
constants in the IOR/XOR case. This also introduces the ability to use rotation
to help AND synthesis.

Let's consider x & 0xff000000000000ff.  It currently generates this:

        li      a5,-1
        slli    a5,a5,56
        addi    a5,a5,255
        and     a0,a0,a5

The trick here is to realize we only have 16 bits that are relevant and the can
be clustered together.  So we rotate x right by 56 bit positions, then turn off
the high bits using zext.h then rotate 8 more positions to put the bits back
into the proper position.  That looks like this:

        rori    a0,a0,56
        zext.h  a0,a0
        rori    a0,a0,8

We can also use zext.w and andi for the bit clearing step.

Built and tested on riscv32-elf and riscv64-elf and bootstrapped + regression
tested on the c920 and k3.  Waiting on pre-commit CI before moving forward.

gcc/
* config/riscv/riscv.cc (and_synthesis): Use riscv_integer_cost rather
than riscv_const_insns.  Use rotate+clear_bits+rotate when useful.

gcc/testsuite/
* gcc.target/riscv/and-synthesis-3.c: New test.

2 days agolibstdc++: Provide defined behavior for unrecognized _Pres_type values.
Tomasz Kamiński [Wed, 24 Jun 2026 09:40:08 +0000 (11:40 +0200)] 
libstdc++: Provide defined behavior for unrecognized _Pres_type values.

If the new _Pres_type values are introduced for given type, they may
lead to unrecognized _Pres_type values, if the TU using them is
linked with TU compiled with older releases, and format from old
TU is selected.

For most of the formatters, the default implementation is used as the
fallback, however __formatter_int and __formatter_fp were treating
that as UB, due to call to __builtin_unreachable in default branch
the switch. This patch addresses above by fallbacking to _Pres_none
behavior in such case.

Note that this for C++20 affects programs using non-Unicode literal
encoding, as __do_vformat_to is exported from the library otherwise,
and thus newest version is always picked.

libstdc++-v3/ChangeLog:

* include/std/format (__formatter_int::format)
(__formatter_fp::format): For unrecognised _M_spec._M_type
values (default branch of switch) fallthrou to _Pres_none.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 days agolibstdc++: Return optional<const _Ex&> from exception_ptr_cast.
Tomasz Kamiński [Thu, 2 Jul 2026 10:20:45 +0000 (12:20 +0200)] 
libstdc++: Return optional<const _Ex&> from exception_ptr_cast.

This implements the remaining part of P3981R2 Better return types
in std::inplace_vector and std::exception_ptr_cast.

For the following functions that are defined out of line in
<optional> header, that header must be included before their
use:
* value - throw bad_optional_access, and would cause cyclic include
  of <exception>,
* transform, and_then - couldn't be used with function that
  returns value (wrapped) in optional, as they would instantiate
  primary specialization
* or_else - reintroduce dependency of bits/invoke.h
* begin/end - dependency or normal_iterator from bits/stl_iterator.h.

The value_or was also defined out of line for consistency, I think
it would be confusing if calling value/transform requires <optional>
include, but not value_or.

This patch also introduce _S_from_ptr function to optional<T&>, that
allows it to be constructed from pointer, without need to check for
null. This function is public, as I believe it will be useful in more
places.

libstdc++-v3/ChangeLog:

* include/bits/optional_ref.h (optional<_Tp&>::_S_from_ptr):
Define.
* include/bits/version.def (exception_ptr_cast): Bump value
to 202603.
* include/bits/version.h: Regenerate.
* libsupc++/exception_ptr.h (exception_ptr_cast)
[__cpp_lib_exception_ptr_cast >= 202603L]: Change return
type to optional<const _Ex&>.
* testsuite/18_support/exception_ptr/exception_ptr_cast.cc:
Modify to handle change in the return type, and add test
for type convertible to optional to reference to that value.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 days agolibstdc++: Extract optional<T&> specialization to bits/optional_ref.h.
Tomasz Kamiński [Wed, 1 Jul 2026 08:47:59 +0000 (10:47 +0200)] 
libstdc++: Extract optional<T&> specialization to bits/optional_ref.h.

This patch extracts optional<_Tp&> specialization to the new
bits/optional_ref.h file. This allows it to be used as return
type of exception_ptr_cast (as required by P3981R2) from <exception>,
without introducing cyclic dependency.

In addition to reference specialization, the definitions of
nullopt_t, nullopt, __is_valid_contained_type..., and _Optional_func
required for it are moved to this new file. We also forward declare
__gnu_cxx::__normal_iterator required for iterator type defintion.

To minimize set of dependencies, the following methods remain
defined (now out of line) in <optional> header:
 * value - requires __throw_bad_optional_access
 * begin/end - requires __normal_iterator
 * then, or_else, transform, constructor from _Optional_func
   - depends on invoke
 * value_or - moved for consistency
Furthemore, to avoid introduction of dependency of <concepts>,
the requires clause for or_else is changed from invocable<_Fn>
to is_invocable_v<_Fn>. The is conforming, as standard specifies
the former in Constraints, and user cannot really on subsumption.

Finally, the in_place_t (and other tags) are extracted into separate
bits/inplace_tags.h header, removing the dependency on bits/utility.h.

libstdc++-v3/ChangeLog:

* include/Makefile.am (bits/optional_ref.h): Add.
* include/Makefile.in: Regenerate.
* include/bits/inplace_tags.h: New file.
* include/bits/utility.h (std::in_place_t, std::in_place)
(std::in_place_type_t, std::in_place_type)
(std::in_place_index_t, in_place_index): Move to
bits/inplace_tags.h.
* include/bits/optional_ref.h: New file.
* include/std/optional (std::nullopt_t, std::nullopt)
(std::__is_valid_contained_type_for_optional)
(std::_Optional_func, std::optional<_Tp&>)
(std::__is_optional_ref_v, std::__optional_ref_base):
Moved to bits/optional_ref.h.
(optional<_Tp&>::begin, optional<_Tp&>::end)
(optional<_Tp&>::value, optional<_Tp&>::value_or)
(optional<_Tp&>::and_then, optional<_Tp&>::transform)
(optional<_Tp&>::optional(_Optional_func<_Fn>, _Value)):
Define out of line.
(optional<_Tp&>::or_else): Define out of line, and
change requires from invocable<_Fn> to is_invocable_v<_Fn>.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 days agoobjective-c,c++: Make declarations language-aware [PR124260].
Iain Sandoe [Thu, 25 Jun 2026 06:21:35 +0000 (07:21 +0100)] 
objective-c,c++: Make declarations language-aware [PR124260].

This is preparation for the main part of the fix of the PR, in this we
make sure to build decls with language-specific data when the compiler
is Objective-c++.  This is because Objective-C metadata are extern "C"
and that needs the lang-specific-data to record it.

PR objc/124260

gcc/objc/ChangeLog:

* objc-act.cc (objc_create_temporary_var, objc_build_struct,
synth_module_prologue, objc_build_internal_const_str_type,
objc_begin_catch_clause, objc_push_parm, synth_self_and_ucmd_args,
start_method_def, objc_start_function,
get_super_receiver): Use build_lang_decl for Objective-C++.
* objc-act.h (objc_build_decl): New.
* objc-gnu-runtime-abi-01.cc (gnu_runtime_01_initialize,
objc_add_static_instance, handle_class_ref): use build_lang_decl
for Objective-C++.
* objc-next-runtime-abi-01.cc (next_runtime_01_initialize,
next_runtime_abi_01_build_const_string_constructor): Likewise.
* objc-next-runtime-abi-02.cc (next_runtime_02_initialize,
next_runtime_abi_02_build_const_string_constructor): Likewise.
* objc-runtime-shared-support.cc (create_field_decl,
start_var_decl): Likewise.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2 days agoMake BB SLP costing more verbose
Richard Biener [Fri, 3 Jul 2026 11:18:43 +0000 (13:18 +0200)] 
Make BB SLP costing more verbose

The following also dumps the costs for parts of the SLP graph that
are associated with another loop when there's one that was not
profitable.  It also prints markers to where scalar/vector parts
start for easier debugging.

* tree-vect-slp.cc (vect_bb_vectorization_profitable_p): Make
profitabilty decision easier to debug.

2 days agotree-optimization: fold memset with length in [0, 1] to conditional store [PR102202]
Naveen [Fri, 3 Jul 2026 12:24:04 +0000 (05:24 -0700)] 
tree-optimization: fold memset with length in [0, 1] to conditional store [PR102202]

The patch improves memset optimization when the length is known to be 0 or 1.
It uses Ranger information to recognize such cases, shrink-wraps the call on
the zero-length case and replaces the one-byte case with a direct byte store.
It also extends gimple_fold_builtin_memset to handle Ranger-proven singleton
lengths not just integer constants.

gcc/ChangeLog:
PR tree-optimization/102202
* tree-call-cdce.cc: Include "tree-ssanames.h", "gimple-fold.h".
(len_has_boolean_range_p): New function.
(can_shrink_wrap_len_p): New function.
(gen_zero_len_conditions): New function.
(shrink_wrap_len_call): New function.
(shrink_wrap_conditional_dead_built_in_calls): Dispatch to
shrink_wrap_one_memset_call for memset calls eligible for the [0, 1]
length transform, ahead of the generic LHS and range-test paths.
(pass_call_cdce::execute): Collect memset calls satisfying
can_shrink_wrap_memset_p as shrink-wrap candidates.

gcc/testsuite/ChangeLog:
PR tree-optimization/102202
* gcc.dg/pr102202-1.c: New test.
* gcc.dg/pr102202.c: New test.
* gcc.target/aarch64/pr100518.c: Modify to handle the warning.

Signed-off-by: Naveen <naveen.siddegowda@oss.qualcomm.com>
3 days agoaarch64: Fold merging svextb/svexth/svextw with a ptrue to AND [PR120027]
Kyrylo Tkachov [Sun, 28 Jun 2026 17:48:28 +0000 (10:48 -0700)] 
aarch64: Fold merging svextb/svexth/svextw with a ptrue to AND [PR120027]

For unsigned types the svextb, svexth and svextw intrinsics are plain
zero-extends, which the expander already lowers to a bitwise AND with a
constant mask.  The any/don't-care (_x) form and the zeroing (_z) form with
an all-true predicate therefore compile to a single unpredicated AND, but
the merging (_m) form with an all-true predicate did not: it kept the
inactive argument and produced a predicated UXT.  For example

  svuint64_t f (svuint64_t x, svuint64_t y)
  { return svextb_m (y, svptrue_b64 (), x); }

compiled to

ptrue p3.b, all
mov z31.d, z0.d
movprfx z0, z1
uxtb z0.d, p3/m, z31.d
ret

where a single

and z0.d, z0.d, #0xff
ret

is sufficient, because the all-true predicate makes the inactive operand
dead.

Give svext_bhw_impl a gimple fold that rewrites the unsigned merging form
with an all-true predicate to a BIT_AND_EXPR.  Signed types (which use a
real sign-extend instruction), partial predicates and pfalse predicates are
left to the existing handling, as is the _x form, which the expander already
turns into an AND.

Bootstrapped and tested on aarch64-none-linux-gnu.

PR target/120027

gcc/ChangeLog:

* config/aarch64/aarch64-sve-builtins-base.cc (svext_bhw_impl::fold):
New member function.  Fold the unsigned svextb/svexth/svextw
intrinsics to a bitwise AND when the merging form has an all-true
predicate.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve/acle/general/pr120027.c: New test.

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
3 days agofortran: Don't reuse original descriptors for packed arrays [PR125998]
Mikael Morin [Fri, 3 Jul 2026 09:16:04 +0000 (11:16 +0200)] 
fortran: Don't reuse original descriptors for packed arrays [PR125998]

Don't try to reuse the original descriptor when creating a descriptor
for packed data in gfc_conv_array_parameter.

For a non-transposed array (anything but TRANSPOSE(VAR)) the original
descriptor was reused, and only the data was reset to the result of
packing.  This is wrong because the original descriptor can be
non-contiguous, it can't be correct as the descriptor of packed data.
In the testcase, a dummy array associated with a transposed array actual
argument matches this case.  Reusing the descriptor in that case would
cause the packed data to be used transposed, that is not in the normal
array element order.  This change removes this case to always fallback
to what was previously the transposed case (see next).

For the transposed case (TRANSPOSE(VAR)), the full dimensions of the
original untransposed descriptor were reused (in other words, the
dimensions of VAR).  This is wrong because packing doesn't change the
shape, so the packed array should have the same bounds as the bounds
of TRANSPOSE(VAR), not the same bounds as VAR.  Reusing the strides of
an unpacked array for a packed array doesn't seem right either.  This
change uses matching dimensions when copying from the original
descriptor, and only copies the lbound and ubound.  The strides are
recalculated.  And then the offset is recalculated as well (even though
I couldn't find a testcase where it made a difference).

PR fortran/97592
PR fortran/125998

gcc/fortran/ChangeLog:

* trans-array.cc (gfc_conv_array_parameter): Always create a new
descriptor.  Copy lbound and ubound from the original descriptor
using matching dimension indexes.  Recalculate stride and
offset.

gcc/testsuite/ChangeLog:

* gfortran.dg/contiguous_17.f90: New test.

3 days agomiddle-end: Handle variable-length vector types in store_constructor
Tamar Christina [Fri, 3 Jul 2026 08:15:01 +0000 (09:15 +0100)] 
middle-end: Handle variable-length vector types in store_constructor

Currently vec_init does not support VLA vec_init and we instead fall back to
storing piecewise through memory.

However there's no defined semantics for this.  This patch adds the semantics
that for VLA constructors the vector has to be cleared with zero before
piecewise being constructed from scalar elements.  This means unspecified
elements are initialized to zero.

Without this patch

#include <arm_sve.h>

svint32_t __attribute__ ((noipa))
func_init4 (int32_t a, int32_t b, int32_t c)
{
  svint32_t temp = {a, b, c};
  return temp;
}

compiles to:

func_init4:
        addvl   sp, sp, #-3
        movi    d30, #0
        str     z30, [sp, #2, mul vl]
        addvl   x3, sp, #2
        str     w0, [x3]
        addvl   x0, sp, #1
        add     x0, x0, 4
        ldr     z31, [sp, #2, mul vl]
        str     z31, [sp, #1, mul vl]
        str     w1, [x0]
        ldr     z31, [sp, #1, mul vl]
        str     z31, [sp]
        str     w2, [sp, 8]
        ldr     z0, [sp]
        addvl   sp, sp, #3
        ret

and with the patch

func_init4:
        fmov    s0, w2
        fmov    s0, s0
        insr    z0.s, w1
        insr    z0.s, w0
        ret

note that this is still not optimal as the

        fmov    s0, s0

that's doing the zero-ing of the vector is not actually needed since the
transfer instruction

        fmov    s0, w2

already zeros the destination SVE register.  But this is an AArch64 deficiency
that will be dealt with in the backend.

the optimal codegen here is:

 func_init4:
        orr     x1, x1, x2, lsl 32
        fmov    d0, x1
        insr    z0.s, w0
        ret

Co-Authored-By: Chris Bazley <Chris.Bazley@arm.com>
gcc/ChangeLog:

* expr.cc (store_constructor): Handle VLA vec_init support and generic
fall through piecewise copy.
* doc/md.texi: Document change

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve/copsi.c: New test.

3 days agoSH: Add test case for PR81426
Oleg Endo [Fri, 3 Jul 2026 06:05:54 +0000 (15:05 +0900)] 
SH: Add test case for PR81426

gcc/testsuite/ChangeLog:

PR target/81426
* gcc.target/sh/pr81426.c: New test.

3 days agoSH: Add another testcase for PR 34777
Oleg Endo [Fri, 3 Jul 2026 05:41:07 +0000 (14:41 +0900)] 
SH: Add another testcase for PR 34777

gcc/testsuite/ChangeLog:

PR target/34777
* gcc.target/sh/torture/pr34777-1.c: New test.

3 days agoSH: Add another test case for LRA
Oleg Endo [Fri, 3 Jul 2026 05:13:29 +0000 (14:13 +0900)] 
SH: Add another test case for LRA

gcc/testsuite/ChangeLog:

PR target/124778
* gcc.target/sh/torture/pr124778.c: New test.

3 days ago[RISC-V] Improve IOR/XOR synthesis for expensive constant cases
Jeff Law [Fri, 3 Jul 2026 04:36:47 +0000 (22:36 -0600)] 
[RISC-V] Improve IOR/XOR synthesis for expensive constant cases

So much like the changes to add_synthesis, this adjusts xor/ior synthesis to
use riscv_integer_cost rather than riscv_const_insns.  For those that didn't
read the add_synthesis patch, what happens is riscv_const_insns returns 0 for
constants requiring more than 3 insns to synthesize.  So imagine if the
original constant had cost 5, it's bit inversion has cost 4.  Both get
converted to "0" because they're over the maximal value and thus we can't
distinguish between them and we fail to use C' with XNOR, ORN or ANDN to
improve the resulting code.

The constants here were actually from the AND cases, but given the common ISA
capability and GCC structure I suspected the AND cases would apply to IOR/XOR,
and they do.

Tested without regression on riscv32-elf and riscv64-elf, also bootstrapped and
regression tested on the k3 and c920.  I'll obviously be waiting for pre-commit
CI to do its thing before moving forward.

gcc/

* config/riscv/riscv.cc (synthesize_ior_xor): Use riscv_integer_cost
rather than riscv_const_insns.

gcc/testsuite

* gcc.target/riscv/xor-synthesis-4.c: New test.

3 days agoregenerate sh.opt.urls, vas.opt.urls
Oleg Endo [Fri, 3 Jul 2026 04:05:03 +0000 (13:05 +0900)] 
regenerate sh.opt.urls, vas.opt.urls

gcc/ChangeLog:
* config/sh/sh.opt.urls: Renegerate.
* config/vax/vax.opt.urls: Renegerate.

3 days agoSH: Switch to LRA permanently
Oleg Endo [Wed, 25 Sep 2024 00:47:25 +0000 (09:47 +0900)] 
SH: Switch to LRA permanently

gcc/ChangeLog:

PR target/55212
* config/sh/sh.opt (mlra): Ignore option but keep it around
for compatibility.
* config/sh/sh.cc (TARGET_LRA_P): Remove.
(sh_lra_p): Move definition ...
* config/sh/sh-protos.h (sh_lra_p): ... here.  Always return true.
* doc/invoke.texi: Remove mention of -mlra for SH.

3 days agoSH: Add movv2sf patterns.
Oleg Endo [Mon, 29 Jun 2026 04:38:30 +0000 (13:38 +0900)] 
SH: Add movv2sf patterns.

The movv2sf is split into multiple movsf after RA.  Without the extra patterns
LRA will get stuck in a reload cycle.  At the moment the primary use cases of
V2SF mode is the FSCA insn.

gcc/ChangeLog:
PR target/55212
* config/sh/sh.md (movv2sf, movv2sf_i, unnamed splits): New patterns.
* config/sh/sh.cc (sh_hard_regno_mode_ok): Allow V2SF only in fp-regs.
(sh_max_mov_insn_displacement): Return 0 for any float mode.

3 days agoSH: Reduce R0 live ranges around R0-constrained move insns for LRA
Kaz Kojima [Sun, 6 Oct 2024 03:34:55 +0000 (12:34 +0900)] 
SH: Reduce R0 live ranges around R0-constrained move insns for LRA

Some move and extend patterns can result in longer R0 live ranges and LRA has
trouble dealing with those.  This tries to reduce the likelihood of failures by
using insn variants that use an explicit R0-clobber and splitting the move into
two insns.  This tricks LRA into thinking it's using non-R0 for the operand.

gcc/ChangeLog:
PR target/55212
* config/sh/sh.md (extend<mode>si2_short_mem_disp_z): New
insn_and_split.
(extend<mode>si2): Use it for LRA.
(mov<mode>_store_mem_index, *mov<mode>_store_mem_index): New patterns.
(mov<mode>): Use it for LRA.
(movsf_ie_store_mem_index, movsf_ie_load_mem_index,
*movsf_ie_store_mem_inde, *movsf_ie_load_mem_index): New patterns.
(movsf): Use it for LRA.

3 days agoSH: Adjust fp-reg related move insns to work with LRA
Kaz Kojima [Tue, 23 Jun 2026 02:26:21 +0000 (11:26 +0900)] 
SH: Adjust fp-reg related move insns to work with LRA

On SH fp move insns usually don't support displacement addressing modes.
Instead it needs to use additional match_scratch constraints which LRA has
trouble dealing with.  Split movsf_ie_ra into several new patterns to remove
match_scratch as a mitigation.  For movdf constant loads add a new sub-pattern.
Use a new pattern movsf_ie_rffr to handle movsf multiword subregs and disable
movsf_ie_ra for reg from/to subreg of SImode.

gcc/ChangeLog:

PR target/55212
* config/sh/predicates.md (pc_relative_load_operand): New predicate.
* config/sh/sh-protos.h (sh_movsf_ie_ra_split_p): Remove.
(sh_movsf_ie_y_split_p): New proto.
(sh_movsf_ie_subreg_multiword_p): New proto.
* config/sh/sh.cc: (sh_movsf_ie_ra_split_p): Remove.
(sh_movsf_ie_y_split_p): New function.
(sh_movsf_ie_subreg_multiword_p): New function.
(broken_move): Take movsf_ie_ra into account for fldi cases.
* config/sh/sh.md (movdf_i4_F_z): New insn.
(movdf): Use it when expanding.
(movsf_ie_ra): Use define_insn instead of define_insn_and_split.
Adjust alternatives.
(movsf_ie_rffr): New insn_and_split.
(movsf_ie_F_z, movsf_ie_Q_z, movsf_ie_y): New insns.
(movsf): Use new patterns when expanding.

3 days agoDaily bump.
GCC Administrator [Fri, 3 Jul 2026 00:16:37 +0000 (00:16 +0000)] 
Daily bump.

3 days agofortran: [PR126018] Fix rejects character function invocation as stop code
Jerry DeLisle [Wed, 1 Jul 2026 21:03:23 +0000 (14:03 -0700)] 
fortran: [PR126018] Fix rejects character function invocation as stop code

Expressions used in stop codes can be functions as long as they resolve to
integer or character.

PR fortran/126018

gcc/fortran/ChangeLog:

* match.cc (gfc_match_stopcode): Adjust the f2008 error check.If the
STOP code expr type is unknown, do not error. It will be checked in
gfc_resolve_code.
* resolve.cc (gfc_resolve_code): Add checks for EXEC_STOP and
EXEC_ERROR_STOP.

gcc/testsuite/ChangeLog:

* gfortran.dg/stop_function_code_1.f90: New test.

3 days agoAArch64: Cap suggested unroll factor for small known-niters loops
Pengfei Li [Mon, 29 Jun 2026 08:30:45 +0000 (08:30 +0000)] 
AArch64: Cap suggested unroll factor for small known-niters loops

The AArch64 backend can suggest an unroll factor to the vectorizer in
order to expose more ILP. However, in some cases the suggested value is
larger than needed. For the test cases added by this patch, the AArch64
backend suggests an unroll factor of 4, but the loops only need 1 or 2
SVE vector iterations respectively to cover their 10 or 20 scalar
iterations.

This patch caps the suggested unroll factor with CEIL (niters, VF) for
small known-niters loops. CEIL is used rather than truncating division
so that the completely unrolled vector loop still covers all scalar
iterations. Reducing the unroll factor below the number of required
vector iterations could require a separate epilogue loop and lead to
worse code generation.

Bootstrapped and tested on aarch64-linux-gnu.

gcc/ChangeLog:

* config/aarch64/aarch64.cc
(aarch64_vector_costs::determine_suggested_unroll_factor): Add a
loop_vec_info parameter.
(determine_suggested_unroll_factor): Cap the suggested unroll for
small-niters loops.
(aarch64_vector_costs::finish_cost): Pass loop_vinfo to
determine_suggested_unroll_factor.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve/vect-unroll-1.c: New test.
* gcc.target/aarch64/sve/vect-unroll-2.c: New test.

3 days ago[RISC-V] Improve ADD synthesis
Jeff Law [Thu, 2 Jul 2026 17:41:09 +0000 (11:41 -0600)] 
[RISC-V] Improve ADD synthesis

So testing passed for the V2 of this patch, but there were some minor issues I
felt needed to be addressed.

First in the new pattern, we can use %S to output the right value rather than
recomputing it ourselves.  Second the test was tightend up slightly by adding
missing escapes.  Finally a typos in the ChangeLog and a comment in bitmanip.md
was fixed.  I didn't go through a full test cycle on those changes, but I did
test those on riscv32-elf and riscv64-elf with no regressions.

Attached is the final patch I'm pushing to the trunk.

--

So I instrumented the 3 ALU synthesis routines and built 502.gcc, then fed
those results into some python code that allows me to compare instruction
counts and total size for tests across LLVM and GCC.  Naturally the idea was to
see if there were cases we should handle but were missing.

This fixes cases in add_synthesis.  First we weren't utilizing add.uw, so
there's a relatively small set of cases where we can take the original constant
C, sign extend it from 32 to 64 bit resulting in C'.  If C' is cheaper to
synthesize than C, then we can load up C' into a GPR, then use add.uw.  This
(of course) requires the upper 32 bits of C to be zero and bit 31 to be on.

The second case is for INT_MIN.  Adding INT_MIN to a register ultimately just
flips the uppermost bit and thus can be implemented with a binvi.  Combine (of
course) collapses the bit inversion case back into arithmetic.  Given the
result is just a binvi, this patch recognizes that special case as a new
pattern. That has a secondary effect of fixing the xfail for xor-synthesis-2.c
which was failing for precisely this reason.

While exploring the logical space it also came to light that we should be using
riscv_integer_cost rather than riscv_const_insns. The latter clamps at 3.  So
if we had C with cost 5 and C' with cost 4 and we can use either, we really
want to use C', but didn't have a way to make that selection.  Using
riscv_integer_cost resolves that *and* we generate less junk RTL since we don't
have to call GEN_INT so often.  I haven't included  testcase for that in this
patch, but definitely will on the ior/xor/and space.

At this time the synthesis side for addition looks good relative to LLVM, but
sometimes combine is going to undo its work.  I checked every case from that
set where GCC has more instructions than LLVM and each and every one was a
scenario where combine+mvconst_internal undid the early synthesis work.  So
just more reasons to keep pushing on that problem.  I did add a special pattern
for the INT_MIN case.  That was trivial and since it collapses to a single insn
with Zbs it seemed like the right thing to do in case combine discovers it from
some other path.

Both GCC and LLVM seem to be missing shNadd.uw support; after some head-banging
I did manage to characterize some cases where shNadd.uw was unique enough to be
useful.  That exploration was ongoing when the latest test run fired up so that
support will land in a later patch.

I mentioned my evaluation also looked at code size differences. That brings in
general constant synthesis and there's a significant cluster of cases where
LLVM consistently does better (li|lui+shift sometimes encodes better than
lui+addi).  That's already being tracked in bugzilla.

The other insight from this effort is that ADD, IOR, XOR are relatively minor
when compared to AND.  I'm filtering out simm12 constants because those are
trivially handled.  What was left was ~1k unique constants passed to AND.  ~100
to ADD and ~100 to IOR/XOR.  Point being the larger effort towards AND handling
seems more likely to pay dividends.  Given the larger set of primitives for AND
it's no surprise we've already spent considerably more effort there.

Tested on riscv32-elf and riscv64-elf with no regressions. Bootstrapped and
regression tested on the K3 and c920 platforms. Waiting on pre-commit CI before
pushing.

gcc/

* config/riscv/bitmanip.md (xor_for_plus_minint): New pattern.
* config/riscv/riscv.cc (synthesize_add): Handle INT_MIN as
bit inversion.  Add support for add.uw.  Use riscv_integer_cost
rather than riscv_const_insns.
(synthesize_add_extended): Use riscv_integer_cost rather than
riscv_const_insns.

gcc/testsuite/

* gcc.target/riscv/add-synthesis-3.c: New test.
* gcc.target/riscv/xor-synthesis-2.c: No longer xfail.

3 days agoc++/reflection: members_of: skip built-ins [PR125819]
Marek Polacek [Thu, 18 Jun 2026 19:08:00 +0000 (15:08 -0400)] 
c++/reflection: members_of: skip built-ins [PR125819]

Currently, we include all the built-ins like __builtin_fdimf32x in
the result of members_of.  We probably should skip them.  This patch
uses DECL_IS_UNDECLARED_BUILTIN so that we skip __builtin_abs but
include abs.

On ^^:: this reduces the # of elements from 2591 to 651.

PR c++/125819

gcc/cp/ChangeLog:

* reflect.cc (namespace_members_of): Skip
DECL_IS_UNDECLARED_BUILTIN decls.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/members_of17.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 days agolibstdc++: implement LWG3662 basic_string::append/assign(NTBS, pos, n) suboptimal
Yuao Ma [Thu, 2 Jul 2026 12:32:17 +0000 (20:32 +0800)] 
libstdc++: implement LWG3662 basic_string::append/assign(NTBS, pos, n) suboptimal

This patch implements LWG3662 for both ABIs of strings.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h(append, assign): Add new
overloads.
* include/bits/cow_string.h(append, assign): Ditto.
* testsuite/21_strings/basic_string/modifiers/append/char/2.cc:
Test new overloads.
* testsuite/21_strings/basic_string/modifiers/append/wchar_t/2.cc:
Ditto.
* testsuite/21_strings/basic_string/modifiers/assign/char/3.cc:
Ditto.
* testsuite/21_strings/basic_string/modifiers/assign/wchar_t/3.cc:
Ditto.

3 days agoAArch64: Enable SVE AES instructions in streaming mode with FEAT_SSVE_AES
Sivan Shani [Thu, 2 Jul 2026 13:10:18 +0000 (13:10 +0000)] 
AArch64: Enable SVE AES instructions in streaming mode with FEAT_SSVE_AES

FEAT_SSVE_AES makes the existing SVE AES instructions (AESE, AESD, AESMC,
AESIMC) available in Streaming SVE mode.

gcc/ChangeLog:

* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins):
Check for SVE2 and SVE_AES directly.
* config/aarch64/aarch64-sve-builtins-sve2.def (REQUIRED_EXTENSIONS):
Make AES builtins streaming-compatible with SSVE AES.
* config/aarch64/aarch64-sve2.md: Use TARGET_SVE_AES instead of
TARGET_SVE2_AES.
* config/aarch64/aarch64.h (TARGET_SVE2_AES): Rename to...
(TARGET_SVE_AES): Add support for SSVE AES.
* config/aarch64/iterators.md: Use TARGET_SVE2 for VNx2DI
PMULL pair mode.

gcc/testsuite/ChangeLog:

* g++.target/aarch64/sve/aarch64-ssve.exp: Test SVE AES intrinsics
as streaming-compatible with +ssve-aes.
* gcc.target/aarch64/sve2/acle/asm/aesd_u8.c: Use +ssve-aes for
streaming-compatible tests.
* gcc.target/aarch64/sve2/acle/asm/aese_u8.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/aesimc_u8.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/aesmc_u8.c: Likewise.
* lib/target-supports.exp: Test aes intrinsics in streaming mode.

3 days agoaarch64: Fix tls debuginfo missing location info [PR97344]
Srinath Parvathaneni [Thu, 2 Jul 2026 13:51:07 +0000 (13:51 +0000)] 
aarch64: Fix tls debuginfo missing location info [PR97344]

This patch fixes the missing debuginfo for the TLS variables by emitting
".xword %dtprel(symbol)" along with DW_AT_location in .debug_info section.

Support for the assembler directive ".xword %dtprel(symbol)" was recently
introduced. To prevent assembler errors when building GCC with older
versions of binutils, the patch adds a configure check that skips these
changes if the assembler does not support ".xword %dtprel(symbol)".

Related ABI changes are proposed here [1].
[1] https://github.com/ARM-software/abi-aa/pull/330

gcc/ChangeLog:

PR target/97344
* config.in: Re-generate.
* config/aarch64/aarch64.cc (aarch64_output_dwarf_dtprel): Define
function.
(TARGET_ASM_OUTPUT_DWARF_DTPREL): Define macro.
* configure: Re-generate.
* configure.ac: Add assemler check for dtprel relocation.

gcc/testsuite/ChangeLog:

PR target/97344
* gcc.target/aarch64/pr97344.c: New test.
* lib/target-supports.exp (aarch64_gas_has_dtprel_reloc): Add new target
check.

4 days agolibstdc++: Cleanup trailing whitespace from r16-8429-g8b95d5f5b22621.
Tomasz Kamiński [Thu, 2 Jul 2026 10:29:36 +0000 (12:29 +0200)] 
libstdc++: Cleanup trailing whitespace from r16-8429-g8b95d5f5b22621.

libstdc++-v3/ChangeLog:

* include/bits/version.def: Remove trailing whitespaces.
* include/std/inplace_vector: Likewise.
* testsuite/23_containers/inplace_vector/modifiers/single_insert.cc:
Likewise.

4 days agoarm: make the SHAPE macro take a trailing semicolon
Richard Earnshaw [Wed, 1 Jul 2026 12:46:56 +0000 (13:46 +0100)] 
arm: make the SHAPE macro take a trailing semicolon

The SHAPE macro is used like a statement, but as currently written does
not take a trailing semicolon.  This can be confusing for context-sensitive
editors as it looks like a statement, but isn't really.  Fix this by
tweaking the macro to use a no-op trailing statement that now requires
a semicolon.  The ATTRIBUTE_UNUSED isn't really needed but makes the
intent clearer.

gcc/ChangeLog:

* config/arm/arm-mve-builtins-shapes.cc (SHAPE): Add a
trailing statement that lacks a semicolon.  Add that to all
existing uses.

4 days agoaarch64: make the SHAPE macro take a trailing semicolon
Richard Earnshaw [Wed, 1 Jul 2026 12:43:24 +0000 (13:43 +0100)] 
aarch64: make the SHAPE macro take a trailing semicolon

The SHAPE macro is used like a statement, but as currently written does
not take a trailing semicolon.  This can be confusing for context-sensitive
editors as it looks like a statement, but isn't really.  Fix this by
tweaking the macro to use a no-op trailing statement that now requires
a semicolon.  The ATTRIBUTE_UNUSED isn't really needed but makes the
intent clearer.

gcc/ChangeLog:

* config/aarch64/aarch64-sve-builtins-shapes.cc (SHAPE): Add a
trailing statement that lacks a semicolon.  Add that to all
existing uses.

4 days agobuild: Simplify in-tree-gld version checks
Rainer Orth [Thu, 2 Jul 2026 09:05:10 +0000 (11:05 +0200)] 
build: Simplify in-tree-gld version checks

gcc/configure.ac contains many inline checks if an in-tree gld is of a
version recent enough to enable some feature.

The checks are highly repetitive and hard to read, so this patch
replaces them by two shell functions, gcc_fn_gld_min_version and
gcc_fn_gld_elf_min_version.  Both configure.ac and the scripts generated
by autoconf already heavily use shell functions, so they are no
portability problem.

Tested on x86_64-pc-linux-gnu as follows:

* Bootstrap with out-of-tree gas/gld.

* Non-bootstrap builds with

** the bundled gas/gld (2.44),

** in-tree binutils trunk (2.46.50), and

** fake in-tree builds where bfd/configure and ld/configure were hacked
   to pose as gld 2.9 and 2.16 respecively.

Initially a full in-tree build was run.  Afterwards, the gcc directory
was moved aside, recreated with make configure-gcc, and the resulting
versions of auto-host.h compared.  Besides, the differences between the
various linker versions were as expected.

2026-05-08  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc:
* configure.ac (gcc_fn_gld_min_version): New function.
(gcc_fn_gld_elf_min_version): Likewise.
Use them.
* configure: Regenerate.

4 days agofortran: array descriptor: Move array growth function [PR122521]
Mikael Morin [Thu, 2 Jul 2026 08:45:09 +0000 (10:45 +0200)] 
fortran: array descriptor: Move array growth function [PR122521]

Move gfc_grow_array, a descriptor growth function used in array constructor
descriptors initialisation, to trans-descriptor.cc.

PR fortran/122521

gcc/fortran/ChangeLog:

* trans-array.cc (gfc_grow_array): Move function ...
* trans-descriptor.cc (gfc_grow_array): ... to this file.
* trans-descriptor.h (gfc_grow_array): Add declaration.

4 days agofortran: array descriptor: Move descriptor copy function [PR122521]
Mikael Morin [Thu, 2 Jul 2026 08:44:59 +0000 (10:44 +0200)] 
fortran: array descriptor: Move descriptor copy function [PR122521]

Move copy_descriptor in trans-stmt.cc to gfc_copy_descriptor in
trans-descriptor.cc.

PR fortran/122521

gcc/fortran/ChangeLog:

* trans-descriptor.h (gfc_copy_descriptor): Add declaration.
* trans-stmt.cc (trans_associate_var): Update caller.
(copy_descriptor): Rename function and move it ...
* trans-descriptor.cc (gfc_copy_descriptor): ... here.

4 days agofortran: array descriptor: Move bound shift utility function [PR122521]
Mikael Morin [Thu, 2 Jul 2026 08:44:47 +0000 (10:44 +0200)] 
fortran: array descriptor: Move bound shift utility function [PR122521]

Move gfc_conv_shift_descriptor_lbound to trans-descriptor.cc

PR fortran/122521

gcc/fortran/ChangeLog:

* trans-array.cc (gfc_conv_shift_descriptor_lbound): Move
function ...
* trans-descriptor.cc (gfc_conv_shift_descriptor_lbound): ... to
this file.
* trans-array.h (gfc_conv_shift_descriptor_lbound): Move
declaration ...
* trans-descriptor.h (gfc_conv_shift_descriptor_lbound): ... to this
file.

4 days agofortran: array descriptor: Move size and cosize functions [PR122521]
Mikael Morin [Thu, 2 Jul 2026 08:44:36 +0000 (10:44 +0200)] 
fortran: array descriptor: Move size and cosize functions [PR122521]

Move the gfc_conv_descriptor_size and gfc_conv_descriptor_cosize
functions from trans-array.cc to trans-descriptor.cc.

PR fortran/122521

gcc/fortran/ChangeLog:

* trans-array.cc: (gfc_conv_descriptor_size_1,
gfc_conv_descriptor_size, gfc_conv_descriptor_cosize): Move
functions ...
* trans-descriptor.cc (gfc_conv_descriptor_size_1,
gfc_conv_descriptor_size, gfc_conv_descriptor_cosize): ... to this
file.
* trans-array.h (gfc_conv_descriptor_size,
gfc_conv_descriptor_cosize): Move ...
* trans-descriptor.h (gfc_conv_descriptor_size,
gfc_conv_descriptor_cosize): ... here.

4 days agofortran: array descriptor: Move null factory function [PR122521]
Mikael Morin [Thu, 2 Jul 2026 08:44:25 +0000 (10:44 +0200)] 
fortran: array descriptor: Move null factory function [PR122521]

Move null descriptor factory function to trans-descriptor.cc.

PR fortran/122521

gcc/fortran/ChangeLog:

* trans-array.cc (DATA_FIELD, OFFSET_FIELD, DTYPE_FIELD, SPAN_FIELD,
DIMENSION_FIELD, CAF_TOKEN_FIELD, STRIDE_SUBFIELD, LBOUND_SUBFIELD,
UBOUND_SUBFIELD): Remove preprocessor constants.
(gfc_build_null_descriptor): Move function to ...
* trans-descriptor.cc (gfc_build_null_descriptor): ... this file.
* trans-array.h (gfc_build_null_descriptor): Move declaration to ...
* trans-descriptor.h (gfc_build_null_descriptor): ... this file.

4 days agofortran: array descriptor: Move debug info generation function [PR122521]
Mikael Morin [Thu, 2 Jul 2026 08:44:11 +0000 (10:44 +0200)] 
fortran: array descriptor: Move debug info generation function [PR122521]

Move the gfc_get_descriptor_offsets_for_info function, which is used
to build debug info of array descriptors, to the trans-descriptor.cc
file.

PR fortran/122521

gcc/fortran/ChangeLog:

* trans-array.cc (gfc_get_descriptor_offsets_for_info): Move
function ...
* trans-descriptor.cc (gfc_get_descriptor_offsets_for_info): ...
to this file.
* trans-array.h (gfc_get_descriptor_offsets_for_info): Move
declaration ...
* trans-descriptor.h (gfc_get_descriptor_offsets_for_info): ...
to this file.
* trans-types.cc: Include trans-descriptor.h.

4 days agofortran: array descriptor: Move accessor functions to a separate file [PR122521]
Mikael Morin [Thu, 2 Jul 2026 08:43:58 +0000 (10:43 +0200)] 
fortran: array descriptor: Move accessor functions to a separate file [PR122521]

Move existing descriptor getters and setters to a new file.

PR fortran/122521

gcc/fortran/ChangeLog:

* Make-lang.in (F95_OBJS): Add fortran/trans-descriptor.o to the
list of objects.
* trans-array.cc: Include new header.
(gfc_get_descriptor_field, gfc_conv_descriptor_data_get,
gfc_conv_descriptor_data_set, gfc_conv_descriptor_offset,
gfc_conv_descriptor_offset_get, gfc_conv_descriptor_offset_set,
gfc_conv_descriptor_dtype, gfc_conv_descriptor_span,
gfc_conv_descriptor_span_get, gfc_conv_descriptor_span_set,
gfc_conv_descriptor_rank, gfc_conv_descriptor_version,
gfc_conv_descriptor_elem_len, gfc_conv_descriptor_attribute,
gfc_conv_descriptor_type, gfc_get_descriptor_dimension,
gfc_conv_descriptor_dimension, gfc_conv_descriptor_token,
gfc_conv_descriptor_subfield, gfc_conv_descriptor_stride,
gfc_conv_descriptor_stride_get, gfc_conv_descriptor_stride_set,
gfc_conv_descriptor_lbound, gfc_conv_descriptor_lbound_get,
gfc_conv_descriptor_lbound_set, gfc_conv_descriptor_ubound,
gfc_conv_descriptor_ubound_get, gfc_conv_descriptor_ubound_set):
Move functions ...
* trans-descriptor.cc: ... to this new file.
* trans-array.h (gfc_get_descriptor_offsets_for_info): Fix
long line in declaration.
(gfc_conv_descriptor_data_get, gfc_conv_descriptor_offset_get,
gfc_conv_descriptor_span_get, gfc_conv_descriptor_dtype,
gfc_conv_descriptor_rank, gfc_conv_descriptor_elem_len,
gfc_conv_descriptor_version, gfc_conv_descriptor_attribute,
gfc_conv_descriptor_type, gfc_get_descriptor_dimension,
gfc_conv_descriptor_stride_get, gfc_conv_descriptor_lbound_get,
gfc_conv_descriptor_ubound_get, gfc_conv_descriptor_token,
gfc_conv_descriptor_data_set, gfc_conv_descriptor_offset_set,
gfc_conv_descriptor_span_set, gfc_conv_descriptor_stride_set,
gfc_conv_descriptor_lbound_set, gfc_conv_descriptor_ubound_set):
Move declarations ...
* trans-descriptor.h: ... to this new file.
* trans-decl.cc: Include new header.
* trans-expr.cc: Likewise.
* trans-intrinsic.cc: Likewise.
* trans-io.cc: Likewise.
* trans-openmp.cc: Likewise.
* trans-stmt.cc: Likewise.
* trans.cc: Likewise.

4 days agolibstdc++: Refactor preprocessor condition for Windows symlinks
Jonathan Wakely [Wed, 1 Jul 2026 18:46:42 +0000 (19:46 +0100)] 
libstdc++: Refactor preprocessor condition for Windows symlinks

Only define windows_create_symlink when it will actually be functional,
and adjust its callers to not use it unless it's defined. This matches
the form of windows_read_symlink_handle and its caller.

libstdc++-v3/ChangeLog:

* src/c++17/fs_ops.cc (windows_create_symlink): Adjust
preprocessor conditions to not define this at all unless
SYMBOLIC_LINK_FLAG_DIRECTORY is defined.
(fs::create_directory_symlink): Adjust preprocessor conditions
accordingly.
(fs::create_symlink): Likewise.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 days agolibstdc++: Use atomic store for num_leap_seconds in tzdb.cc
Jonathan Wakely [Wed, 1 Jul 2026 18:44:41 +0000 (19:44 +0100)] 
libstdc++: Use atomic store for num_leap_seconds in tzdb.cc

Although NumLeapSeconds::set_locked is always called with list_mutex()
locked, if ATOMIC_INT_LOCK_FREE == 2 then readers ofthe variable will be
loading it without list_mutex() locked. We need to use an atomic store
even if the lock is held.

Also simplify the non-atomic version of NumLeapSeconds::set to just set
the variable instead of indirecting via set_locked.

libstdc++-v3/ChangeLog:

* src/c++20/tzdb.cc (_Node::NumLeapSeconds::set_locked)
[ATOMIC_INT_LOCK_FREE == 2]: Use atomic store.
(_Node::NumLeapSeconds::set) [ATOMIC_INT_LOCK_FREE != 2]: Set
value directly instead of calling set_locked.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 days agoOpenMP: support for uses_allocators clause: Fix libgomp build for PTX < 4.1
Thomas Schwinge [Wed, 1 Jul 2026 21:24:46 +0000 (23:24 +0200)] 
OpenMP: support for uses_allocators clause: Fix libgomp build for PTX < 4.1

Fix-up for commit 7a8f98b48104ccf10c6dceccc51b70de69288eaa
"OpenMP: support for uses_allocators clause", which regressed libgomp build for
PTX < 4.1 configurations:

    In file included from [...]/libgomp/config/nvptx/allocator.c:48:
    [...]/libgomp/config/nvptx/allocator.c:47:28: error: ‘__nvptx_lowlat_realloc’ defined but not used [-Werror=unused-function]
       47 | #define BASIC_ALLOC_PREFIX __nvptx_lowlat
          |                            ^~~~~~~~~~~~~~
    [...]/libgomp/config/nvptx/../../basic-allocator.c:63:27: note: in definition of macro ‘fn1’
       63 | #define fn1(prefix, name) prefix ## _ ## name
          |                           ^~~~~~
    [...]/libgomp/config/nvptx/../../basic-allocator.c:69:29: note: in expansion of macro ‘fn’
       69 | #define basic_alloc_realloc fn(BASIC_ALLOC_PREFIX,realloc)
          |                             ^~
    [...]/libgomp/config/nvptx/../../basic-allocator.c:69:32: note: in expansion of macro ‘BASIC_ALLOC_PREFIX’
       69 | #define basic_alloc_realloc fn(BASIC_ALLOC_PREFIX,realloc)
          |                                ^~~~~~~~~~~~~~~~~~
    [...]/libgomp/config/nvptx/../../basic-allocator.c:257:1: note: in expansion of macro ‘basic_alloc_realloc’
      257 | basic_alloc_realloc (char *heap, void *addr, size_t oldsize,
          | ^~~~~~~~~~~~~~~~~~~
    [...]/libgomp/config/nvptx/allocator.c:47:28: error: ‘__nvptx_lowlat_calloc’ defined but not used [-Werror=unused-function]
       47 | #define BASIC_ALLOC_PREFIX __nvptx_lowlat
          |                            ^~~~~~~~~~~~~~
    [...]/libgomp/config/nvptx/../../basic-allocator.c:63:27: note: in definition of macro ‘fn1’
       63 | #define fn1(prefix, name) prefix ## _ ## name
          |                           ^~~~~~
    [...]/libgomp/config/nvptx/../../basic-allocator.c:67:28: note: in expansion of macro ‘fn’
       67 | #define basic_alloc_calloc fn(BASIC_ALLOC_PREFIX,calloc)
          |                            ^~
    [...]/libgomp/config/nvptx/../../basic-allocator.c:67:31: note: in expansion of macro ‘BASIC_ALLOC_PREFIX’
       67 | #define basic_alloc_calloc fn(BASIC_ALLOC_PREFIX,calloc)
          |                               ^~~~~~~~~~~~~~~~~~
    [...]/libgomp/config/nvptx/../../basic-allocator.c:167:1: note: in expansion of macro ‘basic_alloc_calloc’
      167 | basic_alloc_calloc (char *heap, size_t size)
          | ^~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
    make[7]: *** [Makefile:819: allocator.lo] Error 1

If, for PTX < 4.1, we're not proving OpenMP low-latency memory, just disable
the whole '__nvptx_lowlat_pool' machinery.

libgomp/
* config/nvptx/allocator.c [PTX < 4.1]: Fix build.
* config/nvptx/team.c [PTX < 4.1]: Disable the whole
'__nvptx_lowlat_pool' machinery.

4 days agotree-optimization/124545 - VN: add inverse widening lookup for PLUS/MINUS
Philipp Tomsich [Wed, 1 Jul 2026 10:19:30 +0000 (12:19 +0200)] 
tree-optimization/124545 - VN: add inverse widening lookup for PLUS/MINUS

visit_nary_op canonicalises (T)(A + C) into (T)A + (T)C for its VN
lookup, but not the reverse -- so whether VN discovers (T)A + C ==
(T)(A + C) depends on which form it sees first.  Add a match.pd rule
that rewrites (T)A +- CST into (T)(A +- CST') using the op! qualifier,
so the fold only fires when the narrow expression already has a value
number -- i.e. only inside VN via mprts_hook.

Restrict to TYPE_OVERFLOW_UNDEFINED inner types: for unsigned inner the
narrow op wraps mod 2^prec (defined) while the widened outer op does
not, changing the observed value (bitfld-5.c is the concrete miscompile
when the guard is loosened).

Use wi::min_precision (CST, SIGNED) rather than int_fits_type_p for the
fits-check, so sign-encoded small negatives (e.g. -1 as sizetype's
0xFFFF...FFFF) qualify.

PR tree-optimization/124545

gcc/ChangeLog:

* match.pd: Add (T)A +- CST -> (T)(A +- CST') for widening
conversions from a signed inner type with undefined overflow.

gcc/testsuite/ChangeLog:

* gcc.dg/pr124545.c: New test.
* gcc.dg/pr124545-2.c: New test.

4 days agoMAINTAINERS: Update my email address
Eugene Rozenfeld [Sun, 21 Jun 2026 21:32:53 +0000 (14:32 -0700)] 
MAINTAINERS: Update my email address

ChangeLog:

* MAINTAINERS: Update my email address.

4 days agoLRA: Add cannot_substitute_const_equiv_p target hook
Kaz Kojima [Fri, 18 Oct 2024 02:09:37 +0000 (11:09 +0900)] 
LRA: Add cannot_substitute_const_equiv_p target hook

On SH fp constant load special instructions 'fldi0' and 'fldi1' are only valid
for single-precision fp mode and thus depend on mode-switiching.  LRA is
not aware of that (or any mode-switching constraints) and would emit such
constant loads in the wrong mode by changing fp-move related insn alternative
without validating fp-mode attributes.

This new target hook allows rejecting such potentially unsafe substitutions.

This patch has been proposed here
https://gcc.gnu.org/pipermail/gcc-patches/2026-March/709649.html

but was initially rejected, as it's just papering over the real problem.
Further discussion has clarified that this is a general issue in GCC, not only
limited to LRA.  Everything that runs after the mode-switching pass
can make potentially unsafe insn transformations because nothing is validating
the insn mode requirements against the current cpu/fpu mode state.

After some reconsideration, this patch was approved
https://gcc.gnu.org/pipermail/gcc-patches/2026-June/722024.html

gcc/ChangeLog:
PR target/117182
PR target/55212
* target.def (cannot_substitute_const_equiv_p): New target hook.
* doc/tm.texi.in: Add it.
* lra-constraints.cc (get_equiv): Use it.
* config/sh/sh.cc (sh_cannot_substitute_const_equiv_p): Override it.
* doc/tm.texi: Re-generate.

4 days agoSH: Move and adjust testcase pr55212-c248.c
Oleg Endo [Wed, 1 Jul 2026 02:58:29 +0000 (11:58 +0900)] 
SH: Move and adjust testcase pr55212-c248.c

gcc/testsuite/ChangeLog:

PR target/55212
* gcc.target/sh/pr55212-c248.c: Move to ..
* gcc.target/sh/torture/pr55212-c248.c: .. here.  Skip it for -O0.

4 days agoSH: Pin input args to hard-regs via predicates for sfuncs
Kaz Kojima [Tue, 24 Sep 2024 09:26:42 +0000 (18:26 +0900)] 
SH: Pin input args to hard-regs via predicates for sfuncs

Some sfuncs uses hard reg as input and clobber its raw reg pattern. It
seems that LRA doesn't process this clobber pattern.  Rewrite these
patterns so as to work with LRA.

gcc/ChangeLog:

PR target/55212
* config/sh/predicates.md (hard_reg_r0..r7): New predicates.
* config/sh/sh.md (udivsi3_i4, udivsi3_i4_single,
udivsi3_i1): Rewrite with match_operand and match_dup.
(block_lump_real, block_lump_real_i4): Ditto.
(udivsi3): Adjust for it.
* config/sh/sh-mem.cc (expand_block_move): Ditto.

4 days agoDaily bump.
GCC Administrator [Thu, 2 Jul 2026 00:16:40 +0000 (00:16 +0000)] 
Daily bump.

4 days agoDarwin: Updates to handling of NeXT metadata [PR124260].
Iain Sandoe [Sat, 27 Jun 2026 19:39:39 +0000 (20:39 +0100)] 
Darwin: Updates to handling of NeXT metadata [PR124260].

Darwin-specific preparations for changes to handle the PR:
  Allow metadata to reside in const_data.

  Add ClassList to the cases where we want the symbols to be linker-visible.

  This adds expanded comments on the meaning of the flag fields in the ImageInfo
metadata.

PR objc/124260

gcc/ChangeLog:

* config/darwin.cc (darwin_objc2_section): Also allow meta data
in const_data.
(darwin_label_is_anonymous_local_objc_name): Make ClassList linker-
visible.
(darwin_file_end): Update comments on the ImageInfo flags.  Do not
claim we have signed pointers.

gcc/testsuite/ChangeLog:

* objc.dg/image-info.m: Test revised flags value for ABI-2.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
4 days agoFortran: Fix asan problems with PDT testcases [PR121972]
Paul Thomas [Wed, 1 Jul 2026 16:14:25 +0000 (17:14 +0100)] 
Fortran: Fix asan problems with PDT testcases [PR121972]

Co-authored-by: Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/121972

gcc/fortran
* expr.cc (has_parameterized_comps): Return false if the DT
is neither a pdt_type nor has PDT components. Correct the
logic for a PDT component.
* trans-expr.cc (alloc_scalar_allocatable_for_assignment): Use
calloc for types with paramterized components as well as those
with allocatable components.
* trans-stmt.cc (gfc_trans_allocate): Merge the allocation of
parameterized components of PDTs and class PDTs into one block
If an allocate type_spec is present that has allocatable comps
where the class declared type does not, nullify the allocatable
components.

gcc/testsuite/
* gfortran.dg/asan/pdt_46.f03: Copy of original with tree dump
for counts of frees, mallocs and callocs removed.
* gfortran.dg/asan/pdt_77.f03: Ditto.
* gfortran.dg/pdt_46.f03: Calloc count added, corresponding to
reduction in mallocs..
* gfortran.dg/pdt_50.f03: Ditto.

4 days agos390: Fixup fix for *extzv_<mode>_{srl,sll}<clobbercc_or_nocc>
Stefan Schulze Frielinghaus [Wed, 1 Jul 2026 19:08:46 +0000 (21:08 +0200)] 
s390: Fixup fix for *extzv_<mode>_{srl,sll}<clobbercc_or_nocc>

Since r17-2057 the output template is a statement which means we have to
annotate the mnemonic.

gcc/ChangeLog:

* config/s390/s390.md: Annotate mnemonic for
extzv_<mode>_{srl,sll}<clobbercc_or_nocc>.

4 days agolibstdc++: Add std::complex to the [simd] vectorizable types
Matthias Kretz [Thu, 5 Mar 2026 09:20:53 +0000 (10:20 +0100)] 
libstdc++: Add std::complex to the [simd] vectorizable types

The implementation for [simd.bit] is trivial (not explicitly vectorized)
using calls to the scalar functions.

The division operator for vec<complex<T>> is not implemented yet
(instantiation hits an unconditional static_assert).

_M_abs() is not and cannot be implemented without [simd.math] (sqrt and
hypot).

libstdc++-v3/ChangeLog:
* include/Makefile.am: Add bits/simd_bit.h, bits/simd_complex.h,
and bit/simd_math.
* include/Makefile.in: Regenerate.
* include/bits/simd_bit.h: New file.
* include/bits/simd_complex.h: New file.
* include/bits/simd_details.h (__complex_like): New concept.
(__vectorizable): Extend for complex types.
(_AbiVariant): Add _CxIleav and _CxCtgus variants.
(_ScalarAbi, _Abi): Add _S_is_cx_ileav and _S_is_cx_ctgus
members.
(_ArchTraits::_M_have_addsub): New.
(__native_abi): For __complex_like default to _CxIleav _Abi.
Derive the size from the native size for the complex's
value_type.
(__abi_rebind): Implement rebind to and from complex.
(__is_mask_conversion_explicit): Take _Cx* _AbiVariant into
account.
(__value_preserving_convertible_to): Also allow conversion to
complex.
(__simd_unsigned_integer): New.
(__simd_complex_value_type, __simd_complex): New.
* include/bits/simd_loadstore.h (unchecked_load): Use a cast to
the complex's value_type for converting loads to __complex_like.
* include/bits/simd_mask.h (basic_mask): Constrain partial
specializations to non-complex ABI tags.
(basic_mask::basic_mask): Add conversion from _CxIleav ABIs.
(_M_to_uint): Add option to interpret two mask elements as one
result bit. Make use of __x86_cvt_vecmask_to_bitmask.
(basic_mask::basic_mask): Add conversion from _CxCtgus and
_CxIleav masks.
(__select_impl): The complex specialization of basic_vec needs
_S_concat instead of _S_init.
(_M_reduce_count): Implement recursive reduction.
* include/bits/simd_mask_reductions.h (reduce_count): Fall back
to _M_reduce_count() for mask types without unary minus.
* include/bits/simd_math.h: New file.
* include/bits/simd_vec.h (basic_vec): Constrain partial
specializations to !__complex_like.
* include/bits/simd_x86.h (__x86_cvt_vecmask_to_bitmask): New.
* include/bits/vec_ops.h (__is_const_known): __complex_like
arguments are known if real and imag are known.
(_S_complex_negate_real, _S_complex_negate_imag, _S_addsub)
(_S_complex_real_is_const_known_zero)
(_S_complex_imag_is_const_known_zero): New.
* include/bits/version.def: Add simd_complex.
* include/bits/version.h: Regenerate.
* include/std/simd: Ask for simd_complex feature macro. Include
bits/simd_bit.h, bits/simd_complex.h, and bits/simd_math.h.
* testsuite/std/simd/arithmetic.cc: Enable tests for complex
which needs complex_init.h.
* testsuite/std/simd/complex_init.h: Helper for passing complex
values as template arguments.
* testsuite/std/simd/create_tests.h: Add float16_t, and three
complex types.
* testsuite/std/simd/mask2.cc: Add complex test types.
* testsuite/std/simd/simd_bit.cc: New test.
* testsuite/std/simd/simd_bit_expensive.cc: New test.
* testsuite/std/simd/stores.cc: Guard converting stores from
complex.
* testsuite/std/simd/test_setup.h (any_type_of): New.
(complex_like): New.
(bit_equal): Handle multi-reg and complex arguments.
(cx_isinf): New.
(equal_with_nan_and_inf_fixup): Handle complex types.
(is_const_known): Add std::complex overload.
(test_iota): Add support for std::complex.
* testsuite/std/simd/traits_common.cc: Add complex test types.
Test that instantiation of complete classes is well-formed.
* testsuite/std/simd/traits_impl.cc: Add complex test types.
Test __complex_like. Add a test that _CxIleav is dropped when
rebinding to the member of a _CxIleav mask.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>