]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
7 days agocobol, libgcobol: Fix typos in various files
Dhruv Chawla [Wed, 13 May 2026 10:51:03 +0000 (10:51 +0000)] 
cobol, libgcobol: Fix typos in various files

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/cobol/ChangeLog:

* compare.cc (alpha_compare): Fix typos.
* Make-lang.in: Fix typos.
* except.cc (cbl_enabled_exceptions_t::turn_on_off): Likewise.
* genapi.cc (MAX_AFTERS): Likewise.
(cobol_compare): Likewise.
(enter_program_common): Likewise.
(parser_bsearch_end): Likewise.
(parser_set_pointers): Likewise.
* gengen.cc (chain_parameter_to_function): Likewise.
* gengen.h (gg_return): Likewise.
* genutil.cc (refer_is_clean): Likewise.
* lexio.cc (right_margin): Likewise.
(maybe_add_space): Likewise.
* messages.cc: Likewise.
* parse_ante.h (procedure_division_ready): Likewise.
* structs.cc (create_cblc_field_t): Likewise.
* symbols.cc (special_pair_cmp): Likewise.
(symbol_table_init): Likewise.
(symbol_label_add): Likewise.
* symbols.h: Likewise.
* util.cc (date_time_fmt): Likewise.
(cobol_lineno): Likewise.

libgcobol/ChangeLog:

* README: Fix typos.
* charmaps.cc (__gg__iconverter): Likewise.
* common-defs.h (enum cbl_field_attr_t): Likewise.
* gcobolio.h: Likewise.
* gfileio.cc (__gg__file_stash): Likewise.
* gmath.cc (__gg__pow): Likewise.
* inspect.cc (inspect_backward_format_1): Likewise.
(__gg__inspect_format_1): Likewise.
(inspect_backward_format_2): Likewise.
(__gg__inspect_format_2): Likewise.
(__gg__inspect_format_1_sbc): Likewise.
* intrinsic.cc (gets_month): Likewise.
* libgcobol.cc (get_time_nanoseconds_local): Likewise.
(__gg__compare_2): Likewise.
(display_both): Likewise.
(accept_envar): Likewise.
(__gg__set_pointer): Likewise.
(struct cbl_exception_t): Likewise.
(default_exception_handler): Likewise.
(convert_for_convert): Likewise.
* valconv.cc: Likewise.
* xmlparse.cc (struct xml_ec_value_t): Likewise.

7 days agoc-family, c: Fix typos in various files
Dhruv Chawla [Wed, 13 May 2026 10:48:53 +0000 (10:48 +0000)] 
c-family, c: Fix typos in various files

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/c-family/ChangeLog:

* c-attribs.cc (append_access_attr): Fix typos.
(append_access_attr_idxs): Likewise.
(has_attribute): Likewise.
* c-common.cc (get_cpp_ttype_from_string_type): Likewise.
(cb_get_suggestion): Likewise.
(maybe_add_include_fixit): Likewise.
* c-common.h (convert_vector_to_array_for_subscript): Likewise.
* c-cppbuiltin.cc (builtin_define_type_max): Likewise.
* c-format.cc (check_format_info_main): Likewise.
(check_format_types): Likewise.
* c-omp.cc (c_omp_categorize_directive): Likewise.
* c-opts.cc (c_common_post_options): Likewise.
* c-ubsan.cc (ubsan_instrument_bounds): Likewise.

gcc/c/ChangeLog:

* c-decl.cc (pop_file_scope): Fix typos.
(diagnose_mismatched_decls): Likewise.
(parser_xref_tag): Likewise.
(verify_counted_by_attribute): Likewise.
* c-fold.cc (c_disable_warnings): Likewise.
* c-parser.cc (c_parser_do_statement): Likewise.
(c_parser_expression): Likewise.
(c_parser_objc_at_property_declaration): Likewise.
* c-tree.h (struct c_declspecs): Likewise.
* c-typeck.cc (build_access_with_size_for_counted_by): Likewise.
(build_modify_expr): Likewise.
(c_find_omp_var_r): Likewise.
* gimple-parser.cc (c_parser_gimple_compound_statement): Likewise.

7 days agoanalyzer: Fix typos in various files
Dhruv Chawla [Wed, 13 May 2026 10:46:00 +0000 (10:46 +0000)] 
analyzer: Fix typos in various files

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/analyzer/ChangeLog:

* access-diagram.cc: Fix typos.
* analyzer.cc (fixup_tree_for_diagnostic_1): Likewise.
(tree_to_json): Likewise.
* bounds-checking.cc: Likewise.
* constraint-manager.cc (constraint_manager::impossible_derived_conditions_p): Likewise.
* diagnostic-manager.cc (prune_frame): Likewise.
* engine.cc (get_eh_outedge): Likewise.
(maybe_process_run_of_enodes): Likewise.
* inlining-iterator.h: Likewise.
* ops.cc (call_and_return_op::execute): Likewise.
* pending-diagnostic.h (class pending_diagnostic): Likewise.
* region-model-asm.cc: Likewise.
* region-model.cc (check_one_function_attr_null_terminated_string_arg): Likewise.
(region_model::deref_rvalue): Likewise.
(region_model::scan_for_null_terminator): Likewise.
(region_model::check_for_null_terminated_string_arg): Likewise.
(model_merger::mergeable_svalue_p): Likewise.
(test_canonicalization_4): Likewise.
* region.cc (region::accept): Likewise.
* setjmp-longjmp.cc (region_model::on_longjmp): Likewise.
* sm-fd.cc: Likewise.
* sm-malloc.cc: Likewise.
* sm-taint.cc: Likewise.
* store.cc (binding_cluster::maybe_get_compound_binding): Likewise.
(binding_cluster::can_merge_p): Likewise.
(store::replay_call_summary): Likewise.
* svalue.cc (svalue::can_merge_p): Likewise.
(widening_svalue::eval_condition_without_cm): Likewise.

7 days agoalgol68, libga68: Fix typos in various files
Dhruv Chawla [Wed, 13 May 2026 10:36:21 +0000 (10:36 +0000)] 
algol68, libga68: Fix typos in various files

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/algol68/ChangeLog:

* a68-imports-archive.cc (struct Archive_fl_header): Fix typos.
* a68-imports.cc (encoded_mode_free): Likewise.
* a68-low-chars.cc (a68_char_repr): Likewise.
* a68-low-clauses.cc (a68_lower_label): Likewise.
(a68_lower_labeled_unit): Likewise.
(a68_lower_completer): Likewise.
(a68_lower_initialiser_series): Likewise.
(a68_lower_case_clause): Likewise.
* a68-low-decls.cc (a68_lower_variable_declaration): Likewise.
(a68_lower_procedure_variable_declaration): Likewise.
* a68-low-ints.cc (a68_get_int_skip_tree): Likewise.
(a68_int_maxval): Likewise.
* a68-low-moids.cc (lower_struct_mode): Likewise.
* a68-low-multiples.cc (a68_multiple_single_bound_check): Likewise.
* a68-low-prelude.cc (a68_lower_divab3): Likewise.
(a68_lower_upb3): Likewise.
(a68_lower_lwb3): Likewise.
* a68-low-procs.cc (a68_get_proc_skip_tree): Likewise.
* a68-low-reals.cc (a68_real_maxval): Likewise.
(a68_real_minval): Likewise.
* a68-low-units.cc (a68_lower_identifier): Likewise.
* a68-low.cc (a68_low_assignation): Likewise.
* a68-moids-misc.cc (a68_is_firm): Likewise.
(a68_is_coercible_series): Likewise.
* a68-parser-bottom-up.cc (strange_separator): Likewise.
(a68_bottom_up_parser): Likewise.
* a68-parser-prelude.cc (stand_prelude): Likewise.
* a68-parser-scanner.cc (a68_lexical_analyser): Likewise.
* a68-parser-scope.cc (a68_scope_checker): Likewise.
* a68-parser-serial-dsa.cc (serial_dsa_check_serial_clause): Likewise.
* a68-parser-taxes.cc (test_firmly_related_ops_local): Likewise.
* a68-parser.cc: Likewise.
* a68-types.h (struct KEYWORD_T): Likewise.
(struct OPTIONS_T): Likewise.
(struct NODE_T): Likewise.
(struct MODE_CACHE_T): Likewise.
* ga68-coding-guidelines.texi: Likewise.
* ga68.texi: Likewise.

libga68/ChangeLog:

* ga68-error.c: Fix typos.
* ga68-unistr.c (_libga68_u32_cmp): Likewise.
(_libga68_u8_uctomb): Likewise.
(_libga68_u32_to_u8): Likewise.

7 days agoada: Fix typos in various files
Dhruv Chawla [Wed, 13 May 2026 10:31:25 +0000 (10:31 +0000)] 
ada: Fix typos in various files

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ada/ChangeLog:

* adaint.c (__gnat_set_OWNER_ACL): Fix typos.
* aux-io.c: Likewise.
* cio.c: Likewise.
* cstreams.c: Likewise.
* doc/gnat_rm/gnat_language_extensions.rst: Likewise.
* doc/gnat_rm/implementation_defined_attributes.rst: Likewise.
* doc/gnat_rm/implementation_defined_characteristics.rst: Likewise.
* doc/gnat_rm/implementation_defined_pragmas.rst: Likewise.
* doc/gnat_rm/interfacing_to_other_languages.rst: Likewise.
* doc/gnat_rm/representation_clauses_and_pragmas.rst: Likewise.
* doc/gnat_rm/standard_and_implementation_defined_restrictions.rst: Likewise.
* doc/gnat_rm/the_gnat_library.rst: Likewise.
* doc/gnat_ugn/building_executable_programs_with_gnat.rst: Likewise.
* doc/gnat_ugn/gnat_and_program_execution.rst: Likewise.
* doc/gnat_ugn/gnat_utility_programs.rst: Likewise.
* doc/gnat_ugn/platform_specific_information.rst: Likewise.
* doc/gnat_ugn/the_gnat_compilation_model.rst: Likewise.
* doc/share/conf.py: Likewise.
* gcc-interface/decl.cc (components_to_record): Likewise.
* gcc-interface/misc.cc (gnat_get_array_descr_info): Likewise.
(get_array_bit_stride): Likewise.
* gcc-interface/trans.cc (Loop_Statement_to_gnu): Likewise.
(gnat_to_gnu): Likewise.
* gcc-interface/utils.cc (gnat_pushdecl): Likewise.
(maybe_pad_type): Likewise.
(finish_record_type): Likewise.
(process_deferred_decl_context): Likewise.
* gnat_rm.texi: Likewise.
* gnat_ugn.texi: Likewise.
* gnathtml.pl: Likewise.
* gsocket.h: Likewise.
* init.c (__gnat_handle_vms_condition): Likewise.
(GNAT$STOP): Likewise.
* raise-gcc.c (db_phases): Likewise.
* rtinit.c (__gnat_runtime_initialize): Likewise.
* sigtramp-arm-qnx.c: Likewise.
* sigtramp-vxworks-target.h (defined): Likewise.
* sigtramp-vxworks.c: Likewise.
* sysdep.c: Likewise.
* terminals.c (defined): Likewise.
(__gnat_new_tty): Likewise.
(__gnat_close_tty): Likewise.
(__gnat_tty_name): Likewise.
* tracebak.c (PC_ADJUST): Likewise.

7 days agotoplevel: Fix typos in build files
Dhruv Chawla [Mon, 11 May 2026 15:18:41 +0000 (15:18 +0000)] 
toplevel: Fix typos in build files

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
ChangeLog:

* Makefile.def: Fix typos.
* Makefile.in: Likewise.
* Makefile.tpl: Likewise.

gcc/ChangeLog:

* Makefile.in: Fix typos.

7 days agoc: some cleanups for the comptypes hierarchy of functions
Martin Uecker [Sun, 24 May 2026 10:23:05 +0000 (12:23 +0200)] 
c: some cleanups for the comptypes hierarchy of functions

comptypes returns an int where a value of two indicates that a warning
is needed due to a mismatch of attributes.  Change all related functions
to return a boolean and use comptypes_internal in the one caller
(comp_target_types) that requires the additional information.  This allows
simplifying the code a bit and removes the need for two wrapper functions.
Fix a caller that tested for == 1 instead of != 0.

gcc/c/ChangeLog:
* c-decl.cc (diagnose_mismatched_decls): Adapt.
* c-tree.h (comptypes, comptypes_check_enum_int): Adapt.
(comptypes_check_different_types): Remove.
* c-typeck.cc (compatible_types_for_indirection_note_p): Fix.
(comptypes_internal): Remove outdated info from comment.
(comptypes, comptypes_check_enum_int): Adapt.
(comptypes_check_different_types,comp_parm_types): Remove.
(comp_target_types,build_function_call_vec,digest_init): Adapt.

7 days agoc, middle-end: Implement C2Y N3705: bit-precise enum
Jakub Jelinek [Sat, 30 May 2026 07:46:29 +0000 (09:46 +0200)] 
c, middle-end: Implement C2Y N3705: bit-precise enum

The following patch implements the C2Y
https://www.open-std.org/jtc1/sc22/WG14/www/docs/n3705.htm - bit-precise enum
paper.
In c_parser_enum_specifier it allows {,signed,unsigned} _BitInt(N) types as
fixed underlying type of enums for -std=c2y/-std=gnu2y and the rest of the
patch deals with that, mostly by adjusting the preexisting BITINT_TYPE_P macro
(which was just used in one spot though) to not just include BITINT_TYPE
types, but ENUMERAL_TYPE with BITINT_TYPE as underlying type, and changing
lots of places that use TREE_CODE (type) == BITINT_TYPE to
BITINT_TYPE_P (type).
Like normal ENUMERAL_TYPEs are uselessly convertible in GIMPLE with same
precision/sign INTEGER_TYPEs, ENUMERAL_TYPEs with BITINT_TYPE as underlying type
are uselessly convertible with same precision/sign BITINT_TYPE and vice
versa, so that extends the number of spots that need to use BITINT_TYPE_P
macros.
For bit-fields with enumeral types with underlying fixed bit-precise type,
WG14 issue 1021 wording is used, in that those bit-fields promote to the
underlying bit-precise type.

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

