]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 months agolibstdc++: Extend constexpr if to C++14 in _Hashtable::_S_nothrow_move()
Jonathan Wakely [Wed, 8 Oct 2025 14:26:54 +0000 (15:26 +0100)] 
libstdc++: Extend constexpr if to C++14 in _Hashtable::_S_nothrow_move()

We can use diagnostic pragmas to allow the constexpr if version of this
function to be used for C++14 as well. We still need the __and_ version
for C++11 because we can't use 'if' in constexpr functions at all before
C++14.

Also use the integral_constant::value static data member instead of
invoking integral_constant::operator(), as it's a tiny bit cheaper to
compiler.

libstdc++-v3/ChangeLog:

* include/bits/hashtable.h (_Hashtable::_S_nothrow_move): Use
diagnostic pragmas to allow constexpr if in C++14. Use value
member instead of operator().

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agolibstdc++: Tweak comment on generated #endif lines in bits/version.h
Jonathan Wakely [Wed, 8 Oct 2025 11:42:41 +0000 (12:42 +0100)] 
libstdc++: Tweak comment on generated #endif lines in bits/version.h

Make the #endif comment match the #if condition in the generated code.

Also adjust a comment in the Scheme code which describes the logic. The
__glibcxx_NAME macro is not defined _unconditionally_, as it still
depends on the conditions in cxxmin, extra_cond etca,. and the
__cpp_lib_NAME macro now depends on no_stdname too.

libstdc++-v3/ChangeLog:

* include/bits/version.tpl: Fix comment on #endif. Tweak
description of when macros are defined.
* include/bits/version.h: Regenerate.

Reviewed-by: Arsen Arsenović <arsen@aarsen.me>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agotree-ssa-structalias: Put constraint building into its own file
Filip Kastl [Thu, 9 Oct 2025 11:45:17 +0000 (13:45 +0200)] 
tree-ssa-structalias: Put constraint building into its own file

This patch cuts out points-to constraint building from
tree-ssa-structalias.cc and places it into a new file
gimple-ssa-pta-constraints.cc.

The diff of tree-ssa-structalias.cc ended up being messy, so here is a
summary of changes I made that may not be apparent at first glance.
I didn't do any functional changes.  Everything is just shifting
functions and declarations around and giving external linkage to some
things.

- These functions now have external linkage and got shifted to the
  beginning of the file:
determine_global_memory_access
fndecl_maybe_in_other_partition
new_var_info
- The using namespace pointer_analysis directive got shifted to the
  beginning of the file
- Declarations of these global variables got shifted to the beginning of
  the file:
variable_info_pool
final_solutions
final_solutions_obstack
- These global variables got external linkage:
use_field_sensitive
in_ipa_mode

gcc/ChangeLog:

* Makefile.in: Add gimple-ssa-pta-constraints.cc.
* tree-ssa-structalias.cc (determine_global_memory_access):
External linkage, move to namespace pointer_analysis.
(fndecl_maybe_in_other_partition): External linkage, move to
namespace pointer_analysis.
(new_var_info): External linkage, move to namespace
pointer_analysis.
(create_variable_info_for): Move to
gimple-ssa-pta-constraints.cc.
(lookup_vi_for_tree): External linkage, move to namespace
pointer_analysis, move to gimple-ssa-pta-constraints.cc.
(type_can_have_subvars): Move to gimple-ssa-pta-constraints.cc.
(make_param_constraints): Move to gimple-ssa-pta-constraints.cc.
(get_call_vi): Move to gimple-ssa-pta-constraints.cc.
(lookup_call_use_vi): External linkage, move to namespace
pointer_analysis, move to gimple-ssa-pta-constraints.cc.
(lookup_call_clobber_vi): External linkage, move to namespace
pointer_analysis, move to gimple-ssa-pta-constraints.cc.
(get_call_use_vi): Move to gimple-ssa-pta-constraints.cc.
(get_call_clobber_vi): Move to gimple-ssa-pta-constraints.cc.
(get_constraint_for_1): Move to gimple-ssa-pta-constraints.cc.
(get_constraint_for): Move to gimple-ssa-pta-constraints.cc.
(get_constraint_for_rhs): Move to gimple-ssa-pta-constraints.cc.
(do_deref): Move to gimple-ssa-pta-constraints.cc.
(constraint_pool): Move to gimple-ssa-pta-constraints.cc.
(new_constraint): Move to gimple-ssa-pta-constraints.cc.
(insert_vi_for_tree): Move to gimple-ssa-pta-constraints.cc.
(alias_get_name): Move to gimple-ssa-pta-constraints.cc.
(get_vi_for_tree): Move to gimple-ssa-pta-constraints.cc.
(new_scalar_tmp_constraint_exp): Move to
gimple-ssa-pta-constraints.cc.
(get_constraint_for_ssa_var): Move to
gimple-ssa-pta-constraints.cc.
(process_constraint): Move to gimple-ssa-pta-constraints.cc.
(bitpos_of_field): Move to gimple-ssa-pta-constraints.cc.
(get_constraint_for_ptr_offset): Move to
gimple-ssa-pta-constraints.cc.
(get_constraint_for_component_ref): Move to
gimple-ssa-pta-constraints.cc.
(get_constraint_for_address_of): Move to
gimple-ssa-pta-constraints.cc.
(process_all_all_constraints): Move to
gimple-ssa-pta-constraints.cc.
(do_structure_copy): Move to gimple-ssa-pta-constraints.cc.
(make_constraints_to): Move to gimple-ssa-pta-constraints.cc.
(make_constraint_to): Move to gimple-ssa-pta-constraints.cc.
(make_constraint_from): Move to gimple-ssa-pta-constraints.cc.
(make_copy_constraint): Move to gimple-ssa-pta-constraints.cc.
(make_escape_constraint): Move to gimple-ssa-pta-constraints.cc.
(make_indirect_escape_constraint): Move to
gimple-ssa-pta-constraints.cc.
(make_transitive_closure_constraints): Move to
gimple-ssa-pta-constraints.cc.
(make_any_offset_constraints): Move to
gimple-ssa-pta-constraints.cc.
(struct obstack fake_var_decl_obstack): Move to
gimple-ssa-pta-constraints.cc.
(build_fake_var_decl): Move to gimple-ssa-pta-constraints.cc.
(make_heapvar): Move to gimple-ssa-pta-constraints.cc.
(make_constraint_from_restrict): Move to
gimple-ssa-pta-constraints.cc.
(make_constraint_from_global_restrict): Move to
gimple-ssa-pta-constraints.cc.
(get_function_part_constraint): Move to
gimple-ssa-pta-constraints.cc.
(handle_call_arg): Move to gimple-ssa-pta-constraints.cc.
(handle_rhs_call): Move to gimple-ssa-pta-constraints.cc.
(handle_lhs_call): Move to gimple-ssa-pta-constraints.cc.
(get_fi_for_callee): Move to gimple-ssa-pta-constraints.cc.
(find_func_aliases_for_call_arg): Move to
gimple-ssa-pta-constraints.cc.
(find_func_aliases_for_builtin_call): Move to
gimple-ssa-pta-constraints.cc.
(find_func_aliases_for_call): Move to
gimple-ssa-pta-constraints.cc.
(find_func_aliases): Move to gimple-ssa-pta-constraints.cc.
(process_ipa_clobber): Move to gimple-ssa-pta-constraints.cc.
(find_func_clobbers): Move to gimple-ssa-pta-constraints.cc.
(struct fieldoff): Move to gimple-ssa-pta-constraints.cc.
(fieldoff_compare): Move to gimple-ssa-pta-constraints.cc.
(sort_fieldstack): Move to gimple-ssa-pta-constraints.cc.
(var_can_have_subvars): Move to gimple-ssa-pta-constraints.cc.
(type_must_have_pointers): Move to
gimple-ssa-pta-constraints.cc.
(field_must_have_pointers): Move to
gimple-ssa-pta-constraints.cc.
(push_fields_onto_fieldstack): Move to
gimple-ssa-pta-constraints.cc.
(count_num_arguments): Move to gimple-ssa-pta-constraints.cc.
(create_function_info_for): Move to
gimple-ssa-pta-constraints.cc.
(check_for_overlaps): Move to gimple-ssa-pta-constraints.cc.
(create_variable_info_for_1): Move to
gimple-ssa-pta-constraints.cc.
(intra_create_variable_infos): Move to
gimple-ssa-pta-constraints.cc.
(init_base_vars): Move to gimple-ssa-pta-constraints.cc.
(init_constraint_builder): Move to
gimple-ssa-pta-constraints.cc.
(delete_constraint_builder): Move to
gimple-ssa-pta-constraints.cc.
(intra_build_constraints): Move to
gimple-ssa-pta-constraints.cc.
(delete_points_to_sets): Move to gimple-ssa-pta-constraints.cc.
(associate_varinfo_to_alias): Move to
gimple-ssa-pta-constraints.cc
(refered_from_nonlocal_fn): Move to
gimple-ssa-pta-constraints.cc
(refered_from_nonlocal_var): Move to
gimple-ssa-pta-constraints.cc
(ipa_create_function_infos): Move to
gimple-ssa-pta-constraints.cc
(ipa_create_global_variable_infos): Move to
gimple-ssa-pta-constraints.cc
(ipa_build_constraints): Move to gimple-ssa-pta-constraints.cc
* tree-ssa-structalias.h (struct constraint_stats):
(determine_global_memory_access): External linkage, move to
namespace pointer_analysis.
(fndecl_maybe_in_other_partition): External linkage, move to
namespace pointer_analysis.
(new_var_info): External linkage, move to namespace
pointer_analysis.
* gimple-ssa-pta-constraints.cc: New file.
* gimple-ssa-pta-constraints.h: New file.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
2 months agotree-ssa-structalias: Put constraint building into separate functions
Filip Kastl [Thu, 9 Oct 2025 11:42:52 +0000 (13:42 +0200)] 
tree-ssa-structalias: Put constraint building into separate functions

Preparation for splitting out constraint building into a separate source
file.  This patch splits out constraint building from
compute_points_to_sets and ipa_pta_execute into separate functions.
It also moves initializing and cleaning up constraint building stuff
into separate functions.

gcc/ChangeLog:

* tree-ssa-structalias.cc (init_constraint_builder): New
function.
(delete_constraint_builder): New function.
(compute_points_to_sets): Put constraint building into
intra_build_constraints and call it.
(intra_build_constraints): New function.
(delete_points_to_sets): Put cleanup of constraint builder
global vars into delete_constraint_builder and call it.
(ipa_pta_execute): Put constraint building into
ipa_build_constraints and call it.
(ipa_create_function_infos): New function.
(ipa_create_global_variable_infos): New function.
(ipa_build_constraints): New function.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
2 months agolibstdc++: Formatting tests for std::chrono date types.
Tomasz Kamiński [Thu, 9 Oct 2025 09:12:15 +0000 (11:12 +0200)] 
libstdc++: Formatting tests for std::chrono date types.

This covers year_month_day_last, year_month_weekday, year_month_weekday_last.

libstdc++-v3/ChangeLog:

* testsuite/std/time/year_month_day_last/io.cc: New formatting tests.
* testsuite/std/time/year_month_weekday/io.cc: Likewise.
* testsuite/std/time/year_month_weekday_last/io.cc: Likewise.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agoxtensa: constantsynth: Update to version 2
Takayuki 'January June' Suwa [Wed, 8 Oct 2025 01:31:37 +0000 (10:31 +0900)] 
xtensa: constantsynth: Update to version 2

This patch completely replaces the existing "constantsynth" with a new
implementation, which has become unsightly due to the extension.

This new version offers the following benefits:

  - Independence from the insn splitting mechanism.  No define_split
    descriptions are required
  - Resource saving as internally required information storage no longer
    persists across passes
  - The replacement of insns is based on the actual costs (for both size
    and speed) of the insns before and after the conversion, rather than
    on some arbitrary pre-determined ones
  - The replacing insn sequence is verified by formally evaluating the
    RTL expressions to see if it correctly computes the original constant
    value
  - Easy-to-understand/-add interface for constant synthesis methods

The built-in synthesis methods are (supposedly) very effective, with 2
instructions for certain values and up to 5 instructions to cover all
32-bit values.

     /* example */
     _Complex double test(int a[], float b[]) {
       a[0] = 2045 * 2045;
       a[1] = 0xDEADBEEF;
       a[2] = 0xDEADBEEF - 15;
       a[3] = 4182000;
       a[4] = 131071;
       a[5] = 293805;
       a[6] = 700972933;
       a[7] = -372738139;
       b[0] = 3.14159265359f;
       b[1] *= 0.12005615234375f;
       return 1-1i;
     }

     ;; result (-O2 -mextra-l32r-costs=5)
     test:
      entry sp, 32
      movi a8, 0x7af
      float.s f1, a8, 14
      movi a8, 0x7fd
      mull a8, a8, a8
      lsi f0, a3, 4
      s32i.n a8, a2, 0
      movi.n a8, 0x57
      addmi a8, a8, -0x1100
      slli a8, a8, 17
      addmi a8, a8, -0x4100
      addi a8, a8, -17
      s32i.n a8, a2, 4
      addi a8, a8, -15
      s32i.n a8, a2, 8
      movi a8, 0x3fd
      slli a8, a8, 12
      addi a8, a8, -16
      s32i.n a8, a2, 12
      movi.n a8, -1
      srli a8, a8, 15
      s32i.n a8, a2, 16
      movi a8, 0x85
      addmi a8, a8, 0x7f00
      addx8 a8, a8, a8
      s32i.n a8, a2, 20
      movi a8, 0x539
      slli a8, a8, 19
      addi a8, a8, -123
      s32i.n a8, a2, 24
      movi a8, -0x2c7
      slli a8, a8, 19
      addmi a8, a8, 0x7800
      addi a8, a8, -91
      s32i.n a8, a2, 28
      movi.n a8, 0x49
      mul.s f0, f0, f1
      addmi a8, a8, 0x4000
      slli a8, a8, 16
      addmi a8, a8, 0x1000
      addi a8, a8, -37
      s32i.n a8, a3, 0
      ssi f0, a3, 4
      movi a5, -0x401
      movi a3, 0x3ff
      movi.n a2, 0
      slli a3, a3, 20
      movi.n a4, 0
      slli a5, a5, 20
      retw.n

