]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
7 weeks agocobol: Some 1000 small changes in answer to cppcheck diagnostics.
James K. Lowden [Mon, 16 Jun 2025 15:43:35 +0000 (11:43 -0400)] 
cobol: Some 1000 small changes in answer to cppcheck diagnostics.

constification per cppcheck. Use STRICT_WARN and fix reported
diagnostics.  Ignore [shadowVariable] in general. Use std::vector to
avoid exposing arrays as raw pointers.

PR cobol/120621

gcc/cobol/ChangeLog:

* Make-lang.in: Use STRICT_WARN.
* cbldiag.h (location_dump): suppress shadowVariable.
* cdf-copy.cc (esc): Fix shadowVariable.
(copybook_elem_t::open_file): Do not use %m.
* cdf.y: suppress invalidPrintfArgType for target format.
* cdfval.h (struct cdfval_t): Suppress noExplicitConstructor.
* cobol1.cc (cobol_name_mangler): Use C++ cast.
* copybook.h (class copybook_elem_t): Same.
* dts.h: Fixes and suppressions due to cppcheck.
* except.cc (cbl_enabled_exceptions_t::status): Suppress useStlAlgorithm.
(cbl_enabled_exceptions_t::turn_on_off): Const parameter.
(class choose_declarative): Removed.
* genapi.cc (struct called_tree_t): Explicit constructor.
(parser_compile_ecs): Cast to void * for %p.
(parser_compile_dcls): Same.
(parser_statement_begin): Same.
(initialize_variable_internal): Use std::vector for subscripts.
(parser_initialize): Constification.
(get_string_from): Same.
(combined_name): Same.
(parser_perform): Same.
(psa_FldLiteralN): Same.
(is_figconst): Const parameter.
(is_figconst_t): Same.
(parser_exit): Same.
(parser_division): Const pointer.
(parser_perform_conditional): Whitespace.
(parser_set_conditional88): Const parameter.
(inspect_tally): Use std::vector.
(inspect_replacing): Same.
(parser_inspect): Same.
(parser_intrinsic_subst): Use std::vector (constuct elements).
(parser_intrinsic_call_1): Use std::vector for subscripts.
(is_ascending_key): Const pointer.
(parser_sort): Use std::vector.
(parser_file_sort): Same.
(parser_file_merge): Same.
(parser_unstring): Same.
(parser_string): Same.
(parser_call): Const pointer.
(parser_program_hierarchy): Use std::vector.
(conditional_abs): Const paraemeter.
(float_type_of): Same.
(initial_from_initial): Set value, quoted or not.
(parser_symbol_add): Remove redundant nested test.
* genapi.h (parser_add): Const parameters.
(parser_subtract): Same.
(parser_multiply): Same.
(parser_divide): Same.
(parser_perform): Same.
(parser_exit): Same.
(parser_initialize): Same.
(parser_set_conditional88): Same.
(parser_sort): Same.
(parser_file_sort): Same.
(parser_file_merge): Same.
(parser_string): Same.
(is_ascending_key): Same.
* genmath.cc (arithmetic_operation): Use std::vector.
(is_somebody_float): Const parameter.
(all_results_binary): Const parameter.
(fast_multiply): Remove redundant nested test.
(parser_add): Const parameter.
(parser_multiply): Remove redundant nested test.
(parser_divide): Const parameter.
(parser_subtract): Same.
* genutil.cc (get_depending_on_value): Use std::vector.
(get_data_offset): Same.
(tree_type_from_field): Const parameter.
(refer_has_depends): Const pointers.
(get_literal_string): RAII.
(refer_is_clean): Use std::vector.
(get_time_nanoseconds): Newline at EOF.
* genutil.h (tree_type_from_field): Remove declaration.
* inspect.h (struct cbx_inspect_qual_t): Use std::vector.
(struct cbl_inspect_qual_t): Same.
(struct cbx_inspect_match_t): Same.
(class cbl_inspect_match_t): Same.
(struct cbx_inspect_replace_t): Same.
(struct cbl_inspect_replace_t): Same.
(struct cbx_inspect_oper_t): Same.
(struct cbl_inspect_oper_t): Same.
(struct cbx_inspect_t): Same.
(struct cbl_inspect_t): Same.
(parser_inspect): Same.
* lexio.cc (indicated): Const pointer.
(remove_inline_comment): Scope reduction.
(maybe_add_space): Const pointer.
(recognize_replacements): C++ cast.
(check_source_format_directive): Same.
(struct replacing_term_t): Explicit constructor.
(parse_replace_pairs): Const reference.
(location_in): Const reference.
(parse_copy_directive): C++ cast.
(parse_replace_last_off): Const parameter.
(parse_replace_text): Const reference.
(parse_replace_directive): C++ cast.
(cdftext::lex_open): Const reference.
(cdftext::open_output): Scope reduction.
(cdftext::free_form_reference_format): Remove unused variable.
(cdftext::process_file): Simplify.
* lexio.h (struct bytespan_t): Use nullptr.
(struct filespan_t): Initialize icol in constructor.
(struct span_t): Suppress confused operatorEqRetRefThis.
(struct replace_t): Eliminate single-value constructor.
* parse.y: Many const cppcheck reports, and portable bit-shift.
* parse_ante.h (reject_refmod): Const parameter.
(require_pointer): Same.
(require_integer): Same.
(struct evaluate_elem_t): Explicit constructor.
(struct arith_t): Use std::vector.
(class eval_subject_t): Const parameter.
(dump_inspect_match): Declare.
(struct perform_t): Explicit constructor.
(list_add):  Const parameter.
(class tokenset_t): Avoid negative array index.
(struct file_list_t): Explicit constructor.
(struct field_list_t): Same.
(struct refer_list_t): Same.
(struct refer_marked_list_t): Const parameter.
(struct refer_collection_t): Explicit constructor.
(struct ast_inspect_oper_t): Remove class.
(ast_inspect_oper_t): Same.
(struct ast_inspect_t): Same.
(struct ast_inspect_list_t): Same.
(ast_inspect): Add location.
(struct elem_list_t): Explicit constructor.
(struct unstring_tgt_t): Same.
(struct unstring_tgt_list_t): Same.
(struct unstring_into_t): Same.
(struct ffi_args_t): Same.
(struct file_sort_io_t): Same.
(merge_t): Same.
(struct vargs_t): Same.
(class prog_descr_t): Eliminate single-value constructor.
(class program_stack_t): Suppress useStlAlgorithm.
(struct rel_part_t): Eliminate single-value constructor.
(class log_expr_t): Explicit constructor.
(add_debugging_declarative): Rename local variable.
(intrinsic_call_2): Const parameter.
(invalid_key): Use std::find_if.
(parser_add2): Const parameter.
(parser_subtract2): Same.
(stringify): Same.
(unstringify): Same.
(anybody_redefines): Same.
(ast_call): Same.
* parse_util.h (class cname_cmp): Explicit constructor.
(intrinsic_inconsistent_parameter): Same.
* scan_ante.h (struct cdf_status_t): Eliminate single-value constructor.
(class enter_leave_t): Explicit constructor.
(update_location): Const pointer, explicit constructor.
(symbol_function_token): Const pointer.
(typed_name): Same.
* scan_post.h (datetime_format_of): Scope reduction.
* show_parse.h (class ANALYZE): Use std::vector, explicit consstructor.
* symbols.cc (symbol_table_extend): Scope reduction.
(cbl_ffi_arg_t::cbl_ffi_arg_t): Define default constructor.
(end_of_group): Const pointer.
(symbol_find_odo): Const parameter.
(rename_not_ok): Same.
(field_str): Use %u instead of %d.
(struct capacity_of): Const pointer.
(symbols_update): Same.
(symbol_field_parent_set): Same.
(symbol_file_add): Same.
(symbol_typedef_add): Same.
(symbol_field_add): Use new operator=().
(symbol_field): Suppress CastIntegerToAddressAtReturn.
(symbol_register): Same.
(symbol_file): Suppress knownConditionTrueFalse.
(next_program): Const parameter.
(symbol_file_record): Same.
(class is_section): Explicit constructor.
(cbl_file_t::no_key): Remove.
(cbl_prog_hier_t::cbl_prog_hier_t): Use std::vector.
(symbol_label_add): Assert pointer is not NULL.
(symbol_label_section_exists): Const reference in lambda.
(expand_picture): Use C++ cast.
(symbol_program_callables): Const pointer.
(symbol_currency_add): Suppress nullPointerRedundantCheck.
(cbl_key_t): Use std::vector.
(cbl_occurs_t::field_add): Const parameter.
(cbl_occurs_t::index_add): Explicit constructor.
(class is_field_at): Same.
(cbl_file_key_t::deforward): Scope reduction.
(cbl_file_t::keys_str): Use allocated memory only.
(file_status_status_of): Const pointer.
(is_register_field): Const parameter.
* symbols.h (struct cbl_field_data_t): Eliminate single-value constructor.
(struct cbl_occurs_bounds_t): Same.
(struct cbl_refer_t): Use std::vector.
(valid_move): Const parameter.
(is_register_field): Same.
(struct cbl_key_t): Use std::vector.
(struct cbl_substitute_t): Eliminate single-value constructor.
(refer_of): Return const reference
(struct cbl_ffi_arg_t): Eliminate single-value constructor.
(class temporaries_t): Same.
(struct cbl_file_key_t): Define default constructor.
(struct cbl_file_lock_t): Define copy constructor and operator=().
(struct cbl_file_t): Complete default constructor.
(struct symbol_elem_t): Explicit constructor.
(symbol_elem_of): Suppress cstyleCast.
(symbol_redefines): Const parameter.
(struct cbl_field_t): Same.
(cbl_section_of): Test for NULL pointer.
(cbl_field_of): Same.
(cbl_label_of): Same.
(cbl_special_name_of): Same.
(cbl_alphabet_of): Same.
(cbl_file_of): Same.
(is_figconst): Delete extra "struct" keyword.
(is_figconst_low): Same.
(is_figconst_zero): Same.
(is_figconst_space): Same.
(is_figconst_quote): Same.
(is_figconst_high): Same.
(is_space_value): Same.
(is_quoted): Same.
(symbol_index): Const parameter.
(struct cbl_prog_hier_t): Suppress noExplicitConstructor.
(struct cbl_perform_vary_t): Eliminate single-value constructor.
(is_signable): Const parameter.
(is_temporary): Same.
(rename_not_ok): Same.
(field_at): Test for NULL pointer.
(class procref_base_t): Eliminate single-value constructor.
* symfind.cc (is_data_field): Const pointer.
(finalize_symbol_map2): Same.
(class in_scope): Same.
(symbol_match2): Same.
* token_names.h: Suppress useInitializationList.
* util.cc (normalize_picture): Whitespace and remove extra "continue".
(redefine_field): Const pointer.
(cbl_field_t::report_invalid_initial_value): Same.
(literal_subscript_oob): Rename shadow variable.
(cbl_refer_t::subscripts_set): Use std::vector.
(cbl_refer_t::str): Same.
(cbl_refer_t::deref_str): Same.
(locally_unique): Use explicit constructor.
(ambiguous_reference): Same.
(class unique_stack): Use const reference.
(cobol_filename): Const pointer.
(verify_format): Scope reduction.
(class temp_loc_t): Do not derive from YYLTYPE.
(cobol_parse_files): Const pointer.
* util.h (as_voidp): Define convenient converter.

libgcobol/ChangeLog:

* common-defs.h (class cbl_enabled_exceptions_t): Const parameter.

7 weeks agoaarch64: Add support for unpacked SVE FP conversions
Spencer Abson [Mon, 16 Jun 2025 19:31:30 +0000 (19:31 +0000)] 
aarch64: Add support for unpacked SVE FP conversions

This patch introduces expanders for FP<-FP conversions that levarage
partial vector modes.  We also extend the INT<-FP and FP<-INT conversions
using the same approach.

The ACLE enables vectorized conversions like the following:

fcvt z0.h, p7/m, z1.s

modelling the source vector as VNx4SF:

... |     SF|     SF|     SF|     SF|

and the destination as a VNx8HF, where this operation would yield:

... | 0 | HF| 0 | HF| 0 | HF| 0 | HF|

hence the useful results are stored unpacked, i.e.

... | X | HF| X | HF| X | HF| X | HF| (VNx4HF)

This patch allows the vectorizer to use this variant of fcvt as a
conversion from VNx4SF to VNx4HF.  The same idea applies to widening
conversions, and between vectors with FP and integer base types.

If the source itself had been unpacked, e.g.

... |   X   |     SF|   X   |     SF| (VNx2SF)

The result would yield

... | X | X | X | HF| X | X | X | HF| (VNx2HF)

The upper bits of each container here are undefined, it's important to
avoid interpreting them during FP operations - doing so could introduce
spurious traps.  The obvious route we've taken here is to mask undefined
lanes using the operation's predicate if we have flag_trapping_math.

The VPRED predicate mode (e.g. VNx2BI here) cannot do this; to ensure
correct behavior, we need a predicate mode that can control the data as if
it were fully-packed (VNx4BI).

Both VNx2BI and VNx4BI must be recognised as legal governing predicate modes
by the corresponding FP insns.  In general, the governing predicate mode for
an insn could be any such with at least as many significant lanes as the data
mode.  For example, addvnx4hf3 could be controlled by any of VNx{4,8,16}BI.

We implement 'aarch64_predicate_operand', a new define_special_predicate, to
acheive this.

gcc/ChangeLog:

* config/aarch64/aarch64-protos.h (aarch64_sve_valid_pred_p):
Declare helper for aarch64_predicate_operand.
(aarch64_sve_packed_pred): Declare helper for new expanders.
(aarch64_sve_fp_pred): Likewise.
* config/aarch64/aarch64-sve.md (<optab><mode><v_int_equiv>2):
Extend into...
(<optab><SVE_HSF:mode><SVE_HSDI:mode>2): New expander for converting
vectors of HF,SF to vectors of HI,SI,DI.
(<optab><VNx2DF_ONLY:mode><SVE_2SDI:mode>2): New expander for converting
vectors of SI,DI to vectors of DF.
(*aarch64_sve_<optab>_nontrunc<SVE_PARTIAL_F:mode><SVE_HSDI:mode>):
New pattern to match those we've added here.
(@aarch64_sve_<optab>_trunc<VNx2DF_ONLY:mode><VNx4SI_ONLY:mode>): Extend
into...
(@aarch64_sve_<optab>_trunc<VNx2DF_ONLY:mode><SVE_SI:mode>): Match both
VNx2SI<-VNx2DF and VNx4SI<-VNx4DF.
(<optab><v_int_equiv><mode>2): Extend into...
(<optab><SVE_HSDI:mode><SVE_F:mode>2): New expander for converting vectors
of HI,SI,DI to vectors of HF,SF,DF.
(*aarch64_sve_<optab>_nonextend<SVE_HSDI:mode><SVE_PARTIAL_F:mode>): New
pattern to match those we've added here.
(trunc<SVE_SDF:mode><SVE_PARTIAL_HSF:mode>2): New expander to handle
narrowing ('truncating') FP<-FP conversions.
(*aarch64_sve_<optab>_trunc<SVE_SDF:mode><SVE_PARTIAL_HSF:mode>): New
pattern to handle those we've added here.
(extend<SVE_PARTIAL_HSF:mode><SVE_SDF:mode>2): New expander to handle
widening ('extending') FP<-FP conversions.
(*aarch64_sve_<optab>_nontrunc<SVE_PARTIAL_HSF:mode><SVE_SDF:mode>): New
pattern to handle those we've added here.
* config/aarch64/aarch64.cc (aarch64_sve_packed_pred): New function.
(aarch64_sve_fp_pred): Likewise.
(aarch64_sve_valid_pred_p): Likewise.
* config/aarch64/iterators.md (SVE_PARTIAL_HSF): New mode iterator.
(SVE_HSF): Likewise.
(SVE_SDF): Likewise.
(SVE_SI): Likewise.
(SVE_2SDI) Likewise.
(self_mask):  Extend to all integer/FP vector modes.
(narrower_mask): Likewise (excluding QI).
* config/aarch64/predicates.md (aarch64_predicate_operand): New special
predicate to handle narrower predicate modes.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve/pack_fcvt_signed_1.c: Disable the aarch64 vector
cost model to preserve this test.
* gcc.target/aarch64/sve/pack_fcvt_unsigned_1.c: Likewise.
* gcc.target/aarch64/sve/pack_float_1.c: Likewise.
* gcc.target/aarch64/sve/unpack_float_1.c: Likewise.
* gcc.target/aarch64/sve/unpacked_cvtf_1.c: New test.
* gcc.target/aarch64/sve/unpacked_cvtf_2.c: Likewise.
* gcc.target/aarch64/sve/unpacked_cvtf_3.c: Likewise.
* gcc.target/aarch64/sve/unpacked_fcvt_1.c: Likewise.
* gcc.target/aarch64/sve/unpacked_fcvt_2.c: Likewise.
* gcc.target/aarch64/sve/unpacked_fcvtz_1.c: Likewise.
* gcc.target/aarch64/sve/unpacked_fcvtz_2.c: Likewise.

7 weeks agoaarch64: Extend iterator support for partial SVE FP modes
Spencer Abson [Mon, 16 Jun 2025 16:43:07 +0000 (16:43 +0000)] 
aarch64: Extend iterator support for partial SVE FP modes

Define new iterators for partial floating-point modes, and cover these
in some existing mode_attrs.  This patch serves as a starting point for
an effort to extend support for unpacked floating-point operations.

To differentiate between BFloat mode iterators that need to test
TARGET_SSVE_B16B16, and those that don't (see LOGICALF), this patch
enforces the following naming convention:
- _BF: BF16 modes will not test TARGET_SSVE_B16B16.
- _B16B16: BF16 modes will test TARGET_SSVE_B16B16.

gcc/ChangeLog:

* config/aarch64/aarch64-sve.md: Replace uses of SVE_FULL_F_BF
with SVE_FULL_F_B16B16.
Replace use of SVE_F with SVE_F_BF.
* config/aarch64/iterators.md (SVE_PARTIAL_F): New iterator for
partial SVE FP modes.
(SVE_FULL_F_BF): Rename to SVE_FULL_F_B16B16.
(SVE_PARTIAL_F_B16B16): New iterator (BF16 included) for partial
SVE FP modes.
(SVE_F_B16B16): New iterator for all SVE FP modes.
(SVE_BF): New iterator for all SVE BF16 modes.
(SVE_F): Redefine to exclude BF16 modes.
(SVE_F_BF): New iterator to replace the previous SVE_F.
(VPRED): Describe the VPRED mapping for partial vector modes.
(b): Cover partial FP modes.
(is_bf16): Likewise.

7 weeks agoFortran: fix checking of MOLD= in ALLOCATE statements [PR51961]
Harald Anlauf [Sun, 15 Jun 2025 19:09:28 +0000 (21:09 +0200)] 
Fortran: fix checking of MOLD= in ALLOCATE statements [PR51961]

In ALLOCATE statements where the MOLD= argument is present and is not
scalar, and the allocate-object has an explicit-shape-spec, the standard
does not require the ranks to agree.  In that case we skip the rank check,
but emit a warning if -Wsurprising is given.

PR fortran/51961

gcc/fortran/ChangeLog:

* resolve.cc (conformable_arrays): Use modified rank check when
MOLD= expression is given.

gcc/testsuite/ChangeLog:

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

7 weeks agoc++: add -Wsfinae-incomplete
Jason Merrill [Thu, 12 Jun 2025 15:19:19 +0000 (11:19 -0400)] 
c++: add -Wsfinae-incomplete

We already error about a type or function definition causing a concept check
to change value, but it would be useful to diagnose this for other SFINAE
contexts as well; the memoization problem also affects templates.  So
-Wsfinae-incomplete remembers if we've failed a requirement for a complete
type/deduced return type in a non-tf_error context, and later warns if the
type/function becomes complete.

This warning is enabled by default; I think the signal-to-noise ratio is
high enough to warrant that, and it catches things that are likely to make
the program "ill-formed, no diagnostic required".

friend87.C is an interesting case; this could be considered a false positive
because it is using friend injection to define the auto function to
implement a compile-time counter.  I think this is sufficiently pathological
that it's fine to expect people who want to play this sort of game to
suppress the warning.

The data for this warning uses GTY((cache)) to persist through GC, but allow
entries to be discarded if the key is not otherwise marked.

I don't think it's desirable to export/import this information in modules,
it makes sense for it to be local to a single TU.

-Wsfinae-incomplete=2 adds a warning at the point of failure, which is
primarily intended to help with debugging warnings from the default mode.

gcc/ChangeLog:

* doc/invoke.texi: Document -Wsfinae-incomplete.

gcc/c-family/ChangeLog:

* c.opt: Add -Wsfinae-incomplete.
* c.opt.urls: Regenerate.

gcc/cp/ChangeLog:

* constraint.cc (failed_completions_map): New.
(note_failed_type_completion): Rename from
note_failed_type_completion_for_satisfaction.  Add
-Wsfinae-incomplete handling.
(failed_completion_location): New.
* class.cc (finish_struct_1): Add -Wsfinae-incomplete warning.
* decl.cc (require_deduced_type): Adjust.
(finish_function): Add -Wsfinae-incomplete warning.
* typeck.cc (complete_type_or_maybe_complain): Adjust.
(cxx_sizeof_or_alignof_type): Call note_failed_type_completion.
* pt.cc (dependent_template_arg_p): No longer static.
* cp-tree.h: Adjust.

libstdc++-v3/ChangeLog:

* testsuite/20_util/is_complete_or_unbounded/memoization.cc
* testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc:
Expect -Wsfinae-incomplete.

gcc/testsuite/ChangeLog:

* g++.dg/template/friend87.C
* g++.dg/cpp2a/concepts-complete1.C
* g++.dg/cpp2a/concepts-complete2.C
* g++.dg/cpp2a/concepts-complete3.C
* g++.dg/cpp2a/concepts-complete4.C: Expect -Wsfinae-incomplete.

7 weeks agoRISC-V: Refine VX combine test case 0 to avoid code duplication
Pan Li [Sun, 15 Jun 2025 08:28:38 +0000 (16:28 +0800)] 
RISC-V: Refine VX combine test case 0 to avoid code duplication

The case 0 for vx combine def functions are most the same across
the different test files.  Thus, re-arrange them in one place to
avoid code duplication.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i16.c: Leverage
helper macros to avoid code duplication.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary.h: Add
signed and unsigned vx combine test macros.

Signed-off-by: Pan Li <pan2.li@intel.com>
7 weeks agoaarch64: add support for AEABI Build Attributes
Matthieu Longo [Wed, 11 Sep 2024 15:11:55 +0000 (16:11 +0100)] 
aarch64: add support for AEABI Build Attributes

GCS (Guarded Control Stack, an Armv9.4-a extension) requires some
caution at runtime. The runtime linker needs to reason about the
compatibility of a set of relocable object files that might not
have been compiled with the same compiler.
Up until now, those metadata, used for the previously mentioned
runtime checks, have been provided to the runtime linker via GNU
properties which are stored in the ELF section ".note.gnu.property".
However, GNU properties are limited in their expressibility, and a
long-term commmitment was taken in the ABI for the Arm architecture
[1] to provide Build Attributes (a.k.a. BAs).

This patch adds the support for emitting AArch64 Build Attributes.
This support includes generating two new assembler directives:
.aeabi_subsection and .aeabi_attribute. These directives are generated
as per the syntax mentioned in spec "Build Attributes for the Arm®
64-bit Architecture (AArch64)" available at [1].

gcc/configure.ac now includes a new check to test whether the
assembler being used to build the toolchain supports these new
directives.
Two behaviors can be observed when -mbranch-protection=[standard|...]
is passed:
- If the assembler support BAs, GCC emits the BAs directives and
no GNU properties.  Note: the static linker will derive the values
of GNU properties from the BAs, and will emit both BAs and GNU
properties into the output object.
- If the assembler do not support them, only .note.gnu.property
section will contain the relevant information.

Bootstrapped on aarch64-none-linux-gnu, and no regression found.

[1]: https://github.com/ARM-software/abi-aa/pull/230

gcc/ChangeLog:

* config.in: Regenerate.
* config/aarch64/aarch64-elf-metadata.h
(class aeabi_subsection): New class for BAs.
* config/aarch64/aarch64-protos.h
(aarch64_pacret_enabled): New function.
* config/aarch64/aarch64.cc
(HAVE_AS_AEABI_BUILD_ATTRIBUTES): New definition.
(aarch64_file_end_indicate_exec_stack): Emit BAss.
(aarch64_pacret_enabled): New function.
(aarch64_start_file): Indent.
* configure: Regenerate.
* configure.ac: New configure check for BAs support in binutils.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp:
(check_effective_target_aarch64_gas_has_build_attributes): New checker.
* gcc.target/aarch64/build-attributes/aarch64-build-attributes.exp: New DejaGNU file.
* gcc.target/aarch64/build-attributes/build-attribute-bti.c: New test.
* gcc.target/aarch64/build-attributes/build-attribute-gcs.c: New test.
* gcc.target/aarch64/build-attributes/build-attribute-pac.c: New test.
* gcc.target/aarch64/build-attributes/build-attribute-standard.c: New test.
* gcc.target/aarch64/build-attributes/no-build-attribute-bti.c: New test.
* gcc.target/aarch64/build-attributes/no-build-attribute-gcs.c: New test.
* gcc.target/aarch64/build-attributes/no-build-attribute-pac.c: New test.
* gcc.target/aarch64/build-attributes/no-build-attribute-standard.c: New test.

Co-Authored-By: Srinath Parvathaneni <srinath.parvathaneni@arm.com>
7 weeks agoaarch64: encapsulate note.gnu.property emission into a class
Matthieu Longo [Wed, 4 Jun 2025 11:10:05 +0000 (12:10 +0100)] 
aarch64: encapsulate note.gnu.property emission into a class

The code emitting the GNU properties was moved to a separate file to
improve modularity and "releave" the 31000-lines long aarch64.cc file
from a few lines.

It introduces a new namespace "aarch64::" for AArch64 backend which
reduce the length of function names by not prepending 'aarch64_' to
each of them.

gcc/ChangeLog:

* Makefile.in: Add missing declaration of BACKEND_H.
* config.gcc: Add aarch64-elf-metadata.o to extra_objs.
* config/aarch64/aarch64-elf-metadata.h: New file
* config/aarch64/aarch64-elf-metadata.cc: New file.
* config/aarch64/aarch64.cc
(GNU_PROPERTY_AARCH64_FEATURE_1_AND): Removed.
(GNU_PROPERTY_AARCH64_FEATURE_1_BTI): Likewise.
(GNU_PROPERTY_AARCH64_FEATURE_1_PAC): Likewise.
(GNU_PROPERTY_AARCH64_FEATURE_1_GCS): Likewise.
(aarch64_file_end_indicate_exec_stack): Move GNU properties code to
aarch64-elf-metadata.cc
* config/aarch64/t-aarch64: Declare target aarch64-elf-metadata.o

7 weeks agoc++: ICE with unexpanded pack in asm
yxj-github-437 [Wed, 4 Jun 2025 13:18:45 +0000 (21:18 +0800)] 
c++: ICE with unexpanded pack in asm

Here an unexpanded parameter pack pass into asm_operand which doesn't
expect to see an operand without type. So use check_for_bare_parameter_packs
to remedy that.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_asm_operand_list): Check for unexpanded
parameter packs.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/variadic-crash7.C: New test.

7 weeks agoaarch64: add debug comments to feature properties in .note.gnu.property
Matthieu Longo [Mon, 23 Sep 2024 13:38:57 +0000 (14:38 +0100)] 
aarch64: add debug comments to feature properties in .note.gnu.property

