]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
8 weeks agoFortran: Fix missing substring ref for allocatable saved vars [PR120483]
Andre Vehreschild [Mon, 2 Jun 2025 08:41:48 +0000 (10:41 +0200)] 
Fortran: Fix missing substring ref for allocatable saved vars [PR120483]

Compute a substring ref on an allocatable static character array
using pointer arithmetic.  Using an array type corrupts type
layouting and crashes omp generation.

PR fortran/120483

gcc/fortran/ChangeLog:

* trans-expr.cc (gfc_conv_substring): Use pointer arithmetic on
static allocatable char arrays.

gcc/testsuite/ChangeLog:

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

8 weeks agoRISC-V: Add Shlcofideleg extension.
Jiawei [Tue, 27 May 2025 06:37:03 +0000 (14:37 +0800)] 
RISC-V: Add Shlcofideleg extension.

This patch add the RISC-V Shlcofideleg extension. It supports delegating
LCOFI interrupts(the count-overflow interrupts) to VS-mode.[1]

[1] https://riscv.github.io/riscv-isa-manual/snapshot/privileged

gcc/ChangeLog:

* config/riscv/riscv-ext.def: New extension defs.
* config/riscv/riscv-ext.opt: Ditto.
* doc/riscv-ext.texi: Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/arch-shlocofideleg.c: New test.

Signed-off-by: Jiawei <jiawei@iscas.ac.cn>
8 weeks agoi386: Add more peephole2 for APX NDD
Hu, Lin1 [Mon, 10 Mar 2025 08:52:22 +0000 (16:52 +0800)] 
i386: Add more peephole2 for APX NDD

The patch aims to optimize
         movb    (%rdi), %al
         movq    %rdi, %rbx
         xorl    %esi, %eax, %edx
         movb    %dl, (%rdi)
         cmpb    %sil, %al
 jne
to
         xorb    %sil, (%rdi)
         movq    %rdi, %rbx
 jne

Reduce 2 mov and 1 cmp instructions.

Due to APX NDD allowing the dest register and source register to be different,
some original peephole2 are invalid. Add new peephole2 patterns for APX NDD.

gcc/ChangeLog:

* config/i386/i386.md (define_peephole2): Define some new peephole2 for
APX NDD.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr49095-2.c: New test.

8 weeks agoi386: Add more forms peephole2 for adc/sbb
Hu, Lin1 [Wed, 19 Feb 2025 07:51:40 +0000 (15:51 +0800)] 
i386: Add more forms peephole2 for adc/sbb

Enable -mapxf will change some patterns about adc/sbb.

Hence gcc will raise an extra mov like
         movq    8(%rdi), %rax
         adcq    %rax, 8(%rsi), %rax
         movq    %rax, 8(%rdi)
rather than
         movq    8(%rsi), %rax
         adcq    %rax, 8(%rdi)

The patch add more kinds of peephole2 to eliminate the extra mov.

gcc/ChangeLog:

* config/i386/i386.md: Add 4 new peephole2 by swap the original
peephole2's operands' order to support new pattern.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr79173-13.c: New test.
* gcc.target/i386/pr79173-14.c: Ditto.
* gcc.target/i386/pr79173-15.c: Ditto.
* gcc.target/i386/pr79173-16.c: Ditto.
* gcc.target/i386/pr79173-17.c: Ditto.
* gcc.target/i386/pr79173-18.c: Ditto.

8 weeks agoAlways add REG_CALL_DECL note for CALL
H.J. Lu [Mon, 2 Jun 2025 21:56:37 +0000 (05:56 +0800)] 
Always add REG_CALL_DECL note for CALL

Always add REG_CALL_DECL note for CALL so that get_call_fndecl works
without -fipa-ra.

PR other/120494
* calls.cc (expand_call): Always add REG_CALL_DECL note.
(emit_library_call_value_1): Likewise.

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

8 weeks agoFortran: ICE due to missing locus with data statement for coarray [PR99838]
Harald Anlauf [Tue, 3 Jun 2025 18:48:31 +0000 (20:48 +0200)] 
Fortran: ICE due to missing locus with data statement for coarray [PR99838]

PR fortran/99838

gcc/fortran/ChangeLog:

* data.cc (gfc_assign_data_value): For a new initializer use the
location from the constructor as fallback.

gcc/testsuite/ChangeLog:

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

8 weeks agoc: Enable -Wjump-misses-init for -Wc++-compat [PR120078]
Martin Uecker [Mon, 2 Jun 2025 11:57:03 +0000 (13:57 +0200)] 
c: Enable -Wjump-misses-init for -Wc++-compat [PR120078]

Fix a typo that prevented the warning from being activated with -Wc++compat.

PR c/120078

gcc/c-family/ChangeLog:
* c.opt (Wjump-misses-init): Fix typo.

gcc/testsuite/ChangeLog:
* gcc.dg/Wjump-misses-init-3.c: New test.

8 weeks agoc: Move checking assertions from recursion when forming composite types to avoid...
Martin Uecker [Sun, 1 Jun 2025 18:34:52 +0000 (20:34 +0200)] 
c: Move checking assertions from recursion when forming composite types to avoid ICE.

The checking assertion in composite_type_internal for structures and unions may
fail if there are self-referential types.  To avoid this, we move them out of
the recursion.  This should also be more efficient and covers other types.
We have to ignore some cases where we form composite types with qualifiers
not matching (PR120510).

gcc/c/ChangeLog:
* c-typeck.cc (composite_type_internal,composite_type): Move
checking assertions.

gcc/testsuite/ChangeLog:
* gcc.dg/gnu23-tag-composite-6.c: Update.

8 weeks agoc: fix ICE with enum completed with packed attribute after forward decl [PR116892]
Martin Uecker [Sun, 1 Jun 2025 20:30:42 +0000 (22:30 +0200)] 
c: fix ICE with enum completed with packed attribute after forward decl [PR116892]

After forward declaration of an enum and when completing it with the
attribute packed, we need to propagate TYPE_PACKED to all main variants.

PR c/116892

gcc/c/ChangeLog:
* c-decl.cc (finish_enum): Propagate TYPE_PACKED.

gcc/testsuite/ChangeLog:
* gcc.dg/pr116892.c: New test.

8 weeks agoc++: add -fno-modules to some tests
Jason Merrill [Thu, 21 Nov 2024 19:43:17 +0000 (20:43 +0100)] 
c++: add -fno-modules to some tests

These tests in the modules/ directory specifically want to test
behavior without modules enabled, so let's make that explicit.

gcc/testsuite/ChangeLog:

* g++.dg/modules/cpp-1.C
* g++.dg/modules/cpp-3.C
* g++.dg/modules/cpp-4.C: Specify -fno-modules.

8 weeks agoImprove create_tmp_reg_or_ssa_name, always create SSA name
Richard Biener [Tue, 3 Jun 2025 13:02:16 +0000 (15:02 +0200)] 
Improve create_tmp_reg_or_ssa_name, always create SSA name

In GIMPLE we can always use SSA names, so do that as it is cheaper.

* gimple-fold.cc (create_tmp_reg_or_ssa_name): Always
create a SSA name.

8 weeks agoc++: add operator| for WMB_Flags
Jason Merrill [Sat, 24 May 2025 18:41:43 +0000 (14:41 -0400)] 
c++: add operator| for WMB_Flags

There are a lot of uses of | on WMB_Flags, that currently need to then be
cast back to WMB_Flags.  Let's avoid the need for that.

gcc/cp/ChangeLog:

* name-lookup.h (operator|, operator|=): Define for WMB_Flags.

8 weeks agoRISC-V: Reconcile the existing test for vdiv.vx combine
Pan Li [Mon, 2 Jun 2025 13:21:18 +0000 (21:21 +0800)] 
RISC-V: Reconcile the existing test for vdiv.vx combine

Some existing vdiv related test need some adjust for the
asm check.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/binop/vdiv-rv32gcv-nofm.c: Adjust
the asm check for vdiv.
* gcc.target/riscv/rvv/autovec/binop/vdiv-rv32gcv.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vdiv-rv64gcv-nofm.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vdiv-rv64gcv.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
8 weeks agoRISC-V: Add test for vec_duplicate + vdiv.vv combine case 1 with GR2VR cost 0, 1...
Pan Li [Mon, 2 Jun 2025 09:03:02 +0000 (17:03 +0800)] 
RISC-V: Add test for vec_duplicate + vdiv.vv combine case 1 with GR2VR cost 0, 1 and 2

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

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pan Li <pan2.li@intel.com>
8 weeks agoRISC-V: Add test for vec_duplicate + vdiv.vv combine case 0 with GR2VR cost 0, 2...
Pan Li [Mon, 2 Jun 2025 09:01:27 +0000 (17:01 +0800)] 
RISC-V: Add test for vec_duplicate + vdiv.vv combine case 0 with GR2VR cost 0, 2 and 15

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

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i16.c: Add asm check
for vdiv.vx combine.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary_data.h: Add test
data for vdiv run test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vdiv-run-1-i16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vdiv-run-1-i32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vdiv-run-1-i64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vdiv-run-1-i8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
8 weeks agoRISC-V: Combine vec_duplicate + vidv.vv to vdiv.vx on GR2VR cost
Pan Li [Mon, 2 Jun 2025 08:56:59 +0000 (16:56 +0800)] 
RISC-V: Combine vec_duplicate + vidv.vv to vdiv.vx on GR2VR cost

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

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

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

  DEF_VX_BINARY(int32_t, /)

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

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

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_vx_binary_vec_vec_dup): Add new
case for DIV op.
* config/riscv/riscv.cc (get_vector_binary_rtx_cost): Add new func
to get the cost of vector binary.
(riscv_rtx_costs): Add div rtx match and leverage above wrap to
get cost.
* config/riscv/vector-iterators.md: Add new op div to no_shift_vx_op.

Signed-off-by: Pan Li <pan2.li@intel.com>
8 weeks agotree-optimization/120517 - fix dataref group split math
Richard Biener [Tue, 3 Jun 2025 12:09:22 +0000 (14:09 +0200)] 
tree-optimization/120517 - fix dataref group split math

DR_INIT is already measured in bytes, so there's no need to multiply
the DR_INIT difference of two DRs by the size of one of the DRs when
comparing that difference against MAX_BITSIZE_MODE_ANY_MODE.

PR tree-optimization/120517
* tree-vect-data-refs.cc (vect_analyze_data_ref_accesses):
Fix math in dataref group split.

8 weeks agolibstdc++: Check feature test macro for jthread in <stop_token>
Jonathan Wakely [Mon, 2 Jun 2025 22:25:43 +0000 (23:25 +0100)] 
libstdc++: Check feature test macro for jthread in <stop_token>

Check the appropriate feature test macro instead of checking that
__cplusplus >= 201703L.

libstdc++-v3/ChangeLog:

* include/std/stop_token: Check __glibcxx_jthread instead of
__cplusplus.

8 weeks agolibstdc++: Use new __is_destructible built-in in <type_traits>
Jonathan Wakely [Thu, 29 May 2025 12:50:08 +0000 (13:50 +0100)] 
libstdc++: Use new __is_destructible built-in in <type_traits>

libstdc++-v3/ChangeLog:

* include/std/type_traits (is_destructible, is_destructible_v):
Define using new built-in.
(is_nothrow_destructible, is_nothrow_destructible_v): Likewise.
(is_trivially_destructible, is_trivially_destructible_v):
Likewise.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
8 weeks agolibstdc++: Fix errors and incorrect returns in atomic timed waits
Jonathan Wakely [Mon, 2 Jun 2025 10:24:32 +0000 (11:24 +0100)] 
libstdc++: Fix errors and incorrect returns in atomic timed waits