gcc/ChangeLog:

* config/xtensa/xtensa-protos.h (xtensa_constantsynth): Remove.
* config/xtensa/xtensa.cc
(#include): Remove "context.h" and "pass_manager.h".
(machine_function): Remove "litpool_usage" member.
(xtensa_constantsynth_2insn, xtensa_constantsynth_rtx_SLLI,
xtensa_constantsynth_rtx_ADDSUBX, xtensa_constantsynth): Remove.
(constantsynth_method_lshr_m1, split_hwi_to_MOVI_ADDMI,
constantsynth_method_16bits, constantsynth_method_32bits,
constantsynth_method_square): New worker function related to
constant synthesis methods.
(constantsynth_method_info, constantsynth_methods):
New structure representing the list of all constant synthesis
methods.
(constantsynth_info): New structure that stores internal
information for "constantsynth".
(constantsynth_pass1, verify_synth_seq, constantsynth_pass2):
New functions that are the core of "constantsynth".
(do_largeconst): Add a call to constantsynth_pass1() to the insn
enumeration loop, and add a call to constantsynth_pass2() to the
end of this function.
* config/xtensa/xtensa.md (SHI): Remove.
(The two auxiliary define_splits for mov[sh]i_internal): Remove.
(The two auxiliary define_splits for movsf_internal): Remove.

gcc/testsuite/ChangeLog:

* gcc.target/xtensa/constsynth_2insns.c,
gcc.target/xtensa/constsynth_3insns.c,
gcc.target/xtensa/constsynth_double.c: Remove due to outdated.
* gcc.target/xtensa/constsynthV2_O2_costs0.c,
gcc.target/xtensa/constsynthV2_O2_costs5.c,
gcc.target/xtensa/constsynthV2_Os.c: New.

2 months agoxtensa: Change the splitting of D[IF]mode constant assignments to be implemented...
Takayuki 'January June' Suwa [Wed, 8 Oct 2025 01:27:48 +0000 (10:27 +0900)] 
xtensa: Change the splitting of D[IF]mode constant assignments to be implemented in xt_largeconst instead of define_split

This patch moves the process of splitting D[IF]mode constant assignments
into SImode ones from the define_split implementation after reloading to
processing within the "xt_largeconst" target-specific pass.  It also
converts SFmode constant assignments into bit-equivalent SImode ones.

This allows these assignments to be processed by the "constantsynth"
optimization, which will be reimplemented later.

gcc/ChangeLog:

* config/xtensa/xtensa-protos.h
(xtensa_split_DI_reg_imm): Remove.
* config/xtensa/xtensa.cc (xtensa_split_DI_reg_imm): Remove.
(split_DI_SF_DF_const): New worker function.
(do_largeconst): Add a call to split_DI_SF_DF_const() to the insn
enumeration loop.
* config/xtensa/xtensa.md (movdi): Remove split code when the
source is constant.
(movdi_internal): Add a new constraint pair (a, Y) to the second
of the existing constraint alternatives.
(The auxiliary define_split for movdi_internal): Remove.

2 months agoxtensa: Optimize assignment of certain constants to hardware FP registers
Takayuki 'January June' Suwa [Fri, 19 Sep 2025 12:25:10 +0000 (21:25 +0900)] 
xtensa: Optimize assignment of certain constants to hardware FP registers

This patch introduces an optimization that replaces assignments of signed
12-bit integer values divided by 0th through 15th power of two to hardware
FP registers with assignments of that integer values to address (GP)
registers followed by negatively-scaled floating-point conversion
instructions.

For example, 0.12005615234375f is exactly equal to (1967.f / (1 << 14)), so
we can emit such as:

movi a9, 1967
float.s f0, a9, 14

if such conversion reduces costs.

gcc/ChangeLog:

* config/xtensa/xtensa.cc (xt_full_rtx_costs):
New struct, derived from full_rtx_costs.
(FPreg_neg_scaled_simm12b_1, FPreg_neg_scaled_simm12b):
New worker functions.
(do_largeconst): Add a call to FPreg_neg_scaled_simm12b() to the
insn enumeration loop.

2 months agoxtensa: Make large CONST_INT legitimate until the postreload pass
Takayuki 'January June' Suwa [Fri, 19 Sep 2025 12:24:27 +0000 (21:24 +0900)] 
xtensa: Make large CONST_INT legitimate until the postreload pass

Generally, RISC machines only have a limited bit width for integer constant
immediate values, and it is common to implement
TARGET_LEGITIMATE_CONSTANT_P() for their representation.  However, by
making bare CONST_INTs less visible in RTL, some optimizers may miss out
on opportunities.

  - Operands with the nonmemory/immediate_operand() predicates never accept
    constants that TARGET_LEGITIMATE_CONSTANT_P() rejects, so templates
    containing their predicates may unintentionally not be used for insns
    containing such constants during the RTL generation or instruction
    combination passes

  - Some optimizers only accept bare CONST_INTs and may not consider their
    equivalents (such as literal pool entry references) at all
    (Unrelated to this patch, but perhaps even worse, some optimizers such
    as RTL ifcvt, assume that not only the constant format but also the insn
    format is CISC-like)

As a clear example, the effect of constant-anchored optimization during
the postreload pass can be seen by compiling the following with and without
-mconst16 or -mauto-litpools:

     /* example */
     void test(int a[4]) {
       a[0] = 0xDEADFACE;
       a[1] = 0xDEADFACE - 1;
       a[2] = 0xDEADFACE - 2;
       a[3] = 0xDEADFACE + 254;
     }

     ;; without -mauto-litpools
      .literal_position
      .literal .LC0, -559023410
      .literal .LC1, -559023411
      .literal .LC2, -559023412
      .literal .LC3, -559023156
     test:
      entry sp, 32
      l32r a8, .LC0
      s32i.n a8, a2, 0
      l32r a8, .LC1
      s32i.n a8, a2, 4
      l32r a8, .LC2
      s32i.n a8, a2, 8
      l32r a8, .LC3
      s32i.n a8, a2, 12
      retw.n

     ;; with -mauto-litpools
     test:
      entry sp, 32
      movi a8, -559023410
      s32i.n a8, a2, 0
      addi.n a8, a8, -1 ;; const-anchored
      s32i.n a8, a2, 4
      addi.n a8, a8, -1 ;; const-anchored
      s32i.n a8, a2, 8
      addmi a8, a8, 0x100 :: const-anchored
      s32i.n a8, a2, 12
      retw.n

Therefore, we aim to overcome the above obstacles by introducing a tweak
that legitimates a full-bitwidth CONST_INT regardless of other conditions
until a specific RTL path is reached.  Then, the most appropriate point
to switch the behavior of TARGET_LEGITIMATE_CONSTANT_P() would probably
be just before reload/LRA, but as mentioned earlier, there is an optimizer
that should be utilized in postreload, so the switchover point will be
just after that.

This patch introduces a new target-specific pass called "xt_largeconst"
to implement all of the above, which will also serves as a host for other
future optimizers related to large constants, such as "constantsynth".
As a result, this patch also resolves some of the issues mentioned in the
previous patch notes:

  - B[GE/LT]U branch instructions with immediate values of 32768 or 65536
    cannot be emitted
  - Insn combination templates matching the CLAMPS instruction cannot be
    matched against large upper and lower bounds

gcc/ChangeLog:

* config/xtensa/constraints.md (Y):
Change to reference xtensa_postreload_completed_p() instead of
xtensa_split1_finished_p().
* config/xtensa/predicates.md (move_operand): Ditto.
* config/xtensa/t-xtensa (PASSES_EXTRA):
Add xtensa-passes.def as target-specific pass description.
* config/xtensa/xtensa-passes.def:
New definition file that inserts pass_xtensa_largeconst after
pass_postreload_cse.
* config/xtensa/xtensa-protos.h (xtensa_split1_finished_p): Remove.
(xtensa_postreload_completed_p, make_pass_xtensa_largeconst):
New function prototypes.
* config/xtensa/xtensa.cc (machine_function):
Add a new member "postreload_completed".
(xtensa_emit_move_sequence):
Change to reference xtensa_postreload_completed_p() instead of
can_create_pseudo_p().
(xtensa_split1_finished_p): Remove.
(xtensa_postreload_completed_p): New function.
(xtensa_legitimate_constant_p): Change to also consider
xtensa_postreload_completed_p().
(litpool_set_src_1, litpool_set_src, do_largeconst,
rest_of_handle_largeconst):
New sub-functions for pass_xtensa_largeconst.
(pass_data_xtensa_largeconst, pass_xtensa_largeconst):
New target-specific pass definition.
(make_pass_xtensa_largeconst):
New function called by the pass manager.
* config/xtensa/xtensa.md
(The auxiliary define_split for movdi_internal):
Change to reference xtensa_postreload_completed_p() instead of
xtensa_split1_finished_p().
(The first of three auxiliary define_splits for mov[sh]i_internal):
Remove.

gcc/testsuite/ChangeLog:

* gcc.target/xtensa/BGEUI-BLTUI-32k-64k.c:
Disable optimizations and modify to also verify RTL dump in the
"expand" pass.

2 months agoxtensa: Implement TARGET_MD_ASM_ADJUST
Takayuki 'January June' Suwa [Fri, 19 Sep 2025 12:23:51 +0000 (21:23 +0900)] 
xtensa: Implement TARGET_MD_ASM_ADJUST

The behavior of the 'g'-constraint on asm statement operands does not
strictly match that described in the GCC User Manual:

   "'g'  Any register, memory, or immediate integer operand is allowed,
    except for registers that are not general registers."

   -- 6.12.3.1 Simple Constraints, Using the GCC (the latest)

Contrary to the quote above, the following example will produce different
results depending on whether TARGET_CONST16 or TARGET_AUTO_LITPOOLS is
enabled:

     /* example */
     void test(void) {
       asm volatile ("# %0"::"g"(65536));
     }

     ;; TARGET_CONST16 || TARGET_AUTO_LITPOOLS
     test:
      entry sp, 32
      # 65536
      retw.n

     ;; !TARGET_CONST16 && !TARGET_AUTO_LITPOOLS
      .literal_position
      .literal .LC0, 65536
     test:
      entry sp, 32
      # .LC0
      retw.n

Indeed, both of the above results satisfy the constraint, but the latter
is not an "any" constant as stated in the manual, and is therefore incon-
sistent with the former.

This is because the behavior of the 'g'-constraint on constants depends
on the general_operand() predicate, and essentially on
TARGET_LEGITIMATE_CONSTANT_P().

This patch resolves that inconsistency by adding an 'n'-constraint imme-
diately before every occurrence of 'g' in each constraint string during
the RTL generation pass, to prioritize being an integer constant for the
alternative to which 'g' belongs.

gcc/ChangeLog:

* config/xtensa/xtensa.cc
(TARGET_MD_ASM_ADJUST): New macro definition.
(xtensa_md_asm_adjust): New function prototype and definition, that
prepends all 'g'-constraints in the "constraints" vector with 'n',
if neither TARGET_CONST16 nor TARGET_AUTO_LITPOOLS is enabled.

2 months agotree-optimization/122212 - fix CLZ detection
Richard Biener [Thu, 9 Oct 2025 07:06:27 +0000 (09:06 +0200)] 
tree-optimization/122212 - fix CLZ detection

The following corrects a mistake with the zero value handling which
was broken because the bits bias was applied first which works
for the special-case using a bit-and but not when using a conditional
move.  Apply this after the fact instead where it also more easily
folds with an existing bias we compensate.

PR tree-optimization/122212
* tree-ssa-forwprop.cc (simplify_count_zeroes): Apply
bias for CLZ after dealing with the zero special value.

* gcc.dg/torture/pr122212.c: New testcase.

2 months agoAVR: target/122210 - Add double -> fixed-point conversions.
Georg-Johann Lay [Wed, 8 Oct 2025 18:02:53 +0000 (20:02 +0200)] 
AVR: target/122210 - Add double -> fixed-point conversions.

PR target/122210
libgcc/config/avr/libf7/
* libf7-common.mk (F7_ASM_PARTS): Add D2<fx> modules.
* libf7-asm.sx: Implement the D2<fx> modules.

gcc/testsuite/
* gcc.target/avr/dtofx.c: New test.

2 months agoAVR: target/122210 - Add fixed-point -> double conversions.
Georg-Johann Lay [Wed, 8 Oct 2025 18:02:53 +0000 (20:02 +0200)] 
AVR: target/122210 - Add fixed-point -> double conversions.

PR target/122210
libgcc/config/avr/libf7/
* libf7-common.mk (F7_ASM_PARTS): Add <fx>2D modules.
* libf7-asm.sx: Implement the <fx>2D modules.

gcc/testsuite/
* gcc.target/avr/fxtod.c: New test.

2 months agoRISC-V: Allow VLS types using up to LMUL 8
Kito Cheng [Mon, 1 Sep 2025 10:29:53 +0000 (18:29 +0800)] 
RISC-V: Allow VLS types using up to LMUL 8

We used to apply -mrvv-max-lmul= to limit VLS code gen, auto vectorizer,
and builtin string function expansion. But I think the VLS code gen part doesn't
need this limit, since it only happens when the user explicitly writes vector
types.

For example, int32x8_t under -mrvv-max-lmul=m1 with VLEN=128 would be split into
two int32x4_t, which generate more instructions and runs slower.

In this patch, I changed -mrvv-max-lmul= to only affect auto vectorization and
builtin string function expansion. Actually, the option's help text already
says it only controls the LMUL used by auto-vectorization, so I believe this
change is makes sense :)

