]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 weeks agoRISC-V: Fix vsetvl merge rule.
Robin Dapp [Mon, 14 Jul 2025 11:53:12 +0000 (13:53 +0200)] 
RISC-V: Fix vsetvl merge rule.

In PR120297 we fuse
  vsetvl e8,mf2,...
  vsetvl e64,m1,...
into
  vsetvl e64,m4,...

Individually, that's ok but we also change the new vsetvl's demand to
"SEW only" even though the first original one demanded SEW >= 8 and
ratio = 16.

As we forget the ratio after the merge we find that the vsetvl following
the merged one has ratio = 64 demand and we fuse into
  vsetvl e64,m1,..
which obviously doesn't have ratio = 16 any more.

Regtested on rv64gcv_zvl512b.

PR target/120297

gcc/ChangeLog:

* config/riscv/riscv-vsetvl.def: Do not forget ratio demand of
previous vsetvl.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/pr120297.c: New test.

2 weeks agoaarch64: Use SVE2 BSL2N for vector EON
Kyrylo Tkachov [Fri, 11 Jul 2025 14:23:16 +0000 (07:23 -0700)] 
aarch64: Use SVE2 BSL2N for vector EON

SVE2 BSL2N (x, y, z) = (x & z) | (~y & ~z). When x == y this computes:
(x & z) | (~x & ~z) which is ~(x ^ z).
Thus, we can use it to match RTL patterns (not (xor (...) (...))) for both
Advanced SIMD and SVE modes when TARGET_SVE2.
This patch does that.
For code like:

uint64x2_t eon_q(uint64x2_t a, uint64x2_t b) { return EON(a, b); }
svuint64_t eon_z(svuint64_t a, svuint64_t b) { return EON(a, b); }

We now generate:
eon_q:
        bsl2n   z0.d, z0.d, z0.d, z1.d
        ret

eon_z:
        bsl2n   z0.d, z0.d, z0.d, z1.d
        ret

instead of the previous:
eon_q:
        eor     v0.16b, v0.16b, v1.16b
        not     v0.16b, v0.16b
        ret

eon_z:
        eor     z0.d, z0.d, z1.d
        ptrue   p3.b, all
        not     z0.d, p3/m, z0.d
        ret

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

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
gcc/

* config/aarch64/aarch64-sve2.md (*aarch64_sve2_bsl2n_eon<mode>):
New pattern.
(*aarch64_sve2_eon_bsl2n_unpred<mode>): Likewise.

gcc/testsuite/

* gcc.target/aarch64/sve2/eon_bsl2n.c: New test.

2 weeks agoaarch64: Use SVE2 NBSL for vector NOR and NAND for Advanced SIMD modes
Kyrylo Tkachov [Fri, 11 Jul 2025 09:50:32 +0000 (02:50 -0700)] 
aarch64: Use SVE2 NBSL for vector NOR and NAND for Advanced SIMD modes

We already have patterns to use the NBSL instruction to implement vector
NOR and NAND operations for SVE types and modes.  It is straightforward to
have similar patterns for the fixed-width Advanced SIMD modes as well, though
it requires combine patterns without the predicate operand and an explicit 'Z'
output modifier.  This patch does so.

So now for example we generate for:

uint64x2_t nand_q(uint64x2_t a, uint64x2_t b) { return NAND(a, b); }
uint64x2_t nor_q(uint64x2_t a, uint64x2_t b) { return NOR(a, b); }

nand_q:
        nbsl    z0.d, z0.d, z1.d, z1.d
        ret

nor_q:
        nbsl    z0.d, z0.d, z1.d, z0.d
        ret

instead of the previous:
nand_q:
        and     v0.16b, v0.16b, v1.16b
        not     v0.16b, v0.16b
        ret

nor_q:
        orr     v0.16b, v0.16b, v1.16b
        not     v0.16b, v0.16b
        ret

The tied operand requirements for NBSL mean that we can generate the MOVPRFX
when the operands fall that way, but I guess having a 2-insn MOVPRFX form is
not worse than the current 2-insn codegen at least, and the MOVPRFX can be
fused by many cores.

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

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
gcc/

* config/aarch64/aarch64-sve2.md (*aarch64_sve2_unpred_nor<mode>):
New define_insn.
(*aarch64_sve2_nand_unpred<mode>): Likewise.

gcc/testsuite/

* gcc.target/aarch64/sve2/nbsl_nor_nand_neon.c: New test.

2 weeks agoFortran: Fix ICE in ASSOCIATE with user defined operator [PR121060]
Paul Thomas [Wed, 16 Jul 2025 05:16:57 +0000 (06:16 +0100)] 
Fortran: Fix ICE in ASSOCIATE with user defined operator [PR121060]

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

gcc/fortran
PR fortran/121060
* interface.cc (matching_typebound_op): Defer determination of
specific procedure until resolution by returning NULL.

gcc/testsuite/
PR fortran/121060
* gfortran.dg/associate_75.f90: New test.

2 weeks agoFortran: Fix ICE in F2018 IMPORT statements.
Paul Thomas [Wed, 16 Jul 2025 05:11:25 +0000 (06:11 +0100)] 
Fortran: Fix ICE in F2018 IMPORT statements.

2025-07-16  Steve Kargl  <sgk@troutmask.apl.washington.edu>

gcc/fortran
* decl.cc (gfc_match_import): Correct minor whitespace snafu
and fix NULL pointer dereferences in two places.

gcc/testsuite/
* gfortran.dg/import13.f90: New test.

2 weeks agoc, c++: Fix unused result for empty types [PR82134]
Jeremy Rifkin [Tue, 15 Jul 2025 22:17:01 +0000 (18:17 -0400)] 
c, c++: Fix unused result for empty types [PR82134]

Hi,
This fixes PR c/82134 which concerns gcc emitting an incorrect unused
result diagnostic for empty types. This diagnostic is emitted from
tree-cfg.cc because of a couple code paths which attempt to avoid
copying empty types, resulting in GIMPLE that isn't using the returned
value of a call. To fix this I've added suppress_warning in three locations
and a corresponding check in do_warn_unused_result.

Cheers,
Jeremy

PR c/82134

gcc/cp/ChangeLog:

* call.cc (build_call_a): Add suppress_warning
* cp-gimplify.cc (cp_gimplify_expr): Add suppress_warning

gcc/ChangeLog:

* gimplify.cc (gimplify_modify_expr): Add suppress_warning
* tree-cfg.cc (do_warn_unused_result): Check warning_suppressed_p

gcc/testsuite/ChangeLog:

* c-c++-common/attr-warn-unused-result-2.c: New test.

Signed-off-by: Jeremy Rifkin <jeremy@rifkin.dev>
2 weeks agoi386: Decouple AMX-AVX512 from AVX10.2 and imply AVX512F
Haochen Jiang [Tue, 15 Jul 2025 02:44:54 +0000 (10:44 +0800)] 
i386: Decouple AMX-AVX512 from AVX10.2 and imply AVX512F

In ISE058, the AVX10.2 imply is removed from AMX-AVX512. This
leads to re-consideration on the imply for AMX-AVX512.

Since it is using zmm register and using zmm register only, we
need to at least imply AVX512F. AVX512VL is not needed.

On the other hand, if we imply AVX10.1 for AMX-AVX512, it will
cause -mno-avx10.1 disabling AMX-AVX512. This would be a surprise
for users.

Based on the two reasons above, the patch is decoupling AMX-AVX512
from AVX10.2 and imply AVX512F.

gcc/ChangeLog:

* common/config/i386/i386-common.cc
(OPTION_MASK_ISA2_AMX_AVX512_SET): Do not set AVX10.2.
(OPTION_MASK_ISA2_AVX10_2_UNSET): Remove AMX-AVX512 unset.
(OPTION_MASK_ISA2_AVX512F_UNSET): Unset AMX-AVX512.
(ix86_handle_option): Imply AVX512F for AMX-AVX512.

gcc/testsuite/ChangeLog:

* gcc.target/i386/amxavx512-cvtrowd2ps-2.c: Add -mavx512fp16 to
use FP16 related intrins for convert.
* gcc.target/i386/amxavx512-cvtrowps2bf16-2.c: Ditto.
* gcc.target/i386/amxavx512-cvtrowps2ph-2.c: Ditto.
* gcc.target/i386/amxavx512-movrow-2.c: Ditto.

2 weeks agoRISC-V: Refine the scalar SAT_* test cases
Pan Li [Sat, 12 Jul 2025 14:26:32 +0000 (22:26 +0800)] 
RISC-V: Refine the scalar SAT_* test cases

Per previous discuss with Jeff, we don't do complicated
asm check like scalar saturation alu.  It is somehow
not easy to maintain, as well as fragile.  Thus, we
remove these function-body check, and introduce the
jmp label asm check instead.The code-gen of SAT_*
will never have a jmp, and the other run test will
make sure the correctness of SAT_* code-gen.

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

The below failed test cases are resolved:
FAIL: gcc.target/riscv/sat/sat_s_add_imm-2-i8.c -Oz
  check-function-bodies sat_s_add_imm_int8_t_fmt_2_1
FAIL: gcc.target/riscv/sat/sat_s_add_imm-2-i8.c -Os
  check-function-bodies sat_s_add_imm_int8_t_fmt_2_1
FAIL: gcc.target/riscv/sat/sat_s_add_imm-2-i8.c -O3
  check-function-bodies sat_s_add_imm_int8_t_fmt_2_1
FAIL: gcc.target/riscv/sat/sat_s_add_imm-2-i8.c -Ofast
  check-function-bodies sat_s_add_imm_int8_t_fmt_2_1
FAIL: gcc.target/riscv/sat/sat_s_add_imm-2-i8.c -O2
  check-function-bodies sat_s_add_imm_int8_t_fmt_2_1

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat/sat_s_add-1-i16.c: Remove function-body
check and add no jmp label asm check.
* gcc.target/riscv/sat/sat_s_add-1-i32.c:
* gcc.target/riscv/sat/sat_s_add-1-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-1-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-2-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-2-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-2-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-2-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-3-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-3-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-3-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-3-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-4-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-4-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-4-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-4-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-1-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-1-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-1-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-1-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-2-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-2-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-2-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-2-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-1-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-1-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-1-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-1-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-2-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-2-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-2-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-2-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-3-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-3-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-3-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-3-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-4-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-4-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-4-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-4-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-1-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-1-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-1-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-1-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-2-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-2-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-2-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-2-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-3-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-3-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-3-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-3-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-4-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-4-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-4-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-4-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-5-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-5-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-5-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-5-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-6-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-6-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-6-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-6-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-7-u16-from-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-7-u16-from-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-7-u32-from-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-7-u8-from-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-7-u8-from-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-7-u8-from-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-1-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-1-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-1-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-1-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-2-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-2-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-2-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-2-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-3-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-3-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-3-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-3-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-4-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-4-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-4-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-4-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_mul-1-u16-from-u128.c: Ditto.
* gcc.target/riscv/sat/sat_u_mul-1-u32-from-u128.c: Ditto.
* gcc.target/riscv/sat/sat_u_mul-1-u64-from-u128.c: Ditto.
* gcc.target/riscv/sat/sat_u_mul-1-u8-from-u128.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-1-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-1-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-1-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-1-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-10-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-10-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-10-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-10-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-11-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-11-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-11-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-11-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-12-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-12-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-12-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-12-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-2-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-2-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-2-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-2-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-3-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-3-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-3-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-3-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-4-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-4-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-4-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-4-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-5-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-5-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-5-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-5-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-6-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-6-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-6-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-6-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-7-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-7-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-7-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-7-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-8-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-8-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-8-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-8-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-9-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-9-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-9-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-9-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u16-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u16-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u16-3.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u16-4.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u32-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u32-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u32-3.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u32-4.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u64-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u64-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u8-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u8-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u8-3.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u8-4.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u16-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u16-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u16-3.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u32-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u32-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u32-3.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u64-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u8-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u8-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u8-3.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-2-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u16-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u16-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u32-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u32-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u8-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u8-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-3-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u16-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u16-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u32-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u32-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u8-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u8-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-4-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-1-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-1-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-1-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-1-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u8.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 weeks agoRISC-V: Support RVVDImode for avg3_floor auto vect
Pan Li [Tue, 15 Jul 2025 01:45:05 +0000 (09:45 +0800)] 
RISC-V: Support RVVDImode for avg3_floor auto vect

The avg3_floor pattern leverage the add and shift rtl
with the DOUBLE_TRUNC mode iterator.  Aka, RVVDImode
iterator will generate avg3rvvsimode_floor, only the
element size QI, HI and SI are allowed.

Thus, this patch would like to support the DImode by
the standard name, with the iterator V_VLSI_D.

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

gcc/ChangeLog:

* config/riscv/autovec.md (avg<mode>3_floor): Add new
pattern of avg3_floor for rvv DImode.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/avg.h: Add int128 type when
xlen == 64.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i16-from-i32.c:
Suppress __int128 warning for run test.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i16-from-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i32-from-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i8-from-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i8-from-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i8-from-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_data.h: Fix one incorrect
test data.
* gcc.target/riscv/rvv/autovec/avg_floor-run-1-i16-from-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_floor-run-1-i16-from-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_floor-run-1-i32-from-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_floor-run-1-i8-from-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_floor-run-1-i8-from-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_floor-run-1-i8-from-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/avg_floor-1-i64-from-i128.c: New test.
* gcc.target/riscv/rvv/autovec/avg_floor-run-1-i64-from-i128.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 weeks agoDaily bump.
GCC Administrator [Wed, 16 Jul 2025 00:18:49 +0000 (00:18 +0000)] 
Daily bump.

2 weeks agospellcheck.{cc,h}: modernization
David Malcolm [Tue, 15 Jul 2025 20:19:53 +0000 (16:19 -0400)] 
spellcheck.{cc,h}: modernization

No functional change intended.

gcc/ChangeLog:
* spellcheck.cc: Define INCLUDE_ALGORITHM.
(CASE_COST, BASE_COST): Convert to...
(case_cost, base_cost): ...these, in an anonymous namespace.
(get_edit_distance): Update for above.  Use std::min rather than
MIN.
(get_edit_distance_cutoff): Likewise.  Use std::max rather than
MAX.
(selftest::test_edit_distances): Update for BASE_COST renaming.
(selftest::get_old_cutoff): Likewise.  Use std::max.
(selftest::assert_not_suggested_for): Use nullptr.
(selftest::test_find_closest_string): Likewise.
* spellcheck.h: Replace TYPE with StringLikeType in templates,
and use CamelCase.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 weeks agolibgdiagnostics: add diagnostic_message_buffer [PR120792]
David Malcolm [Tue, 15 Jul 2025 20:19:42 +0000 (16:19 -0400)] 
libgdiagnostics: add diagnostic_message_buffer [PR120792]

This patch extends libgdiagnostics to provide a way to capture
the pp tokens making up a message string, so that SARIF and
HTML sinks can retain information such as event IDs and URLs.
As well as richer output, this improves the round-tripping of such
information through sarif-replay.

This also allows diagnostic messages to be built up in pieces,
with a drop-in replacement for fprintf, which I've found useful when
attempting to port "ld" to use libgdiagnostics.

gcc/ChangeLog:
PR sarif-replay/120792
* auto-obstack.h: New file, based on material taken from
pretty-print.cc.
* diagnostic-digraphs.h
(diagnostics::digraphs::digraph::set_description): New.
(diagnostics::digraphs::node::set_label): New.
* doc/libgdiagnostics/topics/compatibility.rst: Add
LIBGDIAGNOSTICS_ABI_4.
* doc/libgdiagnostics/topics/diagnostics.rst
(diagnostic_finish_via_msg_buf): Document new entrypoint.
* doc/libgdiagnostics/topics/execution-paths.rst
(diagnostic_execution_path_add_event_via_msg_buf): Document new
entrypoint.
* doc/libgdiagnostics/topics/index.rst: Add message-buffers.rst.
* doc/libgdiagnostics/topics/message-buffers.rst: New file.
* doc/libgdiagnostics/topics/message-formatting.rst: Add note
about message buffers.
* doc/libgdiagnostics/topics/physical-locations.rst
(diagnostic_add_location_with_label_via_msg_buf): Add.
* doc/libgdiagnostics/tutorial/07-execution-paths.rst: Link to
next section.
* doc/libgdiagnostics/tutorial/08-message-buffers.rst: New file.
* doc/libgdiagnostics/tutorial/index.rst: Add
08-message-buffers.rst.
* libgdiagnostics++.h (libgdiagnostics::message_buffer): New
class.
(libgdiagnostics::execution_path::add_event_via_msg_buf): New.
(libgdiagnostics::diagnostic::add_location_with_label): New.
(libgdiagnostics::diagnostic::finish_via_msg_buf): New.
(libgdiagnostics::graph::set_description): New overload.
(libgdiagnostics::graph::add_edge): New overload.
(libgdiagnostics::node::set_label): New overload.
* libgdiagnostics-private.h
(private_diagnostic_execution_path_add_event_2): Drop decl.
(private_diagnostic_execution_path_add_event_3): New decl.
* libgdiagnostics.cc:  Include "pretty-print-format-impl.h",
"pretty-print-markup.h", and "auto-obstack.h".
(class copying_token_printer): New.
(struct diagnostic_message_buffer): New.
(class pp_element_message_buffer): New.
(libgdiagnostics_path_event::libgdiagnostics_path_event): Replace
params "gmsgid" and "args" with "msg_buf".
(libgdiagnostics_path_event::print_desc): Reimplement using
pp_element_message_buffer to replay m_msg_buf into "pp".
(libgdiagnostics_path_event::m_desc_uncolored): Drop field.
(libgdiagnostics_path_event::m_desc_colored): Drop field.
(libgdiagnostics_path_event::msg_buf): New field.
(diagnostic_execution_path::add_event_va): Reimplement.
(diagnostic_execution_path::add_event_via_msg_buf): New.
(diagnostic::add_location_with_label): New overload, using
msg_buf.
(diagnostic_manager::emit): Reimplement with...
(diagnostic_manager::emit_va): ...this.
(diagnostic_manager::emit_msg_buf): New.
(FAIL_IF_NULL): Rename "p" to "ptr_arg".
(diagnostic_finish_va): Update to use diagnostic_manager::emit_va.
(diagnostic_graph::add_node_with_id): Rename "id" to "node_id".
(diagnostic_graph_add_node): Likewise.
(diagnostic_graph_add_edge): Rename "id" to "edge_id".
(diagnostic_graph_get_node_by_id): Rename "id" to "node_id".
(diagnostic_graph_get_edge_by_id): Rename "id" to "edge_id".
(private_diagnostic_execution_path_add_event_2): Delete.
(diagnostic_message_buffer_new): New public entrypoint.
(diagnostic_message_buffer_release): Likewise.
(diagnostic_message_buffer_append_str): Likewise.
(diagnostic_message_buffer_append_text): Likewise.
(diagnostic_message_buffer_append_byte): Likewise.
(diagnostic_message_buffer_append_printf): Likewise.
(diagnostic_message_buffer_append_event_id): Likewise.
(diagnostic_message_buffer_begin_url): Likewise.
(diagnostic_message_buffer_end_url): Likewise.
(diagnostic_message_buffer_begin_quote): Likewise.
(diagnostic_message_buffer_end_quote): Likewise.
(diagnostic_message_buffer_begin_color): Likewise.
(diagnostic_message_buffer_end_color): Likewise.
(diagnostic_message_buffer_dump): Likewise.
(diagnostic_finish_via_msg_buf): Likewise.
(diagnostic_add_location_with_label_via_msg_buf): Likewise.
(diagnostic_execution_path_add_event_via_msg_buf): Likewise.
(diagnostic_graph_set_description_via_msg_buf): Likewise.
(diagnostic_graph_add_edge_via_msg_buf): Likewise.
(diagnostic_node_set_label_via_msg_buf): Likewise.
(private_diagnostic_execution_path_add_event_3): New private
entrypoint.
* libgdiagnostics.h (LIBGDIAGNOSTICS_PARAM_FORMAT_STRING): New macro.
(LIBGDIAGNOSTICS_PARAM_PRINTF_FORMAT_STRING): New macro.
(diagnostic_message_buffer): New typedef.
(LIBDIAGNOSTICS_HAVE_diagnostic_message_buffer): New define.
(diagnostic_message_buffer_new): New decl.
(diagnostic_message_buffer_release): New decl.
(diagnostic_message_buffer_append_str): New decl.
(diagnostic_message_buffer_append_text): New decl.
(diagnostic_message_buffer_append_byte): New decl.
(diagnostic_message_buffer_append_printf): New decl.
(diagnostic_message_buffer_append_event_id): New decl.
(diagnostic_message_buffer_begin_url): New decl.
(diagnostic_message_buffer_end_url): New decl.
(diagnostic_message_buffer_begin_quote): New decl.
(diagnostic_message_buffer_end_quote): New decl.
(diagnostic_message_buffer_begin_color): New decl.
(diagnostic_message_buffer_end_color): New decl.
(diagnostic_message_buffer_dump): New decl.
(diagnostic_finish_via_msg_buf): New decl.
(diagnostic_add_location_with_label_via_msg_buf): New decl.
(diagnostic_execution_path_add_event_via_msg_buf): New decl.
(diagnostic_graph_set_description_via_msg_buf): New decl.
(diagnostic_graph_add_edge_via_msg_buf): New decl.
(diagnostic_node_set_label_via_msg_buf): New decl.
* libgdiagnostics.map (LIBGDIAGNOSTICS_ABI_3): Drop
private_diagnostic_execution_path_add_event_2.
(LIBGDIAGNOSTICS_ABI_4): New.
* libsarifreplay.cc (class annotation): Use
libgdiagnostics::message_buffer rather than label_text.
(add_any_annotations): Likewise.
(sarif_replayer::handle_result_obj): Likewise.
(make_plain_text_within_result_message): Likewise.
(handle_thread_flow_location_object): Likewise.
(handle_location_object): Likewise.
(sarif_replayer::handle_graph_object): Likewise.
(sarif_replayer::handle_node_object): Likewise.
(sarif_replayer::handle_edge_object): Likewise.
* pretty-print-format-impl.h (pp_token_list::push_back_byte): New
decl.
* pretty-print-markup.h (pp_markup::context::begin_url): New decl.
(pp_markup::context::end_url): New decl.
(pp_markup::context::add_event_id): New decl.
* pretty-print.cc: Include "auto-obstack.h".
(pp_token_list::push_back_byte): New.
(struct auto_obstack): Move to auto-obstack.h.
(default_token_printer): Make non-static.
(pp_markup::context::begin_url): New.
(pp_markup::context::end_url): New.
(pp_markup::context::add_event_id): New.