The __detail::__wait_until function has a comment that should have been
removed when r16-1000-g225622398a9631 changed the return type from a
std::pair to a struct with three members.

The __atomic_wait_address_until_v and __atomic_wait_address_for_v
function templates are apparently never used or instantiated, because
they don't compile. This fixes them, but they're still unused.  I plan
to make use of them in a later commit.

In __atomic_wait_address_until_v, __res.first in the return statement
should have also been changed when r16-1000-g225622398a9631 changed
__wait_result_type, and &__args should have been changed to just __args
by r16-988-g219bb905a60d95.

In __atomic_wait_address_for_v, the parameter is a copy & paste error
and should use chrono::duration not chrono::time_point

Fix _M_spin_until_impl so that the _M_has_val member of the result is
accurate.  If the deadline has passed then it never enters the loop and
so never loads a fresh value, so _M_has_val should be false.  There's
also a redundant clock::now() call in __spin_until_impl which can be
removed, we can reuse the call immediately before it.

libstdc++-v3/ChangeLog:

* include/bits/atomic_timed_wait.h (__detail::__wait_until):
Remove incorrect comment.
(__atomic_wait_address_until_v): Do not take address of __args in
call to __detail::__wait_until. Fix return statement to refer to
member of __wait_result_type.
(__atomic_wait_address_for_v): Change parameter type from
time_point to duration.
* src/c++20/atomic.cc (__spin_until_impl): Fix incorrect
return value. Reuse result of first call to clock.

8 weeks agolibstdc++: Replace some implicit conversions in std::vector
Jonathan Wakely [Thu, 29 May 2025 10:40:59 +0000 (11:40 +0100)] 
libstdc++: Replace some implicit conversions in std::vector

This replaces two implicit conversions from ptrdiff_t to size_t with
explicit conversions that include unreachable hints for the ptrdiff_t
value not being negative.

libstdc++-v3/ChangeLog:

* include/bits/stl_vector.h (~_Vector_base): Add unreachable
hint for negative capacity and cast to size_t explicitly.
* include/bits/vector.tcc (vector::_M_realloc_append): Use
size() instead of end() - begin().

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
8 weeks agolibstdc++: Use explicit cast to unsigned in std::rotr and std::rotl
Jonathan Wakely [Thu, 29 May 2025 10:29:38 +0000 (11:29 +0100)] 
libstdc++: Use explicit cast to unsigned in std::rotr and std::rotl

This suppresses some -Wsign-conversion warnings from Clang when
compiling with -Wsystem-headers.

libstdc++-v3/ChangeLog:

* include/std/bit (__rotl, __rotr): Use static_cast for
conversion from int to unsigned.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
8 weeks agolibstdc++: Remove redundant macro checks in std.cc.in
Jonathan Wakely [Tue, 27 May 2025 15:54:52 +0000 (16:54 +0100)] 
libstdc++: Remove redundant macro checks in std.cc.in

__cpp_lib_any and __cpp_lib_chrono are defined unconditionally in C++20
and __cpp_lib_three_way_comparison and __cpp_lib_concepts depend on
front-end features which are definitely supported by GCC trunk and all
non-GCC compilers we care about.

libstdc++-v3/ChangeLog:

* src/c++23/std.cc.in: Remove redundant checks for feature test
macros that are always true.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
8 weeks agoRISC-V: Use helper function to get FPR to VR move cost
Paul-Antoine Arras [Wed, 28 May 2025 10:09:22 +0000 (12:09 +0200)] 
RISC-V: Use helper function to get FPR to VR move cost

Since last patch introduced get_fr2vr_cost () to get the correct cost to move
data from a floating-point to a vector register, this patch replaces existing
uses of the constant FR2VR.

gcc/ChangeLog:

* config/riscv/riscv-vector-costs.cc (costs::adjust_stmt_cost): Replace
FR2VR with get_fr2vr_cost ().
* config/riscv/riscv.cc (riscv_register_move_cost): Likewise.
(riscv_builtin_vectorization_cost): Likewise.

8 weeks agoRISC-V: Add pattern for vector-scalar multiply-add/sub [PR119100]
Paul-Antoine Arras [Mon, 12 May 2025 12:42:24 +0000 (14:42 +0200)] 
RISC-V: Add pattern for vector-scalar multiply-add/sub [PR119100]

This pattern enables the combine pass (or late-combine, depending on the case)
to merge a vec_duplicate into a plus-mult or minus-mult RTL instruction.

Before this patch, we have two instructions, e.g.:
  vfmv.v.f        v6,fa0
  vfmadd.vv       v9,v6,v7

After, we get only one:
  vfmadd.vf       v9,fa0,v7

On SPEC2017's 503.bwaves_r, depending on the workload, the reduction in dynamic
instruction count varies from -4.66% to -4.75%.

PR target/119100

gcc/ChangeLog:

* config/riscv/autovec-opt.md (*<optab>_vf_<mode>): Add new pattern to
combine vec_duplicate + vfm{add,sub}.vv into vfm{add,sub}.vf.
* config/riscv/riscv-opts.h (FPR2VR_COST_UNPROVIDED): Define.
* config/riscv/riscv-protos.h (get_fr2vr_cost): Declare function.
* config/riscv/riscv.cc (riscv_rtx_costs): Add cost model for MULT with
VEC_DUPLICATE.
(get_fr2vr_cost): New function.
* config/riscv/riscv.opt: Add new option --param=fpr2vr-cost.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vf-1-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-1-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-1-f64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-2-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-2-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-2-f64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-4-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-4-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-4-f64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_mulop.h: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_mulop_data.h: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_mulop_run.h: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmadd-run-1-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmadd-run-1-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmadd-run-1-f64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmsub-run-1-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmsub-run-1-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmsub-run-1-f64.c: New test.

8 weeks agox86: Add g++.target/i386/pr103750.C
H.J. Lu [Tue, 3 Jun 2025 09:17:57 +0000 (17:17 +0800)] 
x86: Add g++.target/i386/pr103750.C

Add a test for PR target/103750 fixed by r16-170-ga670ebde399548.

PR target/103750
* g++.target/i386/pr103750.C: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
8 weeks agolibgomp: Fix up omp_target_memset-3.c test for C++ [PR120444]
Jakub Jelinek [Tue, 3 Jun 2025 05:54:37 +0000 (07:54 +0200)] 
libgomp: Fix up omp_target_memset-3.c test for C++ [PR120444]

The test PASSes for C, but FAILs for C++:
.../libgomp.c-c++-common/omp_target_memset-3.c: In function 'void test_it(void*, int, size_t)':
.../libgomp.c-c++-common/omp_target_memset-3.c:31:7: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
.../libgomp.c-c++-common/omp_target_memset-3.c:33:13: error: invalid conversion from 'void*' to 'int8_t*' {aka 'signed char*'} [-fpermissive]
.../libgomp.c-c++-common/omp_target_memset-3.c:10:19: note: initializing argument 1 of 'void init_val(int8_t*, int, size_t)'
.../libgomp.c-c++-common/omp_target_memset-3.c:37:14: error: invalid conversion from 'void*' to 'int8_t*' {aka 'signed char*'} [-fpermissive]
.../libgomp.c-c++-common/omp_target_memset-3.c:17:20: note: initializing argument 1 of 'void check_val(int8_t*, int, size_t)'
.../libgomp.c-c++-common/omp_target_memset-3.c:38:18: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
.../libgomp.c-c++-common/omp_target_memset-3.c:38:18: error: invalid conversion from 'void*' to 'int8_t*' {aka 'signed char*'} [-fpermissive]
.../libgomp.c-c++-common/omp_target_memset-3.c:17:20: note: initializing argument 1 of 'void check_val(int8_t*, int, size_t)'
.../libgomp.c-c++-common/omp_target_memset-3.c: In function 'int main()':
.../libgomp.c-c++-common/omp_target_memset-3.c:46:7: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]

The following two-liner fixes that, tested on x86_64-linux and i686-linux.

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

PR libgomp/120444
* testsuite/libgomp.c-c++-common/omp_target_memset-3.c (test_it):
Change ptr argument type from void * to int8_t *.
(main): Change ptr variable type from void * to int8_t * and cast
omp_target_alloc result to the latter type.

8 weeks agophiprop: Add testcase for already fixed case [PR116824]
Andrew Pinski [Tue, 3 Jun 2025 03:50:44 +0000 (20:50 -0700)] 
phiprop: Add testcase for already fixed case [PR116824]

This testcase was fixed by r16-906-g8da568c885dc90. Since
this is a C testcase, it would be useful to have a C testcase besides
a C++ one too.

Tested for x86_64-linux-gnu.

PR tree-optimization/116824

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/phiprop-2.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
8 weeks agoswitch-conversion: Mark CSWTCH as mergeable [PR120451]
Andrew Pinski [Mon, 2 Jun 2025 22:56:20 +0000 (15:56 -0700)] 
switch-conversion: Mark CSWTCH as mergeable [PR120451]

When we have a smallish CSWTCH, it could be placed in the rodata.cst16
section so it can be merged with other constants across TUs.

The fix is simple; just mark the decl as mergable (DECL_MERGEABLE).
DECL_MERGEABLE was added with r14-1500-g4d935f52b0d5c0 specifically
to improve these kind of decls.

PR tree-optimization/120451

gcc/ChangeLog:

* tree-switch-conversion.cc (switch_conversion::build_one_array): Mark
the newly created decl as mergable.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/cswtch-6.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
8 weeks agoDaily bump.
GCC Administrator [Tue, 3 Jun 2025 00:18:06 +0000 (00:18 +0000)] 
Daily bump.

8 weeks ago[lra] force reg update after spilling to memory [PR120424]
Alexandre Oliva [Mon, 2 Jun 2025 23:21:45 +0000 (20:21 -0300)] 
[lra] force reg update after spilling to memory [PR120424]

In the added C++ testcase, a stack slot at a negative sp offset is
used to hold a value across a call.

There are a couple of causes that directly lead to this outcome:

- the -fstack-clash-protection and -fnon-call-exception options, that
cause arm_frame_pointer_required to flip from false to true when the
first pseudo gets spilled to memory;

- when the affected pseudo is spilled to memory, we fail to update lra
regno info, because the insns that reference it are already on the
lra_constraint_insn_stack;

There is another potentially-related issue:

- when we notice that the frame pointer can no longer be eliminated to
the stack pointer, we immediately clear can_eliminate, and also
prev_can_eliminate, but update_reg_eliminate relied on the latter to
tell that it needs to propagate a previous_offset to the
newly-selected elimination, or restore the original offsets.

This patch ensures that we update insn register info after spilling a
pseudo to memory, and enables update_reg_eliminate to recognize the
case in which a previously-preferred elimination is disabled
regardless of prev_can_eliminate.

for  gcc/ChangeLog

PR rtl-optimization/120424
PR middle-end/118939
* lra-spills.cc (spill_pseudos): Update insn regno info.
* lra-eliminations.cc (update_reg_eliminate): Recognize
disabling of active elimination regardless of
prev_can_eliminate.

for  gcc/testsuite/ChangeLog

PR rtl-optimization/120424
PR middle-end/118939
* g++.target/arm/pr120424.C: New.
* gnat.dg/controlled9.adb: New.
* gnat.dg/controlled9_pkg.ads: New.