Changes since v1:
- Add testase to make sure auto vectorizer is still constrained by
  -mrvv-max-lmul=.

gcc/ChangeLog:

* config/riscv/riscv-protos.h (vls_mode_valid_p): New argument
allow_up_to_lmul_8.
* config/riscv/riscv-v.cc (autovectorize_vector_modes): Set
allow_up_to_lmul_8 to false.
(vls_mode_valid_p): Add new argument allow_up_to_lmul_8, and use
it to determine whether to allow LMUL 8.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/vls-type-rvv-max-lmul.c: New test.
* gcc.target/riscv/rvv/vls-type-rvv-max-lmul-autovec.c: New
test.

2 months agoPR81358: Enable automatic linking of libatomic.
Prathamesh Kulkarni [Thu, 9 Oct 2025 07:07:24 +0000 (07:07 +0000)] 
PR81358: Enable automatic linking of libatomic.

ChangeLog:
PR driver/81358
* Makefile.def: Add no_atomic=true for libraries that don't depend on
libatomic.
* Makefile.tpl: Export TARGET_CONFIGDIRS and create rule to
add dependencies for libatomic.
* configure.ac: Add libatomic to bootstrap_target_libs.
* Makefile.in: Regenerate.
* configure: Regenerate.

gcc/ChangeLog:
PR driver/81358
* common.opt: New option -flink-libatomic.
* gcc.cc (LINK_LIBATOMIC_SPEC): New macro.
* config/alpha/linux.h (LINK_GCC_C_SEQUENCE_SPEC): Use LINK_LIBATOMIC_SPEC.
* config/arm/uclinux-elf.h: Likewise.
* config/arm/unknown-elf.h: Likewise.
* config/avr/avrlibc.h: Likewise.
* config/bfin/linux.h: Likewise.
* config/darwin.h: Likewise.
* config/gnu-user.h: Likewise.
* config/lm32/uclinux-elf.h: Likewise.
* config/rs6000/linux64.h: Likewise.
* config/rs6000/rtems.h: Likewise.
* config/sparc/sparc.h: Likewise.
* doc/invoke.texi: Document -flink-libatomic.
* configure.ac: Define TARGET_PROVIDES_LIBATOMIC.
* configure: Regenerate.
* config.in: Regenerate.
* common.opt.urls: Regenerate.

libatomic/ChangeLog:
PR driver/81358
* Makefile.am: Pass -fno-link-libatomic.
New rule all-local.
* configure.ac: Assert that CFLAGS is set and pass -fno-link-libatomic.
Use __libatomic_save_CFLAGS__ instead of save_CFLAGS.
* Makefile.in: Regenerate.
* configure: Regenerate.

Signed-off-by: Prathamesh Kulkarni <prathameshk@nvidia.com>
Co-authored-by: Matthew Malcolmson <mmalcolmson@nvidia.com>
2 months agovect: Remove type from misalignment hook.
Robin Dapp [Thu, 11 Sep 2025 13:20:36 +0000 (15:20 +0200)] 
vect: Remove type from misalignment hook.

This patch removes the type argument from the vector_misalignment hook.
Ever since we switched from element to byte misalignment its
semantics haven't been particularly clear and nowadays it should be
redundant.

Also, in case of gather/scatter, the patch sets misalignment to the
misalignment of one unit of the vector mode so targets can
distinguish between element size alignment and element mode alignment.

is_packed is now always set, regardless of misalignment.

gcc/ChangeLog:

* config/aarch64/aarch64.cc (aarch64_builtin_support_vector_misalignment):
Remove type.
* config/arm/arm.cc (arm_builtin_support_vector_misalignment):
Ditto.
* config/epiphany/epiphany.cc (epiphany_support_vector_misalignment):
Ditto.
* config/gcn/gcn.cc (gcn_vectorize_support_vector_misalignment):
Ditto.
* config/loongarch/loongarch.cc (loongarch_builtin_support_vector_misalignment):
Ditto.
* config/riscv/riscv.cc (riscv_support_vector_misalignment):
Ditto.
* config/rs6000/rs6000.cc (rs6000_builtin_support_vector_misalignment):
Ditto.
* config/s390/s390.cc (s390_support_vector_misalignment):
Ditto.
* doc/tm.texi: Adjust vector misalignment docs.
* target.def: Ditto.
* targhooks.cc (default_builtin_support_vector_misalignment):
Remove type.
* targhooks.h (default_builtin_support_vector_misalignment):
Ditto.
* tree-vect-data-refs.cc (vect_can_force_dr_alignment_p):
Set misalignment for gather/scatter and remove type.
(vect_supportable_dr_alignment): Ditto.

2 months agodoc: type-punning through a union is a GNU extension for C++
Sam James [Thu, 9 Oct 2025 02:40:58 +0000 (03:40 +0100)] 
doc: type-punning through a union is a GNU extension for C++

We didn't explicitly say that type-punning through a union is undefined
behavior in C++. Mention that, and that we support it as a GNU extension.

This was reported on LLVM's Discourse (forums) [0].

[0] https://discourse.llvm.org/t/ub-when-type-punning-through-unions/88527/6

gcc/ChangeLog:
PR c++/117219

* doc/invoke.texi (-fstrict-aliasing): Explain that type-punning
through a union in C++ is supported as a GNU extension.

2 months agodoc: fix grammar nit
Sam James [Thu, 9 Oct 2025 02:38:06 +0000 (03:38 +0100)] 
doc: fix grammar nit

gcc/ChangeLog:

* doc/invoke.texi: Add missing full stop.

2 months agodoc: mention -Wmaybe-uninitialized vs CCP
Sam James [Tue, 7 Oct 2025 00:51:55 +0000 (01:51 +0100)] 
doc: mention -Wmaybe-uninitialized vs CCP

CCP interacts poorly with -Wmaybe-uninitialized in some cases by assuming a value
which stops us warning about it (false negatives). Inform users about this
infamous interaction.

gcc/ChangeLog:
PR tree-optimization/18501

* doc/invoke.texi (-Wmaybe-uninitialized): Mention interaction with
CCP.

2 months agoDaily bump.
GCC Administrator [Thu, 9 Oct 2025 00:21:21 +0000 (00:21 +0000)] 
Daily bump.

2 months agoc: Implement C23 rules for undefined static functions in _Generic
Joseph Myers [Wed, 8 Oct 2025 23:12:11 +0000 (23:12 +0000)] 
c: Implement C23 rules for undefined static functions in _Generic

A fairly late change in C23, the resolution of CD2 ballot comments
US-077 and US-078, added certain locations in _Generic to the
obviously unevaluated locations where it is permitted to have a
reference to a static function that is never defined.

Implement this feature in GCC.  The main complication is that, unlike
previous cases where it's known at the end of an operand to a
construct such as sizeof whether that operand is obviously unevaluated
and so an appropriate argument can be passed to pop_maybe_used, in the
case of a default generic association in _Generic it may not be known
until the end of that _Generic expression whether that case is
evaluated or not.  Thus, we arrange for the state of the
maybe_used_decls stack to be saved in this case and later restored
once the correct argument to pop_maybe_used is known.

There may well be further changes in this area in C2y (if the
"discarded" proposal is adopted, further locations will be OK for such
references to undefined static functions).  For now, only expressions
and not type names in _Generic have this special treatment.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/c/
* c-typeck.cc (in_generic, save_maybe_used, restore_maybe_used):
New.
(mark_decl_used, record_maybe_used_decl, pop_maybe_used): Use
in_generic.
(struct maybe_used_decl): Move to c-tree.h.
* c-tree.h (struct maybe_used_decl): Move from c-typeck.cc.
(in_generic, save_maybe_used, restore_maybe_used): Declare.
* c-parser.cc (c_parser_generic_selection): Increment and
decrement in_generic.  Use pop_maybe_used, save_maybe_used and
restore_maybe_used.

gcc/testsuite/
* gcc.dg/c11-generic-4.c, gcc.dg/c23-generic-5.c,
gcc.dg/c2y-generic-5.c: New tests.

2 months agoFortran: fix warnings for symbols with C binding and declared PRIVATE [PR49111]
Harald Anlauf [Tue, 7 Oct 2025 19:54:45 +0000 (21:54 +0200)] 
Fortran: fix warnings for symbols with C binding and declared PRIVATE [PR49111]

The Fortran standard does not prohibit restricting the accessibility of a
symbol by use of the PRIVATE attribute and exposing it via a C binding
label.  Instead of unconditionally generating a warning, only warn if the
binding label is surprisingly identical to the privatized Fortran symbol
and when -Wsurprising is specified.

PR fortran/49111

gcc/fortran/ChangeLog:

* decl.cc (verify_bind_c_sym): Modify condition for generation of
accessibility warning, and adjust warning message.

gcc/testsuite/ChangeLog:

* gfortran.dg/binding_label_tests_9.f03: Adjust test.
* gfortran.dg/module_private_2.f90: Likewise.
* gfortran.dg/public_private_module_2.f90: Likewise.
* gfortran.dg/binding_label_tests_35.f90: New test.

2 months agoc: Allow variably-modified types in generic associations for C2Y
Martin Uecker [Sat, 30 Aug 2025 17:05:05 +0000 (19:05 +0200)] 
c: Allow variably-modified types in generic associations for C2Y

This implements part of N3348 to allow variably-modified types in
generic associations in C2Y and making it a pedantic warning before.
Allowing star * is not yet implemented.

gcc/c/ChangeLog:
* c-parser.cc (c_parser_generic_selection): Change
error_at to pedwarn_c23.

gcc/testsuite/ChangeLog:
* gcc.dg/c11-generic-2.c: Adapt error message.
* gcc.dg/c2y-generic-3.c: Adapt test.
* gcc.dg/c2y-generic-4.c: New test.

2 months agolibstdc++: Update dead links to PSTL upstream in docs
Jonathan Wakely [Wed, 8 Oct 2025 11:41:16 +0000 (12:41 +0100)] 
libstdc++: Update dead links to PSTL upstream in docs

The pstl code has been removed from the llvm repo so point to the Intel
upstream project where it really originates from.

libstdc++-v3/ChangeLog:

* doc/xml/manual/status_cxx2017.xml: Replace broken link to PSTL
upstream.
* doc/xml/manual/status_cxx2020.xml: Likewise.
* doc/html/manual/status.html: Regenerate.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agolibstdc++: Remove unused config/cpu/i486/atomicity.h file
Jonathan Wakely [Tue, 7 Oct 2025 14:06:43 +0000 (15:06 +0100)] 
libstdc++: Remove unused config/cpu/i486/atomicity.h file

This file is no longer used, because we always use the definitions in
config/cpu/generic/atomicity_builtins/atomicity.h now.

libstdc++-v3/ChangeLog:

* config/cpu/i486/atomicity.h: Removed.

Reviewed-by: Uros Bizjak <ubizjak@gmail.com>
2 months agolibstdc++: Remove unused config/cpu/cris/atomicity.h file [PR122172]
Jonathan Wakely [Tue, 7 Oct 2025 14:06:43 +0000 (15:06 +0100)] 
libstdc++: Remove unused config/cpu/cris/atomicity.h file [PR122172]

This file is no longer used, because we always use the definitions in
config/cpu/generic/atomicity_builtins/atomicity.h now.

H-P confirmed that the code generated by __atomic_fetch_add is fine and
we don't need the handwritten assembly.

libstdc++-v3/ChangeLog:

PR libstdc++/122172
* config/cpu/cris/atomicity.h: Removed.

Reviewed-by: Hans-Peter Nilsson <hp@axis.com>
2 months agolibstdc++: Fix allocator propagation and tests for std::indirect and std::polymorphic
Jonathan Wakely [Wed, 1 Oct 2025 11:45:17 +0000 (12:45 +0100)] 
libstdc++: Fix allocator propagation and tests for std::indirect and std::polymorphic

I noticed that several tests were doing:

static_assert([] { /* ... */; return true; });

i.e. just testing a lambda, not invoking it and testing the result. This
change fixes that, so that all the lambdas are invoked.

After fixing that, most of the tests failed because they were using
__gnu_test::tracker_allocator or std::scoped_allocator_adaptor in
constexpr functions. The tracker_allocator modifies global state, so can
never be constexpr, and none of std::scoped_allocator_adaptor's members
are marked constexpr.

This change makes __gnu_test::uneq_allocator and
__gnu_test::propagating_allocator usable in constant expressions, which
allows some of the tests which can't be constexpr to be duplicated to
new functions which use uneq_allocator or propagating_allocator instead
of tracker_allocator. This new functions can be tested with the
static_assert calling a lambda.