gcc/
* tree.h (BITINT_TYPE_P): Return true also for ENUMERAL_TYPE with
BITINT_TYPE as underlying type.
* stor-layout.cc (finish_bitfield_representative): Use BITINT_TYPE_P
macro.
(layout_type): Likewise.  Lay out ENUMERAL_TYPEs with BITINT_TYPE as
underlying type the same as BITINT_TYPEs.
* gimple-lower-bitint.cc (maybe_cast_middle_bitint): Use BITINT_TYPE_P
macro.
(mergeable_op, optimizable_arith_overflow, comparison_op,
bitint_large_huge::handle_cast, bitint_large_huge::lower_shift_stmt,
bitint_large_huge::lower_muldiv_stmt,
bitint_large_huge::lower_mul_overflow,
bitint_large_huge::lower_bit_query,
bitint_large_huge::lower_call, bitint_large_huge::lower_asm,
bitint_large_huge::lower_stmt, build_bitint_stmt_ssa_conflicts,
arith_overflow_arg_kind, gimple_lower_bitint): Likewise.
* gimple-expr.cc (useless_type_conversion_p): Likewise.
* fold-const.cc (make_range_step): Likewise.
(range_check_type): For ENUMERAL_TYPEs with BITINT_TYPE as underlying
type use the underlying type.
(extract_muldiv_1): Use BITINT_TYPE_P macro.
(native_encode_wide_int): Likewise.
(native_interpret_int): Likewise.
* vr-values.cc
(simplify_using_ranges::simplify_float_conversion_using_ranges):
Likewise.
* cfgexpand.cc (expand_debug_expr): Likewise.
* convert.cc (convert_to_integer_1): Add special case for ENUMERAL_TYPE
with underlying BITINT_TYPE.
* tree-ssa-sccvn.cc (vn_walk_cb_data::push_partial_def): Use
BITINT_TYPE_P macro.
(vn_reference_lookup_3): Likewise.
(eliminate_dom_walker::eliminate_stmt): Likewise.
* match.pd (ctz(ext(X)) == ctz(X), popcount(zext(X)) == popcount(X),
parity(zext(X)) == parity(X), a != 0 ? CLZ(a) : CST -> .CLZ(a),
a != 0 ? CTZ(a) : CST -> .CTZ(a), ffs(ext(X)) == ffs(X)): Likewise.
* builtins.cc (fold_builtin_bit_query): Likewise.
* explow.cc (promote_function_mode): Handle ENUMERAL_TYPE with
BITINT_TYPE as underlying type like BITINT_TYPE.
(promote_mode): Likewise.
* expr.cc (EXTEND_BITINT): Use BITINT_TYPE_P macro.
(expand_expr_real_1): Likewise.
* fold-const-call.cc (fold_const_call_ss): Likewise.
* gimple-fold.cc (gimple_fold_builtin_memset): Likewise.
(clear_padding_type_may_have_padding_p): Handle ENUMERAL_TYPE
with BITINT_TYPE as underlying type like BITINT_TYPE.
(type_has_padding_at_level_p): Likewise.
(clear_padding_type): Likewise.
* gimple-match-exports.cc (build_call_internal): Use BITINT_TYPE_P
macro.
* internal-fn.cc (expand_ubsan_result_store): Likewise.
* tree-sra.cc (create_access): Likewise.
(analyze_access_subtree): Likewise.
* tree-ssa-phiopt.cc (cond_removal_in_builtin_zero_pattern): Likewise.
* tree-ssa.cc (maybe_optimize_var): Likewise.
* tree-switch-conversion.cc (switch_conversion::array_value_type):
Likewise.
(switch_conversion::build_arrays): Likewise.
(jump_table_cluster::emit): Likewise.
* ubsan.cc (ubsan_encode_value): Likewise.
(ubsan_type_descriptor): Handle ENUMERAL_TYPE with BITINT_TYPE as
underlying type like BITINT_TYPE.
(instrument_si_overflow): Use BITINT_TYPE_P macro.
* varasm.cc (output_constant): Handle ENUMERAL_TYPE with BITINT_TYPE
as underlying type like BITINT_TYPE.
* config/aarch64/aarch64.cc (aarch64_return_in_memory_1): Use
BITINT_TYPE_P macro.
(bitint_or_aggr_of_bitint_p): Likewise.
(aarch64_composite_type_p): Likewise.
* config/arm/arm.cc (arm_return_in_memory): Likewise.
(arm_needs_doubleword_align): Likewise.
* config/i386/i386.cc (classify_argument): Handle ENUMERAL_TYPE with
BITINT_TYPE as underlying type like BITINT_TYPE.
* config/loongarch/loongarch.h: Use BITINT_TYPE_P macro.
gcc/c-family/
* c-attribs.cc (type_valid_for_vector_size): Use BITINT_TYPE_P macro.
* c-common.cc (c_common_get_narrower): For ENUMERAL_TYPE with
BITINT_TYPE as underlying type convert to the underlying type.
(c_common_signed_or_unsigned_type): Use BITINT_TYPE_P macro.
(sync_resolve_size): Likewise.
(atomic_bitint_fetch_using_cas_loop): Likewise.
(resolve_overloaded_builtin): Likewise.
gcc/c/
* c-parser.cc (c_parser_enum_specifier): Implement
C2Y N3705: bit-precise enum.  Allow for flag_isoc2y enumerated
types with BITINT_TYPE as underlying type.
* c-lang.cc (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Redefine.
* c-tree.h (c_enum_underlying_base_type): Declare.
* c-objc-common.cc (c_enum_underlying_base_type): New function.
* c-decl.cc (finish_struct): Use BITINT_TYPE_P macro.
* c-typeck.cc (perform_integral_promotions): Promote bit-fields with
enum type with underlying fixed _BitInt type to that _BitInt type.
gcc/testsuite/
* gcc.dg/bitint-133.c: New test.
* gcc.dg/bitint-134.c: New test.
* gcc.dg/bitint-135.c: New test.
* gcc.dg/bitint-136.c: New test.
* gcc.dg/torture/bitint-99.c: New test.

Reviewed-by: Joseph Myers <josmyers@redhat.com>
8 days agocobol: Include m4/autoconf.m4. [PR125503]
Robert Dubner [Sat, 30 May 2026 02:48:59 +0000 (22:48 -0400)] 
cobol: Include m4/autoconf.m4. [PR125503]

libgcobol/ChangeLog:

PR cobol/125503
* m4/autoconf.m4: New file.

8 days agoswitch-conv: Remove label from case_bit_test
Andrew Pinski [Sun, 17 May 2026 08:42:12 +0000 (01:42 -0700)] 
switch-conv: Remove label from case_bit_test

The label for case_bit_test is only used to stability
the qsort but the target bb here could be used for that.
So let's remove the label from case_bit_test and stability
the qsort by using the target bb's index.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-switch-conversion.cc (case_bit_test::cmp): Stability
based on the index of the target bb instead.
(bit_test_cluster::emit): Remove setting of the label field
of case_bit_test.
* tree-switch-conversion.h (case_bit_test): Remove the label
field.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
8 days agoDaily bump.
GCC Administrator [Sat, 30 May 2026 00:16:40 +0000 (00:16 +0000)] 
Daily bump.

8 days agoFix pr125453-1.c at -O2 on some targets
Andrew Pinski [Fri, 29 May 2026 16:02:10 +0000 (09:02 -0700)] 
Fix pr125453-1.c at -O2 on some targets

On some targets at -O2, pr125453-1.c testcase produces
a -Wstringop-overflow warning. Since this testcase is not testing
the warnings but rather an ICE, we can just add -w to the additional
options.

Pushed as obvious after testing it on x86_64-linux-gnu.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr125453-1.c: Add -w to the options.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
8 days agoranger-fold: Don't call into gimple_stmt_nonnegative_p [PR125475]
Andrew Pinski [Thu, 28 May 2026 04:09:01 +0000 (21:09 -0700)] 
ranger-fold: Don't call into gimple_stmt_nonnegative_p [PR125475]

When fold_using_range::fold_stmt comes in with a varying range,
it currently calls gimple_stmt_nonnegative_p to see if the value
is non-negative. But in the case where it matters (pr33738.C),
it will return true always because here we have just an unsigned type.
That sets the range to `[0, type_max]`. So instead we should
check if the type_min/type_max is not the same as precisionmin/precisionmax
and set the range to `[type_min, type_max]` in that case.

This fixes a recusion if we change tree_expr_nonnegative_p over to use
the ranger and I suspect might it help Ada code too.

PR tree-optimization/125475

gcc/ChangeLog:

* gimple-range-fold.cc (fold_using_range::fold_stmt): Don't call
gimple_stmt_nonnegative_p. Instead set the varying range to
`[type_min, type_max]` if not the same as the precision.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
8 days agocontrib: Make dg-extract-results.py tolerant of unparseable files
Kevin Buettner [Fri, 29 May 2026 18:29:02 +0000 (11:29 -0700)] 
contrib: Make dg-extract-results.py tolerant of unparseable files

This commit is for the benefit of GDB, but as the binutils-gdb
repository shares the contrib/ directory with GCC, this commit
must first be applied to GCC and then copied back to binutils-gdb.

When running GDB tests in parallel (make check -j$(nproc)), the
consolidated gdb.sum and gdb.log files are produced by
contrib/dg-extract-results.py, which merges per-test output files.

If any single per-test output file is malformed (e.g., due to a
DejaGnu EILSEQ crash, which is how I encountered this problem), the
script aborts via self.fatal().  Because this script is invoked via a
Makefile command using shell redirection, this causes the top-level
output files to be left as empty, zero-byte files, discarding valid
results from all other tests.

Fix by making the script tolerant of unparseable input files.  Wrap
each file's parsing in a try/except block.  When a file cannot be
parsed, emit a warning to stderr and continue processing remaining
files.  This ensures that crashing tests do not destroy the
consolidated output for the entire parallel build.

Tested on Fedora 44 using the GCC testsuite (make check-gcc
-j$(nproc)). The consolidated results are produced correctly with
no regressions.

This commit fixes this GDB bug:

https://sourceware.org/bugzilla/show_bug.cgi?id=34147

contrib/ChangeLog:

* dg-extract-results.py: Show warnings instead of erroring out
when encountering an unparseable file.

8 days agoAVR: ad target/121343 - Use hard-reg constraints in FMUL[S[U]] insns.
Georg-Johann Lay [Fri, 29 May 2026 19:11:45 +0000 (21:11 +0200)] 
AVR: ad target/121343 - Use hard-reg constraints in FMUL[S[U]] insns.

PR target/121343
gcc/
* config/avr/avr.md (FMUL): New int iterator.
(fmul, fmul_X, fmul_1, fmul_2): New int attributes.
(fmul, fmuls, fmulsu): Turn from expander to insn_and_split.
(fmul_insn, fmuls_insn, fmulsu_insn): Remove.

8 days agolibstdc++: Adjust flat_set::swap swapping order
Patrick Palka [Fri, 29 May 2026 19:21:06 +0000 (15:21 -0400)] 
libstdc++: Adjust flat_set::swap swapping order

In r17-908 I accidentally made us swap the comparator first, but we
decided that the container should be swapped first.

libstdc++-v3/ChangeLog:

* include/std/flat_set (_Flat_set_impl::swap): Swap _M_cont
first.

8 days agoFortran: checking of passed character length [PR125393]
Harald Anlauf [Thu, 28 May 2026 20:49:26 +0000 (22:49 +0200)] 
Fortran: checking of passed character length [PR125393]

Commit r16-3462 enhanced checking of character length passed to a character
dummy.  However, when the actual argument was an array element, its storage
size was estimated from all elements up to the end of the array.  This
could give a bogus warning when the dummy argument was of a scalar
character type.  Fix check for this case to actually compare the character
lengths of actual and dummy.

PR fortran/125393

gcc/fortran/ChangeLog:

* interface.cc (get_expr_storage_size): Additionally return
character length.
(gfc_compare_actual_formal): When the formal is a scalar character
variable, use character lengths, not array storage size for check.

gcc/testsuite/ChangeLog:

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

8 days agolibstdc++: allocate_at_least ask only what it reports (P0401)
Nathan Myers [Tue, 26 May 2026 14:41:27 +0000 (10:41 -0400)] 
libstdc++: allocate_at_least ask only what it reports (P0401)

allocate_at_least is rounding up the allocation request size to
its default alignment, which may be more than an integral
multiple of the object size requested. When the memory is freed,
what the container reports it is freeing differs from the amount
that was allocated. This patch rounds the request size back down
to what will be reported to the caller.

The algorithm to compute the allocation is altered in response
to findings on godbolt.org, which indicate dropping to uint8 to
perform the division is a pessimization everywhere other than
x86. The new version emits code for multiplication, instead.

In addition, the remaining -m32 test that failed under the new
allocation method is fixed, and guards are added for building
with -fno-aligned-new and for -fno-sized-deallocation.

Tested on x86 -m64/-m32.

libstdc++-v3/ChangeLog:
* include/bits/new_allocator.h (allocate_at_least): Reduce
allocation to match what is reported.
* testsuite/20_util/allocator/allocate_at_least2.cc: Add tests.
* testsuite/23_containers/vector/modifiers/insert_vs_emplace.cc:
Fix, for -m32 and new allocation results.

8 days agocobol: Speed improvements; function prototypes; POSIX compatibility.
Robert Dubner [Fri, 29 May 2026 13:43:07 +0000 (09:43 -0400)] 
cobol: Speed improvements; function prototypes; POSIX compatibility.

1) The execution speed of ADD N TO VAR and SUBTRACT N FROM VAR where N
is an integer in the range -9 through +9 and VAR is of type Numeric
Display is improved through specialized code in genmath.cc

2) The execution speed of FILE READ of line-sequential files is improved
by using a 64K read buffer.

3) COBOL function prototypes are implemented.

4) These changes include the beginning of implementing the POSIX
compatibility layer.

5) Added the ability to detect GOTO_EXPR that lack matching LABEL_EXPR.

Co-authored-by: Robert Dubner <rdubner@symas.com>
Co-authored-by: James K. Lowden <jklowden@cobolworx.com>
Co-authored-by: Xavier Del Campo <xdelcampo@symas.com>
gcc/cobol/ChangeLog:

* Make-lang.in: Include gcobc script.
* cdf.y: Change formal parameters of cdf_literalize().
* cobol1.cc (cobol_langhook_handle_option): Add OPT_ftrunc option.
* compare.cc (total_digits_tree): Remove debugging statements.
(float_compare): Likewise.
* copybook.h (class copybook_elem_t): Update conditional close().
* dts.h: Change copyright notice.
* gcobc: Likewise.
* gcobol.1: Likewise.
* gcobol.3: Likewise.
* gcobolspec.cc (COMPAT_LIBRARY): POSIX compatibility.
(POSIX_LIBRARY): Likewise.
(lang_specific_driver): Likewise.
* genapi.cc (section_label): Missing LABEL_EXPR detection.
(paragraph_label): Likewise.
(internal_perform_through): Likewise.
(enter_program_common): Add comment.
(parser_enter_program): Change current_program_index() handling.
(build_alter_switch): Missing LABEL_EXPR detection.
(parser_display_internal): Handle REFER_T_ADDRESS_OF flag.
(create_and_call): ADDRESS OF is passed BY VALUE.
* gengen.cc (LOOK_FOR_MISSING_LABELS_not): Missing LABEL_EXPR
detection.
(dump_missing_labels): Likewise.
(gg_append_statement): Likewise.
(gg_struct_field_ref): Likewise.
(LABEL_ROOT): Likewise.
(gg_create_goto_pair): Likewise.
(scm_dump_generic_nodes): Forward declaration.
(gg_leaving_the_source_code_file): Missing LABEL_EXPR detection.
(label_decl_text_from_expr): New function.
* gengen.h (gg_create_assembler_name): New declaration.
(label_decl_text_from_expr): New declaration.
* genmath.cc (uchar_f_node): Fast ADD N TO NUMERIC-DISPLAY.
(uchar_ten_node): Likewise.
(fast_add): Likewise.
(fast_subtract): Likewise.
(parser_add): Likewise.
(add_floats): Likewise.
(ordinary_add_format_1): Likewise.
(ordinary_subtract_format_1): Likewise.
(add_case_1): Likewise.
(add_case_2): Likewise.
(add_case_3): Likewise.
(parser_multiply): Likewise.
(add_case_4): Likewise.
(add_litN_to_numdisp): Likewise.
(add_format_1): Likewise.
(add_format_2): Likewise.
(add_format_3): Likewise.
(subtract_floats): Likewise.
(subtract_format_1): Likewise.
(subtract_format_2): Likewise.
(subtract_format_3): Likewise.
(parser_subtract): Likewise.
* genutil.cc (refer_has_depends): False when type == FldIndex.
* lang-specs.h: Add fdefaultbyte, fstatic-call, ftrunc.
* lang.opt: Add ftrunc.
* lexio.cc (cdftext::open_input): Improved error message.
* parse.y: CDF support, POSIX support.
* parse_ante.h (cbl_division_t): Different enum.
(mode_syntax_only): New implementation of syntax_only.
(parse_error_inc): Likewise.
(resume_parsing): Likewise.
(successful_parse): Likewise.
(name_of): Formal parameter is now const.
(nice_name_of): Likewise.
(ast_op): Chanage formal parameters.
(prototype_ok): COBOL function prototypes.
(struct prototype_type_t): Likewise.
(is_allowed_name): Likewise.
(prototype_add): Likewise.
(prototype_args): Likewise.
(verify_args): Likewise.
(valid_pointer_relop): New function.
(field_value_all): Eliminate.
(current_field): COBOL function prototypes.
(ast_enter_exit_section): Improved error messages.
(data_division_ready): Improved mode_syntax_only.
(file_section_fd_set): Change "return false" to "return 0".
(ast_end_program): Improved mode_syntax_only.
* scan_ante.h (symbol_function_token): Use symbol_function_any().
(symbol_exists): Change for() loop termination.
(typed_name): COBOL function prototypes.
* structs.cc: Support for buffered FILE READ.
* symbols.cc (symbol_field_location): Use field_locs[] map.
(symbol_table_extend): Likewise.
(is_prototypical): COBOL function prototypes.
(symbol_elem_cmp): Likewise.
(symbol_program): Likewise.
(struct symbol_elem_t): Likewise.
(symbol_function): Likewise.
(enum protoreq_t): Likewise.
(symbol_function_impl): Likewise.
(struct cbl_label_t): Likewise.
(symbol_function_any): Likewise.
(symbols_dump): Likewise.
(cbl_field_t::attr_str): Likewise.
(field_str): Likewise.
(symbols_update): Likewise.
(symbol_field_add): Likewise.
(symbol_field_same_as): Likewise.
(cbl_alphabet_t::reencode): Detect iconv() errors.
(symbol_program_add): COBOL function prototypes.
* symbols.h (enum dspc_t): Enum for Division, Section, Paragraph,
Clause.
(cbl_prototype_ok): COBOL function prototypes.
(valid_move): Handle strong typing.
(struct parameter_t): Improved function parameter handling.
(struct cbl_ffi_arg_t): Likewise.
(struct cbl_label_t): COBOL function prototypes.
(struct function_descr_t): Likewise.
(struct cbl_alphabet_t): Detect iconv() errors.
(struct cbl_file_t): Support for LINAGE and the like.
(prototype_args):COBOL function prototypes.
(is_prototypical):COBOL function prototypes.
(is_numeric): Refmods are not numeric.
(struct symbol_elem_t): Additional declarations.
* symfind.cc (update_symbol_map2): Use symbols map.
* token_names.h: New comment.
* util.cc (cbl_prototype_ok): COBOL function prototypes.
(cdf_literalize): New formal parameters.
(effective_type): New function.
(valid_move): Handle strong typing.
(cobol_trunc_binary): Handle new ftrunc option.
(parse_error_reset): Forward declaration.
(parse_file): Formatting.
* util.h (cobol_trunc_binary): New declaration.

libgcobol/ChangeLog:

* Makefile.am: Add AM_COBC and AM_COBFLAGS; update
toolexeclib_LTLIBRARIES with libgcobol_posix.la and
libgcobol_compat_gnu.la.
* Makefile.in: POSIX compatibility support.
* aclocal.m4: Regenerate.
* charmaps.cc (__gg__iconverter): Restore map of encoding pairs.
(__gg__get_charmap): Change how encodings are mapped.
* charmaps.h (CHARMAPS_H): Include #include <map>.
(DEFAULT_32_ENCODING): Wrap in __FreeBSD__ conditional.
(error_msg_direct): Wrap in IN_TARGET_LIBS.
(class cbl_iconv_t): Wrapper for iconv() calls.
(class charmap_t): Explicit constructor.
* compat/README.md: POSIX compatibility layer.
* compat/gnu/lib/CBL_ALLOC_MEM.cbl: Likewise.
* compat/gnu/lib/CBL_CHECK_FILE_EXIST.cbl: Likewise.
* compat/gnu/lib/CBL_DELETE_FILE.cbl: Likewise.
* compat/gnu/lib/CBL_FREE_MEM.cbl: Likewise.
* compat/gnu/udf/stored-char-length.cbl: Likewise.
* compat/t/Makefile: Likewise.
* compat/t/smoke.cbl: Likewise.
* configure: Regenerate.
* configure.ac: New macros
* configure.tgt: Likewise.
* ec.h (enum ec_type_t): New implementor-defined ec_imp_iconv_open_e
exception.
* encodings.h (_ENCODINGS_H_): #include <type_traits> for mapping
the cbl_encoding_t values.
(struct cbl_encoding_t_hash): Likewise.
* exceptl.h (ec_type_of): Remove "extern" from declaration.
* gcobolio.h (FILE_BUFFER_SIZE): READ FILE buffer size.
* gfileio.cc (sequential_file_write): Honor non-ascii encodings.
(line_sequential_file_read): Buffered FILE READ.
(line_sequential_file_read_sbc): Buffered FILE READ.
* intrinsic.cc (string_to_dest): Eliminate function.
(get_all_time): Replace __gg__convert_encoding() with
__gg__iconverter().
(__gg__when_compiled): Likewise.
* io.cc (__compat_file_status_word): POSIX compatibility layer.
* io.h (enum file_high_t): Likewise.
(enum file_status_t): Likewise.
* libgcobol.cc (init_var_both): Eliminate call to
initialize_program_state().
(__gg__move): Eliminate call to __gg__convert_encoding_length;
handle REFER_T_ADDRESS_OF.
(display_both): Handle REFER_T_ADDRESS_OF.
(__gg__display_clean): Likewise.
(__gg__convert_encoding): Eliminate function.
(__gg__convert_encoding_length): Likewise.
(default_exception_handler): Improve exception handling.
(ec_type_descr): Likewise.
(ec_type_disposition): Likewise.
(ec_is_fatal): Likewise.
(__gg__check_fatal_exception): Likewise.
(__gg__set_env_value): Remove call to __gg__convert_encoding.
* libgcobol.h (__gg__convert_encoding): Eliminate.
(__gg__convert_encoding_length): Eliminate.
* posix/bin/udf-gen: POSIX compatibility.
* posix/cpy/posix-errno.cbl: Likewise.
* posix/cpy/psx-lseek.cpy: Likewise.
* posix/cpy/psx-open.cpy: Likewise.
* posix/cpy/statbuf.cpy: Likewise.
* posix/cpy/tm.cpy: Likewise.
* posix/shim/lseek.cc (offsetof): Likewise.
(posix_lseek): Likewise.
* posix/shim/open.cc (posix_open): Likewise.
* posix/t/errno.cbl: Likewise.
* posix/t/exit.cbl: Likewise.
* posix/t/localtime.cbl: Likewise.
* posix/t/stat.cbl: Likewise.
* posix/udf/posix-exit.cbl: Likewise.
* posix/udf/posix-ftruncate.cbl: Likewise.
* posix/udf/posix-localtime.cbl: Likewise.
* posix/udf/posix-lseek.cbl: Likewise.
* posix/udf/posix-mkdir.cbl: Likewise.
* posix/udf/posix-open.cbl: Likewise.
* posix/udf/posix-read.cbl: Likewise.
* posix/udf/posix-stat.cbl: Likewise.
* posix/udf/posix-unlink.cbl: Likewise.
* posix/udf/posix-write.cbl: Likewise.
* valconv.cc: New exceptions.
* compat/gnu/cpy/cblproto.cpy: New file.
* compat/gnu/cpy/cbltypes.cpy: New file.
* compat/gnu/cpy/stored-char-length.cpy: New file.
* compat/gnu/lib/CBL_CLOSE_FILE.cbl: New file.
* compat/gnu/lib/CBL_CREATE_FILE.cbl: New file.
* compat/gnu/lib/CBL_OPEN_FILE.cbl: New file.
* compat/gnu/lib/CBL_READ_FILE.cbl: New file.
* compat/gnu/lib/CBL_WRITE_FILE.cbl: New file.
* compat/gnu/lib/cbl_alloc_mem.3: New file.
* compat/gnu/lib/cbl_alloc_mem.cbl3: New file.
* compat/gnu/lib/cbl_check_file_exist.3: New file.
* compat/gnu/lib/cbl_close_file.3: New file.
* compat/gnu/lib/cbl_create_file.3: New file.
* compat/gnu/lib/cbl_delete_file.3: New file.
* compat/gnu/lib/cbl_free_mem.3: New file.
* compat/gnu/lib/cbl_open_file.3: New file.
* compat/gnu/lib/cbl_read_file.3: New file.
* compat/gnu/lib/cbl_write_file.3: New file.
* compat/gnu/udf/cobrt-file-status.cbl: New file.
* posix/cpy/posix-close.cpy: New file.
* posix/cpy/posix-errno.cpy: New file.
* posix/cpy/posix-exit.cpy: New file.
* posix/cpy/posix-fstat.cpy: New file.
* posix/cpy/posix-ftruncate.cpy: New file.
* posix/cpy/posix-localtime.cpy: New file.
* posix/cpy/posix-lseek.cpy: New file.
* posix/cpy/posix-mkdir.cpy: New file.
* posix/cpy/posix-open.cpy: New file.
* posix/cpy/posix-read.cpy: New file.
* posix/cpy/posix-stat.cpy: New file.
* posix/cpy/posix-unlink.cpy: New file.
* posix/cpy/posix-write.cpy: New file.
* posix/shim/fstat.cc: New file.
* posix/udf/posix-close.cbl: New file.
* posix/udf/posix-errno.cbl: New file.
* posix/udf/posix-fstat.cbl: New file.

gcc/testsuite/ChangeLog:

* cobol.dg/group2/37-digit_Initialization_of_fundamental_types.cob:
Updated compiler error message.
* cobol.dg/group2/BINARY_and_COMP-5.cob:
Likewise.
* cobol.dg/group2/Check_for_equality_of_COMP-1___COMP-2.cob:
Likewise.
* cobol.dg/group2/Multi-target_MOVE_with_subscript_re-evaluation.cob:
Likewise.
* cobol.dg/group2/Named_conditionals_-_fixed__float__and_alphabetic.cob:
Likewise.
* cobol.dg/group2/Simple_p-scaling.cob:
Likewise.
* cobol.dg/group2/access_to_OPTIONAL_LINKAGE_item_not_passed.cob:
Likewise.
* cobol.dg/group2/compare_national_to_display.cob:
Likewise.
* cobol.dg/group2/comprensive_compare_comp-1_comp-5.cob:
Likewise.
* cobol.dg/group2/CBL_ALLOC_MEM___CBL_FREE_MEM.cob: New test.
* cobol.dg/group2/CBL_ALLOC_MEM___CBL_FREE_MEM.out: New test.
* cobol.dg/group2/CBL_CHECK_FILE_EXIST.cob: New test.
* cobol.dg/group2/CBL_CHECK_FILE_EXIST.out: New test.
* cobol.dg/group2/CBL_CREATE_FILE___CBL_WRITE_FILE___CBL_CLOSE_FILE.cob: New test.
* cobol.dg/group2/CBL_DELETE_FILE.cob: New test.
* cobol.dg/group2/CBL_DELETE_FILE.out: New test.
* cobol.dg/group2/CBL_OPEN_FILE___CBL_CLOSE_FILE.cob: New test.
* cobol.dg/group2/CBL_OPEN_FILE___CBL_CLOSE_FILE.out: New test.
* cobol.dg/group2/CBL_OPEN_FILE___CBL_READ_FILE___CBL_CLOSE_FILE.cob: New test.
* cobol.dg/group2/CBL_OPEN_FILE___CBL_READ_FILE___CBL_CLOSE_FILE.out: New test.
* cobol.dg/group2/CBL_READ_FILE__check_file_size_with_flags___128.cob: New test.
* cobol.dg/group2/Complex_HEX__VALUE_and_MOVE_-_UTF-16.cob: New test.
* cobol.dg/group2/Complex_HEX__VALUE_and_MOVE_-_UTF-16.out: New test.
* cobol.dg/group2/MOVE_LEVEL_78.cob: New test.
* cobol.dg/group2/MOVE_LEVEL_78.out: New test.
* cobol.dg/group2/add_-1_to_negative_pic_S9999.cob: New test.
* cobol.dg/group2/add_-1_to_negative_pic_S9999.out: New test.
* cobol.dg/group2/add_-1_to_pic_9999.cob: New test.
* cobol.dg/group2/add_-1_to_pic_9999.out: New test.
* cobol.dg/group2/add_-1_to_positive_pic_S9999.cob: New test.
* cobol.dg/group2/add_-1_to_positive_pic_S9999.out: New test.
* cobol.dg/group2/add_1_to_pic_9999.cob: New test.
* cobol.dg/group2/add_1_to_pic_9999.out: New test.
* cobol.dg/group2/add_1_to_positive_pic_S9999.cob: New test.
* cobol.dg/group2/add_1_to_positive_pic_S9999.out: New test.
* cobol.dg/group2/add__1_to_negative_pic_S9999.cob: New test.
* cobol.dg/group2/add__1_to_negative_pic_S9999.out: New test.
* cobol.dg/group2/ambiguous_PERFORM.cob: New test.
* cobol.dg/group2/ambiguous_PERFORM.out: New test.
* cobol.dg/group2/cbltypes.cpy: New test.
* cobol.dg/group2/compare_float_to_other_types.cob: New test.
* cobol.dg/group2/compare_float_to_other_types.out: New test.
* cobol.dg/group2/move_numeric_to_alphanumeric.cob: New test.
* cobol.dg/group2/move_numeric_to_alphanumeric.out: New test.

8 days agoOpenMP: Reject omp_{cgroup,pteam,thread}_mem_alloc for static vars in ALLOCATE direct...
Tobias Burnus [Fri, 29 May 2026 14:51:18 +0000 (16:51 +0200)] 
OpenMP: Reject omp_{cgroup,pteam,thread}_mem_alloc for static vars in ALLOCATE directive [PR122892]

Using omp_{cgroup,pteam,thread}_mem_alloc for static variables was not
very useful as currently worded in the spec; hence, OpenMP 6.1 will
disallow it also for for local static variables, OpenMP 6.0 already
disallowed for other static variables. Cf. OpenMP specification
issue #4665.

For Fortran, the check is modified while for C the check was completely
missing. Both has been rectified by this commit. For C++, the allocate
directive still has to be added.

PR c/122892

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_allocate): Reject
omp_{cgroup,pteam,thread}_mem_alloc for static variables.

gcc/fortran/ChangeLog:

* openmp.cc (gfc_resolve_omp_allocate): Reject
omp_{cgroup,pteam,thread}_mem_alloc also for local static
variables.

gcc/ChangeLog:

* gimplify.cc (gimplify_scan_omp_clauses): Update for removed
plural -S in GOMP_OMP_PREDEF_ALLOC_THREAD.

include/ChangeLog:

* gomp-constants.h (GOMP_OMP_PREDEF_ALLOC_THREADS): Rename to ...
(GOMP_OMP_PREDEF_ALLOC_THREAD): ... this.
(GOMP_OMP_PREDEF_ALLOC_CGROUP, GOMP_OMP_PREDEF_ALLOC_PTEAM): Define
with the value of omp_{cgroup,pteam}_mem_alloc

libgomp/ChangeLog:

* allocator.c (_Static_assert): Add asserts for the values of
GOMP_OMP_PREDEF_ALLOC_CGROUP and GOMP_OMP_PREDEF_ALLOC_PTEAM.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/allocate-static-3.f90: Modify to also
disallow local static variables.
* c-c++-common/gomp/allocate-20.c: New test.

8 days agolibgcc: Support -mcall-ms2sysv-xlogues on FreeBSD/x86
Rainer Orth [Fri, 29 May 2026 14:24:40 +0000 (16:24 +0200)] 
libgcc: Support -mcall-ms2sysv-xlogues on FreeBSD/x86

With the bulk of the gcc.target/x86_64/abi tests fixed on FreeBSD/amd64,
a couple remain:

FAIL: gcc.target/x86_64/abi/ms-sysv/ms-sysv.c -mcall-ms2sysv-xlogues -O2 "-DGEN_ARGS=-p0\ --omit-rbp-clobbers" (test for excess errors)

and five more.  They all fail to link like