8 weeks agocobol: Honor HAVE_CLOCK_GETTIME and HAVE_GETTIMEOFDAY. [PR119975]
Robert Dubner [Mon, 2 Jun 2025 19:55:20 +0000 (15:55 -0400)] 
cobol: Honor HAVE_CLOCK_GETTIME and HAVE_GETTIMEOFDAY. [PR119975]

These changes cause genapi.cc to use whichever of clock_gettime() or
gettimeofday() are available.  This prevents compilation errors on
systems where clock_gettime() is not available.

gcc/cobol/ChangeLog:

PR cobol/119975
* genapi.cc (parser_intrinsic_call_0): Use get_time_64() function.
* genutil.cc (get_time_64): Definition created.
* genutil.h (get_time_64): Declaration created.

8 weeks agoc++: more __is_destructible fixes [PR107600]
Jason Merrill [Mon, 2 Jun 2025 18:58:42 +0000 (14:58 -0400)] 
c++: more __is_destructible fixes [PR107600]

PR c++/107600

gcc/cp/ChangeLog:

* method.cc (destructible_expr): Fix refs and arrays of unknown
bound.

gcc/testsuite/ChangeLog:

* g++.dg/ext/is_destructible2.C: Add more cases.

8 weeks ago[PATCH] RISC-V: Add smcntrpmf extension.
Dongyan Chen [Mon, 2 Jun 2025 19:30:29 +0000 (13:30 -0600)] 
[PATCH] RISC-V: Add smcntrpmf extension.

This patch support smcntrpmf extension[1].
To enable GCC to recognize and process smcntrpmf extension correctly at compile time.

[1]https://github.com/riscvarchive/riscv-smcntrpmf

gcc/ChangeLog:

* config/riscv/riscv-ext.def: New extension defs.
* config/riscv/riscv-ext.opt: Ditto.
* doc/riscv-ext.texi: Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/arch-59.c: New test.

8 weeks agoc++: constinit diagnostic regression [PR120506]
Jason Merrill [Mon, 2 Jun 2025 14:59:02 +0000 (10:59 -0400)] 
c++: constinit diagnostic regression [PR120506]

In r16-57 I thought it was unnecessary to mention incomplete initialization
after another diagnostic, but actually it's useful elaboration.

PR c++/120506

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_outermost_constant_expr): Always check
CONSTRUCTOR_NO_CLEARING.

gcc/testsuite/ChangeLog:

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

8 weeks agoc++, coroutines: Some cleanups in build_actor.
Iain Sandoe [Sat, 31 May 2025 15:13:40 +0000 (16:13 +0100)] 
c++, coroutines: Some cleanups in build_actor.

We were incorrectly guarding all the frame cleanups on the
basis of frame_needs_free (which is always set for the present
code-gen since we have no allocation elision).  The net result
being that the (incorrect) code was behaving as expected.

We built, but never used, a label for the frame destruction;
in practice it is never triggered independently of the promise
and argument copy destruction.

Finally there are a few instances where we had been building
expressions manually rather than using higher-level APIs.

gcc/cp/ChangeLog:

* coroutines.cc (build_actor_fn): Remove an unused
label, guard the frame deallocation correctly, use
simpler APIs to build if and return statements.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
8 weeks agoc++: Emit an error for attempted constexpr co_await [PR118903].
Iain Sandoe [Fri, 30 May 2025 19:09:40 +0000 (20:09 +0100)] 
c++: Emit an error for attempted constexpr co_await [PR118903].

We checked that the coroutine expressions were not suitable for
constexpr, but did not emit and error when needed.

PR c++/118903

gcc/cp/ChangeLog:

* constexpr.cc (potential_constant_expression_1): Emit
an error when co_await et. al. are used in constexpr
contexts.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
8 weeks agoc++: Add co_await, co_yield and co_return to dump_expr.
Iain Sandoe [Fri, 30 May 2025 19:06:26 +0000 (20:06 +0100)] 
c++: Add co_await, co_yield and co_return to dump_expr.

These were omitted there as an oversight, most of the error handling
for the coroutines code is specific rather than using generic %qE etc.

gcc/cp/ChangeLog:

* error.cc (dump_expr): Add co_await, co_yield and co_return.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
8 weeks agolibstdc++: Remove spaces before function parameter list
Jonathan Wakely [Thu, 29 May 2025 10:33:54 +0000 (11:33 +0100)] 
libstdc++: Remove spaces before function parameter list

We don't use this GCC coding convention in libstdc++.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h (basic_string::size): Remove space
before parameter list.
(basic_string::capacity): Likewise.
* include/bits/stl_deque.h (deque::size): Likewise.
* include/bits/stl_vector.h (vector::size, vector::capacity):
Likewise.
* include/bits/vector.tcc (vector::_M_realloc_insert): Likewise.
(vector::_M_realloc_append): Likewise.

8 weeks agolibstdc++: Implement LWG 2439 for std::unique_copy [PR120386]
Jonathan Wakely [Wed, 21 May 2025 19:12:50 +0000 (20:12 +0100)] 
libstdc++: Implement LWG 2439 for std::unique_copy [PR120386]

The current overload set for __unique_copy handles three cases:

- The input range uses forward iterators, the output range does not.
  This is the simplest case, and can just compare adjacent elements of
  the input range.

- Neither the input range nor output range use forward iterators.
  This requires a local variable copied from the input range and updated
  by assigning each element to the local variable.

- The output range uses forward iterators.
  For this case we compare the current element from the input range with
  the element just written to the output range.

There are two problems with this implementation. Firstly, the third case
assumes that the value type of the output range can be compared to the
value type of the input range, which might not be possible at all, or
might be possible but give different results to comparing elements of
the input range. This is the problem identified in LWG 2439.

Secondly, the third case is used when both ranges use forward iterators,
even though the first case could (and should) be used. This means that
we compare elements from the output range instead of the input range,
with the problems described above (either not well-formed, or might give
the wrong results).

The cause of the second problem is that the overload for the first case
looks like:

OutputIterator
__unique_copy(ForwardIter, ForwardIter, OutputIterator, BinaryPred,
              forward_iterator_tag, output_iterator_tag);

When the output range uses forward iterators this overload cannot be
used, because forward_iterator_tag does not inherit from
output_iterator_tag, so is not convertible to it.

To fix these problems we need to implement the resolution of LWG 2439 so
that the third case is only used when the value types of the two ranges
are the same. This ensures that the comparisons are well behaved. We
also need to ensure that the first case is used when both ranges use
forward iterators.

This change replaces a single step of tag dispatching to choose between
three overloads with two step of tag dispatching, choosing between two
overloads at each step. The first step dispatches based on the iterator
category of the input range, ignoring the category of the output range.
The second step only happens when the input range uses non-forward
iterators, and dispatches based on the category of the output range and
whether the value type of the two ranges is the same. So now the cases
that are handled are:

- The input range uses forward iterators.
- The output range uses non-forward iterators or a different value type.
- The output range uses forward iterators and has the same value type.

For the second case, the old code used __gnu_cxx::__ops::__iter_comp_val
to wrap the predicate in another level of indirection. That seems
unnecessary, as we can just use a pointer to the local variable instead
of an iterator referring to it.

During review of this patch, it was discovered that all known
implementations of std::unique_copy and ranges::unique_copy (except
cmcstl2) disagree with the specification. The standard (and the SGI STL
documentation) say that it uses pred(*i, *(i-1)) but everybody uses
pred(*(i-1), *i) instead, and apparently always has done. This patch
adjusts ranges::unique_copy to be consistent.

In the first __unique_copy overload, the local copy of the iterator is
changed to be the previous position not the next one, so that we use
++first as the "next" iterator, consistent with the logic used in the
other overloads. This makes it easier to compare them, because we aren't
using pred(*first, *next) in one and pred(something, *first) in the
others. Instead it's always pred(something, *first).

libstdc++-v3/ChangeLog:

PR libstdc++/120386
* include/bits/ranges_algo.h (__unique_copy_fn): Reorder
arguments for third case to match the first two cases.
* include/bits/stl_algo.h (__unique_copy): Replace three
overloads with two, depending only on the iterator category of
the input range.  Dispatch to __unique_copy_1 for the
non-forward case.
(__unique_copy_1): New overloads for the case where the input
range uses non-forward iterators.
(unique_copy): Only pass the input range category to
__unique_copy.
* testsuite/25_algorithms/unique_copy/lwg2439.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
8 weeks agolibgomp: Add OpenMP's omp_target_memset/omp_target_memset_async
Tobias Burnus [Mon, 2 Jun 2025 15:43:57 +0000 (17:43 +0200)] 
libgomp: Add OpenMP's omp_target_memset/omp_target_memset_async

PR libgomp/120444

include/ChangeLog:

* cuda/cuda.h (cuMemsetD8, cuMemsetD8Async): Declare.

libgomp/ChangeLog:

* libgomp-plugin.h (GOMP_OFFLOAD_memset): Declare.
* libgomp.h (struct gomp_device_descr): Add memset_func.
* libgomp.map (GOMP_6.0.1): Add omp_target_memset{,_async}.
* libgomp.texi (Device Memory Routines): Document them.
* omp.h.in (omp_target_memset, omp_target_memset_async): Declare.
* omp_lib.f90.in (omp_target_memset, omp_target_memset_async):
Add interfaces.
* omp_lib.h.in (omp_target_memset, omp_target_memset_async): Likewise.
* plugin/cuda-lib.def: Add cuMemsetD8.
* plugin/plugin-gcn.c (struct hsa_runtime_fn_info): Add
hsa_amd_memory_fill_fn.
(init_hsa_runtime_functions): DLSYM_OPT_FN load it.
(GOMP_OFFLOAD_memset): New.
* plugin/plugin-nvptx.c (GOMP_OFFLOAD_memset): New.
* target.c (omp_target_memset_int, omp_target_memset,
omp_target_memset_async_helper, omp_target_memset_async): New.
(gomp_load_plugin_for_device): Add DLSYM (memset).
* testsuite/libgomp.c-c++-common/omp_target_memset.c: New test.
* testsuite/libgomp.c-c++-common/omp_target_memset-2.c: New test.
* testsuite/libgomp.c-c++-common/omp_target_memset-3.c: New test.
* testsuite/libgomp.fortran/omp_target_memset.f90: New test.
* testsuite/libgomp.fortran/omp_target_memset-2.f90: New test.

8 weeks agoc++: __is_destructible fixes [PR107600]
Jason Merrill [Mon, 2 Jun 2025 14:09:07 +0000 (10:09 -0400)] 
c++: __is_destructible fixes [PR107600]

destructible_expr was wrongly assuming that TO is a class type.

When is_xible_helper was added in r8-742 it returned early for abstract
class types, which is correct for __is_constructible, but not
__is_assignable or (now) __is_destructible.

PR c++/107600

gcc/cp/ChangeLog:

* method.cc (destructible_expr): Handle non-classes.
(constructible_expr): Check for abstract class here...
(is_xible_helper): ...not here.

gcc/testsuite/ChangeLog:

* g++.dg/ext/is_destructible2.C: New test.

8 weeks agoc++: __has_trivial_destructor regression
Jason Merrill [Mon, 2 Jun 2025 12:36:22 +0000 (08:36 -0400)] 
c++: __has_trivial_destructor regression

We don't want the new call to get_dtor to cause function instantiation.

PR c++/107600

gcc/cp/ChangeLog:

* semantics.cc (trait_expr_value) [CPTK_HAS_TRIVIAL_DESTRUCTOR]:
Add cp_unevaluated.

gcc/testsuite/ChangeLog:

* g++.dg/ext/has_trivial_destructor-3.C: New test.

8 weeks agolibstdc++: Pass small trivial types by value in polymorphic wrappers
Tomasz Kamiński [Wed, 28 May 2025 09:16:22 +0000 (11:16 +0200)] 
libstdc++: Pass small trivial types by value in polymorphic wrappers

This patch adjust the passing of parameters for the move_only_function,
copyable_function and function_ref. For types that are declared as being passed
by value in signature template argument, they are passed by value to the invoker,
when they are small (at most two pointers), trivially move constructible and
trivially destructible. The latter guarantees that passing them by value has not
user visible side effects.

In particular, this extends the set of types forwarded by value, that was
previously limited to scalars, to also include specializations of std::span and
std::string_view, and similar standard and program defined-types.

Checking the suitability of the parameter types requires the types to be complete.
As a consequence, the implementation imposes requirements on instantiation of
move_only_function and copyable_function. To avoid producing the errors from
the implementation details, a static assertion was added to partial
specializations of copyable_function, move_only_function and function_ref.
The static assertion uses existing __is_complete_or_unbounded, as arrays type
parameters are automatically decayed in function type.

Standard already specifies in [res.on.functions] p2.5 that instantiating these
partial specialization with incomplete types leads to undefined behavior.

libstdc++-v3/ChangeLog:

* include/bits/funcwrap.h (__polyfunc::__pass_by_rref): Define.
(__polyfunc::__param_t): Update to use __pass_by_rref.
* include/bits/cpyfunc_impl.h:: Assert that are parameters type
are complete.
* include/bits/funcref_impl.h: Likewise.
* include/bits/mofunc_impl.h: Likewise.
* testsuite/20_util/copyable_function/call.cc: New test.
* testsuite/20_util/function_ref/call.cc: New test.
* testsuite/20_util/move_only_function/call.cc: New test.
* testsuite/20_util/copyable_function/conv.cc: New test.
* testsuite/20_util/function_ref/conv.cc: New test.
* testsuite/20_util/move_only_function/conv.cc: New test.
* testsuite/20_util/copyable_function/incomplete_neg.cc: New test.
* testsuite/20_util/function_ref/incomplete_neg.cc: New test.
* testsuite/20_util/move_only_function/incomplete_neg.cc: New test.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
8 weeks agolibstdc++: Implement C++26 std::polymorphic [PR119152]
Jonathan Wakely [Tue, 27 May 2025 09:38:41 +0000 (11:38 +0200)] 
libstdc++: Implement C++26 std::polymorphic [PR119152]

This patch implements C++26 std::polymorphic as specified in P3019 with
amendment to move assignment from LWG 4251.

The implementation always allocate stored object on the heap. The manager
function (_M_manager) is similary keep with the object (polymorphic::_Obj),
which reduces the size of the polymorphic to size of the single pointer plus
allocator (that is declared with [[no_unique_address]]).

The implementation does not not use small-object optimization (SSO). We may
consider adding this in the future, as SSO is allowed by the standard. However,
storing any polimorphic object will require providing space for two pointers
(manager function and vtable pointer) and user-declared data members.

PR libstdc++/119152

libstdc++-v3/ChangeLog:

* include/bits/indirect.h (std::polymorphic, pmr::polymorphic)
[__glibcxx_polymorphic]: Define.
* include/bits/version.def (polymorphic): Define.
* include/bits/version.h: Regenerate.
* include/std/memory: Define __cpp_lib_polymorphic.
* testsuite/std/memory/polymorphic/copy.cc: New test.
* testsuite/std/memory/polymorphic/copy_alloc.cc: New test.
* testsuite/std/memory/polymorphic/ctor.cc: New test.
* testsuite/std/memory/polymorphic/ctor_poly.cc: New test.
* testsuite/std/memory/polymorphic/incomplete.cc: New test.
* testsuite/std/memory/polymorphic/invalid_neg.cc: New test.
* testsuite/std/memory/polymorphic/move.cc: New test.
* testsuite/std/memory/polymorphic/move_alloc.cc: New test.

Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
8 weeks agoor1k: Fix struct return test
Stafford Horne [Sat, 31 May 2025 05:54:58 +0000 (06:54 +0100)] 
or1k: Fix struct return test

In or1k structs are returned from functions using the memory address
passed in r3.  In the current version of GCC the struct stores changed
from r11 (the return value) to r3 the incoming memory address.  Both of
are valid.

Adjust the test to match what GCC is producing now.

gcc/testsuite/ChangeLog:

* gcc.target/or1k/return-2.c: Fix test.

8 weeks agoor1k: Support long jump offsets with -mcmodel=large
Stafford Horne [Mon, 12 May 2025 20:47:21 +0000 (21:47 +0100)] 
or1k: Support long jump offsets with -mcmodel=large

The -mcmodel=large option was originally added to handle generation of
large binaries with large PLTs.  However, when compiling the Linux
kernel with allyesconfig the output binary is so large that the jump
instruction 26-bit immediate is not large enough to store the jump
offset to some symbols when linking.  Example error:

  relocation truncated to fit: R_OR1K_INSN_REL_26 against symbol `do_fpe_trap' defined in .text section in arch/openrisc/kernel/traps.o

We fix this by forcing jump offsets to registers when -mcmodel=large.

Note, to get the Linux kernel allyesconfig config to work with OpenRISC,
this patch is needed along with some other patches to the Linux hand
coded assembly bits.

gcc/ChangeLog:

* config/or1k/predicates.md (call_insn_operand): Add condition
to not allow symbol_ref operands with TARGET_CMODEL_LARGE.
* config/or1k/or1k.opt: Document new -mcmodel=large
implications.
* doc/invoke.texi: Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/or1k/call-1.c: New test.
* gcc.target/or1k/got-1.c: New test.

8 weeks agotestsuite: Add tls_link effective target
Christophe Lyon [Thu, 17 Apr 2025 15:55:14 +0000 (15:55 +0000)] 
testsuite: Add tls_link effective target

Some tests have 'dg-do link' but currently require 'tls' which is a
compile-only check.

In some configurations of arm-none-eabi, the 'tls' effective-target
can be successful although these tests fail to link with
undefined reference to `__aeabi_read_tp'

This patch as a new tls_link effective target which makes sure we can
build an executable.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_effective_target_tls_link): New.
* g++.dg/tls/pr102496-1.C: Require tls_link.
* g++.dg/tls/pr77285-1.C: Likewise.

gcc/ChangeLog:

* doc/sourcebuild.texi (tls_link): Add documentation.

8 weeks agoRISC-V: Adjust build rule for gen-riscv-ext-opt and gen-riscv-ext-texi
Kito Cheng [Wed, 28 May 2025 09:59:11 +0000 (17:59 +0800)] 
RISC-V: Adjust build rule for gen-riscv-ext-opt and gen-riscv-ext-texi

Separate the build rules to compile and link stage to make sure
BUILD_LINKERFLAGS and BUILD_LDFLAGS are applied correctly.

We hit this issue when we try to build GCC with non-system-default g++,
and it use newer libstdc++, and then got error from using older libstdc++ from
system, that should not happened if we link with -static-libgcc and
-static-libstdc++.

gcc/ChangeLog:

* config/riscv/t-riscv: Adjust build rule for gen-riscv-ext-opt
and gen-riscv-ext-texi.

8 weeks agoc++tools: Don't check --enable-default-pie.
Kito Cheng [Tue, 27 May 2025 02:10:15 +0000 (10:10 +0800)] 
c++tools: Don't check --enable-default-pie.

`--enable-default-pie` is an option to specify whether to enable
position-independent executables by default for `target`.

However c++tools is build for `host`, so it should just follow
`--enable-host-pie` option to determine whether to build with
position-independent executables or not.

NOTE:

I checked PR 98324 and build with same configure option
(`--enable-default-pie` and lto bootstrap) on x86-64 linux to make sure
it won't cause same problem.

c++tools/ChangeLog:

* configure.ac: Don't check `--enable-default-pie`.
* configure: Regen.

8 weeks agoRISC-V: Implement full-featured iterator for riscv_subset_list [NFC]
Kito Cheng [Mon, 26 May 2025 06:43:47 +0000 (14:43 +0800)] 
RISC-V: Implement full-featured iterator for riscv_subset_list [NFC]

This commit implements a full-featured iterator for the
riscv_subset_list, that it able to use range-based-for-loop.

That could simplfy the code in the future, and make it more readable,
also more compatible with standard C++ containers.

gcc/ChangeLog:

* config/riscv/riscv-c.cc (riscv_cpu_cpp_builtins): Use
range-based-for-loop.
* config/riscv/riscv-subset.h (riscv_subset_list::iterator):
New.
(riscv_subset_list::const_iterator): New.

8 weeks agoOpenMP: Handle more cases in user/condition selector
Sandra Loosemore [Mon, 2 Jun 2025 03:26:42 +0000 (03:26 +0000)] 
OpenMP: Handle more cases in user/condition selector

Tobias had noted that the C front end was not treating C23 constexprs
as constant in the user/condition selector property, which led to
missed opportunities to resolve metadirectives at parse time.
Additionally neither C nor C++ was permitting the expression to have
pointer or floating-point type -- the former being a common idiom in
other C/C++ conditional expressions.  By using the existing front-end
hooks for the implicit conversion to bool in conditional expressions,
we also get free support for using a C++ class object that has a bool
conversion operator in the user/condition selector.

gcc/c/ChangeLog
* c-parser.cc (c_parser_omp_context_selector): Call
convert_lvalue_to_rvalue and c_objc_common_truthvalue_conversion
on the expression for OMP_TRAIT_PROPERTY_BOOL_EXPR.

gcc/cp/ChangeLog
* cp-tree.h (maybe_convert_cond): Declare.
* parser.cc (cp_parser_omp_context_selector): Call
maybe_convert_cond and fold_build_cleanup_point_expr on the
expression for OMP_TRAIT_PROPERTY_BOOL_EXPR.
* pt.cc (tsubst_omp_context_selector): Likewise.
* semantics.cc (maybe_convert_cond): Remove static declaration.

gcc/testsuite/ChangeLog
* c-c++-common/gomp/declare-variant-2.c: Update expected output.
* c-c++-common/gomp/metadirective-condition-constexpr.c: New.
* c-c++-common/gomp/metadirective-condition.c: New.
* c-c++-common/gomp/metadirective-error-recovery.c: Update expected
output.
* g++.dg/gomp/metadirective-condition-class.C: New.
* g++.dg/gomp/metadirective-condition-template.C: New.

8 weeks ago[PATCH] testsuite: RISC-V: Fix the typo in param-autovec-mode.c
Liao Shihua [Mon, 2 Jun 2025 03:11:25 +0000 (21:11 -0600)] 
[PATCH] testsuite: RISC-V: Fix the typo in param-autovec-mode.c

This patch fixes the typo in the test case `param-autovec-mode.c` in the RISC-V
autovec testsuite.

The option `autovec-mode` is changed to `riscv-autovec-mode` to match the
expected parameter name.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/param-autovec-mode.c: Change
`autovec-mode` to `riscv-autovec-mode` in dg-options.

8 weeks agoDaily bump.
GCC Administrator [Mon, 2 Jun 2025 00:16:29 +0000 (00:16 +0000)] 
Daily bump.