gcc/testsuite/ChangeLog:
PR sarif-replay/120792
* libgdiagnostics.dg/sarif.py: Delete duplicate script.
* libgdiagnostics.dg/test-message-buffer-c.py: New test script.
* libgdiagnostics.dg/test-message-buffer.c: New test.
* libgdiagnostics.dg/test-warning-with-path-c.py: Update expected
output to reflect that SARIF for event messages now contains JSON
pointers when referring to other events by ID.
* sarif-replay.dg/2.1.0-valid/3.11.6-embedded-links.sarif: Add
HTML and SARIF output, and call out to Python scripts to verify
the output.  Add example of a result with a link in its message.
* sarif-replay.dg/2.1.0-valid/embedded-links-check-html.py: New
test script.
* sarif-replay.dg/2.1.0-valid/embedded-links-check-sarif-roundtrip.py:
New test script.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 weeks agolibstdc++: Constrain std::swap using concepts in C++20
Jonathan Wakely [Mon, 14 Jul 2025 10:13:54 +0000 (11:13 +0100)] 
libstdc++: Constrain std::swap using concepts in C++20

This is a minor compile-time optimization for C++20.

libstdc++-v3/ChangeLog:

* include/bits/move.h (swap): Replace enable_if with concepts
when available, and with __enable_if_t alias otherwise.

2 weeks agolibstdc++: Make ranges::advance(it, n, bound) follow standard more strictly
Jonathan Wakely [Mon, 14 Jul 2025 10:21:24 +0000 (11:21 +0100)] 
libstdc++: Make ranges::advance(it, n, bound) follow standard more strictly

The standard specifies some of the effects of ranges::advance in terms
of "Equivalent to:" and it's observable that our current implementation
deviates from the precise specification in the standard.  This was
causing some failures in the libc++ testsuite.

For the sized_sentinel_for<I, S> case I optimized our implementation to
avoid redundant calls when we have already checked that there's nothing
to do.  We were eliding `advance(i, bound)` when the iterator already
equals the sentinel, and eliding `advance(i, n)` when `n` is zero. In
both cases, removing the seemingly redundant calls is not equivalent to
the spec because `i = std::move(bound)` or `i += 0` operations can be
observed by program-defined iterators. This patch inlines the observable
side effects of advance(i, bound) or advance(i, 0) without actually
calling those functions.

For the non-sized sentinel case, `if (i == bound || n == 0)` is
different from `if (n == 0 || i == bound)` for the case where n is zero
and a program-defined iterator observes the number of comparisons.
This patch changes it to do `n == 0` first. I don't think this is
required by the standard, as this condition is not "Equivalent to:" any
observable sequence of operations, but testing `n == 0` first is
probably cheaper anyway.

libstdc++-v3/ChangeLog:

* include/bits/ranges_base.h (ranges::advance(i, n, bound)):
Ensure that observable side effects on iterators match what is
specified in the standard.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 weeks agolibstdc++: Add missing initializers for __maybe_present_t members [PR119962]
Patrick Palka [Tue, 15 Jul 2025 19:17:23 +0000 (15:17 -0400)] 
libstdc++: Add missing initializers for __maybe_present_t members [PR119962]

Data members of type __maybe_present_t where the conditionally present
type might be an aggregate or fundamental type need to be explicitly
value-initialized (rather than implicitly default-initialized), so that
default-initialization of the containing class always results in an
completely initialized object.

PR libstdc++/119962

libstdc++-v3/ChangeLog:

* include/std/ranges (join_view::_Iterator::_M_outer): Initialize.
(lazy_split_view::_OuterIter::_M_current): Initialize.
(join_with_view::_Iterator::_M_outer_it): Initialize.
* testsuite/std/ranges/adaptors/join.cc (test15): New test.
* testsuite/std/ranges/adaptors/join_with/1.cc (test05): New test.
* testsuite/std/ranges/adaptors/lazy_split.cc (test13): New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2 weeks agoc++: don't mark void exprs as read [PR44677]
Jason Merrill [Mon, 14 Jul 2025 22:29:17 +0000 (18:29 -0400)] 
c++: don't mark void exprs as read [PR44677]

In Jakub's patch for PR44677 he added code to prevent mark_exp_read on
e.g. (void)++i from marking i as read, but it seems to me that we can
generalize that to avoid looking any farther into any void expression;
you can't read a void value, and an explicit cast will have already called
mark_exp_read on its operand in convert_to_void.

For testing I added an assert to catch places where we were trying to mark
void expressions as read, and fix a few that it found.  But there were
several other places (such as check_return_expr) where we could have a void
expression but always calling mark_exp_read makes sense, so I dropped the
assert from the final commit.

PR c++/44677

gcc/cp/ChangeLog:

* cp-gimplify.cc (cp_fold) [CLEANUP_POINT_EXPR]: Don't force rvalue.
[COMPOUND_EXPR]: Likewise.
* cvt.cc (convert_to_void): Call mark_exp_read later.
* expr.cc (mark_use): Turn off read_p for any void argument.
(mark_exp_read): Return early for void argument.

2 weeks ago[PATCH v5] RISC-V: Mips P8700 Conditional Move Support.
Umesh Kalappa [Tue, 15 Jul 2025 16:35:44 +0000 (10:35 -0600)] 
[PATCH v5] RISC-V: Mips P8700 Conditional Move Support.

Updated the test for rv32 accordingly and no regress found for runs like
"runtest --tool gcc --target_board='riscv-sim/-march=rv32gc_zba_zbb_zbc_zbs/-mabi=ilp32d/-mcmodel=medlow' riscv.exp" and
"runtest --tool gcc --target_board='riscv-sim/-march=rv64gc_zba_zbb_zbc_zbs/-mabi=lp64d/-mcmodel=medlow' riscv.exp"

lint warnings can be ignored for riscv-cores.def and riscv-ext-mips.def

gcc/ChangeLog:

* config/riscv/riscv-cores.def (RISCV_CORE): Updated the supported march.
* config/riscv/riscv-ext-mips.def (DEFINE_RISCV_EXT):
New file added for mips conditional mov extension.
* config/riscv/riscv-ext.def: Likewise.
* config/riscv/t-riscv: Generates riscv-ext.opt
* config/riscv/riscv-ext.opt: Generated file.
* config/riscv/riscv.cc (riscv_expand_conditional_move): Updated for mips cmov
and outlined some code that handle arch cond move.
* config/riscv/riscv.md (mov<mode>cc): updated expand for MIPS CCMOV.
* config/riscv/mips-insn.md: New file for mips-p8700 ccmov insn.
* doc/riscv-ext.texi: Updated for mips cmov.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/mipscondmov.c: Test file for mips.ccmov insn.

2 weeks agolibgcc: Fix aarch64 build
Andrew Pinski [Tue, 15 Jul 2025 15:56:31 +0000 (08:56 -0700)] 
libgcc: Fix aarch64 build

For aarch64, libgcc is built with -Werror, after the latest
-Wunused-but-set* commit (r16-2258-g0eac9cfee8cb0b21d), a new warning
showed up:
```
../../../gcc/libgcc/config/libbid/bid_binarydecimal.c: In function
‘__binary32_to_bid128’:
../../../gcc/libgcc/config/libbid/bid_binarydecimal.c:130:31: error:
variable â€˜c3’ set but not used [-Werror=unused-but-set-variable=]
  130 | { unsigned long long c0,c1,c2,c3;                               \
      |                               ^~
../../../gcc/libgcc/config/libbid/bid_binarydecimal.c:146842:5: note:
in expansion of macro â€˜__mul_10x256_to_256’
146842 |     __mul_10x256_to_256 (z.w[5], z.w[4], z.w[3], z.w[2],
z.w[5], z.w[4],
       |     ^~~~~~~~~~~~~~~~~~~
```

This fixes it by casting c3 to void after the last __mul_10x64 in
__mul_10x256_to_256 macro to mark it as being "used".

libgcc/config/libbid/ChangeLog:

* bid_binarydecimal.c (__mul_10x256_to_256): Mark c3 as being
used.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 weeks agolibstdc++: Implement std::chrono::current_zone() for Windows [PR108409]
Björn Schäpers [Thu, 10 Jul 2025 07:48:19 +0000 (09:48 +0200)] 
libstdc++: Implement std::chrono::current_zone() for Windows [PR108409]

On Windows there is no API to get the current time zone as IANA name,
instead Windows has its own zones. But there exists a mapping provided
by the Unicode Consortium. This patch adds a script to convert the XML
file with the mapping to a lookup table and adds a Windows code path to
use that mapping.

libstdc++-v3/Changelog:

Implement std::chrono::current_zone() for Windows

PR libstdc++/108409
* scripts/gen_windows_zones_map.py: New file, generates
windows_zones-map.h.
* src/c++20/windows_zones-map.h: New file, contains the look up
table.
* src/c++20/tzdb.cc (tzdb::current_zone): Add Windows code path.

Signed-off-by: Björn Schäpers <bjoern@hazardy.de>
2 weeks agolibstdc++: Search for tzdata on Windows (msys)
Björn Schäpers [Mon, 7 Jul 2025 22:43:34 +0000 (00:43 +0200)] 
libstdc++: Search for tzdata on Windows (msys)

Windows does not provide a tzdata.zi, but msys does. Use this, if
available, instead of the embedded (and possibly outdated) database.

libstdc++-v3/Changelog:

Use msys provided time zone information.

* src/c++20/tzdb.cc (zoneinfo_file): On Windows look relative
from the DLL path for the time zone information.

Signed-off-by: Björn Schäpers <bjoern@hazardy.de>
2 weeks agoc++: constexpr uninitialized union [PR120577]
Jason Merrill [Sat, 12 Jul 2025 09:15:01 +0000 (05:15 -0400)] 
c++: constexpr uninitialized union [PR120577]

This was failing for two reasons:

1) We were wrongly treating the basic_string constructor as
zero-initializing the object, which it doesn't.
2) Given that, when we went to look for a value for the anonymous union,
we concluded that it was value-initialized, and trying to evaluate that
broke because we weren't setting ctx->ctor for it.

This patch fixes both issues, #1 by setting CONSTRUCTOR_NO_CLEARING and #2
by inserting a new CONSTRUCTOR for the member rather than evaluate it out of
context, which is consistent with cxx_eval_store_expression.

PR c++/120577

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_call_expression): Set
CONSTRUCTOR_NO_CLEARING on initial value for ctor.
(cxx_eval_component_reference): Make value-initialization
of an aggregate member explicit.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/constexpr-union9.C: New test.

2 weeks agoc++: decomp25 vs -fimplicit-constexpr [PR117784]
Jason Merrill [Tue, 15 Jul 2025 14:46:41 +0000 (10:46 -0400)] 
c++: decomp25 vs -fimplicit-constexpr [PR117784]

Avoid diagnostic changes from -fimplicit-constexpr.

PR c++/117784

gcc/testsuite/ChangeLog:

* g++.dg/cpp26/decomp25.C: Add -fno-implicit-constexpr.

2 weeks agoopenmp, fortran: Fix ICE when the procedure name cannot be found in declare variant...
Kwok Cheung Yeung [Tue, 15 Jul 2025 14:26:26 +0000 (15:26 +0100)] 
openmp, fortran: Fix ICE when the procedure name cannot be found in declare variant directives [PR104428]

The result of searching for the procedure name symbol should be checked in
case the symbol cannot be found to avoid a null dereference.

gcc/fortran/

PR fortran/104428
* trans-openmp.cc (gfc_trans_omp_declare_variant): Check that proc_st
is non-NULL before dereferencing.  Add line number to error message.

gcc/testsuite/

PR fortran/104428
* gfortran.dg/gomp/pr104428.f90: New.

2 weeks agoasf: Fix offset check in base reg initialization for big-endian targets
Konstantinos Eleftheriou [Tue, 3 Jun 2025 07:16:17 +0000 (09:16 +0200)] 
asf: Fix offset check in base reg initialization for big-endian targets

During the base register initialization, in the case that we are
eliminating the load instruction, we are using `offset == 0` in order
to find the store instruction that has the same offset as the
load. This would not work on big-endian targets where byte 0 would be
the MS byte.

This patch updates the condition to take into account the target's
endianness.

We are, also, removing the adjustment of the starting position for the
bitfield insertion, when BYTES_BIG_ENDIAN != BITS_BIG_ENDIAN. This is
supposed to be handled inside `store_bit_field` and it's not needed
anymore after the offset fix.

Bootstrapped/regtested on AArch64 LE, x86_64 and PowerPC LE.

gcc/ChangeLog:

* avoid-store-forwarding.cc (generate_bit_insert_sequence):
Remove adjustment of bitfield insertion's starting position
when BYTES_BIG_ENDIAN != BITS_BIG_ENDIAN.
(process_store_forwarding): Update offset check in base reg
initialization to take into account the target's endianness.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/avoid-store-forwarding-be.c: New test.

2 weeks agoaarch64: Enable selective LDAPUR generation for cores with RCPC2
Soumya AR [Tue, 15 Jul 2025 13:58:44 +0000 (19:28 +0530)] 
aarch64: Enable selective LDAPUR generation for cores with RCPC2

This patch adds the ability to fold the address computation into the addressing
mode for LDAPR instructions using LDAPUR when RCPC2 is available.

LDAPUR emission is enabled by default when RCPC2 is available, but can be
disabled using the avoid_ldapur tune flag on a per-core basis.

Currently, it is disabled for neoverse-v2, neoverse-v3, cortex-x925, and
architecutres before armv8.8-a.

Earlier, the following code:

uint64_t
foo (std::atomic<uint64_t> *x)
{
  return x[1].load(std::memory_order_acquire);
}

would generate:

foo(std::atomic<unsigned long>*):
add     x0, x0, 8
ldapr   x0, [x0]
ret

but now generates:

foo(std::atomic<unsigned long>*):
ldapur  x0, [x0, 8]
ret

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

Signed-off-by: Soumya AR <soumyaa@nvidia.com>
gcc/ChangeLog:

* config/aarch64/aarch64-tuning-flags.def (AARCH64_EXTRA_TUNING_OPTION):
Add AVOID_LDAPUR tuning flag.
* config/aarch64/aarch64.cc (aarch64_adjust_generic_arch_tuning):
Set AVOID_LDAPUR for architectures before armv8.8-a.
(aarch64_override_options_internal): Apply generic tuning adjustments
to generic_armv8_a_tunings and generic_armv9_a_tunings.
* config/aarch64/aarch64.h (TARGET_ENABLE_LDAPUR): New macro to
control LDAPUR usage based on RCPC2 and tuning flags.
* config/aarch64/aarch64.md: Add enable_ldapur attribute.
* config/aarch64/atomics.md (aarch64_atomic_load<mode>_rcpc): Modify
to emit LDAPUR for cores with RCPC2.
(*aarch64_atomic_load<ALLX:mode>_rcpc_zext): Likewise.
(*aarch64_atomic_load<ALLX:mode>_rcpc_sext): Update constraint to Ust.
* config/aarch64/tuning_models/cortexx925.h: Add AVOID_LDAPUR flag.
* config/aarch64/tuning_models/neoversev2.h: Likewise.
* config/aarch64/tuning_models/neoversev3.h: Likewise.
* config/aarch64/tuning_models/neoversev3ae.h: Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/ldapr-sext.c: Update expected output to include
offsets.
* gcc.target/aarch64/ldapur.c: New test for LDAPUR.
* gcc.target/aarch64/ldapur_avoid.c: New test for AVOID_LDAPUR flag.

2 weeks agolibstdc++: Tweak dg-error patterns for C++26 constexpr changes
Jonathan Wakely [Fri, 11 Jul 2025 22:49:05 +0000 (23:49 +0100)] 
libstdc++: Tweak dg-error patterns for C++26 constexpr changes

libstdc++-v3/ChangeLog:

* testsuite/25_algorithms/copy/debug/constexpr_neg.cc:
* testsuite/25_algorithms/copy_backward/debug/constexpr_neg.cc:
* testsuite/25_algorithms/equal/debug/constexpr_neg.cc:
* testsuite/25_algorithms/lower_bound/debug/constexpr_partitioned_neg.cc:
* testsuite/25_algorithms/lower_bound/debug/constexpr_partitioned_pred_neg.cc:
* testsuite/25_algorithms/lower_bound/debug/constexpr_valid_range_neg.cc:
* testsuite/25_algorithms/upper_bound/debug/constexpr_partitioned_neg.cc:
* testsuite/25_algorithms/upper_bound/debug/constexpr_partitioned_pred_neg.cc:
* testsuite/25_algorithms/upper_bound/debug/constexpr_valid_range_neg.cc:

2 weeks agotree-optimization/121059 - fixup loop mask query
Richard Biener [Mon, 14 Jul 2025 12:09:28 +0000 (14:09 +0200)] 
tree-optimization/121059 - fixup loop mask query

When we opportunistically mask an operand of a AND with an already
available loop mask we need to query that set with the correct number
of masks we expect.

PR tree-optimization/121059
* tree-vect-stmts.cc (vectorizable_operation): Query
scalar_cond_masked_set with the correct number of masks.

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

Co-Authored-By: Richard Sandiford <richard.sandiford@arm.com>
2 weeks agoc, c++: Extend -Wunused-but-set-* warnings [PR44677]
Jakub Jelinek [Tue, 15 Jul 2025 13:00:33 +0000 (15:00 +0200)] 
c, c++: Extend -Wunused-but-set-* warnings [PR44677]

The -Wunused-but-set-* warnings work by using 2 bits on VAR_DECLs &
PARM_DECLs, TREE_USED and DECL_READ_P.  If neither is set, we typically
emit -Wunused-variable or -Wunused-parameter warning, that is for variables
which are just declared (including initializer) and completely unused.
If TREE_USED is set and DECL_READ_P is unset, -Wunused-but-set-* warnings
are emitted, i.e. for variables which can appear on the lhs of an assignment
expression but aren't actually used elsewhere.  The DECL_READ_P marking is
done through mark_exp_read called from lots of places (e.g. lvalue to rvalue
conversions etc.).

LLVM has an extension on top of that in that it doesn't count pre/post
inc/decrements as use (i.e. DECL_READ_P for GCC).

The following patch does that too, though because we had the current
behavior for 11+ years already and lot of people is -Wunused-but-set-*
warning free in the current GCC behavior and not in the clang one (including
GCC sources), it allows users to choose.
Furthermore, it implements another level, where also var @= expr uses of var
(except when it is also used in expr) aren't counted as DECL_READ_P.

I think it would be nice to also handle var = var @ expr or var = expr @ var
but unfortunately mark_exp_read is then done in both FEs during parsing of
var @ expr or expr @ var and the code doesn't know it is rhs of an
assignment with var as lhs.

The patch works mostly by checking if DECL_READ_P is clear at some point and
then clearing it again after some operation which might have set it.

-Wunused or -Wall or -Wunused -Wextra or -Wall -Wextra turn on the 3 level
of the new warning (i.e. the one which ignores also var++, ++var etc. as
well as var @= expr), so does -Wunused-but-set-{variable,parameter}, but
users can use explicit -Wunused-but-set-{variable,parameter}={1,2} to select
a different level.

2025-07-15  Jakub Jelinek  <jakub@redhat.com>
    Jason Merrill  <jason@redhat.com>

PR c/44677
gcc/
* common.opt (Wunused-but-set-parameter=, Wunused-but-set-variable=):
New options.
(Wunused-but-set-parameter, Wunused-but-set-variable): Turn into
aliases.
* common.opt.urls: Regenerate.
* diagnostic-spec.cc (nowarn_spec_t::nowarn_spec_t): Use
OPT_Wunused_but_set_variable_ instead of OPT_Wunused_but_set_variable
and OPT_Wunused_but_set_parameter_ instead of
OPT_Wunused_but_set_parameter.
* gimple-ssa-store-merging.cc (find_bswap_or_nop_1): Remove unused
but set variable tmp.
* ipa-strub.cc (pass_ipa_strub::execute): Cast named_args to
(void) if ATTR_FNSPEC_DECONST_WATERMARK is not defined.
* doc/invoke.texi (Wunused-but-set-parameter=,
Wunused-but-set-variable=): Document new options.
(Wunused-but-set-parameter, Wunused-but-set-variable): Adjust
documentation now that they are just aliases.
gcc/c-family/
* c-opts.cc (c_common_post_options): Change
warn_unused_but_set_parameter and warn_unused_but_set_variable
from 1 to 3 if they were set only implicitly.
* c-attribs.cc (build_attr_access_from_parms): Remove unused
but set variable nelts.
gcc/c/
* c-parser.cc (c_parser_unary_expression): Clear DECL_READ_P
after default_function_array_read_conversion for
-Wunused-but-set-{parameter,variable}={2,3} on
PRE{IN,DE}CREMENT_EXPR argument.
(c_parser_postfix_expression_after_primary): Similarly for
POST{IN,DE}CREMENT_EXPR.
* c-decl.cc (pop_scope): Use OPT_Wunused_but_set_variable_
instead of OPT_Wunused_but_set_variable.
(finish_function): Use OPT_Wunused_but_set_parameter_
instead of OPT_Wunused_but_set_parameter.
* c-typeck.cc (mark_exp_read): Handle {PRE,POST}{IN,DE}CREMENT_EXPR
and don't handle it when cast to void.
(build_modify_expr): Clear DECL_READ_P after build_binary_op
for -Wunused-but-set-{parameter,variable}=3.
gcc/cp/
* cp-gimplify.cc (cp_fold): Clear DECL_READ_P on lhs of MODIFY_EXPR
after cp_fold_rvalue if it wasn't set before.
* decl.cc (poplevel): Use OPT_Wunused_but_set_variable_
instead of OPT_Wunused_but_set_variable.
(finish_function): Use OPT_Wunused_but_set_parameter_
instead of OPT_Wunused_but_set_parameter.
* expr.cc (mark_use): Clear read_p for {PRE,POST}{IN,DE}CREMENT_EXPR
cast to void on {VAR,PARM}_DECL for
-Wunused-but-set-{parameter,variable}={2,3}.
(mark_exp_read): Handle {PRE,POST}{IN,DE}CREMENT_EXPR and don't handle
it when cast to void.
* module.cc (trees_in::fn_parms_fini): Remove unused but set variable
ix.
* semantics.cc (finish_unary_op_expr): Return early for
PRE{IN,DE}CREMENT_EXPR.
* typeck.cc (cp_build_unary_op): Clear DECL_READ_P
after mark_lvalue_use for -Wunused-but-set-{parameter,variable}={2,3}
on PRE{IN,DE}CREMENT_EXPR argument.
(cp_build_modify_expr): Clear DECL_READ_P after cp_build_binary_op
for -Wunused-but-set-{parameter,variable}=3.
gcc/go/
* gofrontend/gogo.cc (Function::export_func_with_type): Remove
unused but set variable i.
gcc/cobol/
* gcobolspec.cc (lang_specific_driver): Remove unused but set variable
n_cobol_files.
gcc/testsuite/
* c-c++-common/Wunused-parm-1.c: New test.
* c-c++-common/Wunused-parm-2.c: New test.
* c-c++-common/Wunused-parm-3.c: New test.
* c-c++-common/Wunused-parm-4.c: New test.
* c-c++-common/Wunused-parm-5.c: New test.
* c-c++-common/Wunused-parm-6.c: New test.
* c-c++-common/Wunused-var-7.c (bar, baz): Expect warning on a.
* c-c++-common/Wunused-var-19.c: New test.
* c-c++-common/Wunused-var-20.c: New test.
* c-c++-common/Wunused-var-21.c: New test.
* c-c++-common/Wunused-var-22.c: New test.
* c-c++-common/Wunused-var-23.c: New test.
* c-c++-common/Wunused-var-24.c: New test.
* g++.dg/cpp26/name-independent-decl1.C (foo): Expect one
set but not used warning.
* g++.dg/warn/Wunused-parm-12.C: New test.
* g++.dg/warn/Wunused-parm-13.C: New test.
* g++.dg/warn/Wunused-var-2.C (f2): Expect set but not used warning
on parameter x and variable a.
* g++.dg/warn/Wunused-var-40.C: New test.
* g++.dg/warn/Wunused-var-41.C: New test.
* gcc.dg/memchr-3.c (test_find): Change return type from void to int,
and add return n; statement.
* gcc.dg/unused-9.c (g): Move dg-bogus to the correct line and expect
a warning on i.

2 weeks agoaarch64: fixup: Implement sme2+faminmax extension.
Alfie Richards [Fri, 4 Jul 2025 15:37:10 +0000 (15:37 +0000)] 
aarch64: fixup: Implement sme2+faminmax extension.

Fixup to the SME2+FAMINMAX intrinsics commit.

gcc/ChangeLog:

* config/aarch64/aarch64-sme.md (@aarch64_sme_<faminmax_uns_op><mode>):
Change gating and comment.

2 weeks agolibstdc++: Ensure that ranges::destroy destroys in constexpr [PR121024]
Jonathan Wakely [Thu, 10 Jul 2025 13:12:44 +0000 (14:12 +0100)] 
libstdc++: Ensure that ranges::destroy destroys in constexpr [PR121024]

The new test is currently marked as XFAIL because PR c++/102284 means
that GCC doesn't notice that the lifetimes have ended.

libstdc++-v3/ChangeLog:

PR libstdc++/121024
* include/bits/ranges_uninitialized.h (ranges::destroy): Do not
optimize away trivial destructors during constant evaluation.
(ranges::destroy_n): Likewise.
* testsuite/20_util/specialized_algorithms/destroy/121024.cc:
New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 weeks agolibstdc++: Make all experimental::observer_ptr functions constexpr
Jonathan Wakely [Mon, 14 Jul 2025 10:11:28 +0000 (11:11 +0100)] 
libstdc++: Make all experimental::observer_ptr functions constexpr

I've just created LWG 4295 proposing this change, and am implementing it
via this patch.

libstdc++-v3/ChangeLog:

* include/experimental/memory (swap, make_observer_ptr): Add
constexpr.
(operator==, operator!=, operator<, operator>, operator<=)
(operator>=): Likewise.
* testsuite/experimental/memory/observer_ptr/make_observer.cc:
Checks for constant evaluation.
* testsuite/experimental/memory/observer_ptr/relops/relops.cc:
Likewise.
* testsuite/experimental/memory/observer_ptr/swap/swap.cc:
Likewise.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 weeks agolibstdc++: Ensure std::make_unsigned<Enum> works for 128-bit enum
Jonathan Wakely [Sun, 13 Jul 2025 14:05:52 +0000 (15:05 +0100)] 
libstdc++: Ensure std::make_unsigned<Enum> works for 128-bit enum

Another follow-up to r16-2190-g4faa42ac0dee2c, ensuring that make_signed
and make_unsigned work on enumeration types with 128-bit integers as
their underlying type.

libstdc++-v3/ChangeLog:

* include/std/type_traits (__make_unsigned_selector): Add
unsigned __int128 to type list.
* testsuite/20_util/make_unsigned/int128.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 weeks agolibstdc++: Ensure std::hash<__int128> is defined [PR96710]
Jonathan Wakely [Fri, 16 May 2025 12:33:23 +0000 (13:33 +0100)] 
libstdc++: Ensure std::hash<__int128> is defined [PR96710]

This is a follow-up to r16-2190-g4faa42ac0dee2c which ensures that
std::hash is always enabled for signed and unsigned __int128. The
standard requires std::hash to be enabled for all arithmetic types.

libstdc++-v3/ChangeLog:

PR libstdc++/96710
* include/bits/functional_hash.h (hash<__int128>): Define for
strict modes.
(hash<unsigned __int128>): Likewise.
* testsuite/20_util/hash/int128.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 weeks agoRevert "aarch64: Use EOR3 for DImode values"
Kyrylo Tkachov [Tue, 15 Jul 2025 08:49:15 +0000 (10:49 +0200)] 
Revert "aarch64: Use EOR3 for DImode values"

This reverts commit cfa827188dc236ba905b12ef06ccc517b9f2de39.

2 weeks agolibstdc++: Format %a/%A/%b/%h/%B/%p without using locale::classic [PR110739]
Tomasz KamiÅ„ski [Fri, 27 Jun 2025 13:04:19 +0000 (15:04 +0200)] 
libstdc++: Format %a/%A/%b/%h/%B/%p without using locale::classic [PR110739]

With changes r16-2063-g8ad5968a8dcb47 the _M_a_A, _M_b_B and _M_p functions
are called only if the locale is equal to the locale::classic(), for which
the behavior is know. This patch changes they implementation, so instead of
reffering to __timepunct facet members, they use hardcoded list of English
weekday, months names. Only one list is needed, as in case of locale::classic()
abbreviated name corresponds to first tree letters of the full name.

For _M_p, _M_r we use a new _M_fill_ampm helper, that fills provided buffer
with "AM"/"PM" depending on the hours value.

In _M_S we no longer guard querying of numpuct facet, with check that requires
potentially equally expensive construction of locale::classic. We also mark
localized path as unlikely.

The _M_locale method is no longer used in __formatter_chrono, and thus was
moved to __formatter_duration.

PR libstdc++/110739

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (__formatter_chrono::_S_weekdays)
(__formatter_chrono::_S_months, __formatter_chrono::_S_fill_ampm):
Define.
(__formatter_chrono::_M_format_to): Do not pass context parameter
to functions listed below.
(__formatter_chrono::_M_a_A, __formatter_chrono::_M_b_B): Implement
using harcoded list of names, and remove format context parameter.
(__formatter_chrono::_M_p, __formatter_chrono::_M_r): Implement
using _S_fill_ampm.
(__formatter_chrono::_M_c): Removed format context parameter.
(__formatter_chrono::_M_subsecs): Call __ctx.locale() directly,
instead of _M_locale and do not compare with locale::classic().
Add [[unlikely]] attributes.
(__formatter_chrono::_M_locale): Move to __formatter_duration.
(__formatter_duration::_M_locale): Moved from __formatter_chrono.

2 weeks agoaarch64: AND/BIC combines for unpacked SVE FP comparisons
Spencer Abson [Wed, 2 Jul 2025 21:31:40 +0000 (21:31 +0000)] 
aarch64: AND/BIC combines for unpacked SVE FP comparisons

This patch extends the splitting patterns for combining FP comparisons
with predicated logical operations such that they cover all of SVE_F.

gcc/ChangeLog:

* config/aarch64/aarch64-sve.md (*fcm<cmp_op><mode>_and_combine):
Extend from SVE_FULL_F to SVE_F.
(*fcmuo<mode>_and_combine): Likewise.
(*fcm<cmp_op><mode>_bic_combine): Likewise.
(*fcm<cmp_op><mode>_nor_combine): Likewise.
(*fcmuo<mode>_bic_combine): Likewise.
(*fcmuo<mode>_nor_combine): Likewise.  Move the comment here to
above fcmuo<mode>_bic_combine, since it applies to both patterns.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve/unpacked_fcm_combines_1.c: New test.
* gcc.target/aarch64/sve/unpacked_fcm_combines_2.c: Likewise.

2 weeks agofortran: Amend descriptor bounds init if unallocated
Mikael Morin [Tue, 15 Jul 2025 07:58:44 +0000 (09:58 +0200)] 
fortran: Amend descriptor bounds init if unallocated

Always generate the conditional initialization of unallocated variables
regardless of the basic variable allocation tracking done in the
frontend and with an additional always false condition.

The scalarizer used to always evaluate array bounds, including in the
case of unallocated arrays on the left hand side of an assignment.  This
was (correctly) causing uninitialized warnings, even if the
uninitialized values were in the end discarded.

Since the fix for PR fortran/108889, an initialization of the descriptor
bounds is added to silent the uninitialized warnings, conditional on the
array being unallocated.  This initialization is not useful in the
execution of the program, and it is removed if the compiler can prove
that the variable is unallocated (in the case of a local variable for
example).  Unfortunately, the compiler is not always able to prove it
and the useless initialization may remain in the final code.
Moreover, the generated code that was causing the evaluation of
uninitialized variables has ben changed to avoid them, so we can try to
remove or revisit that unallocated variable bounds initialization tweak.

Unfortunately, just removing the extra initialization restores the
warnings at -O0, as there is no dead code removal at that optimization
level.  Instead, this change keeps the initialization and modifies its
guarding condition with an extra always false variable, so that if
optimizations are enabled the whole initialization block is removed, and
if they are disabled it remains and is sufficient to prevent the
warning.

The new variable requires the code generation to be done earlier in the
function so that the variable declaration and usage are in the same
scope.

As the modified condition guarantees the removal of the block with
optimizations, we can emit it more broadly and remove the basic
allocation tracking that was done in the frontend to limit its emission.

gcc/fortran/ChangeLog:

* gfortran.h (gfc_symbol): Remove field allocated_in_scope.
* trans-array.cc (gfc_array_allocate): Don't set it.
(gfc_alloc_allocatable_for_assignment): Likewise.
Generate the unallocated descriptor bounds initialisation
before the opening of the reallocation code block.  Create a
variable and use it as additional condition to the unallocated
descriptor bounds initialisation.

2 weeks agofortran: Delay evaluation of array bounds after reallocation
Mikael Morin [Tue, 15 Jul 2025 07:58:35 +0000 (09:58 +0200)] 
fortran: Delay evaluation of array bounds after reallocation

Delay the evaluation of bounds, offset, etc after the reallocation,
for the scalarization of allocatable arrays on the left hand side of
assignments.