In some cases none of the tests could be adapted to be constexpr, so the
static_assert and lambda were just removed.

Two changes were also needed for the actual library code, because the
move assignment operators for std::indirect and std::polymorphic were
using copy-assignment on the allocator. Although the semantics of
move-assignment for allocators should be equivalent to copy-assignment,
an allocator isn't actually required to support copy-assignment unless
propagate_on_container_copy_assignment is true. So we have to use
move-assignment for propagate_on_container_move_assignment cases.

libstdc++-v3/ChangeLog:

* include/bits/indirect.h (indirect::operator=(indirect&&)):
Move assign allocator when POCMA is true.
(polymorphic::operator=(polymorphic&&)): Likewise.
* testsuite/std/memory/indirect/copy.cc: Remove constexpr from
functions that use tracker_allocator. Add test_constexpr().
* testsuite/std/memory/indirect/copy_alloc.cc: Remove constexpr
from all functions and remove static_assert.
* testsuite/std/memory/indirect/ctor.cc: Do not use
scoped_allocator_adaptor during constant evaluation.
* testsuite/std/memory/indirect/move.cc: Remove constexpr from
functions that use tracker_allocator. Add test_constexpr().
* testsuite/std/memory/indirect/move_alloc.cc: Remove constexpr
from all functions and remove static_assert.
* testsuite/std/memory/indirect/relops.cc: Invoke lambda in
static_assert.
* testsuite/std/memory/polymorphic/copy.cc: Remove constexpr
from functions that use tracker_allocator. Add test_constexpr().
* testsuite/std/memory/polymorphic/copy_alloc.cc: Remove
constexpr from all functions and remove static_assert.
* testsuite/std/memory/polymorphic/ctor.cc: Do not use
scoped_allocator_adaptor during constant evaluation.
* testsuite/std/memory/polymorphic/ctor_poly.cc: Likewise.
* testsuite/std/memory/polymorphic/move.cc: Remove constexpr
from functions that use tracker_allocator. Add test_constexpr().
* testsuite/std/memory/polymorphic/move_alloc.cc: Remove
constexpr from all functions and remove static_assert.
* testsuite/util/testsuite_allocator.h (tracker_allocator):
Remove redundant 'inline' from friend.
(uneq_allocator): Make all functions constexpr.
(uneq_allocator::base, uneq_allocator::swap_base): Remove.
(uneq_allocator::~uneq_allocator): Remove.
(uneq_allocator::allocate, uneq_allocator::deallocate): Do not
use map of allocations during constant evaluation.
(propagating_allocator): Make all functions constexpr.
(propagating_allocator::base): Remove.
(propagating_allocator::swap_base): Simplify.
(ExplicitConsAlloc, CustomPointerAlloc, NullablePointer): Add
constexpr to all functions.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agoUpdate to Unicode 17.0.0
Jakub Jelinek [Wed, 8 Oct 2025 15:54:11 +0000 (17:54 +0200)] 
Update to Unicode 17.0.0

The following patch updates GCC from Unicode 16.0.0 to 17.0.0.

I've followed what the README says and updated also one script from
glibc, but that needed another Unicode file - HangulSyllableType.txt -
around as well, so I'm adding it.
I've added one new test to named-universal-char-escape-1.c for
randomly chosen character from new CJK block.
Note, Unicode 17.0.0 authors forgot to adjust the 4-8 table, I've filed
bugreports about that but the UnicodeData.txt changes for the range ends
and the new range seems to match e.g. what is in the glyph tables, so
the patch follows UnicodeData.txt and not 4-8 table here.

Another thing was that makeuname2c.cc didn't handle correctly when
the size of the generated string table modulo 77 was 76 or 77, in which
case it forgot to emit a semicolon after the string literal and so failed
to compile.

And as can be seen in the emoji-data.txt diff, some properties like
Extended_Pictographic have been removed from certain characters, e.g.
from the Mahjong cards characters except U+1F004, and one libstdc++
test was testing that property exactly on U+1F000.  Dunno why that was
changed, but U+1F004 is the only colored one among tons of black and white
ones.

2025-10-08  Jakub Jelinek  <jakub@redhat.com>

contrib/
* unicode/README: Add HangulSyllableType.txt file to the
list as newest utf8_gen.py from glibc now needs it.  Adjust
git commit hash and change unicode 16 version to 17.
* unicode/from_glibc/utf8_gen.py: Updated from glibc.
* unicode/DerivedCoreProperties.txt: Updated from Unicode 17.0.0.
* unicode/emoji-data.txt: Likewise.
* unicode/PropList.txt: Likewise.
* unicode/GraphemeBreakProperty.txt: Likewise.
* unicode/DerivedNormalizationProps.txt: Likewise.
* unicode/NameAliases.txt: Likewise.
* unicode/UnicodeData.txt: Likewise.
* unicode/EastAsianWidth.txt: Likewise.
* unicode/DerivedGeneralCategory.txt: Likewise.
* unicode/HangulSyllableType.txt: New file.
gcc/testsuite/
* c-c++-common/cpp/named-universal-char-escape-1.c: Add test for
\N{CJK UNIFIED IDEOGRAPH-3340E}.
libcpp/
* makeucnid.cc (write_copyright): Adjust copyright year.
* makeuname2c.cc (generated_ranges): Adjust end points for a couple
of ranges based on UnicodeData.txt Last changes and add a whole new
CJK UNIFIED IDEOGRAPH- entry.  None of these changes are in the 4-8
table, but clearly it has just been forgotten.
(write_copyright): Adjust copyright year.
(write_dict): Fix up condition when to print semicolon.
* generated_cpp_wcwidth.h: Regenerate.
* ucnid.h: Regenerate.
* uname2c.h: Regenerate.
libstdc++-v3/
* include/bits/unicode-data.h: Regenerate.
* testsuite/ext/unicode/properties.cc: Test __is_extended_pictographic
on U+1F004 rather than U+1F000.

2 months agoc++: clobber non-placement new
Jason Merrill [Wed, 8 Oct 2025 15:09:49 +0000 (16:09 +0100)] 
c++: clobber non-placement new

And also add the clobber for non-placement new.

For now let's limit the clobber of an array with non-constant bound to
placement new in constant evaluation, where we need it to set the active
member of a union.

And catch some additional cases of there being no actual data to clobber.

This changes the diagnostics in a couple of analyzer tests, but the new
diagnostics are also valid.

It also adds some -Wuninitialized warnings which seem like an improvement;
the lines that now warn about an uninitialized vptr are correct, since
trying to assign to a member of a virtual base reads the vptr of an object
that was never created.

gcc/cp/ChangeLog:

* init.cc (build_new_1): Also clobber for non-placement new.
Only loop clobber in constexpr.
* expr.cc (wrap_with_if_consteval): New.
* cp-tree.h (wrap_with_if_consteval): Declare.

gcc/testsuite/ChangeLog:

* g++.dg/analyzer/new-2.C: Adjust diags.
* g++.dg/analyzer/noexcept-new.C: Adjust diags.
* g++.dg/warn/Warray-bounds-23.C: Add warnings.
* g++.dg/warn/Warray-bounds-24.C: Add warnings.
* g++.dg/cpp26/constexpr-new4a.C: New test.

2 months agoRegenerate gcc/configure
Antoni Boucher [Wed, 8 Oct 2025 13:49:13 +0000 (09:49 -0400)] 
Regenerate gcc/configure

Use autoconf 2.69 to regenerate gcc/configure

gcc/ChangeLog:

* configure: Regenerate.

2 months agolibstdc++: Fix type in computation of _M_weekday_index.
Tomasz Kamiński [Wed, 8 Oct 2025 13:14:04 +0000 (15:14 +0200)] 
libstdc++: Fix type in computation of _M_weekday_index.

The value should use divide instead of modulo, as given 1st of month
being weekday X (Mon, Tue, ...), 01 is always X[1], 08 is X[2], e.t.c.

This values is currently not observable, as there is no user-accessible
format specifier that will print it, however it may be exposed in future.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (_ChronoData::_M_fill_day): Replace
'%' by '/'.

2 months agox86-64: mingw: Pass and return _Float16 in vector registers [PR115054]
Trevor Gross [Sun, 14 Sep 2025 00:50:21 +0000 (19:50 -0500)] 
x86-64: mingw: Pass and return _Float16 in vector registers [PR115054]

For MinGW on x86-64, GCC currently passes and returns `_Float16` in
GPRs. Microsoft does not specify an ABI for the type so this is purely
an extension; however, there are a few reasons the current ABI is not
ideal:

1. `float` and `double` are both passed and returned in xmm registers
   under the MSVC ABI, there isn't any reason for `_Float16` to deviate.
2. `_Float16` is returned in xmm0 on Windows x86-32 by both GCC and
   Clang.
3. There is a platform-natural ABI with AVX512-FP16, which requires
   half-precision operands to be in vector registers.
4. System V uses vector registers for `_Float16`.

Thus, update the `HFmode` ABI to both pass and return in vector
registers, meaning its ABI is now identical to `float` and `double`.
This is already Clang's behavior on both its x64 MSVC and MinGW targets,
so the change here also resolves an ABI incompatibility (originally
reported in linked issue).

The results can be verified by evaluating the change in assembly output
with this source:

    void pass_f16(_Float16 x, _Float16 *dst) {
        *dst = x;
    }

    void callee_f16(_Float16);
    void call_f16() {
        callee_f16(1.0);
    }

    _Float16 ret_f16(_Float16 *x) {
        return *x;
    }

    /* Check libcall ABI */

    void extend_f16(_Float16 *x, _Float32 *dst) {
        *dst = (_Float32)*x;
    }

    void trunc_f16(_Float32 *x, _Float16 *dst) {
        *dst = (_Float16)*x;
    }

    /* Float varargs should be in vregs with a zeroed shadow GPR */

    void va(_Float16, ...);
    void va_f16() {
        va(1.0f16, 2.0f16, 3.0f16, 4.0f16, 5.0f16);
    }

While modifying the `function_value_ms_64` `switch` statement, a
redundant condition and trailing whitespace in the 16-byte case is
cleaned up.

2025-09-13  Trevor Gross  <tmgross@umich.edu>

gcc:
PR target/115054
* config/i386/i386.cc (function_arg_ms_64,
function_value_ms_64): Pass and return _Float16 in vector
registers on Windows.

Signed-off-by: Trevor Gross <tmgross@umich.edu>
Signed-off-by: Jonathan Yong <10walls@gmail.com>
2 months agolibstdc++: Add missing include to std/time/format/format.cc
Jonathan Wakely [Wed, 8 Oct 2025 09:14:27 +0000 (10:14 +0100)] 
libstdc++: Add missing include to std/time/format/format.cc

libstdc++-v3/ChangeLog:

* testsuite/std/time/format/format.cc: Include <vector>.

2 months agoAdd boolean pattern for bitwise ops
Richard Biener [Tue, 7 Oct 2025 13:38:57 +0000 (15:38 +0200)] 
Add boolean pattern for bitwise ops

As we consider bitwise operations possible mask operations we have
to consider the case of only one operand arriving as mask.  The
following compensates for this by creating mask from the other operand
and insert possibly required mask conversions.

PR tree-optimization/110223
PR tree-optimization/122128
* tree-vect-patterns.cc (vect_recog_bool_pattern): Add
compensation for mixed mask/data bitwise operations.

* gcc.dg/vect/vect-bool-2.c: New testcase.
* gcc.dg/vect/vect-bool-cmp-3.c: Likewise.
* gcc.dg/vect/vect-bool-cmp-4.c: Likewise.

2 months agoCheck non-strictly vect_internal_def internal defs in integer_type_for_mask
Richard Biener [Wed, 8 Oct 2025 07:19:50 +0000 (09:19 +0200)] 
Check non-strictly vect_internal_def internal defs in integer_type_for_mask

We are missing masks produced by inductions or reductions otherwise.

* tree-vect-patterns.cc (integer_type_for_mask): Only
reject vect_external_defs.

2 months agoAdjust g++.dg/vect/pr64410.cc scan
Richard Biener [Wed, 8 Oct 2025 09:50:14 +0000 (11:50 +0200)] 
Adjust g++.dg/vect/pr64410.cc scan

We are now vectorizing more loops in standard library functions.
Restrict the dump scan to the loop we're interested in.

PR testsuite/120100
* g++.dg/vect/pr64410.cc: Adjust.

2 months agolibstdc++: Implement submdspan_mapping_result. [PR110352]
Luc Grosheintz [Thu, 2 Oct 2025 09:27:16 +0000 (11:27 +0200)] 
libstdc++: Implement submdspan_mapping_result. [PR110352]

Implement the class submdspan_mapping_result and add it to the std
module.

PR libstdc++/110352

libstdc++-v3/ChangeLog:

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

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
2 months agolibstdc++: Implement full_extent_t. [PR110352]
Luc Grosheintz [Thu, 2 Oct 2025 09:27:15 +0000 (11:27 +0200)] 
libstdc++: Implement full_extent_t. [PR110352]

Add the class and updates the std module.

PR libstdc++/110352

libstdc++-v3/ChangeLog:

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

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
2 months agolibstdc++: Implement strided_slice from <mdspan>. [PR110352]
Luc Grosheintz [Thu, 2 Oct 2025 09:27:14 +0000 (11:27 +0200)] 
libstdc++: Implement strided_slice from <mdspan>. [PR110352]