gld-2.46: /tmp//ccXprYoX.o: in function `msabi_00_0':
ms-sysv.c:(.text+0x30): undefined reference to `__sse_savms64f_12'

and many more missing symbols.  Those are usually provided in libgcc.a
by i386/t-msabi, so this patch includes them on FreeBSD/x86, too.  As
with the previous fixes, the resms64*.h and savms64*.h files need to
include .note.GNU-stack, too.

Bootstrapped without regressions on amd64-pc-freebsd15.0 with both gld
and /usr/bin/ld (lld), and x86_64-pc-linux-gnu.

2026-03-19  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libgcc:
* config.host <i[34567]86-*-freebsd*> (tmake_file): Add
i386/t-msabi.
<x86_64-*-freebsd*>: Likewise.
* config/i386/i386-asm.h: Update comment.

* config/i386/resms64.h: Use .note.GNU-stack on FreeBSD, too.
* config/i386/resms64f.h: Likewise.
* config/i386/resms64fx.h: Likewise.
* config/i386/resms64x.h: Likewise.
* config/i386/savms64.h: Likewise.
* config/i386/savms64f.h: Likewise.

8 days agogccrs: workaround -Wrestrict false positive [PR114385]
Marc Poulhiès [Thu, 28 May 2026 20:11:52 +0000 (22:11 +0200)] 
gccrs: workaround  -Wrestrict false positive [PR114385]

Recent change gives:

In file included from /gccrs/build/prev-x86_64-pc-linux-gnu/libstdc++-v3/include/string:45,
                 from ../../gcc/rust/rust-system.h:34,
                 from ../../gcc/rust/lex/rust-token.cc:19:
In static member function 'static constexpr std::char_traits<char>::char_type* std::char_traits<char>::copy(char_type*, const char_type*, std::size_t)',
    inlined from 'static constexpr void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_S_copy(_CharT*, const _CharT*, size_type) [with _CharT = char; _Traits = std:
:char_traits<char>; _Alloc = std::allocator<char>]' at /gccrs/build/prev-x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:4
87:21,
    inlined from 'static constexpr void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_S_copy(_CharT*, const _CharT*, size_type) [with _CharT = char; _Traits = std:
:char_traits<char>; _Alloc = std::allocator<char>]' at /gccrs/build/prev-x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:4
82:7,
    inlined from 'constexpr void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_mutate(size_type, size_type, const _CharT*, size_type) [with _CharT = char; _Trait
s = std::char_traits<char>; _Alloc = std::allocator<char>]' at /gccrs/build/prev-x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_st
ring.tcc:403:15,
    inlined from 'constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_append(const _CharT*, size_type) [
with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' at /gccrs/build/prev-x86_64-pc-linux-gnu/libstdc+
+-v3/include/bits/basic_string.tcc:498:17,
    inlined from 'constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const _CharT*, size_type) [wit
h _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' at /gccrs/build/prev-x86_64-pc-linux-gnu/libstdc++-v
3/include/bits/basic_string.h:1624:18,
    inlined from 'constexpr _Str std::__str_concat(const typename _Str::value_type*, typename _Str::size_type, const typename _Str::value_type*, typename _Str::size_type,
const typename _Str::allocator_type&) [with _Str = __cxx11::basic_string<char>]' at /gccrs/build/prev-x86_64-pc-linux-gnu/libstdc++-v3/
include/bits/basic_string.h:3908:19,
    inlined from 'constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*) [with
_CharT = char; _Traits = char_traits<char>; _Alloc = allocator<char>]' at /gccrs/build/prev-x86_64-pc-linux-gnu/libstdc++-v3/include/bi
ts/basic_string.h:3984:31,
    inlined from 'std::string Rust::Token::as_string() const' at ../../gcc/rust/lex/rust-token.cc:251:45:
/gccrs/build/prev-x86_64-pc-linux-gnu/libstdc++-v3/include/bits/char_traits.h:432:56: error: 'void* __builtin_memcpy(void*, const void*
, long unsigned int)' accessing 18446744073709551609 or more bytes at offsets 0 and 0 overlaps 9223372036854775795 bytes at offset -9223372036854775802 [-Werror=restrict]
  432 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
      |                                        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~

Split the concatenation to avoid the warning.

Fix comes from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125404#c2

gcc/rust/ChangeLog:
PR tree-optimization/114385
* lex/rust-token.cc (Token::as_string): split concatenation.

Co-authored-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
8 days ago[riscv] Fix sync builtins unspec->unspecv
Nathan Sidwell [Thu, 28 May 2026 12:35:17 +0000 (08:35 -0400)] 
[riscv] Fix sync builtins unspec->unspecv

gcc/
* config/riscv/sync.md: Move & rename atomic unspec enums to unspecv
enum. Use renamed UNSPECV_$NAME enums.
* config/riscv/sync-rvwmo.md: Use renamed UNSPECV_$NAME enums.
* config/riscv/sync-ztso.md: Use renamed UNSPECV_$NAME enums.

8 days agoaarch64: add __ARM_FEATURE_ macros for SVE2.2 and SME2.2
Artemiy Volkov [Thu, 12 Mar 2026 12:21:06 +0000 (12:21 +0000)] 
aarch64: add __ARM_FEATURE_ macros for SVE2.2 and SME2.2

This patch defines __ARM_FEATURE_ macros for the SVE2.2 and SME2.2
extensions, together with necessary new tests.  In the v1 of the series
(https://gcc.gnu.org/pipermail/gcc-patches/2026-February/707393.html),
this was a part of the first patch, but now it's been moved to the tail
end of the series so that these definitions aren't visible before the
contents of the extensions are actually available.

gcc/ChangeLog:

* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins):
Emit definitions for __ARM_FEATURE_{SVE,SME}2p2.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/pragma_cpp_predefs_3.c: Add SVE2p2 tests.
* gcc.target/aarch64/pragma_cpp_predefs_4.c: Add SME2p2 test.

8 days agoaarch64: implement FMUL SME instruction
Artemiy Volkov [Fri, 16 Jan 2026 13:09:52 +0000 (13:09 +0000)] 
aarch64: implement FMUL SME instruction

The SME2.2 extension introduces the following variants of a new
streaming-mode instruction:

- FMUL (Multi-vector floating-point multiply by vector)
- FMUL (Multi-vector floating-point multiply)

The first operand is a multi-vector consisting of two or four vectors, and
the second operand either has the same type, or is a single vector of the
underlying type.  New intrinsics are documented in the ACLE manual [0] and
are as follows:

svfloat{16,32,64}x{2,4}_t svmul[_single_f{16,32,64}_x{2,4}]
  (svfloat{16,32,64}x{2,4}_t zd, svfloat{16,32,64}_t zm) __arm_streaming;

svfloat{16,32,64}x{2,4}_t svmul[_f{16,32,64}_x{2,4}]
  (svfloat{16,32,64}x{2,4}_t zd, svfloat{16,32,64}x{2,4}_t zm) __arm_streaming;

This patch implements the above changes throughout the SVE builtin
description files and aarch64-sve2.md.

[0] https://github.com/ARM-software/acle

gcc/ChangeLog:

* config/aarch64/aarch64-sve-builtins-sve2.def (svmul): Define new
SVE function variant.
* config/aarch64/aarch64-sve2.md (@aarch64_sve_<optab><mode>): New
instruction pattern.
(@aarch64_sve_<optab><mode>_single): Likewise.
* config/aarch64/aarch64.h (TARGET_STREAMING_SME2p2): New macro.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sme2/acle-asm/mul_f16_x2.c: New test.
* gcc.target/aarch64/sme2/acle-asm/mul_f16_x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mul_f32_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mul_f32_x4.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mul_f64_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/mul_f64_x4.c: Likewise.

8 days agoaarch64: implement changes for COMPACT and EXPAND SVE instructions
Artemiy Volkov [Sat, 10 Jan 2026 15:16:59 +0000 (15:16 +0000)] 
aarch64: implement changes for COMPACT and EXPAND SVE instructions

SVE2.2 and SME2.2 extensions introduce the following changes related to
COMPACT/EXPAND instructions:

- COMPACT (Copy Active vector elements to lower-numbered elements) for 8-
  and 16-bit-wide vector elements: these variants of an existing instruction
  are new in SVE2.2 (or in streaming mode, SME2.2)
- COMPACT (Copy Active vector elements to lower-numbered elements) for 32-
  and 64-bit-wide vector elements: previously only legal in non-streaming
  mode, these variants are now allowed in streaming mode under SME2.2
- EXPAND (Copy lower-numbered vector elements to Active elements): this
  instruction is new in SVE2.2 (or in streaming mode, SME2.2)

The new supporting intrinsics are documented in the ACLE manual [0] and
are as follows:

sv{uint,int}{8,16}_t svcompact[_{u,s}{8,16}]
  (svbool_t pg, sv{uint,int}{8,16}_t zn);
sv{mfloat8,bfloat16,float16}_t svcompact[_{mf8,bf16,f16}]
  (svbool_t pg, sv{mfloat8,bfloat16,float16}_t zn);

sv{uint,int}{8,16,32,64}_t svexpand[_{u,s}{8,16,32,64}]
  (svbool_t pg, sv{uint,int}{8,16,32,64}_t zn);
svfloat{16,32,64}_t svexpand[_f{16,32,64}]
  (svbool_t pg, svfloat{16,32,64}_t zn);
sv{mfloat8,bfloat16}_t svexpand[_{mf8,bf16}]
  (svbool_t pg, sv{mfloat8,bfloat16}_t zn);

This patch implements the above changes throughout the SVE builtin
description files and aarch64-sve{,2}.md.

New ASM tests have been added as usual; also, an adjustment has been made
to aarch64-ssve.exp in g++.target/ to reflect the fact that the svcompact
intrinsic is not nonstreaming-only anymore.

[0] https://github.com/ARM-software/acle

gcc/ChangeLog:

* config/aarch64/aarch64-sve-builtins-base.cc (class svexpand_impl):
Define new SVE function base.
* config/aarch64/aarch64-sve-builtins-base.def (svcompact): Allow
execution in streaming mode when SME2p2 is enabled.
* config/aarch64/aarch64-sve-builtins-base.h (svexpand): Declare
new SVE function base.
* config/aarch64/aarch64-sve-builtins-sve2.def (svcompact): Define
new SVE function.
(svexpand): Likewise.
* config/aarch64/aarch64-sve.md (@aarch64_sve_compact<mode>):
Enable 32- and 64-bit element variants under SME2p2.  New
insn pattern for 8- and 16-bit elements.
(@aarch64_sve_expand<mode>): New insn pattern.
* config/aarch64/aarch64.h (TARGET_SVE_OR_SME2p2): New macro.
* config/aarch64/aarch64.md (UNSPEC_SVE_EXPAND): New UNSPEC.

gcc/testsuite/ChangeLog:

* g++.target/aarch64/sve/aarch64-ssve.exp: Add sve2p2 to the
target string.  Move svcompact from $nonstreaming_only to
$streaming_ok.
* gcc.target/aarch64/sve2/acle/asm/compact_bf16.c: New test.
* gcc.target/aarch64/sve2/acle/asm/compact_f32.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/compact_f64.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/compact_mf8.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/compact_s16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/compact_s32.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/compact_s64.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/compact_s8.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/compact_u16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/compact_u32.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/compact_u64.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/compact_u8.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/expand_bf16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/expand_f32.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/expand_f64.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/expand_mf8.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/expand_s16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/expand_s32.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/expand_s64.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/expand_s8.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/expand_u16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/expand_u32.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/expand_u64.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/expand_u8.c: Likewise.

8 days agoaarch64: implement FIRSTP and LASTP SVE instructions
Artemiy Volkov [Wed, 17 Dec 2025 13:27:21 +0000 (13:27 +0000)] 
aarch64: implement FIRSTP and LASTP SVE instructions

This commit implements patterns and intrinsics for these two instructions
new in SVE2.2 (or in streaming mode, SME2.2):

- FIRSTP (Scalar index of first true predicate element (predicated))
- LASTP (Scalar index of last true predicate element (predicated))

The new intrinsics are documented in the ACLE manual [0] and have the
following signatures:

int64_t svfirstp_b{8,16,32,64} (svbool_t pg, svbool_t pn);
int64_t svlastp_b{8,16,32,64} (svbool_t pg, svbool_t pn);

The intrinsics are implemented in the usual way; the new
svfirst_lastp_impl base class is used for both families.  The ->fold ()
method implements constant folding except for LASTP under
-msve-vector-bits=scalable.  On the .md side, the patterns for both new
instructions are implemented using UNSPECs as they can't be expressed in
terms of standard RTL.

Included are standard asm tests (which are heavily based on cntp_* tests
from the sve directory), as well as some general C tests
demonstrating aforementioned optimizations when PG and/or PN are constant
vectors.

[0] https://github.com/ARM-software/acle

gcc/ChangeLog:

* config/aarch64/aarch64-sve-builtins-sve2.cc
(class svfirst_lastp_impl): Define new SVE function base class.
(svfirstp): Define new SVE function base.
(svlastp): Likewise.
* config/aarch64/aarch64-sve-builtins-sve2.def (svfirstp): Define
new SVE function.
(svlastp): Likewise.
* config/aarch64/aarch64-sve-builtins-sve2.h (svfirstp): Declare
new SVE function base.
* config/aarch64/aarch64-sve2.md (@aarch64_pred_firstp<mode>): New
insn pattern.
(@aarch64_pred_lastp<mode>): Likewise.
* config/aarch64/iterators.md (UNSPEC_FIRSTP): New UNSPEC.
(UNSPEC_LASTP): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve2/acle/asm/firstp_b16.c: New test.
* gcc.target/aarch64/sve2/acle/asm/firstp_b32.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/firstp_b64.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/firstp_b8.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/lastp_b16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/lastp_b32.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/lastp_b64.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/lastp_b8.c: Likewise.
* gcc.target/aarch64/sve2/acle/general/firstp.c: Likewise.
* gcc.target/aarch64/sve2/acle/general/lastp.c: Likewise.

8 days agoaarch64: implement FRINT32/64 SVE instructions
Artemiy Volkov [Thu, 11 Dec 2025 11:17:46 +0000 (11:17 +0000)] 
aarch64: implement FRINT32/64 SVE instructions

SVE2.2 (or in streaming mode, SME2.2) adds the following SVE
instructions:

- FRINT32X (Floating-point round to 32-bit integer (predicated))
- FRINT32Z (Floating-point round to 32-bit integer, rounding toward zero
  (predicated))
- FRINT64X (Floating-point round to 64-bit integer (predicated))
- FRINT64Z (Floating-point round to 64-bit integer, rounding toward zero
  (predicated))

The intrinsics that expand to them are defined in the ACLE manual [0]:

svfloat{32,64}_t svrint32x{_f32,_f64}_z
  (svbool_t pg, svfloat{32,64}_t zn);
svfloat{32,64}_t svrint32x{_f32,_f64}_x
  (svbool_t pg, svfloat{32,64}_t zn);
svfloat{32,64}_t svrint32x{_f32,_f64}_m
  (svfloat{32,64}_t inactive, svbool_t pg, svfloat{32,64}_t zn);

svfloat{32,64}_t svrint32z{_f32,_f64}_z
  (svbool_t pg, svfloat{32,64}_t zn);
svfloat{32,64}_t svrint32z{_f32,_f64}_x
  (svbool_t pg, svfloat{32,64}_t zn);
svfloat{32,64}_t svrint32z{_f32,_f64}_m
  (svfloat{32,64}_t inactive, svbool_t pg, svfloat{32,64}_t zn);

svfloat{32,64}_t svrint64x{_f32,_f64}_z
  (svbool_t pg, svfloat{32,64}_t zn);
svfloat{32,64}_t svrint64x{_f32,_f64}_x
  (svbool_t pg, svfloat{32,64}_t zn);
svfloat{32,64}_t svrint64x{_f32,_f64}_m
  (svfloat{32,64}_t inactive, svbool_t pg, svfloat{32,64}_t zn);

svfloat{32,64}_t svrint64z{_f32,_f64}_z
  (svbool_t pg, svfloat{32,64}_t zn);
svfloat{32,64}_t svrint64z{_f32,_f64}_x
  (svbool_t pg, svfloat{32,64}_t zn);
svfloat{32,64}_t svrint64z{_f32,_f64}_m
  (svfloat{32,64}_t inactive, svbool_t pg, svfloat{32,64}_t zn);

The implementation of new intrinsics and RTL patterns is quite
straightforward, and a standard set of ASM tests has been added to the
sve2/acle/asm directory.

[0] https://github.com/ARM-software/acle

Changes since v1:
- Append extension names to comments in aarch64-sve2.md.

gcc/ChangeLog:

* config/aarch64/aarch64-sve-builtins-sve2.cc (svrint32x): Define
new function base.
(svrint32z): Likewise.
(svrint64x): Likewise.
(svrint64z): Likewise.
* config/aarch64/aarch64-sve-builtins-sve2.def (svrint32x):
Define new SVE function.
(svrint32z): Likewise.
(svrint64x): Likewise.
(svrint64z): Likewise.
* config/aarch64/aarch64-sve-builtins-sve2.h (svrint32x): Declare
new function base.
(svrint32z): Likewise.
(svrint64x): Likewise.
(svrint32z): Likewise.
* config/aarch64/aarch64-sve-builtins.cc (TYPES_sd_float): New
type set.
(sd_float): New SVE type array.
* config/aarch64/aarch64-sve2.md (@cond_<frintnzs_op><mode>): New
insn pattern.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve2/acle/asm/rint32x_f32.c: New test.
* gcc.target/aarch64/sve2/acle/asm/rint32x_f64.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rint32z_f32.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rint32z_f64.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rint64x_f32.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rint64x_f64.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rint64z_f32.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rint64z_f64.c: Likewise.

8 days agoaarch64: add zeroing forms for predicated SVE top FP conversions
Artemiy Volkov [Sat, 10 Jan 2026 07:40:59 +0000 (07:40 +0000)] 
aarch64: add zeroing forms for predicated SVE top FP conversions

SVE2.2 (or in streaming mode, SME2.2) adds support for zeroing
predication for the following SVE FP conversion instructions:

SVE1:
- BFCVTNT (Single-precision convert to BFloat16 (top, predicated))

SVE2:
- FCVTLT (Floating-point widening convert (top, predicated))
- FCVTNT (Floating-point narrowing convert (top, predicated))
- FCVTXNT (Double-precision convert to single-precision, rounding
  to odd (top, predicated))

Additionally, this patch implements corresponding intrinsics documented in
the ACLE manual [0] with the following signatures:

svfloat{32,64}_t svcvtlt_{f32[_f16],_f64[_f32]}_z
  (svbool_t pg, svfloat{16,32}_t op);

sv{bfloat16,float16,float32}_t svcvtnt_{f16[_f32],_f32[_f64],_bf16[_f32]}_z
  (sv{bfloat16,float16,float32}_t even, svbool_t pg, svfloat{32,64}_t op);

svfloat32_t svcvtxnt_f32[_f64]_z
  (svfloat32_t even, svbool_t pg, svfloat64_t op);

This patch adds an alternative that emits a single zeroing-predication
form of the instructions mentioned above (as long as the sve2p2_or_sme2p2
condition holds) to corresponding RTL patterns.  For narrowing conversions
([B]FCVTNT and FCVTXNT), since an additional merge operand controlling the
values of inactive lanes is required, the intrinsics have been changed to
use the new top_narrowing_convert SVE function base class; this new class
injects a const_vector selector operand at expand time.  Depending on the
value of this operand, either the destination vector or a constant zero
vector is used to supply values for inactive lanes.

The new tests all have "_z" in their names since they only cover the
zeroing-predication versions of their respective intrinsics.

[0] https://github.com/ARM-software/acle

gcc/ChangeLog:

* config/aarch64/aarch64-sve-builtins-base.cc (class svcvtnt_impl):
Remove.
(svcvtnt): Redefine using narrowing_top_convert.
* config/aarch64/aarch64-sve-builtins-functions.h
(class narrowing_top_convert): New SVE function base class.
(NARROWING_TOP_CONVERT0): New function-like macro for specializing
narrowing_top_convert.
(NARROWING_TOP_CONVERT1): Likewise.
* config/aarch64/aarch64-sve-builtins-sve2.cc (class svcvtxnt_impl):
Remove.
(svcvtxnt): Redefine using narrowing_top_convert.
* config/aarch64/aarch64-sve-builtins-sve2.def (svcvtlt): Allow
zeroing predication.
(svcvtnt): Likewise.
(svcvtxnt): Likewise.
* config/aarch64/aarch64-sve.md (@aarch64_sve_cvtnt<mode>):
Convert to compact syntax. Add operand 4 for values of
inactive lanes.  New alternative for zeroing predication.
* config/aarch64/aarch64-sve2.md
(*cond_<sve_fp_op><mode>_relaxed): Convert to compact syntax.
New alternative for zeroing predication.
(*cond_<sve_fp_op><mode>_strict): Likewise.
(@aarch64_sve_cvtnt<mode>): Convert to compact syntax. Add
operand 4 for values of inactive lanes.  New alternative for
zeroing predication.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve2/acle/asm/cvtlt_f32_z.c: New test.
* gcc.target/aarch64/sve2/acle/asm/cvtlt_f64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cvtnt_bf16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cvtnt_f16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cvtnt_f32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cvtxnt_f32_z.c: Likewise.

8 days agoaarch64: add zeroing forms for predicated SVE int-/FP-to-FP conversions
Artemiy Volkov [Fri, 9 Jan 2026 19:30:52 +0000 (19:30 +0000)] 
aarch64: add zeroing forms for predicated SVE int-/FP-to-FP conversions

SVE2.2 (or in streaming mode, SME2.2) adds support for zeroing
predication for the following SVE FP conversion instructions:

SVE1:
- SCVTF (Signed integer convert to floating-point (predicated))
- UCVTF (Unsigned integer convert to floating-point (predicated))
- FCVT (Floating-point convert (predicated))
- BFCVT (Single-precision convert to BFloat16 (predicated))

SVE2:
- FCVTX (Double-precision convert to single-precision, rounding to
  odd (predicated))

The SVE1 instructions are spread over several patterns for various
combinations of source/destination widths and FP semantics, and the FCVTX
instruction is serviced by two patterns in the aarch64-sve2.md file via
the SVE2_COND_FP_UNARY_NARROWB iterator (one for strict, the other for
relaxed FP semantics).  The patch adds an alternative that emits a single
zeroing-predication version of an instruction whenever the merge operand
is a constant zero vector and the sve2p2_or_sme2p2 condition holds.

As with the original cvt_b?f* tests in the sve/acle/asm directory,
testcases for conversions from both integral and floating-point types
coexist in the same files and are grouped only by the destination type.
FCVTX tests are added in a separate file.

gcc/ChangeLog:

* config/aarch64/aarch64-sve.md
(*cond_<optab>_nonextend<SVE_FULL_HSDI:mode><SVE_FULL_F:mode>_relaxed):
New alternative for zeroing predication.  Add `arch` attribute
to every alternative.
(*cond_<optab>_nonextend<SVE_HSDI:mode><SVE_PARTIAL_F:mode>_relaxed):
Likewise.
(*cond_<optab>_nonextend<SVE_FULL_HSDI:mode><SVE_FULL_F:mode>_strict):
Likewise.
(*cond_<optab>_extend<VNx4SI_ONLY:mode><VNx2DF_ONLY:mode>):
Likewise.
(*cond_<optab>_trunc<SVE_FULL_SDF:mode><SVE_FULL_HSF:mode>):
Likewise.
(*cond_<optab>_trunc<SVE_SDF:mode><SVE_PARTIAL_HSF:mode>):
Likewise.
(*cond_<optab>_trunc<VNx4SF_ONLY:mode><VNx8BF_ONLY:mode>):
Likewise.
(*cond_<optab>_nontrunc<SVE_FULL_HSF:mode><SVE_FULL_SDF:mode>):
Likewise.
(*cond_<optab>_nontrunc<SVE_PARTIAL_HSF:mode><SVE_SDF:mode>_relaxed):
Likewise.
* config/aarch64/aarch64-sve2.md
(*cond_<sve_fp_op><mode>_any_relaxed): Likewise.
(*cond_<sve_fp_op><mode>_any_strict): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve2/acle/asm/cvt_bf16_z.c: New test.
* gcc.target/aarch64/sve2/acle/asm/cvt_f16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cvt_f32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cvt_f64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cvtx_f32_z.c: Likewise.

8 days agoaarch64: add zeroing forms for predicated SVE FP-to-integer conversions
Artemiy Volkov [Wed, 14 Jan 2026 13:32:58 +0000 (13:32 +0000)] 
aarch64: add zeroing forms for predicated SVE FP-to-integer conversions

SVE2.2 (or in streaming mode, SME2.2) adds support for zeroing predication
for all variants of the following FP-to-integer conversion instructions:

- FCVTZU (Floating-point convert to unsigned integer, rounding toward zero
  (predicated))
- FCVTZS (Floating-point convert to signed integer, rounding toward zero
  (predicated))

To implement this change, this patch adds a new alternative to patterns
involving the SVE_COND_FCVTI iterator and accepting an independent value
as the merge operand.  The new alternative has the new zeroing-predication
forms as the output string and is only enabled when sve2p2_or_sme2p2 is
true in the target architecture.

The new ASM tests only cover the "_z" versions of the intrinsics and as
such all have the "_z" suffix in their name, and are grouped by type of
the destination operand.

gcc/ChangeLog:

* config/aarch64/aarch64-sve.md
(*cond_<optab>_nontrunc<SVE_FULL_F:mode><SVE_FULL_HSDI:mode>_relaxed):
New alternative for zeroing predication.  Add `arch` attribute
to every alternative.
(*cond_<optab>_nontrunc<SVE_PARTIAL_F:mode><SVE_HSDI:mode>_relaxed):
Likewise.
(*cond_<optab>_nontrunc<SVE_FULL_F:mode><SVE_FULL_HSDI:mode>_strict):
Likewise.
(*cond_<optab>_trunc<VNx2DF_ONLY:mode><VNx4SI_ONLY:mode>):
Likewise.
(*cond_<optab>_trunc<VNx2DF_ONLY:mode><VNx2SI_ONLY:mode>_relaxed):
Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve2/acle/asm/cvt_s16_z.c: New test.
* gcc.target/aarch64/sve2/acle/asm/cvt_s32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cvt_s64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cvt_u16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cvt_u32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cvt_u64_z.c: Likewise.

8 days agoaarch64: add zeroing forms for predicated SVE FP unary operations
Artemiy Volkov [Fri, 9 Jan 2026 19:05:28 +0000 (19:05 +0000)] 
aarch64: add zeroing forms for predicated SVE FP unary operations

SVE2.2 (or in streaming mode, SME2.2) adds support for zeroing predication
for the following floating-point unary instructions:

SVE:

- FABS (Floating-point absolute value (predicated))
- FNEG (Floating-point negate (predicated))
- FRECPX (Floating-point reciprocal exponent (predicated))
- FRINT<r> (Floating-point round to integral value (predicated))
- FSQRT (Floating-point square root (predicated))

SVE2:
- FLOGB (Floating-point base 2 logarithm as integer (predicated))

These instructions are covered by SVE_COND_FP_UNARY for SVE and
SVE2_COND_INT_UNARY_FP for SVE2, thus this change is limited to two
patterns in each of aarch64-sve.md and aarch64-sve2.md (one for relaxed,
and one for strict FP semantics).  The change is to add a new alternative
with Dz as operand 3 (the merge operand), enabled only if the
sve2p2_or_sme2p2 condition holds and emitting a single instruction with
zeroing predication.

The tests that have been added are based on the original SVE tests
for corresponding instructions, but all have a "_z" suffix in their name
since they only test codegen for the "_z" variants of the corresponding
intrinsics.

gcc/ChangeLog:

* config/aarch64/aarch64-sve.md (*cond_<optab><mode>_any_relaxed):
New alternative for zeroing predication.  Add `arch` attribute
to every alternative.
(*cond_<optab><mode>_any_strict): Likewise.
* config/aarch64/aarch64-sve2.md (*cond_<sve_fp_op><mode>):
Likewise.
(*cond_<sve_fp_op><mode>_strict): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve2/acle/asm/abs_f16_z.c: New test.
* gcc.target/aarch64/sve2/acle/asm/abs_f32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/abs_f64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/logb_f16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/logb_f32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/logb_f64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/neg_f16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/neg_f32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/neg_f64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/recpx_f16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/recpx_f32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/recpx_f64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rinta_f16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rinta_f32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rinta_f64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rinti_f16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rinti_f32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rinti_f64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rintm_f16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rintm_f32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rintm_f64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rintn_f16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rintn_f32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rintn_f64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rintp_f16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rintp_f32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rintp_f64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rintx_f16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rintx_f32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rintx_f64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rintz_f16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rintz_f32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rintz_f64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/sqrt_f16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/sqrt_f32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/sqrt_f64_z.c: Likewise.

8 days agoaarch64: add zeroing forms for predicated SVE bit reversal operations
Artemiy Volkov [Fri, 9 Jan 2026 17:50:22 +0000 (17:50 +0000)] 
aarch64: add zeroing forms for predicated SVE bit reversal operations

SVE2.2 (or in streaming mode, SME2.2) adds support for zeroing
predication for the following SVE bit reversal instructions:

- REVB, REVH, REVW (Reverse bytes / halfwords / words within elements
  (predicated))
- REVD (Reverse 64-bit doublewords in elements (predicated)) (SVE2 only)

The first three are covered by the SVE_INT_UNARY code iterator, and REVD,
being SVE2-only, has a standalone pattern in aarch64-sve2.md.  This patch
adds an alternative for the zeroing-predication forms of the original
instructions.  The pattern for REVD also required changes to the predicate
for operand 3 to accept constant zero RTX whenever SVE2.2 is enabled.
Additionally, use the /z form of the REVD instruction for PRED_X
predication to save a data dependency.

The tests that have been added are based on the original SVE/SVE2 tests
for corresponding instructions, but all have a "_z" suffix in their name
since they only test codegen for the "_z" variants of the corresponding
intrinsics.

gcc/ChangeLog:

* config/aarch64/aarch64-sve.md (@cond_<optab><mode>):
New alternative for zeroing predication.  Add `arch` attribute
to every alternative.
* config/aarch64/aarch64-sve2.md (@aarch64_pred_<optab><mode>):
Use zeroing predication variant for PRED_X.
(@cond_<optab><mode>): Accept constant zero as operand 3.  New
alternative for zeroing predication.  Add `arch` attribute to
every alternative.
* config/aarch64/predicates.md (aarch64_simd_reg_or_direct_zero):
New predicate.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve2/acle/asm/revb_s16_z.c: New test.
* gcc.target/aarch64/sve2/acle/asm/revb_s32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revb_s64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revb_u16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revb_u32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revb_u64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_bf16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_f16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_f32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_f64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_s16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_s32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_s64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_s8_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_u16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_u32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_u64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_u8_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revh_s32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revh_s64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revh_u32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revh_u64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revw_s64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revw_u64_z.c: Likewise.

8 days agoaarch64: add zeroing forms for predicated SVE integer extends
Artemiy Volkov [Wed, 31 Dec 2025 11:30:05 +0000 (11:30 +0000)] 
aarch64: add zeroing forms for predicated SVE integer extends

SVE2.2 (or in streaming mode, SME2.2) adds support for zeroing
predication for the following SVE integer extension instructions:

- SXTB, SXTH, SXTW (Signed byte / halfword / word extend (predicated))
- UXTB, UXTH, UXTW (Unsigned byte / halfword / word extend (predicated))

The functional change is limited to two patterns in aarch64-sve.md
handling SVE extends merging with an independent value, to which this
patch adds a new alternative that emits a single zeroing-predication form
of an instruction as long as the sve2p2_or_sme2p2 condition holds.

The tests that have been added are based on the original SVE tests
for corresponding instructions, but all have a "_z" suffix in their name
since they only test codegen for the "_z" variants of the corresponding
intrinsics.

gcc/ChangeLog:

* config/aarch64/aarch64-sve.md
(@aarch64_cond_sxt<SVE_FULL_HSDI:mode><SVE_PARTIAL_I:mode>):
New alternative for zeroing predication.  Add `arch` attribute
to every alternative.
(*cond_uxt<mode>_any): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve2/acle/asm/extb_s16_z.c: New test.
* gcc.target/aarch64/sve2/acle/asm/extb_s32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/extb_s64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/extb_u16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/extb_u32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/extb_u64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/exth_s32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/exth_s64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/exth_u32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/exth_u64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/extw_s64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/extw_u64_z.c: Likewise.

8 days agoaarch64: add zeroing forms for predicated SVE integer unary operations
Artemiy Volkov [Fri, 9 Jan 2026 17:48:19 +0000 (17:48 +0000)] 
aarch64: add zeroing forms for predicated SVE integer unary operations

SVE2.2 (or in streaming mode, SME2.2) adds support for zeroing predication
for the following integer unary instructions:

SVE:
- ABS (Absolute value (predicated))
- CLS (Count leading sign bits (predicated))
- CLZ (Count leading zero bits (predicated))
- CNT (Count non-zero bits (predicated))
- CNOT (Logically invert boolean condition (predicated))
- NEG (Negate (predicated))
- NOT (Bitwise invert (predicated))
- RBIT (Reverse bits (predicated))

SVE2:
- SQABS (Signed saturating absolute value)
- SQNEG (Signed saturating negate)
- URECPE (Unsigned reciprocal estimate (predicated))
- URSRQTE (Unsigned reciprocal square root estimate (predicated))

These instructions are covered by the SVE_INT_UNARY and SVE2_U32_UNARY
iterators, except for CNOT, which has a standalone pattern.  Therefore,
three patterns across aarch64-sve.md and aarch64-sve2.md had to be
provided with a new alternative, having Dz (const_vector of all zeroes) as
the merge operand.  The new alternatives are conditional upon the
sve2p2_or_sme2p2 test added earlier, and emit the new zeroing-predication
forms of the original instructions.

The tests that have been added are based on the original SVE/SVE2 tests
for corresponding instructions, but all have a "_z" suffix in their name
since they only test codegen for the "_z" variants of the corresponding
intrinsics.

gcc/ChangeLog:

* config/aarch64/aarch64-sve.md (*cond_<optab><mode>_any):
New alternative for zeroing predication.  Add `arch` attribute
to every alternative.
(*cond_cnot<mode>_any): Likewise.
* config/aarch64/aarch64-sve2.md: (*cond_<sve_int_op><mode>):
Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve2/acle/asm/abs_s16_z.c: New test.
* gcc.target/aarch64/sve2/acle/asm/abs_s32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/abs_s64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/abs_s8_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cls_s16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cls_s32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cls_s64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cls_s8_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/clz_s16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/clz_s32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/clz_s64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/clz_s8_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/clz_u16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/clz_u32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/clz_u64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/clz_u8_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cnot_s16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cnot_s32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cnot_s64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cnot_s8_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cnot_u16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cnot_u32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cnot_u64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cnot_u8_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cnt_s16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cnt_s32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cnt_s64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cnt_s8_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cnt_u16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cnt_u32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cnt_u64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/cnt_u8_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/neg_s16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/neg_s32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/neg_s64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/neg_s8_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/not_s16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/not_s32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/not_s64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/not_s8_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/not_u16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/not_u32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/not_u64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/not_u8_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/qabs_s16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/qabs_s32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/qabs_s64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/qabs_s8_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/qneg_s16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/qneg_s32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/qneg_s64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/qneg_s8_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rbit_s16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rbit_s32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rbit_s64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rbit_s8_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rbit_u16_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rbit_u32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rbit_u64_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rbit_u8_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/recpe_u32_z.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/rsqrte_u32_z.c: Likewise.

8 days agoaarch64: add preliminary definitions for SVE2.2/SME2.2
Artemiy Volkov [Thu, 12 Mar 2026 12:19:29 +0000 (12:19 +0000)] 
aarch64: add preliminary definitions for SVE2.2/SME2.2

This is a preparatory patch for the bulk of the SVE2.2/SME2.2 support
series, putting into place some machinery used by the later patches.  This
includes TARGET_* constants that are set based on ISA flags, and new
match_test definitions that are used to enable/disable individual
instruction patterns/alternatives.

On the testsuite side of things, this patch adds two new effective-target
checks in lib/target-supports.exp, one for each of SVE2.2-capable HW and
toolchain.

v1 of this patch also contained __ARM_FEATURE_* macro definitions for
SVE2.2 and SME2.2, but these have been moved to the end of the series to
improve bisection.

gcc/ChangeLog:

* config/aarch64/aarch64.h (TARGET_SVE2p2): New macro.
(TARGET_SME2p2): Likewise.
(TARGET_SVE2p2_OR_SME2p2): Likewise.
* config/aarch64/aarch64.md (arches): Add sve2p2_or_sme2p2 enum
constant.
(arch): Add test for sve2p2_or_sme2p2.
* doc/invoke.texi: Document sve2p2 and sme2p2 extensions.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp
(check_effective_target_aarch64_sve2p2_hw): New target check.
(check_effective_target_aarch64_sve2p2_ok): New target check.
(exts_sve2): Add sme2p2.

8 days agoi386: Rewrite index*1+disp into base+disp
LIU Hao [Fri, 29 May 2026 10:17:53 +0000 (12:17 +0200)] 
i386: Rewrite index*1+disp into base+disp

Sometimes, GCC may synthesize an address like [index * 1 + displacement]. This
commit rewrites that into [base + displacement], to eliminate the requirement
of an SIB byte (which is always the case, as RSP isn't a valid index), and to
allow a small displacement to be encoded in one byte.

gcc/ChangeLog:

* config/i386/i386.cc (ix86_decompose_address): Add a special case where
there's no base, there's an index, and the scale is 1.

gcc/testsuite/ChangeLog:

* gcc.target/i386/rewrite-sib-without-base.c: New test.

Signed-off-by: LIU Hao <lh_mouse@126.com>
8 days agotestsuite: Tweak sse2-p{add,sub}[bdw]-2.c tests for -march=cascadelake
Roger Sayle [Fri, 29 May 2026 09:26:31 +0000 (10:26 +0100)] 
testsuite: Tweak sse2-p{add,sub}[bdw]-2.c tests for -march=cascadelake

Update the recently added gcc.target/i386/sse2-p{add,sub}[bdw]-2.c
tests for -march=cascadelake.  Committed as obvious.

2026-05-29  Roger Sayle  <roger@nextmovesoftware.com>

gcc/testsuite/ChangeLog
* gcc.target/i386/sse2-paddb-2.c: Support -march=cascadelake.
* gcc.target/i386/sse2-paddd-2.c: Likewise.
* gcc.target/i386/sse2-paddw-2.c: Likewise.
* gcc.target/i386/sse2-psubb-2.c: Likewise.
* gcc.target/i386/sse2-psubd-2.c: Likewise.
* gcc.target/i386/sse2-psubw-2.c: Likewise.

8 days agoada: Fix bug when reading multibyte utf-8 character
Marc Poulhiès [Fri, 27 Mar 2026 15:29:16 +0000 (16:29 +0100)] 
ada: Fix bug when reading multibyte utf-8 character

A multibyte utf-8 character has its msb set, which is the sign bit for a
signed value.

The get_immediate C function, for linux (and others) uses read() when
the character is read from a terminal. It was using a "char" type, so it
can be both signed or unsigned (target dependent). On target where char
is signed, it means that reading a multibyte utf-8 character will
produce a negative value. For example:

€ = 0xE2 0x82 0xAC

The first byte is 0xE2, which is -30 for a signed char.

Then the value is written in a signed int, still as -30 (0xFFFF_FFE2),
and the caller fails a range check because 0xFFFF_FFE2 is not in the
unsigned range for a Character (0..255).

Fixing the variable to an unsigned char avoids the conversion to a
signed value.

gcc/ada/ChangeLog:

* sysdep.c (getc_immediate_common): Read character as unsigned
value.

8 days agoada: Cleanup of Analyze_Aspect_Specifications and related code
Bob Duff [Thu, 26 Mar 2026 22:25:58 +0000 (18:25 -0400)] 
ada: Cleanup of Analyze_Aspect_Specifications and related code

Rename Decorate to be Decorate_Aspect_Links; seems more readable.
Change it to support N_Attribute_Definition_Clause in addition
to N_Pragma. Move most calls to it into Insert_Aitem.

Move call to Set_Has_Delayed_Rep_Aspects to be near
calls to Set_Has_Delayed_Aspects.

Make Anod and Eloc variables more local to where they are used.

Misc comment improvements, including removing some useless ones.

gcc/ada/ChangeLog:

* sem_ch13.adb (Delay_Aspect): Remove the side effect.
(Decorate): Rename to be Decorate_Aspect_Links.
Generalize.
(Insert_Aitem): Call Decorate_Aspect_Links.
* aspects.ads: Minor comment improvement: we don't need to worry;
we just need to do it.
* einfo.ads: Minor comment improvement.

8 days agoada: Implement AI22-0154 (Revised resolution of indexing aspects)
Gary Dismukes [Tue, 24 Mar 2026 00:40:04 +0000 (00:40 +0000)] 
ada: Implement AI22-0154 (Revised resolution of indexing aspects)

Customer code was running into an error due to a violation of the
rule for indexing aspects that any functions declared in the same
package spec that do not satisfy the legality rules for eligible
indexing functions make the aspects illegal. In this case it was
due to a derived type inheriting a function of the parent type
that had indexing aspects. Consideration of this problem led
to proposing language changes in AI22-0154, which revises the
resolution rules to take the indexing profile requirements into
account (rather than allowing resolution indexing aspect names
to consider any available function declared within the scope).
This set of changes implements the revised resolution rules,
allowing the compiler to accept the customer code.

In some cases the compiler will now issue a warning instead of
ignoring an ineligible candidate entity. Specifically this is
done when a candidate interpretation is a function that has at
least a first formal of the type associated with the aspect,
but doesn't satisfy other requirements of the particular
indexing aspect. We impose this limitation so as to avoid
issuing too many false-positive warnings.

These changes also reduce technical debt by removing code in
Sem_Util.Inherit_Nonoverridable_Aspect that was handling checking
and addition of new indexing functions for derived types via calls
to Check_Function_For_Indexing_Aspect. That handling is now covered
fully by Check_Indexing_Functions (which itself makes calls to
Check_Function_For_Indexing_Aspect).

Additionally, these changes attempt to implement rule changes
specified by AI22-0159/01 (Inheritance for aspects allowed to
denote multiple subprograms), an AI that was added to address
problems identified while finalizing AI22-0154.

gcc/ada/ChangeLog:

* sem_ch6.adb (New_Overloaded_Entity): Add missing call to
Check_For_Primitive_Subprogram (Is_Primitive must be set).
* sem_ch13.ads (Check_Function_For_Indexing_Aspect): Move declaration
to package body.
* sem_ch13.adb (Check_Indexing_Functions): Remove early return for
derived types. Pass appropriate values for the new Boolean parameters
on existing calls to Check_Function_For_Indexing_Aspect. Perform a
second interpretation loop, calling Check_Function_For_Indexing_Aspect
and passing Indexing_Found for the Has_Eligible_Func parameter and True
for the Error_On_Ineligible parameter, and remove the existing call
to Error_Msg_NE that was flagging nonlocal entities (a similar error
is now reported inside procedure Check_Function_For_Indexing_Aspect).
Suppress call to Check_Inherited_Indexing in derived type cases.
(Check_Nonoverridable_Aspect_Subprograms): Remove early return when
the aspect spec does not come from source, so aspects of derived types
will also go through this procedure. Check restrictions of AI22-0159/01
for derived types and inheritance of aspects. Replace iteration over
overloaded interpretations with iteration over Aspect_Subprograms (and
only do that for indexing aspects). Condition Sloc for existing error
check for nonprimitive operations based on whether the aspect comes
from source, posting the error on the entity rather than the aspect
if the aspect is not given explicitly.
(Analyze_Aspects_At_Freeze_Point): Split off a new case alternative
for iterator aspects, and specialize treatment for indexing aspects
by forcing a search for new indexing functions. When none are found,
issue an error only in the case where the type has no inherited
indexing functions. Test that the version is at least Ada_2012 rather
than Ada_2022 for calling Check_Nonoverridable_Aspect_Subprograms.
(Check_Function_For_Indexing_Aspect): Move declaration from the package
spec to the body. Add Has_Eligible_Func and Error_On_Ineligible formals
and update spec comment.
Return early if the candidate subprogram was already inherited (present
in Aspect_Subprograms).
For a scope mismatch on Subp, report error only when Has_Eligible_Func
is False and Error_On_Ineligible is True (and never a warning).
Add "<<" in several calls to Report_Ineligible_Indexing_Function
(formerly Illegal_Indexing) to allow either warnings or errors.
Return without adding subprogram to Aspect_Subprograms when
Error_On_Ineligible is False.
(Report_Ineligible_Indexing_Function): Name changed from
Illegal_Indexing.
Return early when only a warning can be issued and the ineligible
subprogram is inherited, or if its first formal (if any) does not match
the aspect's associated type (to reduce false-positive warnings).
Set Error_Msg_Warn based on Error_On_Ineligible formal.
Report a continuation message identifying the ineligible entity.
Remove comment preceding body that has been obviated by AI22-0154.
* sem_util.adb (Inherit_Nonoverridable_Aspect): Remove the loop over
primitives that was checking and adding eligible primitives. That code
was incomplete, and collection of new indexing functions for derived
types is now handled by Check_Indexing_Functions. Also remove the
associated "???" comment.

8 days agoada: Document the gnatg switch
Tonu Naks [Wed, 11 Mar 2026 12:59:36 +0000 (12:59 +0000)] 
ada: Document the gnatg switch

gcc/ada/ChangeLog:

* doc/gnat_rm.rst: update toctree
* doc/gnat_rm/about_this_guide.rst: add reference
* doc/gnat_rm/gnat_implementation_mode.rst: new file
* opt.ads: remove redundant comment
* gnat_rm.texi: Regenerate.

8 days agoada: Minor typo fix in documentation
Marc Poulhiès [Thu, 26 Mar 2026 12:00:06 +0000 (13:00 +0100)] 
ada: Minor typo fix in documentation

gcc/ada/ChangeLog:

* doc/gnat_rm/gnat_language_extensions.rst (Destructors): fix
typo.
* gnat_rm.texi: Regenerate.

8 days agoada: Complete previous light runtime configuration fix
Ronan Desplanques [Thu, 26 Mar 2026 08:58:56 +0000 (09:58 +0100)] 
ada: Complete previous light runtime configuration fix

A recent fix for light runtime configuration was missing a crucial part:
it left an #include directive that needed to be removed. This patch
completes that fix.

gcc/ada/ChangeLog:

* argv.c: Remove unused include directive.

8 days agoada: Create a boolean version of Warnings_Suppressed
Viljar Indus [Wed, 25 Mar 2026 13:18:52 +0000 (15:18 +0200)] 
ada: Create a boolean version of Warnings_Suppressed

Add a Boolean overload of Warnings_Suppressed that wraps the existing
String_Id version, simplifying call sites that only need to know whether
warnings are suppressed at a location rather than the suppression reason.

gcc/ada/ChangeLog:

* erroutc.ads (Warnings_Suppressed): New Boolean overload.
* errout.adb (Error_Msg_Internal): Use Boolean Warnings_Suppressed.
* errutil.adb (Error_Msg): Likewise.

8 days agoada: Improve error message insertion methods
Viljar Indus [Wed, 25 Mar 2026 10:57:10 +0000 (12:57 +0200)] 
ada: Improve error message insertion methods

Extract the error chain insertion logic into dedicated subprograms.
Insert_Error_Msg adds a new message into the chain and adds the next and
previous pointers, making the deferred Set_Prev_Pointers pass in Finalize
redundant. Find_Msg_Insertion_Point and Is_Before extract the existing
logic for finding the insertion point in Error_Msg_Internal.

gcc/ada/ChangeLog:

* errout.adb (Is_Before): New helper function.
(Find_Msg_Insertion_Point): New procedure.
(Error_Msg_Internal): Use Find_Msg_Insertion_Point and Insert_Error_Msg.
(Finalize): Remove call to Set_Prev_Pointers.
(Set_Prev_Pointers): Removed.
* erroutc.adb (Insert_Error_Msg): New procedure.
* erroutc.ads (Insert_Error_Msg): New declaration.

8 days agoada: Do not set Global_Discard_Names in GNATprove_Mode
Andres Toom [Mon, 16 Mar 2026 09:55:09 +0000 (11:55 +0200)] 
ada: Do not set Global_Discard_Names in GNATprove_Mode

GNATprove now supports the Image attribute of enumerated types. Hence,
it is important to keep the names of the enumeration literals to be able
to properly reason about them.

gcc/ada/ChangeLog:

* gnat1drv.adb (Adjust_Global_Switches): Do not set
Global_Discard_Names in GNATprove_Mode.

8 days agoada: Fix light runtime configurations
Ronan Desplanques [Wed, 25 Mar 2026 13:39:35 +0000 (14:39 +0100)] 
ada: Fix light runtime configurations

A recent changed added a dependency from the environment-related
functions in argv.c to env.c. This broke some runtime configurations that
provide command line support but no environment variable support.

This fixes the issue by moving all of argv.c's environment-related code
to env.c. It also tweaks a comment in passing.

gcc/ada/ChangeLog:

* argv.c (__gnat_env_count) (__gnat_len_env) (__gnat_fill_env): Move
to...
* env.c (__gnat_env_count) (__gnat_len_env) (__gnat_fill_env):
...here. Tweak comment.

8 days agoada: Do not disable conformance warning in GNAT_Mode
Bob Duff [Tue, 24 Mar 2026 22:43:16 +0000 (18:43 -0400)] 
ada: Do not disable conformance warning in GNAT_Mode

The switch -gnatw_p enables a warning during conformance
checking that is stricter than the standard Ada conformance
rules. This patch removes the test for -gnatg mode when
issuing the warning, because that is redundant -- -gnatg
already turns off -gnatw_p.

We do not want this warning enabled in GNAT sources, but there is
no need to have -gnatg involved explicitly.
The same goes for In_Internal_Unit.

gcc/ada/ChangeLog:

* sem_ch6.adb (Subprogram_Subtypes_Have_Same_Declaration):
Remove tests for In_Internal_Unit and GNAT_Mode.

8 days agoada: VAST Check_Entity_Chain
Marc Poulhiès [Thu, 12 Mar 2026 16:28:18 +0000 (17:28 +0100)] 
ada: VAST Check_Entity_Chain

Add Check_Entity_Chain to VAST: checks the Next_Entity/Prev_Entity are
consistent for entity chains.

Currently only checked for entities that are used as Scope.

Fixing existing inconsistencies is not direct.

Any call to Copy_And_Swap creates an incorrect chain, where the new node
has its Prev/Next/First/Last links copied from the original node, but
back links are not changed, leading to something like this for
Copy_And_Swap (Priv, Full):

  ,----,       ,----,       ,----,     ,----,
  | A  |------>| B  |------>|Priv|---->| D  |---> Empty
  |    |<------|    |<------|    |<----|    |
  '----'       '----'       '----'     '----'
                   ^                    ^
                   |        ,----,      |
                   `--------|Full|------`
                            |    |
                            '----'

And then after a while, probably after Exchange_Entities() the links are
incorrect and traversing the chain from First to Last or from Last to
First does not yield the same elements.

gcc/ada/ChangeLog:

* vast.adb (Check_Enum)<Check_Entity_Chain>: Add.
(Status)<Check_Entity_Chain>: Set to Print_And_Continue.
(Check_Entity_Chain): New.
(Check_Scope): Call Check_Entity_Chain.

8 days agoada: Add Delete_Error_And_Continuation_Msgs and refactor duplicate code in errout...
Viljar Indus [Sat, 21 Mar 2026 01:25:05 +0000 (03:25 +0200)] 
ada: Add Delete_Error_And_Continuation_Msgs and refactor duplicate code in errout and errutil

Packages errout and errutil were sharing a lot of code. Extract all of
the common functionality to erroutc.
Extract Delete_Specifically_Suppressed_Warnings and Set_Prev_Pointers.

gcc/ada/ChangeLog:

* errout.adb (Delete_Warning_And_Continuations): use
Delete_Error_And_Continuation_Msgs.
(Output_Messages): Call new refactored subprograms.
(Delete_Specifically_Suppressed_Warnings): New
procedure.
* (Set_Prev_Pointers): New procedure.
* (Finalize): use Delete_Specifically_Suppressed_Warnigns and
Set_Prev_Pointers.
(Finalize): use Delete_Error_And_Continuation_Msgs.
* erroutc.adb (Delete_Error_And_Continuation_Msgs): New procedure.
(Remove_Duplicate_Errors): New_Function.
(Write_All_Errors_In_Brief_Format): New function.
(Write_All_Errors_In_Verbose_Format): New function.
(Write_Error_Summary): New function.
* erroutc.ads (Delete_Error_And_Continuation_Msgs): Likewise.
(Remove_Duplicate_Errors): Likewise.
(Write_All_Errors_In_Brief_Format): Likewise.
(Write_All_Errors_In_Verbose_Format): Likewise.
(Write_Error_Summary): Likewise.
* errutil.adb (Finalize): Call new refactored subprograms.

8 days agoada: Add Filter_And_Delete_Errors
Viljar Indus [Sat, 21 Mar 2026 01:01:33 +0000 (03:01 +0200)] 
ada: Add Filter_And_Delete_Errors

gcc/ada/ChangeLog:

* errout.adb (Remove_Warning_Messages): Use
Filter_And_Delete_Errors.
* errout.ads (Purge_Messages): Renamed to
Delete_Error_Msgs_In_Range.
* erroutc.adb (Filter_And_Delete_Errors): New procedure.
(Purge_Messages): Renamed to Delete_Error_Msgs_In_Range.
* erroutc.ads (Filter_And_Delete_Errors): New procedure.
(Purge_Messages): Renamed to Delete_Error_Msgs_In_Range.
* par-ch5.adb (Missing_Begin): call Delete_Error_Msgs_In_Range.

8 days agoada: Simplify Warning_Specifically_Suppressed calls.
Viljar Indus [Fri, 20 Mar 2026 13:47:54 +0000 (15:47 +0200)] 
ada: Simplify Warning_Specifically_Suppressed calls.

In most places we only care about whether the warning was suppressed or
not and we never care what the exact reason was. Add a new subprogram
Warning_Is_Suppressed for that purpose.

gcc/ada/ChangeLog:

* errout.adb (Finalize): use Warning_Is_Suppressed.
* erroutc.adb (Warning_Is_Suppressed): New subprogram.
* erroutc.ads (Warning_Is_Suppressed): Likewise.

8 days agoada: Refactor error message deletion
Viljar Indus [Fri, 20 Mar 2026 13:15:07 +0000 (15:15 +0200)] 
ada: Refactor error message deletion

Extract the common code from multiple places where we deleted
messages into one common subprogram.

gcc/ada/ChangeLog:

* errout.adb: Use Delete_Error_Msg.
* erroutc.adb (Delete_Error_Msg): New subprogram.
* erroutc.ads (Delete_Error_Msg): Likewise.

8 days agoada: Fix crash on qualified bounds during unnesting
Eric Botcazou [Tue, 24 Mar 2026 09:23:08 +0000 (10:23 +0100)] 
ada: Fix crash on qualified bounds during unnesting

The problem is that the Activation_Record_Component field is accessed for
an E_Package entity, which does not contain any.

gcc/ada/ChangeLog:

* exp_unst.adb (Note_Uplevel_Bound_Trav): Do not register an uplevel
reference for a package.  Use a single if_statement in the body.

8 days agoada: Remove obsolete trick in Analyze_Function_Return
Eric Botcazou [Sat, 21 Mar 2026 11:24:35 +0000 (12:24 +0100)] 
ada: Remove obsolete trick in Analyze_Function_Return

The compiler no longer creates a temporary for controlled aggregate returns.

gcc/ada/ChangeLog:

* sem_ch6.adb (Analyze_Function_Return): Remove obsolete code that
wraps the return in a block when the expression is an aggregate.

8 days agoada: Create a function for checking Suppressed loop warnings
Viljar Indus [Fri, 20 Mar 2026 10:43:16 +0000 (12:43 +0200)] 
ada: Create a function for checking Suppressed loop warnings

gcc/ada/ChangeLog:

* errout.adb (Error_Msg): Add new function
In_Loop_With_Suppressed_Warnings.

8 days agoada: Simplify implementation of instantiation messages
Viljar Indus [Thu, 12 Mar 2026 14:27:00 +0000 (16:27 +0200)] 
ada: Simplify implementation of instantiation messages

Remove duplication and extra variables and simplify control flow.

gcc/ada/ChangeLog:

* errout.adb (Error_Msg_N): Simplify code.

8 days agoada: Improve dmsg
Viljar Indus [Fri, 20 Mar 2026 15:23:14 +0000 (17:23 +0200)] 
ada: Improve dmsg

Add missing attributes to dmsg. Additionally add support for
printing locations and fixes.

gcc/ada/ChangeLog:

* erroutc-pretty_emitter.adb (To_String): Relocated to erroutc.
(To_File_Name): Likewise.
(Line_To_String): Likewise.
(Column_To_String): Likewise.
* erroutc.adb (dedit): New function for debugging edits.
(dfix): New function for debuging fixes.
(dloc): New function for debugging locations.
(dmsg): Print missing Error_Msg_Object attributes.
(To_String): New function for printing spans
(To_String): Relocated from erroutc-pretty_emitter.adb
(To_File_Name): Likewise.
* erroutc.ads: Likewise.

8 days agoada: Stop using gnat_envp
Ronan Desplanques [Tue, 17 Mar 2026 14:38:44 +0000 (15:38 +0100)] 
ada: Stop using gnat_envp

First, a bit of context: Ada has only had support for manipulating
environment variables in the standard library since Ada 2005 and the
introduction of Ada.Environment_Variables.

Prior to that, GNAT had introduced the implementation-specific
Ada.Command_Line.Environment, which still exists today. Until now,
Ada.Command_Line.Environment used a global variable, gnat_envp, which
must be initialized with envp, the optional third parameter to main in C.
When the main was in Ada, the binder generated the appropriate assignment.
The rest of the time, it was the responsibility of the user to write this
assignment. Failure to do so would cause null pointer dereferences when
using Ada.Command_Line.Environment. Although documented in the spec of
Ada.Command_Line, this was rather easy to miss.

Worse, the assignment caused linking failures in the rather common case
of a C GPR project with'ing an Ada GPR project and linking dynamically.

Also, Ada.Command_Line.Environment was inconsistent across platforms with
regard to how it was affected by calls to putenv.

When we added support for the standard Ada.Environment_Variables, the
gnat_envp machinery wasn't reused. Instead, another mechanism based on
the Unix global variable environ (and its close equivalents on other
platforms) was introduced.

What this patch does is switch Ada.Command_Line.Environment over to this
new environ-based mechanism. All uses of gnat_envp are removed, but the
definition itself is kept for backwards compatibility.

gcc/ada/ChangeLog:

* argv-lynxos178-raven-cert.c: Update comments.
* argv.c (gnat_envp): Add comment about it being unused.
(__gnat_env_count, __gnat_len_env, __gnat_fill_env): Use
__gnat_environ instead of gnat_envp.
* bindgen.adb (Command_Line_Used): Update comment.
(Gen_Main): Remove gnat_envp assignment generation. Remove generated
envp parameter.
(Gen_Output_File_Ada): Remove generated envp parameter.
* env.h: Make usable as C++.
* libgnat/a-colien.ads: Remove comment.
* libgnat/a-comlin.ads: Update comment.
* targparm.ads: Update comment.

8 days agoada: Require compilation unit to have no indentation
Piotr Trojanek [Tue, 10 Mar 2026 15:18:13 +0000 (16:18 +0100)] 
ada: Require compilation unit to have no indentation

We had a style check for compilation unit to start at column number which is
multiple of indentation value. Now we require compilation units to no have no
indentation.

gcc/ada/ChangeLog:

* par-ch10.adb (P_Compilation_Unit): Require no indentation.

8 days agoada: Fix compiler crash on primitive completed by expression function
Eric Botcazou [Tue, 17 Mar 2026 21:44:13 +0000 (22:44 +0100)] 
ada: Fix compiler crash on primitive completed by expression function

This further restricts the special bypass for the freezing of the profile
in Analyze_Subprogram_Body_Helper to the case of wrapper functions.

gcc/ada/ChangeLog:

PR ada/93702
* exp_ch3.adb (Make_Controlling_Function_Wrappers): Do not set the
Was_Expression_Function flag on the body.
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Avoid freezing the
profile only for wrapper functions.

8 days agoada: Pretty-print filter of loop parameter specification
Piotr Trojanek [Mon, 16 Mar 2026 12:42:08 +0000 (13:42 +0100)] 
ada: Pretty-print filter of loop parameter specification

Filter was only pretty-printed for iterator specification, but it can also
appear in loop parameter specification. This only affects debug output.

gcc/ada/ChangeLog:

* sprint.adb (Sprint_Node_Actual): Print filter in loop parameter
specification.

8 days agoada: Suppress warning for quantified expression with filters
Piotr Trojanek [Mon, 16 Mar 2026 12:40:44 +0000 (13:40 +0100)] 
ada: Suppress warning for quantified expression with filters

If quantified expression has a filter, it becomes less clear whether we should
warn about quantified variable not being used.

gcc/ada/ChangeLog:

* sem_ch4.adb (Analyze_Quantified_Expression): If there is a filter,
then suppress the warning.

8 days agoada: Suppress warning about unused variable in trivial quantification
Piotr Trojanek [Fri, 13 Mar 2026 11:54:06 +0000 (12:54 +0100)] 
ada: Suppress warning about unused variable in trivial quantification

When condition of a quantification expression is written as True or False, then
the user has likely done this on purpose and there is no need for a warning.

gcc/ada/ChangeLog:

* sem_ch4.adb (Analyze_Quantified_Expression): Suppress warning for
trivial conditions.

8 days agoada: Unset Comes_From_Source in inlined static functions
Viljar Indus [Tue, 17 Mar 2026 07:40:27 +0000 (09:40 +0200)] 
ada: Unset Comes_From_Source in inlined static functions

Unset Comes_From_Source in the inlined expression in
order to avoid spurious resolution errors.

gcc/ada/ChangeLog:

* inline.adb (Adjust_Node): Renamed from Adjust_Sloc and
additionally unset Comes_From_Source.

8 days agoada: Missing overflow check on Integer_128 under GNATProve mode
Javier Miranda [Fri, 13 Mar 2026 19:48:26 +0000 (19:48 +0000)] 
ada: Missing overflow check on Integer_128 under GNATProve mode

Under GNATProve mode the frontend does not generate overflow
checks on type conversions of Universal Integer numbers to
128-bit integer type numbers.

gcc/ada/ChangeLog:

* checks.adb (Apply_Scalar_Range_Check): When the type of the expression
is Universal Integer we cannot statically determine if the expression
is in the range of the target type.
* sem_eval.adb (In_Subrange_Of): Do not consider T2 in the range of
Universal Integer (since theoretically they are not).
(Test_In_Range): Do not consider Universal type expressions in range
of subtype Typ.

8 days agoada: Add (r)pech debug routines for entity chains and simple check
Marc Poulhiès [Thu, 12 Mar 2026 16:01:06 +0000 (17:01 +0100)] 
ada: Add (r)pech debug routines for entity chains and simple check

(r)pech (Print Entity Chain - Header) can be used to dump the entity
chains with one node header per line:

- N_Defining_Identifier "system__use_ada_main_program_name" (Entity_Id=2804) (source)
- N_Defining_Identifier "system__zcx_by_default" (Entity_Id=2808) (source)
- N_Defining_Identifier "system__standard_library" (Entity_Id=108628) (source)
- N_Defining_Identifier "system__exception_table" (Entity_Id=109523) (source)

Also add a simple consistency check to all routines that dumps the
entity chain: if Prev (Next (E)) /= E (or Next (Prev (E)) /= E in the
reverse order), an extra line is printed:

- N_Defining_Identifier "system__tick" (Entity_Id=2550) (source)
 !! - Prev (Next (^^^^)) = N_Defining_Identifier  "system__default_priority" (Entity_Id=2700) (source)
- N_Defining_Identifier "system__address" (Entity_Id=2553) (source)

This example shows that the next links have 2550->2553, but the previous
links have 2700 <- 2553.

gcc/ada/ChangeLog:

* treepr.ads (pech, rpech): New.
(Print_Entity_Chain): Adjust signature and comment to handle
printing only header and doing the simple check.
* treepr.adb (pech, rpech): New.
(Print_Entity_Chain): Support for printing only headers and doing
simple check.

8 days agoada: Enable resolution of overloading on Last and Previous for Iterable
Claire Dross [Wed, 11 Mar 2026 09:25:16 +0000 (10:25 +0100)] 
ada: Enable resolution of overloading on Last and Previous for Iterable

The resolution of overloading for the optional Last and Previous primitives
of an Iterable aspect should be done like for other primitives.

gcc/ada/ChangeLog:

* sem_ch13.adb (Resolve_Iterable_Operation): Handle Previous and Last
like Next and First.

8 days agoada: Add volatile abstract state to creation functions in Interfaces.C.Strings
Claire Dross [Wed, 11 Mar 2026 16:56:51 +0000 (17:56 +0100)] 
ada: Add volatile abstract state to creation functions in Interfaces.C.Strings

The additional volatile abstract state is necessary to model the value of the
new pointer.

gcc/ada/ChangeLog:

* libgnat/i-cstrin.ads: New C_Addresses volatile state to use as
input of the New_String and New_Char_Array.

8 days agoada: Fix assertion failure on call in object notation in entry barrier
Eric Botcazou [Mon, 16 Mar 2026 07:08:05 +0000 (08:08 +0100)] 
ada: Fix assertion failure on call in object notation in entry barrier

The problem is that the Original_Record_Component field is accessed without
checking that it may be.

gcc/ada/ChangeLog:

* sem_util.adb (Statically_Names_Object) <N_Selected_Component>:
Return False if the selector is neither component nor discriminant.

8 days agoada: Inheritance of pragma/aspect unchecked_union
Javier Miranda [Thu, 12 Mar 2026 18:55:21 +0000 (18:55 +0000)] 
ada: Inheritance of pragma/aspect unchecked_union

Derived types inherit pragma/aspect uncheched union.

gcc/ada/ChangeLog:

* sem_ch3.adb (Build_Derived_Record_Type): Record type derivations
inherit Is_Unchecked_Union and Has_Unchecked_Union flags.
(Inherit_Component): Add discriminals to the associations list.
* exp_ch3.adb (Build_Record_Init_Proc): Derivations of Unchecked_Union
types don't need an initialization procedure; they reuse the init proc
of their parent type.

8 days agoada: Distribute declaration of return object into conditional expressions
Eric Botcazou [Mon, 9 Mar 2026 17:59:11 +0000 (18:59 +0100)] 
ada: Distribute declaration of return object into conditional expressions

This lifts one of the limitations of the distribution of a declaration of
an object into the dependent expressions of its initialization expression
when it is a conditional expression, namely the case of the return object
of an extended return statement.

gcc/ada/ChangeLog:

* exp_ch4.adb (Expand_N_Case_Expression): Deal with initialization
expression of return object.
(Expand_N_If_Expression): Likewise.
(Insert_Conditional_Object_Declaration): Likewise.
* exp_util.adb (Is_Distributable_Declaration): Lift limitation for
return objects, including those with a class-wide type.
* sem_ch3.adb (Analyze_Object_Declaration): Set Return_Applies_To
on artificial return objects created from within a transient scope.
Remove test on Expander_Active for better error recovery.

8 days agoada: Fix reStructuredText markup
Ronan Desplanques [Thu, 12 Mar 2026 14:35:55 +0000 (15:35 +0100)] 
ada: Fix reStructuredText markup

gcc/ada/ChangeLog:

* doc/gnat_ugn/building_executable_programs_with_gnat.rst: Fix
markup.
* gnat_ugn.texi: Regenerate.

8 days agoada: Suppress warning about unused quantified variables with junk names
Piotr Trojanek [Wed, 11 Mar 2026 21:00:46 +0000 (22:00 +0100)] 
ada: Suppress warning about unused quantified variables with junk names

For quantified expressions like "for all Dummy in ... => True" we don't want
to warn about unused variable when it has a junk name.

gcc/ada/ChangeLog:

* sem_ch4.adb (Analyze_Quantified_Expression): Suppress warning for
variables with junk names.

8 days agoada: Refactor Inline_Static_Function_Call
Viljar Indus [Mon, 9 Mar 2026 14:33:19 +0000 (16:33 +0200)] 
ada: Refactor Inline_Static_Function_Call

gcc/ada/ChangeLog:

* inline.adb (Inline_Static_Function_Call): Reduce source code nesting.
* inline.ads (Inline_Static_Function_Call): Likewise.

8 days agoada: Calculate the sloc adjustment for inlined static functions
Viljar Indus [Mon, 9 Mar 2026 12:52:33 +0000 (14:52 +0200)] 
ada: Calculate the sloc adjustment for inlined static functions

First (and last) node calculation is done by traversing the original
nodes of the given node. This is fine for expanding existing code.
However when inlining static functions this can lead to a node that is
in a completly different location (e.g. the spec) being considered the
first node in the location of the inlined call. This means that in this
type of scenario reseting the slocs is not enough.

The correct approach to use here would be to calculate the Adjustment
in the Source File Index between the function and the inlined call. This
approach is also used in inlining regular subprograms.

Once there is an entry in the Source File Index for the inlined call the
error message mechanism will both highlight the call and the expression
function if an error is present in the inlined call.

gcc/ada/ChangeLog:

* inline.adb (Inline_Static_Function_Call): Add a Source File Index
entry for the call and apply the necessary sloc adjustment values
for all of the inlined nodes.

8 days agoada: Make __gnat_copy_attribs non-blocking on windows
Tonu Naks [Wed, 26 Nov 2025 12:24:19 +0000 (12:24 +0000)] 
ada: Make __gnat_copy_attribs non-blocking on windows

gcc/ada/ChangeLog:

* adaint.c (__gnat_copy_attribs): use GetFileAttributesEx to
to fetch attributes.

8 days agoc++: Fix build_value_init_noctor anon aggr handling
Jakub Jelinek [Fri, 29 May 2026 08:16:10 +0000 (10:16 +0200)] 
c++: Fix build_value_init_noctor anon aggr handling

As I've mentioned on Saturday, the CWG3130 patchset fail to bootstrap.
The problem is that we try to call build_value_init on anonymous unions
or structs, which doesn't work well when they don't have a default
constructor.
Now, if some non-trivial construction is needed, type will already have
either a user-provided constructor or at least non-trivial one, in that
case build_value_init_noctor isn't called at all.  So, this patch
just zero-initializes the anonymous aggregate members.

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

* init.cc (build_value_init_noctor): Zero initialize anonymous
union/struct subobjects.  Formatting fix.

8 days agolibgfortran: Use MapViewOfFileEx instead of MapViewOfFileExNuma in caf_shmem
Peter Damianov [Fri, 29 May 2026 06:53:42 +0000 (08:53 +0200)] 
libgfortran: Use MapViewOfFileEx instead of MapViewOfFileExNuma in caf_shmem

MapViewOfFileExNuma is only present when _WIN32_WINNT >= 0x0600 (Windows Vista
or later). The code is passing NUMA_NO_PREFERRED_MODE, and that
is documented as:

No NUMA node is preferred. This is the same as calling the MapViewOfFileEx
function.

https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-mapviewoffileexnuma

So, MapViewOfFileEx will behave identically, while still allowing Windows XP
support.

libgfortran/ChangeLog:

* caf/shmem/shared_memory.c (shared_memory_init): Use
MapViewOfFileEx instead of MapViewOfFileExNuma.

9 days agobb-slp-complex-mla-half-float.c: Add the missing end brace
H.J. Lu [Fri, 29 May 2026 02:16:22 +0000 (10:16 +0800)] 
bb-slp-complex-mla-half-float.c: Add the missing end brace

commit 44a31df54837adf2f7815e7966dfe8ac32eb8f3b
Author: Artemiy Volkov <artemiy.volkov@arm.com>
Date:   Mon May 18 10:21:18 2026 +0000

    aarch64: introduce partial AdvSIMD vector modes

changed gcc.dg/vect/complex/bb-slp-complex-mla-half-float.c to:

-/* { dg-final { scan-tree-dump "Found COMPLEX_FMA" "slp1"  { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump "Found COMPLEX_FMA" "slp1" { xfail arm*-*-* } } */

The end brace was missing.  Add the missing end brace to fix it.

PR testsuite/125489
* gcc.dg/vect/complex/bb-slp-complex-mla-half-float.c: Add the
missing end brace.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
9 days agoDaily bump.
GCC Administrator [Fri, 29 May 2026 00:16:40 +0000 (00:16 +0000)] 
Daily bump.

9 days agoFortran: f_c_string intrinsic improvements
Sandra Loosemore [Thu, 28 May 2026 22:33:33 +0000 (22:33 +0000)] 
Fortran: f_c_string intrinsic improvements

The existing implementation of f_c_string is quite inefficient, doing
either 2 or 3 allocations and copies of the input string prefix.  This
rewrite adds folding for constant string arguments and handles other
cases with a single allocation and copy.

This patch also adds the missing documentation for this intrinsic to the
gfortran manual.

gcc/fortran/ChangeLog
* intrinsic.texi (F_C_STRING): New section.
* trans-intrinsic.cc (conv_trim): Delete.
(conv_isocbinding_function): Rewrite the F_C_STRING case.

gcc/testsuite/ChangeLog
* gfortran.dg/f_c_string3.f90: New.
* gfortran.dg/f_c_string4.f90: New.
* gfortran.dg/f_c_string5.f90: New.

9 days agoFortran: Add c_f_strpointer intrinsic
Sandra Loosemore [Thu, 28 May 2026 22:33:33 +0000 (22:33 +0000)] 
Fortran: Add c_f_strpointer intrinsic

This is a missing Fortran 2023 feature.

gcc/fortran/ChangeLog
* check.cc (gfc_check_c_f_strpointer): New.
* f95-lang.cc (gfc_init_builtin_functions): Add BUILT_IN_STRNLEN.
* gfortran.h (enum gfc_isym_id): Add GFC_ISYM_C_F_STRPOINTER.
* gfortran.texi (Interoperable Subroutines and Functions): Mention
f_c_string and c_f_strpointer.
* intrinsic.cc (add_subroutines): Add c_f_strpointer.  Fix nearby
whitespace errors.
(sort_actual): Handle first argument to c_f_strpointer specially.
* intrinsic.h (gfc_check_c_f_strpointer): Declare.
* intrinsic.texi (C_F_STRPOINTER): New section.  Add entry to menu
and cross-references from similar functions.
* iso-c-binding.def: Add c_f_strpointer.
* trans-intrinsic.cc (conv_isocbinding_subroutine_strpointer): New.
(gfc_conv_intrinsic_subroutine): Call it.

gcc/testsuite/ChangeLog
* gfortran.dg/c_f_strpointer-1.f90: New.
* gfortran.dg/c_f_strpointer-2.f90: New.
* gfortran.dg/c_f_strpointer-3.f90: New.
* gfortran.dg/c_f_strpointer-4.f90: New.
* gfortran.dg/c_f_strpointer-5.f90: New.
* gfortran.dg/c_f_strpointer-6.f90: New.
* gfortran.dg/c_f_strpointer-7.f90: New.
* gfortran.dg/c_f_strpointer-8.f90: New.
* gfortran.dg/c_f_strpointer-9.f90: New.
* gfortran.dg/c_f_strpointer-10.f90: New.
* gfortran.dg/pr108961.f90: Rename locally-defined c_f_strpointer.

Co-authored-by: Tobias Burnus <tburnus@baylibre.com>
9 days agolibcody: allow non-ASCII module names [PR120458]
Jean-Christian CÎRSTEA [Sun, 22 Mar 2026 17:57:42 +0000 (19:57 +0200)] 
libcody: allow non-ASCII module names [PR120458]

Before this commit, attempting to use non-ASCII characters in quoted
words failed, even though the protocol allows the usage of such
characters in quoted words. To fix this:

1. Remove `c >= 0x7f` comparison when parsing a quoted word.
2. Use `unsigned char` instead of `char` such that `c < 0x20` fails for
   non-ASCII characters.

PR c++/120458

libcody/ChangeLog:

* buffer.cc (S2C): Allow non-ASCII chars in quoted words.
* cody.hh: Use unsigned char for S2C().

gcc/testsuite/ChangeLog:

* g++.dg/README: Explain purpose of modules/ dir.
* g++.dg/modules/pr120458-1_a.C: Define non-ASCII module with
default mapper.
* g++.dg/modules/pr120458-1_b.C: Import non-ASCII module with
default mapper.
* g++.dg/modules/pr120458-2_a.C: Define non-ASCII module with
a file as mapper.
* g++.dg/modules/pr120458-2_b.C: Import non-ASCII module with
a file as mapper.
* g++.dg/modules/pr120458-2.map: Define mapping for pr120458-2
test case.

Signed-off-by: Jean-Christian CÎRSTEA <jean-christian.cirstea@tuta.com>
9 days agovect-early-break-no-epilog_11.c: Require avx512f_runtime
H.J. Lu [Thu, 28 May 2026 20:30:56 +0000 (04:30 +0800)] 
vect-early-break-no-epilog_11.c: Require avx512f_runtime

Require avx512f_runtime instead of avx512f_hw to fix

ERROR: gcc.dg/vect/vect-early-break-no-epilog_11.c -flto -ffat-lto-objects: unknown effective target keyword `avx512f_hw' for " dg-require-effective-target 7 avx512f_hw { target i?86-*-* x86_64-*-* } "