Before this change, the code preceding the scalarization loop is like:

    D.4757 = ref2.offset;
    D.4759 = ref2.dim[0].ubound;
    D.4762 = ref2.dim[0].lbound;
    {
      if (ref2.data == 0B) goto realloc;
      if (ref2.dim[0].lbound + 4 != ref2.dim[0].ubound) goto realloc;
      goto L.10;
      realloc:
      ... change offset and bounds ...
      D.4757 = ref2.offset;
      D.4762 = NON_LVALUE_EXPR <ref2.dim[0].lbound>;
      ... reallocation ...
      L.10:;
    }
    while (1)
      {
... scalarized code ...

so the bounds etc are evaluated first to variables, and the reallocation
code takes care to update the variables during the reallocation.  This
is problematic because the variables' initialization references the
array bounds, which for unallocated arrays are uninitialized at the
evaluation point.  This used to (correctly) cause uninitialized warnings
(see PR fortran/108889), and a workaround for variables was found, that
initializes the bounds of arrays variables to some value beforehand if
they are unallocated.  For allocatable components, there is no warning
but the problem remains, some uninitialized values are used, even if
discarded later.

After this change the code becomes:

    {
      if (ref2.data == 0B) goto realloc;
      if (ref2.dim[0].lbound + 4 != ref2.dim[0].ubound) goto realloc;
      goto L.10;
      realloc:;
      ... change offset and bounds ...
      ... reallocation ...
      L.10:;
    }
    D.4762 = ref2.offset;
    D.4763 = ref2.dim[0].lbound;
    D.4764 = ref2.dim[0].ubound;
    while (1)
      {
... scalarized code

so the scalarizer avoids storing the values to variables at the time it
evaluates them, if the array is reallocatable on assignment.  Instead,
it keeps expressions with references to the array descriptor fields,
expressions that remain valid through reallocation.  After the
reallocation code has been generated, the expressions stored by the
scalarizer are evaluated in place to variables.

The decision to delay evaluation is based on the existing field
is_alloc_lhs, which requires a few tweaks to be alway correct wrt to
what its name suggests.  Namely it should be set even if the assignment
right hand side is an intrinsic function, and it should not be set if
the right hand side is a scalar and neither if the -fno-realloc-lhs flag
is passed to the compiler.

gcc/fortran/ChangeLog:

* trans-array.cc (gfc_conv_ss_descriptor): Don't evaluate
offset and data to a variable if is_alloc_lhs is set.  Move the
existing evaluation decision condition for data...
(save_descriptor_data): ... here as a new predicate.
(evaluate_bound): Add argument save_value.  Omit the evaluation
of the value to a variable if that argument isn't set.
(gfc_conv_expr_descriptor): Update caller.
(gfc_conv_section_startstride): Update caller.  Set save_value
if is_alloc_lhs is not set.  Omit the evaluation of stride to a
variable if save_value isn't set.
(gfc_set_delta): Omit the evaluation of delta to a variable
if is_alloc_lhs is set.
(gfc_is_reallocatable_lhs): Return false if flag_realloc_lhs
isn't set.
(gfc_alloc_allocatable_for_assignment): Don't update
the variables that may be stored in saved_offset, delta, and
data.  Call instead...
(update_reallocated_descriptor): ... this new procedure.
* trans-expr.cc (gfc_trans_assignment_1): Don't omit setting the
is_alloc_lhs flag if the right hand side is an intrinsic
function.  Clear the flag if the right hand side is scalar.

2 weeks agofortran: Generate array reallocation out of loops
Mikael Morin [Tue, 15 Jul 2025 07:58:26 +0000 (09:58 +0200)] 
fortran: Generate array reallocation out of loops

Generate the array reallocation on assignment code before entering the
scalarization loops.  This doesn't move the generated code itself,
which was already put before the outermost loop, but only changes the
current scope at the time the code is generated.  This is a prerequisite
for a followup patch that makes the reallocation code create new
variables.  Without this change the new variables would be declared in
the innermost loop body and couldn't be used outside of it.

gcc/fortran/ChangeLog:

* trans-expr.cc (gfc_trans_assignment_1): Generate array
reallocation code before entering the scalarisation loops.

2 weeks agoFix tree.cc compilation on SPARC
Rainer Orth [Tue, 15 Jul 2025 07:49:52 +0000 (09:49 +0200)] 
Fix tree.cc compilation on SPARC

commit 4d7baa94a48c27030c8ffcfaf3dd187be09903a9
Author: Andrew Pinski <quic_apinski@quicinc.com>
Date:   Sun Jul 13 11:56:03 2025 -0700

    tree: Add include to tm_p.h to tree.cc [PR120866]

broke SPARC bootstrap:

In file included from ./tm_p.h:4,
                 from /vol/gcc/src/hg/master/local/gcc/tree.cc:35:
/vol/gcc/src/hg/master/local/gcc/config/sparc/sparc-protos.h:46:47: error: use of enum â€˜memmodel’ without previous declaration
   46 | extern void sparc_emit_membar_for_model (enum memmodel, int, int);
      |

Fixed by including memmodel.h.

Bootstrapped without regressions on sparc-sun-solaris2.11 and
i386-pc-solaris2.11.

2025-07-15  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc:
* tree.cc: Include memmodel.h.

2 weeks agofortran: Fix indentation
Filip Kastl [Tue, 15 Jul 2025 06:39:00 +0000 (08:39 +0200)] 
fortran: Fix indentation

Move a block of code two spaces to the left.  Commiting as obvious.

gcc/fortran/ChangeLog:

* resolve.cc (resolve_select_type): Fix indentation.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
2 weeks agoDaily bump.
GCC Administrator [Tue, 15 Jul 2025 00:18:55 +0000 (00:18 +0000)] 
Daily bump.

2 weeks agocobol: Eliminate cppcheck warnings in gcc/cobol .cc files.
Robert Dubner [Mon, 14 Jul 2025 20:41:35 +0000 (16:41 -0400)] 
cobol: Eliminate cppcheck warnings in gcc/cobol .cc files.

These changes eliminate various cppcheck warnings, mostly involving C-Style
casting and applying "const" to various variables and formal parameters.
Some tab characters were eliminated, and some lines were trimmed to
seventy-nine characters.

gcc/cobol/ChangeLog:

* cobol1.cc (cobol_langhook_handle_option): Eliminate cppcheck warnings.
* dts.h: Likewise.
* except.cc (cbl_enabled_exceptions_t::dump): Likewise.
* gcobolspec.cc (lang_specific_driver): Likewise.
* genapi.cc (parser_file_merge): Likewise.
* gengen.cc (gg_unique_in_function): Likewise.
(gg_declare_variable): Likewise.
(gg_peek_fn_decl): Likewise.
(gg_define_function): Likewise.
* genmath.cc (set_up_on_exception_label): Likewise.
(set_up_compute_error_label): Likewise.
(arithmetic_operation): Likewise.
(fast_divide): Likewise.
* genutil.cc (get_and_check_refstart_and_reflen): Likewise.
(get_depending_on_value_from_odo): Likewise.
(get_data_offset): Likewise.
(get_binary_value): Likewise.
(process_this_exception): Likewise.
(copy_little_endian_into_place): Likewise.
(refer_is_clean): Likewise.
(refer_fill_depends): Likewise.
* genutil.h (process_this_exception): Likewise.
(copy_little_endian_into_place): Likewise.
(refer_is_clean): Likewise.
* lexio.cc (check_push_pop_directive): Likewise.
(check_source_format_directive): Likewise.
(location_in): Likewise.
(lexer_input): Likewise.
(cdftext::lex_open): Likewise.
(lexio_dialect_mf): Likewise.
(valid_sequence_area): Likewise.
(cdftext::free_form_reference_format): Likewise.
(cdftext::segment_line): Likewise.
* lexio.h (struct span_t): Likewise.
* scan_ante.h (trim_location): Likewise.
* symbols.cc (symbol_elem_cmp): Likewise.
(symbol_alphabet): Likewise.
(end_of_group): Likewise.
(cbl_field_t::attr_str): Likewise.
(symbols_update): Likewise.
(symbol_typedef_add): Likewise.
(symbol_field_add): Likewise.
(new_temporary_impl): Likewise.
(symbol_label_section_exists): Likewise.
(symbol_program_callables): Likewise.
(file_status_status_of): Likewise.
* symfind.cc (is_data_field): Likewise.
(finalize_symbol_map2): Likewise.
(class in_scope): Likewise.
(symbol_match2): Likewise.
* util.cc (get_current_dir_name): Likewise.
(gb4): Likewise.
(class cdf_directives_t): Likewise.
(cbl_field_t::report_invalid_initial_value): Likewise.
(literal_subscript_oob): Likewise.
(cbl_refer_t::str): Likewise.
(date_time_fmt): Likewise.
(class unique_stack): Likewise.
(cobol_set_pp_option): Likewise.
(cobol_filename): Likewise.
(cobol_filename_restore): Likewise.
(gcc_location_set_impl): Likewise.
(ydferror): Likewise.
(error_msg_direct): Likewise.
(yyerror): Likewise.
(cbl_unimplemented_at): Likewise.

2 weeks agolibstdc++: Add comments to deleted std::swap overloads for LWG 2766
Jonathan Wakely [Sun, 13 Jul 2025 14:34:15 +0000 (15:34 +0100)] 
libstdc++: Add comments to deleted std::swap overloads for LWG 2766

We pre-emptively implemented part of LWG 2766, which still hasn't been
approved. Add comments to the deleted swap overloads saying why they're
there, because the standard doesn't require them.

libstdc++-v3/ChangeLog:

* include/bits/stl_pair.h (swap): Add comment to deleted
overload.
* include/bits/unique_ptr.h (swap): Likewise.
* include/std/array (swap): Likewise.
* include/std/optional (swap): Likewise.
* include/std/tuple (swap): Likewise.
* include/std/variant (swap): Likewise.
* testsuite/23_containers/array/tuple_interface/get_neg.cc:
Adjust dg-error line numbers.

2 weeks agoamdgcn: fix vec_ucmp infinite recursion
Andrew Stubbs [Wed, 9 Jul 2025 14:59:20 +0000 (14:59 +0000)] 
amdgcn: fix vec_ucmp infinite recursion

I suppose this pattern doesn't get used much! The unsigned compare was meant to
be defined using the signed compare pattern, but actually ended up trying to
recursively call itself.  This patch fixes the issue in the obvious way.

gcc/ChangeLog:

* config/gcn/gcn-valu.md (vec_cmpu<mode>di_exec): Call gen_vec_cmp*,
not gen_vec_cmpu*.

2 weeks agoRevert "tree-optimization/121059 - record loop mask when required"
Richard Biener [Mon, 14 Jul 2025 15:18:04 +0000 (17:18 +0200)] 
Revert "tree-optimization/121059 - record loop mask when required"

This reverts commit 66346b6d800fc4baae876e0fe4e932401bcc85fa.

2 weeks agos390: Implement reduction optabs
Juergen Christ [Tue, 8 Jul 2025 17:02:42 +0000 (19:02 +0200)] 
s390: Implement reduction optabs

Implementation and tests for the standard reduction optabs.

Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>
gcc/ChangeLog:

* config/s390/vector.md (reduc_plus_scal_<mode>): Implement.
(reduc_plus_scal_v2df): Implement.
(reduc_plus_scal_v4sf): Implement.
(REDUC_FMINMAX): New int iterator.
(reduc_fminmax_name): New int attribute.
(reduc_minmax): New code iterator.
(reduc_minmax_name): New code attribute.
(reduc_<reduc_fminmax_name>_scal_v2df): Implement.
(reduc_<reduc_fminmax_name>_scal_v4sf): Implement.
(reduc_<reduc_minmax_name>_scal_v2df): Implement.
(reduc_<reduc_minmax_name>_scal_v4sf): Implement.
(REDUCBIN): New code iterator.
(reduc_bin_insn): New code attribute.
(reduc_<reduc_bin_insn>_scal_v2di): Implement.
(reduc_<reduc_bin_insn>_scal_v4si): Implement.
(reduc_<reduc_bin_insn>_scal_v8hi): Implement.
(reduc_<reduc_bin_insn>_scal_v16qi): Implement.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp: Add s390 to vect_logical_reduc targets.
* gcc.target/s390/vector/reduc-binops-1.c: New test.
* gcc.target/s390/vector/reduc-minmax-1.c: New test.
* gcc.target/s390/vector/reduc-plus-1.c: New test.

2 weeks agos390: Remove min-vect-loop-bound override
Juergen Christ [Tue, 8 Jul 2025 16:59:26 +0000 (18:59 +0200)] 
s390: Remove min-vect-loop-bound override

The default setting of s390 for the parameter min-vect-loop-bound was
set to 2 to prevent certain epilogue loop vectorizations in the past.
Reevaluation of this parameter shows that this setting now is not
needed anymore and sometimes even harmful.  Remove the overwrite to
align s390 with other backends.

Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>
gcc/ChangeLog:

* config/s390/s390.cc (s390_option_override_internal): Remove override.

2 weeks agoamdgcn: Don't clobber VCC if we don't need to
Andrew Stubbs [Fri, 11 Jul 2025 13:41:19 +0000 (13:41 +0000)] 
amdgcn: Don't clobber VCC if we don't need to

This is a hold-over from GCN3 where v_add always wrote to the condition
register, whether you wanted it or not.  This hasn't been true since GCN5, and
we dropped support for GCN3 a little while ago, so let's fix it.

There was actually a latent bug here because some other post-reload splitters
were generating v_add instructions without declaring the VCC clobber (at least
mul did this), so this should fix some wrong-code bugs also.

gcc/ChangeLog:

* config/gcn/gcn-valu.md (add<mode>3<exec_clobber>): Rename ...
(add<mode>3<exec>): ... to this, remove the clobber, and change the
instruction from v_add_co_u32 to v_add_u32.
(add<mode>3_dup<exec_clobber>): Rename ...
(add<mode>3_dup<exec>): ... to this, and likewise.
(sub<mode>3<exec_clobber>): Rename ...
(sub<mode>3<exec>): ... to this, and likewise
* config/gcn/gcn.md (addsi3): Remove the DI clobber, and change the
instruction from v_add_co_u32 to v_add_u32.
(addsi3_scc): Likewise.
(subsi3): Likewise, but for v_sub_co_u32.
(muldi3): Likewise.

2 weeks agotree-optimization/121059 - record loop mask when required
Richard Biener [Mon, 14 Jul 2025 12:09:28 +0000 (14:09 +0200)] 
tree-optimization/121059 - record loop mask when required

For loop masking we need to mask a mask AND operation with the loop
mask.  The following makes sure we have a corresponding mask
available.  There's no good way to distinguish loop masking from
len masking here, so assume we have recorded a mask for the operands
mask producers.

PR tree-optimization/121059
* tree-vect-stmts.cc (vectorizable_operation): Record a
loop mask for mask AND operations.

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

2 weeks agoRISC-V: Add testcase for rv32 SAT_MUL from uint64
Pan Li [Fri, 11 Jul 2025 00:58:31 +0000 (08:58 +0800)] 
RISC-V: Add testcase for rv32 SAT_MUL from uint64

Add the run and asm testcase for rv32 SAT_MUL, widen mul from
uint8_t, uint16_t, uint32_t to uint64_t.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat/sat_u_mul-1-u16-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-1-u32-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-1-u8-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-1-u16-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-1-u32-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-1-u8-from-u64.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 weeks agoMatch: Refine the widen mul check for SAT_MUL pattern
Pan Li [Fri, 11 Jul 2025 00:38:09 +0000 (08:38 +0800)] 
Match: Refine the widen mul check for SAT_MUL pattern

The widen mul will have source type from N-bits to
dest type 2N-bits.  The previous check only focus on
the HOST_WIDE_INT but not working for QI => HI, HI => SI
and SI to DImode.  Thus, refine the widen mul precision
check as dest has twice bits of input.

gcc/ChangeLog:

* match.pd: Make sure widen mul has twice bitsize
of the inputs in SAT_MUL pattern.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 weeks agox86: Check all 0s/1s vectors with standard_sse_constant_p
Uros Bizjak [Mon, 14 Jul 2025 09:16:36 +0000 (17:16 +0800)] 
x86: Check all 0s/1s vectors with standard_sse_constant_p

commit 77473a27bae04da99d6979d43e7bd0a8106f4557
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Jun 26 06:08:51 2025 +0800

    x86: Also handle all 1s float vector constant

replaces

(insn 29 28 30 5 (set (reg:V2SF 107)
        (mem/u/c:V2SF (symbol_ref/u:DI ("*.LC0") [flags 0x2]) [0  S8 A64])) 2031 {*movv2sf_internal}
     (expr_list:REG_EQUAL (const_vector:V2SF [
                (const_double:SF -QNaN [-QNaN]) repeated x2
            ])
        (nil)))

with

(insn 98 13 14 3 (set (reg:V8QI 112)
        (const_vector:V8QI [
                (const_int -1 [0xffffffffffffffff]) repeated x8
            ])) -1
     (nil))
...
(insn 29 28 30 5 (set (reg:V2SF 107)
        (subreg:V2SF (reg:V8QI 112) 0)) 2031 {*movv2sf_internal}
     (expr_list:REG_EQUAL (const_vector:V2SF [
                (const_double:SF -QNaN [-QNaN]) repeated x2
            ])
        (nil)))

which leads to

pr121015.c: In function â€˜render_result_from_bake_h’:
pr121015.c:34:1: error: unrecognizable insn:
   34 | }
      | ^
(insn 98 13 14 3 (set (reg:V8QI 112)
        (const_vector:V8QI [
                (const_int -1 [0xffffffffffffffff]) repeated x8
            ])) -1
     (expr_list:REG_EQUIV (const_vector:V8QI [
                (const_int -1 [0xffffffffffffffff]) repeated x8
            ])
        (nil)))
during RTL pass: ira

Check all 0s/1s vectors with standard_sse_constant_p to avoid unsupported
all 1s vectors.

Co-Developed-by: H.J. Lu <hjl.tools@gmail.com>
gcc/

PR target/121015
* config/i386/i386-features.cc (ix86_broadcast_inner): Check all
0s/1s vectors with standard_sse_constant_p.

gcc/testsuite/

PR target/121015
* gcc.target/i386/pr121015.c: New test.

2 weeks agox86-64: Add --enable-x86-64-mfentry
H.J. Lu [Wed, 2 Jul 2025 00:58:23 +0000 (08:58 +0800)] 
x86-64: Add --enable-x86-64-mfentry

When profiling is enabled with shrink wrapping, the mcount call may not
be placed at the function entry after

pushq %rbp
movq %rsp,%rbp

As the result, the profile data may be skewed which makes PGO less
effective.

Add --enable-x86-64-mfentry to enable -mfentry by default to use
__fentry__, added to glibc in 2010 by:

commit d22e4cc9397ed41534c9422d0b0ffef8c77bfa53
Author: Andi Kleen <ak@linux.intel.com>
Date:   Sat Aug 7 21:24:05 2010 -0700

    x86: Add support for frame pointer less mcount

instead of mcount, which is placed before the prologue so that -pg can
be used with -fshrink-wrap-separate enabled at -O1.  This option is
64-bit only because __fentry__ doesn't support PIC in 32-bit mode.  The
default it to enable -mfentry when targeting glibc.

Also warn -pg without -mfentry with shrink wrapping enabled.  The warning
is disable for PIC in 32-bit mode.

gcc/

PR target/120881
* config.in: Regenerated.
* configure: Likewise.
* configure.ac: Add --enable-x86-64-mfentry.
* config/i386/i386-options.cc (ix86_option_override_internal):
Enable __fentry__ in 64-bit mode if ENABLE_X86_64_MFENTRY is set
to 1.  Warn -pg without -mfentry with shrink wrapping enabled.
* doc/install.texi: Document --enable-x86-64-mfentry.

gcc/testsuite/

PR target/120881
* gcc.dg/20021014-1.c: Add additional -mfentry -fno-pic options
for x86.
* gcc.dg/aru-2.c: Likewise.
* gcc.dg/nest.c: Likewise.
* gcc.dg/pr32450.c: Likewise.
* gcc.dg/pr43643.c: Likewise.
* gcc.target/i386/pr104447.c: Likewise.
* gcc.target/i386/pr113122-3.c: Likewise.
* gcc.target/i386/pr119386-1.c: Add additional -mfentry if not
ia32.
* gcc.target/i386/pr119386-2.c: Likewise.
* gcc.target/i386/pr120881-1a.c: New test.
* gcc.target/i386/pr120881-1b.c: Likewise.
* gcc.target/i386/pr120881-1c.c: Likewise.
* gcc.target/i386/pr120881-1d.c: Likewise.
* gcc.target/i386/pr120881-2a.c: Likewise.
* gcc.target/i386/pr120881-2b.c: Likewise.
* gcc.target/i386/pr82699-1.c: Add additional -mfentry.
* lib/target-supports.exp (check_effective_target_fentry): New.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 weeks agoDarwin: account for macOS 26
Francois-Xavier Coudert [Mon, 14 Jul 2025 10:14:00 +0000 (12:14 +0200)] 
Darwin: account for macOS 26

darwin25 will be named macOS 26 (codename Tahoe). This is a change from
darwin24, which was macOS 15. We need to adapt the driver to this new
numbering scheme.

2025-07-14  François-Xavier Coudert  <fxcoudert@gcc.gnu.org>

gcc/ChangeLog:

PR target/120645
* config/darwin-driver.cc: Account for latest macOS numbering
scheme.

gcc/testsuite/ChangeLog:

* gcc.dg/darwin-minversion-link.c: Account for macOS 26.

2 weeks ago[PATCH v2] RISC-V: Vector-scalar widening multiply-(subtract-)accumulate [PR119100]
Paul-Antoine Arras [Mon, 14 Jul 2025 12:10:44 +0000 (06:10 -0600)] 
[PATCH v2] RISC-V: Vector-scalar widening multiply-(subtract-)accumulate [PR119100]

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

Before this patch, we have three instructions, e.g.:
  fcvt.s.h       fa5,fa5
  vfmv.v.f       v24,fa5
  vfmadd.vv      v8,v24,v16

After, we get only one:
  vfwmacc.vf     v8,fa5,v16

PR target/119100

gcc/ChangeLog:

* config/riscv/autovec-opt.md (*vfwmacc_vf_<mode>): New pattern to
handle both vfwmacc and vfwmsac.
(*extend_vf_<mode>): New pattern that serves as an intermediate combine
step.
* config/riscv/vector-iterators.md (vsubel): New mode attribute. This is
just the lower-case version of VSUBEL.
* config/riscv/vector.md (@pred_widen_mul_<optab><mode>_scalar): Reorder
and swap operands to match the RTL emitted by expand, i.e. first
float_extend then vec_duplicate.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vf-1-f16.c: Add vfwmacc and
vfwmsac.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-1-f32.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-2-f16.c: Likewise. Also check
for fcvt and vfmv.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-2-f32.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f16.c: Add vfwmacc and
vfwmsac.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f32.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-4-f16.c: Likewise. Also check
for fcvt and vfmv.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-4-f32.c: Likewise.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_mulop.h: Add support for
widening variants.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_mulop_widen_run.h: New test
helper.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfwmacc-run-1-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfwmacc-run-1-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfwmsac-run-1-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfwmsac-run-1-f32.c: New test.

2 weeks agolibstdc++: Protect PSTL headers against overloaded commas
Jonathan Wakely [Sun, 13 Jul 2025 08:33:04 +0000 (09:33 +0100)] 
libstdc++: Protect PSTL headers against overloaded commas

Reported upstream: https://github.com/uxlfoundation/oneDPL/issues/2342

libstdc++-v3/ChangeLog:

* include/pstl/algorithm_impl.h (__for_each_n_it_serial):
Protect against overloaded comma operator.
(__brick_walk2): Likewise.
(__brick_walk2_n): Likewise.
(__brick_walk3): Likewise.
(__brick_move_destroy::operator()): Likewise.
(__brick_calc_mask_1): Likewise.
(__brick_copy_by_mask): Likewise.
(__brick_partition_by_mask): Likewise.
(__brick_calc_mask_2): Likewise.
(__brick_reverse): Likewise.
(__pattern_partial_sort_copy): Likewise.
* include/pstl/memory_impl.h (__brick_uninitialized_move):
Likewise.
(__brick_uninitialized_copy): Likewise.
* include/pstl/numeric_impl.h (__brick_transform_scan):
Likewise.

2 weeks agolibstdc++: Correct value of __cpp_lib_constexpr_exceptions [PR117785]
Jonathan Wakely [Fri, 11 Jul 2025 22:49:27 +0000 (23:49 +0100)] 
libstdc++: Correct value of __cpp_lib_constexpr_exceptions [PR117785]

Only P3068R6 (Allowing exception throwing in constant-evaluation) is
implemented in the library so far, so the value of the
constexpr_exceptions feature test macro should be 202411L. Once we
support the library changes in P3378R2 (constexpr exception types) then
we can set the value to 202502L again.

libstdc++-v3/ChangeLog:

PR libstdc++/117785
* include/bits/version.def (constexpr_exceptions): Define
correct value.
* include/bits/version.h: Regenerate.
* libsupc++/exception: Check correct value.
* testsuite/18_support/exception/version.cc: New test.

2 weeks agolibstdc++: Fix constexpr exceptions for -fno-exceptions
Jonathan Wakely [Fri, 11 Jul 2025 11:40:14 +0000 (12:40 +0100)] 
libstdc++: Fix constexpr exceptions for -fno-exceptions

The if-consteval branches in std::make_exception_ptr and
std::exception_ptr_cast use a try-catch block, which gives an error for
-fno-exceptions. Just make them return a null pointer at compile-time
when -fno-exceptions is used, because there's no way to get an active
exception with -fno-exceptions.

For both functions we have a runtime-only branch that depends on RTTI,
and a fallback using try-catch which works for runtime and consteval.
Rearrange both functions to express this logic more clearly.

Also adjust some formatting and whitespace elsewhere in the file.

libstdc++-v3/ChangeLog:

* libsupc++/exception_ptr.h (make_exception_ptr): Return null
for consteval when -fno-exceptions is used.
(exception_ptr_cast): Likewise. Allow consteval path to work
with -fno-rtti.

Reviewed-by: Jakub Jelinek <jakub@redhat.com>
2 weeks agoAda: Add missing guard before accessing the Underlying_Record_View field
Eric Botcazou [Mon, 14 Jul 2025 10:11:44 +0000 (12:11 +0200)] 
Ada: Add missing guard before accessing the Underlying_Record_View field

It is necessary when GNAT extensions are enabled (-gnatX switch).

gcc/ada/
PR ada/121056
* sem_ch4.adb (Try_Object_Operation.Try_Primitive_Operation): Add
test on Is_Record_Type before accessing Underlying_Record_View.

gcc/testsuite/
* gnat.dg/deref4.adb: New test.
* gnat.dg/deref4_pkg.ads: New helper.

2 weeks agoaarch64: Implement sme2+faminmax extension.
Alfie Richards [Fri, 4 Jul 2025 15:37:10 +0000 (15:37 +0000)] 
aarch64: Implement sme2+faminmax extension.

Implements the sme2+faminmax svamin and svamax intrinsics.

gcc/ChangeLog:

* config/aarch64/aarch64-sme.md (@aarch64_sme_<faminmax_uns_op><mode>):
New patterns.
* config/aarch64/aarch64-sve-builtins-sme.def (svamin): New intrinsics.
(svamax): New intrinsics.
* config/aarch64/aarch64-sve-builtins-sve2.cc (class faminmaximpl): New
class.
(svamin): New function.
(svamax): New function.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sme2/acle-asm/amax_f16_x2.c: New test.
* gcc.target/aarch64/sme2/acle-asm/amax_f16_x4.c: New test.
* gcc.target/aarch64/sme2/acle-asm/amax_f32_x2.c: New test.
* gcc.target/aarch64/sme2/acle-asm/amax_f32_x4.c: New test.
* gcc.target/aarch64/sme2/acle-asm/amax_f64_x2.c: New test.
* gcc.target/aarch64/sme2/acle-asm/amax_f64_x4.c: New test.
* gcc.target/aarch64/sme2/acle-asm/amin_f16_x2.c: New test.
* gcc.target/aarch64/sme2/acle-asm/amin_f16_x4.c: New test.
* gcc.target/aarch64/sme2/acle-asm/amin_f32_x2.c: New test.
* gcc.target/aarch64/sme2/acle-asm/amin_f32_x4.c: New test.
* gcc.target/aarch64/sme2/acle-asm/amin_f64_x2.c: New test.
* gcc.target/aarch64/sme2/acle-asm/amin_f64_x4.c: New test.

2 weeks agoi386: Remove KEYLOCKER related feature since Panther Lake and Clearwater Forest
Haochen Jiang [Fri, 11 Jul 2025 08:16:52 +0000 (16:16 +0800)] 
i386: Remove KEYLOCKER related feature since Panther Lake and Clearwater Forest

According to July 2025 SDM, Key locker will no longer be supported on
hardware 2025 onwards. This means for Panther Lake and Clearwater Forest,
the feature will not be enabled. Remove them from those two platforms.

gcc/ChangeLog:

* config/i386/i386.h (PTA_PANTHERLAKE): Revmoe KL and WIDEKL.
(PTA_CLEARWATERFOREST): Ditto.
* doc/invoke.texi: Revise documentation.

2 weeks agoRISC-V: Add testcases for unsigned vector SAT_SUB form 11 and form 12
panciyan [Thu, 10 Jul 2025 06:54:26 +0000 (06:54 +0000)] 
RISC-V: Add testcases for unsigned vector SAT_SUB form 11 and form 12

This patch adds testcase for form11 and form12, as shown below:

void __attribute__((noinline))                                       \
vec_sat_u_sub_##T##_fmt_11 (T *out, T *op_1, T *op_2, unsigned limit) \
{                                                                    \
  unsigned i;                                                        \
  for (i = 0; i < limit; i++)                                        \
    {                                                                \
      T x = op_1[i];                                                 \
      T y = op_2[i];                                                 \
      T ret;                                                         \
      T overflow = __builtin_sub_overflow (x, y, &ret);           \
      out[i] = overflow ? 0 : ret;                                   \
    }                                                                \
}

void __attribute__((noinline))                                        \
vec_sat_u_sub_##T##_fmt_12 (T *out, T *op_1, T *op_2, unsigned limit) \
{                                                                     \
  unsigned i;                                                         \
  for (i = 0; i < limit; i++)                                         \
    {                                                                 \
      T x = op_1[i];                                                  \
      T y = op_2[i];                                                  \
      T ret;                                                          \
      T overflow = __builtin_sub_overflow (x, y, &ret);            \
      out[i] = !overflow ? ret : 0;                                   \
    }                                                                 \
}

Passed the rv64gcv regression test.

Signed-off-by: Ciyan Pan <panciyan@eswincomputing.com>
gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/sat/vec_sat_arith.h: Unsigned vector SAT_SUB form11 form12.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_data.h: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-1-u16.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-1-u32.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-1-u64.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-1-u8.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-10-u16.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-10-u32.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-10-u64.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-10-u8.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-2-u16.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-2-u32.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-2-u64.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-2-u8.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-3-u16.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-3-u32.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-3-u64.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-3-u8.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-4-u16.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-4-u32.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-4-u64.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-4-u8.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-5-u16.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-5-u32.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-5-u64.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-5-u8.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-6-u16.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-6-u32.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-6-u64.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-6-u8.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-7-u16.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-7-u32.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-7-u64.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-7-u8.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-8-u16.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-8-u32.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-8-u64.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-8-u8.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-9-u16.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-9-u32.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-9-u64.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-9-u8.c: Use ussub instead of usub.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-11-u16.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-11-u32.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-11-u64.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-11-u8.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-12-u16.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-12-u32.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-12-u64.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-12-u8.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-11-u16.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-11-u32.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-11-u64.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-11-u8.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-12-u16.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-12-u32.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-12-u64.c: New test.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-run-12-u8.c: New test.

2 weeks agoDaily bump.
GCC Administrator [Mon, 14 Jul 2025 00:16:48 +0000 (00:16 +0000)] 
Daily bump.

2 weeks agotree: Add include to tm_p.h to tree.cc [PR120866]
Andrew Pinski [Sun, 13 Jul 2025 18:56:03 +0000 (11:56 -0700)] 
tree: Add include to tm_p.h to tree.cc [PR120866]

After r16-1738-g0337e3c2743ca0, a call to ASM_GENERATE_INTERNAL_LABEL
was done without including tm_p.h. This does not break most targets
as ASM_GENERATE_INTERNAL_LABEL macro function does not call target
specific functions from it; mostly just sprintf. It does however
break pdp11-aout and powerpc-aix* because those two call a target
specific function to do create the internal label.

Pushed as obvious after a build of gcc for pdp11-aout and x86_64-linux-gnu.

PR middle-end/120866
gcc/ChangeLog:

* tree.cc: Add include to tm_p.h.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 weeks agomiddle-end: Fix typo in gimple.h
Benjamin Wu [Sun, 13 Jul 2025 16:25:02 +0000 (17:25 +0100)] 
middle-end: Fix typo in gimple.h

gcc/ChangeLog:

* gimple.h (GTMA_DOES_GO_IRREVOCABLE): Fix typo.

2 weeks agocobol: Minor changes to genapi.cc to eliminate CPPCHECK warnings.
Robert Dubner [Fri, 11 Jul 2025 21:11:21 +0000 (17:11 -0400)] 
cobol: Minor changes to genapi.cc to eliminate CPPCHECK warnings.

Several hundred cppcheck warnings were eliminated.

Most of these changes were replacing C-style casts, checking for NULL
pointers, establishing some variables and formal parameters as const,
and moving some variables around to tidy up their scopes.

One memory leak was found and eliminated as a result of the cppcheck.

gcc/cobol/ChangeLog:

* Make-lang.in: Eliminate the .cc.o override.
* genapi.cc (level_88_helper): Eliminate cppcheck warning.
(get_level_88_domain): Likewise.
(get_class_condition_string): Likewise.
(parser_call_targets_dump): Likewise.
(parser_compile_ecs): Likewise.
(initialize_variable_internal): Likewise.
(move_tree): Likewise.
(combined_name): Likewise.
(assembler_label): Likewise.
(find_procedure): Likewise.
(parser_perform): Likewise.
(parser_perform_times): Likewise.
(internal_perform_through): Likewise.
(internal_perform_through_times): Likewise.
(psa_FldLiteralN): Likewise.
(psa_FldBlob): Likewise.
(parser_accept): Likewise.
(parser_accept_exception): Likewise.
(parser_accept_exception_end): Likewise.
(parser_accept_command_line): Likewise.
(parser_accept_envar): Likewise.
(parser_display_internal): Likewise.
(parser_display): Likewise.
(parser_assign): Likewise.
(parser_initialize_table): Likewise.
(parser_arith_error): Likewise.
(parser_arith_error_end): Likewise.
(parser_division): Likewise.
(label_fetch): Likewise.
(parser_label_label): Likewise.
(parser_label_goto): Likewise.
(parser_perform_start): Likewise.
(parser_perform_conditional): Likewise.
(parser_perform_conditional_end): Likewise.
(parser_perform_until): Likewise.
(parser_file_delete): Likewise.
(parser_intrinsic_subst): Likewise.
(create_lsearch_address_pairs): Likewise.
(parser_bsearch_start): Likewise.
(is_ascending_key): Likewise.
(parser_sort): Likewise.
(parser_file_sort): Likewise.
(parser_return_start): Likewise.
(parser_file_merge): Likewise.
(parser_string_overflow): Likewise.
(parser_unstring): Likewise.
(parser_string): Likewise.
(parser_call_exception): Likewise.
(create_and_call): Likewise.
(mh_identical): Likewise.
(move_helper): Likewise.
(binary_initial_from_float128): Likewise.
(initial_from_initial): Likewise.
(psa_FldLiteralA): Likewise.
(parser_local_add): Likewise.
(parser_symbol_add): Likewise.
* genapi.h (parser_display): Likewise.
* gengen.cc (gg_call_expr): Explict check for NULL_TREE.
(gg_call): Likewise.
* show_parse.h (SHOW_PARSE_LABEL_OK): Likewise.
(TRACE1_FIELD_VALUE): Likewise.
(CHECK_FIELD): Likewise.
(CHECK_FIELD2): Likewise.
(CHECK_LABEL): Likewise.
* util.cc (cbl_internal_error): Apply [[noreturn]] attribute.
* util.h (cbl_internal_error): Likewise.

libgcobol/ChangeLog:

* common-defs.h (PTRCAST): Moved here from libgcobol.h.
* libgcobol.h (PTRCAST): Deleted.

2 weeks agoDaily bump.
GCC Administrator [Sun, 13 Jul 2025 00:22:33 +0000 (00:22 +0000)] 
Daily bump.

2 weeks agoFix some auto-profile issues
Jan Hubicka [Sat, 12 Jul 2025 15:57:25 +0000 (17:57 +0200)] 
Fix some auto-profile issues

This patch fixes minor things that has cumulated in my tree.  Except for
formating fixes an important change is that seen set is now kept up to date.
Oriignal code first populated it for all string in the string table but now
gimple matching may introduce new ones that needs to be checked for match with
symbol table as well.

This makes imagemagic of spec2017 to be faster with auto-fdo then without at
least when trained with ref run.  Train run has problem since it does not train
the innermost loop at all, so even with normal PGO it is slower then without.

autorpfoiledbootstrapped/regtested x86_64-linux, comitted.

gcc/ChangeLog:

* auto-profile.cc (function_instance::~function_instance):
Move down in source.
(string_table::get_cgraph_node): New member function with
logic broken out from ...
(function_instance::get_cgraph_node): ... here.
(match_with_target): Fix formating.
(function_instance::match): Fix formating; do not use iterators
after modifying map; remove incorrect set of warned flag.
(autofdo_source_profile::offline_external_functions): Keep
seen set up to date.
(function_instance::read_function_instance): Fix formating.

2 weeks agoi386: Robustify MMX move patterns
Uros Bizjak [Sat, 12 Jul 2025 15:34:18 +0000 (17:34 +0200)] 
i386: Robustify MMX move patterns

MMX allows only direct moves from zero, so correct V_32:mode and v2qi
move patterns to allow only nonimm_or_0_operand as their input operand.

gcc/ChangeLog:

* config/i386/mmx.md (mov<V_32:mode>):
Use nonimm_or_0_operand predicate for operand 1.
(*mov<V_32:mode>_internal): Ditto.
(movv2qi): Ditto.
(*movv2qi_internal): Ditto.  Use ix86_hardreg_mov_ok
in insn condition.

2 weeks agolra: Reallow reloading user hard registers if the insn is not asm [PR 120983]
Xi Ruoyao [Tue, 8 Jul 2025 06:39:11 +0000 (14:39 +0800)] 
lra: Reallow reloading user hard registers if the insn is not asm [PR 120983]

The PR 87600 fix has disallowed reloading user hard registers to resolve
earlyclobber-induced conflict.

However before reload, recog completely ignores the constraints of
insns, so the RTL passes may produce insns where some user hard
registers violate an earlyclobber.  Then we'll get an ICE without
reloading them, like what we are recently encountering in LoongArch test
suite.

IIUC "recog does not look at constraints until reload" has been a
well-established rule in GCC for years and I don't have enough skill to
challange it.  So reallow reloading user hard registers (but still
disallow doing so for asm) to fix the ICE.

gcc/ChangeLog:

PR rtl-optimization/120983
* lra-constraints.cc (process_alt_operands): Allow reloading
user hard registers unless the insn is an asm.

2 weeks agotestsuite: Enable the PR 87600 tests for LoongArch
Xi Ruoyao [Tue, 8 Jul 2025 06:07:21 +0000 (14:07 +0800)] 
testsuite: Enable the PR 87600 tests for LoongArch

I'm going to refine a part of the PR 87600 fix which seems triggering
PR 120983 that LoongArch is particularly suffering.  Enable the PR 87600
tests so I'll not regress PR 87600.

gcc/testsuite/ChangeLog:

PR rtl-optimization/87600
PR rtl-optimization/120983
* gcc.dg/pr87600.h [__loongarch__]: Define REG0 and REG1.
* gcc.dg/pr87600-1.c (dg-do): Add loongarch.
* gcc.dg/pr87600-2.c (dg-do): Likewise.

2 weeks agoFortran/OpenACC: Permit PARAMETER as 'var' in clauses (+ ignore)
Tobias Burnus [Sat, 12 Jul 2025 05:18:06 +0000 (07:18 +0200)] 
Fortran/OpenACC: Permit PARAMETER as 'var' in clauses (+ ignore)

It turned out that other compilers permit (require?) named constants
to appear in clauses - and programs actually use this. OpenACC 3.4
added therefore the following:
  In this spec, a _var_ (in italics) is one of the following:
  ...
  * a named constant in Fortran.
plus
  If during an optimization phase _var_ is removed by the compiler,
  appearances of var in data clauses are ignored.

Thus, all errors related to PARAMETER are now downgraded, most
to a -Wsurprising warning, but for 'acc declare device_resident'
(which kind of makes sense), no warning is printed.

In trans-openmp.cc, those are ignored, unless I missed some code
path. (If so, I hope the middle end removes them; but before
removing them for the covered cases, the program just compiled &
linked fine.)

Note that 'ignore PARAMETER inside clauses' in trans-openmp.cc
would in principle also apply to expressions ('if (var)') but
those should be evaluated during 'resolve.cc' + 'openmp.cc' to
their (numeric, logical, string) value such that there should
be no issue.

gcc/fortran/ChangeLog:

* invoke.texi (-Wsurprising): Note about OpenACC warning
related to PARAMATER.
* openmp.cc (resolve_omp_clauses, gfc_resolve_oacc_declare):
Accept PARAMETER for OpenACC but add surprising warning.
* trans-openmp.cc (gfc_trans_omp_variable_list,
gfc_trans_omp_clauses): Ignore PARAMETER inside clauses.

gcc/testsuite/ChangeLog:

* gfortran.dg/goacc/parameter.f95: Add -Wsurprising flag
and update expected diagnostic.
* gfortran.dg/goacc/parameter-3.f90: New test.
* gfortran.dg/goacc/parameter-4.f90: New test.

2 weeks agoDaily bump.
GCC Administrator [Sat, 12 Jul 2025 00:19:25 +0000 (00:19 +0000)] 
Daily bump.

2 weeks agodiagnostics: add support for directed graphs; use them for state graphs
David Malcolm [Fri, 11 Jul 2025 18:58:21 +0000 (14:58 -0400)] 
diagnostics: add support for directed graphs; use them for state graphs

In r16-1631-g2334d30cd8feac I added support for capturing state
information from -fanalyzer in XML form, and adding a way to visualize
these states in HTML output.  The data was optionally captured in SARIF
output (with "xml-state=yes"), stashing the XML in string form in
a property bag.

This worked, but there was no way to round-trip the stored data back
from SARIF without adding an XML parser to GCC, which I don't want to
do.

SARIF supports capturing directed graphs, so this patch:

(a) adds a new namespace diagnostics::digraphs, with classes digraph,
node, and edge, representing directed graphs in a form similar to
what SARIF can serialize

(b) adds support to GCC's diagnostic subsystem for reporting graphs,
either "globally" or as part of a diagnostic.  An example in a testsuite
plugin emits an error that has a couple of dummy graphs associated with
it, and captures the optimization passes as a digraph "globally".
Graphs are ignored by text sinks, but are captured by sarif sinks,
and the "experimental-html" sink gains SVG-based rendering of any graphs
using dot.  This HTML output is rather crude; an example can be seen
here:
  https://dmalcolm.fedorapeople.org/gcc/2025-07-10/diagnostic-test-graphs-html.c.html

(c) adds support to libgdiagnostics for the above

(d) adds support to sarif-replay for the above (round-tripping any
graph information)

(e) replaces the XML representation of state with a representation
based on the above directed graphs, using property bags to stash
additional information (e.g. "this is an on-stack buffer")

(f) implements round-tripping of this information in sarif-replay

To summarize:
- previously we could generate HTML diagrams for debugging
  -fanalyzer directly from gcc, but not from stored .sarif output.
- with this patch, we can generate such HTML diagrams both directly
  *and* from stored .sarif output (provided the SARIF sink was created
  with "state-graphs=yes")

Examples of HTML output can be seen here:
  https://dmalcolm.fedorapeople.org/gcc/2025-07-10/
where as before j/k can be used to cycle through the events.
which is almost identical to the output from the old XML-based
implementation seen at:
  https://dmalcolm.fedorapeople.org/gcc/2025-06-23/

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Add diagnostic-digraphs.o and
diagnostic-state-graphs.o.

gcc/ChangeLog:
* diagnostic-format-html.cc: Include "diagnostic-format-sarif.h",
Replace include of "diagnostic-state.h" with includes of
"diagnostic-digraphs.h" and "diagnostic-state-graphs.h".
(html_generation_options::html_generation_options): Update for
field renaming.
(html_builder::m_body_element): New field.
(html_builder::html_builder): Initialize m_body_element.
(html_builder::maybe_make_state_diagram): Port from XML
implementation to state graph implementation.
(html_builder::make_element_for_diagnostic): Add any
per-diagnostic graphs.
(html_builder::add_graph): New.
(html_builder::emit_global_graph): New.
(html_output_format::report_global_digraph): New.
* diagnostic-format-html.h
(html_generation_options::m_show_state_diagram_xml): Replace
with...
(html_generation_options::m_show_state_diagrams_sarif): ...this.
(html_generation_options::m_show_state_diagram_dot_src): Rename
to...
(html_generation_options::m_show_state_diagrams_dot_src): ...this.
* diagnostic-format-sarif.cc: Include "diagnostic-digraphs.h" and
"diagnostic-state-graphs.h".
(sarif_builder::m_run_graphs): New field.
(sarif_result::on_nested_diagnostic): Update call to
make_location_object to pass arg by pointer.
(sarif_builder::sarif_builder): Initialize m_run_graphs.
(sarif_builder::report_global_digraph): New.
(sarif_builder::make_result_object): Add any graphs to
the result object.
(sarif_builder::make_locations_arr): Update call to
make_location_object to pass arg by pointer.
(sarif_builder::make_location_object): Pass param "loc_mgr" by
pointer rather than by reference so that it can be null, and
handle this case.
(copy_any_property_bag): New.
(make_sarif_graph): New.
(make_sarif_node): New.
(make_sarif_edge): New.
(sarif_property_bag::set_graph): New.
(populate_thread_flow_location_object): Port from XML
implementation to state graph implementation.
(make_run_object): Store any graphs.
(sarif_output_format::report_global_digraph): New.
(sarif_generation_options::sarif_generation_options): Rename
m_xml_state to m_state_graph.
(selftest::test_make_location_object): Update for change to
make_location_object.
* diagnostic-format-sarif.h:
(sarif_generation_options::m_xml_state): Replace with...
(sarif_generation_options::m_state_graph): ...this.
(class sarif_location_manager): Add forward decl.
(diagnostics::digraphs::digraph): New forward decl.
(diagnostics::digraphs::node): New forward decl.
(diagnostics::digraphs::edge): New forward decl.
(sarif_property_bag::set_graph): New decl.
(class sarif_graph): New.
(class sarif_node): New.
(class sarif_edge): New.
(make_sarif_graph): New decl.
(make_sarif_node): New decl.
(make_sarif_edge): New decl.
* diagnostic-format-text.h
(diagnostic_text_output_format::report_global_digraph): New.
* diagnostic-format.h
(diagnostic_output_format::report_global_digraph): New vfunc.
* diagnostic-digraphs.cc: New file.
* diagnostic-digraphs.h: New file.
* diagnostic-metadata.h (diagnostics::digraphs::lazy_digraphs):
New forward decl.
(diagnostic_metadata::diagnostic_metadata): Initialize
m_lazy_digraphs.
(diagnostic_metadata::set_lazy_digraphs): New.
(diagnostic_metadata::get_lazy_digraphs): New.
(diagnostic_metadata::m_lazy_digraphs): New field.
* diagnostic-output-spec.cc (sarif_scheme_handler::make_sink):
Update for XML to state graph changes.
(sarif_scheme_handler::make_sarif_gen_opts): Likewise.
(html_scheme_handler::make_sink): Rename "show-state-diagram-xml"
to "show-state-diagrams-sarif" and use pluralization consistently.
* diagnostic-path.cc: Replace include of "xml.h" with
"diagnostic-state-graphs.h".
(diagnostic_event::maybe_make_xml_state): Replace with...
(diagnostic_event::maybe_make_diagnostic_state_graph): ...this.
* diagnostic-path.h (diagnostics::digraphs::digraph): New forward
decl.
(diagnostic_event::maybe_make_xml_state): Replace with...
(diagnostic_event::maybe_make_diagnostic_state_graph): ...this.
* diagnostic-state-graphs.cc: New file.
* diagnostic-state-graphs.h: New file.
* diagnostic-state-to-dot.cc: Port implementation from XML to
state graphs.
* diagnostic-state.h: Deleted file.
* diagnostic.cc (diagnostic_context::report_global_digraph): New.
* diagnostic.h (diagnostics::digraphs::lazy_digraph): New forward
decl.
(diagnostic_context::report_global_digraph): New decl.
* doc/analyzer.texi (Debugging the Analyzer): Update to reflect
change from XML to state graphs.
* doc/invoke.texi ("sarif" diagnostics sink): Replace "xml-state"
with "state-graphs".
("experimental-html" diagnostics sink): Replace
"show-state-diagrams-xml" with "show-state-diagrams-sarif"
* doc/libgdiagnostics/topics/compatibility.rst
(LIBGDIAGNOSTICS_ABI_3): New.
* doc/libgdiagnostics/topics/graphs.rst: New file.
* doc/libgdiagnostics/topics/index.rst: Add graphs.rst.
* graphviz.h (node_id::operator=): New.
* json.h (json::value::dyn_cast_string): New.
(json::object::get_num_keys): New accessor.
(json::object::get_key): New accessor.
(json::string::dyn_cast_string): New.
* libgdiagnostics++.h (class libgdiagnostics::graph): New.
(class libgdiagnostics::node): New.
(class libgdiagnostics::edge): New.
(class libgdiagnostics::diagnostic::take_graph): New.
(class libgdiagnostics::manager::take_global_graph): New.
(class libgdiagnostics::graph::set_description): New.
(class libgdiagnostics::graph::get_node_by_id): New.
(class libgdiagnostics::graph::get_edge_by_id): New.
(class libgdiagnostics::graph::add_edge): New.
(class libgdiagnostics::node::set_label): New.
(class libgdiagnostics::node::set_location): New.
(class libgdiagnostics::node::set_logical_location): New.
* libgdiagnostics-private.h: New file.
* libgdiagnostics.cc: Define INCLUDE_STRING.  Include
"diagnostic-digraphs.h", "diagnostic-state-graphs.h", and
"libgdiagnostics-private.h".
(struct diagnostic_graph): New.
(struct diagnostic_node): New.
(struct diagnostic_edge): New.
(libgdiagnostics_path_event::libgdiagnostics_path_event): Add
state_graph param.
(libgdiagnostics_path_event::maybe_make_diagnostic_state_graph):
New.
(libgdiagnostics_path_event::m_state_graph): New field.
(diagnostic_execution_path::add_event_va): Add state_graph param.
(class prebuilt_digraphs): New.
(diagnostic::diagnostic): Use m_graphs in m_metadata.
(diagnostic::take_graph): New.
(diagnostic::get_graphs): New accessor.
(diagnostic::m_graphs): New field.
(diagnostic_manager::take_global_graph): New.
(diagnostic_execution_path_add_event): Update for new param to
add_event_va.
(diagnostic_execution_path_add_event_va): Likewise.
(diagnostic_graph::add_node_with_id): New public entrypoint.
(diagnostic_graph::add_edge_with_label): New public entrypoint.
(diagnostic_manager_new_graph): New public entrypoint.
(diagnostic_manager_take_global_graph): New public entrypoint.
(diagnostic_take_graph): New public entrypoint.
(diagnostic_graph_release): New public entrypoint.
(diagnostic_graph_set_description): New public entrypoint.
(diagnostic_graph_add_node): New public entrypoint.
(diagnostic_graph_add_edge): New public entrypoint.
(diagnostic_graph_get_node_by_id): New public entrypoint.
(diagnostic_graph_get_edge_by_id): New public entrypoint.
(diagnostic_node_set_location): New public entrypoint.
(diagnostic_node_set_label): New public entrypoint.
(diagnostic_node_set_logical_location): New public entrypoint.
(private_diagnostic_execution_path_add_event_2): New private
entrypoint.
(private_diagnostic_graph_set_property_bag): New private
entrypoint.
(private_diagnostic_node_set_property_bag): New private
entrypoint.
(private_diagnostic_edge_set_property_bag): New private
entrypoint.
* libgdiagnostics.h (diagnostic_graph): New typedef.
(diagnostic_node): New typedef.
(diagnostic_edge): New typedef.
(diagnostic_manager_new_graph): New decl.
(diagnostic_manager_take_global_graph): New decl.
(diagnostic_take_graph): New decl.
(diagnostic_graph_release): New decl.
(diagnostic_graph_set_description): New decl.
(diagnostic_graph_add_node): New decl.
(diagnostic_graph_add_edge): New decl.
(diagnostic_graph_get_node_by_id): New decl.
(diagnostic_graph_get_edge_by_id): New decl.
(diagnostic_node_set_label): New decl.
(diagnostic_node_set_location): New decl.
(diagnostic_node_set_logical_location): New decl.
* libgdiagnostics.map (LIBGDIAGNOSTICS_ABI_3): New.
* libsarifreplay.cc: Include "libgdiagnostics-private.h".
(id_map): New "using".
(sarif_replayer::report_invalid_sarif): Update for change to
report_problem params.
(sarif_replayer::report_unhandled_sarif): Likewise.
(sarif_replayer::report_note): New.
(sarif_replayer::report_problem): Pass param "ref" by
pointer rather than reference and handle it being null.
(sarif_replayer::maybe_get_property_bag): New.
(sarif_replayer::maybe_get_property_bag_value): New.
(sarif_replayer::handle_run_obj): Handle run-level "graphs" as per
§3.14.20.
(sarif_replayer::handle_result_obj): Handle result-level "graphs"
as per Â§3.27.19.
(handle_thread_flow_location_object): Optionally handle graphs
stored in property "gcc/diagnostic_event/state_graph" as state
graphs.
(sarif_replayer::handle_graph_object): New.
(sarif_replayer::handle_node_object): New.
(sarif_replayer::handle_edge_object): New.
(sarif_replayer::get_graph_node_by_id_property): New.
* selftest-run-tests.cc (selftest::run_tests): Call
selftest::diagnostic_graph_cc_tests and
selftest::diagnostic_state_graph_cc_tests.
* selftest.h (selftest::diagnostic_graph_cc_tests): New decl.
(selftest::diagnostic_state_graph_cc_tests): New decl.

gcc/analyzer/ChangeLog:
* ana-state-to-diagnostic-state.cc: Reimplement, replacing
XML-based implementation with one based on state graphs.
* ana-state-to-diagnostic-state.h: Likewise.
* checker-event.cc: Replace include of "xml.h" with include of
"diagnostic-state-graphs.h".
(checker_event::maybe_make_xml_state): Replace with...
(checker_event::maybe_make_diagnostic_state_graph): ...this.
* checker-event.h: Add include of "diagnostic-digraphs.h".
(checker_event::maybe_make_xml_state): Replace decl with...
(checker_event::maybe_make_diagnostic_state_graph): ...this.
* engine.cc (exploded_node::on_stmt_pre): Replace
"_analyzer_dump_xml" with "__analyzer_dump_sarif".
* program-state.cc: Replace include of "diagnostic-state.h" with
"diagnostic-state-graphs.h".
(program_state::dump_dot): Port from XML to state graphs.
* program-state.h: Drop reduntant forward decl of xml::document.
(program_state::make_xml): Replace decl with...
(program_state::make_diagnostic_state_graph): ...this.
(program_state::dump_xml_to_pp): Drop decl.
(program_state::dump_xml_to_file): Drop decl.
(program_state::dump_xml): Drop decl.
(program_state::dump_dump_sarif): New decl.
* sm-malloc.cc (get_dynalloc_state_for_state): New.
(malloc_state_machine::add_state_to_xml): Replace with...
(malloc_state_machine::add_state_to_state_graph): ...this.
* sm.cc (state_machine::add_state_to_xml): Replace with...
(state_machine::add_state_to_state_graph): ...this.
(state_machine::add_global_state_to_xml): Replace with...
(state_machine::add_global_state_to_state_graph): ...this.
* sm.h (class xml_state): Drop forward decl.
(class analyzer_state_graph): New forward decl.
(state_machine::add_state_to_xml): Replace decl with...
(state_machine::add_state_to_state_graph): ...this.
(state_machine::add_global_state_to_xml): Replace decl with...
(state_machine::add_global_state_to_state_graph): ...this.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/state-diagram-1-sarif.py (test_xml_state):
Rename to...
(test_state_graph): ...this.  Port from XML to SARIF graphs.
* gcc.dg/analyzer/state-diagram-1.c: Update sink option
from "sarif:xml-state=yes" to "sarif:state-graphs=yes".
* gcc.dg/analyzer/state-diagram-5-sarif.c: Likewise.
* gcc.dg/analyzer/state-diagram-5-sarif.py: Drop import of ET.
(test_nested_types_in_xml_state): Rename to...
(test_nested_types_in_state_graph): ...this.  Port from XML to
SARIF graphs.
* gcc.dg/plugin/diagnostic-test-graphs-html.c: New test.
* gcc.dg/plugin/diagnostic-test-graphs-html.py: New test script.
* gcc.dg/plugin/diagnostic-test-graphs-sarif.c: New test.
* gcc.dg/plugin/diagnostic-test-graphs-sarif.py: New test script.
* gcc.dg/plugin/diagnostic-test-graphs.c: New test.
* gcc.dg/plugin/diagnostic_plugin_test_graphs.cc: New test plugin.
* gcc.dg/plugin/plugin.exp (plugin_test_list): Add the above.
* lib/sarif.py (get_xml_state): Delete.
(get_state_graph): New.
(def get_state_node_attr): New.
(get_state_node_kind): New.
(get_state_node_name): New.
(get_state_node_type): New.
(get_state_node_value): New.
* sarif-replay.dg/2.1.0-invalid/3.40.2-duplicate-node-id.sarif:
New test.
* sarif-replay.dg/2.1.0-invalid/3.41.4-unrecognized-node-id.sarif:
New test.
* sarif-replay.dg/2.1.0-valid/graphs-check-html.py: New test
script.
* sarif-replay.dg/2.1.0-valid/graphs-check-sarif-roundtrip.py: New
test script.
* sarif-replay.dg/2.1.0-valid/graphs.sarif: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 weeks agojson: add json::value::clone
David Malcolm [Fri, 11 Jul 2025 18:58:20 +0000 (14:58 -0400)] 
json: add json::value::clone

gcc/ChangeLog:
* json.cc (json::object::clone): New.
(json::object::clone_as_object): New.
(json::array::clone): New.
(json::float_number::clone): New.
(json::integer_number::clone): New.
(json::string::clone): New.
(json::literal::clone): New.
(selftest::test_cloning): New test.
(selftest::json_cc_tests): Call it.
* json.h (json::value::clone): New vfunc.
(json::object::clone): New decl.
(json::object::clone_as_object): New decl.
(json::array::clone): New decl.
(json::float_number::clone): New decl.
(json::integer_number::clone): New decl.
(json::string::clone): New decl.
(json::literal::clone): New decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 weeks agojson: fix null-termination of json::string
David Malcolm [Fri, 11 Jul 2025 18:58:20 +0000 (14:58 -0400)] 
json: fix null-termination of json::string

gcc/ChangeLog:
* json.cc (string::string): When constructing from pointer and
length, ensure the new buffer is null-terminated.
(selftest::test_strcmp): New.
(selftest::json_cc_tests): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 weeks agolibgdiagnostics: doc fixes
David Malcolm [Fri, 11 Jul 2025 18:58:20 +0000 (14:58 -0400)] 
libgdiagnostics: doc fixes

gcc/ChangeLog:
* doc/libgdiagnostics/topics/compatibility.rst
(_LIBGDIAGNOSTICS_ABI_2): Add missing anchor.
* doc/libgdiagnostics/topics/diagnostic-manager.rst
(diagnostic_manager_add_sink_from_spec): Add links to GCC's
documentation of "-fdiagnostics-add-output=".  Fix parameter
markup.
(diagnostic_manager_set_analysis_target): Fix parameter markup.
Add link to SARIF spec.
* doc/libgdiagnostics/topics/logical-locations.rst: Markup fix.
* doc/libgdiagnostics/tutorial/02-physical-locations.rst: Clarify
wording of what "the source file" means, and that a range can't
have multiple files.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 weeks ago[PR121007, LRA]: Fall back to reload of whole inner address in PR case and constrain...
Vladimir N. Makarov [Fri, 11 Jul 2025 15:27:54 +0000 (11:27 -0400)] 
[PR121007, LRA]: Fall back to reload of whole inner address in PR case and constrain iteration number of address reloads

gcc/ChangeLog:

* lra-constraints.cc (process_address_1): When changing base reg
on a reg of the base class, fall back to reload of whole inner address.
(process_address): Constrain the iteration number.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr121007.c: New.

2 weeks agoc++: Implement C++26 P2786R13 - Trivial Relocatability [PR119064]
Jakub Jelinek [Fri, 11 Jul 2025 17:05:38 +0000 (19:05 +0200)] 
c++: Implement C++26 P2786R13 - Trivial Relocatability [PR119064]

The following patch implements the compiler side of the C++26 paper.
Based on the https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119064#c3
feedback, the patch enables the new conditional keywords
trivially_relocatable_if_eligible and replaceable_if_eligible only
for C++26, for older versions those conditional keywords yield
-Wc++26-compat warning and are treated as normal identifiers.
Plus __trivially_relocatable_if_eligible and __replaceable_if_eligible
are handled as conditional keywords always without diagnostics (similarly
to __final in C++98).
The patch uses __builtin_ prefix on the new traits (but unlike clang
which for some weird reason chose to name one __builtin_is_replaceable
and another __builtin_is_cpp_trivially_relocatable this one uses
__builtin_is_replaceable and __builtin_is_trivially_relocatable.
I'll try to convince clang to change, they've only implemented it
recently.
The patch computes these properties on demand, only when something needs
them (at the expense of eating 2 more bits per lang_type, but I've recently
saved 64 bits and a patch to save another 64 bits is pending; and even
4 bits wouldn't fit).
The patch doesn't add __builtin_trivially_relocate builtin that clang has,
std::trivially_relocate is not constexpr and I think we don't need it for
now at least until we implement some kind of vtable pointer signing
__builtin_memmove should do the job.  Especially if libstdc++ will for clang
compatibility use the builtin if available and __builtin_memmove otherwise,
we can switch any time.
I've cross-tested all testcases also against the clang++ trunk
implementation, and both compilers agreed in everything except for
https://github.com/llvm/llvm-project/issues/143599
where clang++ was changed already and
https://github.com/llvm/llvm-project/issues/144232
where I believe clang++ got it wrong too.
The first testcase comes from
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2786r13.html#simple-worked-examples
just tweaked so that the classes are named differently each time and that it
compiles.  There are 3 differences from the paper vs. the g++ as well as
clang++ implementation, I've added comments into
trivially-relocatable1.C but I think either that part of the paper wasn't
updated through the later changes or it got it wrong.

2025-07-11  Jakub Jelinek  <jakub@redhat.com>

PR c++/119064
gcc/
* doc/invoke.texi (Wc++26-compat): Document.
gcc/c-family/
* c.opt (Wc++26-compat): New option.
* c.opt.urls: Regenerate.
* c-opts.cc (c_common_post_options): Clear warn_cxx26_compat for
C++26 or later.
* c-cppbuiltin.cc (c_cpp_builtins): For C++26 predefine
__cpp_trivial_relocatability=202502L.
gcc/cp/
* cp-tree.h: Implement C++26 P2786R13 - Trivial Relocatability.
(struct lang_type): Add trivially_relocatable,
trivially_relocatable_computed, replaceable and replaceable_computed
bitfields.  Change width of dummy from 2 to 30.
(CLASSTYPE_TRIVIALLY_RELOCATABLE_BIT,
CLASSTYPE_TRIVIALLY_RELOCATABLE_COMPUTED, CLASSTYPE_REPLACEABLE_BIT,
CLASSTYPE_REPLACEABLE_COMPUTED): Define.
(enum virt_specifier): Add VIRT_SPEC_TRIVIALLY_RELOCATABLE_IF_ELIGIBLE
and VIRT_SPEC_REPLACEABLE_IF_ELIGIBLE enumerators.
(trivially_relocatable_type_p, replaceable_type_p): Declare.
* cp-trait.def (IS_NOTHROW_RELOCATABLE, IS_REPLACEABLE,
IS_TRIVIALLY_RELOCATABLE): New traits.
* parser.cc (cp_parser_class_property_specifier_seq_opt): Handle
trivially_relocatable_if_eligible,
__trivially_relocatable_if_eligible, replaceable_if_eligible and
__replaceable_if_eligible.
(cp_parser_class_head): Set CLASSTYPE_REPLACEABLE_BIT
and/or CLASSTYPE_TRIVIALLY_RELOCATABLE_BIT if corresponding
conditional keywords were parsed and assert corresponding *_COMPUTED
macro is false.
* pt.cc (instantiate_class_template): Copy over also
CLASSTYPE_TRIVIALLY_RELOCATABLE_{BIT,COMPUTED} and
CLASSTYPE_REPLACEABLE_{BIT,COMPUTED} bits.
* semantics.cc (referenceable_type_p): Move definition earlier.
(trait_expr_value): Handle CPTK_IS_NOTHROW_RELOCATABLE,
CPTK_IS_REPLACEABLE and CPTK_IS_TRIVIALLY_RELOCATABLE.
(finish_trait_expr): Likewise.
* tree.cc (default_movable_type_p): New function.
(union_with_no_declared_special_member_fns): Likewise.
(trivially_relocatable_type_p): Likewise.
(replaceable_type_p): Likewise.
* constraint.cc (diagnose_trait_expr): Handle
CPTK_IS_NOTHROW_RELOCATABLE, CPTK_IS_REPLACEABLE and
CPTK_IS_TRIVIALLY_RELOCATABLE.
gcc/testsuite/
* g++.dg/cpp26/feat-cxx26.C: Add test for
__cpp_trivial_relocatability.
* g++.dg/cpp26/trivially-relocatable1.C: New test.
* g++.dg/cpp26/trivially-relocatable2.C: New test.
* g++.dg/cpp26/trivially-relocatable3.C: New test.
* g++.dg/cpp26/trivially-relocatable4.C: New test.
* g++.dg/cpp26/trivially-relocatable5.C: New test.
* g++.dg/cpp26/trivially-relocatable6.C: New test.
* g++.dg/cpp26/trivially-relocatable7.C: New test.
* g++.dg/cpp26/trivially-relocatable8.C: New test.
* g++.dg/cpp26/trivially-relocatable9.C: New test.
* g++.dg/cpp26/trivially-relocatable10.C: New test.
* g++.dg/cpp26/trivially-relocatable11.C: New test.

2 weeks agoaarch64: Tweak handling of general SVE permutes [PR121027]
Richard Sandiford [Fri, 11 Jul 2025 15:48:41 +0000 (16:48 +0100)] 
aarch64: Tweak handling of general SVE permutes [PR121027]

This PR is partly about a code quality regression that was triggered
by g:caa7a99a052929d5970677c5b639e1fa5166e334.  That patch taught the
gimple optimisers to fold two VEC_PERM_EXPRs into one, conditional
upon either (a) the original permutations not being "native" operations
or (b) the combined permutation being a "native" operation.

Whether something is a "native" operation is tested by calling
can_vec_perm_const_p with allow_variable_p set to false.  This requires
the permutation to be supported directly by TARGET_VECTORIZE_VEC_PERM_CONST,
rather than falling back to the general vec_perm optab.

This exposed a problem with the way that we handled general 2-input
permutations for SVE.  Unlike Advanced SIMD, base SVE does not have
an instruction to do general 2-input permutations.  We do still implement
the vec_perm optab for SVE, but only when the vector length is known at
compile time.  The general expansion is pretty expensive: an AND, a SUB,
two TBLs, and an ORR.  It certainly couldn't be considered a "native"
operation.

However, if a VEC_PERM_EXPR has a constant selector, the indices can
be wider than the elements being permuted.  This is not true for the
vec_perm optab, where the indices and permuted elements must have the
same precision.

This leads to one case where we cannot leave a general 2-input permutation
to be handled by the vec_perm optab: when permuting bytes on a target
with 2048-bit vectors.  In that case, the indices of the elements in
the second vector are in the range [256, 511], which cannot be stored
in a byte index.

TARGET_VECTORIZE_VEC_PERM_CONST therefore has to handle 2-input SVE
permutations for one specific case.  Rather than check for that
specific case, the code went ahead and used the vec_perm expansion
whenever it worked.  But that undermines the !allow_variable_p
handling in can_vec_perm_const_p; it becomes impossible for
target-independent code to distinguish "native" operations from
the worst-case fallback.

This patch instead limits TARGET_VECTORIZE_VEC_PERM_CONST to the
cases that it has to handle.  It fixes the PR for all vector lengths
except 2048 bits.

A better fix would be to introduce some sort of costing mechanism,
which would allow us to reject the new VEC_PERM_EXPR even for
2048-bit targets.  But that would be a significant amount of work
and would not be backportable.

gcc/
PR target/121027
* config/aarch64/aarch64.cc (aarch64_evpc_sve_tbl): Punt on 2-input
operations that can be handled by vec_perm.

gcc/testsuite/
PR target/121027
* gcc.target/aarch64/sve/acle/general/perm_1.c: New test.

2 weeks agoaarch64: Use EOR3 for DImode values
Kyrylo Tkachov [Thu, 3 Jul 2025 17:09:47 +0000 (10:09 -0700)] 
aarch64: Use EOR3 for DImode values

Similar to BCAX, we can use EOR3 for DImode, but we have to be careful
not to force GP<->SIMD moves unnecessarily, so add a splitter for that case.

So for input:
uint64_t eor3_d_gp (uint64_t a, uint64_t b, uint64_t c) { return EOR3 (a, b, c); }
uint64x1_t eor3_d (uint64x1_t a, uint64x1_t b, uint64x1_t c) { return EOR3 (a, b, c); }

We generate the desired:
eor3_d_gp:
        eor     x1, x1, x2
        eor     x0, x1, x0
        ret

eor3_d:
        eor3    v0.16b, v0.16b, v1.16b, v2.16b
        ret

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

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
gcc/

* config/aarch64/aarch64-simd.md (*eor3qdi4): New
define_insn_and_split.

gcc/testsuite/

* gcc.target/aarch64/simd/eor3_d.c: Add tests for DImode operands.

2 weeks agoaarch64: Handle DImode BCAX operations
Kyrylo Tkachov [Thu, 3 Jul 2025 16:45:02 +0000 (09:45 -0700)] 
aarch64: Handle DImode BCAX operations

To handle DImode BCAX operations we want to do them on the SIMD side only if
the incoming arguments don't require a cross-bank move.
This means we need to split back the combination to separate GP BIC+EOR
instructions if the operands are expected to be in GP regs through reload.
The split happens pre-reload if we already know that the destination will be
a GP reg.  Otherwise if reload descides to use the "=r,r" alternative we ensure
operand 0 is early-clobber.
This scheme is similar to how we handle the BSL operations elsewhere in
aarch64-simd.md.

Thus, for the functions:
uint64_t bcax_d_gp (uint64_t a, uint64_t b, uint64_t c) { return BCAX (a, b, c); }
uint64x1_t bcax_d (uint64x1_t a, uint64x1_t b, uint64x1_t c) { return BCAX (a, b, c); }

we now generate the desired:
bcax_d_gp:
        bic     x1, x1, x2
        eor     x0, x1, x0
        ret

bcax_d:
        bcax    v0.16b, v0.16b, v1.16b, v2.16b
        ret

When the inputs are in SIMD regs we use BCAX and when they are in GP regs we
don't force them to SIMD with extra moves.

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

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
gcc/

* config/aarch64/aarch64-simd.md (*bcaxqdi4): New
define_insn_and_split.

gcc/testsuite/

* gcc.target/aarch64/simd/bcax_d.c: Add tests for DImode arguments.

2 weeks agoaarch64: Use EOR3 for 64-bit vector modes
Kyrylo Tkachov [Thu, 3 Jul 2025 15:58:19 +0000 (08:58 -0700)] 
aarch64: Use EOR3 for 64-bit vector modes

Similar to the BCAX patch, we can also use EOR3 for 64-bit modes,
just by adjusting the mode iterator used.
Thus for input:

uint32x2_t
bcax_s (uint32x2_t a, uint32x2_t b, uint32x2_t c)
{
  return EOR3 (a, b, c);
}

we now generate:
bcax_s:
        eor3    v0.16b, v0.16b, v1.16b, v2.16b
        ret

instead of:
bcax_s:
        eor     v1.8b, v1.8b, v2.8b
        eor     v0.8b, v1.8b, v0.8b
        ret

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
gcc/

* config/aarch64/aarch64-simd.md (eor3q<mode>4): Use VDQ_I mode
iterator.

gcc/testsuite/

* gcc.target/aarch64/simd/eor3_d.c: New test.

2 weeks agoaarch64: Allow 64-bit vector modes in pattern for BCAX instruction
Kyrylo Tkachov [Thu, 3 Jul 2025 15:37:33 +0000 (08:37 -0700)] 
aarch64: Allow 64-bit vector modes in pattern for BCAX instruction

The BCAX instruction from TARGET_SHA3 only operates on the full .16b form
of the inputs but as it's a pure bitwise operation we can use it for the 64-bit
modes as well as there we don't care about the upper 64 bits.  This patch extends
the relevant pattern in aarch64-simd.md to accept the 64-bit vector modes.

Thus, for the input:
uint32x2_t
bcax_s (uint32x2_t a, uint32x2_t b, uint32x2_t c)
{
  return BCAX (a, b, c);
}

we can now generate:
bcax_s:
        bcax    v0.16b, v0.16b, v1.16b, v2.16b
        ret

instead of the current:
bcax_s:
        bic     v1.8b, v1.8b, v2.8b
        eor     v0.8b, v1.8b, v0.8b
        ret

This patch doesn't cover the DI/V1DI modes as that would require extending
the bcaxqdi4 pattern with =r,r alternatives and adding splitting logic to
handle the cases where the operands arrive in GP regs.  It is doable, but can
be a separate patch.  This patch as is should be a straightforward improvement
always.

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

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
gcc/

* config/aarch64/aarch64-simd.md (bcaxq<mode>4): Use VDQ_I mode
iterator.

gcc/testsuite/

* gcc.target/aarch64/simd/bcax_d.c: New test.

2 weeks agotree-optimization/121034 - fix reduction vectorization
Richard Biener [Fri, 11 Jul 2025 11:14:13 +0000 (13:14 +0200)] 
tree-optimization/121034 - fix reduction vectorization

The following fixes the loop following the reduction chain to
properly visit all SLP nodes involved and makes the stmt info
and the SLP node we track match.

PR tree-optimization/121034
* tree-vect-loop.cc (vectorizable_reduction): Cleanup
reduction chain following code.

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

2 weeks agolibstdc++: Implement C++26 P3748R0 - Inspecting exception_ptr should be constexpr
Jakub Jelinek [Fri, 11 Jul 2025 11:50:07 +0000 (13:50 +0200)] 
libstdc++: Implement C++26 P3748R0 - Inspecting exception_ptr should be constexpr

The following patch makes std::exception_ptr_cast constexpr.
The paper suggests using dynamic_cast, but that does only work for
polymorphic exceptions, doesn't work if they are scalar or non-polymorphic
classes.

Furthermore, the patch adds some static_asserts for
"Mandates: E is a cv-unqualified complete object type. E is not an array type.
E is not a pointer or pointer-to-member type."

2025-07-11  Jakub Jelinek  <jakub@redhat.com>

* libsupc++/exception_ptr.h: Implement C++26 P3748R0 - Inspecting
exception_ptr should be constexpr.
(std::exception_ptr_cast): Make constexpr, remove inline keyword.  Add
static_asserts for Mandates.  For if consteval use std::rethrow_exception,
catch it and return its address or nullptr.
* testsuite/18_support/exception_ptr/exception_ptr_cast.cc (E::~E): Add
constexpr.
(G::G): Likewise.
(test01): Likewise.  Return bool and take bool argument, throw if the
argument is true.  Add static_assert(test01(false)).
(main): Call test01(true) in try.

2 weeks agotestsuite: Add testcase for already fixed PR [PR120954]
Jakub Jelinek [Fri, 11 Jul 2025 11:43:58 +0000 (13:43 +0200)] 
testsuite: Add testcase for already fixed PR [PR120954]

This was a regression introduced by r16-1893 (and its backports) for C++,
though for C it had false positive warning for years.  Fixed by r16-2000
(and its backports).

2025-07-11  Jakub Jelinek  <jakub@redhat.com>

PR c++/120954
* c-c++-common/Warray-bounds-11.c: New test.

2 weeks agoRewrite assign_discriminators
Jan Hubicka [Fri, 11 Jul 2025 11:01:13 +0000 (13:01 +0200)] 
Rewrite assign_discriminators

To assign debug locations to corresponding statements auto-fdo uses
discriminators.  Documentation says that if given statement belongs to multiple
basic blocks, the discrminator distinguishes them.

Current implementation however only work fork statements that expands into a
squence of gimple statements which forms a linear sequence, sicne it
essentially tracks a current location and renews it each time new BB is found.
This is commonly not true for C++ code as in:

  <bb 25> :
  [simulator/csimplemodule.cc:379:85] _40 = std::__cxx11::basic_string<char>::c_str ([simulator/csimplemodule.cc:379:85] &D.80680);
  [simulator/csimplemodule.cc:379:85 discrim 13] _41 = [simulator/csimplemodule.cc:379:85] &this->D.78503.D.78106.D.72008.D.68585.D.67935.D.67879.D.67782;
  [simulator/csimplemodule.cc:379:85 discrim 13] _42 = &this->D.78503.D.78106.D.72008.D.68585.D.67935.D.67879.D.67782;
  [simulator/csimplemodule.cc:377:45] _43 = this->D.78503.D.78106.D.72008.D.68585.D.67935.D.67879.D.67782._vptr.cObject;
  [simulator/csimplemodule.cc:377:45] _44 = _43 + 40;
  [simulator/csimplemodule.cc:377:45] _45 = [simulator/csimplemodule.cc:377:45] *_44;
  [simulator/csimplemodule.cc:379:85] D.89001 = OBJ_TYPE_REF(_45;(const struct cObject)_42->5B) (_41);

This is a fragment of code that is expanded from:

371         if (this!=simulation.getContextModule())
372             throw cRuntimeError("send()/sendDelayed() of module (%s)%s called in the context of "
373                                 "module (%s)%s: method called from the latter module "
374                                 "lacks Enter_Method() or Enter_Method_Silent()? "
375                                 "Also, if message to be sent is passed from that module, "
376                                 "you'll need to call take(msg) after Enter_Method() as well",
377                                 getClassName(), getFullPath().c_str(),
378                                 simulation.getContextModule()->getClassName(),
379                                 simulation.getContextModule()->getFullPath().c_str());

Notice that 379:85 is interleaved by 377:45 and the pass does not assign new discriminator.
With patch we get:

  <bb 25> :
  [simulator/csimplemodule.cc:379:85 discrim 7] _40 = std::__cxx11::basic_string<char>::c_str ([simulator/csimplemodule.cc:379:85] &D.80680);
  [simulator/csimplemodule.cc:379:85 discrim 8] _41 = [simulator/csimplemodule.cc:379:85] &this->D.78503.D.78106.D.72008.D.68585.D.67935.D.67879.D.67782;
  [simulator/csimplemodule.cc:379:85 discrim 8] _42 = &this->D.78503.D.78106.D.72008.D.68585.D.67935.D.67879.D.67782;
  [simulator/csimplemodule.cc:377:45 discrim 1] _43 = this->D.78503.D.78106.D.72008.D.68585.D.67935.D.67879.D.67782._vptr.cObject;
  [simulator/csimplemodule.cc:377:45 discrim 1] _44 = _43 + 40;
  [simulator/csimplemodule.cc:377:45 discrim 1] _45 = [simulator/csimplemodule.cc:377:45] *_44;
  [simulator/csimplemodule.cc:379:85 discrim 8] D.89001 = OBJ_TYPE_REF(_45;(const struct cObject)_42->5B) (_41);

There are earlier statements with line number 379, so that is why there is discriminator 7 for the call.
After that discriminator is increased.  There are two reasons for it
 1) AFDO requires every callsite to have unique lineno:discriminator pair
 2) call may not terminate and htus the profile of first statement
    may be higher than the rest.

Old pass also contained logic to skip debug statements.  This is not a good
idea since we output them to the debug output and if AFDO tool picks these
locations up they will be misplaced in basic blocks.

Debug statements are naturally quite useful to track back the AFDO profiles
and in meantime LLVM folks implemented something similar called pseudoprobe.
I think it makes sense toenable debug statements with -fauto-profile even if
debug info is off and make use of them as done in this patch.

Sadly AFDO tool is quite broken and bulid around assumption that every address
has at most one debug location assigned to it (i.e. debug info before debug
statements were introduced). I have WIP patch fixing this.

Note that LLVM also has -fdebug-info-for-auto-profile (on by defualt it seems)
that controls discriminator production and some other little bits.  I wonder if
we want to have something similar.  Should it be -gdebug-info-for-auto-profile
instead?

gcc/ChangeLog:

* opts.cc (finish_options): Enable debug_nonbind_markers_p for
auto-profile.
* tree-cfg.cc (struct locus_discrim_map): Remove.
(struct locus_discrim_hasher): Remove.
(locus_discrim_hasher::hash): Remove.
(locus_discrim_hasher::equal): Remove.
(first_non_label_nondebug_stmt): Remove.
(build_gimple_cfg): Do not allocate discriminator tables.
(next_discriminator_for_locus): Remove.
(same_line_p): Remove.
(struct discrim_entry): New structure.
(assign_discriminator): Rewrite.
(assign_discriminators): Rewrite.

2 weeks agoFix ICE in speculative devirtualization
Jan Hubicka [Fri, 11 Jul 2025 10:37:24 +0000 (12:37 +0200)] 
Fix ICE in speculative devirtualization

This patch fixes ICE bilding lto1 with autoprofiledbootstrap and in pr114790.
What happens is that auto-fdo speculatively devirtualizes to a wrong target.
This is due to a bug where it mixes up dwarf names and linkage names of inline
functions I need to fix as well.

Later we clone at WPA time. At ltrans time clone is materialized and call is
turned into a direct call (this optimization is missed by ipa-cp propagation).
At this time we should resolve speculation but we don't.  As a result we get
error from verifier after inlining complaining that there is speculative call
with corresponding direct call lacking speculative flag.

This seems long-lasting problem in cgraph_update_edges_for_call_stmt_node but
I suppose it does not trigger since we usually speculate correctly or notice
the direct call at WPA time already.

Bootstrapped/regtested x86_64-linux.

gcc/ChangeLog:

PR ipa/114790
* cgraph.cc (cgraph_update_edges_for_call_stmt_node): Resolve devirtualization
if call statement was optimized out or turned to direct call.

gcc/testsuite/ChangeLog:

* g++.dg/lto/pr114790_0.C: New test.
* g++.dg/lto/pr114790_1.C: New test.

2 weeks agoipa: Disallow signature changes in fun->has_musttail functions [PR121023]
Jakub Jelinek [Fri, 11 Jul 2025 10:09:44 +0000 (12:09 +0200)] 
ipa: Disallow signature changes in fun->has_musttail functions [PR121023]

As the following testcase shows e.g. on ia32, letting IPA opts change
signature of functions which have [[{gnu,clang}::musttail]] calls
can turn programs that would be compiled normally into something
that is rejected because the caller has fewer argument stack slots
than the function being tail called.

The following patch prevents signature changes for such functions.
It is perhaps too big hammer in some cases, but it might be hard
to try to figure out what signature changes are still acceptable and which
are not at IPA time.

2025-07-11  Jakub Jelinek  <jakub@redhat.com>
    Martin Jambor  <mjambor@suse.cz>

PR ipa/121023
* ipa-fnsummary.cc (compute_fn_summary): Disallow signature changes
on cfun->has_musttail functions.

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

2 weeks agoi386: Add a new peeophole2 for PR91384 under APX_F
Hu, Lin1 [Tue, 8 Apr 2025 07:43:59 +0000 (15:43 +0800)] 
i386: Add a new peeophole2 for PR91384 under APX_F

gcc/ChangeLog:

PR target/91384
* config/i386/i386.md: Add new peeophole2 for optimize *negsi_1
followed by *cmpsi_ccno_1 with APX_F.

gcc/testsuite/ChangeLog:

PR target/91384
* gcc.target/i386/pr91384-1.c: New test.

2 weeks agoproperly compute fp/mode for scalar ops for vectorizer costing
Richard Biener [Thu, 10 Jul 2025 11:30:30 +0000 (13:30 +0200)] 
properly compute fp/mode for scalar ops for vectorizer costing

The x86 add_stmt_hook relies on the passed vectype to determine
the mode and whether it is FP for a scalar operation.  This is
unreliable now for stmts involving patterns and in the future when
there is no vector type passed for scalar operations.

To be least disruptive I've kept using the vector type if it is passed.

* config/i386/i386.cc (ix86_vector_costs::add_stmt_cost): Use
the LHS of a scalar stmt to determine mode and whether it is FP.

2 weeks agocobol: Fix build on 32-bit Darwin [PR120621]
Rainer Orth [Fri, 11 Jul 2025 07:56:18 +0000 (09:56 +0200)] 
cobol: Fix build on 32-bit Darwin [PR120621]

Bootstrapping trunk with 32-bit-default on Mac OS X 10.11
(i386-apple-darwin15) fails:

/vol/gcc/src/hg/master/local/gcc/cobol/lexio.cc: In static member function 'static void cdftext::process_file(filespan_t, int, bool)':
/vol/gcc/src/hg/master/local/gcc/cobol/lexio.cc:1859:14: error: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'size_t' {aka 'long unsigned int'} [-Werror=format=]
 1859 |       dbgmsg("%s:%d: line " HOST_SIZE_T_PRINT_UNSIGNED ", opening %s on fd %d",
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1860 |              __func__, __LINE__,mfile.lineno(),
      |                                 ~~~~~~~~~~~~~~
      |                                             |
      |                                             size_t {aka long unsigned int}
In file included from /vol/gcc/src/hg/master/local/gcc/system.h:1244,
                 from /vol/gcc/src/hg/master/local/gcc/cobol/cobol-system.h:61,
                 from /vol/gcc/src/hg/master/local/gcc/cobol/lexio.cc:33:
/vol/gcc/src/hg/master/local/gcc/hwint.h:135:51: note: format string is defined here
  135 | #define HOST_SIZE_T_PRINT_UNSIGNED "%" GCC_PRISZ "u"
      |                                     ~~~~~~~~~~~~~~^
      |                                                   |
      |                                                   unsigned int
      |                                     %" GCC_PRISZ "lu

On Darwin, size_t is always long unsigned int.  However, unsigned int
and long unsigned int are both 32-bit, so hwint.h selects %u for the
format.  As documented there, the arg needs to be cast to fmt_size_t to
avoid the error.

This isn't an issue on other 32-bit platforms like Solaris/i386 or
Linux/i686 since they use unsigned int for size_t.

/vol/gcc/src/hg/master/local/gcc/cobol/parse.y: In function 'int yyparse()':
/vol/gcc/src/hg/master/local/gcc/cobol/parse.y:10215:36: error: format '%zu' expects argument of type 'size_t', but argument 4 has type 'int' [-Werror=format=]
10215 |                     error_msg(loc, "FUNCTION %qs has "
      |                                    ^~~~~~~~~~~~~~~~~~~
10216 |                               "inconsistent parameter type %zu (%qs)",
      |                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10217 |                               keyword_str($1), p - args.data(), name_of(p->field) );
      |                                                                ~~~~~~~~~~~~~~~
      |                                                                  |
      |                                                                  int

The arg (p - args.data())) is ptrdiff_t (int on 32-bit Darwin), while
the %zu format expect size_t (long unsigned int).  The patch therefore
casts the ptrdiff_t arg to long and prints it as such.

There are two more instances of the same problem:

/vol/gcc/src/hg/master/local/gcc/cobol/util.cc: In member function 'void cbl_field_t::report_invalid_initial_value(const YYLTYPE&) const':
/vol/gcc/src/hg/master/local/gcc/cobol/util.cc:905:80: error: format '%zu' expects argument of type 'size_t', but argument 6 has type 'int' [-Werror=format=]
  905 |                 error_msg(loc, "%s cannot represent VALUE %qs exactly (max %c%zu)",
      |                                                                              ~~^
      |                                                                                |
      |                                                                                long unsigned int
      |                                                                              %u
  906 |                           name, data.initial, '.', pend - p);
      |                                                    ~~~~~~~~
      |                                                         |
      |                                                         int

In file included from /vol/gcc/src/hg/master/local/gcc/cobol/scan.l:48:
/vol/gcc/src/hg/master/local/gcc/cobol/scan_ante.h: In function 'int numstr_of(const char*, radix_t)':
/vol/gcc/src/hg/master/local/gcc/cobol/scan_ante.h:152:25: error: format '%zu' expects argument of type 'size_t', but argument 4 has type 'int' [-Werror=format=]
  152 |       error_msg(yylloc, "significand of %s has more than 36 digits (%zu)", input, nx);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~         ~~
      |                                                                                   |
      |                                                                                   int

Fixed in the same way.

Bootstrapped without regressions on i386-apple-darwin15,
x86_64-apple-darwin, i386-pc-solaris2.11, amd64-pc-solaris2.11,
i686-pc-linux-gnu, and x86_64-pc-linux-gnu.

2025-06-23  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/cobol:
PR cobol/120621
* lexio.cc (parse_replace_pairs): Cast mfile.lineno() to fmt_size_t.
* parse.y (intrinsic): Print ptrdiff_t using %ld, cast arg to long.
* scan_ante.h (numstr_of): Print nx using %ld, cast arg to long.
* util.cc (cbl_field_t::report_invalid_initial_value): Print
ptrdiff_t using %ld, cast arg to long.

2 weeks agolibstdc++: Always treat __float128 as a floating-point type
Jonathan Wakely [Wed, 2 Jul 2025 20:16:30 +0000 (21:16 +0100)] 
libstdc++: Always treat __float128 as a floating-point type

Similar to the previous commit that made is_integral_v<__int128>
unconditionally true, this makes is_floating_point_v<__float128>
unconditionally true. With the new extended floating-point types in
C++23 (std::float64_t etc.) it seems unhelpful for is_floating_point_v
to be true for them, but not for __float128. Especially as it is true on
some targets, because __float128 is just a typedef for long double.

This change makes is_floating_point_v<__float128> true whenever the type
is defined, giving less surprising and more portable behaviour.

libstdc++-v3/ChangeLog:

* include/bits/cpp_type_traits.h (__is_floating<__float128>):
Do not depend on __STRICT_ANSI__.
* include/bits/stl_algobase.h (__size_to_integer(__float128)):
Likewise.
* include/std/type_traits (__is_floating_point_helper<__float128>):
Likewise.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
2 weeks agolibstdc++: Treat __int128 as a real integral type [PR96710]
Jonathan Wakely [Fri, 16 May 2025 12:33:23 +0000 (13:33 +0100)] 
libstdc++: Treat __int128 as a real integral type [PR96710]

Since LWG 3828 (included in C++23) implementations are allowed to have
extended integer types that are wider than intmax_t. This means we no
longer have to make is_integral_v<__int128> false for strict -std=c++23
mode, removing the confusing inconsistency with -std=gnu++23 (where
is_integral_v<__int128> is true).

This change makes __int128 a true integral type for all modes, treating
LWG 3828 as a DR for previous standards. Most of the change just
involves removing special cases where we wanted to treat __int128 and
unsigned __int128 as integral types even when is_integral_v was false.

There are still some preprocessor conditionals needed, because on some
targets the compiler defines the macro __GLIBCXX_TYPE_INT_N_0 as
__int128 in non-strict modes. Because we define explicit specializations
of templates such as is_integral for all the INT_N types, we already
have a specialization of is_integral<__int128> in non-strict modes, and
so to avoid a redefinition we only must only define
is_integral<__int128> for strict modes.

libstdc++-v3/ChangeLog:

PR libstdc++/96710
* include/bits/cpp_type_traits.h (__is_integer): Define explicit
specializations for __int128.
(__memcpyable_integer): Remove explicit specializations for
__int128.
* include/bits/iterator_concepts.h (incrementable_traits):
Likewise.
(__is_signed_int128, __is_unsigned_int128, __is_int128): Remove.
(__is_integer_like, __is_signed_integer_like): Remove check for
__int128.
* include/bits/max_size_type.h: Remove all uses of __is_int128
in constraints.
* include/bits/ranges_base.h (__to_unsigned_like): Remove
overloads for __int128.
(ranges::ssize): Remove special case for __int128.
* include/bits/stl_algobase.h (__size_to_integer): Define
__int128 overloads for strict modes.
* include/ext/numeric_traits.h (__is_integer_nonstrict): Remove
explicit specializations for __int128.
* include/std/charconv (to_chars): Define overloads for
__int128.
* include/std/format (__format::make_unsigned_t): Remove.
(__format::to_chars): Remove.
* include/std/limits (numeric_limits): Define explicit
specializations for __int128.
* include/std/type_traits (__is_integral_helper): Likewise.
(__make_unsigned, __make_signed): Likewise.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
2 weeks agoFortran: Implement F2018 IMPORT statements [PR106135]
Paul Thomas [Fri, 11 Jul 2025 07:28:27 +0000 (08:28 +0100)] 
Fortran:  Implement F2018 IMPORT statements [PR106135]

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

gcc/fortran
PR fortran/106135
* decl.cc (build_sym): Emit an error if a symbol associated by
an IMPORT, ONLY or IMPORT, all statement is being redeclared.
(gfc_match_import): Parse and check the F2018 versions of the
IMPORT statement. For scopes other than and interface body, if
the symbol cannot be found in the host scope, generate it and
set it up such that gfc_fixup_sibling_symbols can transfer its
'imported attribute' if it turnes out to be a not yet parsed
procedure. Test for violations of C897-8100.
* gfortran.h : Add 'import_only' to the gfc_symtree structure.
Add the enum, 'importstate', which is used for values the new
field 'import_state' in gfc_namespace.
* parse.cc (gfc_fixup_sibling_symbols): Transfer the attribute
'imported' to the new symbol.
* resolve.cc (check_sym_import_status, check_import_status):
New functions to test symbols and expressions for violations of
F2018:C8102.
(resolve_call): Test the 'resolved_sym' against C8102 by a call
to 'check_sym_import_status'.
(gfc_resolve_expr): If the expression is OK and an IMPORT
statement has been registered in the current scope, test C102
by calling 'check_import_status'.
(resolve_select_type): Test the declared derived type in TYPE
IS and CLASS IS statements.

gcc/testsuite/
PR fortran/106135
* gfortran.dg/import3.f90: Use -std=f2008 and comment on change
in error message texts with f2018.
* gfortran.dg/import12.f90: New test.

2 weeks agoStop updating gcc-12 branch
Richard Biener [Fri, 11 Jul 2025 06:32:26 +0000 (08:32 +0200)] 
Stop updating gcc-12 branch

contrib/
* gcc-changelog/git_update_version.py: Stop updating gcc-12
branch.

2 weeks agoDaily bump.
GCC Administrator [Fri, 11 Jul 2025 00:19:26 +0000 (00:19 +0000)] 
Daily bump.

2 weeks agoc++: Save 8 further bytes from lang_type allocations
Jakub Jelinek [Thu, 10 Jul 2025 22:05:23 +0000 (00:05 +0200)] 
c++: Save 8 further bytes from lang_type allocations

The following patch implements the
/* FIXME reuse another field?  */
comment on the lambda_expr member.
I think (and asserts in the patch seem to confirm) CLASSTYPE_KEY_METHOD
is only ever non-NULL for TYE_POLYMORPHIC_P and on the other side
CLASSTYPE_LAMBDA_EXPR is only used on closure types which are never
polymorphic.

So, the patch just uses one member for both, with the accessor macros
changed to be no longer lvalues and adding SET_* variants of the macros
for setters.

2025-07-11  Jakub Jelinek  <jakub@redhat.com>

* cp-tree.h (struct lang_type): Add comment before key_method.
Remove lambda_expr.
(CLASSTYPE_KEY_METHOD): Give NULL_TREE if not TYPE_POLYMORPHIC_P.
(SET_CLASSTYPE_KEY_METHOD): Define.
(CLASSTYPE_LAMBDA_EXPR): Give NULL_TREE if TYPE_POLYMORPHIC_P.
Use key_method member instead of lambda_expr.
(SET_CLASSTYPE_LAMBDA_EXPR): Define.
* class.cc (determine_key_method): Use SET_CLASSTYPE_KEY_METHOD
macro.
* decl.cc (xref_tag): Use SET_CLASSTYPE_LAMBDA_EXPR macro.
* lambda.cc (begin_lambda_type): Likewise.
* module.cc (trees_in::read_class_def): Use SET_CLASSTYPE_LAMBDA_EXPR
and SET_CLASSTYPE_KEY_METHOD macros, assert lambda is NULL if
TYPE_POLYMORPHIC_P and otherwise assert key_method is NULL.