GNU properties are emitted to provide some information about the features
used in the generated code like BTI, GCS, or PAC. However, no debug
comment are emitted in the generated assembly even if -dA is provided.
It makes understanding the information stored in the .note.gnu.property
section more difficult than needed.

This patch adds assembly comments (if -dA is provided) next to the GNU
properties. For instance, if BTI and PAC are enabled, it will emit:
  .word  0x3  // GNU_PROPERTY_AARCH64_FEATURE_1_AND (BTI, PAC)

gcc/ChangeLog:

* config/aarch64/aarch64.cc
(aarch64_file_end_indicate_exec_stack): Emit assembly comments.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/bti-1.c: Emit assembly comments, and update
test assertion.

7 weeks agoCombine static and afdo branch predictions
Jan Hubicka [Mon, 16 Jun 2025 08:19:05 +0000 (10:19 +0200)] 
Combine static and afdo branch predictions

Currently afdo reads the profile and anotates basic blocks containing
statements which have samples in profile data.  For basic blocks which has been
fully optimized out (for example, basic blocks controlling loops that has been
fully unrolled) it has no data which it then tries to determine in
afdo_propagate using Kirhoff law.

Problem is that often there is not enough info to solve the problem. In that
case few tricks are applied and then algorithm gives up.

In all cases where it gave up, the count is then set to AFDO 0 and consequently
we end up with basic blocks having 0 counts in hot regions of program and we
can not trust those 0s much when optimizing.

This patch attempts to preserve static profile in regions we have no info.
After the propagation connected regions are identified and existing profile is
scaled to fit profile data.  For single-entry-single exit regions this is
correct answer.  For other regions we can theoretically try to adjust static
profile, but no attempts is made to do it to keep things simple.
Static profile has quality GUESSED while AFDO data quality AFDO which makes
it possible to distinguish it later.

afdo_adjust_guessed_profile does the profile adjustment. Rest of changes are
preventing the code from tampering with counts of basic blocks that can not
be fully determined.  The propagation has some tricks to compute lower bound
of some basic blocks on the boundary of annotated regions and i am not trying
to preserve that.

We can end up with connected components where we can not determine the count.
This happens in pracitce in hot code i.e. for SPEC2017 perl benchmark. I plan
to handle this incrementally. Current code will simply set profle as undefined
in those regions, which works worse than 0 and thus we get regression in perl.
With this changed to 0, I now get same SPEC2017 score as without profiling.

The patch also makes gcc to completely ignore info about basic blocks which
do have statements that have actual 0 AFDO profile info.  Since the profile
generation tool cuts profile at 2%, I think we should keep low guessed profile
there insead of 0.  This is another step I plan to work on incrementally
this week.

Bootstrapped/regtested x86-64, comitted.

gcc/ChangeLog:

* auto-profile.cc (edge_set): Remove unused typedef.
(is_bb_annotated): Sanity check that annotated BBs has
quality AFDO and non-anntoated non-AFDO.  Exceptions are
zeros.
(set_bb_annotated): Verify that BB set annotated has
AFDO profile.
(afdo_set_bb_count): Do not return true for 0 counts.
(afdo_find_equiv_class): Fix formating;
do not combine profile of annoated and non-annotated BBs.
(afdo_propagate_edge): Fix variable names; dump info
about changes; do not change non-annoated BB profiles;
if all flow out of BB was decided on, annotate remaining
edges with 0.
(afdo_propagate): Dump info about copied BB counts
and number of iteraitons used.
(cmp): New function.
(afdo_adjust_guessed_profile): New function.
(afdo_calculate_branch_prob): Do not initialize loop
optimizer here; call afdo_adjust_guessed_profile.
(afdo_annotate_cfg): Initialize profile here;
anotate entry/exit blocks only of profile is non-0.
* profile-count.h: (profile_count::force_guessed): New.
* tree-cfg.cc (gimple_verify_flow_info): Fix typo.

7 weeks agoRISC-V: Update Profiles string in RV23.
Jiawei [Mon, 16 Jun 2025 03:21:29 +0000 (11:21 +0800)] 
RISC-V: Update Profiles string in RV23.

Add b-ext in RVA/B23 as independent extension flags and add supm in
RVA23.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc: Add b-ext and supm.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/arch-53.c: Update testcase.

7 weeks agoxtensa: Revert "xtensa: Eliminate unwanted reg-reg moves during DFmode input reloads"
Takayuki 'January June' Suwa [Sun, 15 Jun 2025 09:00:50 +0000 (18:00 +0900)] 
xtensa: Revert "xtensa: Eliminate unwanted reg-reg moves during DFmode input reloads"

Since there are no unwanted reg-reg moves during DFmode input reloads in
recent GCCs, the previously committed patch
"xtensa: eliminate unwanted reg-reg moves during DFmode input reloads"
(commit cfad4856fa46abc878934a9433d0bfc2482ccf00) is no longer necessary
and is therefore being reverted.

gcc/ChangeLog:

* config/xtensa/predicates.md (reload_operand):
Remove.
* config/xtensa/xtensa.md:
Remove the peephole2 pattern that was previously added.

7 weeks agoxtensa: Revert "xtensa: Eliminate unnecessary general-purpose reg-reg moves"
Takayuki 'January June' Suwa [Sat, 14 Jun 2025 11:30:55 +0000 (20:30 +0900)] 
xtensa: Revert "xtensa: Eliminate unnecessary general-purpose reg-reg moves"

Due to improved register allocation for GP registers whose modes has been
changed by paradoxical SUBREGs, the previously committed patch
"xtensa: eliminate unnecessary general-purpose reg-reg moves"
(commit f83e76c3f998c8708fe2ddca16ae3f317c39c37a)  is no longer necessary
and is therefore reverted.

gcc/ChangeLog:

* config/xtensa/xtensa.md:
Remove the peephole2 pattern that was previously added.

gcc/testsuite/ChangeLog:

* gcc.target/xtensa/elim_GP_regmove_0.c: Remove.
* gcc.target/xtensa/elim_GP_regmove_1.c: Remove.

7 weeks agosimplify-rtx.cc:Simplify XOR(AND(ROTATE(~1) A) ASHIFT(1 A)) to IOR.
Jiawei [Fri, 13 Jun 2025 10:25:56 +0000 (18:25 +0800)] 
simplify-rtx.cc:Simplify XOR(AND(ROTATE(~1) A) ASHIFT(1 A)) to IOR.

This patch adds a new simplification rule to `simplify-rtx.cc` that
handles a common bit manipulation pattern involving a single-bit set
and clear followed by XOR.

The transformation targets RTL of the form:

  (xor (and (rotate (~1) A) B) (ashift 1 A))

which is semantically equivalent to:

  B | (1 << A)

- v3 log:
  Update RTL format, remove commas.
  Only apply on SHIFT_COUNT_TRUNCATED target.
  check '!side_effects_p' on XEXP (op1, 1).

gcc/ChangeLog:

* simplify-rtx.cc (simplify_context::simplify_binary_operation_1): Handle
more logical simplifications.

7 weeks agoDaily bump.
GCC Administrator [Mon, 16 Jun 2025 00:17:41 +0000 (00:17 +0000)] 
Daily bump.

7 weeks agoRISC-V: Add test for vec_duplicate + vmaxu.vv combine case 1 with GR2VR cost 0, 1...
Pan Li [Sat, 14 Jun 2025 14:34:36 +0000 (22:34 +0800)] 
RISC-V: Add test for vec_duplicate + vmaxu.vv combine case 1 with GR2VR cost 0, 1 and 2

Add asm dump check test for vec_duplicate + vmaxu.vv combine to vmaxu.vx,
with the GR2VR cost is 0, 1 and 2.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u16.c: Add asm check
for vmaxu.vx combine.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-u8.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
7 weeks agoRISC-V: Add test for vec_duplicate + vmaxu.vv combine case 0 with GR2VR cost 0, 2...
Pan Li [Sat, 14 Jun 2025 14:32:23 +0000 (22:32 +0800)] 
RISC-V: Add test for vec_duplicate + vmaxu.vv combine case 0 with GR2VR cost 0, 2 and 15

Add asm dump check test for vec_duplicate + vmaxu.vv combine to vmaxu.vx,
with the GR2VR cost is 0, 2 and 15.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u16.c: Add asm check
for vmaxu.vx combine.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary.h: Add test
helper macros.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary_data.h: Add test
data for run test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmax-run-1-u16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmax-run-1-u32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmax-run-1-u64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmax-run-1-u8.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmax-run-2-u16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmax-run-2-u32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmax-run-2-u64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmax-run-2-u8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
7 weeks agoRISC-V: Combine vec_duplicate + vmaxu.vv to vmaxu.vx on GR2VR cost
Pan Li [Sat, 14 Jun 2025 14:29:40 +0000 (22:29 +0800)] 
RISC-V: Combine vec_duplicate + vmaxu.vv to vmaxu.vx on GR2VR cost

This patch would like to combine the vec_duplicate + vmaxu.vv to the
vmaxu.vx.  From example as below code.  The related pattern will depend
on the cost of vec_duplicate from GR2VR.  Then the late-combine will
take action if the cost of GR2VR is zero, and reject the combination
if the GR2VR cost is greater than zero.

Assume we have example code like below, GR2VR cost is 0.

  #define DEF_VX_BINARY(T, OP)                                        \
  void                                                                \
  test_vx_binary (T * restrict out, T * restrict in, T x, unsigned n) \
  {                                                                   \
    for (unsigned i = 0; i < n; i++)                                  \
      out[i] = in[i] OP x;                                            \
  }

  DEF_VX_BINARY(int32_t, /)

Before this patch:
  10   │ test_vx_binary_or_int32_t_case_0:
  11   │     beq a3,zero,.L8
  12   │     vsetvli a5,zero,e32,m1,ta,ma
  13   │     vmv.v.x v2,a2
  14   │     slli    a3,a3,32
  15   │     srli    a3,a3,32
  16   │ .L3:
  17   │     vsetvli a5,a3,e32,m1,ta,ma
  18   │     vle32.v v1,0(a1)
  19   │     slli    a4,a5,2
  20   │     sub a3,a3,a5
  21   │     add a1,a1,a4
  22   │     vmaxu.vv v1,v1,v2
  23   │     vse32.v v1,0(a0)
  24   │     add a0,a0,a4
  25   │     bne a3,zero,.L3

After this patch:
  10   │ test_vx_binary_or_int32_t_case_0:
  11   │     beq a3,zero,.L8
  12   │     slli    a3,a3,32
  13   │     srli    a3,a3,32
  14   │ .L3:
  15   │     vsetvli a5,a3,e32,m1,ta,ma
  16   │     vle32.v v1,0(a1)
  17   │     slli    a4,a5,2
  18   │     sub a3,a3,a5
  19   │     add a1,a1,a4
  20   │     vmaxu.vx v1,v1,a2
  21   │     vse32.v v1,0(a0)
  22   │     add a0,a0,a4
  23   │     bne a3,zero,.L3

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_vx_binary_vec_dup_vec): Add new
case UMAX.
(expand_vx_binary_vec_vec_dup): Ditto.
* config/riscv/riscv.cc (riscv_rtx_costs): Ditto.
* config/riscv/vector-iterators.md: Add new op umax.

Signed-off-by: Pan Li <pan2.li@intel.com>
7 weeks agoDaily bump.
GCC Administrator [Sun, 15 Jun 2025 00:17:36 +0000 (00:17 +0000)] 
Daily bump.

7 weeks agoAVR: Fix PR120423 / PR116389.
Georg-Johann Lay [Sat, 14 Jun 2025 17:57:18 +0000 (19:57 +0200)] 
AVR: Fix PR120423 / PR116389.

The problem with PR120423 and PR116389 is that reload might assign an invalid
hard register to a paradoxical subreg.  For example with the test case from
the PR, it assigns (REG:QI 31) to the inner of (subreg:HI (QI) 0) which is
valid, but the subreg will be turned into (REG:HI 31) which is invalid
and triggers an ICE in postreload.

The problem only occurs with the old reload pass.