* gcc.dg/vect/vect-early-break-no-epilog_11.c: Require
avx512f_runtime instead of avx512f_hw.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
9 days agotree-ssa: Loop store motion micro-optimizations.
Roger Sayle [Thu, 28 May 2026 19:56:27 +0000 (20:56 +0100)] 
tree-ssa: Loop store motion micro-optimizations.

ref_always_accessed_p is (currently) only ever called with stored_p being
true, so specializing for this case, renaming ref_always_accessed{,_p} to
ref_always_stored{,_p} saves storage and some redundant checks at run-time.

2026-05-28  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* tree-ssa-loop-im.cc (ref_always_accessed_p): Rename to...
(ref_always_stored_p): New function specialized to determine if
REF is a store that is always executed in LOOP.
(execute_sm): Use ref_always_stored_p instead of
ref_always_accessed_p.
(class ref_always_accessed): Rename to..
(class ref_always_stored): Remove (always true) stored_p field.
(ref_always_stored::operator ()): Always check for a store.
Move hash table lookup, get_lim_data, after store test.
(can_sm_ref_p): Use ref_always_stored_p insead of
ref_always_accessed_p.

9 days agox86_64 SSE: Tweak/correct STV cost of 128-bit rotate by constant.
Roger Sayle [Thu, 28 May 2026 19:54:17 +0000 (20:54 +0100)] 
x86_64 SSE: Tweak/correct STV cost of 128-bit rotate by constant.