8 weeks agoMove get_call_rtx_from to final.c
H.J. Lu [Sun, 1 Jun 2025 01:29:48 +0000 (09:29 +0800)] 
Move get_call_rtx_from to final.c

Move get_call_rtx_from to final.c and call call_from_call_insn.

PR other/120493
* final.cc (call_from_call_insn): Change the argument type to
const rtx_call_insn *.
(get_call_rtx_from): New.
* rtl.h (is_a_helper <const rtx_call_insn *>::test): New.
(get_call_rtx_from): Moved to the final.cc section.
* rtlanal.cc (get_call_rtx_from): Removed.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
8 weeks agoFortran: Fix handling of parsed format strings.
Jerry DeLisle [Sat, 31 May 2025 15:57:22 +0000 (08:57 -0700)] 
Fortran: Fix handling of parsed format strings.

Previously parsed strings with errors were being cached such
that subsequent use of the format string were not being
checked for errors.

PR libfortran/119856

libgfortran/ChangeLog:

* io/format.c (parse_format_list): Set the fmt->error
message for missing comma.
(parse_format): Do not cache the parsed format string
if a previous error ocurred.

gcc/testsuite/ChangeLog:

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

8 weeks agoforwprop: Manually rename the virtual mem op for complex and vector loads prop
Andrew Pinski [Sat, 31 May 2025 22:10:14 +0000 (15:10 -0700)] 
forwprop: Manually rename the virtual mem op for complex and vector loads prop

There are two places which forwprop replaces an original load to a few different loads.
Both can set the vuse manually instead of relying on update_ssa.
One is doing a complex load followed by REAL/IMAG_PART only
And the other is very similar but for vector loads followed by BIT_FIELD_REF.

Since this was the last place that needed to handle updating the ssa form,
Remove the TODO_update_ssa also from the pass.

gcc/ChangeLog:

* tree-ssa-forwprop.cc (optimize_vector_load): Set the vuse manually
on the new load statements. Also remove forward declaration since
the definition is before the first use.
(pass_forwprop::execute): Likewise for complex loads.
(pass_data_forwprop): Remove TODO_update_ssa.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
8 weeks agocobol: Wrap the call to fprintf in a libgcobol routine. [PR119524]
Robert Dubner [Sun, 1 Jun 2025 16:32:37 +0000 (12:32 -0400)] 
cobol: Wrap the call to fprintf in a libgcobol routine. [PR119524]

gcc/cobol/ChangeLog:

PR cobol/119524
* gengen.cc (gg_printf): Use the new __gg__fprintf_stderr() function
instead of generating a call to fprintf().

libgcobol/ChangeLog:

PR cobol/119524
* libgcobol.cc (__gg__fprintf_stderr): New function.

8 weeks agoPR modula2/120474: InOut buffering should flush the WriteLn before the Read
Gaius Mulley [Sun, 1 Jun 2025 10:25:25 +0000 (11:25 +0100)] 
PR modula2/120474: InOut buffering should flush the WriteLn before the Read

This patch adds a BufferFlush to InOut.mod:LocalWrite.

gcc/m2/ChangeLog:

PR modula2/120474
* gm2-libs-log/InOut.mod (LocalWrite): Call FIO.FlushBuffer.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
8 weeks agoc: fix ICE related to tagged types with attributes in diagnostics [PR120380]
Martin Uecker [Thu, 29 May 2025 15:17:12 +0000 (17:17 +0200)] 
c: fix ICE related to tagged types with attributes in diagnostics [PR120380]

get_aka_type will create a new type for diagnostics, but for tagged types
attributes will then be ignored with a warning.  This can lead to reentering
warning code which leads to an ICE.  Fix this by ignoring the attributes
for tagged types.

PR c/120380

gcc/c/ChangeLog:
* c-objc-common.cc (get_aka_type): Ignore attributes for tagged types.

gcc/testsuite/ChangeLog:
* gcc.dg/pr120380.c: New test.

8 weeks agoc++: rename PR120123 test
Jason Merrill [Sun, 1 Jun 2025 03:10:44 +0000 (23:10 -0400)] 
c++: rename PR120123 test

As Patrick points out (and I had realized after pushing it), this testcase
has nothing to do with explicit object parameters.

PR c++/120123

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/explicit-obj-lambda18.C: Move to...
* g++.dg/cpp2a/concepts-lambda24.C: ...here.

8 weeks agoRISC-V: Fix line too long format issue for autovect.md [NFC]
Pan Li [Sat, 31 May 2025 03:01:06 +0000 (11:01 +0800)] 
RISC-V: Fix line too long format issue for autovect.md [NFC]

Inspired by the avg_ceil patches, notice there were even more
lines too long from autovec.md.  So fix that format issues.

gcc/ChangeLog:

* config/riscv/autovec.md: Fix line too long for sorts
of pattern.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 months agoxtensa: Remove include of reload.h
Takayuki 'January June' Suwa [Tue, 27 May 2025 06:59:21 +0000 (15:59 +0900)] 
xtensa: Remove include of reload.h

As one of the last steps in removing old reload.

gcc/ChangeLog:

* config/xtensa/xtensa.cc: Remove include of reload.h.

2 months agoxtensa: Remove an unnecessary constraint modifier from movsf_internal insn pattern
Takayuki 'January June' Suwa [Tue, 27 May 2025 06:58:35 +0000 (15:58 +0900)] 
xtensa: Remove an unnecessary constraint modifier from movsf_internal insn pattern

In this case, there is no need to consider reloading when memory is the
destination.  On the other hand, when memory is the source, reloading
read from constant pool becomes double indirection and should obviously
be avoided.

gcc/ChangeLog:

* config/xtensa/xtensa.md (movsf_internal):
Remove destination side constraint modifier '^' in the third
alternative.

2 months agoxtensa: Implement TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS
Takayuki 'January June' Suwa [Tue, 27 May 2025 06:57:26 +0000 (15:57 +0900)] 
xtensa: Implement TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS

Implement TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS in order to avoid using
ALL_REGS rclass as is done on other targets, instead of overestimating
between integer and FP register move costs.

gcc/ChangeLog:

* config/xtensa/xtensa.cc
(xtensa_ira_change_pseudo_allocno_class):
New prototype and function.
(TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS): Define macro.
(xtensa_register_move_cost):
Change between integer and FP register move cost to a value
based on actual behavior, i.e. 2, the default and the same as
the move cost between integer registers.

2 months agoDaily bump.
GCC Administrator [Sun, 1 Jun 2025 00:17:06 +0000 (00:17 +0000)] 
Daily bump.

2 months agoPR modula2/120497: error is generated for good code when returning a pointer var...
Gaius Mulley [Sun, 1 Jun 2025 00:05:55 +0000 (01:05 +0100)] 
PR modula2/120497: error is generated for good code when returning a pointer var variable

The return type checking needs to skip over the Lvalue part of the VAR
parameter or variable.

gcc/m2/ChangeLog:

PR modula2/120497
* gm2-compiler/M2Range.mod (IsAssignmentCompatible): Remove from
import list.
(FoldTypeReturnFunc): Rewrite to skip the Lvalue of a var
variable.
(CodeTypeReturnFunc): Ditto.
(CodeTypeIndrX): Call AssignmentTypeCompatible rather than
IsAssignmentCompatible.
(FoldTypeIndrX): Ditto.

gcc/testsuite/ChangeLog:

PR modula2/120497
* gm2/pim/pass/ReturnType.mod: New test.
* gm2/pim/pass/ReturnType2.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2 months agoHave TODO_verify_* not set by any pass
Andrew Pinski [Fri, 30 May 2025 06:50:08 +0000 (23:50 -0700)] 
Have TODO_verify_* not set by any pass

This is a follow up to the patch set starting at https://gcc.gnu.org/pipermail/gcc-patches/2014-April/386650.html.

Currently TODO_verify_{il,all} is set by a few passes as TODOs afterwards but
we don't need to do that any more. Those were mostly removed back in
https://gcc.gnu.org/pipermail/gcc-patches/2014-May/387647.html

And now since TODO_verify_all is no longer used, remove it too.
Removes last_verified from the function structure since it is always 0 before the
call to execute_todo that has TODO_verify_all set on it.

Also this removes the ability for good to use TODO_verify_il from the passes and reserves
bit 31 of the TODO for the verfification and internally only the passes.cc code.

gcc/ChangeLog:

* function.h (struct function): Remove last_verified.
* gimple-harden-conditionals.cc (pass_data_harden_compares): Remove
TODO_verify_il.
(pass_data_harden_conditional_branches): Likewise.
* gimple-harden-control-flow.cc (pass_harden_control_flow_redundancy::execute):
Don't return TODO_verify_il.
* ipa-strub.cc (pass_data_ipa_strub): Remove TODO_verify_il.
* passes.cc (TODO_verify_il): Define.
(execute_function_todo): Don't use or set last_verified.
(clear_last_verified): Remove.
(execute_one_ipa_transform_pass): Update comment before execute_todo.
Assert that none of the todos have TODO_verify_il set on it.
(execute_one_pass): Don't call clear_last_verified on all functions.
Assert that none of the todos have TODO_verify_il set on it.
* tree-inline.cc (initialize_cfun): Don't copy last_verified.
* tree-pass.h (TODO_verify_all): Remove.
* tree-vrp.cc (pass_data_early_vrp): Remove TODO_verify_all.
(pass_data_fast_vrp): Likewise.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 months agotree-optimization/120357 - ICE with early break vectorization
Richard Biener [Fri, 30 May 2025 12:11:47 +0000 (14:11 +0200)] 
tree-optimization/120357 - ICE with early break vectorization

When doing early break vectorization of a loop with a conditional
reduction the epilog creation code is confused as to before which exit
to insert the conditional reduction induction IV update.  The
following make sure this is done before the main IV exit.

PR tree-optimization/120357
* tree-vect-loop.cc (vect_create_epilog_for_reduction): Create
the conditional reduction induction IV increment before the
main IV exit.

* gcc.dg/vect/vect-early-break_136-pr120357.c: New testcase.

2 months agoPR modula2/120389 Assigning wrong type to an array causes an ICE
Gaius Mulley [Sat, 31 May 2025 00:53:48 +0000 (01:53 +0100)] 
PR modula2/120389 Assigning wrong type to an array causes an ICE

This patch provides follow on fixes for undetected type violations
which can occur then Lvalues are generated during assignment.
For example array accesses and with statements.  The type checker
M2Check.mod has been overhauled and cleaned up.

gcc/ChangeLog:

PR modula2/120389
* doc/gm2.texi (-fm2-strict-type-reason): Document new flag.

gcc/m2/ChangeLog:

PR modula2/120389
* gm2-compiler/M2Check.def (AssignmentTypeCompatible): Add new
parameter enableReason.
* gm2-compiler/M2Check.mod (EquivalenceProcedure): New type.
(falseReason2): New procedure function.
(falseReason1): Ditto.
(falseReason0): Ditto.
(checkTypeEquivalence): Rewrite.
(checkUnboundedArray): Ditto.
(checkUnbounded): Ditto.
(checkArrayTypeEquivalence): Ditto.
(checkCharStringTypeEquivalence): Ditto.
(buildError4): Add false reason.
(buildError2): Ditto.
(IsTyped): Use GetDType.
(IsTypeEquivalence): New procedure function.
(checkVarTypeEquivalence): Ditto.
(checkVarEquivalence ): Rewrite.
(checkConstMeta): Ditto.
(checkEnumField): New procedure function.
(checkEnumFieldEquivalence): Ditto.
(checkSubrangeTypeEquivalence): Rewrite.
(checkSystemEquivalence): Ditto.
(checkTypeKindViolation): Ditto.
(doCheckPair): Ditto.
(InitEquivalenceArray): New procedure.
(addEquivalence): Ditto.
(checkProcType): Rewrite.
(deconstruct): Deallocate reason string.
(AssignmentTypeCompatible): Initialize reason and reasonEnable
fields.
(ParameterTypeCompatible): Ditto.
(doExpressionTypeCompatible): Ditto.
* gm2-compiler/M2GenGCC.mod (CodeIndrX) Rewrite.
(CheckBinaryExpressionTypes): Rewrite and simplify now that the
type checker is more robust.
(CheckElementSetTypes): Ditto.
(CodeXIndr): Add new range assignment type check.
* gm2-compiler/M2MetaError.def: Correct comments.
* gm2-compiler/M2Options.def (SetStrictTypeAssignment): New procedure.
(SetStrictTypeReason): Ditto.
* gm2-compiler/M2Options.mod: (SetStrictTypeAssignment): New procedure.
(SetStrictTypeReason): Ditto.
(StrictTypeReason): Initialize.
(StrictTypeAssignment): Ditto.
* gm2-compiler/M2Quads.mod (CheckBreak): Delete.
(BreakQuad): New global variable.
(BreakAtQuad): Delete.
(gdbhook): New procedure.
(BreakWhenQuadCreated): Ditto.
(CheckBreak): Ditto.
(Init): Call BreakWhenQuadCreated and gdbhook.
(doBuildAssignment): Add type assignment range check.
(CheckProcTypeAndProcedure): Only check if the procedure
types differ.
(doIndrX): Add type IndrX range check.
(CheckReturnType): Add range return type check.
* gm2-compiler/M2Range.def (InitTypesIndrXCheck): New procedure
function.
(InitTypesReturnTypeCheck): Ditto.
* gm2-compiler/M2Range.mod (InitTypesIndrXCheck): New procedure
function.
(InitTypesReturnTypeCheck): Ditto.
(HandlerExists): Add new clauses.
(FoldAssignment): Pass extra FALSE parameter to
AssignmentTypeCompatible.
(FoldTypeReturnFunc): New procedure.
(FoldTypeAssign): Ditto.
(FoldTypeIndrX): Ditto.
(CodeTypeAssign): Rewrite.
(CodeTypeIndrX): New procedure.
(CodeTypeReturnFunc): Ditto.
(FoldTypeCheck): Add new case clauses.
(CodeTypeCheck): Ditto.
(FoldRangeCheckLower): Ditto.
(IssueWarning): Ditto.
* gm2-gcc/m2options.h (M2Options_SetStrictTypeAssignment): New
function prototype.
(M2Options_SetStrictTypeReason): Ditto.
* gm2-lang.cc (gm2_langhook_handle_option): New case clause
OPT_fm2_strict_type_reason.
* lang.opt (-fm2-strict-type-reason): New option.

gcc/testsuite/ChangeLog:

PR modula2/120389
* gm2/pim/fail/testcharint.mod: New test.
* gm2/pim/fail/testindrx.mod: New test.
* gm2/pim/pass/testxindr.mod: New test.
* gm2/pim/pass/testxindr2.mod: New test.
* gm2/pim/pass/testxindr3.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2 months agoDaily bump.
GCC Administrator [Sat, 31 May 2025 00:19:06 +0000 (00:19 +0000)] 
Daily bump.

2 months agodiagnostics: implement highlight-a vs -b in HTML output [PR116792]
David Malcolm [Fri, 30 May 2025 23:57:46 +0000 (19:57 -0400)] 
diagnostics: implement highlight-a vs -b in HTML output [PR116792]

Update HTML output so that it renders highlight-a vs highlight-b
via <span> tags in the message itself, in the quoted source line,
in the underlines, and in the labels and their vertical bars.

Example output can be seen at:
  https://dmalcolm.fedorapeople.org/gcc/2025-05-28/diagnostic-ranges.c.html

gcc/ChangeLog:
PR other/116792
* diagnostic-format-html.cc (HTML_STYLE): Add ".highlight-a" and
".highlight-b".
(html_builder::make_element_for_diagnostic): Handle begin_color
and end_color.
* diagnostic-show-locus.cc (to_html::to_html): Add "richloc"
param and use it to initialize m_richloc.
(to_html::colorize_text_for_range_idx): Drop.
(to_html::get_location_range_by_idx): New.
(to_html::get_highlight_color_for_range_idx): New.
(to_html::m_richloc): New field.
(print_html_span_start): Update for new param of to_html ctor.
(line_printer::m_was_in_range_p): New field.
(line_printer::m_last_range_idx): New field.
(layout_printer<Sink>::print_source_line): Use set_in_range
and set_outside_range rather than colorization calls.
(layout_printer<Sink>::set_in_range): New.
(layout_printer<Sink>::set_outside_range): New.
(layout_printer<Sink>::print_annotation_line): Use set_in_range
and set_outside_range rather than colorization calls.
(layout_printer<to_text>::begin_label): Convert param from label
to state_idx.  Add "is_label_text" param and use it to guard logic
for turning off colorization within paths.
(layout_printer<to_html>::begin_label): Likewise.  Push <span>
for any highlight color.
(layout_printer<to_text>::end_label): Likewise.
(layout_printer<to_text>::end_label): Likewise, popping the
<span>.
(layout_printer<Sink>::print_any_labels): Convert begin/end_label
calls to pass in state_idx rather than label.  Use begin/end_label
rather than colorization calls.
(layout_printer<Sink>::layout_printer): Likewise.
(layout_printer<Sink>::layout_printer): Initialize new fields.
(diagnostic_source_print_policy::print_as_html): Update for new
param of to_html ctor.

gcc/testsuite/ChangeLog:
PR other/116792
* gcc.dg/format/diagnostic-ranges-html.py: New test script.
* gcc.dg/format/diagnostic-ranges.c: Add HTML generation to
options, and invoke the new script to check the HTML output.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 months agoc++: another xobj lambda testcase [PR120123]
Jason Merrill [Fri, 30 May 2025 22:27:45 +0000 (18:27 -0400)] 
c++: another xobj lambda testcase [PR120123]

Patrick noticed this was fixed by r16-970.

PR c++/120123

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/explicit-obj-lambda18.C: New test.

2 months agoFix typo in comment in execute_all_ipa_transforms.
Andrew Pinski [Fri, 30 May 2025 07:00:31 +0000 (00:00 -0700)] 
Fix typo in comment in execute_all_ipa_transforms.

small typo, missing n at the end of function.

Pushed as obvious after a bootstrap/test.

gcc/ChangeLog:

* passes.cc (execute_all_ipa_transforms): Fix typo in
commenet.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 months agoc: Update description of C library facilities provided by GCC for C23
Joseph Myers [Fri, 30 May 2025 20:15:53 +0000 (20:15 +0000)] 
c: Update description of C library facilities provided by GCC for C23

The documentation of which standard C library facilities (headers) are
provided by GCC, as being those required of freestanding
implementations, is reasonably accurate for C99 and before (if you
ignore the provision of <tgmath.h> for non-GNU targets).  It's less
accurate for C11, since we provide <stdatomic.h> although that's not
required for freestanding implementations.  And it's very inaccurate
for C23, which specifies that freestanding implementations also
provide most of <string.h>, memalignment from <stdlib.h>, and, when
supporting Annex F, also <fenv.h>, <math.h> and the strto*
floating-point numeric conversion functions from <stdlib.h>.

I don't think expanding the scope of the C library facilities GCC
provides to include all those extra facilities specified by C23 for
freestanding implementations is a good idea.  (Indeed, GCC once used
to install assert.h on some platforms, but stopped doing so a long
time ago.)  Rather, it seems better to document that in both the
freestanding and the hosted cases, GCC is intended to provide the
compiler part of a conforming implementation, to be combined with a
corresponding library implementation, rather than providing all the
required library facilities in either case.

The rule about which headers GCC provides is then described in terms
of headers not declaring functions with external linkage, which is
much closer to existing practice, although still not perfect in all
cases (<stdatomic.h>, although mainly providing type-generic
operations, does declare a few non-type-generic functions that we
provide in libatomic).

A paragraph in trouble.texi that talks about freestanding
implementations with -ansi -pedantic is not changed (given that the
description in terms of freestanding implementations is sufficiently
accurate for C90); if the -ansi there were changed to an option for a
more recent standard, a corresponding change to that paragraph might
be needed as well.

Tested with "make info html pdf".

* doc/standards.texi (C Language): Document library facilities
provided in terms of headers not declaring functions with external
linkage, not in terms of headers required of freestanding
implementations.
* doc/sourcebuild.texi (Subdirectories, Headers): Likewise.
* doc/trouble.texi (Standard Libraries): Likewise.

2 months agoFortran: parameter inquiries of constant complex arrays [PR102599,PR114022]
Harald Anlauf [Fri, 30 May 2025 17:25:15 +0000 (19:25 +0200)] 
Fortran: parameter inquiries of constant complex arrays [PR102599,PR114022]

PR fortran/102599
PR fortran/114022

gcc/fortran/ChangeLog:

* expr.cc (simplify_complex_array_inquiry_ref): Helper function for
simplification of inquiry references (%re/%im) of constant complex
arrays.
(find_inquiry_ref): Use it for handling %re/%im inquiry references
of complex arrays.
(scalarize_intrinsic_call): Fix frontend memleak.
* primary.cc (gfc_match_varspec): When the reference is NULL, the
previous simplification has succeeded in evaluating inquiry
references also of arrays.

gcc/testsuite/ChangeLog:

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

2 months agoc++: more xobj lambda 'this' capture [PR113563]
Jason Merrill [Fri, 30 May 2025 12:59:31 +0000 (08:59 -0400)] 
c++: more xobj lambda 'this' capture [PR113563]

Nathaniel shared a more extensive test, which revealed more needed fixes.

PR c++/113563

gcc/cp/ChangeLog:

* lambda.cc (lambda_capture_field_type): Handle 'this' normally.
(build_capture_proxy): Special-case 'this' by-ref capture more.
(nonlambda_method_basetype): Look through xobj lambdas.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/explicit-obj-lambda17.C: New test.

2 months agoC: Flex array in union followed by a structure field is not reported [PR120354]
Qing Zhao [Thu, 29 May 2025 15:59:41 +0000 (15:59 +0000)] 
C: Flex array in union followed by a structure field is not reported [PR120354]

There is only one last_field for a structure type, but there might
be multiple last_fields for a union type, therefore we should ORed
the result of TYPE_INCLUDES_FLEXARRAY for multiple last_fields of
a union type.

PR c/120354

gcc/c/ChangeLog:

* c-decl.cc (finish_struct): Or the results for TYPE_INCLUDES_FLEXARRAY.

gcc/testsuite/ChangeLog:

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

2 months agoC: Flex array in the middle via type alias is not reported [PR120353]
Qing Zhao [Wed, 28 May 2025 21:13:38 +0000 (21:13 +0000)] 
C: Flex array in the middle via type alias is not reported [PR120353]

The root cause of the bug is: the TYPE_INCLUDES_FLEXARRAY marking of the
structure type is not copied to its aliased type.
The fix is to copy this marking to all the variant types of the current
structure type.

PR c/120353

gcc/c/ChangeLog:

* c-decl.cc (finish_struct): Copy TYPE_INCLUDES_FLEXARRAY marking
to all the variant types of the current structure type.