The patch maps the paradoxical subregs to a zero-extends which will be
allocated correctly.  For the 120423 testcases, the code is the same like
with -mlra (which doesn't implement the fix), so the patch doesn't even
introduce a performance penalty.

The patch is only needed for v15:  v14 is not affected, and in v16 reload
will be removed.

PR rtl-optimization/120423
PR rtl-optimization/116389
gcc/
* config/avr/avr.md [-mno-lra]: Add pre-reload split to transform
(left shift of) a paradoxical subreg to a (left shift of) zero-extend.
gcc/testsuite/
* gcc.target/avr/torture/pr120423-1.c: New test.
* gcc.target/avr/torture/pr120423-2.c: New test.
* gcc.target/avr/torture/pr120423-116389.c: New test.

(cherry picked from commit 61789b5abec3079d02ee9eaa7468015ab1f6f701)

7 weeks agoc++, coroutines: Improve diagnostics for awaiter/promise.
Iain Sandoe [Thu, 29 May 2025 15:50:44 +0000 (16:50 +0100)] 
c++, coroutines: Improve diagnostics for awaiter/promise.

At present, we can issue diagnostics about missing or malformed
awaiter or promise methods when we encounter their uses in the
body of a user's function.  We might then re-issue the same
diagnostics when processing the initial or final await expressions.

This change avoids such duplication, and also attempts to
identify issues with the initial or final expressions specifically
since diagnostics for those do not have any useful line number.

gcc/cp/ChangeLog:

* coroutines.cc (build_co_await): Identify diagnostics
for initial and final await expressions.
(cp_coroutine_transform::wrap_original_function_body): Do
not handle initial and final await expressions here ...
(cp_coroutine_transform::apply_transforms): ... handle them
here and avoid duplicate diagnostics.
* coroutines.h: Declare inital and final await expressions
in the transform class.  Save the function closing brace
location.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/coro1-missing-await-method.C: Adjust for
improved diagnostics.
* g++.dg/coroutines/coro-missing-final-suspend.C: Likewise.
* g++.dg/coroutines/pr104051.C: Move to...
* g++.dg/coroutines/pr104051-0.C: ...here.
* g++.dg/coroutines/pr104051-1.C: New test.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
7 weeks agoDaily bump.
GCC Administrator [Sat, 14 Jun 2025 00:17:58 +0000 (00:17 +0000)] 
Daily bump.

7 weeks agoc++, coroutines: Handle builtin_constant_p [PR116775].
Iain Sandoe [Mon, 9 Jun 2025 10:00:47 +0000 (11:00 +0100)] 
c++, coroutines: Handle builtin_constant_p [PR116775].

Since the folding of this builtin happens after the main coroutine FE
lowering, we need to account for await expressions in that lowering.

Since these expressions have a property of being not evaluated, but do
not have the full constraints of an unevaluatated context, we want to
apply the checks and then remove the await expressions so that they no
longer participate in the analysis and lowering.

When a builtin_constant_p call is encountered, and the operand contains
any await expression, we check to see if the operand can be a constant
and replace the call with its result.

PR c++/116775

gcc/cp/ChangeLog:

* coroutines.cc (analyze_expression_awaits): When we see
a builtin_constant_p call, and that contains one or more
await expressions, then replace the call with its result
and discard the unevaluated operand.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/pr116775.C: New test.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
7 weeks agoc++, coroutines: Ensure that the resumer is marked as can_throw.
Iain Sandoe [Sat, 7 Jun 2025 16:01:15 +0000 (17:01 +0100)] 
c++, coroutines: Ensure that the resumer is marked as can_throw.

We must flag that the resumer might throw (since the wrapping of the
original function body unconditionally adds a try-catch/rethrow). We
also add code that might throw - even when the original function body
would not.

TODO: We could improve code-gen by recognising cases where the combined
body + initial await expressions cannot throw and omitting the unneeded
try/catch/rethrow wrapper.

gcc/cp/ChangeLog:

* coroutines.cc (build_actor_fn): Set can_throw.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
7 weeks agoexpand: Add a helper function for edge splitting [PR120629]
Jakub Jelinek [Fri, 13 Jun 2025 21:17:17 +0000 (23:17 +0200)] 
expand: Add a helper function for edge splitting [PR120629]

On Fri, Jun 13, 2025 at 08:52:55AM +0100, Richard Sandiford wrote:
> But now that there are two instances, I wonder if it would
> be worth hiding this detail in a helper function?

Here it is.

2025-06-13  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/120629
* cfgexpand.cc (expand_split_edge): New function.
(expand_gimple_cond, construct_init_block): Use it.

7 weeks agoaarch64: Fold NOT+PTEST to NOTS [PR118150]
Spencer Abson [Fri, 13 Jun 2025 09:25:28 +0000 (09:25 +0000)] 
aarch64: Fold NOT+PTEST to NOTS [PR118150]

Add combiner patterns for folding NOT+PTEST to NOTS when they share
the same governing predicate.

gcc/ChangeLog:
PR target/118150
* config/aarch64/aarch64-sve.md (*one_cmpl<mode>3_cc): New
combiner pattern.
(*one_cmpl<mode>3_ptest): Likewise.

gcc/testsuite/ChangeLog:
PR target/118150
* gcc.target/aarch64/sve/acle/general/not_1.c: New test.

7 weeks agolibstdc++: Fix std::uninitialized_value_construct for arrays [PR120397]
Jonathan Wakely [Thu, 22 May 2025 14:42:45 +0000 (15:42 +0100)] 
libstdc++: Fix std::uninitialized_value_construct for arrays [PR120397]

The std::uninitialized_{value,default}_construct{,_n} algorithms should
be able to create arrays, but that currently fails because when an
exception happens they clean up using std::_Destroy and in C++17 that
doesn't support destroying arrays. (For C++20 and later, std::destroy
does handle destroying arrays.)

This commit adjusts the _UninitDestroyGuard RAII type used by those
algos so that in C++17 mode it recursively destroys each rank of an
array type, only using std::_Destroy for the last rank when it's
destroying non-array objects.

libstdc++-v3/ChangeLog:

PR libstdc++/120397
* include/bits/stl_uninitialized.h (_UninitDestroyGuard<I,void>):
Add new member function _S_destroy and call it from the
destructor (for C++17 only).
* testsuite/20_util/specialized_algorithms/uninitialized_default_construct/120397.cc:
New test.
* testsuite/20_util/specialized_algorithms/uninitialized_value_construct/120397.cc:
New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 weeks agolibstdc++: Format %r, %x and %X using locale's time_put facet [PR120648]
Tomasz Kamiński [Fri, 13 Jun 2025 11:28:30 +0000 (13:28 +0200)] 
libstdc++: Format %r, %x and %X using locale's time_put facet [PR120648]

Similarly to issue reported for %c in PR117214, the format string for locale
specific time (%r, %X) and date (%x) representations may contain specifiers
not accepted by chrono-spec, leading to exception being thrown. This
happened for following conversion specifier and locale combinations:
 * %r, %X for aa_DJ.UTF-8, ar_SA.UTF-8
 * %x for ca_AD.UTF-8, my_MM.UTF-8

This fix follows approach from r15-8490-gc24a1d5, and uses time_put to emit
localized date format. The existing _M_c is reworked to handle all locale
dependent conversion specifies, by accepting them as argument. It is also
renamed to _M_c_r_x_X.

PR libstdc++/120648

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (__formatter_chrono::_M_format_to):
Handle %c, %r, %x and %X by passing them to _M_c_r_x_X.
(__formatter_chrono::_M_c_r_x_X): Reworked from _M_c.
(__formatter_chrono::_M_c): Renamed into above.
(__formatter_chrono::_M_r, __formatter_chrono::_M_x)
(__formatter_chrono::_M_X): Removed.
* testsuite/std/time/format/pr117214.cc: New tests for %r, %x,
%X with date, time and durations.

7 weeks agolibstdc++: Optimize __make_comp/pred_proj for empty/scalar types
Patrick Palka [Fri, 13 Jun 2025 15:03:19 +0000 (11:03 -0400)] 
libstdc++: Optimize __make_comp/pred_proj for empty/scalar types

When creating a composite comparator/predicate that invokes a given
projection function, we don't need to capture a scalar (such as a
function pointer or member pointer) or empty object by reference,
instead capture it by value and use [[no_unique_address]] to elide
its storage (in the empty case).  This makes using __make_comp_proj
zero-cost in the common case where both functions are empty/scalars.

libstdc++-v3/ChangeLog:

* include/bits/ranges_algo.h (__detail::__by_ref_or_value_fn): New.
(__detail::_Comp_proj): New.
(__detail::__make_comp_proj): Use it instead.
(__detail::_Pred_proj): New.
(__detail::__make_pred_proj): Use it instead.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
7 weeks agolibstdc++: add a workaround for format_kind<optional<T>> [PR120644]
Giuseppe D'Angelo [Fri, 13 Jun 2025 09:38:23 +0000 (11:38 +0200)] 
libstdc++: add a workaround for format_kind<optional<T>> [PR120644]

The specialization of format_kind for optional is causing a problem when
optional is imported and included. The comments on the PR strongly
suggest that this is a frontend bug; this commit just works around the
issue by specifying the type of format_kind<optional<T>> to be
`range_format`, rather than leaving the compiler deduce it via `auto`.

PR c++/120644

libstdc++-v3/ChangeLog:

* include/std/optional (format_kind): Do not use `auto`.

7 weeks agotestsuite: Fix pr119160.c for non-glibc targets [PR119862]
Konstantinos Eleftheriou [Tue, 10 Jun 2025 06:24:45 +0000 (08:24 +0200)] 
testsuite: Fix pr119160.c for non-glibc targets [PR119862]

Testcase pr119160.c fails with symbol referencing errors for
`__cyg_profile_func_enter` and `__cyg_profile_func_exit` on non-glibc
systems.

This patch adds empty definitions for `__cyg_profile_func_enter`
and `__cyg_profile_func_exit` in order to prevent those errors.

PR testsuite/119862

gcc/testsuite/ChangeLog:

* gcc.dg/pr119160.c: Added empty definitions for
`__cyg_profile_func_enter` and `__cyg_profile_func_exit`
functions.

7 weeks agoexpand: Fix up edge splitting for ENTRY block during expansion if there are any PHIs...
Jakub Jelinek [Fri, 13 Jun 2025 12:01:18 +0000 (14:01 +0200)] 
expand: Fix up edge splitting for ENTRY block during expansion if there are any PHIs [PR120629]

Andrew ran some extra ranger checking during bootstrap and found one more
case (though much rarer than the GIMPLE_COND case).

Seems on fold-const.cc (native_encode_expr) we end up with bb 2, ENTRY
bb successor, having PHI nodes (usually there is some bb in between, even if
empty, in the native_encode_expr it is tail recursion but haven't managed
to construct a test with such case by hand).
So, we have in optimized dump
  <bb 2> [local count: 1089340384]:
  # expr_12 = PHI <expr_199(D)(0), part_93(51)>
  # ptr_13 = PHI <ptr_86(D)(0), ptr_13(51)>
  # len_14 = PHI <len_103(D)(0), _198(51)>
  # off_10 = PHI <off_102(D)(0), _207(51)>
  # add_acc_99 = PHI <0(0), add_acc_101(51)>
where there are mostly default defs from the 0->2 edge (and one zero)
and some other values from the other edge.
construct_init_block inserts a BB_RTL basic block with the function start
instructions and similarly to the GIMPLE_COND case it wants to insert that
bb on the edge from ENTRY to its single successor.
Now, without this patch redirect_edge_succ redirects the 0->2 edge to 0->52,
so the 51->2 edge gets moved first by unordered_remove, and
make_single_succ_edge adds a new 52->2 edge.  So we end up with
  # expr_12 = PHI <expr_199(D)(51), part_93(52)>
  # ptr_13 = PHI <ptr_86(D)(51), ptr_13(52)>
  # len_14 = PHI <len_103(D)(51), _198(52)>
  # off_10 = PHI <off_102(D)(51), _207(52)>
  # add_acc_99 = PHI <0(51), add_acc_101(52)>
which is not correct, the default definitions and zero are now from the edge
from end of function and the other values from the edge from the new BB_RTL
successor of ENTRY.  With this patch we get
  # expr_12 = PHI <expr_199(D)(52), part_93(51)>
  # ptr_13 = PHI <ptr_86(D)(52), ptr_13(51)>
  # len_14 = PHI <len_103(D)(52), _198(51)>
  # off_10 = PHI <off_102(D)(52), _207(51)>
  # add_acc_99 = PHI <0(52), add_acc_101(51)>
instead.

2025-06-13  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/120629
* cfgexpand.cc (construct_init_block): If first_block isn't BB_RTL,
has any PHI nodes and false_edge->dest_idx before redirection is
different from make_single_succ_edge result's dest_idx, swap the
latter with the former last pred edge and their dest_idx members.

7 weeks agolibstdc++: Replace _CharT template parameter with CharT in format tests.
Tomasz Kamiński [Fri, 13 Jun 2025 06:54:45 +0000 (08:54 +0200)] 
libstdc++: Replace _CharT template parameter with CharT in format tests.

As pointed out by Daniel Krügler we do not need to use reserved name
in tests.

libstdc++-v3/ChangeLog:

* testsuite/23_containers/vector/bool/format.cc: Replaced _CharT
with CharT.
* testsuite/std/format/debug.cc: Likewise.
* testsuite/std/format/ranges/adaptors.cc: Likewise.
* testsuite/std/format/ranges/formatter.cc: Likewise.
* testsuite/std/format/ranges/map.cc: Likewise.
* testsuite/std/format/ranges/sequence.cc: Likewise.
* testsuite/std/format/ranges/string.cc: Likewise.
* testsuite/std/format/tuple.cc: Likewise.
* testsuite/std/time/format/empty_spec.cc: Likewise.
* testsuite/std/time/format/pr120114.cc: Likewise.
* testsuite/std/time/format/pr120481.cc: Likewise.
* testsuite/std/time/format/precision.cc: Likewise.

7 weeks agolibstdc++: Rework formatting of empty chrono-spec for duration.
Tomasz Kamiński [Fri, 6 Jun 2025 10:24:11 +0000 (12:24 +0200)] 
libstdc++: Rework formatting of empty chrono-spec for duration.

In contrast to other calendar types if empty chrono-spec is used for duration
we are required to format it (and its representation type) via ostream.
Handling this case was now moved to be part of the format function
for duration. To facilitate that __formatter_chrono::_M_format_to_ostream
function was made public.

However, for standard integral types, we know the result of inserting
them into ostream, and in consequence we can format them directly. This
is handled by configuring default format spec to "%Q%q" for such types.

As we no longer use __formatter_chrono::_M_format with empty chrono-spec,
this function now requires that _M_chrono_specs are not empty,
and conditional call to _M_format_to_ostream is removed. This allows
_M_format_to_ostream to be reduced to accept only duration.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (__formatter_chrono::_M_format):
Remove handling of empty _M_chrono_specs.
(__formatter_chrono::_M_format_to_ostream): Changed to accept
only chrono::duration and made public.
(std::formatter<chrono::duration<_Rep, _Period>, _CharT>):
Configure __defSpec and handle empty chrono-spec locally.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 weeks agolibstdc++: Format empty chrono-spec for the sys_info and local_info directly.
Tomasz Kamiński [Fri, 6 Jun 2025 09:56:08 +0000 (11:56 +0200)] 
libstdc++: Format empty chrono-spec for the sys_info and local_info directly.

This patch change implementation of the formatters for sys_info and local_info,
so they no longer delegate to operator<< for ostream in case of empty spec.
As this types may be only formatted with chrono-spec containing only %%, %t, %n
specifiers and fill characters, we use a separate __formatter_chrono_info formatter.