This one line change resolves the failure of gcc.target/i386/rotate-2.c
when compiled with -march=cascadelake triggered by recent STV improvements.
https://gcc.gnu.org/pipermail/gcc-patches/2026-May/716996.html

The decision of whether to perform STV is finely balanced, and affected
by the microarchitecture's timings/costs, but in this case the underlying
issue appears to be the parameterized cost for performing a 128-bit
rotation by a constant in SSE registers.  Depending upon the number
of bits to rotate by, SSE requires either 1 or 2 shuffles, followed
by a left shift, a right shift and an any_or_plus to combine the result.
This is therefore 4 or 5 instructions, but currently returns
COSTS_N_INSNS(1) instead of COSTS_N_INSNS(4) [probably a typo].

As an aside, it might be more useful for this gain to based on latency;
as both the shuffles and the shifts can each be performed in parallel,
so a reasonable vcost may therefore be COSTS_N_INSNS(3), but such fine
tuning might require microbenchmarking.  I mention it here just in case
using COSTS_N_INSNS(4) is bisected as a performance regression.

2026-05-28  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* config/i386/i386-features.cc (compute_convert_gain): Tweak
the cost of a 128-bit rotation to be 4 (or 5) instructions.

9 days agox86_64 SSE: Handle SUBREG conversions in TImode STV (for ptest).
Roger Sayle [Thu, 28 May 2026 19:50:11 +0000 (20:50 +0100)] 
x86_64 SSE: Handle SUBREG conversions in TImode STV (for ptest).