Adds strided_slice as standardized in N5014. Also creates
the internal feature testing macro for submdspan.

PR libstdc++/110352

libstdc++-v3/ChangeLog:

* include/bits/version.def (submdspan): New internal macro.
* include/bits/version.h: Regenerate.
* include/std/mdspan (strided_slice): New class.
* src/c++23/std.cc.in (strided_slice): Add.
* testsuite/23_containers/mdspan/submdspan/strided_slice.cc: New test.
* testsuite/23_containers/mdspan/submdspan/strided_slice_neg.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
2 months agolibstdc++: Improve and cleanup mdspan related code.
Luc Grosheintz [Tue, 30 Sep 2025 10:55:18 +0000 (12:55 +0200)] 
libstdc++: Improve and cleanup mdspan related code.

The improvement is that in __index_type_cast, we don't need to check at
runtime if we know that _IndexType is smaller than _OIndexType.

The cleanup is whitespace (overlength lines) in <mdspan>, grouping is_always_foo
and is_foo together, and de-uglifying a variable in test code.

libstdc++-v3/ChangeLog:

* include/std/mdspan (__mdspan::__index_type_cast): Optimize by
skipping a __glibcxx_assert if it's know at compile-time.
(std::layout_left_padded, std::layout_righ_padded): Reorder
is_always_strided and is_unique member functions.
* testsuite/23_containers/mdspan/int_like.h: Rename _M_i to
value.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
2 months agoDo not expect 8 byte vectorization with ia32
Richard Biener [Wed, 8 Oct 2025 09:38:12 +0000 (11:38 +0200)] 
Do not expect 8 byte vectorization with ia32

We are not considering ia32 to be TARGET_MMX_WITH_SSE so the testcase
cannot work there.

PR target/120091
gcc/testsuite/
* gcc.target/i386/pr119919.c: Only check for vectorization
when !ia32.

2 months agolibstdc++: Implement std::layout_right_padded [PR110352].
Luc Grosheintz [Mon, 29 Sep 2025 06:00:19 +0000 (08:00 +0200)] 
libstdc++: Implement std::layout_right_padded [PR110352].

This commit adds the right padded layout as described in N5014, with
LWG4372 (dynamic padding value) and LWG4314 (move in operator()).

PR libstdc++/110352

libstdc++-v3/ChangeLog:

* include/std/mdspan (_RightPaddedIndices): Traits for right
padded layouts.
(layout_right::mapping::mapping) New overload for right padded
layouts.
(layout_right_padded): Add implementation.
* src/c++23/std.cc.in (layout_right_padded): Add.
* testsuite/23_containers/mdspan/layouts/ctors.cc: Update
test for right padded layouts.
* testsuite/23_containers/mdspan/layouts/empty.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/mapping.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded_neg.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded_traits.h: Ditto.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
2 months agolibstdc++: Implement std::layout_left_padded [PR110352].
Luc Grosheintz [Mon, 29 Sep 2025 06:00:18 +0000 (08:00 +0200)] 
libstdc++: Implement std::layout_left_padded [PR110352].

This commit adds a new layout layout_left_padded as standardized in
N5014. It adds a purely internal feature testing macro padded_layouts
and registers layout_left_padded in the std module.

This commit implements LWG4372, because without it's not possible
to properly test padded layouts with a dynamic padding value. It also
implements LWG4314, for consistency with prior layouts.

The implementation uses a _PaddedStorage to deduplicate most of the code
shared between left- and right-padded layouts. It's implemented through
aggregation rather than inheritence, because of a bug related to
inheriting conditionally explicit ctors.

The tests are written such that the canonical version works for
layout_left_padded. A version for layout_right_padded is derived
essentially by reversing the order of the extents.

PR libstdc++/110352

libstdc++-v3/ChangeLog:

* include/bits/version.def (padded_layouts): Add new internal
feature testing macro.
* include/bits/version.h: Regenerate.
* include/std/mdspan (__fwd_prod): New overload.
(layout_left_padded): Add declaration and implementation.
(layout_right_padded): Add declaration only.
(layout_left::mapping::mapping): New overload for left
padded mappings.
(__index_type_cast): New function that performs a checked cast
to index_type.
(__is_left_padded_mapping): New concept.
(__is_right_padded_mapping): Ditto.
(__standardized_mapping): Recognize left and right padded
mappings.
(_LeftPaddedIndices): Traits for left padded details.
(_PaddedStorage): New class for implementing padded layouts.
* src/c++23/std.cc.in (layout_left_padded): Add.
* testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc:
Refactor and add tests for layout_left_padded.
* testsuite/23_containers/mdspan/layouts/ctors.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/empty.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/mapping.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded_neg.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded_traits.h: New
traits.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
2 months agoAdd missing menu item for JIT Language and ABI
Richard Biener [Wed, 8 Oct 2025 09:13:15 +0000 (11:13 +0200)] 
Add missing menu item for JIT Language and ABI

Build of gccint.texi is currently broken, the following fixes it.

* doc/tm.texi.in (JIT Language and ABI): Add menu item.
* doc/tm.texi: Re-generate.

2 months agoc: Fix i386 target attribute regression [PR 122180]
Alfie Richards [Tue, 7 Oct 2025 09:34:48 +0000 (09:34 +0000)] 
c: Fix i386 target attribute regression [PR 122180]

My patch (r16-4182-g73888cefe6da65) broke another target (i386), which this
patch fixes.

The issue was the target_version code was incorrectly being triggered on
targets that do not support target_version semantics (i386).

PR target/122180

gcc/c/ChangeLog:

* c-decl.cc (pushdecl): Add TARGET_HAS_FMV_TARGET_ATTRIBUTE check.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr122180.c: New test.

2 months agogimplify: Fix up __builtin_c[lt]zg gimplification [PR122188]
Jakub Jelinek [Wed, 8 Oct 2025 07:58:41 +0000 (09:58 +0200)] 
gimplify: Fix up __builtin_c[lt]zg gimplification [PR122188]

The following testcase ICEs during gimplification.
The problem is that save_expr sometimes doesn't create a SAVE_EXPR but
returns the original complex tree (COND_EXPR) and the code then uses that
tree in 2 different spots without unsharing.  As this is done during
gimplification it wasn't unshared when whole body is unshared and because
gimplification is destructive, the first time we gimplify it we destruct it
and second time we try to gimplify it we ICE on it.
Now, we could replace one a use with unshare_expr (a), but because this
is a gimplification hook, I think easier than trying to create a save_expr
is just gimplify the argument, then we know it is is_gimple_val and so
something without side-effects and can safely use it twice.  That argument
would be the first thing to gimplify after return GS_OK anyway, so it
doesn't change argument sequencing etc.

2025-10-08  Jakub Jelinek  <jakub@redhat.com>

PR c/122188
* c-gimplify.cc (c_gimplify_expr): Gimplify CALL_EXPR_ARG (*expr_p, 0)
instead of calling save_expr on it.

* c-c++-common/pr122188.c: New test.

2 months agotestsuite: Fix up pr121987.c testcase for ilp32 [PR121206]
Jakub Jelinek [Wed, 8 Oct 2025 07:49:25 +0000 (09:49 +0200)] 
testsuite: Fix up pr121987.c testcase for ilp32 [PR121206]

The test FAILs on ilp32 targets with
pr121987.c:5:21: warning: unsigned conversion from 'long long int' to 'long unsigned int' changes value from '10000000000' to '1410065408' [-Woverflow]
excess error.  Fixed by using unsigned long long instead of unsigned and
using a suffix on the constant.
Tested on x86_64-linux with -m32/-m64, additionally tested with older cc1
where it ICEd in both cases in upper_bound.

2025-10-08  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/121206
* gcc.dg/pr121987.c (main): Use unsigned long long type for e instead
of unsigned long and use ULL suffix on the initializer.

2 months agoFortran: Fix PDT parameter substitution [PR93175,PR102240,PR102686]
Paul Thomas [Wed, 8 Oct 2025 07:17:10 +0000 (08:17 +0100)] 
Fortran: Fix PDT parameter substitution [PR93175,PR102240,PR102686]

2025-10-08  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/93175
PR fortran/102240
PR fortran/102686
* array.cc (match_array_element_spec): For pdt templates, call
gfc_correct_parm_expr to elimante extraneous symbols from the
bound expressions.
* decl.cc (correct_parm_expr, gfc_correct_parm_expr): New fcns
that remove symbols that are not PDT parameters from the type
specification expressions.
(insert_parameter_exprs): Process function symbols as if they
are variables in the substitution with parameter expressions.
(gfc_get_pdt_instance): Make sure that the parameter list of
PDT components is updated as the instance is built. Move the
construction of pdt_strings down a bit in the function and
remove the tie up with pdt_arrays.
* gfortran.h: Add prototype for gfc_correct_parm_expr.
* resolve.cc (resolve_component): Skip testing for constant
specification expressions in pdt_template component string
lengths and pdt_strings.
* trans-array.cc (structure_alloc_comps): Remove testing for
deferred parameters and instead make sure that components of
PDT type have parameters substituted with the parameter exprs
of the enclosing PDT.

gcc/testsuite/
PR fortran/93175
PR fortran/102240
PR fortran/102686
* gfortran.dg/pdt_55.f03: New test.

2 months agoFixup store bool pattern
Richard Biener [Tue, 7 Oct 2025 13:32:45 +0000 (15:32 +0200)] 
Fixup store bool pattern

I think the bool pattern recognition for a store from a bool we
decided to represent with a mask type is a bit confused.  The
following streamlines it by using the mask to create a data 0/1
and first possibly converting the mask according to the vector
data type we produce (that was missing and is noticable in PR110223).

This alone doesn't fix the 2nd testcase from the PR, but is required.

PR tree-optimization/110223
* tree-vect-patterns.cc (vect_recog_bool_pattern): Fix
mistakes in the store-from-mask bool pattern.  Add
required mask conversions.

2 months agotree-optimization/105490 - improve COND_EXPR bool pattern
Richard Biener [Tue, 7 Oct 2025 12:31:18 +0000 (14:31 +0200)] 
tree-optimization/105490 - improve COND_EXPR bool pattern

We miss to add a mask conversion from the mask producer to the
appropriate mask for the condition operation.  The following moves
required helpers and adds the missing part of the pattern.  That's
required both for the case we have different mask element sizes
and for the case we have a different number of elements because
cond expression vectorization doesn't handle the mask having
different nunits than the data vector.

PR tree-optimization/105490
* tree-vect-patterns.cc (build_mask_conversion): Move earlier.
(vect_convert_mask_for_vectype): Likewise.
(vect_recog_bool_pattern): Remove redundant truth type
construction.  Add missing possibly required mask conversion.

* gcc.dg/vect/vect-cond-14.c: New testcase.

2 months agolibgccjit: Add ability to get CPU features
Antoni Boucher [Fri, 21 Mar 2025 17:13:41 +0000 (13:13 -0400)] 
libgccjit: Add ability to get CPU features

gcc/ChangeLog:
PR jit/112466
* Makefile.in (tm_jit_file_list, tm_jit_include_list, TM_JIT_H,
JIT_TARGET_DEF, JIT_TARGET_H, JIT_TARGET_OBJS): New variables.
(tm_jit.h, cs-tm_jit.h, jit/jit-target-hooks-def.h,
s-jit-target-hooks-def-h, default-jit.o): New rules.
(s-tm-texi): Also check timestamp on jit-target.def.
(generated_files): Add TM_JIT_H and jit/jit-target-hooks-def.h.
(build/genhooks.o): Also depend on JIT_TARGET_DEF.
* config.gcc (tm_jit_file, jit_target_objs, target_has_targetjitm):
New variables.
* config/i386/t-i386 (i386-jit.o): New rule.
* configure: Regenerate.
* configure.ac (tm_jit_file_list, tm_jit_include_list,
jit_target_objs): Add substitutes.
* doc/tm.texi: Regenerate.
* doc/tm.texi.in (targetjitm): Document.
(target_has_targetjitm): Document.
* genhooks.cc: Include jit/jit-target.def.
* config/default-jit.cc: New file.
* config/i386/i386-jit.cc: New file.
* config/i386/i386-jit.h: New file.

gcc/jit/ChangeLog:
PR jit/112466
* Make-lang.in (JIT_OBJS): New variable.
* jit-playback.cc (replay): Include jit-target.h and initialize
target.
* jit-playback.h (class populate_target_info): New class.
* jit-recording.cc (recording::context::populate_target_info): New
method.
* jit-recording.h (recording::context::populate_target_info): New
method.
(recording::context::m_populated_target_info): New field.
* libgccjit.cc: Include jit-target.h.
(struct gcc_jit_target_info): New struct.
(gcc_jit_context_get_target_info, gcc_jit_target_info_release,
gcc_jit_target_info_cpu_supports, gcc_jit_target_info_arch,
gcc_jit_target_info_supports_target_dependent_type): New functions.
* libgccjit.h (gcc_jit_context_get_target_info,
gcc_jit_target_info_release, gcc_jit_target_info_cpu_supports,
gcc_jit_target_info_arch,
gcc_jit_target_info_supports_target_dependent_type):
New functions.
* libgccjit.map (LIBGCCJIT_ABI_35): New ABI tag.
* docs/topics/compilation.rst: Add documentation for the
functions gcc_jit_context_get_target_info, gcc_jit_target_info_release,
gcc_jit_target_info_cpu_supports, gcc_jit_target_info_arch,
gcc_jit_target_info_supports_target_dependent_type.
* docs/topics/compatibility.rst (LIBGCCJIT_ABI_35): New ABI tag.
* jit-target-def.h: New file.
* jit-target.cc: New file.
* jit-target.def: New file.
* jit-target.h: New file.