gcc/testsuite/ChangeLog:

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

2 months agolibstdc++: Test for formatting with empty spec for calendar types.
Tomasz Kamiński [Fri, 30 May 2025 09:31:35 +0000 (11:31 +0200)] 
libstdc++: Test for formatting with empty spec for calendar types.

Adding a test for behavior of the ostream operator and the formatting
with empty chron-spec for the chrono types. This commit covers calendar
types.

libstdc++-v3/ChangeLog:

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

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agoRISC-V: Add test cases for avg_ceil vaadd implementation
Pan Li [Thu, 29 May 2025 13:33:44 +0000 (21:33 +0800)] 
RISC-V: Add test cases for avg_ceil vaadd implementation

Add asm and run testcase for avg_ceil vaadd implementation.

The below test suites are passed for this patch series.
* The rv64gcv fully regression test.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/avg.h: Add test helper macros.
* gcc.target/riscv/rvv/autovec/avg_data.h: Add test data for
avg_ceil.
* gcc.target/riscv/rvv/autovec/avg_ceil-1-i16-from-i32.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-1-i16-from-i64.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-1-i32-from-i64.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-1-i8-from-i16.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-1-i8-from-i32.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-1-i8-from-i64.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i16-from-i32.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i16-from-i64.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i32-from-i64.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i8-from-i16.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i8-from-i32.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i8-from-i64.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 months agoRISC-V: Reconcile the existing test for avg_ceil
Pan Li [Thu, 29 May 2025 13:31:54 +0000 (21:31 +0800)] 
RISC-V: Reconcile the existing test for avg_ceil

Some existing avg_floor test need updated due to change to
leverage vaadd.vv directly.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls/avg-4.c: Update asm check
to vaadd.
* gcc.target/riscv/rvv/autovec/vls/avg-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/avg-6.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/vec-avg-rv32gcv.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/vec-avg-rv64gcv.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 months agoRISC-V: Leverage vaadd.vv for signed standard name avg_ceil
Pan Li [Thu, 29 May 2025 13:19:36 +0000 (21:19 +0800)] 
RISC-V: Leverage vaadd.vv for signed standard name avg_ceil

The avg_ceil has the rounding mode towards +inf, while the
vaadd.vv has the rnu which totally match the sematics.  From
RVV spec, the fixed vaadd.vv with rnu,

roundoff_signed(v, d) = (signed(v) >> d) + r
r = v[d - 1]

For vaadd, d = 1, then we have

roundoff_signed(v, 1) = (signed(v) >> 1) + v[0]

If v[0] is bit 0, nothing need to do as there is no rounding.
If v[0] is bit 1, there will be rounding with 2 cases.

Case 1: v is positive.
  roundoff_signed(v, 1) = (signed(v) >> 1) + 1, aka round towards +inf
  roundoff_signed(2 + 3, 1) = (5 >> 1) + 1 = 3

Case 2: v is negative.
  roundoff_signed(v, 1) = (signed(v) >> 1) + 1, aka round towards +inf
  roundoff_signed(-9 + 2, 1) = (-7 >> 1) + 1 = -4 + 1 = -3

Thus, we can leverage the vaadd with rnu directly for avg_ceil.

The below test suites are passed for this patch series.
* The rv64gcv fully regression test.

gcc/ChangeLog:

* config/riscv/autovec.md (avg<v_double_trunc>3_ceil): Add insn
expand to leverage vaadd with rnu directly.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 months agotree-optimization/120341 - stores into STRING_CSTs can trap
Richard Biener [Fri, 30 May 2025 11:47:55 +0000 (13:47 +0200)] 
tree-optimization/120341 - stores into STRING_CSTs can trap

The following fixes conditional store elimination and store motion
so they consider stores to STRING_CSTs as trapping.

PR tree-optimization/120341
* tree-ssa-loop-im.cc (can_sm_ref_p): STRING_CSTs are readonly.
* tree-ssa-phiopt.cc (cond_store_replacement): Likewise.

* gcc.dg/torture/pr120341-1.c: New testcase.
* gcc.dg/torture/pr120341-2.c: Likewise.

2 months agoAdd 'libgomp.c++/target-valarray-1.C'
Thomas Schwinge [Wed, 30 Apr 2025 09:29:08 +0000 (11:29 +0200)] 
Add 'libgomp.c++/target-valarray-1.C'

libgomp/
* testsuite/libgomp.c++/target-std__valarray-1.C: New.
* testsuite/libgomp.c++/target-std__valarray-1.output: Likewise.

2 months agolibgomp: Add testcases for concurrent access to standard C++ containers on offload...
Thomas Schwinge [Fri, 30 May 2025 09:37:46 +0000 (11:37 +0200)] 
libgomp: Add testcases for concurrent access to standard C++ containers on offload targets, a number of USM variants

libgomp/
* testsuite/libgomp.c++/target-std__array-concurrent-usm.C: New.
* testsuite/libgomp.c++/target-std__array-concurrent.C: Adjust.
* testsuite/libgomp.c++/target-std__bitset-concurrent-usm.C: New.
* testsuite/libgomp.c++/target-std__bitset-concurrent.C: Adjust.
* testsuite/libgomp.c++/target-std__deque-concurrent-usm.C: New.
* testsuite/libgomp.c++/target-std__deque-concurrent.C: Adjust.
* testsuite/libgomp.c++/target-std__forward_list-concurrent-usm.C: New.
* testsuite/libgomp.c++/target-std__forward_list-concurrent.C: Adjust.
* testsuite/libgomp.c++/target-std__list-concurrent-usm.C: New.
* testsuite/libgomp.c++/target-std__list-concurrent.C: Adjust.
* testsuite/libgomp.c++/target-std__map-concurrent-usm.C: New.
* testsuite/libgomp.c++/target-std__map-concurrent.C: Adjust.
* testsuite/libgomp.c++/target-std__multimap-concurrent-usm.C: New.
* testsuite/libgomp.c++/target-std__multimap-concurrent.C: Adjust.
* testsuite/libgomp.c++/target-std__multiset-concurrent-usm.C: New.
* testsuite/libgomp.c++/target-std__multiset-concurrent.C: Adjust.
* testsuite/libgomp.c++/target-std__set-concurrent-usm.C: New.
* testsuite/libgomp.c++/target-std__set-concurrent.C: Adjust.
* testsuite/libgomp.c++/target-std__span-concurrent-usm.C: New.
* testsuite/libgomp.c++/target-std__span-concurrent.C: Adjust.
* testsuite/libgomp.c++/target-std__valarray-concurrent-usm.C: New.
* testsuite/libgomp.c++/target-std__valarray-concurrent.C: Adjust.
* testsuite/libgomp.c++/target-std__vector-concurrent-usm.C: New.
* testsuite/libgomp.c++/target-std__vector-concurrent.C: Adjust.

2 months agolibgomp: Add testcases for concurrent access to standard C++ containers on offload...
Kwok Cheung Yeung [Thu, 8 May 2025 19:41:16 +0000 (20:41 +0100)] 
libgomp: Add testcases for concurrent access to standard C++ containers on offload targets

libgomp/

* testsuite/libgomp.c++/target-std__array-concurrent.C: New.
* testsuite/libgomp.c++/target-std__bitset-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__deque-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__flat_map-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__flat_multimap-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__flat_multiset-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__flat_set-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__forward_list-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__list-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__map-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__multimap-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__multiset-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__set-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__span-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__unordered_map-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__unordered_multimap-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__unordered_multiset-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__unordered_set-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__valarray-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__vector-concurrent.C: Likewise.

Co-authored-by: Thomas Schwinge <tschwinge@baylibre.com>
2 months agolibgomp: Add testcases for the standard C++ math library on offload targets
Kwok Cheung Yeung [Wed, 21 May 2025 11:59:58 +0000 (12:59 +0100)] 
libgomp: Add testcases for the standard C++ math library on offload targets

libgomp/

* testsuite/libgomp.c++/target-std__cmath.C: New.
* testsuite/libgomp.c++/target-std__complex.C: Likewise.
* testsuite/libgomp.c++/target-std__numbers.C: Likewise.

2 months agoAdd 'libgomp.c++/target-flex-[...].C' test cases
Waffl3x [Mon, 26 May 2025 08:38:27 +0000 (02:38 -0600)] 
Add 'libgomp.c++/target-flex-[...].C' test cases

libgomp/ChangeLog:

* testsuite/libgomp.c++/target-flex-10.C: New test.
* testsuite/libgomp.c++/target-flex-100.C: New test.
* testsuite/libgomp.c++/target-flex-101.C: New test.
* testsuite/libgomp.c++/target-flex-11.C: New test.
* testsuite/libgomp.c++/target-flex-12.C: New test.
* testsuite/libgomp.c++/target-flex-2000.C: New test.
* testsuite/libgomp.c++/target-flex-2001.C: New test.
* testsuite/libgomp.c++/target-flex-2002.C: New test.
* testsuite/libgomp.c++/target-flex-2003.C: New test.
* testsuite/libgomp.c++/target-flex-30.C: New test.
* testsuite/libgomp.c++/target-flex-300.C: New test.
* testsuite/libgomp.c++/target-flex-31.C: New test.
* testsuite/libgomp.c++/target-flex-32.C: New test.
* testsuite/libgomp.c++/target-flex-33.C: New test.
* testsuite/libgomp.c++/target-flex-41.C: New test.
* testsuite/libgomp.c++/target-flex-60.C: New test.
* testsuite/libgomp.c++/target-flex-61.C: New test.
* testsuite/libgomp.c++/target-flex-62.C: New test.
* testsuite/libgomp.c++/target-flex-70.C: New test.
* testsuite/libgomp.c++/target-flex-80.C: New test.
* testsuite/libgomp.c++/target-flex-81.C: New test.
* testsuite/libgomp.c++/target-flex-90.C: New test.
* testsuite/libgomp.c++/target-flex-common.h: New test.

Co-authored-by: Thomas Schwinge <tschwinge@baylibre.com>
2 months agoDefuse 'RESULT_DECL' check in 'pass_nrv' (for offloading compilation) [PR119835]
Thomas Schwinge [Wed, 28 May 2025 16:40:31 +0000 (18:40 +0200)] 
Defuse 'RESULT_DECL' check in 'pass_nrv' (for offloading compilation) [PR119835]

... to avoid running into ICEs per PR119835, until that's resolved properly.

PR middle-end/119835
gcc/
* tree-nrv.cc (pass_nrv::execute): Defuse 'RESULT_DECL' check.
libgomp/
* testsuite/libgomp.oacc-c-c++-common/abi-struct-1.c:
'#pragma GCC optimize "-fno-inline"'.
* testsuite/libgomp.c-c++-common/target-abi-struct-1.c: New.
* testsuite/libgomp.c-c++-common/target-abi-struct-1-O0.c: Adjust.

Co-authored-by: Richard Biener <rguenther@suse.de>
2 months agotestsuite: Add testcase for GCC 13 branch s390 bug [PR120480]
Jakub Jelinek [Fri, 30 May 2025 12:35:12 +0000 (14:35 +0200)] 
testsuite: Add testcase for GCC 13 branch s390 bug [PR120480]

This got broken with r13-9727 and fixed with either of
r13-9729 or r13-9728.

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

PR target/120480
* gcc.dg/pr120480.c: New test.

2 months agoOpenMP: Support OpenMP 5.0 "declare mapper" directives for C
Julian Brown [Fri, 30 May 2025 12:19:40 +0000 (14:19 +0200)] 
OpenMP: Support OpenMP 5.0 "declare mapper" directives for C