This patch teaches i386's STV pass how to handle SUBREG conversions,
i.e. that a TImode SUBREG can be transformed into a V1TImode SUBREG,
without worrying about other DEFs and USEs.

One example where this is useful is

typedef long long __m128i __attribute__ ((__vector_size__ (16)));
int foo (__m128i x, __m128i y) {
  return (__int128)x == (__int128)y;
}

where with -O2 -msse4 we can now scalar-to-vector transform:

(insn 7 4 8 2 (set (reg:CCZ 17 flags)
        (compare:CCZ (subreg:TI (reg/v:V2DI 86 [ x ]) 0)
            (subreg:TI (reg/v:V2DI 87 [ y ]) 0))) {*cmpti_doubleword}

into

(insn 17 4 7 2 (set (reg:V1TI 91)
        (xor:V1TI (subreg:V1TI (reg/v:V2DI 86 [ x ]) 0)
            (subreg:V1TI (reg/v:V2DI 87 [ y ]) 0)))
     (nil))
(insn 7 17 8 2 (set (reg:CCZ 17 flags)
        (unspec:CCZ [
                (reg:V1TI 91) repeated x2
            ] UNSPEC_PTEST)) {*sse4_1_ptestv1ti}
     (expr_list:REG_DEAD (reg/v:V2DI 87 [ y ])
        (expr_list:REG_DEAD (reg/v:V2DI 86 [ x ])
            (nil))))

with the dramatic effect that the assembly output before:

foo: movaps  %xmm0, -40(%rsp)
        movq    -32(%rsp), %rdx
        movq    %xmm0, %rax
        movq    %xmm1, %rsi
        movaps  %xmm1, -24(%rsp)
        movq    -16(%rsp), %rcx
        xorq    %rsi, %rax
        xorq    %rcx, %rdx
        orq     %rdx, %rax
        sete    %al
        movzbl  %al, %eax
        ret

now becomes

foo: pxor    %xmm1, %xmm0
        xorl    %eax, %eax
        ptest   %xmm0, %xmm0
        sete    %al
        ret

i.e. a 128-bit vector doesn't need to be transferred to the
scalar unit to be tested for equality.  The new test case includes
additional related examples that show similar improvements.

Previously we explicitly checked *cmpti_doubleword operands to be
either immediate constants, or a TImode REG or a TImode MEM.  By
enhancing this to allow a TImode SUBREG, we now handle everything
that would match the general_operand predicate, making this part
of STV more like other RTL passes (lra/reload).  The big change is
that unlike a regular DF USE, a SUBREG USE doesn't require us to
analyze and convert the rest of the DEF-USE chain.

2026-05-28  Roger Sayle  <roger@nextmovesoftware.com>
    Hongtao Liu  <hongtao.liu@intel.com>

gcc/ChangeLog
* config/i386/i386-features.cc (scalar_chain::add_insn): Don't
call analyze_register_chain if the USE is a SUBREG.
(scalar_chain::convert_op): Call gen_lowpart to convert
scalar (TImode) SUBREGs to vector (V1TImode) SUBREGs.
(convertible_comparison_p): We can now handle all general_operands
of *cmp<dwi>_doubleword.
(timode_remove_non_convertible_regs): We only need to check TImode
uses that aren't TImode SUBREGs of registers in other modes.

gcc/testsuite/ChangeLog
* gcc.target/i386/sse4_1-ptest-7.c: New test case.

9 days agox86 SSE: Improve vector increment/decrement on x86.
Roger Sayle [Thu, 28 May 2026 19:46:04 +0000 (20:46 +0100)] 
x86 SSE: Improve vector increment/decrement on x86.

This patch improves the code generated by the i386 backend for incrementing
(adding one to) and decrementing (subtracting one from) a vector.  With SSE
materializing the vector -1 is more efficient than materializing the
vector +1, hence x + 1 (increment) is better expressed as x - (-1), and
x - 1 (decrement) is better expressed as x + (-1).  Conveniently the
relevant additions and subtractions are specified as a single pattern,
using a plusminus iterator, in the machine description.

For the four example functions:

typedef char v16sqi __attribute__ ((vector_size(16)));
typedef unsigned char v16uqi __attribute__ ((vector_size(16)));

v16sqi sadd1(v16sqi x) { return x+1; }
v16uqi uadd1(v16uqi x) { return x+1; }
v16sqi saddm1(v16sqi x) { return x-1; }
v16uqi uaddm1(v16uqi x) { return x-1; }

GCC with -O2 -mavx2 previously generated:

sadd1: vpcmpeqd        %xmm1, %xmm1, %xmm1
        vpabsb  %xmm1, %xmm1
        vpaddb  %xmm1, %xmm0, %xmm0
        ret

uadd1: vpcmpeqd        %xmm1, %xmm1, %xmm1
        vpabsb  %xmm1, %xmm1
        vpaddb  %xmm1, %xmm0, %xmm0
        ret

saddm1: vpcmpeqd        %xmm1, %xmm1, %xmm1
        vpabsb  %xmm1, %xmm1
        vpsubb  %xmm1, %xmm0, %xmm0
        ret

uaddm1: vpcmpeqd        %xmm1, %xmm1, %xmm1
        vpaddb  %xmm1, %xmm0, %xmm0
        ret

With this patch, we now consistently generate:

sadd1:  vpcmpeqd        %xmm1, %xmm1, %xmm1
        vpsubb  %xmm1, %xmm0, %xmm0
        ret

uadd1:  vpcmpeqd        %xmm1, %xmm1, %xmm1
        vpsubb  %xmm1, %xmm0, %xmm0
        ret

saddm1: vpcmpeqd        %xmm1, %xmm1, %xmm1
        vpaddb  %xmm1, %xmm0, %xmm0
        ret

uaddm1: vpcmpeqd        %xmm1, %xmm1, %xmm1
        vpaddb  %xmm1, %xmm0, %xmm0
        ret

2026-05-28  Roger Sayle  <roger@nextmovesoftware.com>
    Hongtao Liu  <hongtao.liu@intel.com>
    Uros Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog
* config/i386/i386.md (inv_insn): New define_code_attr.
* config/i386/sse.md (<plusminus><mode>3): Accept a CONST_VECTOR
as the second operand.  If the second operand is CONST1_RTX,
canonicalize to use CONSTM1_RTX instead.
(*add<mode>3_one): New define_insn_and_split to convert padd +1
to psub -1.
(*sub<mode>3_one): Likewise, a new define_insn_and_split to
convert psub +1 to padd -1.

gcc/testsuite/ChangeLog
* gcc.target/i386/avx512f-simd-1.c: Tweak test case.
* gcc.target/i386/sse2-paddb-2.c: New test case.
* gcc.target/i386/sse2-paddd-2.c: Likewise.
* gcc.target/i386/sse2-paddw-2.c: Likewise.
* gcc.target/i386/sse2-psubb-2.c: Likewise.
* gcc.target/i386/sse2-psubd-2.c: Likewise.
* gcc.target/i386/sse2-psubw-2.c: Likewise.

9 days agoc++: fix infinite looping with arr[arr] [PR125454]
Marek Polacek [Thu, 28 May 2026 17:43:58 +0000 (13:43 -0400)] 
c++: fix infinite looping with arr[arr] [PR125454]

Here r16-3466 moved the canonicalization step that transforms
idx[array] to array[idx] to the beginning of cp_build_array_ref.
When we have array[array], we'll be swapping till we blow the stack.

Previously, we'd give the !INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P
error so there was no problem.

PR c++/125454

gcc/cp/ChangeLog:

* typeck.cc (cp_build_array_ref): Don't recurse for array[array].

gcc/testsuite/ChangeLog:

* g++.dg/other/array8.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
9 days agofortran: module-contained PRIVATE procedures must have global ELF linkage [PR125430]
Jerry DeLisle [Sat, 23 May 2026 04:56:34 +0000 (21:56 -0700)] 
fortran: module-contained PRIVATE procedures must have global ELF linkage [PR125430]

Assisted by: Claude Sonnet 4.6

gcc/fortran/ChangeLog:

PR fortran/125430
* trans-decl.cc (build_function_decl): Set TREE_PUBLIC for all
module-contained procedures so submodules compiled as separate
translation units can reach them via host association.  Also set
DECL_VISIBILITY to VISIBILITY_HIDDEN for PRIVATE procedures,
matching the existing treatment of module variables.

gcc/testsuite/ChangeLog:

PR fortran/125430
* gfortran.dg/module_private_2.f90: Remove scan-tree-dump-times
assertion for 'priv'; PRIVATE module procedures now have global
linkage with hidden visibility and are no longer optimized away.
* gfortran.dg/public_private_module_2.f90: Add xfail markers to
scan-assembler-not for 'two' and 'six'; update comment to mention
procedures alongside variables.
* gfortran.dg/public_private_module_7.f90: Add xfail marker to
scan-assembler-not for '__m_common_attrs_MOD_other'.
* gfortran.dg/public_private_module_8.f90: Add xfail marker to
scan-assembler-not for '__m_MOD_myotherlen'.
* gfortran.dg/submodule_private_host.f90: New test.
* gfortran.dg/submodule_private_host_aux.f90: New auxiliary file.
* gfortran.dg/warn_unused_function_2.f90: Remove 'defined but not
used' expectation for s1; PRIVATE module procedures now have
global linkage and no longer trigger the unused-function warning.

9 days ago[RISC-V] Fix expected testsuite output after ext-dce changes
Jeff Law [Thu, 28 May 2026 17:36:01 +0000 (11:36 -0600)] 
[RISC-V] Fix expected testsuite output after ext-dce changes

The recent changes to ext-dce can transform sign extension to zero extension in
some cases.  As a result tests which previously expected a signed load can now
see an unsigned load.  Of course on rv32 "lw" loads a full word, so this
doesn't show up there.  So instead of looking for "lw" we instead look for
"(lwu|lw)".  This fixes the "regressions" after the ext-dce changes.

gcc/testsuite
* gcc.target/riscv/amo/a-rvwmo-store-compat-seq-cst.c: Adjust expected
output.
* gcc.target/riscv/amo/a-rvwmo-store-relaxed.c: Likewise.
* gcc.target/riscv/amo/a-rvwmo-store-release.c: Likewise.
* gcc.target/riscv/amo/a-ztso-store-compat-seq-cst.c: Likewise.
* gcc.target/riscv/amo/a-ztso-store-relaxed.c: Likewise.
* gcc.target/riscv/amo/a-ztso-store-release.c: Likewise.
* gcc.target/riscv/amo/zalasr-rvwmo-store-compat-seq-cst.c: Likewise.
* gcc.target/riscv/amo/zalasr-rvwmo-store-relaxed.c: Likewise.
* gcc.target/riscv/amo/zalasr-rvwmo-store-release.c: Likewise.
* gcc.target/riscv/amo/zalasr-ztso-store-compat-seq-cst.c: Likewise.
* gcc.target/riscv/amo/zalasr-ztso-store-relaxed.c: Likewise.
* gcc.target/riscv/amo/zalasr-ztso-store-release.c: Likewise.
* gcc.target/riscv/cpymem-64-ooo.c: Likewise.
* gcc.target/riscv/cpymem-64.c: Likewise.
* gcc.target/riscv/memcpy-nonoverlapping.c: Likewise.
* gcc.target/riscv/pr67731.c: Likewise.

9 days agoc++: add fixed test [PR106957]
Marek Polacek [Thu, 28 May 2026 16:18:29 +0000 (12:18 -0400)] 
c++: add fixed test [PR106957]

Fixed by r16-8015:
c++: error routines re-entered with uneval lambda [PR124397]

PR c++/106957

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/lambda-uneval32.C: New test.

9 days agolibstdc++: Fix -fno-exceptions support in testsuite_allocator.h
Patrick Palka [Thu, 28 May 2026 14:41:33 +0000 (10:41 -0400)] 
libstdc++: Fix -fno-exceptions support in testsuite_allocator.h

This fixes the error

.../testsuite_allocator.h:402:13: error: exception handling disabled, use '-fexceptions' to enable
  402 |             catch(...)
      |             ^~~~~

seen when running some C++23 library tests with -fno-exceptions.

libstdc++-v3/ChangeLog:

* testsuite/util/testsuite_allocator.h
(uneq_allocator::allocate): Use __try/__catch instead.
(uneq_allocator::allocate_at_least): Likewise.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
9 days agolibstdc++: Fix availability of flat_meow::operator=(initializer_list)
Patrick Palka [Thu, 28 May 2026 14:39:32 +0000 (10:39 -0400)] 
libstdc++: Fix availability of flat_meow::operator=(initializer_list)

This assignment operator was not being brought in from the private base
class causing assignments from {...} to be inefficiently treated as
construction + move assignment.

libstdc++-v3/ChangeLog:

* include/std/flat_map (flat_map): Bring in operator= from
_Flat_map_base.
(flat_multimap): Likewise.
* include/std/flat_set (flat_set): Bring in operator= from
_Flat_set_base.
(flat_multiset): Likewise.
* testsuite/23_containers/flat_map/1.cc (test11): Simplify by
using = {...}.
(test12): New test.
* testsuite/23_containers/flat_multimap/1.cc (test10): Simplify
by using = {...}.
(test11): New test.
* testsuite/23_containers/flat_multiset/1.cc (test10): Simplify
by using = {...}.
(test11): New test.
* testsuite/23_containers/flat_set/1.cc (test10): Simplify by
using = {...}.
(test11): New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
9 days agolibstdc++: Implement P3567R2 flat_meow fixes
Patrick Palka [Thu, 28 May 2026 14:39:29 +0000 (10:39 -0400)] 
libstdc++: Implement P3567R2 flat_meow fixes

This implements the changes in sections 5, 6 and 8 of P3567R2; the other
changes (in section 4 and 7) are effectively already implemented.

libstdc++-v3/ChangeLog:

* include/bits/version.def (flat_map): Bump to 202511.
(flat_set): Likewise.
* include/bits/version.h: Regenerate.
* include/std/flat_map (_Flat_map_impl): Remove
is_nothrow_swappable_v assertions.
(_Flat_map_impl::_Flat_map_impl): Explicitly default copy ctor.
Define move ctor with corrected exception handling as per
P3567R2.
(_Flat_map_impl::operator=): Likewise.
(_Flat_map_impl::insert_range): Define new __sorted_t overload
as per P3567R2.
(_Flat_map_impl::swap): Make conditionally noexcept as per
P3567R2.
* include/std/flat_set (_Flat_set_impl): Remove
is_nothrow_swappable_v assertion.
(_Flat_set_impl::_Flat_set_impl): Explicitly default copy ctor.
Define move ctor with correct invariant preserving behavior as
per P3567R2.
(_Flat_set_impl::operator=): Likewise.
(_Flat_set_impl::_M_insert_range): Factored out from
insert_range.  Add bool parameter __is_sorted defaulted to
false.
(_Flat_set_impl::insert_range): Define new __sorted_t overload
as per P3567R2.
(_Flat_set_impl::swap): Make conditionally noexcept as per
P3567R2.  Correct to use ranges::swap instead of ADL swap.
* testsuite/23_containers/flat_map/1.cc (test11, test12):
New tests.
* testsuite/23_containers/flat_multimap/1.cc (test10, test11):
New tests.
* testsuite/23_containers/flat_multiset/1.cc (test10, test11):
New tests.
* testsuite/23_containers/flat_set/1.cc (test10, test11):
New tests.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
9 days agolibstdc++: Fix suboptimal complexity of flat_map::_M_insert
Patrick Palka [Thu, 28 May 2026 14:39:27 +0000 (10:39 -0400)] 
libstdc++: Fix suboptimal complexity of flat_map::_M_insert

Ever since r16-1742 ranges::inplace_merge is now correctly C++20 iterator
aware which allows us to idiomatically implement this helper with the
correct optimal complexity N + M log M instead of N log N.

libstdc++-v3/ChangeLog:

* include/std/flat_map (_Flat_map_impl::_M_insert): New bool
parameter __is_sorted defaulted to false.  Reimplement using
views::zip and ranges::inplace_merge.
(_Flat_map_impl::insert): In the __sorted_t overload, pass
__is_sorted=true to _M_insert.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
9 days agocobol: Add assertion to suppress -Warray-bounds false positive [PR125404]
Jonathan Wakely [Wed, 20 May 2026 21:24:33 +0000 (22:24 +0100)] 
cobol: Add assertion to suppress -Warray-bounds false positive [PR125404]

This works around a warning from std::vector code, which seems to be
assuming that the vector is empty and therefore calling back() would be
invalid:

/home/test/src/gcc/gcc/cobol/symfind.cc:526:45: error: array subscript -1 is outside array bounds of ‘long unsigned int [1152921504606846975]’ [-Werror=array-bounds=]
  526 |                     return ancestors.back() == i01;
      |                            ~~~~~~~~~~~~~~~~~^~~~~~

Compiling with -D_GLIBCXX_ASSERTIONS also fixes the warning.

gcc/cobol/ChangeLog:

PR cobol/125404
* symfind.cc (symbol_find): Add assertion that ancestors vector
is not empty.

9 days agoRISC-V: Fix REGNO_REG_CLASS for FP hard registers
Jin Ma [Tue, 26 May 2026 03:25:57 +0000 (11:25 +0800)] 
RISC-V: Fix REGNO_REG_CLASS for FP hard registers

The GCC Internals Manual, section 19.8 "Register Classes", documents
REGNO_REG_CLASS as:

  REGNO_REG_CLASS (regno)                                      [Macro]
    A C expression whose value is a register class containing hard
    register regno.  In general there is more than one such class;
    choose a class which is minimal, meaning that no smaller class
    also contains the register.

riscv_regno_to_class[] currently maps every FP hard register to
RVC_FP_REGS, but RVC_FP_REGS only contains f8-f15.  The entries for
f0-f7 and f16-f31 therefore violate the "containing hard register
regno" half of the contract: the returned class does not contain the
register at all.

The mismatch corrupts IRA's cost model.  setup_allocno_cost_vector
indexes the per-hard-reg cost slot via REGNO_REG_CLASS:

  rclass = REGNO_REG_CLASS (hard_regno);
  num = cost_classes_ptr->index[rclass];
  ...
  reg_costs[j] = COSTS (costs, i)->cost[num];

After setup_regno_cost_classes_by_mode adds RVC_FP_REGS to the cost
classes, the cost for e.g. f16 is silently read from the RVC_FP_REGS
slot.

The new fp-reg-class.c testcase puts eight "cf"- and sixteen "f"-
constrained doubles live across a call.  In the buggy state IRA
places the cf pseudos outside the cf class and LRA recovers with
sixteen fmv.d to fs* registers; with the fix IRA spills those values
honestly and the IRA "+++Costs" line reports a non-zero "mem"
component.

Fix it by giving each FP hard register its minimal class: FP_REGS for
f0-f7 and f16-f31, RVC_FP_REGS for f8-f15.  As a companion change,
switch riscv_secondary_memory_needed from class-equality tests to
reg_class_subset_p so it still recognises the FP side regardless of
which subclass the table returns.

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_regno_to_class): Use the minimal
class containing each FP hard register: FP_REGS for f0-f7 and
f16-f31, RVC_FP_REGS for f8-f15.
(riscv_secondary_memory_needed): Use reg_class_subset_p to
detect FP classes.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/fp-reg-class.c: New test.