gcc/testsuite/ChangeLog:
PR jit/112466
* jit.dg/all-non-failing-tests.h: Mention
test-target-info.c.
* jit.dg/test-target-info.c: New test.
* jit.dg/test-error-target-info.c: New test.

2 months agoDaily bump.
GCC Administrator [Wed, 8 Oct 2025 00:20:55 +0000 (00:20 +0000)] 
Daily bump.

2 months agoc: Implement C2y handling of incomplete tentative definitions [PR26581]
Joseph Myers [Tue, 7 Oct 2025 23:04:54 +0000 (23:04 +0000)] 
c: Implement C2y handling of incomplete tentative definitions [PR26581]

Before C2y, a tentative definition (file-scope, not extern, no
initializer) with internal linkage and incomplete type was undefined
behavior ("shall" outside Constraints violated).  In C2y, this has
changed to a constraint violation if the type has not been completed
by the end of the translation unit, and is valid if the type has been
completed by the end of the translation unit.  This change originates
from N3347 but the wording accepted into C2y was that from reflector
message 26758.

In GCC, the case of incomplete array types was a hard error with
-pedantic, rather than a pedwarn, contrary to how -pedantic is
supposed to behave; bug 26581 requested a change to allow this case
with -pedantic (i.e. the change made in C2y).  For incomplete structs
and unions, GCC only diagnoses them if the type remains incomplete at
the end of the translation unit; bug 88727 (*not* fixed here) requests
the case where the type gets completed should also be diagnosed as a
quality of implementation matter (and that bug is still applicable for
pre-C2y langauge versions and -Wc23-c2y-compat).

Change the handling of arrays following C2y; the previous error
becomes a pedwarn_c23 while there is a new error at the end of the
translation unit if the type remains incomplete there in C2y mode.

There is an ambiguity in the wording in C2y for the case where the
type gets completed only in an inner scope; I've raised that in
reflector message 34118.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

PR c/26581

gcc/c/
* c-decl.cc (c_finish_incomplete_decl): Give error for tentative
definition of incomplete array for C2y with internal linkage.
(finish_decl): Do not set DO_DEFAULT based on -pedantic.  Use
pedwarn_c23 for missing array sizes for internal linkage.

gcc/testsuite/
* gcc.dg/c23-incomplete-2.c, gcc.dg/c23-incomplete-3.c,
gcc.dg/c23-incomplete-4.c, gcc.dg/c2y-incomplete-4.c,
gcc.dg/c2y-incomplete-5.c: New tests.
* gcc.dg/c23-thread-local-2.c, gcc.dg/c2y-incomplete-1.c: Update
expected errors.

2 months agolibbid: Set rounding mode to round-to-nearest for _Decimal128 arithmetic
H.J. Lu [Sat, 30 Aug 2025 18:46:31 +0000 (11:46 -0700)] 
libbid: Set rounding mode to round-to-nearest for _Decimal128 arithmetic

Since _Decimal128 arithmetic requires the round-to-nearest rounding
mode, define DFP_INIT_ROUNDMODE and DFP_RESTORE_ROUNDMODE, similar to
FP_INIT_ROUNDMODE in sfp-machine.h, to set the rounding mode to
round-to-nearest at _Decimal128 related arithmetic function entrances
and restores it upon return.  This doesn't require linking with libm
when libgcc is used.

libgcc/

PR target/120691
* Makefile.in (DECNUMINC): Add -I$(srcdir)/config/$(cpu_type).
* config/i386/dfp-machine.h: New file.
* config/i386/32/dfp-machine.h: Likewise.
* config/i386/64/dfp-machine.h: Likewise.

libgcc/config/libbid/

PR target/120691
* bid128_div.c: Run DFP_INIT_ROUNDMODE at function entrace and
DFP_RESTORE_ROUNDMODE at function exit.
* bid128_rem.c: Likewise.
* bid128_sqrt.c: Likewise.
* bid64_div.c (bid64_div): Likewise.
* bid64_sqrt.c (bid64_sqrt): Likewise.
* bid_conf.h: Include <dfp-machine.h>.
* dfp-machine.h: New file.

gcc/testsuite/

PR target/120691
* gcc.target/i386/pr120691.c: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 months agoc++: new-expr clobber of constant-size array
Jason Merrill [Sat, 4 Oct 2025 08:24:29 +0000 (09:24 +0100)] 
c++: new-expr clobber of constant-size array

I previously tried to clobber an array as a whole, but fell back on a loop
due to issues with std::construct_at following the resolution of LWG3436.
But the loop seems to make life hard for the optimizers and it occurs to me
that for a one-element array we can just clobber the element type.

This also fixes some xfails in Warray-bounds-20.C.

gcc/cp/ChangeLog:

* init.cc (build_new_1): Clobber a constant-bound array as a whole.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Warray-bounds-20.C: Remove xfails, add diags.

2 months agodocs: Add documentation for TARGET_HAS_FMV_TARGET_ATTRIBUTE macro
Alfie Richards [Wed, 13 Aug 2025 20:13:28 +0000 (20:13 +0000)] 
docs: Add documentation for TARGET_HAS_FMV_TARGET_ATTRIBUTE macro

Adds documentation for the TARGET_HAS_FMV_TARGET_ATTRIBUTE macro hook.

gcc/ChangeLog:

* doc/tm.texi: Regenerate.
* doc/tm.texi.in: Add documentation for TARGET_HAS_FMV_TARGET_ATTRIBUTE.

2 months agoAVR: target/122187 - Don't clobber recog_data.operand[] in insn out.
Georg-Johann Lay [Tue, 7 Oct 2025 15:50:34 +0000 (17:50 +0200)] 
AVR: target/122187 - Don't clobber recog_data.operand[] in insn out.

avr.cc::avr_out_extr() and avr.cc::avr_out_extr_not()
changed xop for output, which spoiled the operand for
the next invokation, running into an assertion.

This patch makes a local copy of the operands.

PR target/122187
gcc/
* config/avr/avr.cc (avr_out_extr, avr_out_extr_not):
Make a local copy of the passed rtx[] operands.

gcc/testsuite/
* gcc.target/avr/torture/pr122187.c: New test.

2 months agoall: Fix "specifc", "costant" and "constat" typos in comments
Jonathan Wakely [Tue, 7 Oct 2025 14:00:24 +0000 (15:00 +0100)] 
all: Fix "specifc", "costant" and "constat" typos in comments

gcc/ChangeLog:

* config/i386/i386-features.cc
(general_scalar_chain::vector_const_cost): Fix spelling in
comment.
* ipa-prop.h (enum jump_func_type): Likewise.
* tree-vectorizer.cc (try_vectorize_loop_1): Likewise.

gcc/cp/ChangeLog:

* module.cc (trees_out::lang_vals): Fix spelling in comment.

gcc/jit/ChangeLog:

* docs/_build/texinfo/libgccjit.texi: Fix spelling.
* docs/internals/index.rst: Likewise.

libgm2/ChangeLog:

* configure.host: Fix spelling in comment.

libstdc++-v3/ChangeLog:

* configure.host: Fix spelling in comment.

gcc/testsuite/ChangeLog:

* gfortran.dg/dynamic_dispatch_9.f03: Fix spelling in comment.
* gfortran.dg/use_only_3.inc: Likewise

2 months ago[PATCH] RISC-V: Detect wrap in shuffle_series_pattern [PR121845].
Robin Dapp [Tue, 7 Oct 2025 13:18:27 +0000 (07:18 -0600)] 
[PATCH] RISC-V: Detect wrap in shuffle_series_pattern [PR121845].

Hi,

In shuffle_series_pattern we use series_p to determine if the permute
mask is a simple series.  This didn't take into account that series_p
also returns true for e.g. {0, 3, 2, 1} where the step is 3 and the
indices form a series modulo 4.

We emit
 vid + vmul
in order to synthesize a series.  In order to be always correct we would
need a vrem afterwards still which does not seem worth it.