This patch adds support for "declare mapper" directives (and the "mapper"
modifier on "map" clauses) for C.

gcc/c/ChangeLog:

* c-decl.cc (c_omp_mapper_id, c_omp_mapper_decl, c_omp_mapper_lookup,
c_omp_extract_mapper_directive, c_omp_map_array_section,
c_omp_scan_mapper_bindings_r, c_omp_scan_mapper_bindings): New
functions.
* c-objc-common.h (LANG_HOOKS_OMP_FINISH_MAPPER_CLAUSES,
LANG_HOOKS_OMP_MAPPER_LOOKUP, LANG_HOOKS_OMP_EXTRACT_MAPPER_DIRECTIVE,
LANG_HOOKS_OMP_MAP_ARRAY_SECTION): Define langhooks for C.
* c-parser.cc (c_parser_omp_clause_map): Add declare_mapper_p
parameter; handle mapper modifier.
(c_parser_omp_all_clauses): Update call to c_parser_omp_clause_map.
(c_parser_omp_target): Instantiate explicit mappers and record bindings
for implicit mappers.
(c_parser_omp_declare_mapper): Parse "declare mapper" directives.
(c_parser_omp_declare): Support "declare mapper".
(c_parser_omp_declare_reduction): Use inform not error_at.
* c-tree.h (c_omp_finish_mapper_clauses, c_omp_mapper_lookup,
c_omp_extract_mapper_directive, c_omp_map_array_section,
c_omp_mapper_id, c_omp_mapper_decl, c_omp_scan_mapper_bindings,
c_omp_instantiate_mappers): Add prototypes.
* c-typeck.cc (c_finish_omp_clauses): Handle GOMP_MAP_PUSH_MAPPER_NAME
and GOMP_MAP_POP_MAPPER_NAME.
(c_omp_finish_mapper_clauses): New function (langhook).

libgomp/ChangeLog:

* testsuite/libgomp.c-c++-common/declare-mapper-9.c: Enable for C.
* testsuite/libgomp.c-c++-common/declare-mapper-10.c: Likewise.
* testsuite/libgomp.c-c++-common/declare-mapper-11.c: Likewise.
* testsuite/libgomp.c-c++-common/declare-mapper-12.c: Likewise.
* testsuite/libgomp.c-c++-common/declare-mapper-13.c: Likewise.
* testsuite/libgomp.c-c++-common/declare-mapper-14.c: Likewise.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/declare-mapper-3.c: Enable for C.
* c-c++-common/gomp/declare-mapper-4.c: Likewise.
* c-c++-common/gomp/declare-mapper-5.c: Likewise.
* c-c++-common/gomp/declare-mapper-6.c: Likewise.
* c-c++-common/gomp/declare-mapper-7.c: Likewise.
* c-c++-common/gomp/declare-mapper-8.c: Likewise.
* c-c++-common/gomp/declare-mapper-9.c: Likewise.
* c-c++-common/gomp/declare-mapper-10.c: Likewise.
* c-c++-common/gomp/declare-mapper-12.c: Likewise.
* c-c++-common/gomp/map-6.c: Update dg-error.
* gcc.dg/gomp/udr-3.c: Update for change to dg-note.
* c-c++-common/gomp/declare-mapper-11.c: New.
* gcc.dg/gomp/declare-mapper-10.c: New test.
* gcc.dg/gomp/declare-mapper-11.c: New test.
* gcc.dg/gomp/declare-mapper-13.c: New test.

2 months agoType mismatch for passed external function
Thomas Koenig [Fri, 30 May 2025 11:31:58 +0000 (13:31 +0200)] 
Type mismatch for passed external function

This obvious and simple patch fixes a 15/16 regression where the
typespec of a global function was in the RESULT clause and not
in the symbol itself.

gcc/fortran/ChangeLog:

PR fortran/120355
* interface.cc (compare_parameter): If the global function has a
result clause, take typespec from there for the comparison against
the dummy argument.

gcc/testsuite/ChangeLog:

PR fortran/120355
* gfortran.dg/interface_62.f90: New test.

2 months agodiagnostics: consolidate calls to colorizer::set_named_color
David Malcolm [Fri, 30 May 2025 11:18:44 +0000 (07:18 -0400)] 
diagnostics: consolidate calls to colorizer::set_named_color

I noticed whilst working on another issue that in diagnostic-show-locus
within the quoted source lines and the annotation underlines that when
we're showing highlight-{a,b} that we emit
  start-colorization-code, character, end-colorization-code
per *character*, rather than just when the colorization changes.

This was due to me failing to implement consolidation of such changes in
colorizer::set_named_color in r15-2015-g7d73c01ce6d1ab.

Fixed thusly, simplifying the output.

I manually inspected all of the changed testcases in a terminal with
color enabled and verified that the output is visually identical to
before.

gcc/ChangeLog:
* diagnostic-show-locus.cc (colorizer::m_current_named_color): New
field.
(colorizer::set_named_color): Use it to consolidate repeated calls
to the same color.

gcc/testsuite/ChangeLog:
* g++.dg/diagnostic/bad-binary-ops-highlight-colors.C: Update
expected multiline output for quoted source and underlines to
reflect emitting color codes when changes happen, rather than
per character.
* g++.dg/diagnostic/long-short-colorization.C: Likewise.
* g++.dg/plugin/show-template-tree-color-labels.C: Likewise.
* gcc.dg/bad-binary-ops-highlight-colors.c: Likewise.
* gcc.dg/format/colors.c: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 months agotree-optimization/120457 - avoid lowering of some single-element interleave
Richard Biener [Fri, 30 May 2025 06:54:10 +0000 (08:54 +0200)] 
tree-optimization/120457 - avoid lowering of some single-element interleave

The following makes sure we are not lowering single-element interleaving
schemes in a way that defeats load vectorizing later but allows the
VMAT_ELEMENTWISE fallback to be used.

PR tree-optimization/120457
* tree-vect-slp.cc (vect_lower_load_permutations): Implement
the same heuristics as load vectorization for single-element
interleaving that spans multiple vectors.

2 months agolibstdc++: Define __wait_result_type for atomic waiting
Jonathan Wakely [Fri, 31 Jan 2025 22:10:21 +0000 (22:10 +0000)] 
libstdc++: Define __wait_result_type for atomic waiting

libstdc++-v3/ChangeLog:

* include/bits/atomic_timed_wait.h: Use __wait_result_type.
* include/bits/atomic_wait.h (__wait_result_type): New struct.
(__wait_args::_M_prep_for_wait_on): Rename to _M_setup_wait, use
__wait_result_type.
(__atomic_wait_address): Adjust to call _M_setup_wait.
* src/c++20/atomic.cc (__spin_impl): Use __wait_result_type.
(__wait_impl): Likewise.
(__spin_until_impl): Likewise.
(__wait_until_impl): Likewise.

2 months agolibstdc++: Rewrite std::counting_semaphore base class [PR118494]
Jonathan Wakely [Wed, 15 Jan 2025 09:05:28 +0000 (09:05 +0000)] 
libstdc++: Rewrite std::counting_semaphore base class [PR118494]

Remove __platform_semaphore. Replace __atomic_semaphore with
__semaphore_base<bool> and change its counter to be ptrdiff_t when the
count doesn't fit in __platform_wait_t (PR 118494).

Make the std::counting_semaphore constructor constexpr to support
constant initialization (PR 110854).

Add precondition checks to the constructor and release member functions
(PR 98749).

libstdc++-v3/ChangeLog:

PR libstdc++/118494
PR libstdc++/110854
PR libstdc++/98749
* acinclude.m4 (GLIBCXX_CHECK_GTHREADS): Remove checks for
sem_timedwait. Do not define _GLIBCXX_HAVE_POSIX_SEMAPHORE.
* config.h.in: Regenerate.
* configure: Regenerate.
* include/bits/semaphore_base.h (__platform_semaphore): Remove.
(__atomic_semaphore): Replace with __semaphore_base<bool> and
make type of _M_count depend on template parameter. Fix _S_max
constant to use correct type.
(__semaphore_base::_M_try_acquire): Qualify to avoid ADL.
(__semaphore_base::_M_release): Return old value. Remove FIXME
comment.
(__semaphore_impl): Replace typedef with alias template.
* include/bits/version.def (semaphore): Do not depend on
_GLIBCXX_HAVE_POSIX_SEMAPHORE.
* include/bits/version.h: Regenerate.
* include/std/semaphore (semaphore): Adjust type of _M_sem
member. Add constexpr to constructor. Add assertions to
(semaphore::semaphore(ptrdiff_t)): Add constexpr. Add assertion
for precondition.
(semaphore::release): Add assertion using value returned from
_M_release.
* testsuite/30_threads/semaphore/100806.cc: Increase template
argument for std::counting_semaphore, so constructor
precondition is met.
* testsuite/30_threads/semaphore/cons.cc: New test.
* testsuite/30_threads/semaphore/try_acquire_posix.cc: Remove.
* testsuite/30_threads/semaphore/platform_try_acquire_for.cc:
Removed.

2 months agolibstdc++: Create new base class of std::barrier<C> for non-dependent code
Jonathan Wakely [Fri, 10 Jan 2025 17:00:48 +0000 (17:00 +0000)] 
libstdc++: Create new base class of std::barrier<C> for non-dependent code

This moves all non-dependent state and logic for std::barrier<C> into a
new non-template base class, to avoid template bloat.

This would permit moving the _M_arrive function into the library instead
of the header.

libstdc++-v3/ChangeLog:

* include/std/barrier (__tree_barrier_base): New class.
(__tree_barrier): Move non-dependent code into
__tree_barrier_base and derive from it.

2 months agolibstdc++: Fix std::barrier for constant initialization [PR118395]
Jonathan Wakely [Fri, 10 Jan 2025 12:22:21 +0000 (12:22 +0000)] 
libstdc++: Fix std::barrier for constant initialization [PR118395]

The std::barrier constructor should be constexpr, which means we need to
defer the dynamic allocation if the constructor is called during
constant-initialization. We can defer it to the first call to
barrier::arrive, using compare-and-swap on an atomic<T*> (instead of the
unique_ptr<T[]> currently used).

Also add precondition checks to the constructor and arrive member
function. Also implement the proposed resolution of LWG 3898.

libstdc++-v3/ChangeLog:

PR libstdc++/118395
PR libstdc++/108974
PR libstdc++/98749
* include/std/barrier (__tree_barrier): Use default
member-initializers. Change _M_state member from
unique_ptr<__state_t[]> to atomic<__state_t*>. Add
no_unique_address attribute to _M_completion.
(__tree_barrier::_M_arrive): Load value from _M_state.
(__tree_barrier::_M_invoke_completion): New member function to
ensure a throwing completion function will terminate, as
proposed in LWG 3898.
(__tree_barrier::max): Reduce by one to avoid overflow.
(__tree_barrier::__tree_barrier): Add constexpr. Qualify call to
std::move. Remove mem-initializers made unnecessary by default
member-initializers. Add precondition check. Only allocate state
array if not constant evaluated.
(__tree_barrier::arrive): Add precondition check. Do deferred
initialization of _M_state if needed.
(barrier): Add static_assert, as proposed in LWG 3898.
(barrier::barrier): Add constexpr.
* testsuite/30_threads/barrier/cons.cc: New test.
* testsuite/30_threads/barrier/lwg3898.cc: New test.