For empty chron-spec __formatter_chrono_info formats sys_info using format_to call
with format specifier extracted from corresponding operator<<, that now delegates
to format with empty spec. For local_info we replicate functionality of the operator<<.
The alignment and padding is handled using an _Padding_sink.

For non-empty spec, we delegate to __formatter_chrono::_M_format. As non-of the
format specifiers depends on the formatted object, we pass chrono::day to avoid
triggering additional specializations.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (__format::__formatter_chrono_info)
[_GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI]: Define.
(std::formatter<chrono::sys_info, _CharT>)
(std::formatter<chrono::local_inf, _CharT>): Delegate to
__format::__formatter_chrono_info.
(std::operator<<(basic_ostream<_CharT, _Traits>& const sys_info&)):
Use format on sys_info with empty format spec.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 weeks agolibstdc++: Test chrono-spec containing only whitespaces.
Tomasz Kamiński [Thu, 12 Jun 2025 14:36:15 +0000 (16:36 +0200)] 
libstdc++: Test chrono-spec containing only whitespaces.

libstdc++-v3/ChangeLog:

* testsuite/std/time/format/whitespace.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 weeks agodriver: Try to read spec from gcc_exec_prefix if possible
Kito Cheng [Tue, 10 Jun 2025 03:17:45 +0000 (11:17 +0800)] 
driver: Try to read spec from gcc_exec_prefix if possible

GCC will try to read the spec file from the directory where it is
installed, but it should try to read from gcc_exec_prefix rather than
standard_exec_prefix, because the latter is not the right one if
compiler has been relocated into other places other than the path
specfied at configuration time.

gcc/ChangeLog:

* gcc.cc (driver::set_up_specs): Use gcc_exec_prefix to
read the spec file rather than standard_exec_prefix.

7 weeks agomcore: Don't use gen_rtx_MEM on __attribute__((dllimport))
H.J. Lu [Sun, 8 Jun 2025 06:23:09 +0000 (14:23 +0800)] 
mcore: Don't use gen_rtx_MEM on __attribute__((dllimport))

On mcore-elf, mcore_mark_dllimport generated

(gdb) call debug_tree (decl)
 <function_decl 0x7fffe9941200 f1
    type <function_type 0x7fffe981f000
        type <void_type 0x7fffe98180a8 void VOID
            align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffe98180a8
            pointer_to_this <pointer_type 0x7fffe9818150>>
        HI
        size <integer_cst 0x7fffe9802738 constant 16>
        unit-size <integer_cst 0x7fffe9802750 constant 2>
        align:16 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffe981f000
        arg-types <tree_list 0x7fffe980b988 value <void_type 0x7fffe98180a8 void>>
        pointer_to_this <pointer_type 0x7fffe991b0a8>>
    addressable used public external decl_5 SI /tmp/x.c:1:40 align:16 warn_if_not_align:0 context <translation_unit_decl 0x7fffe9955080 /tmp/x.c>
    attributes <tree_list 0x7fffe9932708
        purpose <identifier_node 0x7fffe9954000 dllimport>>
    (mem:SI (mem:SI (symbol_ref:SI ("@i.__imp_f1")) [0  S4 A32]) [0  S4 A32]) chain <function_decl 0x7fffe9941300 f2>>

which caused:

(gdb) bt
    file=0x2c0f1c8 "/export/gnu/import/git/sources/gcc-test/gcc/calls.cc",
    line=3746, function=0x2c0f747 "expand_call")
    at /export/gnu/import/git/sources/gcc-test/gcc/diagnostic.cc:1780
    target=0x0, ignore=1)
    at /export/gnu/import/git/sources/gcc-test/gcc/calls.cc:3746
...
(gdb) call debug_rtx (datum)
(mem:SI (symbol_ref:SI ("@i.__imp_f1")) [0  S4 A32])
(gdb)

Don't use gen_rtx_MEM in mcore_mark_dllimport to generate

(gdb) call debug_tree (fndecl)
 <function_decl 0x7fffe9941200 f1
    type <function_type 0x7fffe981f000
        type <void_type 0x7fffe98180a8 void VOID
            align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffe98180a8
            pointer_to_this <pointer_type 0x7fffe9818150>>
        HI
        size <integer_cst 0x7fffe9802738 constant 16>
        unit-size <integer_cst 0x7fffe9802750 constant 2>
        align:16 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffe981f000
        arg-types <tree_list 0x7fffe980b988 value <void_type 0x7fffe98180a8 void>>
        pointer_to_this <pointer_type 0x7fffe991b0a8>>
    addressable used public external decl_5 SI /tmp/x.c:1:40 align:16 warn_if_not_align:0 context <translation_unit_decl 0x7fffe9955080 /tmp/x.c>
    attributes <tree_list 0x7fffe9932708
        purpose <identifier_node 0x7fffe9954000 dllimport>>
    (mem:SI (symbol_ref:SI ("@i.__imp_f1")) [0  S4 A32]) chain <function_decl 0x7fffe9941300 f2>>
(gdb)

instead.  This fixes:

gcc.c-torture/compile/dll.c -O0 (internal compiler error: in assemble_variable, at varasm.cc:2544)
gcc.dg/visibility-12.c (internal compiler error: in expand_call, at calls.cc:3744)

for more-elf.

PR target/120589
* config/mcore/mcore.cc (mcore_mark_dllimport): Don't use
gen_rtx_MEM.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
7 weeks agoDaily bump.
GCC Administrator [Fri, 13 Jun 2025 00:17:20 +0000 (00:17 +0000)] 
Daily bump.

7 weeks agoUpdate gcc es.po
Joseph Myers [Thu, 12 Jun 2025 21:23:24 +0000 (21:23 +0000)] 
Update gcc es.po

* es.po: Update.

7 weeks agorecip: Reset range info when replacing sqrt with rsqrt [PR120638]
Jakub Jelinek [Thu, 12 Jun 2025 18:22:39 +0000 (20:22 +0200)] 
recip: Reset range info when replacing sqrt with rsqrt [PR120638]

This pass reuses a SSA_NAME on the lhs of sqrt etc. call as lhs
of .RSQRT etc. call.  The following testcase is miscompiled since my recent
ranger cast changes, because we compute (correct) range for sqrtf argument
as well as result but then recip pass keeps using that range for the .RQSRT
call which returns 1. / sqrt, so the function then returns 0.5f
unconditionally.
Note, on foo this is a regression from GCC 15, but on bar it regressed
already with the r14-536 change.

2025-06-12  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/120638
* tree-ssa-math-opts.cc (pass_cse_reciprocals::execute): Call
reset_flow_sensitive_info on arg1.

* gcc.dg/pr120638.c: New test.

7 weeks agotestsuite: Add testcase for already fixed PR [PR120630]
Jakub Jelinek [Thu, 12 Jun 2025 17:53:07 +0000 (19:53 +0200)] 
testsuite: Add testcase for already fixed PR [PR120630]

These tests were broken by my r16-1398 PR120434 change and
fixed by r16-1482 PR120629 change.

Committing these to increase testsuite coverage.

2025-06-12  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/120630
* gcc.dg/pr120630.c: New test.
* gcc.c-torture/execute/pr120630.c: New test.

7 weeks agolibstdc++: do not use an unreserved name in _Temporary_buffer [PR119496]
Giuseppe D'Angelo [Thu, 5 Jun 2025 14:50:35 +0000 (16:50 +0200)] 
libstdc++: do not use an unreserved name in _Temporary_buffer [PR119496]

As the PR observes, _Temporary_buffer was using an unreserved name for a
member function that can therefore clash with macros defined by the
user. Avoid that by renaming the member function.

PR libstdc++/119496

libstdc++-v3/ChangeLog:

* include/bits/stl_algo.h: Adjust calls to requested_size.
* include/bits/stl_tempbuf.h (requested_size): Rename with
an _M_ prefix.
* testsuite/17_intro/names.cc: Add a #define for
requested_size.

Signed-off-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
7 weeks agolibstdc++: add range support to std::optional (P3168)
Giuseppe D'Angelo [Mon, 9 Jun 2025 21:13:21 +0000 (23:13 +0200)] 
libstdc++: add range support to std::optional (P3168)

This commit implements P3168 ("Give std::optional Range Support"), added
for C++26. Both begin() and end() are straightforward, implemented using
normal_iterator over a raw pointer.

std::optional is also a view, so specialize enable_view for it.

We also need to disable automatic formatting a std::optional as a range
by specializing format_kind. In order to avoid dragging <format> when
including <optional>, I've isolated format_kind and some supporting code
into <bits/formatfwd.h> so that I can use that (comparatively) lighter
header.

libstdc++-v3/ChangeLog:

* include/bits/formatfwd.h (format_kind): Move the definition
(and some supporting code) from <format>.
* include/std/format (format_kind): Likewise.
* include/bits/version.def (optional_range_support): Add
the feature-testing macro.
* include/bits/version.h: Regenerate.
* include/std/optional (iterator, const_iterator, begin, end):
Add range support.
(enable_view): Specialize for std::optional.
(format_kind): Specialize for std::optional.
* testsuite/20_util/optional/range.cc: New test.
* testsuite/20_util/optional/version.cc: Test the new
feature-testing macro.

7 weeks agoor1k: Fix ICE in libgcc caused by recent validate_subreg changes
Stafford Horne [Sat, 7 Jun 2025 13:46:30 +0000 (14:46 +0100)] 
or1k: Fix ICE in libgcc caused by recent validate_subreg changes