This patch adds the modulo for VLA permutes and punts if we wrap around
for VLS permutes.  I'm not really certain whether we'll really see a wrapping
VLA series (certainly we haven't so far in the test suite) but as we observed
a VLS one here now it appears conservatively correct to module the indices.

Regtested on rv64gcv_zvl512b.

Regards
 Robin

PR target/121845

gcc/ChangeLog:

* config/riscv/riscv-v.cc (shuffle_series_patterns):
Modulo indices for VLA and punt when wrapping for VLS.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr121845.c: New test.

2 months ago[PATCH] RISC-V: Fix slide pattern recognition [PR122124]
Raphael Moreira Zinsly [Tue, 7 Oct 2025 13:14:01 +0000 (07:14 -0600)] 
[PATCH] RISC-V: Fix slide pattern recognition [PR122124]

Ensure the second pivot is really a pivot and it's not in OP1.

PR target/122124
gcc/ChangeLog:
* config/riscv/riscv-v.cc (shuffle_slide_patterns): Check if
the second pivot is in OP1 and improve comments.

gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/pr122124.c: New test.

2 months agoFortran: Fix ICE in pdt_1[3-5].f03 with -fcheck=all [PR102901]
Paul Thomas [Tue, 7 Oct 2025 12:30:43 +0000 (13:30 +0100)] 
Fortran: Fix ICE in pdt_1[3-5].f03 with -fcheck=all [PR102901]

2025-10-07  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/102901
* trans-array.cc (structure_alloc_comps): Do not use
gfc_check_pdt_dummy with pointer or allocatable components.

gcc/testsuite/
PR fortran/102901
* gfortran.dg/pdt_56.f03: Copy of pdt_13.f03 compiled with
-fcheck=all.

2 months agolibstdc++: Initialize local variable in __gnu_cxx::rope
Jonathan Wakely [Wed, 1 Oct 2025 14:12:35 +0000 (15:12 +0100)] 
libstdc++: Initialize local variable in __gnu_cxx::rope

This avoids -Wmaybe-uninitialized warnings.

libstdc++-v3/ChangeLog:

* include/ext/ropeimpl.h (rope::_S_fetch): Initialize variable.

2 months agolibstdc++: Fix -Wparentheses warning in std::mul_sat
Jonathan Wakely [Wed, 1 Oct 2025 12:53:14 +0000 (13:53 +0100)] 
libstdc++: Fix -Wparentheses warning in std::mul_sat

libstdc++-v3/ChangeLog:

* include/bits/sat_arith.h (mul_sat): Add parentheses around
operands.

2 months agolibstdc++: Fix -Wmaybe-uninitialized warning in another test
Jonathan Wakely [Wed, 1 Oct 2025 12:51:55 +0000 (13:51 +0100)] 
libstdc++: Fix -Wmaybe-uninitialized warning in another test

Like r16-4120-ge1b9ccaa10df01 this is a false positive, but we can just
initialize the variable.

libstdc++-v3/ChangeLog:

* testsuite/std/time/parse/parse.cc: Initialize variable.

2 months agolibstdc++: Suppress -Wpessimizing-move warnings in shared_ptr tests
Jonathan Wakely [Thu, 2 Oct 2025 15:37:33 +0000 (16:37 +0100)] 
libstdc++: Suppress -Wpessimizing-move warnings in shared_ptr tests

libstdc++-v3/ChangeLog:

* testsuite/20_util/shared_ptr/cons/move.cc: Add comment and
dg-prune-output for -Wpessimizing-move warning.
* testsuite/experimental/memory/shared_ptr/cons/move_ctor.cc:
Likewise.

2 months agolibstdc++: Fix -Wreorder warning in std::philox_engine
Jonathan Wakely [Wed, 1 Oct 2025 12:48:18 +0000 (13:48 +0100)] 
libstdc++: Fix -Wreorder warning in std::philox_engine

libstdc++-v3/ChangeLog:

* include/bits/random.h (philox_engine(result_type)): Reorder
ctor-initializer-list to match declaration order.

2 months agolibstdc++: Fix -Wformat warning in std::string
Jonathan Wakely [Wed, 1 Oct 2025 12:31:59 +0000 (13:31 +0100)] 
libstdc++: Fix -Wformat warning in std::string

The __throw_out_of_range_fmt function works like fprintf and so the
arguments corresponding to %zu specifiers need to be size_t. The
std::basic_string<C,T,A>::size_type type is A::size_type which is not
necessarily size_t. Add explicit casts to avoid a -Wformat warning with
-Wsystem-headers.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h (basic_string::_M_check): Cast
size_type arguments to size_t.

2 months agoRevert "Ada: Remove useless Makefile variable"
Eric Botcazou [Tue, 7 Oct 2025 07:51:37 +0000 (09:51 +0200)] 
Revert "Ada: Remove useless Makefile variable"

This reverts commit 49aed8ceb5d3ee8af96ebd7edd5d250b682697cd.

2 months agomatch: Extend `-(a ptrdiff b)` pattern by allowing a nop conversion between the neg...
Andrew Pinski [Sun, 5 Oct 2025 16:08:15 +0000 (09:08 -0700)] 
match: Extend `-(a ptrdiff b)` pattern by allowing a nop conversion between the neg and ptrdiff [PR121921]

When I tried to fix this before I didn't realize there was already a pattern for
`-(a ptrdiff b) -> (b ptrdiff a)`, I had added a complex pattern to match `ptr0 - (ptr0 - ptr1)`.
But with there being a pattern for `-(a ptrdiff b)`, we just need to extend the pattern
to support a nop conversion inbetween the negative and the ptrdiff.
Also the check for TYPE_OVERFLOW_UNDEFINED was wrong, in the case of `-(a - b) -> (b - a)`, the check
is !TYPE_OVERFLOW_SANITIZED so this pattern should use the same check.

Bootstrapped and tested on x86_64-linux-gnu.

Changes since v1:
* v2: Use the old type of the pointer_diff rather than ssizetype.

PR tree-optimization/121921

gcc/ChangeLog:

* match.pd (`-(a ptrdiff b)`): Extend for a nop_convert
between the neg and ptrdiff.

gcc/testsuite/ChangeLog:

* gcc.dg/pr121921-1.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agophiopt/cselim: Improve cselim-limited to commonalize all stores [PR122083]
Andrew Pinski [Sat, 4 Oct 2025 03:18:07 +0000 (20:18 -0700)] 
phiopt/cselim: Improve cselim-limited to commonalize all stores [PR122083]

cselim (and the phiopt's cselim-limited) can commonalize a single
store which makes this too limited in some/many cases. Instead let's
commonalize all trailing stores as much as possible (only in the same
order).
The change is smallish, basically the restriction on being the only store
is removed from single_trailing_store_in_bb (renamed too). And also
looping to remove all of the trailing stores instead of just doing one for
the pass.

Note sink will do the same optimization so doing it earlier seems like a good
idea because it improve change inlining size estimates.
For an example with this change, early inlining can happen for min_cmp<long int>
in g++.dg/opt/pr122083-1.C now; that avoids a -Wnonnull warning as the memcmp with
the null argument is optimized early. It can also catch some min in phiopt1 in some
cases.

Bootstrapped and tested on x86_64-linux-gnu.

Changes since v1:
* v2: For !flag_expensive_optimizations, handle the only store rather than just the last
      store.

PR tree-optimization/122083

gcc/ChangeLog:

* tree-ssa-phiopt.cc (single_trailing_store_in_bb): Rename to ...
(trailing_store_in_bb): This and take new argument to check for
only store.
(cond_if_else_store_replacement_limited): Update to use
trailing_store_in_bb.
(cond_if_else_store_replacement): Loop until
cond_if_else_store_replacement_limited returns false.
(pass_phiopt::execute): Instead of calling cond_if_else_store_replacement_limited
once, also loop on it.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/ssa-pre-19.c: Disable phiopt and cselim.
* g++.dg/opt/pr122083-1.C: New test.
* gcc.dg/tree-ssa/cselim-1.c: New test.
* gcc.dg/tree-ssa/cselim-2.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agox86: Swap %edx/%rdx with %eax/%rax for PR middle-end/122122
H.J. Lu [Tue, 7 Oct 2025 00:28:04 +0000 (08:28 +0800)] 
x86: Swap %edx/%rdx with %eax/%rax for PR middle-end/122122

Swap %edx/%rdx with %eax/%rax after

commit r16-4255-g075310d3a3ef1a8b483b62d9535887b37f291ee4
Author: Jan Hubicka <hubicka@ucw.cz>
Date:   Mon Oct 6 21:35:22 2025 +0200

    Update profile in tree-ssa-dce

commit 8498ef3d0758012bf3e355a61a0f89aff7513851
Author: Jan Hubicka <hubicka@ucw.cz>
Date:   Wed Oct 1 16:56:15 2025 +0200

    Improve profile update in merge_blocks

PR middle-end/122122
* gcc.target/i386/memcpy-pr120683-2.c: Swap %edx/%rdx with
%eax/%rax after
* gcc.target/i386/memcpy-pr120683-3.c: Likewise.
* gcc.target/i386/memcpy-pr120683-4.c: Likewise.
* gcc.target/i386/memcpy-pr120683-5.c: Likewise.
* gcc.target/i386/memcpy-pr120683-6.c: Likewise.
* gcc.target/i386/memcpy-pr120683-7.c: Likewise.
* gcc.target/i386/pr111657-1.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 months agoDaily bump.
GCC Administrator [Tue, 7 Oct 2025 00:21:28 +0000 (00:21 +0000)] 
Daily bump.

2 months agocselim: Don't create a phi node if the rhs side are the same [PR122155]
Andrew Pinski [Sat, 4 Oct 2025 17:16:20 +0000 (10:16 -0700)] 
cselim: Don't create a phi node if the rhs side are the same [PR122155]

This is a small compile time optimization where if commonalizing stores
that have the same rhs, a phi node does not need to be created.
This uses the same code as what was added for the `= {};` case.
The reason why it is a compile time optimization is that Copy prop
later on will do the same thing so not creating a new phi and a new
ssa name will have a small compile time improvement.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/122155

gcc/ChangeLog:

* tree-ssa-phiopt.cc (cond_if_else_store_replacement_1): Don't
create a phi if the 2 rhs are the same.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/cselim-3.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agoAVR/LibF7: Implement sincos.
Georg-Johann Lay [Mon, 6 Oct 2025 19:31:46 +0000 (21:31 +0200)] 
AVR/LibF7: Implement sincos.

libgcc/config/avr/libf7/
* libf7-common.mk (F7_ASM_PARTS): Add D_sincos.
* libf7-asm.sx: (D_sincos): New module implements sincos / sincosl.

gcc/testsuite/
* gcc.target/avr/sincos-1.c: New test.

2 months agoUpdate profile in tree-ssa-dce
Jan Hubicka [Mon, 6 Oct 2025 19:35:22 +0000 (21:35 +0200)] 
Update profile in tree-ssa-dce

The profile mismatches uncovered by my merge_blocks change are actually caused
by tree-ssa-dce not updating profile of blocks with no statements for whose it
optimized away control dependencies.  In most cases those basic blocks are
merged or skipped as forwarders.  I tried to simply set their count as
uninitialized but that upsets verifier since in some cases we keep the block
around (for example, when it is header of a loop).

In all cases I debugged we optimized away an unnecesary loop and while merging
old code picked porfile of loop preheader, while we now pick loop header.  This
is however not guaranteed and we may process blocks in different order and pick
wrong profile.

Since regions of dead basic blocks must be acyclic it is easy to propagate the
frequencies as implemented by this patch.

Bootstrapped/regtested x86_64-linux. Comitted

gcc/ChangeLog:

PR middle-end/122122
* tree-cfgcleanup.cc (tree_forwarder_block_p): Cleanup.
* tree-ssa-dce.cc (propagate_counts): New function.
(eliminate_unnecessary_stmts): Use it.

2 months agoFix description of --param auto-profile-bbs
Jan Hubicka [Thu, 2 Oct 2025 10:12:05 +0000 (12:12 +0200)] 
Fix description of --param auto-profile-bbs

gcc/ChangeLog:

* params.opt (-param=auto-profile-bbs=): Add missing full stop after
description.

2 months agoIf a range's bitmask changes, reflect it in the bounds.
Andrew MacLeod [Thu, 2 Oct 2025 15:51:01 +0000 (11:51 -0400)] 
If a range's bitmask changes, reflect it in the bounds.

Rather than trying to be smart, if the bitmask changes, adjust all range
bounds to satisfy the bitmask requirements.

PR tree-optimization/121206
gcc/
* value-range.cc (irange::intersect_bitmask): Always call
set_range_from_bitmask if the bitmask changes.

gcc/testsuite
* gcc.dg/pr121987.c: New.

2 months agodoc: mention STAGE1_CFLAGS
Sam James [Wed, 14 Aug 2024 12:15:30 +0000 (13:15 +0100)] 
doc: mention STAGE1_CFLAGS

STAGE1_CFLAGS can be used to accelerate the just-built stage1 compiler
which especially improves its performance on some of the large generated
files during bootstrap. It defaults to nothing (i.e. -O0).

The downside is that if the native compiler is buggy, there's a greater
risk of a failed bootstrap. Those with a modern native compiler, ideally
a recent version of GCC, should be able to use -O1 or -O2 without issue
to get a faster build.

PR rtl-optimization/111619
* doc/install.texi (Building a native compiler): Discuss STAGE1_CFLAGS.

2 months agoAVR/LibF7: target/122177 - fix fmin / fmax return value for one NaN arg.
Georg-Johann Lay [Sun, 5 Oct 2025 18:56:56 +0000 (20:56 +0200)] 
AVR/LibF7: target/122177 - fix fmin / fmax return value for one NaN arg.

fmin and fmax should return the non-NaN argument in the case where
exactly one argument is a NaN.

Moreover, IEEE double fmin and fmax can be performed without
first converting the args to the internal representation and
then converting back again.

PR target/122177
libgcc/config/avr/libf7/
* libf7-common.mk (m_ddd): Remove: fmin, fmax.
(F7_ASM_PARTS): Add: D_fminfmax.
* libf7-asm.sx (D_fmanfmax): New module.
* f7-wraps.h: Rebuild.

gcc/testsuite/
* gcc.target/avr/fminfmax-1.c: New test.

2 months agoAVR: Speed up IEEE double comparisons.
Georg-Johann Lay [Sun, 5 Oct 2025 18:56:56 +0000 (20:56 +0200)] 
AVR: Speed up IEEE double comparisons.

IEEE double can be compared without first converting them to
the internal representation.

libgcc/config/avr/libf7/
* libf7-common.mk (g_xdd_cmp): Remove le, lt, ge, gt, ne, eq, unord.
(F7_ASM_PARTS): Add D_cmp, D_eq, D_ne, D_ge, D_gt, D_le, D_lt, D_unord.
* libf7-asm.sx (D_cmp, D_eq, D_ne, D_ge, D_gt, D_le, D_lt, D_unord):
New modules.
* f7-wraps.h: Rebuild.

gcc/testsuite/
* gcc.target/avr/cmpdi-1.c: New test.

2 months agoaarch64: Fix ICE when op2 is zero for SVE2 saturating add intrinsics.
Jennifer Schmitz [Thu, 21 Aug 2025 17:01:49 +0000 (10:01 -0700)] 
aarch64: Fix ICE when op2 is zero for SVE2 saturating add intrinsics.

When op2 in SVE2 saturating add intrinsics (svuqadd, svsqadd) is a zero
vector and predication is _z, an ICE in vregs occurs, e.g. for

svuint8_t foo (svbool_t pg, svuint8_t op1)
{
    return svsqadd_u8_z (pg, op1, svdup_s8 (0));
}

The insn failed to match the pattern (aarch64-sve2.md):

;; Predicated binary operations with no reverse form, merging with zero.
;; At present we don't generate these patterns via a cond_* optab,
;; so there's no correctness requirement to handle merging with an
;; independent value.
(define_insn_and_rewrite "*cond_<sve_int_op><mode>_z"
  [(set (match_operand:SVE_FULL_I 0 "register_operand")
(unspec:SVE_FULL_I
  [(match_operand:<VPRED> 1 "register_operand")
   (unspec:SVE_FULL_I
     [(match_operand 5)
      (unspec:SVE_FULL_I
[(match_operand:SVE_FULL_I 2 "register_operand")
 (match_operand:SVE_FULL_I 3 "register_operand")]
SVE2_COND_INT_BINARY_NOREV)]
     UNSPEC_PRED_X)
   (match_operand:SVE_FULL_I 4 "aarch64_simd_imm_zero")]
  UNSPEC_SEL))]
  "TARGET_SVE2"
  {@ [ cons: =0 , 1   , 2 , 3  ]
     [ &w       , Upl , 0 , w  ] movprfx\t%0.<Vetype>, %1/z, %0.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
     [ &w       , Upl , w , w  ] movprfx\t%0.<Vetype>, %1/z, %2.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
  }
  "&& !CONSTANT_P (operands[5])"
  {
    operands[5] = CONSTM1_RTX (<VPRED>mode);
  }
  [(set_attr "movprfx" "yes")]
)

because operands[3] and operands[4] were both expanded into the same register
operand containing a zero vector by define_expand "@cond_<sve_int_op><mode>".

This patch fixes the ICE by making a case distinction in
function_expander::use_cond_insn that uses add_fixed_operand if
fallback_arg == CONST0_RTX (mode), and otherwise add_input_operand (which was
previously the default and allowed the expansion of the zero-vector
fallback_arg to a register operand).

The patch was bootstrapped and tested on aarch64-linux-gnu, no regression.
OK for trunk?

Alex Coplan pointed out in the bugzilla ticket that this ICE goes back
to GCC 10. Shall we backport?

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
Co-authored by: Richard Sandiford <rdsandiford@googlemail.com>

gcc/
PR target/121599
* config/aarch64/aarch64-sve-builtins.cc
(function_expander::use_cond_insn): Use add_fixed_operand if
fallback_arg == CONST0_RTX (mode).

gcc/testsuite/
PR target/121599
* gcc.target/aarch64/sve2/pr121599.c: New test.

2 months agotree-optimization/122131 - do not use re-align load for gathers
Richard Biener [Mon, 6 Oct 2025 07:53:07 +0000 (09:53 +0200)] 
tree-optimization/122131 - do not use re-align load for gathers

As we now ask vect_supportable_dr_alignment for gathers avoid using
(optimized) re-align instructions for them.

PR tree-optimization/122131
* tree-vect-data-refs.cc (vect_supportable_dr_alignment): Do
not use re-align loads for gathers.

* gcc.target/powerpc/altivec-39.c: New testcase.

2 months agoada: Fix handling of Extended_Access with array subtype
Marc Poulhiès [Mon, 22 Sep 2025 08:57:13 +0000 (10:57 +0200)] 
ada: Fix handling of Extended_Access with array subtype

For array subtypes, return the extended types corresponding to the array
type.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (get_extended_unconstrained_array): Handle
array subtype.

Co-authored-by: Éric Botcazou <botcazou@adacore.com>
2 months agoada: Implement proper upcasting in more cases
Eric Botcazou [Wed, 24 Sep 2025 17:02:34 +0000 (19:02 +0200)] 
ada: Implement proper upcasting in more cases

Upcasting (conversion from a tagged type extension to one of its parents)
is represented as a simple N_Type_Conversion node in the expanded code,
but translating it into a VIEW_CONVERT_EXPR is a bit problematic because
source and target types of the GCC node are supposed to have the same size
(at least in "non-pathological" cases).

That's why Gigi attempts to build an explicit chain of references to the
appropriate _Parent (sub)component instead, but it currently does that
only for simple (i.e. non-discriminated) tagged types.  This can be easily
extended to discriminated tagged types in not-too-dynamic cases (an example
is the ACATS c391002 test).

gcc/ada/ChangeLog:

* gcc-interface/utils.cc (convert): Also extract the _Parent field
to implement upcasting in the case where only the sizes match.

2 months agoada: Fix extended access and memory pool explicit deref
Marc Poulhiès [Tue, 16 Sep 2025 13:07:29 +0000 (15:07 +0200)] 
ada: Fix extended access and memory pool explicit deref

Explicit dereference of an extended access with data allocation in a
memory pool would crash the compiler.

gcc/ada/ChangeLog:

* gcc-interface/trans.cc (Attribute_to_gnu)<Attr_Pool_Address>: Handle
extended access.

2 months agoada: Fix usage of Table.Table in Fmap
Ronan Desplanques [Thu, 25 Sep 2025 07:53:35 +0000 (09:53 +0200)] 
ada: Fix usage of Table.Table in Fmap

Table.Table can be instantiated to use either 0-based or 1-based
indexing, which can cause some confusion and make 0-based instances get
used as 1-based ones.

This was the case for two tables in Fmap before this patch. That did not
cause any bugs but allocated an extra cell in the arrays that went
unused.

This patch also replaces Increment_Last-and-assignment combos with
equivalent calls to Append.

gcc/ada/ChangeLog:

* fmap.adb (File_Mapping, Path_Mapping): Fix instantiations.
(Add_To_File_Map): Use Table.Table.Append.

2 months agoada: Remove obsolete code
Ronan Desplanques [Wed, 24 Sep 2025 12:53:18 +0000 (14:53 +0200)] 
ada: Remove obsolete code

This patch removes code that has been unused since the project manager
infrastructure was retired.

gcc/ada/ChangeLog:

* fmap.ads (Add_Forbidden_File_Name): Remove obsolete code.
* fmap.adb (Forbidden_Names, Add_Forbidden_File_Name,
Mapped_Path_Name, Reset_Tables): Remove obsolete code.

2 months agoada: Refine documentation of -gnatwr
Tonu Naks [Thu, 18 Sep 2025 07:18:08 +0000 (10:18 +0300)] 
ada: Refine documentation of -gnatwr

gcc/ada/ChangeLog:

* doc/gnat_ugn/building_executable_programs_with_gnat.rst: refine
description of -gnatwr
* gnat_ugn.texi: Regenerate.

2 months agotree-optimization/122158 - vector reduction epilog for bit-precision result
Richard Biener [Mon, 6 Oct 2025 07:06:45 +0000 (09:06 +0200)] 
tree-optimization/122158 - vector reduction epilog for bit-precision result

The following makes sure to perform the vector element extraction
using the element type and convert to the original, possibly
bit-precision, result afterwards.  I've also used gimple_build
for the BIT_FIELD_REF since that simplifies the code.

PR tree-optimization/122158
* tree-vect-loop.cc (vect_create_epilog_for_reduction): Handle
bit-precision result.

* gcc.dg/vect/pr122158.c: New testcase.

2 months agostmt: Handle %cc[name] in resolve_asm_operand_names [PR122133]
Jakub Jelinek [Mon, 6 Oct 2025 07:46:48 +0000 (09:46 +0200)] 
stmt: Handle %cc[name] in resolve_asm_operand_names [PR122133]

Last year I've extended the asm template syntax in inline asm to support
%cc0 etc., apparently the first 2 letter generic operand modifier.
As the following testcase shows, I forgot to tweak the [foo] handling
for it though.  As final.cc will error on any % ISALPHA not followed by
digit (with the exception of % c c digit), I think we can safely handle
this for any 2 letters in between % and [, instead of hardcoding it for
now only for %cc[ and changing it again next time we add something
two-letter.

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

PR middle-end/122133
* stmt.cc (resolve_asm_operand_names): Handle % and 2 letters followed
by open square.

* c-c++-common/toplevel-asm-9.c: New test.

2 months agoIntroduce fold_before_rtl_expansion_p [PR122142]
Andrew Pinski [Fri, 3 Oct 2025 16:54:45 +0000 (09:54 -0700)] 
Introduce fold_before_rtl_expansion_p [PR122142]

As requested in https://inbox.sourceware.org/gcc-patches/CAFiYyc1jzZSZNhTas-DdMBFOzH1p96oGN=OVj6fyjt8HzDUyCA@mail.gmail.com/T/#u.
This introduces fold_before_rtl_expansion_p to replace
`(cfun->curr_properties & PROP_last_full_fold) != 0`.
I am not a fan of include tree-pass.h in gimple-fold.h but that was the
only way to reduce the number of changes.

Bootrapped and tested on x86_64-linux-gnu.

PR tree-optimization/122142
gcc/ChangeLog:

* generic-match-head.cc: Include gimple-iterator.h
and gimple-fold.h.
* gimple-fold.cc (gimple_fold_builtin_constant_p): Use
fold_before_rtl_expansion_p.
(gimple_fold_builtin_assume_aligned): Likewise.
(gimple_fold_builtin_stdarg): Likewise.
(gimple_fold_call): Likewise.
* gimple-fold.h: Include "tree-pass.h".
(fold_before_rtl_expansion_p): New function.
* match.pd: Use fold_before_rtl_expansion_p
instead of `cfun->curr_properties & PROP_last_full_fold`.
* tree-ssa-forwprop.cc (simplify_builtin_memcmp): Likewise.
(optimize_stack_restore): Likewise.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agoDaily bump.
GCC Administrator [Mon, 6 Oct 2025 00:17:42 +0000 (00:17 +0000)] 
Daily bump.

2 months agox86: Handle small OP size in setmem_epilogue_gen_val
H.J. Lu [Fri, 3 Oct 2025 23:02:20 +0000 (07:02 +0800)] 
x86: Handle small OP size in setmem_epilogue_gen_val

Since OP size passed to setmem_epilogue_gen_val may be smaller than the
required vector size, duplicate it first before setting vector.

gcc/

PR target/122150
* config/i386/i386-expand.cc (setmem_epilogue_gen_val): Duplicate
OP if its size is smaller than MODE size.

gcc/testsuite/

PR target/122150
* gcc.target/i386/pr122150.c: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 months agoDisable some testcase for -Og
Andrew Pinski [Sun, 5 Oct 2025 20:30:49 +0000 (13:30 -0700)] 
Disable some testcase for -Og

Running the testsuite with ADDITIONAL_TORTURE_OPTIONS set include "-Og -g",
there are a few extra failures in the torture testsuite. These 2 failures
are expected so let's skip them in the same way for -O0.

asm-inline.c is because inlining does not happen as much at -Og.
restrict-8.c fails due to not building the points to aliasing info at -Og.

gcc/testsuite/ChangeLog:

* c-c++-common/torture/asm-inline.c: Disable at -Og.
* gcc.dg/torture/restrict-8.c: Likewise.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agohppa: Fix over alignment of 64-bit functions
John David Anglin [Sun, 5 Oct 2025 16:52:28 +0000 (12:52 -0400)] 
hppa: Fix over alignment of 64-bit functions

Both 32 and 64-bit assembly code needs 32-bit alignment.

2025-10-05  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

* config/pa/pa.h (FUNCTION_BOUNDARY): Set to 32.

2 months agoDaily bump.
GCC Administrator [Sun, 5 Oct 2025 16:50:51 +0000 (16:50 +0000)] 
Daily bump.

2 months agocontrib: Ignore commit b40ef6e9dc09 Sync toplevel files from binutils-gdb
Mark Wielaard [Sun, 5 Oct 2025 16:26:43 +0000 (18:26 +0200)] 
contrib: Ignore commit b40ef6e9dc09 Sync toplevel files from binutils-gdb

contrib/ChangeLog:

* gcc-changelog/git_update_version.py (ignored_commits): Add
commit b40ef6e9dc096c8c19399e94947a1965258a6942.

2 months ago*: regenerate autotools
Sam James [Sun, 5 Oct 2025 16:12:21 +0000 (17:12 +0100)] 
*: regenerate autotools

libatomic/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* testsuite/Makefile.in: Regenerate.

libcc1/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.

libffi/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* include/Makefile.in: Regenerate.
* man/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.

libgcobol/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.

libgfortran/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.

libgm2/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* libm2cor/Makefile.in: Regenerate.
* libm2iso/Makefile.in: Regenerate.
* libm2log/Makefile.in: Regenerate.
* libm2min/Makefile.in: Regenerate.
* libm2pim/Makefile.in: Regenerate.

libgomp/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* testsuite/Makefile.in: Regenerate.

libgrust/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* libformat_parser/Makefile.in: Regenerate.
* libproc_macro_internal/Makefile.in: Regenerate.

libitm/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* testsuite/Makefile.in: Regenerate.

libobjc/ChangeLog:

* aclocal.m4: Regenerate.
* configure: Regenerate.

libphobos/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* libdruntime/Makefile.in: Regenerate.
* src/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.

libquadmath/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.

libsanitizer/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* asan/Makefile.in: Regenerate.
* configure: Regenerate.
* hwasan/Makefile.in: Regenerate.
* interception/Makefile.in: Regenerate.
* libbacktrace/Makefile.in: Regenerate.
* lsan/Makefile.in: Regenerate.
* sanitizer_common/Makefile.in: Regenerate.
* tsan/Makefile.in: Regenerate.
* ubsan/Makefile.in: Regenerate.

libssp/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.

libstdc++-v3/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* doc/Makefile.in: Regenerate.
* include/Makefile.in: Regenerate.
* libsupc++/Makefile.in: Regenerate.
* po/Makefile.in: Regenerate.
* python/Makefile.in: Regenerate.
* src/Makefile.in: Regenerate.
* src/c++11/Makefile.in: Regenerate.
* src/c++17/Makefile.in: Regenerate.
* src/c++20/Makefile.in: Regenerate.
* src/c++23/Makefile.in: Regenerate.
* src/c++26/Makefile.in: Regenerate.
* src/c++98/Makefile.in: Regenerate.
* src/experimental/Makefile.in: Regenerate.
* src/filesystem/Makefile.in: Regenerate.
* src/libbacktrace/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.

libvtv/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* testsuite/Makefile.in: Regenerate.

lto-plugin/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.

2 months agoRISC-V: Combine vec_duplicate + vwaddu.wv to vwaddu.wx on GR2VR cost
Pan Li [Fri, 26 Sep 2025 15:08:20 +0000 (23:08 +0800)] 
RISC-V: Combine vec_duplicate + vwaddu.wv to vwaddu.wx on GR2VR cost

This patch would like to combine the vec_duplicate + vwaddu.wv to the
vwaddu.wx.  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 asm code like below, GR2VR cost is 0.

Before this patch:
  11       beq a3,zero,.L8
  12       vsetvli a5,zero,e32,m1,ta,ma
  13       vmv.v.x v2,a2
  ...
  16   .L3:
  17       vsetvli a5,a3,e32,m1,ta,ma
  ...
  22       vwaddu.wv v1,v2,v3
  ...
  25       bne a3,zero,.L3

After this patch:
  11       beq a3,zero,.L8
  ...
  14    .L3:
  15       vsetvli a5,a3,e32,m1,ta,ma
  ...
  20       vwaddu.wx v1,a2,v3
  ...
  23       bne a3,zero,.L3

Unfortunately, and similar as vwaddu.vv, only widening from uint32_t to
uint64_t has the necessary zero-extend during combine, we loss the extend
op after expand for any other types.

gcc/ChangeLog:

* config/riscv/autovec-opt.md (*widen_waddu_wx_<mode>): Add new
pattern to match vwaddu.wx.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 months agoMatch: Refactor unsigned SAT_MUL form 1 mul and widen-mul by for [NFC]
Pan Li [Thu, 25 Sep 2025 04:59:07 +0000 (12:59 +0800)] 
Match: Refactor unsigned SAT_MUL form 1 mul and widen-mul by for [NFC]

Inspired by the previous patch, the form 1 of unsigned SAT_MUL
can be mul or widen-mul based.  So we can leverage the keyword
for to group it, and avoid the pattern duplication.

The below test suites are passed for this patch:
1. The rv64gcv fully regression tests.
2. The x86 bootstrap tests.
3. The x86 fully regression tests.

gcc/ChangeLog:

* match.pd: Refactor the form 1 of SAT_MUL by keyword for.

Signed-off-by: Pan Li <pan2.li@intel.com>