After commit eb2ea476db2 ("emit-rtl: Allow extra checks for
paradoxical subregs [PR119966]") paradoxical subregs or the OpenRISC
condition flag register (reg:BI sr_f) are no longer allowed.

This causes and ICE in the ce1 pass which tries to get the or1k flag
register into an SI register, which is no longer possible.

Adjust or1k_can_change_mode_class to allow changing the or1k flag reg to
SI mode which in turn allows paradoxical subregs to be generated again.

gcc/ChangeLog:

PR target/120587
* config/or1k/or1k.cc (or1k_can_change_mode_class): Allow
changing flags mode from BI to SI to allow for paradoxical
subregs.

7 weeks agolibstdc++: Format empty chrono-spec for the time points and hh_mm_ss directly.
Tomasz Kamiński [Fri, 6 Jun 2025 09:32:27 +0000 (11:32 +0200)] 
libstdc++: Format empty chrono-spec for the time points and hh_mm_ss directly.

This patch change implementation of the formatters for time points and hh_mm_ss,
so they no longer delegate to operator<< for ostream in case of empty chrono-spec.
As in case of calendar types, the formatters for specific type now provide
__formatter_chrono with default _ChronoSpec that are used in case if empty
chrono-spec.

The configuration of __defSpec is straight forward, except for the sys_time,
and local_time that print time, if the duration is convertible to days,
which is equivalent to setting _M_chrono_specs "%F" instead of "%F %T".
Furthermore, certain sys_time<Dur> do not support ostream operator, and
should not be formattable with empty spec - in such case default
_M_chrono_spec, allowing the issue to still be detected in _M_parse.

Finally, _ChronoFormats are extended to cover required format strings.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (_ChronoFormats::_S_ftz)
(_ChronoFormats::_S_ft, _ChronoFormats::_S_t): Define.
(__formatter_chrono::_M_format_to_ostream): Remove handling for
time_points.
(std::formatter<chrono::hh_mm_ss<_Dur>, _CharT>)
(std::formatter<chrono::sys_time<_Dur>, _CharT>)
(std::formatter<chrono::utc_time<_Dur>, _CharT>)
(std::formatter<chrono::tai_time<_Dur>, _CharT>)
(std::formatter<chrono::gps_time<_Dur>, _CharT>)
(std::formatter<chrono::file_time<_Dur>, _CharT>)
(std::formatter<chrono::local_time<_Dur>, _CharT>)
(std::formatter<chrono::__detail::__local_time_fmt<_Dur>, _CharT>)
(std::formatter<chrono::zoned_time<_Dur>, _CharT>):
Define __defSpec, and pass it as argument to _M_prase and
constructor of __formatter_chrono.

7 weeks agolibstdc++: Format empty chrono-spec for the calendar types directly.
Tomasz Kamiński [Fri, 6 Jun 2025 08:45:21 +0000 (10:45 +0200)] 
libstdc++: Format empty chrono-spec for the calendar types directly.

This patch change implementation of the formatters for the calendar types,
so they no longer delegate to operator<< for ostream in case of empty chrono-spec.
Instead of that, we define the behavior in terms of format specifiers
supplied by each formatter as an argument to _M_parse. Similarly each formatter
constructs its __formatter_chrono from a relevant default spec, preserving the
functionality of calling format on default constructed formatters.

Expressing  the existing functionality of the operator ostream, requires
providing two additional features:
 * printing "is not a valid sth" for !ok objects,
 * printing a weekday index in the month.

The formatter functionality is enabled by setting spec _M_debug (corresponding
to '?') that is currently unused. This is currently supported only for
subset of format specifiers used by the ostream operators. In future, we could
make this user configurable (by adding '?' after 'L') and cover all flags.

For the handling of the weekday index (for weekday_indexed, month_weekday,
year_month_weekday), we need to introduce a new format specifier. To not
conflict with future extension we use '%\0' (embedded null) as this character
cannot be placed in valid format spec.

Finally, the format strings for calendar types subsets each other, e.g.
year_month_weekday_last ("%Y/%b/%a[last])" contains month_weekday_last,
weekday_last, weekday, e.t.c.. We introduce a _ChronoFormats class that provide
consteval accessors to format specs, internally sharing they representations.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (__format::_ChronoFormats): Define.
(__formatter_chrono::__formatter_chrono())
(__formatter_chrono::__formatter_chrono(_ChronoSpec<_CharT>)): Define.
(__formatter_chrono::_M_parse): Add parameter with default spec,
and merge it with new values. Handle '%\0' as weekday index
specifier.
(__formatter_chrono::_M_a_A, __formatter_chrono::_M_b_B)
(__formatter_chrono::_M_C_y_Y, __formatter_chrono::_M_d_e)
(__formatter_chrono::_M_F): Support _M_debug flag.
(__formatter_chrono::_M_wi, __formatter_chrono::_S_weekday_index):
Define.
(std::formatter<chrono::day, _CharT>)
(std::formatter<chrono::month, _CharT>)
(std::formatter<chrono::year, _CharT>)
(std::formatter<chrono::weekday, _CharT>)
(std::formatter<chrono::weekday_indexed, _CharT>)
(std::formatter<chrono::weekday_last, _CharT>)
(std::formatter<chrono::month_day, _CharT>)
(std::formatter<chrono::month_day_last, _CharT>)
(std::formatter<chrono::month_weekday, _CharT>)
(std::formatter<chrono::month_weekday_last, _CharT>)
(std::formatter<chrono::year_month, _CharT>)
(std::formatter<chrono::year_month_day, _CharT>)
(std::formatter<chrono::year_month_day_last, _CharT>)
(std::formatter<chrono::year_month_weekday, _CharT>)
(std::formatter<chrono::year_month_weekday_last, _CharT>):
Define __defSpec, and pass it as argument to _M_parse and
constructor of __formatter_chrono.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 weeks agoi386: Fix signed integer overflow in ix86_expand_int_movcc, part 2 [PR120604]
Uros Bizjak [Thu, 12 Jun 2025 12:03:50 +0000 (14:03 +0200)] 
i386: Fix signed integer overflow in ix86_expand_int_movcc, part 2 [PR120604]

Make sure we can represent the difference between two 64-bit DImode immediate
values in 64-bit HOST_WIDE_INT and return false if this is not the case.

ix86_expand_int_movcc is used in mov<mode>cc expaner.  Expander will FAIL
when the function returns false and middle-end will retry expansion with
values forced to registers.

PR target/120604

gcc/ChangeLog:

* config/i386/i386-expand.cc (ix86_expand_int_movcc): Make sure
we can represent the difference between two 64-bit DImode
immediate values in 64-bit HOST_WIDE_INT.

7 weeks agoexpand: Fix up edge splitting for GIMPLE_COND expansion if there are any PHIs [PR120629]
Jakub Jelinek [Thu, 12 Jun 2025 13:51:51 +0000 (15:51 +0200)] 
expand: Fix up edge splitting for GIMPLE_COND expansion if there are any PHIs [PR120629]

My r16-1398 PR120434 ranger during expansion change broke profiled lto
bootstrap on x86_64-linux, the following testcase is reduced from that.

The problem is during expand_gimple_cond, if we are unlucky that neither
of edge_true and edge_false point to the next basic block, the code
effectively attempts to split the false_edge and make the new bb BB_RTL
with some extra instructions which just arranges to jump.
It does it by creating a new bb, redirecting the false_edge and then
creating a new edge from the new bb to the dest.
Note, we don't have GIMPLE cfg hooks installed anymore and even if we
would, the 3 calls aren't the same as one split_edge with transformation
of the new bb into BB_RTL and adding it some BB_HEAD/BB_END.  If
false_edge->dest is BB_RTL or doesn't have PHI nodes (which before my
patch was always the case because), then this works fine, but with
PHI nodes on false_edge->dest redirect_edge_succ will remove the false_edge
from dest->preds (unordered remove which moves into its place the last edge
in the vector) and the new make_edge will then add the new edge as last
in the vector.  So, unless false_edge is the last edge in the dest->preds
vector this effectively swaps the last edge in the vector with
false_edge/its new replacement.
gimple_split_edge solves this by temporarily clearing phi_nodes on dest
(not needed when we don't have GIMPLE hooks), then making the new edge
first and redirecting the old edge (plus restoring phi_nodes on dest).
That way the redirection replaces the old edge with the new one and
PHI arguments don't need adjustment.  At the cost of temporarily needing
one more edge in the vector and so if unlucky reallocation.
Doing it like that is one of the options (i.e. just move the
make_single_succ_edge call).  This patch instead keeps doing what it did
and just swaps two edges again if needed to restore the PHI behavior
- remember edge_false->dest_idx first if there are PHI nodes in
edge_false->dest and afterwards if new edge's dest_idx is different from
the remembered one, swap the new edge with EDGE_PRED (dest, old_dest_idx).
That way PHI arguments are maintained properly as well.  Without this
we sometimes just swap PHI arguments.

In particular we had
  # ivtmp.24_52 = PHI <ivtmp.24_49(10), 1(6)>
on bb 8 (dest) and edge_false is the 10->8 edge.  We create a new
BB_RTL bb 15 on this edge, redirect the 10->8 edge to 10->15 which
does unordered_remove and so the bb8->preds edge vec is just 6->8,
PHIs not touched as in IR_RTL_CFGRTL mode.  Then a new 15->8 edge is
created.  Without the patch we get
  # ivtmp.24_52 = PHI <ivtmp.24_49(6), 1(15)>
which is wrong, while with this patch we get
  # ivtmp.24_52 = PHI <ivtmp.24_49(15), 1(6)>
which matches just the addition of (for ranger uninteresting) BB_RTL
on the 10->15->8 edge.

2025-06-12  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/120629
* cfgexpand.cc (expand_gimple_cond): If dest bb isn't BB_RTL,
has any PHI nodes and false_edge->dest_idx before redirection is
different from make_single_succ_edge result's dest_idx, swap the
latter with the former last pred edge and their dest_idx members.

* g++.dg/opt/pr120629.C: New test.

7 weeks agoRISC-V: Add test for vec_dup + vmax.vv combine case 1 with max func 1 and GR2VR cost...
Pan Li [Thu, 12 Jun 2025 02:42:39 +0000 (10:42 +0800)] 
RISC-V: Add test for vec_dup + vmax.vv combine case 1 with max func 1 and GR2VR cost 0, 1 and 2

Add asm dump check test for vec_duplicate + vmax.vv combine to vmax.vx,
with the GR2VR cost is 0, 1 and 2.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-i16.c: Add asm check
for vmax.vx combine.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-i8.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
7 weeks agoRISC-V: Add test for vec_dup + vmax.vv combine case 1 with max func 0 and GR2VR cost...
Pan Li [Thu, 12 Jun 2025 02:23:49 +0000 (10:23 +0800)] 
RISC-V: Add test for vec_dup + vmax.vv combine case 1 with max func 0 and GR2VR cost 0, 1 and 2

Add asm dump check test for vec_duplicate + vmax.vv combine to vmax.vx,
with the GR2VR cost is 0, 1 and 2.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-i16.c: Add asm check
for vmax.vx combine.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-i8.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
7 weeks agoRISC-V: Add test for vec_dup + vmax.vv combine case 0 with max func 1 and GR2VR cost...
Pan Li [Thu, 12 Jun 2025 01:12:09 +0000 (09:12 +0800)] 
RISC-V: Add test for vec_dup + vmax.vv combine case 0 with max func 1 and GR2VR cost 0, 2 and 15

Add asm dump check test for vec_duplicate + vmax.vv combine to
vmax.vx, with the GR2VR cost is 0, 2 and 15.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i16.c: Add asm check
for max func 1 vmax.vx combine.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmax-run-2-i16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmax-run-2-i32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmax-run-2-i64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmax-run-2-i8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
7 weeks agoRISC-V: Add test for vec_dup + vmax.vv combine case 0 with max func 0 and GR2VR cost...
Pan Li [Wed, 11 Jun 2025 13:51:08 +0000 (21:51 +0800)] 
RISC-V: Add test for vec_dup + vmax.vv combine case 0 with max func 0 and GR2VR cost 0, 2 and 15

Add asm dump check test for vec_duplicate + vmax.vv combine to vmax.vx,
with the GR2VR cost is 0, 2 and 15.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i16.c: Add asm check
for max func 1 vmax.vx combine.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary.h: Add test
helper macros.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary_data.h: Add test
data for run test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmax-run-1-i16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmax-run-1-i32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmax-run-1-i64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmax-run-1-i8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
7 weeks agoRISC-V: Combine vec_duplicate + vmax.vv to vmax.vx on GR2VR cost
Pan Li [Wed, 11 Jun 2025 13:49:21 +0000 (21:49 +0800)] 
RISC-V: Combine vec_duplicate + vmax.vv to vmax.vx on GR2VR cost

This patch would like to combine the vec_duplicate + vmax.vv to the
vmax.vx.  From example as below code.  The related pattern will depend
on the cost of vec_duplicate from GR2VR.  Then the late-combine will
take action if the cost of GR2VR is zero, and reject the combination
if the GR2VR cost is greater than zero.

Assume we have example code like below, GR2VR cost is 0.

  #define DEF_VX_BINARY(T, OP)                                        \
  void                                                                \
  test_vx_binary (T * restrict out, T * restrict in, T x, unsigned n) \
  {                                                                   \
    for (unsigned i = 0; i < n; i++)                                  \
      out[i] = in[i] OP x;                                            \
  }

  DEF_VX_BINARY(int32_t, /)

Before this patch:
  10   │ test_vx_binary_or_int32_t_case_0:
  11   │     beq a3,zero,.L8
  12   │     vsetvli a5,zero,e32,m1,ta,ma
  13   │     vmv.v.x v2,a2
  14   │     slli    a3,a3,32
  15   │     srli    a3,a3,32
  16   │ .L3:
  17   │     vsetvli a5,a3,e32,m1,ta,ma
  18   │     vle32.v v1,0(a1)
  19   │     slli    a4,a5,2
  20   │     sub a3,a3,a5
  21   │     add a1,a1,a4
  22   │     vmax.vv v1,v1,v2
  23   │     vse32.v v1,0(a0)
  24   │     add a0,a0,a4
  25   │     bne a3,zero,.L3

After this patch:
  10   │ test_vx_binary_or_int32_t_case_0:
  11   │     beq a3,zero,.L8
  12   │     slli    a3,a3,32
  13   │     srli    a3,a3,32
  14   │ .L3:
  15   │     vsetvli a5,a3,e32,m1,ta,ma
  16   │     vle32.v v1,0(a1)
  17   │     slli    a4,a5,2
  18   │     sub a3,a3,a5
  19   │     add a1,a1,a4
  20   │     vmax.vx v1,v1,a2
  21   │     vse32.v v1,0(a0)
  22   │     add a0,a0,a4
  23   │     bne a3,zero,.L3

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_vx_binary_vec_dup_vec): Add new
case SMAX.
(expand_vx_binary_vec_vec_dup): Ditto.
* config/riscv/riscv.cc (riscv_rtx_costs): Ditto.
* config/riscv/vector-iterators.md: Add new op smax.

Signed-off-by: Pan Li <pan2.li@intel.com>
7 weeks agoaarch64: Incorrect removal of ZA restore [PR120624]
Richard Sandiford [Thu, 12 Jun 2025 11:10:39 +0000 (12:10 +0100)] 
aarch64: Incorrect removal of ZA restore [PR120624]

The PCS defines a lazy save scheme for managing ZA across normal
"private-ZA" functions.  GCC currently uses this scheme for calls
to all private-ZA functions (rather than using caller-save).

Therefore, before a sequence of calls to private-ZA functions, GCC emits
code to set up a lazy save.  After the sequence of calls, GCC emits code
to check whether lazy save was committed and restore the ZA contents
if so.

These sequences are emitted by the mode-switching pass, in an attempt
to reduce the number of redundant saves and restores.

The lazy save scheme also means that, before a function can use ZA,
it must first conditionally store the old contents of ZA to the caller's
lazy save buffer, if any.

This all creates some relatively complex dependencies between
setup code, save/restore code, and normal reads from and writes to ZA.
These dependencies are modelled using special fake hard registers:

    ;; Sometimes we use placeholder instructions to mark where later
    ;; ABI-related lowering is needed.  These placeholders read and
    ;; write this register.  Instructions that depend on the lowering
    ;; read the register.
    (LOWERING_REGNUM 87)

    ;; Represents the contents of the current function's TPIDR2 block,
    ;; in abstract form.
    (TPIDR2_BLOCK_REGNUM 88)

    ;; Holds the value that the current function wants PSTATE.ZA to be.
    ;; The actual value can sometimes vary, because it does not track
    ;; changes to PSTATE.ZA that happen during a lazy save and restore.
    ;; Those effects are instead tracked by ZA_SAVED_REGNUM.
    (SME_STATE_REGNUM 89)

    ;; Instructions write to this register if they set TPIDR2_EL0 to a
    ;; well-defined value.  Instructions read from the register if they
    ;; depend on the result of such writes.
    ;;
    ;; The register does not model the architected TPIDR2_ELO, just the
    ;; current function's management of it.
    (TPIDR2_SETUP_REGNUM 90)

    ;; Represents the property "has an incoming lazy save been committed?".
    (ZA_FREE_REGNUM 91)

    ;; Represents the property "are the current function's ZA contents
    ;; stored in the lazy save buffer, rather than in ZA itself?".
    (ZA_SAVED_REGNUM 92)

    ;; Represents the contents of the current function's ZA state in
    ;; abstract form.  At various times in the function, these contents
    ;; might be stored in ZA itself, or in the function's lazy save buffer.
    ;;
    ;; The contents persist even when the architected ZA is off.  Private-ZA
    ;; functions have no effect on its contents.
    (ZA_REGNUM 93)

Every normal read from ZA and write to ZA depends on SME_STATE_REGNUM,
in order to sequence the code with the initial setup of ZA and
with the lazy save scheme.

The code to restore ZA after a call involves several instructions,
including conditional control flow.  It is initially represented as
a single define_insn and is split late, after shrink-wrapping and
prologue/epilogue insertion.

The split form of the restore instruction includes a conditional call
to __arm_tpidr2_restore:

(define_insn "aarch64_tpidr2_restore"
  [(set (reg:DI ZA_SAVED_REGNUM)
(unspec:DI [(reg:DI R0_REGNUM)] UNSPEC_TPIDR2_RESTORE))
   (set (reg:DI SME_STATE_REGNUM)
(unspec:DI [(reg:DI SME_STATE_REGNUM)] UNSPEC_TPIDR2_RESTORE))
  ...
)

The write to SME_STATE_REGNUM indicates the end of the region where
ZA_REGNUM might differ from the real contents of ZA.  In other words,
it is the point at which normal reads from ZA and writes to ZA
can safely take place.

To finally get to the point, the problem in this PR was that the
unsplit aarch64_restore_za pattern was missing this change to
SME_STATE_REGNUM.  It could therefore be deleted as dead before
it had chance to be split.  The split form had the correct dataflow,
but the unsplit form didn't.

Unfortunately, the tests for this code tended to use calls and asms
to model regions of ZA usage, and those don't seem to be affected
in the same way.

gcc/
PR target/120624
* config/aarch64/aarch64.md (SME_STATE_REGNUM): Expand on comments.
* config/aarch64/aarch64-sme.md (aarch64_restore_za): Also set
SME_STATE_REGNUM

gcc/testsuite/
PR target/120624
* gcc.target/aarch64/sme/za_state_7.c: New test.

7 weeks agoDaily bump.
GCC Administrator [Thu, 12 Jun 2025 10:03:36 +0000 (10:03 +0000)] 
Daily bump.

7 weeks agolibstdc++: Uglify __mapping_alike template parameter and fix test and typo in comment.
Tomasz Kamiński [Thu, 5 Jun 2025 08:40:10 +0000 (10:40 +0200)] 
libstdc++: Uglify __mapping_alike template parameter and fix test and typo in comment.

When the static assert was generated from instantiations of default member
initializer of class B, the error was not generated for B<1, std::layout_left,
std::layout_left> case, only when -D_GLIBCXX_DEBUG was set. Changing B calls to
functions fixes that.

We also replace class with typename in template head of layout_right::mapping
constructors.

libstdc++-v3/ChangeLog:

* include/std/mdspan (__mdspan::__mapping_alike): Rename template
parameter from M to _M_p.
(layout_right::mapping): Replace class with typename in template
head.
(layout_stride::mapping): Fix typo in comment.
* testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc:
Changed B to function.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 weeks agolibstdc++: Make layout_left(layout_stride) noexcept.
Luc Grosheintz [Wed, 4 Jun 2025 14:58:53 +0000 (16:58 +0200)] 
libstdc++: Make layout_left(layout_stride) noexcept.

[mdspan.layout.left.cons] of N4950 states that this ctor is not
noexcept. Since, all other ctors of layout_left, layout_right or
layout_stride are noexcept, the choice was made, based on
[res.on.exception.handling], to make this ctor noexcept.

Two other major standard library implementations make the same choice.

libstdc++-v3/ChangeLog:

* include/std/mdspan (layout_left): Strengthen the exception
guarantees of layout_left::mapping(layout_stride::mapping).
* testsuite/23_containers/mdspan/layouts/ctors.cc:
Simplify tests to reflect the change.

Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 weeks agolibstdc++: Add tests for layout_stride.
Luc Grosheintz [Wed, 4 Jun 2025 14:58:52 +0000 (16:58 +0200)] 
libstdc++: Add tests for layout_stride.

Implements the tests for layout_stride and for the features of the other
two layouts that depend on layout_stride.

libstdc++-v3/ChangeLog:

* testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc: Add
tests for layout_stride.
* testsuite/23_containers/mdspan/layouts/ctors.cc: Add test for
layout_stride and the interaction with other layouts.
* testsuite/23_containers/mdspan/layouts/empty.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/mapping.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/stride.cc: New test.

Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 weeks agolibstdc++: Implement layout_stride from mdspan.
Luc Grosheintz [Wed, 4 Jun 2025 14:58:51 +0000 (16:58 +0200)] 
libstdc++: Implement layout_stride from mdspan.

Implements the remaining parts of layout_left and layout_right; and all
of layout_stride.

The implementation of layout_stride::mapping::is_exhaustive applies
the following change to the standard:

  4266. layout_stride::mapping should treat empty mappings as exhaustive

https://cplusplus.github.io/LWG/issue4266

The preconditions for layout_stride(extents, strides) are not checked.

libstdc++-v3/ChangeLog:

* include/std/mdspan (layout_stride): New class.
* src/c++23/std.cc.in: Add layout_stride.

Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 weeks agolibstdc++: Add tests for layout_right.
Luc Grosheintz [Wed, 4 Jun 2025 14:58:50 +0000 (16:58 +0200)] 
libstdc++: Add tests for layout_right.

Adds tests for layout_right and for the parts of layout_left that depend
on layout_right.

libstdc++-v3/ChangeLog:

* testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc: Add
tests for layout_right.
* testsuite/23_containers/mdspan/layouts/ctors.cc: Add tests for
layout_right and the interaction with layout_left.
* testsuite/23_containers/mdspan/layouts/empty.cc: ditto.
* testsuite/23_containers/mdspan/layouts/mapping.cc: ditto.

Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 weeks agolibstdc++: Implement layout_right from mdspan.
Luc Grosheintz [Wed, 4 Jun 2025 14:58:49 +0000 (16:58 +0200)] 
libstdc++: Implement layout_right from mdspan.

Implement the parts of layout_left that depend on layout_right; and the
parts of layout_right that don't depend on layout_stride.

libstdc++-v3/ChangeLog:

* include/std/mdspan (layout_right): New class.
* src/c++23/std.cc.in: Add layout_right.

Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 weeks agolibstdc++: Add tests for layout_left.
Luc Grosheintz [Wed, 4 Jun 2025 14:58:48 +0000 (16:58 +0200)] 
libstdc++: Add tests for layout_left.

Implements a suite of tests for the currently implemented parts of
layout_left. The individual tests are templated over the layout type, to
allow reuse as more layouts are added.

libstdc++-v3/ChangeLog:

* testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc: New test.
* testsuite/23_containers/mdspan/layouts/ctors.cc: New test.
* testsuite/23_containers/mdspan/layouts/empty.cc: New test.
* testsuite/23_containers/mdspan/layouts/mapping.cc: New test.

Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 weeks agolibstdc++: Implement layout_left from mdspan.
Luc Grosheintz [Wed, 4 Jun 2025 14:58:47 +0000 (16:58 +0200)] 
libstdc++: Implement layout_left from mdspan.

Implements the parts of layout_left that don't depend on any of the
other layouts.

libstdc++-v3/ChangeLog:

* include/std/mdspan (layout_left): New class.
* src/c++23/std.cc.in: Add layout_left.

Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 weeks agolibstdc++: Improve naming, whitespace and silence warnings for extents.
Luc Grosheintz [Wed, 4 Jun 2025 14:58:46 +0000 (16:58 +0200)] 
libstdc++: Improve naming, whitespace and silence warnings for extents.

libstdc++-v3/ChangeLog:

* include/std/mdspan(__mdspan::_ExtentsStorage): Change name
of private member _M_dynamic_extens to _M_dyn_exts.
(extents): Change name of private member from _M_dynamic_extents
to _M_exts.
Fix two instances of whitespace errors.
* testsuite/23_containers/mdspan/extents/ctor_default.cc: Fix
integer comparison with cmp_equal.

Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 weeks agoPR modula2/119650: Regenerate target independent documentation
Gaius Mulley [Thu, 12 Jun 2025 09:00:36 +0000 (10:00 +0100)] 
PR modula2/119650: Regenerate target independent documentation

This patch regenerates the target independent documentation
triggered by the additional library modules.

gcc/m2/ChangeLog:

PR modula2/119650
* gm2-libs/ARRAYOFCHAR.def: Remove comment about non
existent read.
* target-independent/m2/Builtins.texi: Regenerate.
* target-independent/m2/SYSTEM-iso.texi: Ditto.
* target-independent/m2/SYSTEM-pim.texi: Ditto.
* target-independent/m2/gm2-libs.texi: Ditto.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
7 weeks agolibstdc++: Improve documentation on copyright notices in new tests
Jonathan Wakely [Tue, 10 Jun 2025 08:56:05 +0000 (09:56 +0100)] 
libstdc++: Improve documentation on copyright notices in new tests

Clarify that FSF copyright notices in tests are incorrect for
contributions under DCO terms. Clarify the sentence about copying
existing tests to clarify that it is only referring to copying the code
in the test file, rather than just copying an existing file as a
template for a new test.

libstdc++-v3/ChangeLog:

* doc/xml/manual/test.xml: Improve discussion of copyright
notices in new test cases.
* doc/html/manual/test.html: Regenerate.

7 weeks agolibstdc++: Remove outdated comment about wchar_t in create_testsuite_files
Jonathan Wakely [Fri, 6 Jun 2025 12:43:22 +0000 (13:43 +0100)] 
libstdc++: Remove outdated comment about wchar_t in create_testsuite_files

This script claims that wchar_t tests are filtered out if the toolchain
being tested doesn't support it.  That doesn't seem to have been true
since r0-68039-ga72c74a1dee345 in 2005.

libstdc++-v3/ChangeLog:

* scripts/create_testsuite_files: Remove incorrect comment about
filtering out wchar_t tests.

7 weeks agolibstdc++: Do not specialize std::formatter for incomplete type [PR120625]
Jonathan Wakely [Wed, 11 Jun 2025 10:11:52 +0000 (11:11 +0100)] 
libstdc++: Do not specialize std::formatter for incomplete type [PR120625]

Using an incomplete type as the template argument for std::formatter
specializations causes problems for program-defined specializations of
std::formatter which have constraints. When the compiler has to find
which specialization of std::formatter to use for the incomplete type it
considers the program-defined specializations and checks to see if their
constraints are satisfied, which can give errors if the constraints
cannot be checked for incomplete types.

This replaces the base class of the disabled specializations with a
concrete class __formatter_disabled, so there is no need to match a
specialization and no more incomplete type.

libstdc++-v3/ChangeLog:

PR libstdc++/120625
* include/std/format (__format::__disabled): Remove.
(__formatter_disabled): New type.
(formatter<char*, wchar_t>, formatter<const char*, wchar_t>)
(formatter<char[N], wchar_t>, formatter<string, wchar_t>)
(formatter<string_view, wchar_t>): Use __formatter_disabled as
base class instead of formatter<__disabled, wchar_t>.
* testsuite/std/format/formatter/120625.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
7 weeks agoada: Fix code size increase with pragma Aggregate_Individually_Assign
Eric Botcazou [Fri, 7 Feb 2025 08:26:51 +0000 (09:26 +0100)] 
ada: Fix code size increase with pragma Aggregate_Individually_Assign

The problem is that individual assignments have to preserve the other bits
of the target, in other words the original semantics of aggregates, where
the anonymous object is entirely constructed, is partially lost.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Generate
a zero-initialization for the anonymous object of a small aggregate
allocated on the stack.
(inline_status_for_subprog): Minor tweak.

7 weeks agoada: Update bug-box texts
Tonu Naks [Thu, 30 May 2024 09:22:18 +0000 (09:22 +0000)] 
ada: Update bug-box texts

gcc/ada/ChangeLog:

* comperr.adb: update support instructions
* switch.adb: update support instructions

7 weeks agoada: Fix reference to RM clause in comment
Ronan Desplanques [Thu, 10 Apr 2025 15:08:34 +0000 (17:08 +0200)] 
ada: Fix reference to RM clause in comment

The implicit declarations for labels are defined in 5.1 (12), not
5.1 (3).

gcc/ada/ChangeLog:

* sinfo.ads: Fix RM reference.

7 weeks agoada: Reuse local constant when handling External_Initialization
Piotr Trojanek [Thu, 10 Apr 2025 08:13:35 +0000 (10:13 +0200)] 
ada: Reuse local constant when handling External_Initialization

Code cleanup; behavior is unaffected.

gcc/ada/ChangeLog:

* sem_ch3.adb (Apply_External_Initialization): Reuse local constant.

7 weeks agoada: Fix documentation of Generalized Finalization extension
Eric Botcazou [Sat, 5 Apr 2025 14:21:45 +0000 (16:21 +0200)] 
ada: Fix documentation of Generalized Finalization extension

The current documentation does not reflect the implementation present in
the compiler and contains various other inaccuracies.

gcc/ada/ChangeLog:

* doc/gnat_rm/gnat_language_extensions.rst
(Generalized Finalization): Document the actual implementation.
(No_Raise): Move to separate section.
* gnat_rm.texi: Regenerate.

7 weeks agoada: Apply tweak for machine-code-based coverage
Ronan Desplanques [Mon, 7 Apr 2025 08:19:24 +0000 (10:19 +0200)] 
ada: Apply tweak for machine-code-based coverage

gcc/ada/ChangeLog:

* libgnat/s-valuer.adb (Scan_Raw_Real): Apply tweak.

7 weeks agoada: Fix support e-mail addresses
Tonu Naks [Fri, 4 Apr 2025 14:38:35 +0000 (14:38 +0000)] 
ada: Fix support e-mail addresses

gcc/ada/ChangeLog:

* comperr.adb: replace report@ with support@
* gnatcmd.adb: replace report@ with support@

7 weeks agoada: Fix wrong visibility over discriminants
Ronan Desplanques [Fri, 4 Apr 2025 08:31:27 +0000 (10:31 +0200)] 
ada: Fix wrong visibility over discriminants

This patch fixes an issue where the compiler was incorrectly allowing
references to discriminants of the ancestor type in private type
extensions.

gcc/ada/ChangeLog:

* sem_ch3.adb (Build_Derived_Private_Type): Fix test.
(Build_Derived_Record_Type): Adjust error recovery paths.

7 weeks agoada: Assorted minor cleanups and tweaks
Eric Botcazou [Fri, 4 Apr 2025 18:17:28 +0000 (20:17 +0200)] 
ada: Assorted minor cleanups and tweaks

There should be no functional changes.

gcc/ada/ChangeLog:

* einfo.ads (Has_Homonym): Fix inaccuracy in description.
* sem_ch8.ads (Find_Direct_Name): Remove obsolete description.
* sem_ch12.adb (Analyze_Associations): Rename I_Node parameter
into N and adjust description.
(Analyze_Subprogram_Instantiation): Add missing description.
(Contains_Instance_Of): Fix description.
(Associations): Rename Generic_Actual_Rec into Actual_Rec and
Gen_Assocs_Rec into Match_Rec.
(Analyze_One_Association): Rename I_Node parameter into N.
(Check_Fixed_Point_Warning): Rename Gen_Assocs parameter into
Match.
(Body of Associations): Minor cleanups and tweaks.
(Analyze_Associations): Rename I_Node parameter into N and
adjust implementation.
(Analyze_One_Association): Likewise.
(Analyze_Package_Instantiation): Remove obsolete code and clean up.
(Check_Fixed_Point_Warning): Rename Gen_Assocs parameter into
Match and adjust implementation.
(Freeze_Package_Instance): Simplify condition.
(Get_Unit_Instantiation_Node): Add support for instantiations of
subprograms and stop the loop properly in case of errors.
* sem_util.ads (Add_Global_Declaration): Rename N parameter into
Decl and fix description.
* sem_util.adb (Add_Global_Declaration): Rename N parameter into
Decl and adjust implementation.

7 weeks agoada: Add Ada RM clause reference in comment
Ronan Desplanques [Wed, 2 Apr 2025 15:30:43 +0000 (17:30 +0200)] 
ada: Add Ada RM clause reference in comment

gcc/ada/ChangeLog:

* libgnat/s-valuer.adb (Scan_Raw_Real): Add RM reference.

7 weeks agoada: Remove subexpression that's always False
Ronan Desplanques [Thu, 3 Apr 2025 12:22:24 +0000 (14:22 +0200)] 
ada: Remove subexpression that's always False

Also improve a few comments in the enclosing subprogram body.

gcc/ada/ChangeLog:

* libgnat/s-valuer.adb (Scan_Raw_Real): Remove subexpression. Improve
surrounding comments.

7 weeks agoada: VAST: Check basic tree properties
Bob Duff [Tue, 1 Apr 2025 23:03:31 +0000 (19:03 -0400)] 
ada: VAST: Check basic tree properties

Check that the tree is really a tree, that parent pointers
make sense, that every node has been analyzed, and so on.
Most of these checks are disabled, because they fail in
many cases, including the compiler and run-time library.

Improve the debugging support in VAST. Walk subtrees "by hand",
rather than calling Atree.Traverse routines, because that
makes debugging printouts more convenient, and because we
want to keep a node stack for checking parents.

gcc/ada/ChangeLog:

* vast.adb: Check basic tree properties.
* atree.adb (Traverse_Field): Minor.
* treepr.adb (Destroy): Minor comment.

7 weeks agoada: Fix rounding test with odd bases
Eric Botcazou [Wed, 2 Apr 2025 11:13:33 +0000 (13:13 +0200)] 
ada: Fix rounding test with odd bases

The test as currently written is incorrect for odd bases.

gcc/ada/ChangeLog:

* libgnat/s-valuer.adb (Round_Extra): Use multiplicative test.

7 weeks agoada: Remove obsolete test
Ronan Desplanques [Mon, 31 Mar 2025 13:17:26 +0000 (15:17 +0200)] 
ada: Remove obsolete test

A previous change cleaned up the Ekind field of record component
entities. That made a particular test obsolete, so this patch removes
that test.

gcc/ada/ChangeLog:

* einfo-utils.adb (Set_Convention): Remove obsolete test.

7 weeks agoada: Set Ekinds of discriminants earlier
Ronan Desplanques [Wed, 2 Apr 2025 09:48:06 +0000 (11:48 +0200)] 
ada: Set Ekinds of discriminants earlier

Some error processing paths in Enter_Name are adjusted so that error
messages are not affected.

gcc/ada/ChangeLog:

* sem_ch3.adb (Process_Discriminants): Set Ekind earlier.
* sem_util.adb (Enter_Name): Adjust error processing.

7 weeks agoada: Fix various issues in System.Value_F.Integer_To_Fixed function
Eric Botcazou [Wed, 2 Apr 2025 08:02:18 +0000 (10:02 +0200)] 
ada: Fix various issues in System.Value_F.Integer_To_Fixed function

The first issue is that the function would wrongly raise Constraint_Error
on the edge case where Val = 2**(Int'Size - 1) and Minus is not set.

The second issue is that some runtimes are compiled with -gnatp and would
fail to raise Constraint_Error when the sum of the terms overflows an Int.

The third issue is that the function takes a long time to deal with huge
negative exponents.

gcc/ada/ChangeLog:

* libgnat/s-valuef.adb (Integer_To_Fixed): Enable overflow checks.
Deal specifically with Val = 2**(Int'Size - 1) if Minus is not set.
Exit the loop when V saturates to 0 in the case of (huge) negative
exponents.

7 weeks agoada: Tweak special handling of synchronized type scopes
Ronan Desplanques [Wed, 2 Apr 2025 08:48:57 +0000 (10:48 +0200)] 
ada: Tweak special handling of synchronized type scopes

Exp_Util.Insert_Actions handles scopes of synchronized types specially,
but the condition it tested before this patch was not quite correct in
some cases, for example during some expansion operations made under
Expand_N_Task_Type_Declaration. This patch refines the test.

gcc/ada/ChangeLog:

* exp_util.adb (Insert_Actions): Refine test.

7 weeks agoada: Small tweak to latest change
Eric Botcazou [Mon, 31 Mar 2025 22:24:12 +0000 (00:24 +0200)] 
ada: Small tweak to latest change

gcc/ada/ChangeLog:

* doc/gnat_ugn/building_executable_programs_with_gnat.rst (Compiler
switches) <-O>: Fix long line.
* gnat_ugn.texi: Regenerate.

7 weeks agoada: Implement -gnatRh switch to display holes in record layout
Eric Botcazou [Mon, 31 Mar 2025 19:29:27 +0000 (21:29 +0200)] 
ada: Implement -gnatRh switch to display holes in record layout

This implements the new (sub)switch -gnatRh to display holes in the layout
of record types, which are mostly present to fulfill alignment requirements.

gcc/ada/ChangeLog:

* doc/gnat_ugn/building_executable_programs_with_gnat.rst (List of
all switches): Add -gnatRh subswitch.
(Debugging Control): Document -gnatRh subswitch.
* opt.ads (List_Representation_Info_Holes): New boolean variable.
* repinfo.adb: Add with clause for GNAT.Heap_Sort_G.
(List_Common_Type_Info): Relax assertion.
(List_Object_Info): Replace assertion with additional test.
(List_Record_Layout): If -gnatRh is specified, make sure that the
components are ordered by increasing offsets.  Output a comment
line giving the number of unused bits if there is a hole between
consecutive components.  Streamline the control flow of the loop.
(List_Record_Info): Use the original record type giving the layout
of components, if any, to display the layout of the record.
* switch-c.adb (Scan_Front_End_Switches) <-gnatR>: Add support for
-gnatRh subswitch.
* usage.adb (Usage): Document -gnatRh subswitch.
* gnat_ugn.texi: Regenerate.

7 weeks agoada: Adjust alignment calculation for secondary stack
Johannes Kliemann [Tue, 25 Mar 2025 15:20:41 +0000 (15:20 +0000)] 
ada: Adjust alignment calculation for secondary stack

The secondary stack allocator needs to take alignment constraints into
account when doing allocations. In the full runtime the secondary stack
is allocated in chunks on the heap and can grow dynamically. As it does
not grow contiguously the "top" of the stack depends on the size of
the allocation. Therefore the alignment of the stack top is not known at
allocation time and the padding needed for a particular alignment needs
to be calculated conservatively to ensure the allocation fits the
requested size after the base address has been aligned.
On more restricted platforms the secondary stack is a contiguous block
of statically allocated memory. Here the conservative mechanism is not
required since the allocations base address is known and the required
padding can be calculated right away. The conservative approach also
sometimes causes an allocation to be slightly larger than it needs to
be. This can be a problem on platforms with limited RAM availability. To
avoid this problem modify the calculation of the required padding on these
platforms to always exactly fit the required size.

gcc/ada/ChangeLog:

* libgnat/s-secsta.adb (SS_Allocate): Add comment about
conservative alignment padding calculation.
* libgnat/s-secsta__cheri.adb (SS_Allocate): Add comment about
conservative alignment padding calculation.

7 weeks agoada: Rewrite boolean expression
Ronan Desplanques [Mon, 31 Mar 2025 11:44:53 +0000 (13:44 +0200)] 
ada: Rewrite boolean expression

This patch rewrites a boolean expression to make it easier to understand
in its context. It also tweaks the surrounding comments.

gcc/ada/ChangeLog:

* sem_warn.adb (Check_References): Rewrite expression

7 weeks agoada: Remove uses of E_Void
Ronan Desplanques [Fri, 28 Mar 2025 10:22:22 +0000 (11:22 +0100)] 
ada: Remove uses of E_Void

This patch removes various calls on entities that have their entity
kinds set to E_Void, by giving those entities their proper kinds earlier.
This is to prepare for potential new future invariant checks on entities.

gcc/ada/ChangeLog:

* sem_ch3.adb (Constrain_Index, Make_Index, Array_Type_Declaration,
Analyze_Number_Declaration): Remove uses of E_Void.

7 weeks agoada: Document supported GCC optimization switches
Eric Botcazou [Fri, 28 Mar 2025 17:51:23 +0000 (18:51 +0100)] 
ada: Document supported GCC optimization switches

In particular the most recently added ones, namely -Og and -Oz.  But -Ofast
is not documented because it disregards strict compliance with standards.

gcc/ada/ChangeLog:

* usage.adb (Usage): Justify the documentation of common switches
like that of other switches.  Rework that of the -O switch.
* doc/gnat_ugn/building_executable_programs_with_gnat.rst (Compiler
switches) <-O>: Rework and document 'z' and 'g' operands.
* doc/gnat_ugn/gnat_and_program_execution.rst (Optimization Levels):
Rework and document -Oz and -Og switches.
* gnat_ugn.texi: Regenerate.

7 weeks agoada: Remove creation of some unused itypes
Ronan Desplanques [Fri, 28 Mar 2025 11:37:50 +0000 (12:37 +0100)] 
ada: Remove creation of some unused itypes

Before this patch, Constrain_Index always started by creating an itype
but then sometimes not using it for anything. This patch makes it so an
itype is only created when needed.

gcc/ada/ChangeLog:

* sem_ch3.adb (Constrain_Index): Avoid unused itypes.

7 weeks agoada: Factorize return statement
Ronan Desplanques [Fri, 28 Mar 2025 11:58:36 +0000 (12:58 +0100)] 
ada: Factorize return statement

Code cleanup; behavior is unaffected.

gcc/ada/ChangeLog:

* sem_ch3.adb (Constrain_Index): Factorize return statement.

7 weeks agoada: Remove duplicate setter call
Ronan Desplanques [Thu, 27 Mar 2025 13:46:00 +0000 (14:46 +0100)] 
ada: Remove duplicate setter call

gcc/ada/ChangeLog:

* sem_ch3.adb (Build_Derived_Numeric_Type): Remove duplicate call.

7 weeks agoFix test case for PR117811 which failed for int < 32 bit.
Georg-Johann Lay [Thu, 12 Jun 2025 08:07:37 +0000 (10:07 +0200)] 
Fix test case for PR117811 which failed for int < 32 bit.

PR middle-end/117811
PR testsuite/52641
gcc/testsuite/
* gcc.dg/torture/pr117811.c: Fix for int < 32 bit.

7 weeks agoRefactor record_function_versions.
Alfie Richards [Thu, 27 Mar 2025 14:12:06 +0000 (14:12 +0000)] 
Refactor record_function_versions.

Renames record_function_versions to add_function_version, and make it
explicit that it is adding a single version to the function structure.

Additionally, change the insertion point to always maintain priority ordering
of the versions.

This allows for removing logic for moving the default to the first
position which was duplicated across target specific code and enables
easier reasoning about function sets.

gcc/ChangeLog:

* cgraph.cc (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* cgraph.h (cgraph_node::record_function_versions): Refactor and
rename to...
(cgraph_node::add_function_version): new function.
* config/aarch64/aarch64.cc (aarch64_get_function_versions_dispatcher):
Remove reordering.
* config/i386/i386-features.cc (ix86_get_function_versions_dispatcher):
Remove reordering.
* config/riscv/riscv.cc (riscv_get_function_versions_dispatcher):
Remove reordering.
* config/rs6000/rs6000.cc (rs6000_get_function_versions_dispatcher):
Remove reordering.

gcc/cp/ChangeLog:

* decl.cc (maybe_version_functions): Change record_function_versions
call to add_function_version.

7 weeks agoUpdate is_function_default_version to work with target_version.
Alfie Richards [Fri, 31 Jan 2025 10:47:14 +0000 (10:47 +0000)] 
Update is_function_default_version to work with target_version.

Notably this respects target_version semantics where an unannotated
function can be the default version.

gcc/ChangeLog:

* attribs.cc (is_function_default_version): Add target_version logic.

7 weeks agoi386: Set SRF, GRR, CWF, GNR, DMR, ARL and PTL issue rate
Hu, Lin1 [Wed, 14 May 2025 03:36:26 +0000 (11:36 +0800)] 
i386: Set SRF, GRR, CWF, GNR, DMR, ARL and PTL issue rate

Hi,

This patch aims to set SRF issue rate to 4, GNR issue rate to 6. According to
tests about spec2017, the patch has little effect on performance.

For GRR, CWF, DMR, ARL and PTL, the patch set their issue rate to 6. Waiting for
more information to update.

Bootstrapped and regtested on x86_64-linux-pc-gnu, OK for trunk.

BRs,
Lin

gcc/ChangeLog:

* config/i386/x86-tune-sched.cc (ix86_issue_rate): Set 4 for SRF,
6 for GRR, GNR, CWF, DMR, ARL, PTL.