]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
5 weeks agodom: small compile time optimization with switches
Andrew Pinski [Fri, 15 May 2026 21:40:52 +0000 (14:40 -0700)] 
dom: small compile time optimization with switches

In the process of converting gswitch away from CASE_LABEL_EXPR,
I found a place in dom where we store the whole CASE_LABEL_EXPR.
This place only needed to store the value of the case rather than
the whole case expression. This does that small optimization
and adds a few comments for the next person to understand what
is going on here. It was not obvious at my first read of the code
what it was doing or what error_mark was being used for.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-ssa-dom.cc (record_edge_info): For switches
info only store the case low value to be recorded as
the only value. Add comments.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
5 weeks agoDaily bump.
GCC Administrator [Sun, 17 May 2026 00:16:24 +0000 (00:16 +0000)] 
Daily bump.

5 weeks agoPR 122245: -fc-prototypes when procedure defined via INTERFACE
Thomas Koenig [Sat, 16 May 2026 14:37:57 +0000 (16:37 +0200)] 
PR 122245: -fc-prototypes when procedure defined via INTERFACE

This simple patch emits correct prototypes when a procedure is
defined via an interface by simply checking the presence
of an interface and using its formal arglist.

gcc/fortran/ChangeLog:

PR fortran/122245
* dump-parse-tree.cc (write_formal_arglist): Take the formal
arglist from the symbol's interface if it is present.

5 weeks agolibgomp: Fix env.c compilation on Darwin
Rainer Orth [Sat, 16 May 2026 12:17:31 +0000 (14:17 +0200)] 
libgomp: Fix env.c compilation on Darwin

Darwin bootstrap is currently broken compiling libgomp/env.c:

libgomp/env.c: In function 'initialize_env':
libgomp/env.c:2476:7: error: use of logical '||' with constant operand '2097152' [-Werror=constant-logical-operand]
 2476 |       || GOMP_DEFAULT_STACKSIZE)
      |       ^~
libgomp/env.c:2476:7: note: use '|' for bitwise operation
 2476 |       || GOMP_DEFAULT_STACKSIZE)
      |       ^~

This is only seen on Darwin since this is the only target that defines a
non-zero GOMP_DEFAULT_STACKSIZE.

Bootstrapped without regressions on x86_64-apple-darwin25.5.0 and
x86_64-apple-darwin21.6.0.

2026-05-16  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libgomp:
* env.c (initialize_env): Check GOMP_DEFAULT_STACKSIZE for
non-zero.

5 weeks agolibstdc++: replace assert with __glibcxx_assert [PR125228]
Dragon Archer [Fri, 8 May 2026 18:16:15 +0000 (18:16 +0000)] 
libstdc++: replace assert with __glibcxx_assert [PR125228]

Unlike `__glibcxx_assert` which is guarded by `_GLIBCXX_ASSERTIONS` and
enabled only in Debug build of libstdc++, `assert` is either always
enabled, or always disabled if manually defining `NDEBUG` before
`#include <cassert>` or `#include <assert.h>`. This not only makes
`assert` inflexible, but also introduces extra runtime overhead and/or
increased binary size in Release builds.

Uses of `assert` without `NDEBUG` introduces `__FILE__` into the final
library, and unconditionally checks the assertions.

This patch replaces the uses of `assert` in ryu and debug.cc with
`__glibcxx_assert`, and removed their direct dependency on `<cassert>`.
To avoid modifying the third-party ryu headers, this patch redefines
`assert` to `__glibcxx_assert` when including the ryu headers.

libstdc++-v3/ChangeLog:

PR libstdc++/125228
* src/c++11/debug.cc: Replace assert with __glibcxx_assert,
and remove the include of <cassert>.
* src/c++17/floating_to_chars.cc: Likewise, but redefine
assert as __glibcxx_assert.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
5 weeks agolibstdc++: Make configure check for atomics work on Windows [PR125312]
Jonathan Wakely [Fri, 15 May 2026 09:41:33 +0000 (10:41 +0100)] 
libstdc++: Make configure check for atomics work on Windows [PR125312]

The changes in r16-427-g86627faec10da5 do not work for native mingw-w64
builds because the #include with a hardcoded unix-style path doesn't
work for a native mingw-w64 compiler. This results in configure
detecting that native mingw builds do not support atomic builtins for
the _Atomic_word type, causing non-inline atomics to be used for
__gnu_cxx::__exchange_and_add and __gnu_cxx::__atomic_add, which is an
unintented ABI change (and inconsistent with mingw cross-compilers where
the configure test passes and so enables the inline functions using
atomic builtins).

This attempts to solve the problem by copying the atomic_word.h header
to the current working directory, so it can be included without using an
absolute path.

libstdc++-v3/ChangeLog:

PR libstdc++/125312
* acinclude.m4 (GLIBCXX_ENABLE_ATOMIC_BUILTINS): Copy header
into cwd instead of including it via an absolute path.
* configure: Regenerate.

5 weeks agomatch.pd: Enable some __builtin_bswap* optimizations even for __builtin_bitreverse...
Jakub Jelinek [Sat, 16 May 2026 08:51:39 +0000 (10:51 +0200)] 
match.pd: Enable some __builtin_bswap* optimizations even for __builtin_bitreverse* [PR50481]

Most of the bswap optimizations equally apply also to bitreverse builtins.
The following patch enables those.

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

PR target/50481
* match.pd (BITREVERSE): New define_operator_list.  Use it next to
BSWAP for a subset of bswap simplifications.

* gcc.dg/builtin-bitreverse-4.c: New test.

Reviewed-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
5 weeks agoAdd __builtin_bitreverse128 [PR50481]
Jakub Jelinek [Sat, 16 May 2026 08:50:57 +0000 (10:50 +0200)] 
Add __builtin_bitreverse128 [PR50481]

We already have __builtin_bswap{16,32,64,128}, the last one has been
added ~6 years ago.  So, I think we should have also
__builtin_bitreverse128.

The following patch does that.

Note, we don't have __builtin_bswapg and I don't think we should, one can
only byteswap something which has number of bits divisible by CHAR_BIT.
For __builtin_bitreverseg that isn't a problem, but am not sure I want to
spend time handling it on say unsigned _BitInt(357).  Perhaps only if there
is some real-world use-case.

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

PR target/50481
* doc/extend.texi (__builtin_bitreverse32, __builtin_bitreverse64):
Tweak wording for consistency with __builtin_bswap*.
(__builtin_bitreverse128): Document.
* builtins.def (BUILT_IN_BITREVERSE128): New.
* builtins.cc (expand_builtin): Handle also BUILT_IN_BITREVERSE128.
(is_inexpensive_builtin): Likewise.
* fold-const-call.cc (fold_const_call_ss): Handle also
CFN_BUILT_IN_BITREVERSE128.
* fold-const.cc (tree_call_nonnegative_warnv_p): Likewise.
* tree-ssa-ccp.cc (evaluate_stmt): Handle also BUILT_IN_BITREVERSE128.
* tree-ssa-phiopt.cc (empty_bb_or_one_feeding_into_p): Handle also
CFN_BUILT_IN_BITREVERSE128.
(cond_removal_in_builtin_zero_pattern): Likewise.

* gcc.dg/builtin-bitreverse-1.c: Add __builtin_bitreverse128 tests.
* gcc.dg/builtin-bitreverse-2.c: Likewise.

Reviewed-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
5 weeks agotree-ssa-ccp: Fix up __builtin_bitreverse* handling [PR50481]
Jakub Jelinek [Sat, 16 May 2026 08:50:00 +0000 (10:50 +0200)] 
tree-ssa-ccp: Fix up __builtin_bitreverse* handling [PR50481]

The committed __builtin_bitreverse* patch mishandled the
bitwise CCP handling, it is true that BUILT_IN_BITREVERSE* can be
handled there similarly to BUILT_IN_BSWAP*, but not exactly, for
the latter we need (and do) bswap the value and mask constants,
while for the former we obviously need to bitreverse them instead.

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

PR target/50481
* tree-ssa-ccp.cc (evaluate_stmt): Fix up
BUILT_IN_BITREVERSE{8,16,32,64} handling.

* gcc.dg/builtin-bitreverse-3.c: New test.

Reviewed-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
5 weeks agox86_64: Handle hard registers in TImode STV with inter-unit moves.
Roger Sayle [Sat, 16 May 2026 07:44:06 +0000 (08:44 +0100)] 
x86_64: Handle hard registers in TImode STV with inter-unit moves.

This patch extends the types of chains that can be converted by x86's
TImode Scalar-To-Vector (STV) pass, to include chains that originate
and/or terminate with moves from/to hard registers.  Currently STV
candidate instructions explicitly exclude those than mention hard
registers.

As motivation, consider the four following functions:

__int128 a, b, c, z;
__int128 fun();

void foo_in(__int128 x) { z = (x ^ a ^ b ^ c); }

__int128 foo_out() { return (z ^ a ^ b ^ c); }

__int128 foo_inout(__int128 x) { return (x ^ a ^ b ^ c ^ z); }

void foo_fun() { z = (fun() ^ a ^ b ^ c); }

Of these, only the first, foo_in, is currently STV converted to use
SSE instructions.  Its incoming argument is constructed from a concat
of two DImode registers, and support for this idiom was added in a
previous STV patch.  The next two functions aren't converted because
the chain terminates with a return, which places the TImode result in
a hard register.  Likewise, the final foo_fun case isn't converted as
the result from fun initiates a chain from a hard register.

This patch supports STV conversion of TImode register-to-register
moves, where either the source or the destination (but not both) is
a hard register, by implementing it as a (relatively expensive)
inter-unit move.

Before, with -O2 -mavx:

foo_out:
        movq    z(%rip), %rax
        movq    z+8(%rip), %rdx
        xorq    a(%rip), %rax
        xorq    a+8(%rip), %rdx
        xorq    b(%rip), %rax
        xorq    b+8(%rip), %rdx
        xorq    c(%rip), %rax
        xorq    c+8(%rip), %rdx
        ret

After, with -O2 -mavx:

foo_out:
        vmovdqa z(%rip), %xmm0
        vpxor   a(%rip), %xmm0, %xmm0
        vpxor   b(%rip), %xmm0, %xmm0
        vpxor   c(%rip), %xmm0, %xmm0
        vpextrq $1, %xmm0, %rdx
        vmovq   %xmm0, %rax
        ret

Likewise for foo_fun, before with -O2 -mavx:

foo_fun:
        subq    $8, %rsp
        call    fun
        movq    a(%rip), %rsi
        movq    a+8(%rip), %rdi
        xorq    b(%rip), %rsi
        xorq    b+8(%rip), %rdi
        xorq    c(%rip), %rsi
        xorq    c+8(%rip), %rdi
        xorq    %rax, %rsi
        xorq    %rdx, %rdi
        movq    %rsi, z(%rip)
        movq    %rdi, z+8(%rip)
        addq    $8, %rsp
        ret

After with -O2 -mavx:

foo_fun:
        subq    $8, %rsp
        call    fun
        vmovdqa a(%rip), %xmm0
        vpxor   b(%rip), %xmm0, %xmm0
        vmovq   %rax, %xmm2
        vpxor   c(%rip), %xmm0, %xmm0
        vpinsrq $1, %rdx, %xmm2, %xmm1
        vpxor   %xmm1, %xmm0, %xmm0
        vmovdqa %xmm0, z(%rip)
        addq    $8, %rsp
        ret

The one small subtlety in this patch is in the cost calculation
for inter-unit moves, which now correctly uses both sse_to_integer
and integer_to_sse costs.  This patch models the transfer of double
word transfers between units as interunit_cost + COSTS_N_INSNS(1),
i.e. that the two transfers are pipelined in parallel, so that the
high latency is accounted for once [rather than 2*interunit_cost
that assumes the transfers take place strictly sequentially with
twice the single word transfer latency].

This revision implements Hongtao's suggestions/fixes to support
TImode values in non-general hard registers, and adds two more
test cases.  Alas things turned out to be a little more complicated
than originally proposed; previously STV used PUT_MODE on TImode
pseudo registers to change their mode everywhere, but something
different is required for hard registers, which may be used in
multiple modes in a function.

To demonstrate the (additional) benefits, consider the function:

register __int128 x __asm("xmm0");
register __int128 y __asm("xmm1");
__int128 m;

void foo()
{
  m = x ^ y;
}

Previously GCC on x86_64 with -O2 generated:

foo:    movaps  %xmm0, -24(%rsp)
        movq    -24(%rsp), %rax
        movq    -16(%rsp), %rdx
        movaps  %xmm1, -24(%rsp)
        xorq    -24(%rsp), %rax
        xorq    -16(%rsp), %rdx
        movq    %rax, m(%rip)
        movq    %rdx, m+8(%rip)
        ret

With this revised patch, we now generate:

foo: movdqa  %xmm0, %xmm2
        pxor    %xmm1, %xmm2
        movaps  %xmm2, m(%rip)
        ret

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

gcc/ChangeLog
* config/i386/i386-features.cc (scalar_chain): If the chain
starts with a register-to-register move from a hard register,
then the hard register's defs don't need to converted.
(timode_scalar_chain::compute_convert_gain): Provide costs
for hard_reg-to-pseudo and pseudo-to-hard_reg moves.
Tweak speed cost of timode_concatdi_p moves.
(timode_scalar_chain::convert_insn): Add support for
hard_reg-to-pseudo and pseudo-to-hard_reg TImode transfers.
(timode_scalar_to_vector_candidate_p): Likewise.

gcc/testsuite/ChangeLog
* gcc.target/i386/avx-stv-1.c: New test case.
* gcc.target/i386/sse2-stv-3.c: Likewise.
* gcc.target/i386/sse2-stv-4.c: Likewise.
* gcc.target/i386/sse2-stv-5.c: Likewise.

5 weeks agoRISC-V: Add test cases for scalar unsigned SAT form 10
Pan Li [Tue, 12 May 2026 14:28:06 +0000 (22:28 +0800)] 
RISC-V: Add test cases for scalar unsigned SAT form 10

Form 10 is supported already, add test to make sure of it.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat/sat_arith.h: Add form 10.
* gcc.target/riscv/sat/sat_u_mul-11-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-11-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-11-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-11-u8.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-11-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-11-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-11-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-11-u8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
5 weeks agoRISC-V: Add test cases for scalar unsigned SAT form 9
Pan Li [Tue, 12 May 2026 14:23:03 +0000 (22:23 +0800)] 
RISC-V: Add test cases for scalar unsigned SAT form 9

Form 9 is supported already, add test to make sure of it.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat/sat_arith.h: Add form 9.
* gcc.target/riscv/sat/sat_u_mul-10-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-10-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-10-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-10-u8.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-10-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-10-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-10-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-10-u8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
5 weeks agoRISC-V: Add test cases for scalar unsigned SAT form 8
Pan Li [Tue, 12 May 2026 13:28:32 +0000 (21:28 +0800)] 
RISC-V: Add test cases for scalar unsigned SAT form 8

Form 8 is supported already, add test to make sure of it.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat/sat_arith.h: Add form 8.
* gcc.target/riscv/sat/sat_u_mul-9-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-9-u16-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-9-u16-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-9-u16-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-9-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-9-u32-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-9-u32-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-9-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-9-u8-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-9-u8-from-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-9-u8-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-9-u8-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-9-u8-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-9-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-9-u16-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-9-u16-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-9-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-9-u32-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-9-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-9-u8-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-9-u8-from-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-9-u8-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-9-u8-from-u64.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
5 weeks agolibgfortran: Fix libcaf_shmem build on Solaris
Rainer Orth [Sat, 16 May 2026 07:07:00 +0000 (09:07 +0200)] 
libgfortran: Fix libcaf_shmem build on Solaris

libcaf_shmem doesn't currently build on Solaris.  Previously this went
unnoticed because the AX_PTHREADS autoconf macro erroneously didn't
detect pthreads support.  Once this is fixed, compilation fails:

In file included from caf/shmem/supervisor.h:35,
                 from caf/shmem/alloc.c:31:
caf/shmem/sync.h:46:25: error: conflicting types for ‘lock_t’; have ‘caf_shmem_mutex’ {aka ‘struct _pthread_mutex’}
   46 | typedef caf_shmem_mutex lock_t;
      |                         ^~~~~~
In file included from /usr/include/sys/machtypes.h:12,
                 from /usr/include/sys/types.h:17,
                 from caf/shmem/thread_support.h:33,
                 from caf/shmem/shared_memory.h:28,
                 from caf/shmem/allocator.h:31,
                 from caf/shmem/alloc.h:28,
                 from caf/shmem/alloc.c:29:
/usr/include/ia32/sys/machtypes.h:50:25: note: previous declaration of ‘lock_t’ with type ‘lock_t’ {aka ‘unsigned int’}

The lock_t definition in <ia32/sys/machtypes.h> is benign: POSIX.1
reserves the _t suffix for the implementation.  At the very least the
code should use a properly prefixed type instead, which this patch does
by changing the code to use caf_shmem_lock_t instead.

Bootstrapped without regressions on i386-pc-solaris2.11,
sparc-sun-solaris2.11, and x86_64-pc-linux-gnu.

2026-05-14  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libgfortran:
* caf/shmem/sync.h (lock_t): Rename to caf_shmem_lock_t.
* caf/shmem.c: Adapt uses.

5 weeks agolibstdc++: Remove Solaris workaround in 20_util/to_chars/float128_c++23.cc [PR107815]
Rainer Orth [Sat, 16 May 2026 07:01:42 +0000 (09:01 +0200)] 
libstdc++: Remove Solaris workaround in 20_util/to_chars/float128_c++23.cc [PR107815]

As described in PR libstdc++/107815, one subtest of
20_util/to_chars/float128_c++23.cc was disabled on Solaris due to a bug
in printf(3C).  This has been fixed since October 2023, so the
workaround can be removed.

Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11, and
x86_64-pc-linux-gnu.

2026-05-13  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libstdc++-v3:
PR libstdc++/107815
* testsuite/20_util/to_chars/float128_c++23.cc (test): Remove
Solaris workaround.

5 weeks agomatch.pd: Simplify ((~x) & y) ^ (x | y)
Shivam Gupta [Tue, 12 May 2026 17:47:05 +0000 (23:17 +0530)] 
match.pd: Simplify ((~x) & y) ^ (x | y)

This adds the simplification of:
  _1 = ~x_2(D);
  t1_4 = _1 & y_3(D);
  t2_5 = x_2(D) | y_3(D);
  _6 = t1_4 ^ t2_5;
  return _6;

to:
  return x_1(D);

also for ((~x) | y) ^ (x & y) version
  _1 = ~x_2(D);
  t1_4 = _1 | y_3(D);
  t2_5 = x_2(D) & y_3(D);
  _6 = t1_4 ^ t2_5;
  return _6;
to:
   int _1;
   _1 = ~x_2(D);
   return _1;

Bootstrapped and tested on aarch64-linux-gnu with
RUNTESTFLAGS="tree-ssa.exp".

changes since v1:
* v3: Change sf2/sg2 to sf/sg in test case
* v2:
- Update testcase to exercise GIMPLE folding
- Add additional type coverage
- Add vector and _Bool coverage
- Move code above in the file

PR tree-optimization/112095

gcc/ChangeLog:

* match.pd: Simplify ((~x) & y) ^ (x | y)
to x and ((~x) | y) ^ (x & y) to ~x.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Shivam Gupta <shivam98.tkg@gmail.com>
5 weeks agoaarch64: mingw: fix support for posix threading
Timo Rothenpieler [Fri, 15 May 2026 19:55:38 +0000 (21:55 +0200)] 
aarch64: mingw: fix support for posix threading

Currently without this --with-threads=pthread fails.

gcc/ChangeLog:

* config/i386/mingw-pthread.h:
rename to generic config/mingw/mingw-pthread.h
* config.gcc [aarch64-*-mingw*]:
Fix support for posix threading on aarch64 mingw targets.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
5 weeks agoDaily bump.
GCC Administrator [Sat, 16 May 2026 00:16:26 +0000 (00:16 +0000)] 
Daily bump.

5 weeks agoConfigure EditorConfig for Git commit messages
Karl Meakin [Thu, 26 Mar 2026 16:50:36 +0000 (16:50 +0000)] 
Configure EditorConfig for Git commit messages

Add a section for Git commit messages to the `.editorconfig` file, so
that editors with EditorConfig support will automatically format commit
messages according to the GNU style.

ChangeLog:

* .editorconfig (COMMIT_EDITMSG): New section.

5 weeks agossa_operands: speed up GIMPLE_SWITCH handling
Andrew Pinski [Fri, 15 May 2026 08:12:15 +0000 (01:12 -0700)] 
ssa_operands: speed up GIMPLE_SWITCH handling

The operands of a GIMPLE_SWITCH is index, followed by the cases.
The cases are all CASE_LABEL_EXPR which are skipped via operands_scanner::get_expr_operands
anyways so we only need to scan the index operand.
This also the first step in changing GIMPLE_SWITCH slightly.

gcc/ChangeLog:

* tree-ssa-operands.cc (operands_scanner::parse_ssa_operands):
Process index of the gswitch only.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
5 weeks agotestsuite: fix Wuninitialized-pr107919-1.C
Marek Polacek [Fri, 15 May 2026 22:39:52 +0000 (18:39 -0400)] 
testsuite: fix Wuninitialized-pr107919-1.C

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wuninitialized-pr107919-1.C: Fix a dg-bogus.

5 weeks agotree-cfg: Revert part of r8-546 [PR125290]
Andrew Pinski [Thu, 14 May 2026 04:24:43 +0000 (21:24 -0700)] 
tree-cfg: Revert part of r8-546 [PR125290]

This reverts the group_case_labels_stmt part of r8-546-gca4d2851687875.
This is placed in the wrong location to remove the case statements that go
directly to __builtin_unreachable. In fact the removal of the case statements
make us lose optimizations in some cases (Wuninitialized-pr107919-1.C for one).

Also this fixes PR 125290 by no longer leaving around a switch which just
has a default case.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/125290

gcc/ChangeLog:

* tree-cfg.cc (group_case_labels_stmt): Remove code that was
added to remove `cases` that goto blocks of unreachable.
* tree-ssa-forwprop.cc (optimize_unreachable): Remove the
comment about switch cases being handled.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wuninitialized-pr107919-1.C: Remove xfail.
* gcc.dg/analyzer/taint-assert.c: Update for the non-removal
of block containing unreachable.
* gcc.dg/torture/pr125290-1.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
5 weeks agolibstdc++: Include range_access.h from <optional> and <stacktrace>
Tomasz Kamiński [Thu, 14 May 2026 12:47:03 +0000 (14:47 +0200)] 
libstdc++: Include range_access.h from <optional> and <stacktrace>

This implements resolutions for LWG4131 and LWG3625 (also part of 4.8. section
of the P3016R6). As for any other issues LWG issue changes are applied as DR
for the oldest applicable standards:
* <optional> (LWG4131): C++26, since optional range support
* <stacktrace> (LWG3625): C++23, since introduction

libstdc++-v3/ChangeLog:

* include/std/optional [__cpp_lib_optional_range_support]:
Replace <bits/stl_iterator.h> include with <bits/range_access.h>.
* include/std/stacktrace: Likewise.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 weeks agopr124532: Reset musttail attribute in compound statements
Andi Kleen [Thu, 14 May 2026 21:37:01 +0000 (14:37 -0700)] 
pr124532: Reset musttail attribute in compound statements

A compound statement didn't reset the musttail state after the statement
with the attribute, which led to bogus errors later. Always reset it.

PR c/124532

gcc/c/ChangeLog:

* c-parser.cc (struct attr_state): Add reset method.
(c_parser_compound_statement_nostart): Rename a to astate.
Reset state before iterating statements.

gcc/testsuite/ChangeLog:

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

5 weeks agohppa64: Use DW_EH_PE_aligned encoding on 64-bit HP-UX
John David Anglin [Fri, 15 May 2026 15:31:06 +0000 (11:31 -0400)] 
hppa64: Use DW_EH_PE_aligned encoding on 64-bit HP-UX

In testing with GNU ld, I noticed that the HP-UX dynamic linker
doesn't support unaligned DW_EH_PE_absptr encodings.

2026-05-15  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

* config/pa/pa.h (ASM_PREFERRED_EH_DATA_FORMAT): Use
DW_EH_PE_aligned encoding on 64-bit HP-UX.

5 weeks agotestsuite: Add aarch64 SVE support to slp-reduc-15.c
Lili Cui [Fri, 15 May 2026 13:33:25 +0000 (21:33 +0800)] 
testsuite: Add aarch64 SVE support to slp-reduc-15.c

Add aarch64 SVE support and use -mavx2 for x86 to support all x86
modes.

Changes:
- Add aarch64-*-* target with -march=armv8.2-a+sve
- Use -mavx2 instead of -march=x86-64-v3 to support all x86 modes
- Separate -fgimple from architecture-specific options.

Reported-by: https://linaro.atlassian.net/browse/GNU-1901
gcc/testsuite/ChangeLog:

* gcc.dg/vect/slp-reduc-15.c: Add aarch64 support and use
-mavx2 for x86.

5 weeks agocaller_save_regs: Return the enabled registers
H.J. Lu [Fri, 15 May 2026 00:01:56 +0000 (08:01 +0800)] 
caller_save_regs: Return the enabled registers

Since the caller can save a register only if the register is enabled in
the caller, change caller_save_regs to return the enabled registers.

PR rtl-optimization/125321
* function-abi.cc (function_abi_aggregator::caller_save_regs):
Return the enabled registers.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
5 weeks agolibstdc++: Use IANA name for ISO-8859-1 in format tests.
Tomasz Kamiński [Fri, 15 May 2026 09:53:51 +0000 (11:53 +0200)] 
libstdc++: Use IANA name for ISO-8859-1 in format tests.

Use IANA name for ISO-8859-1 as "-fexec-charset=" and add dg-require-iconv,
to make sure it is supported.

libstdc++-v3/ChangeLog:

* testsuite/std/format/debug_nonunicode.cc: Pass ISO-8859-1 as
exec-charset and make sure that it is supported.
* testsuite/std/format/fill_nonunicode.cc: Likewise.

5 weeks agoscev: Sign extend step in peeled converted IV handling [PR 125291]
Xi Ruoyao [Tue, 12 May 2026 16:22:15 +0000 (00:22 +0800)] 
scev: Sign extend step in peeled converted IV handling [PR 125291]

For 3 iterations of

    unsigned char flagbits;
    _877 = flagbits_832 + 254;
    _879 = (int) _877;
    # prephitmp_880 = PHI <_879(40), 6(41)>
    _70 = _68 >> prephitmp_880;

The peeled converted IV handling added in r16-3562 incorrectly analyzes
it as [6, 6 + 254, 6 + 254 * 2] instead of [6, 4, 2].  Then VRP uses the
intersect of {6, 560, 514} and {2, 4, 6}, i.e. {6} as the possible value
range, and propagates the constant 6 for _70.

Extend the step (for example, 254 => -2) to fix the issue.

PR tree-optimization/125291

gcc/

* tree-scalar-evolution.cc (simplify_peeled_chrec): Sign-extend
the step for peeled converted IV.

gcc/testsuite/

* gcc.c-torture/execute/pr125291.c: New test.

5 weeks agoLoongArch: add spaceship expanders
Xi Ruoyao [Sat, 2 May 2026 14:51:10 +0000 (22:51 +0800)] 
LoongArch: add spaceship expanders

This helps to optimize certain nested ternary operation producing -1, 0,
or 1 to slt[u]-slt[u]-sub.

gcc/

* config/loongarch/loongarch.md (spaceship<mode>4): New
define_expand.

gcc/testsuite/

* gcc.target/loongarch/la64/spaceship.c: New test.

5 weeks agomatch.pd: Allow FNMA fold through conversions
Abhishek Kaushik [Thu, 14 May 2026 11:10:35 +0000 (11:10 +0000)] 
match.pd: Allow FNMA fold through conversions

The FMA folds in match.pd currently only matches (negate @0) directly.
When the negated operand is wrapped in a type conversion
(e.g. (convert (negate @0))), the simplification to IFN_FNMA does not
trigger.

This prevents folding of patterns such as:

*c = *c - (v8u)(*a * *b);

when the multiply operands undergo vector type conversions before being
passed to FMA. In such cases the expression lowers to neg + mla/mad
instead of the more optimal msb/mls on AArch64 SVE, because the current
fold cannot see through the casts.

Extend the match pattern to allow conversions on the negated
operand and the second multiplicand:

(fmas:c (nop_convert (negate @0)) @1 @2)

The fold rewrites the expression as:

convert (IFN_FNMA (convert:ut @0) (convert:ut @1) (convert:ut @2))

The match is restricted to nop_convert on the negated operand to avoid
folding through value-changing conversions. This enables recognition of
the subtraction-of-product form even when vector element type casts are
present.

The fold is only performed when signed overflow is unobservable for
both the outer FMA operation and the inner negation. This avoids
changing sanitized overflow behaviour when looking through the nop
conversion on the negated operand.

With this change, AArch64 SVE code generation is able to select msb/mls
instead of emitting a separate neg followed by mla/mad.

This patch was bootstrapped and regression tested on aarch64-linux-gnu.

PR target/123924
gcc/
* match.pd: Allow conversions in FMA-to-FNMA fold.

gcc/testsuite/
* gcc.target/aarch64/sve/fnma_match.c: New test.
* gcc.target/aarch64/sve/pr123897.c:
Update the test to scan for FNMA in the tree dump.

5 weeks agoAdd vector_costs::add_slp_cost grouping hook
Richard Biener [Wed, 6 May 2026 08:39:18 +0000 (10:39 +0200)] 
Add vector_costs::add_slp_cost grouping hook

The following simplifies the earlier RFC for making it easier
for the target to correlate multiple cost events created from
a single SLP operation.  Instead of changing where we record
costs this patch only adjusts the submission part.

Targets wanting to take advantage of this can implement
add_slp_cost and handle all or select cases and resort
to the default implementation to get add_stmt_cost events
for unhandled groups.

* tree-vectorizer.h (vector_costs::add_slp_cost): New.
* tree-vectorizer.cc (vector_costs::add_slp_cost): New
default version.
* tree-vect-slp.cc (add_slp_costs): Helper for dispatching
a cost vector in SLP chunks.
(vect_slp_analyze_operations): Adjust.
(li_cost_vec_cmp): Likewise.
(vect_bb_vectorization_profitable_p): Likewise.

5 weeks agotree-optimization/125296 - preserve alignment of access with address forwarding
Richard Biener [Wed, 13 May 2026 12:59:31 +0000 (14:59 +0200)] 
tree-optimization/125296 - preserve alignment of access with address forwarding

The following makes sure to preserve the alignment of the access
and not pick up that of parts of the address we forward.

PR tree-optimization/125296
* tree-ssa-forwprop.cc (forward_propagate_addr_expr_1):
Preserve alignment of the original access.

* gcc.dg/pr125206.c: New testcase.

5 weeks agoi386: Fix up *minmax<mode>3_4 [PR125308]
Jakub Jelinek [Fri, 15 May 2026 07:55:40 +0000 (09:55 +0200)] 
i386: Fix up *minmax<mode>3_4 [PR125308]

IEEE min/max are not commutative and in the pattern
(define_insn "ieee_<ieee_maxmin><mode>3<mask_name><round_saeonly_name>"
  [(set (match_operand:VFH 0 "register_operand" "=x,v")
        (unspec:VFH
          [(match_operand:VFH 1 "register_operand" "0,v")
           (match_operand:VFH 2 "<round_saeonly_nimm_predicate>" "xBm,<round_saeonly_constraint>")]
          IEEE_MAXMIN))]
the first operand is a register and only the second one is register/memory.
Now, the *minmax<mode>3_3 define_insn_and_split does
   rtx tmp = force_reg (<MODE>mode, operands[3]);
   rtvec v = gen_rtvec (2, tmp, operands[2]);
   operands[5] = gen_rtx_UNSPEC (<MODE>mode, v, u);
where operands[3] is the const0_operand, so operands[2] can there be
a memory, but in the *minmax<mode>3_4 case
   rtx tmp = force_reg (<MODE>mode, operands[3]);
   rtvec v = gen_rtvec (2, operands[2], tmp);
   operands[5] = gen_rtx_UNSPEC (<MODE>mode, v, u);
operands[2] goes into the operand which must be a REG, so it
is incorrect to split it into something that won't work.
Now, I've tried both disabling the define_insn_and_split and
the following patch, the former to the latter results in
        movaps  a, %xmm0
        pxor    %xmm1, %xmm1
-       cmpltps %xmm0, %xmm1
-       andps   %xmm1, %xmm0
+       maxps   %xmm1, %xmm0
        movaps  %xmm0, a
        ret
on the testcase, so I think it is better to match it and force_reg
(it is a pre-reload splitter) than change "nonimmediate_operand"
to "register_operand" because it won't match in that case.

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

PR target/125308
* config/i386/sse.md (*minmax<mode>3_4): Force also
operands[2] into a REG.

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

5 weeks agoAdd __builtin_bitreverse{8,16,32,64} builtins [PR50481]
Jakub Jelinek [Fri, 15 May 2026 07:50:52 +0000 (09:50 +0200)] 
Add __builtin_bitreverse{8,16,32,64} builtins [PR50481]

Future work could optimize this on specific targets:
- ARM: lower to RBIT
- x86 with GFNI: lower to vgf2p8affineqb
  https://wunkolo.github.io/post/2020/11/gf2p8affineqb-bit-reversal/

2026-05-15  Disservin  <disservin.social@gmail.com>
    Jakub Jelinek  <jakub@redhat.com>

PR target/50481
* builtin-types.def (BT_FN_UINT8_UINT8): New.
* builtins.def (BUILT_IN_BITREVERSE8, BUILT_IN_BITREVERSE16,
BUILT_IN_BITREVERSE32, BUILT_IN_BITREVERSE64): New builtins.
* builtins.cc (expand_builtin, is_inexpensive_builtin): Handle
bitreverse builtins.
* fold-const-call.cc (fold_const_call_ss): Fold bitreverse builtins.
* fold-const.cc (tree_call_nonnegative_warnv_p): Handle
bitreverse builtins.
* optabs.def (bitreverse_optab): New.
* optabs.cc (expand_bitreverse): New function.
(expand_unop): Use it for bitreverse_optab.
* tree-ssa-ccp.cc (evaluate_stmt): Handle bitreverse builtins.
* tree-ssa-phiopt.cc (empty_bb_or_one_feeding_into_p,
cond_removal_in_builtin_zero_pattern): Likewise.
* doc/extend.texi: Document __builtin_bitreverse{8,16,32,64}.
* doc/md.texi (bitreverse<mode>2): Document.

* gcc.dg/builtin-bitreverse-1.c: New test.
* gcc.dg/builtin-bitreverse-2.c: New test.

Signed-off-by: Disservin <disservin.social@gmail.com>
5 weeks agotestsuite: Add testcase for consteval-only type [PR125179]
Jakub Jelinek [Fri, 15 May 2026 06:54:42 +0000 (08:54 +0200)] 
testsuite: Add testcase for consteval-only type [PR125179]

The following testcase tests that the consteval-only computation is not
quadratic.  With a loop of 50000 types, I believe this would be O(50000^2)
in the earlier implementation and so would timeout.

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

PR c++/125179
* g++.dg/reflect/pr125179.C: New test.

5 weeks agoc, c++: Introduce -Wconstant-logical-operand warning [PR125081]
Jakub Jelinek [Fri, 15 May 2026 06:40:34 +0000 (08:40 +0200)] 
c, c++: Introduce -Wconstant-logical-operand warning [PR125081]

Given the recent (data->flags && ff_genericize) vs.
(data->flags & ff_genericize) typo, I've looked at warning in similar
cases.
We don't warn for cases like that at all, clang/clang++ has
-Wconstant-logical-operand warning enabled by default.
Their behavior is:
1) only warns for rhs of &&/|| (why?)
2) don't warn if rhs is bool
3) for C++ warn if rhs is constant or folds into constant,
   for C warn if rhs is constant or folds into constant and
   that constant is not 0 or 1
4) I think it doesn't warn if rhs comes from a macro
The following patch implements similar warning with similar wording,
just provides the value of the constant, but
1) warns for lhs and rhs
2) doesn't warn if either lhs or rhs is bool
3) doesn't warn if lhs or rhs is or folds to constant 0 or 1
   (but does warn if it is constant 1 of enum type in an enum which
   has enumerator other than just 0/1 (i.e. poor man's boolean))
4) doesn't care if it comes from a macro or not
I think 64 && x is similarly suspicious to x && 64 and both
are likely to be meant 64 & x or x & 64.  I think having
&& 1 or && 0 is common even in C++, people don't always write
&& true or && false etc. and don't see why C++ would be different
in that from C, I think people sometimes write
 if (1
 #ifdef ABC
     && ABC
 #endif
 #ifdef DEF
     && DEF
 #endif
     && 1)
and similar (or similarly with 0/true/false or ||).  And the warning
is only enabled in -Wall, not by default.

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

PR c++/125081
gcc/
* doc/invoke.texi (Wconstant-logical-operand): Document.
gcc/c-family/
* c.opt (Wconstant-logical-operand): New option.
* c.opt.urls: Regenerate.
gcc/c/
* c-tree.h (parser_build_binary_op): Add ORIG_ARG1 argument.
* c-typeck.cc (parser_build_binary_op): Likewise.  Emit
-Wconstant-logical-operand warnings.
* c-parser.cc (c_parser_binary_expression): Adjust
parser_build_binary_op caller, pass to it the original
stack[sp - 1].expr.value before c_objc_common_truthvalue_conversion.
gcc/cp/
* typeck.cc (cp_build_binary_op): Emit -Wconstant-logical-operand
warnings.
gcc/testsuite/
* c-c++-common/Wconstant-logical-operand-1.c: New test.
* c-c++-common/Wconstant-logical-operand-2.c: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
Reviewed-by: "Joseph S. Myers" <josmyers@redhat.com>
5 weeks agoc++: constexpr nested empty objects [PR125315]
Jason Merrill [Fri, 15 May 2026 02:24:09 +0000 (22:24 -0400)] 
c++: constexpr nested empty objects [PR125315]

Here we have one empty subobject inside another; we didn't create a
CONSTRUCTOR for the outer one, so we don't have it as context for the inner.

PR c++/125315

gcc/cp/ChangeLog:

* constexpr.cc (init_subob_ctx): Allow both ctor and object
to be null for an empty subobject.

gcc/testsuite/ChangeLog:

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

5 weeks agoDaily bump.
GCC Administrator [Fri, 15 May 2026 00:16:23 +0000 (00:16 +0000)] 
Daily bump.

5 weeks agotestsuite: Remove debugging puts from check_profiling_available
Uros Bizjak [Thu, 14 May 2026 20:55:13 +0000 (22:55 +0200)] 
testsuite: Remove debugging puts from check_profiling_available

Remove a stray debugging puts and an unused global declaration from
check_profiling_available. Neither affects the AutoFDO availability
check, as the wrapper path is already computed by profopt-perf-wrapper.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_profiling_available): Remove
unused global declaration and debugging output.

5 weeks agoc++/reflection: undeduced auto, deferred noexcept [PR124628]
Patrick Palka [Thu, 14 May 2026 18:53:06 +0000 (14:53 -0400)] 
c++/reflection: undeduced auto, deferred noexcept [PR124628]

Various reflection queries reject functions (or variables) with an
undeduced return type.  But this assumes return type deduction has
already been attempted which is not the case if the function is a
specialization that has not yet been ODR-used or otherwise instantiated,
which we must do now.  Similarly a function can also have an deferred
noexcept-specification which we should also instantiate at this point.

Rather an inventing a new way to resolve the type of such a function
or variable for reflection purposes, I think we can just silently call
mark_used in an unevaluated context, which will behave similarly to
requires { &decl; }.  Since diagnostics (in the immediate context) get
suppressed, we'll gracefully handle deleted functions or those with
unsatisfied constraints, leaving it up to the caller to handle them.

PR c++/124628

gcc/cp/ChangeLog:

* reflect.cc (resolve_type_of_reflected_decl): New.
(get_reflection): Call resolve_type_of_reflected_decl instead
of mark_used.
(has_type): Call resolve_type_of_reflected_decl before
checking for an undeduced auto.
(eval_can_substitute): Likewise.  Also look through BASELINK.
(members_of_representable): Call resolve_type_of_reflected_decl
before checking for an undeduced auto.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/can_substitute2.C: New test.
* g++.dg/reflect/members_of14.C: New test.
* g++.dg/reflect/substitute3.C: Adjust test so that f<int>'s
return type fails to get deduced.
* g++.dg/reflect/type_of3.C: Also test type_of of a templated
member function with deduced return type.

Reviewed-by: Jason Merrill <jason@redhat.com>
Reviewed-by: Marek Polacek <polacek@redhat.com>
5 weeks agoPR124316: Fix ptwrite assembler mode
Andi Kleen [Wed, 13 May 2026 23:40:16 +0000 (16:40 -0700)] 
PR124316: Fix ptwrite assembler mode

Add explicit assembler mode for cases when the argument is not
unambigious. This avoids cases where a user specified 64bit ptwrite
ends up being 32bit due to an ambigious argument.

PR target/124316

gcc/ChangeLog:

* config/i386/i386.md (ptwrite): Add explicit mode to
instruction.

gcc/testsuite/ChangeLog:

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

5 weeks agoOpenMP: mapper [C/C++] reject w/o map usage, reject C++98, fix map decay
Tobias Burnus [Thu, 14 May 2026 16:23:57 +0000 (18:23 +0200)] 
OpenMP: mapper [C/C++] reject w/o map usage, reject C++98, fix map decay

This commit adds a check for the following 'declare mapper restriction:
"At least one map clause that maps var or at least one element of var is
 required."

It additionally fixes a bug in the map-decay code, which did not handle
map modifiers like 'always' when specified in the declare mapper's map
clause.

For C++, some checks are now also run when templates are involved.
Additionally, it turned out that the internal use of constexpr caused
bogus errors when compiled with -std=c++98; therefore, a sorry is now
shown. Solution is to use -std=c++11 or higher.

gcc/c-family/ChangeLog:

* c-omp.cc (omp_map_decayed_kind): Handle map modifiers
also for declare-mapper's map clauses.

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_declare_mapper): Check that the
struct var is actually used by at least one map clause.

gcc/cp/ChangeLog:

* semantics.cc (cp_check_omp_declare_mapper): Change what
argument is expected; check that the struct var is used by at
least one map war. Print sorry when compiling with -std=c++98.
* pt.cc (tsubst_stmt, tsubst_expr): Call it.
* parser.cc (cp_parser_omp_declare_mapper): Update call.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/declare-mapper-10.c: Exclude C++98.
* c-c++-common/gomp/declare-mapper-15.c: Likewise.
* c-c++-common/gomp/declare-mapper-16.c: Likewise.
* c-c++-common/gomp/declare-mapper-3.c: Likewise.
* c-c++-common/gomp/declare-mapper-4.c: Likewise.
* c-c++-common/gomp/declare-mapper-5.c: Likewise.
* c-c++-common/gomp/declare-mapper-6.c: Likewise.
* c-c++-common/gomp/declare-mapper-7.c: Likewise.
* c-c++-common/gomp/declare-mapper-8.c: Likewise.
* c-c++-common/gomp/declare-mapper-9.c: Likewise.
* g++.dg/gomp/declare-mapper-1.C: Likewise.
* g++.dg/gomp/declare-mapper-2.C: Likewise.
* c-c++-common/gomp/pr122866.c: Expect sorry with C++98.
* c-c++-common/gomp/declare-mapper-11.c: Likewise.
Add dg-error for missing var-in-map-clause use.
* g++.dg/gomp/declare-mapper-3.C: Likewise.
* c-c++-common/gomp/declare-mapper-17.c: New test.
* c-c++-common/gomp/declare-mapper-18.c: New test.
* g++.dg/gomp/declare-mapper-4.C: New test.
* g++.dg/gomp/declare-mapper-5.C: New test.

5 weeks agoPR fortran/125092 - implement for binding label argument mismatch.
Thomas Koenig [Thu, 14 May 2026 14:59:11 +0000 (16:59 +0200)] 
PR fortran/125092 - implement for binding label argument mismatch.

This patch implements some checks on different interfaces to the same
C binding functions. It contains a few policy changes, and is somewhat
more permissive than the standard, but there are no constraint
violations (to my knowledge) that it misses.

Apart from checking for standards conformance, this should also
help proof code against (now or future) type-based aliasing mishaps.

Checks for global identifiers are performed on a case-insensitive
basis by default, and only sensitive when -pedantic is in force.
This makes sense if Fortran code wants to interface to "FOO" and
"foo".  The restriction to case-insensitive labels comes from a time
when relevant systems had linkers which were case-insensitive, and
it is not possible to implement C (especially the C versions referenced
in the standard) with such a linker.

Return types of functions, ranks, number, type and rank of arguments
are checked. In non-pedantic mode, arguments which have the same
prototype on the C side are permitted, for example passing a scalar
or an array by reference, or arrays of different rank (both for pass
by reference and pass by descriptors). Assumed types are also
assumed to bee OK. This functionality was checked in a few test
cases, so it would make little sense to remove it.

C_PTR is *not* compatible with a random argument passed by reference.
For example, a TYPE(C_PTR), VALUE argument is not compatible
with an INTEGER argument (without VALUE); C_LOC has to be used.

The one-liner in decl.cc may fix some ENTRY problems, I didn't check.

gcc/fortran/ChangeLog:

PR fortran/125092
* decl.cc (add_global_entry): Use string from the heap instead
of a pointer to stack-allocated memory.
* frontend-passes.cc (check_against_globals): If there is an error
already, return early.
* gfortran.h (gfc_symbol_rank): New prototype.
* interface.cc (symbol_rank): Rename to
(gfc_symbol_rank): this.
(gfc_check_dummy_characteristics): Use new function name.
(gfc_check_result_characteristics): Likewise.
(gfc_compare_interfaces): Likewise.
(compare_parameter): Likewise.
(get_sym_storage_size): Likewise.
(gfc_procedure_use): Likewise.
* resolve.cc (decays_to_pointer): New function.
(c_types_conform): New function.
(compare_c_binding_arglists): New function.
(gfc_verify_binding_labels): Check return types and rank
plus argument lists if there is a pre-exisiting global
symbol.

gcc/testsuite/ChangeLog:

PR fortran/125092
* gfortran.dg/PR100906.f90: Add -Wno-pedantic to options.
* gfortran.dg/PR100911.f90: Likewise.
* gfortran.dg/PR100915.f90: Likewise.
* gfortran.dg/PR94327.f90: Likewise.
* gfortran.dg/PR94331.f90: Likewise.
* gfortran.dg/bind_c_procs_4.f90: Add error messages, remove
warning.
* gfortran.dg/binding_label_tests_25.f90: Add error messages.
* gfortran.dg/binding_label_tests_3.f03: Add error messages.
* gfortran.dg/binding_label_tests_34.f90: Add -Wno-pedantic to
options.
* gfortran.dg/c_char_tests_4.f90: Likewise.
* gfortran.dg/c_char_tests_5.f90: Likewise.
* gfortran.dg/binding_label_tests_36.f90: New test.
* gfortran.dg/binding_label_tests_37.f90: New test.

5 weeks agoLoongArch: Improve xor+xor+ior sequence when possible [PR 96692]
Xi Ruoyao [Fri, 1 May 2026 19:58:04 +0000 (03:58 +0800)] 
LoongArch: Improve xor+xor+ior sequence when possible [PR 96692]

Copy the a ^ b ^ (a | c) => (c & ~a) ^ b optimization from RISC-V zbb
(r17-241) as we have the andn instruction in LA64 and LA32S.

PR rtl-optimization/96692

gcc/

* config/loongarch/loongarch.md (define_split): New splitters
turning a ^ b ^ (a | c) => (c &~ a) ^ b.

gcc/testsuite/

* gcc.target/loongarch/pr96692.c: New test.

5 weeks agolibstdc++: Merge __type_identity and type_identity for C+20.
Tomasz Kamiński [Thu, 14 May 2026 10:48:19 +0000 (12:48 +0200)] 
libstdc++: Merge __type_identity and type_identity for C+20.

The components that used __type_identity in C++20 mode (due source
compatibility with older standard) lead to instantiation of separate
class template from std::type_identity for each used type. This
patch makes __type_identity an alias to type_identity if the latter is
available.

libstdc++-v3/ChangeLog:

* include/std/type_traits (__type_identity, __type_identity_t)
[__cpp_lib_type_identity]: Define as alias to type_identity
and its nested type respectively.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 weeks ago[RISC-V] Drop unused parameters to restore bootstrap
Jeff Law [Thu, 14 May 2026 13:19:52 +0000 (07:19 -0600)] 
[RISC-V] Drop unused parameters to restore bootstrap

Bootstraps on RISC-V recently started failing due to an unused parameter.  I've
only lightly tested this, but it should restore bootstrapping.  Pushing to the
trunk.

gcc/
* config/riscv/riscv-v.cc (expand_const_vector_stepped): Drop unused
SRC parameter. All callers changed.
(expand_const_vector_interleaved_stepped_npatterns): Likewise.
(expand_const_vector): Corresponding changes.

5 weeks agodoc: Fix description of GET_MODE_MASK
Alex Coplan [Tue, 12 May 2026 09:22:09 +0000 (10:22 +0100)] 
doc: Fix description of GET_MODE_MASK

This updates the description of GET_MODE_MASK in the GCC internals
manual.  Currently it says that the macro can only be used for modes
whose bitsize is less than or equal to HOST_BITS_PER_INT.  That may have
once been correct, but these days it seems to work for modes up to
HOST_BITS_PER_WIDE_INT in size.  The code in genmodes.cc:emit_mode_mask
seems to support this.  It has:

  print_maybe_const_decl ("%sunsigned HOST_WIDE_INT", "mode_mask_array",
                          "NUM_MACHINE_MODES", adj_nunits);
  puts ("\
  ((m) >= HOST_BITS_PER_WIDE_INT)             \\\n\
   ? HOST_WIDE_INT_M1U                        \\\n\
   : (HOST_WIDE_INT_1U << (m)) - 1\n");

gcc/ChangeLog:

* doc/rtl.texi (Machine Modes): Update description of
GET_MODE_MASK to use HOST_BITS_PER_WIDE_INT instead of
HOST_BITS_PER_INT as the upper limit of the input mode's bitsize.

5 weeks agolibstdc++: Fix reserve of size_t(-1) elements in piecewise_constant_distribution...
Tomasz Kamiński [Wed, 13 May 2026 15:05:05 +0000 (17:05 +0200)] 
libstdc++: Fix reserve of size_t(-1) elements in piecewise_constant_distribution. [PR113761]

The piecewise_constant_distribution constructor from std::initializer_list il,
unconditionally reserve _M_den for il.size()-1 elements. In case when the il.size()
was zero, this led to unsigned overflow, and attempt to allocate size_t(-1)
elements.

This patch addresses above, by refactoring the constructors of param_type for
both piecewise_constant_distribution and piecewise_linear_distribution, to
exit early (and do not populate internal vectors) if number of intervals range is
smaller than two. For the constructor accepting pair of iterators, this is done
by checking result of __detail::__load_first2, that extracts up to two elements,
and returns false, if less than two is found.

Furthermore, we if the number of intervals is equal to two (for iterator __bbegin
is at __bend after __load_first2), we store densities value on stack, and call
newly introduced an _M_initialize2 helper, that does not populate internal vector
if __ints and __dens values correspond to default configuration.

With both of above changes, we no longer populate _M_int and _M_den with default
values, and corresponding code that clears them in _M_initialize is not necessary.
This avoids any unnecessary memory allocators.

For constructor accepting two iterators, we reserve required space in _M_int vector,
if the iterators are forward (or model sized_sentinel in C++20). The _M_den
initialization is performed afterwards, so _M_int size is already determined
(even for input iterators) and it can be used for call to reserve.

Finally, the _M_initialize members are renamed to _M_configure, so the new
implementation that skips the check, is not used by TU compiler will other
that would invoke it with empty vector, and thus retrigger the issue.

PR libstdc++/113761

libstdc++-v3/ChangeLog:

* include/bits/random.h
(piecewise_constant_distribution::param_type::_M_initialize)
(piecewise_linear_distribution::param_type::_M_initialize): Remove.
(piecewise_constant_distribution::param_type::_M_configure)
(piecewise_linear_distribution::param_type::_M_configure): Define.
(piecewise_constant_distribution::param_type::_M_initialize2)
(piecewise_linear_distribution::param_type::_M_initialize2): Declare.
* include/bits/random.tcc (__detail::__load_first2): Define.
(piecewise_constant_distribution::param_type::_M_initialize)
(piecewise_linear_distribution::param_type::_M_initialize):
Rename to...
(piecewise_constant_distribution::param_type::_M_configure)
(piecewise_linear_distribution::param_type::_M_configure):
Renamed implementation of _M_initialize, that removes checks for
default values.
(piecewise_constant_distribution::param_type::_M_initialize2)
(piecewise_linear_distribution::param_type::_M_initialize2): Define.
(piecewise_constant_distribution::param_type::param_type)
(piecewise_linear_distribution::param_type::param_type):
Exit early for less that two intervals. Use _M_initialize2 to handle
two intervals case. Reserve _M_int for iterators case.
* testsuite/26_numerics/random/piecewise_constant_distribution/cons/range.cc:
Test input and forward iterators, in addition to random_access ones.
* testsuite/26_numerics/random/piecewise_linear_distribution/cons/range.cc:
Likewise.
* testsuite/26_numerics/random/piecewise_constant_distribution/cons/fallback.cc:
New test.
* testsuite/26_numerics/random/piecewise_linear_distribution/cons/fallback.cc:
New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 weeks agoOpenMP: Improve interface comment for the omp_deep_mapping lang hooks
Tobias Burnus [Thu, 14 May 2026 09:41:22 +0000 (11:41 +0200)] 
OpenMP: Improve interface comment for the omp_deep_mapping lang hooks

gcc/fortran/ChangeLog:

* trans-openmp.cc (gfc_omp_deep_mapping_p, gfc_omp_deep_mapping_cnt,
gfc_omp_deep_mapping): Improve interface comment.

gcc/ChangeLog:

* langhooks.cc (lhd_omp_deep_mapping_p, lhd_omp_deep_mapping_cnt,
lhd_omp_deep_mapping): Improve interface comment.
* langhooks.h (lhd_omp_deep_mapping_p, lhd_omp_deep_mapping_cnt,
lhd_omp_deep_mapping): Likewise

5 weeks agolibstdc++: Mark gencanon_eng_neg test as unsupported if __float128 is not available.
Tomasz Kamiński [Thu, 14 May 2026 07:46:14 +0000 (09:46 +0200)] 
libstdc++: Mark gencanon_eng_neg test as unsupported if __float128 is not available.

As DejaGnu reads all lines, the { dg-error } still expected error,
even if the code was removed by preprocessor checks.

libstdc++-v3/ChangeLog:

* testsuite/26_numerics/random/uniform_real_distribution/operators/gencanon_eng_neg.cc:
Removed preprocessor checks, add dg-require-effective-target.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 weeks agoAVR: target/125194 - Make -mno-call-main work with -flto.
Georg-Johann Lay [Thu, 14 May 2026 08:21:28 +0000 (10:21 +0200)] 
AVR: target/125194 - Make -mno-call-main work with -flto.

Instead of emitting  .global __call_main + __call_main=0  in some
module, it uses a %{mno-call-main: --defsym __call_main=0} spec.

The problem with the old implementation is that avr_no_call_main_p
was set by cc1[plus] (in avr_insert_attributes) but used by lto1
(in avr_file_end).  The new approach uses  --defsym __call_main=0
in order to avoid link fails due to multiple definitions of __call_main
in *.o and lib<mcu>.a.

PR target/125194
gcc/
* config/avr/avr.cc (avr_no_call_main_p): Remove variable...
(avr_file_end): ...and code that uses it.
(avr_insert_attributes): Same.  Add "used" to main attributes
when -mno-call-main.
* config/avr/gen-avr-mmcu-specs.cc (print_mcu): Emit code
for link_no_call_main specs.
* config/avr/specs.h (LINK_SPEC): Add %(link_no_call_main).

5 weeks agoDaily bump.
GCC Administrator [Thu, 14 May 2026 00:16:27 +0000 (00:16 +0000)] 
Daily bump.

5 weeks agolibstdc++: Remove trailing whitespace in shared_ptr_atomic.h
Jonathan Wakely [Wed, 13 May 2026 23:39:43 +0000 (00:39 +0100)] 
libstdc++: Remove trailing whitespace in shared_ptr_atomic.h

libstdc++-v3/ChangeLog:

* include/bits/shared_ptr_atomic.h: Remove trailing whitespace.

5 weeks agolibstdc++: Add call to test_format in std/time/clock/local/io.cc
Jonathan Wakely [Wed, 13 May 2026 19:48:42 +0000 (20:48 +0100)] 
libstdc++: Add call to test_format in std/time/clock/local/io.cc

This function was defined but not being called at runtime.

libstdc++-v3/ChangeLog:

* testsuite/std/time/clock/local/io.cc: Call test_format.

5 weeks agolibstdc++: Fix -Wsign-compare warning in new test
Jonathan Wakely [Tue, 12 May 2026 16:14:26 +0000 (17:14 +0100)] 
libstdc++: Fix -Wsign-compare warning in new test

libstdc++-v3/ChangeLog:

* testsuite/std/time/clock/utc/leap_second_info-2.cc: Fix sign
compare warning. Tweak comment.

5 weeks agolibstdc++: rebuild configure
Alexandre Oliva [Wed, 13 May 2026 15:50:34 +0000 (12:50 -0300)] 
libstdc++: rebuild configure

An earlier configury patch made originally in gcc-15, where no line
number changes came up during configure rebuild, needed an explicit
rebuild after porting to trunk.

for  libstdc++-v3/ChangeLog

* configure: Rebuild.

5 weeks agoRISC-V: Remove interleaved vector synthesis optimization [PR125215]
Zhongyao Chen [Fri, 8 May 2026 11:02:06 +0000 (19:02 +0800)] 
RISC-V: Remove interleaved vector synthesis optimization [PR125215]

This patch removes the "hi/lo" optimization path in interleaved
stepped constant vector synthesis. This optimization was found
to be not really better than the fallback merge version. Once the
overflow issue is fixed, the extra masking makes the code generation
"even worse". So remove it instead of fixing.

Obsolete tests slp-interleave-[1-5].c are also removed as they were
specifically designed to verify this now-removed path.

My local test shows no regression.

PR target/125215

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_const_vector_interleaved_stepped_npatterns):
Remove hi/lo optimization and always use the merge fallback.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr125215.c: New test.
* gcc.target/riscv/rvv/autovec/slp-interleave-1.c: Remove.
* gcc.target/riscv/rvv/autovec/slp-interleave-2.c: Remove.
* gcc.target/riscv/rvv/autovec/slp-interleave-3.c: Remove.
* gcc.target/riscv/rvv/autovec/slp-interleave-4.c: Remove.
* gcc.target/riscv/rvv/autovec/slp-interleave-5.c: Remove.

Signed-off-by: Zhongyao Chen <chen.zhongyao@zte.com.cn>
5 weeks agolibstdc++: Use type_identity_t for operator<=> parameter [PR114400]
Tomasz Kamiński [Wed, 13 May 2026 09:51:25 +0000 (11:51 +0200)] 
libstdc++: Use type_identity_t for operator<=> parameter [PR114400]

This matches change to operator== from r14-9642-gf4605c53ea2eeaf,
and implements exact resolution of LWG3950, "std::basic_string_view comparison
operators are overspecified". The difference between __type_identity and
type_identity is observable as illustrated by PR.

libstdc++-v3/ChangeLog:

PR libstdc++/114400
* include/std/string_view (operator<=>): Use type_identity_t
instead of __type_identity_t.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 weeks agoc++/reflection: overzealous complete_type in consteval_only_p [PR125280]
Marek Polacek [Tue, 12 May 2026 21:01:29 +0000 (17:01 -0400)] 
c++/reflection: overzealous complete_type in consteval_only_p [PR125280]

This bug report shows that we generate a bogus "has incomplete type"
error for Element::mData in type12.C with -freflection: consteval_only_p
attempts to complete Array when finishing mData, but mData uses Element
which is currently being defined, so we can't complete it yet.  We could
fix this bogus error by checking can_complete_type_without_circularity
before calling complete_type in consteval_only_p, but I'm no longer so
sure that we must call complete_type at all.  This patch removes that
call.  One consequence of that is that we don't produce the "outside
a constant-evaluated context" error for C::mData (only when mData is
defined outside the class as with A::mData above).  This behavior
matches clang++ though so I'm not too worried about it.

type13.C shows that even without the complete_type we can still get
to consteval_only_p_walker::walk with a member with erroneous type
which currently crashes.

PR c++/125280

gcc/cp/ChangeLog:

* reflect.cc (consteval_only_p): Don't complete_type.
(consteval_only_p_walker::walk): Return false for
error_mark_node.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/init19.C: New test.
* g++.dg/reflect/type12.C: New test.
* g++.dg/reflect/type13.C: New test.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
5 weeks agoMAINTAINERS: Add myself to write after approval and DCO.
Zhongyao Chen [Wed, 13 May 2026 02:05:38 +0000 (10:05 +0800)] 
MAINTAINERS: Add myself to write after approval and DCO.

ChangeLog:

* MAINTAINERS (Write After Approval): Add myself.
(Contributing under the DCO): Add myself.

Signed-off-by: Zhongyao Chen <chen.zhongyao@zte.com.cn>
5 weeks agolibstdc++: Test for unsupported engine range for 128bits floating points [PR119739]
Tomasz Kamiński [Wed, 13 May 2026 12:51:02 +0000 (14:51 +0200)] 
libstdc++: Test for unsupported engine range for 128bits floating points [PR119739]

This patch add test illustrating, that after implementing P0952 "A new specification for
std::generate_canonical",  generators, that emit range of non-power-of-two size, that
span over B bits, are not supported in combination with 128bits integer are not
support for B in ranges: [22, 23), [26, 29), [33, 38), [43, 57). This is because, the
lowest multiply of B that is larger of equal than 113 (size of mantisa of float128)
is greater than 128, and thus they will require 256 bits integers support.

This does not impact any generate defined in standard (see gencanon_eng.cc tests),
nor generate emitting power of 2 sized ranges.

PR libstdc++/119739

libstdc++-v3/ChangeLog:

* testsuite/26_numerics/random/uniform_real_distribution/operators/gencanon_eng_neg.cc:
New test.

Reviewed-by: Nathan Myers <nmyers@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 weeks agoscev: maintain affine CHRECs in the presence of type conversions
Tamar Christina [Wed, 13 May 2026 11:36:07 +0000 (12:36 +0100)] 
scev: maintain affine CHRECs in the presence of type conversions

The example

float *e;
void f (float *f, float *g, char *h, int n,
        int b, int c, int d)
{
  float a = 0;
  for (int i = 0; i < n; ++i) {
    int j = b + i, k = c + i * d;
    float l = g[j], m = h[i] ? g[k] : l;
    a += f[i] * m;
  }
  *e = a;
}

gets vectorized using gathers for the access to g:

.L5:
        ld1b    z4.s, p7/z, [x2, x6]
        cmpne   p6.b, p7/z, z4.b, #0
        ld1w    z2.s, p7/z, [x0, x6, lsl 2]
        add     z7.s, z30.s, z16.s
        add     z6.s, z16.s, z18.s
        add     x6, x6, x7
        ld1w    z5.s, p7/z, [x1, z6.s, sxtw 2]
        ld1w    z3.s, p6/z, [x1, z7.s, sxtw 2]
        incw    z16.s
        sel     z3.s, p6, z3.s, z5.s
        fmla    z17.s, p7/m, z2.s, z3.s
        whilelo p7.s, w6, w3
        b.any   .L5

however the first g is g[b+i] and second is g[c + i*d];

since b is loop invariant the access to g[b+i] is actually linear and since c
is loop invariant, then the base of the second access g[c + i *d] can be
simplified by recognizing the base as g + c.

Today however SCEV fails to analyze these accesses as affine and as a
consequence we end up with gathers:

: missed:  failed: evolution of base is not affine.
        base_address:
        offset from base address:
        constant offset from base address:
        step:
        base alignment: 0
        base misalignment: 0
        offset alignment: 0
        step alignment: 0
        base_object: *_63

Looking at SCEV this is because of an outer cast around the CHREC:

)
(set_scalar_evolution
  instantiated_below = 25
  (scalar = _65)
  (scalar_evolution = (long unsigned int) {b_22(D), +, 1}_2))
)
(instantiate_scev
  (instantiate_below = 25 -> 12)
  (evolution_loop = 2)
  (chrec = (long unsigned int) {b_22(D), +, 1}_2)

(instantiate_scev
  (instantiate_below = 25 -> 12)
  (evolution_loop = 2)
  (chrec = g_27(D))
  (res = g_27(D)))

  which corresponds to

  j_66 = b_22(D) + i_67;
  _65 = (long unsigned int) j_66;
  _64 = _65 * 4;
  _63 = g_27(D) + _64;
  l_62 = *_63;

and the _64 is deemed to not be affine:

(instantiate_scev
  (instantiate_below = 25 -> 12)
  (evolution_loop = 2)
  (chrec = _64)
(analyze_scalar_evolution
  (loop_nb = 2)
  (scalar = _64)
(get_scalar_evolution
  (scalar = _64)
  (scalar_evolution = _64))
)
  (res = scev_not_known))

This patch fixes it by (very carefully) folding a multiply on an unsigned affine
CHREC into the CHREC itself.

which results in

(instantiate_scev
  (instantiate_below = 25 -> 12)
  (evolution_loop = 2)
  (chrec = 4)
  (res = 4))
(set_scalar_evolution
  instantiated_below = 25
  (scalar = _64)
  (scalar_evolution = {(long unsigned int) b_22(D) * 4, +, 4}_2))
)
(instantiate_scev
  (instantiate_below = 25 -> 12)
  (evolution_loop = 2)
  (chrec = g_27(D))
  (res = g_27(D)))
(instantiate_scev
  (instantiate_below = 25 -> 12)
  (evolution_loop = 2)
  (chrec = {(long unsigned int) b_22(D) * 4, +, 4}_2)
  (res = {(long unsigned int) b_22(D) * 4, +, 4}_2))
(set_scalar_evolution
  instantiated_below = 25
  (scalar = _63)
  (scalar_evolution = {g_27(D) + (long unsigned int) b_22(D) * 4, +, 4}_2))
)

and dataref now correctly analyzes the base

        base_address: g_27(D) + (sizetype) b_22(D) * 4
        offset from base address: 0
        constant offset from base address: 0
        step: 4
        base alignment: 4
        base misalignment: 0
        offset alignment: 128
        step alignment: 4
        base_object: *g_27(D) + (sizetype) b_22(D) * 4
        Access function 0: {0B, +, 4}_2

producing the final codegen:

.L7:
        ld1b    z4.s, p7/z, [x2, x6]
        cmpne   p6.b, p7/z, z4.b, #0
        ld1w    z29.s, p7/z, [x4, x6, lsl 2]
        ld1w    z2.s, p7/z, [x0, x6, lsl 2]
        ld1w    z3.s, p6/z, [x5]
        add     x6, x6, x7
        sel     z3.s, p6, z3.s, z29.s
        add     x5, x5, x1
        fmla    z30.s, p7/m, z2.s, z3.s
        whilelo p7.s, w6, w3
        b.any   .L7
        faddv   s31, p5, z30.s

gcc/ChangeLog:

* tree-chrec.cc (chrec_convert_1): Fold unsigned CHREC converts.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/vect-scev-affine_1.c: New test.

5 weeks agox86: Shorter load immediate constants with -Oz
Roger Sayle [Wed, 13 May 2026 11:31:12 +0000 (12:31 +0100)] 
x86: Shorter load immediate constants with -Oz

This patch adds two peephole2 patterns to i386.md to decrease the size
of some integer loads.  These replace "movl $const, %eax" (5 bytes)
with "xorl %eax, %eax" followed by either "movb $const,%al" or
"movb $const,%ah" (together 4 bytes), for suitable constants and
suitable general registers, when the flags register is dead.

Ideally modern Intel and AMD prcoessors can recognize these sequences
during instruction decode (avoiding any partial register stall in
the same way they avoid the false dependence for the xorl), and
internally generate a single uop, treating these bytes like an
alternate instruction encoding.

2026-05-13  Roger Sayle  <roger@nextmovesoftware.com>
    Uros Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog
PR target/32803
* config/i386/i386.md (peephole2): Don't transform xorl;movb into
movzb with -Oz.
(peephole2): Convert movl into xorl;movb (strict_low_part) with -Oz.
(peephole2): Likewise, convert movl into xorl;movb [abcd]h with -Oz.

gcc/testsuite/ChangeLog
PR target/32803
* gcc.target/i386/pr32803-2.c: New test case.
* gcc.target/i386/pr32803-3.c: Likewise.

5 weeks agotestsuite: Skip new test case gcc.target/arm/muldi-1.c with -mthumb
Roger Sayle [Wed, 13 May 2026 11:23:41 +0000 (12:23 +0100)] 
testsuite: Skip new test case gcc.target/arm/muldi-1.c with -mthumb

The recent test to confirm PR middle-end/122871 is resolved on ARM,
wasn't expecting -mthumb.  This adds a requires-effective-target.
Committed as obvious.

2026-05-13  Roger Sayle  <roger@nextmovesoftware.com>
    Richard Earnshaw  <rearnsha@arm.com>

gcc/testsuite/ChangeLog
PR middle-end/122871
* gcc.target/arm/muldi-1.c: Skip test if compiled with -mthumb.

5 weeks agoRecord (de-)composition type in ls_type for VMAT_STRIDED_SLP accesses
Richard Biener [Wed, 13 May 2026 06:47:43 +0000 (08:47 +0200)] 
Record (de-)composition type in ls_type for VMAT_STRIDED_SLP accesses

The following arranges the vector (de-)composition type for VMAT_STRIDED_SLP
loads and stores to be available in the ls_type field of the load/store data
for target costing.

* tree-vect-stmts.cc (vectorizable_store): Record ls_type
for VMAT_STRIDED_SLP.
(vectorizable_load): Likewise.

5 weeks agoDelay setting of slp_node->data in vectorizable_{load,store}
Richard Biener [Tue, 12 May 2026 12:44:30 +0000 (14:44 +0200)] 
Delay setting of slp_node->data in vectorizable_{load,store}

We move 'ls' to slp_node->data early, inhibiting late adjustments
like setting of ls_type.  We also have failure cases after, which
we should not.  The following moves one such failure check earlier
and moves setting slp_node->data and SLP_TREE_TYPE
down, duplicating it to various "success" returns.

* tree-vect-stmts.cc (vectorizable_store): Set slp_node->data
and SLP_TREE_TYPE only on success.
(vectorizable_load): Likewise.  Move one validity check early.

5 weeks agors6000: Fix [su]mul<mode>3_highpart patterns to use RTL codes [PR122665]
Jeevitha [Wed, 13 May 2026 08:36:10 +0000 (03:36 -0500)] 
rs6000: Fix [su]mul<mode>3_highpart patterns to use RTL codes [PR122665]

The existing smul<mode>3_highpart and umul<mode>3_highpart patterns
incorrectly defined the high-part multiply by shifting both operands
right by 32 before multiplication. This does not match the semantics
of the instructions vmulhs<wd> and vmulhu<wd>, which perform a widened
multiplication and return the high part of the result.

This patch replaces the incorrect shift-based patterns with the proper
smul_highpart and umul_highpart RTL codes, and updates the operand
predicate from vsx_register_operand to altivec_register_operand, since
these instructions only accept Altivec registers.

2026-05-13  Jeevitha Palanisamy  <jeevitha@linux.ibm.com>

gcc/
PR target/122665
* config/rs6000/vsx.md (smul<mode>3_highpart, umul<mode>3_highpart):
Replace shift-based patterns with smul_highpart and umul_highpart RTL
codes and use altivec_register_operand.

5 weeks agoEnabling POPCNT generation for 32-bit patterns.
Reshma Roy [Thu, 11 Dec 2025 05:27:53 +0000 (10:57 +0530)] 
Enabling POPCNT generation for 32-bit patterns.

Enabling POPCNT generation for 32-bit pattern from Hacker's Delight

Pattern 1:
int Gia_WordCountOnes32c( uint32_t uword )
{
  uword = (uword & 0x55555555) + ((uword>>1) & 0x55555555);
  uword = (uword & 0x33333333) + ((uword>>2) & 0x33333333);
  uword = (uword & 0x0f0f0f0f) + ((uword>>4) & 0x0f0f0f0f);
  uword = (uword & 0x00ff00ff) + ((uword>>8) & 0x00ff00ff);
  return  (uword & 0x0000ffff) + (uword>>16);
  or
  return (uword & 0x0000FFFF) + ((uword >> 16) & 0x0000FFFF);
}

Pattern 2:
int pop(unsigned x) {
  x = x - ((x >> 1) & 0x55555555);
  x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  x = (x + (x >> 4)) & 0x0F0F0F0F;
  x = x + (x >> 8);
  x = x + (x >> 16);
  return x & 0x0000003F;
}

Pattern 3:
int pop(unsigned x) {
  x = x - ((x >> 1) & 0x55555555);
  x = x - 3*((x >> 2) & 0x33333333)
    x = (x + (x >> 4)) & 0x0F0F0F0F;
  x = x + (x >> 8);
  x = x + (x >> 16);
  return x & 0x0000003F;
}

gcc/ChangeLog:

* match.pd: Add new popcount pattern variants from Hacker's Delight.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/popcount7.c: New test.
* gcc.dg/tree-ssa/popcount7_2.c: New test.
* gcc.dg/tree-ssa/popcount8.c: New test.
* gcc.dg/tree-ssa/popcount9.c: New test.

5 weeks agolibgomp.texi: Add the missing closing brace
H.J. Lu [Wed, 13 May 2026 07:42:37 +0000 (15:42 +0800)] 
libgomp.texi: Add the missing closing brace

Fix GCC build error:

libgomp.texi:647: @code missing closing brace
make[4]: *** [Makefile:1434: stamp-build-info] Error 1

from

commit a94fc2737d4c3916cdab15e2f2e28f74b6c39e65
Author: Tobias Burnus <tburnus@baylibre.com>
Date:   Wed May 13 08:21:53 2026 +0200

    libgomp: Add stub omp_control_tool for OMPT

-@item New @code{omp_pause_stop_tool} constant for omp_pause_resource @tab N @tab
+@item New @code{omp_pause_stop_tool} constant for @code{omp_pause_resource
+      @tab Y @tab

* libgomp.texi: the Add missing closing brace.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
5 weeks agox86-64: Use R11 for DRAP register in preserve_none functions
H.J. Lu [Sun, 10 May 2026 10:36:26 +0000 (18:36 +0800)] 
x86-64: Use R11 for DRAP register in preserve_none functions

In 64-bit mode, for preserve_none functions, DRAP may use any register
except AX, R12–R15, DI, SI (argument registers), SP, and BP. Use R11.
In non-callee-saved functions, R10 and R13 are also available since they
are not used for parameter passing.  In 32-bit mode, preserve_none does
not affect parameter passing, so the current approach remains valid.

DRAP register is used to restore stack pointer in epilogue for stack
realignment.  Always save and restore DRAP register between prologue
and epilogue so that stack pointer can be restored.

Tested with CPython 3.14.4 on Linux/x86-64.

gcc/

PR target/120870
* config/i386/i386.cc (ix86_save_reg): Return true for DRAP
register early at entry.
(find_drap_reg): Use R11_REG in preserve_none functions in
64-bit mode.

gcc/testsuite/

PR target/120870
* gcc.target/i386/pr120870-1.c: New test.
* gcc.target/i386/pr120870-2.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Co-Authored-By: Uros Bizjak <ubizjak@gmail.com>
5 weeks agolibstdc++: Support ON-format DAY in Zone UNTIL field [PR124852]
Álvaro Begué [Tue, 12 May 2026 12:55:01 +0000 (14:55 +0200)] 
libstdc++: Support ON-format DAY in Zone UNTIL field [PR124852]

The Zone-line UNTIL parser only accepted a plain day-of-month integer
for the DAY field, while the tzdata.zi grammar accepts the same ON-style
forms as Rule lines: lastSun, Sun>=8, Sat<=20, etc. Real zones use these
forms in their UNTIL DAY: Europe/Simferopol's `3 - MSK 1997 Mar lastSu
1u`, for instance, became `Mar 1` (silently misparsed) instead of `Mar
30`, leaving Simferopol an extra 29 days in MSK.

The previous parser's `int d = 1; in >> m >> d >> t;` chain silently
left d == 1 when the day token wasn't a digit, then went on to parse the
remainder as the TIME field.

Renames on_day to on_month_day, and factor out the day-component parser
parser from operator>>(istream&, on_day&) as operator>> for newly added
on_day_t tag type, and reuse it for the UNTIL DAY field. The operator
handles all three on_day forms (DayOfMonth, LastWeekday, LessEq /
GreaterEq).  The MONTH-only and YEAR-only short forms are still accepted
because the DAY/TIME fields are optional and default to day 1, time 00:00.
The on_day struct's pin() method handles the year/month-relative
resolution.

The DAY field is unambiguously distinguishable from a TIME field that
could otherwise follow the MONTH directly: per zic's grammar, MONTH
must be followed by DAY before any TIME is allowed.  So we always
attempt to parse a DAY if any non-whitespace remains after the MONTH.

libstdc++-v3/ChangeLog:

PR libstdc++/124852
* src/c++20/tzdb.cc (on_day): Rename to...
(on_day_month): Rename from on_day.
(on_day_month::on_day_t, on_day_month::on_day): Define.
(operator>>(istream&, on_day_t&&)): Factored out of
operator>>(istream&, on_day&).
(operator>>(istream&, on_day&)): Use on_day_t parser.
(operator>>(istream&, ZoneInfo&)): Replace the integer DAY
parser with on_day_t for the UNTIL field.
* testsuite/std/time/time_zone/until_day_on.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Álvaro Begué <alvaro.begue@gmail.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 weeks agolibgomp: Add stub omp_control_tool for OMPT
Tobias Burnus [Wed, 13 May 2026 06:21:53 +0000 (08:21 +0200)] 
libgomp: Add stub omp_control_tool for OMPT

Add the omp_control_tool routine (always returning omp_control_tool_notool);
add it and omp_control_tool/omp_control_tool_result enums/parameters to omp.h
and omp_lib.{h,mod}. Plus add OpenMP 6.0's omp_pause_stop_tool named constant.

Note that omp_control_tool uses the OpenMP 6.0 C/C++ prototype that uses an
enum omp_control_tool_t as first argument instead of an 'int'.

gcc/fortran/ChangeLog:

* intrinsic.texi (OpenMP Modules): Add named parameters for
omp_control_tool and omp_control_tool_result.

gcc/ChangeLog:

* omp-general.cc (omp_runtime_api_procname): Add omp_control_tool.

libgomp/ChangeLog:

* env.c (omp_control_tool): Stub implementation for omp_control_tool.
* fortran.c (omp_control_tool_, omp_control_tool_8_): Add.
* libgomp.map (OMP_6.0): Add for omp_control_tool*.
* libgomp.texi (Tool Control Routine): Add for omp_control_tool.
(OpenMP 6.0): Mark omp_pause_stop_tool as implemented.
* omp.h.in (omp_pause_resource_t): Add omp_pause_stop_tool.
(omp_control_tool_result_t): Add.
(omp_control_tool_t): Add.
* omp_lib.f90.in (omp_lib_kinds): Add omp_pause_stop_tool and
omp_control_tool/omp_control_tool_result parameters.
(omp_lib): Add omp_control_tool interface.
* omp_lib.h.in: Add omp_pause_stop_tool and
omp_control_tool/omp_control_tool_result parameters; add
omp_control_tool interface.
* testsuite/libgomp.c/omp-control-tools-1.c: New test.
* testsuite/libgomp.fortran/omp-control-tools-1.f: New test.
* testsuite/libgomp.fortran/omp-control-tools-1.f90: New test.

5 weeks agolibstdc++: Fix numeric save offset on Zone lines [PR124851]
Álvaro Begué [Sun, 26 Apr 2026 23:51:17 +0000 (19:51 -0400)] 
libstdc++: Fix numeric save offset on Zone lines [PR124851]

When a Zone line specifies a numeric value as its RULES field (the
constant DST save value for that zone line, e.g. Africa/Gaborone's
"2 1 CAST" line), the parser stored the standard offset alone in
ZoneInfo::m_offset. ZoneInfo::to() then returned that as
sys_info::offset, dropping the numeric save and reporting a total
offset that was wrong by the save amount.

This was inconsistent with the two ZoneInfo constructors that take a
sys_info, which previously stored the *total* offset (stdoff + save) in
m_offset. As a result m_offset's semantics depended on which code path
created the ZoneInfo, and only the parser path's lines with non-zero
numeric save were observably broken.

Fix by giving m_offset a single semantics: always the standard offset
only. The two sys_info-taking constructors now subtract the save before
storing, and to(0 adds it back when reconstructing the sys_info.

The remaining .offset() callers inside _M_get_sys_info already expect
the standard offset (they are computing rule firing times, where the
save component is added separately from the active rule's save value),
so no other call sites need adjustment.

libstdc++-v3/ChangeLog:

PR libstdc++/124851
* src/c++20/tzdb.cc (ZoneInfo::ZoneInfo(sys_info&&)): Store
stdoff only in m_offset (subtract info.save).
(ZoneInfo::ZoneInfo(const pair<sys_info, string_view>&)):
Likewise.
(ZoneInfo::offset()): Document new semantics.
(ZoneInfo::to(sys_info&)): Add m_save back to offset() when
populating sys_info::offset.
* testsuite/std/time/time_zone/numeric_save.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Álvaro Begué <alvaro.begue@gmail.com>
5 weeks agoc: avoid false positive for useless casts and generic [PR125261]
Martin Uecker [Tue, 12 May 2026 05:11:38 +0000 (07:11 +0200)] 
c: avoid false positive for useless casts and generic [PR125261]

To reduce the number of false positives, we guard -Wuseless-cast by
c_inhibit_evaluation_warnings and also increment it for a generic
association if we have seen a prior match for a (non-default)
association.  This covers the common case where the default association
comes last.  If there is another association selected after we have
seen a default, we still have false positives.

PR c/125261

gcc/c/ChangeLog:
* c-parser.cc (c_parser_generic_selection): Modify logic for
c_inhibit_evaluation_warnings.
* c-typeck.cc (build_c_cast): Use c_inhibit_evaluation_warnings.

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

5 weeks agoc++/reflection: reject invalid annotation on class [PR123609]
chzn@mail.ustc.edu.cn [Wed, 13 May 2026 04:48:45 +0000 (00:48 -0400)] 
c++/reflection: reject invalid annotation on class [PR123609]

Some errors while parsing attributes on class are ignored due to tentative
parsing, this patch redo parsing to reject it.

PR c++/123609

gcc/cp/ChangeLog:

* parser.cc (cp_parser_class_head): Re-parse attributes
that caused a tentative parsing failure.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/attr-nodiscard1.C: Adjust expected errors.
* g++.dg/reflect/annotations19.C: New test.

Co-authored-by: Jason Merrill <jason@redhat.com>
5 weeks agotestsuite: Move pr123286.c to gcc.target/aarch64/
Naveen [Wed, 13 May 2026 03:30:01 +0000 (20:30 -0700)] 
testsuite: Move pr123286.c to gcc.target/aarch64/

The test for PR middle-end/123286 unconditionally includes <arm_neon.h>
which is only available on AArch64 targets. Hence, move the testcase to
gcc.target/aarch64/ where the target context is implicit.

gcc/testsuite/ChangeLog:
* gcc.dg/pr123286.c: Move to...
* gcc.target/aarch64/pr123286.c: ...here.

Signed-off-by: Naveen <naveen.siddegowda@oss.qualcomm.com>
5 weeks agogfortran.dg/coarray: Require target sleep where calls were recently added, PR125005
Hans-Peter Nilsson [Thu, 23 Apr 2026 16:22:02 +0000 (18:22 +0200)] 
gfortran.dg/coarray: Require target sleep where calls were recently added, PR125005

I added this attribute only to those tests requiring linking and
runtime use, i.e. those failing as per the PR.

PR libfortran/125005
* gfortran.dg/coarray/failed_images_2.f08,
gfortran.dg/coarray/image_status_2.f08,
gfortran.dg/coarray/stopped_images_2.f08: Require sleep effective
target.

5 weeks agoDaily bump.
GCC Administrator [Wed, 13 May 2026 00:16:27 +0000 (00:16 +0000)] 
Daily bump.

5 weeks agocobol: Improved GENERIC for conditionals and comparisons.
Robert Dubner [Tue, 12 May 2026 17:52:28 +0000 (13:52 -0400)] 
cobol: Improved GENERIC for conditionals and comparisons.

After several years, I am finally developing some understanding of
GENERIC and how the middle-end processes it.  These wide-ranging changes
improve the execution speed of conditional logic and numeric-numeric,
numeric-alpha, and alpha-alpha comparisons.

I started with refining the way GENERIC for "IF <conditional statement>"
is created, and then I moved on to numerous individual cases.  Some
all-purpose routines in libgcobol.so have been broken out into special-
purpose routines implemented in GENERIC.

gcc/cobol/ChangeLog:

* Make-lang.in: Incorporate new gcc/cobol/compare.cc file.
* cobol1.cc (ATTR_CONST_NOTHROW_LEAF): Incorporate __builtin_swap16,
__builtin_swap32, __builtin_swap64, and __builtin_swap128.
(cobol_langhook_init): Likewise.
* genapi.cc (treeplet_fill_source): Improve speed.
(get_binary_value_from_float): Spelling.
(normal_normal_compare): Eliminate.
(compare_binary_binary): Eliminate.
(DEBUG_COMPARE): Eliminate.
(cobol_compare): Eliminate.
(parser_enter_file): Eliminate obsolete variables.
(data_decl_type_for): New function.
(parser_alphabet_use): Flag altered alphabets for speed.
(parser_display): Environment switch for putting comments into
the assembly language.
(program_end_stuff): Change "hijack" to "hijack_h".
(parser_division): Repair RETURN-CODE logic.
(parser_logop): Improve GENERIC for logical operations.
(parser_relop): Use new cobol_compare_relop() routine.
(parser_relop_long): Elminate unnecessary static variable.
(inspect_tally): Improve parameter passing to library routine.
(inspect_replacing): Likewise.
(parser_intrinsic_subst): Likewise.
(parser_intrinsic_callv): Likewise.
(parser_intrinsic_call_1): Likewise.
(parser_bsearch_start): Likewise.
(parser_bsearch_when): Use new comparison routine; simplify logic.
(parser_unstring): Improve parameter passing to library routine.
(parser_string): Likewise.
(create_and_call): Repair RETURN-CODE logic.
(parser_call): Adjust exception processing when the target cannot be
found.
(build_temporaryN): Constructor for cblc_field_t::data.
(hijack_for_development): Change hijacking name to "dubner_h".
(hijacker): Change hijacking name to "hijack_h".
(get_reference_to_data): New function.
(mh_identical): Improve speed when sender and receiver have the same
structure.
(mh_source_is_literalN): Eliminate leading plus/minus when moving a
numeric to an alphanumeric.
(move_helper): Adjust logic for mh_identical and mh_source_is_group.
(actually_create_the_static_field): Use constructor for data member.
(psa_new_var_decl): Typo in comment.
(parser_symbol_add): Make the generated data type more consistent
with the COBOL variable type.
* genapi.h (parser_bsearch_when): Change declaration.
(parser_bsearch_start): Formatting.
(parser_sort): Formatting.
* gengen.cc (gg_show_type): Expand for ARRAY_TYPE and ARRAY_REF.
(gg_define_from_declaration): Use void type for DECL_EXPR.
(gg_define_volatile_variable): New function.
(gg_get_address): New function.
(gg_array_value): Use fold_convert().
(gg_bswap): New function.
(gg_memcmp): New function.
* gengen.h (SCHAR_P): New and changed declarations.
(struct gg_function_t): Add alphabet_in_use flag.
(gg_define_volatile_variable): New declaration.
(gg_get_address_of): Comment.
(gg_pointer_to_array): Comment.
(gg_get_address): New declaration.
(gg_bswap): New declaration.
(gg_memcmp):  New declaration.
(gg_insert_into_assemblerf): Formatting.
* genmath.cc (arithmetic_operation): Improved handling of
parameters.
(fast_add): Improved handling of locations.
(parser_add): Formatting.
* genutil.cc (tree_type_from_digits): Correct parameter.
(get_data_offset): Correct exception handling.
(get_binary_value_tree): Improve location handling.
(tree_type_from_field): Correct logic.
(tree_type_from_size): Correct signs for returned type.
(build_array_of_treeplets): Eliminated.
(build_array_of_referlets): New function.
(build_array_of_fourplets): Eliminated.
(build_array_of_refers): New function.
(refer_is_clean): Improved logic.
(refer_is_super_clean): New function.
(refer_is_working_storage): New function.
(refer_offset): Formatting.
(binary_from_FldNumericBin5): New function.
(binary_from_FldNumericBinary): New function.
(d_and_q_num_disp): New function.
(binary_from_FldNumericDisplay): New function.
(make_dp2bin_decl): New function.
(d_and_q_packed): New function.
(binary_from_comp_3): New function.
(binary_from_comp_6): New function.
(binary_from_FldPacked): New function.
(binary_from_FldFloat): New function.
(get_binary_value): New function.
(get_location): New function.
(get_length): New function.
* genutil.h (tree_type_from_digits): New declaration.
(tree_type_from_size): Changed declaration.
(refer_is_super_clean): New declaration.
(refer_is_working_storage): New declaration.
(refer_offset): Changed declaration.
(build_array_of_treeplets): Remove declaration.
(build_array_of_referlets): New declaration.
(build_array_of_fourplets): Remove declaration.
(build_array_of_refers): New declaration.
(tree_type_from_field): New declaration.
(get_binary_value): New declaration.
(get_location): New declaration.
(get_length): New declaration.
* parse.y: Mysterious changes. All changes to YACC rules are
mysterious.
* parse_ante.h (class log_expr_t): Changes to logop() invocation.
* scan_post.h (yylex): Remove unnecessary trailing semicolon.
* structs.cc (create_cblc_file_t): Change cblc_file_t declaration.
(create_referlet_t): New function.
(create_refer_t): New function.
(create_our_type_nodes): Add cblc_referlet_type_node and
cblc_refer_type_node.
* structs.h (member2): New declaration.
(GTY): Type for cblc_referlet_type_node and cblc_refer_type_node.
* symbols.cc (temporaries_t::add): Remove unnecessary trailing
semicolon.
* symbols.h (struct cbl_bsearch_t): Remove obsolete member.
(ENABLE_HIJACKING): Compilation switch for enabling dubner_h and
hijack_h code-generation hijacking.
* util.cc (symbol_field_type_update): Comment.
* compare.cc: New file.
* compare.h: New file.

libgcobol/ChangeLog:

* charmaps.h (class charmap_t): Remove an abort().
* common-defs.h (SUPERTYPE): Pairs integers for complex switch().
(cbl_file_mode_str): Remove unnecessary trailing semicolon.
* gcobolio.h: New cblc_referlet_t and cblc_refer_t structures;
eliminate obsolete structures.
* gmath.cc (__gg__pow): Improved parameter handling.
(__gg__add_fixed_phase1): Likewise.
(__gg__addf1_fixed_phase2): Likewise.
(__gg__fixed_phase2_assign_to_c): Likewise.
(__gg__add_float_phase1): Likewise.
(__gg__addf1_float_phase2): Likewise.
(__gg__float_phase2_assign_to_c): Likewise.
(__gg__addf3): Likewise.
(__gg__subtractf1_fixed_phase2): Likewise.
(__gg__subtractf2_fixed_phase1): Likewise.
(__gg__subtractf1_float_phase2): Likewise.
(__gg__subtractf2_float_phase1): Likewise.
(__gg__subtractf3): Likewise.
(__gg__multiplyf1_phase1): Likewise.
(__gg__multiplyf1_phase2): Likewise.
(__gg__multiplyf2): Likewise.
(__gg__dividef1_phase2): Likewise.
(__gg__dividef23): Likewise.
(__gg__dividef45): Likewise.
* inspect.cc (inspect_backward_format_1): Likewise.
(__gg__inspect_format_1): Likewise.
(inspect_backward_format_2): Likewise.
(__gg__inspect_format_2): Likewise.
(__gg__inspect_format_1_sbc): Likewise.
* intrinsic.cc (kahan_summation): Likewise.
(variance): Likewise.
(__gg__concat): Likewise.
(__gg__max): Likewise.
(__gg__mean): Likewise.
(__gg__median): Likewise.
(__gg__midrange): Likewise.
(__gg__min): Likewise.
(__gg__ord_min): Likewise.
(__gg__ord_max): Likewise.
(__gg__present_value): Likewise.
(__gg__range): Likewise.
(__gg__standard_deviation): Likewise.
(__gg__sum): Likewise.
(__gg__variance): Likewise.
(__gg__substitute): Likewise.
* libgcobol.cc (__gg__resize_int_p): Eliminate.
(__gg__resize_treeplet): Eliminate.
(initialize_program_state): Eliminate the use of obsolete variables.
(format_for_display_internal): Handle FldLiteralN; display up to
38 digits for __int128.
(compare_field_class): Rename to __gg__compare_field_class.
(__gg__compare_field_class): Likewise.
(interconvert): Correct codeset correction logic.
(__gg__compare_2): Use __gg__compare_field_class.
(__gg__move): Handle FldNumericBin5 correction.
(__gg__string): Improved parameter handling.
(display_both): Cope with missing codeset parameter.
(__gg__literaln_alpha_compare): Eliminate.
(__gg__unstring): Improved parameter handling.
(__gg__just_mangle_name): Improved codeset handling.
(__gg__convert): Formatting.
(__gg__set_data_member): Eliminate.
(__gg__show_int128): New function.
(__gg__compare_string_all): New function.
(__gg__compare_string_1): New function.
(ASCII_16): Abuse of the preprocessor to create a 1024-byte string
of ASCII spaces.
(ASCII_64): Likewise.
(ASCII_256): Likewise.
(ASCII_1024): Likewise.
(EBCDIC_16): Abuse of the preprocessor to create a 1024-byte string
of EBCDIC spaces.
(EBCDIC_64): Likewise.
(EBCDIC_256): Likewise.
(EBCDIC_1024): Likewise.
(__gg__compare_string_1a): New function.
(__gg__compare_string_1e): New function.
(__gg__compare_string_2): New function.
(__gg__compare_string_2a): New function.
(__gg__compare_string_4): New function.
(__gg__compare_string_4a): New function.
(__gg_compare_string_different): New function.
(__gg__compare_numeric_all): New function.
(__gg__compare_binary_to_string): New function.
* stringbin.cc (__gg__binary_to_string_ascii): Improved algorithm.

gcc/testsuite/ChangeLog:

* cobol.dg/group2/Check_for_equality_of_COMP-1___COMP-2.cob:
Corrected logic.
* cobol.dg/group2/ENTRY_statement.cob: Expanded test.
* cobol.dg/group2/ENTRY_statement.out: Likewise.
* cobol.dg/group2/FUNCTION_DATE___TIME_OMNIBUS.cob: Automated
generation of run-time environment variable.
* cobol.dg/group2/Intrinsic_Function_ABS.cob: Corrected.
* cobol.dg/group2/RETURN-CODE_moving.cob: Requires "dialect ibm".
* cobol.dg/group2/FUNCTION_TRIM_with_NATIONAL_characters.cob: New test.
* cobol.dg/group2/FUNCTION_TRIM_with_NATIONAL_characters.out: New test.
* cobol.dg/group2/Large_PIC_10000000_.cob: New test.
* cobol.dg/group2/Large_PIC_10000000_.out: New test.
* cobol.dg/group2/Nested_PERFORM.cob: New test.
* cobol.dg/group2/Nested_PERFORM.out: New test.
* cobol.dg/group2/Overlapping_MOVE.cob: New test.
* cobol.dg/group2/Overlapping_MOVE.out: New test.
* cobol.dg/group2/PERFORM_TIMES_subscripted.cob: New test.
* cobol.dg/group2/PERFORM_TIMES_subscripted.out: New test.
* cobol.dg/group2/PERFORM_VARYING_BY_-0.2.cob: New test.
* cobol.dg/group2/PERFORM_VARYING_BY_-0.2.out: New test.
* cobol.dg/group2/REDEFINES__chained.cob: New test.
* cobol.dg/group2/REDEFINES__chained.out: New test.
* cobol.dg/group2/RETURN-CODE_with_INITIAL_and_RECURSIVE.cob: New test.
* cobol.dg/group2/RETURN-CODE_with_INITIAL_and_RECURSIVE.out: New test.
* cobol.dg/group2/Sanity_check_for_ENTRY.cob: New test.
* cobol.dg/group2/Sanity_check_for_ENTRY.out: New test.
* cobol.dg/group2/Simple_COMP-X.cob: New test.
* cobol.dg/group2/Simple_COMP-X.out: New test.
* cobol.dg/group2/compare_alpha_to_all__literal_.cob: New test.
* cobol.dg/group2/compare_alpha_to_all__literal_.out: New test.
* cobol.dg/group2/compare_national_to_display.cob: New test.
* cobol.dg/group2/compare_national_to_display.out: New test.
* cobol.dg/group2/comprensive_compare_comp-1_comp-5.cob: New test.
* cobol.dg/group2/comprensive_compare_comp-1_comp-5.out: New test.
* cobol.dg/group2/refmod_with_nested_parentheses.cob: New test.
* cobol.dg/group2/refmod_with_nested_parentheses.out: New test.
* cobol.dg/group2/signed_unsigned_compare.cob: New test.
* cobol.dg/group2/signed_unsigned_compare.out: New test.

5 weeks agoICE with -Winfinite-recursion due to recursive rather than work queue/list [PR124651]
Heiko Eißfeldt [Tue, 7 Apr 2026 18:28:16 +0000 (20:28 +0200)] 
ICE with -Winfinite-recursion due to recursive rather than work queue/list [PR124651]

As suggested the control flow in
pass_warn_recursion::find_function_exit() was changed
from a recursive to an iterative form. The logic for detecting infinite
recursion is left unchanged.

This avoids stack overflows while handling very large functions
as could be seen with the generated code attached to the PR.

Reg tested OK.

2026-04-07 Heiko Eißfeldt <heiko@hexco.de>

PR middle-end/124651
* gimple-warn-recursion.cc (find_function_exit):
replace recursive calls with iteration for lower stack usage

5 weeks agodoc: Remove unused reference to @gol macro.
Léo Hardt [Tue, 12 May 2026 22:09:28 +0000 (19:09 -0300)] 
doc: Remove unused reference to @gol macro.

The @gol texinfo macro appears to have been used as a workaround for
achieving line breaks in gccoptlists, and has been removed on commit
43b72ed. The texi2pod rule to ignore it was not cleaned up at the time.

I did not find any references to @gol in the documentation, and building
man pages with and without the deleted rule produced identical files.

contrib/ChangeLog:

* texi2pod.pl: Remove rule to parse the defunct @gol macro.

Signed-off-by: Léo Hardt <leom.hardt@inf.ufrgs.br>
5 weeks agohppa64: Don't define MD_EXEC_PREFIX to "/usr/ccs/bin" on hpux
John David Anglin [Tue, 12 May 2026 19:58:26 +0000 (15:58 -0400)] 
hppa64: Don't define MD_EXEC_PREFIX to "/usr/ccs/bin" on hpux

In testing with GNU ld, I found defining MD_EXEC_PREFIX to "/usr/ccs/bin"
sometimes causes HP ld to be selected when we want GNU ld.

2026-05-12  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

* config/pa/pa64-hpux.h (MD_EXEC_PREFIX): Define to empty
string.

5 weeks agoAdd warnings of potentially-uninitialized padding bits
Christopher Bazley [Tue, 10 Feb 2026 15:33:07 +0000 (15:33 +0000)] 
Add warnings of potentially-uninitialized padding bits

    Commit 0547dbb725b reduced the number of cases in which
    union padding bits are zeroed when the relevant language
    standard does not strictly require it, unless gcc was
    invoked with -fzero-init-padding-bits=unions or
    -fzero-init-padding-bits=all in order to explicitly
    request zeroing of padding bits.

    This commit adds a closely related warning,
    -Wzero-init-padding-bits=, which is intended to help
    programmers to find code that might now need to be
    rewritten or recompiled with
    -fzero-init-padding-bits=unions or
    -fzero-init-padding-bits=all in order to replicate
    the behaviour that it had when compiled by older
    versions of GCC. It can also be used to find struct
    padding that was never previously guaranteed to be
    zero initialized and still isn't unless GCC is
    invoked with -fzero-init-padding-bits=all.

    The new warning can be set to the same three states
    as -fzero-init-padding-bits ('standard', 'unions'
    or 'all') and has the same default value ('standard').

    The two options interact as follows:

             f: standard  f: unions   f: all
    w: standard     X         X         X
    w: unions       U         X         X
    w: all          A         S         X

    X = No warnings about padding
    U = Warnings about padding of unions.
    S = Warnings about padding of structs.
    A = Warnings about padding of structs and unions.

    The level of optimisation and whether or not the
    entire initializer is dropped to memory can both
    affect whether warnings are produced when compiling
    a given program. This is intentional, since tying
    the warnings more closely to the relevant language
    standard would require a very different approach
    that would still be target-dependent, might impose
    an unacceptable burden on programmers, and would
    risk not satisfying the intended use-case (which
    is closely tied to a specific optimisation).

gcc/ChangeLog:

* common.opt: Add Wzero-init-padding-bits=.
* common.opt.urls: Regenerated.
* doc/invoke.texi: Document Wzero-init-padding-bits=.
* expr.cc (categorize_ctor_elements_1): Update new struct type
ctor_completeness instead of an integer to indicate presence of
padding or missing fields in a constructor. Instead of setting -1
upon discovery of padding bits in both structs and unions,
set separate flags to indicate the type of padding bits.
(categorize_ctor_elements): Update the type and documentation of
the p_complete parameter.
(mostly_zeros_p): Use new struct type ctor_completeness when
calling categorize_ctor_elements.
(all_zeros_p): Use new struct type ctor_completeness when
calling categorize_ctor_elements.
* expr.h (struct ctor_completeness): New struct type to replace an
an integer that could take the value -1 ('all fields are
initialized, but there's padding'), 0 ('fields are missing') or
1 ('all fields are initialized, and there's no padding'). Named
bool members make the code easier to understand and make room to
disambiguate struct padding bits from union padding bits.
(categorize_ctor_elements): Update the function declaration to use
the new struct type in the last parameter declaration.
* gimplify.cc (gimplify_init_constructor): Replace use of
complete_p != 0 ('all fields are initialized') with !sparse,
replace use of complete == 0 ('fields are missing') with sparse, and
replace use of complete <= 0 ('fields are missing' or 'all fields are
initialized, but there's padding') with sparse || padded_union or
padded_non_union. Trigger new warnings if storage for the object
is not zeroed but padded_union or padded_non_union is set
(because this combination implies possible non-zero padding bits).

gcc/testsuite/ChangeLog:

* gcc.dg/c23-empty-init-warn-1.c: New test.
* gcc.dg/c23-empty-init-warn-10.c: New test.
* gcc.dg/c23-empty-init-warn-11.c: New test.
* gcc.dg/c23-empty-init-warn-12.c: New test.
* gcc.dg/c23-empty-init-warn-13.c: New test.
* gcc.dg/c23-empty-init-warn-14.c: New test.
* gcc.dg/c23-empty-init-warn-15.c: New test.
* gcc.dg/c23-empty-init-warn-16.c: New test.
* gcc.dg/c23-empty-init-warn-17.c: New test.
* gcc.dg/c23-empty-init-warn-2.c: New test.
* gcc.dg/c23-empty-init-warn-3.c: New test.
* gcc.dg/c23-empty-init-warn-4.c: New test.
* gcc.dg/c23-empty-init-warn-5.c: New test.
* gcc.dg/c23-empty-init-warn-6.c: New test.
* gcc.dg/c23-empty-init-warn-7.c: New test.
* gcc.dg/c23-empty-init-warn-8.c: New test.
* gcc.dg/c23-empty-init-warn-9.c: New test.
* gcc.dg/gnu11-empty-init-warn-1.c: New test.
* gcc.dg/gnu11-empty-init-warn-10.c: New test.
* gcc.dg/gnu11-empty-init-warn-11.c: New test.
* gcc.dg/gnu11-empty-init-warn-12.c: New test.
* gcc.dg/gnu11-empty-init-warn-13.c: New test.
* gcc.dg/gnu11-empty-init-warn-14.c: New test.
* gcc.dg/gnu11-empty-init-warn-15.c: New test.
* gcc.dg/gnu11-empty-init-warn-16.c: New test.
* gcc.dg/gnu11-empty-init-warn-17.c: New test.
* gcc.dg/gnu11-empty-init-warn-2.c: New test.
* gcc.dg/gnu11-empty-init-warn-3.c: New test.
* gcc.dg/gnu11-empty-init-warn-4.c: New test.
* gcc.dg/gnu11-empty-init-warn-5.c: New test.
* gcc.dg/gnu11-empty-init-warn-6.c: New test.
* gcc.dg/gnu11-empty-init-warn-7.c: New test.
* gcc.dg/gnu11-empty-init-warn-8.c: New test.
* gcc.dg/gnu11-empty-init-warn-9.c: New test.

5 weeks agoc++: -Wzero-as-null-pointer-constant and <=> [PR100903]
Jason Merrill [Tue, 12 May 2026 15:27:29 +0000 (11:27 -0400)] 
c++: -Wzero-as-null-pointer-constant and <=> [PR100903]

(x <=> y) < 0 is the pattern suggested by the standard, we shouldn't warn
about it because of our implementation strategy.

We already disable the warning in <compare> to avoid warnings on the uses of
this pattern within the header, so no library changes are needed.

PR c++/100903

gcc/cp/ChangeLog:

* call.cc (build_over_call): Avoid -Wzero-as-null-pointer-constant
if the warning is disabled around the called function.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/spaceship-warn1.C: New test.

5 weeks agoc++: deferred parsing of default arguments [PR50479]
Marek Polacek [Mon, 11 May 2026 21:19:42 +0000 (17:19 -0400)] 
c++: deferred parsing of default arguments [PR50479]

In

  void fn (int i = sizeof (i)) {}

the i in sizeof should refer to the parameter ([basic.scope.pdecl]) and
since the second i is not evaluated, the code is valid per
[dcl.fct.default]/9: A parameter shall not appear as a potentially
evaluated expression in a default argument.

This patch fixes this by moving the grokdeclarator call from
_parameter_declaration_list to _parameter_declaration and maybe calling
pushdecl before parsing the default argument.

PR c++/50479
PR c++/62244

gcc/cp/ChangeLog:

* parser.cc (cp_parser_parameter_declaration_list): Move the
grokdeclarator call and setting DECL_SOURCE_LOCATION to...
(cp_parser_parameter_declaration): ...here.  New tree parameter.
Set it.  Call pushdecl for a named decl with a default argument.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/parm1.C: Uncomment code.
* g++.dg/parse/defarg22.C: New test.
* g++.dg/parse/defarg23.C: New test.
* g++.dg/parse/defarg24.C: New test.
* g++.dg/parse/defarg25.C: New test.
* g++.dg/parse/defarg26.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
5 weeks agolibstdc++: Improve handling of leap second expiry time [PR123165]
Jonathan Wakely [Tue, 28 Apr 2026 12:15:22 +0000 (13:15 +0100)] 
libstdc++: Improve handling of leap second expiry time [PR123165]

This change allows the hardcoded list of leap seconds in <chrono> to be
used even when the program is executing after the hardcoded expiry date
in that header.

For times after the hardcoded expiry, the inline __get_leap_second_info
function calls a new library function which compares the number of
hardcoded leap seconds in the header with the number of leap seconds
defined in the tzdata leapseconds file (usually provided by the OS).

There are three leap second lists that are relevant here. The first is
the hardcoded list (and its expiry time) in the <chrono> header. That is
fixed when the user code is compiled, and might be out of date by the
time the application runs. The second list (and its expiry time) is
hardcoded in tzdb.cc in the libstdc++.so library. If the application
uses a newer libstdc++.so at runtime than the <chrono> header used at
compile time, we can still avoid going to the filesystem for dates
within the expiry time of the list in libstdc++.so. The third list is
the most up-to-date one which is read from the leapseconds file.

The code added by this commit tries to avoid reading the file when
possible (because that's slower than using the in-memory lists), and if
it does have to go to the file system, it tries to avoid doing so again
next time the leap seconds are needed.

libstdc++-v3/ChangeLog:

PR libstdc++/123165
* acinclude.m4 (libtool_VERSION): Bump version.
* config/abi/pre/gnu.ver (GLIBCXX_3.4.36): Add new symbol
version and export new symbol.
* configure: Regenerate.
* include/std/chrono (__detail::__recent_leap_second_info):
Declare new function and make it a friend of varous classes.
(leap_second): Make private constructor constexpr. Remove friend
declaration for get_leap_second_info.
(__detail::__get_leap_second_info): Use new function for times
past the hardcoded expiry.
* src/c++20/tzdb.cc (tzdb_list::_Node::fixed_leaps): Move array
of leap seconds here from _S_read_leap_seconds.
(fixed_expiry, num_leap_seconds): New globals.
(__detail::__recent_leap_second_info): Define new function.
(tzdb_list::_Node::_S_read_leap_seconds): Populate vector from
_Node::fixed_leaps. Rename bool variable to clarify meaning.
(tzdb_list::_Node::_S_replace_head): Update num_leap_seconds
when updating the tzdb_list.
* testsuite/util/testsuite_abi.cc: Update known_versions and
latestp.
* testsuite/std/time/clock/utc/leap_second_info-2.cc: New test.

Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 weeks agotestsuite: fix reflect/bases_of5.C for -m32
Marek Polacek [Tue, 12 May 2026 13:19:21 +0000 (09:19 -0400)] 
testsuite: fix reflect/bases_of5.C for -m32

gcc/testsuite/ChangeLog:

* g++.dg/reflect/bases_of5.C: Use decltype (sizeof 0) instead of
unsigned long.

5 weeks agosra: Fix build_user_friendly_ref_for_offset for bit-fields (PR124151)
Martin Jambor [Tue, 12 May 2026 12:59:13 +0000 (14:59 +0200)] 
sra: Fix build_user_friendly_ref_for_offset for bit-fields (PR124151)

When SRA propagates bit-field propagations across assignments, it
first attempts to use build_user_friendly_ref_for_offset to represent
the expression of the new accesses and a possible scalar replacement
so that if there are any warnings generated for it, they are as nice
as we can make them.

However, this can lead to situations where, despite that the new
access has exactly the same type as the new old one, it accesses a
(record or union): field which is just big enough for its precision,
whereas the one we want to match has size rounded up to bytes.  This
causes discrepancy between the recorded size of the new access and the
size get_ref_base_and_extent reports for its expr, which trips the
verifier.

Unlike the previous approach which avoided propagation in the case of
bit fields, this patch fixes build_user_friendly_ref_for_offset by
making it also track the size it is looking at and the size it is
looking for so that it can declare success only if these two also
match.  Additionally, it reverts the simple bail-out fix for PR 117217
because it is no longer necessary.  (I have verified the bug is still
fixed though by applying the new fix on top of the last problematic
commit.)

gcc/ChangeLog:

2026-04-29  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/124151
* tree-sra.cc (build_user_friendly_ref_for_offset): Added parameters
CUR_SIZE and EXP_SIZE.  Added code passing the correct CUR_SIZE and
checking it against EXP_SIZE.  Removed unused code for the case when
EXP_TYPE was NULL_TREE.
(create_artificial_child_access): Adjusted the call to
build_user_friendly_ref_for_offset.
(propagate_subaccesses_from_rhs): Likewise.
(propagate_subaccesses_from_rhs): Removed a check that the size of
lchild is a multiple of BITS_PER_UNIT.
(propagate_subaccesses_from_lhs): Likewise.

gcc/testsuite/ChangeLog:

2026-04-29  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/124151
* gcc.dg/tree-ssa/pr124151.c: New test.

5 weeks agoRX: Fix infinite-loop on LRA [PR113948]
Yoshinori Sato [Tue, 12 May 2026 11:39:07 +0000 (12:39 +0100)] 
RX: Fix infinite-loop on LRA [PR113948]

The LRA was confused and looping due to the definition of the register class.
The LRA yielded incorrect results because the manipulation of stack frames
and the movement of double words relied heavily on existing reloads.
These changes ensure that the correct code is generated even when the "-mlra"
option is specified.

gcc/ChangeLog:
PR target/113948

* config/rx/rx-protos.h (rx_split_double_move): New helper prototype.
(rx_relax_double_operands): Likewise.
* config/rx/rx.cc (rx_legitimize_address): Add expand complex case.
(rx_is_legitimate_address): Add double word case.
(rx_gen_move_template): Fix operation size in unsigned extend.
(rx_gen_move_template): Remove DImode and DFmode.
(rx_get_stack_layout): Fix for frame size calculation.
(rx_initial_elimination_offset): The calculation method has been
changed to one that supports LRA.
(rx_hard_regno_nregs): Use CEIL.
(rx_hard_regno_mode_ok): Add ATTRIBUTE_UNUSED.
(rx_get_subword): New. Double word move helper.
(rx_split_double_move): Likewise.
(rx_relax_double_operands): Likewise.
* config/rx/rx.h (reg_class): Add CC for all regsisters.
(CLASS_MAX_NREGS): Remove.
* config/rx/rx.md (mov<register_modes:mode>):
Replace copy_to_mode_reg to force_reg.
(movdi): Limit the arguments to make register allocation easier.
(movdf): Likewise.
(movdi_internal): New.
(movdf_internal): New.
(addsi3_pid): New. Handling UNSPEC_PID_ADDR.
(addsi3_lra): New. alternative addptrsi3.
(ashlsi3_lra): Likewise.

Signed-off-by: Yoshinori Sato <yoshinori.sato@nifty.com>
5 weeks ago[PATCH 2/2] tree-optimization/vect: Allow single-lane SLP fallback when limit is...
Lili Cui [Tue, 12 May 2026 17:01:00 +0000 (10:01 -0700)] 
[PATCH 2/2] tree-optimization/vect: Allow single-lane SLP fallback when limit is exhausted

In vect_analyze_slp_reduction, the early bail "if (*limit == 0) return
false" blocked all SLP discovery including the single-lane fallback path.
However, single-lane SLP trees (group_size == 1) do not consume the
discovery limit as they cannot cause exponential tree growth.

This causes vectorization failures in loops with many independent
conditional reductions: multi-lane grouping attempts exhaust the limit,
then the single-lane fallback that would have succeeded is incorrectly
rejected.

The fix moves the limit check to only guard chain analysis (which builds
multi-lane trees and does consume limit), allowing the single-lane
fallback to always proceed.

This improves 731.astcenc_r (-Ofast) by 3.8% on EMR and 1.4% on Znver5 with single-copy.

gcc/ChangeLog:

* tree-vect-slp.cc (vect_analyze_slp_reduction): Don't bail out
early when SLP discovery limit is exhausted; only guard the chain
analysis which may build multi-lane trees.  Single-lane fallback
does not consume limit and should always be attempted.

Co-authored-by: Hongtao Liu <hongtao.liu@intel.com>
5 weeks ago[PATCH 1/2] tree-optimization/vect: Allow commutative operand swap for IFN in SLP...
Lili Cui [Tue, 12 May 2026 17:00:00 +0000 (10:00 -0700)] 
[PATCH 1/2] tree-optimization/vect: Allow commutative operand swap for IFN in SLP reduction

In vect_build_slp_tree_1, when checking whether reduction operands at
different positions can be swapped, only tree_code operations (e.g.
PLUS_EXPR) were recognized as commutative.  Internal functions produced
by if-conversion (e.g. .COND_ADD, .COND_MUL) were not handled, causing
"different reduc_idx" failures when the reduction operand appeared at
different commutative positions across SLP lanes.

This patch extends the commutative swap recognition to internal
functions using the unified first_commutative_argument(code_helper, tree)
interface to identify the swappable operand pair for both tree codes and
internal functions.

This improves 731.astcenc_r (-Ofast) by 7.1% on EMR and 2.48% on Znver5.

gcc/ChangeLog:

* tree-vect-slp.cc (vect_build_slp_tree_1): Use unified
first_commutative_argument interface to allow commutative
operand swap for both tree codes and internal functions
(e.g. .COND_ADD) in SLP reduction matching.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/slp-reduc-15.c: New test.

Co-authored-by: Hongtao Liu <hongtao.liu@intel.com>
5 weeks agoAvoid setting ls_type when unused
Richard Biener [Tue, 12 May 2026 08:40:56 +0000 (10:40 +0200)] 
Avoid setting ls_type when unused

The following avoids setting the ls_type on loads/stores when that
type isn't used.

* tree-vect-stmts.cc (get_load_store_type): Pass
temporary to vect_use_grouped_gather, only set ls_type
when that succeeded.

5 weeks agomatch.pd: rearrange (VCE (BFR)) simplification conditions [PR125259]
Artemiy Volkov [Mon, 11 May 2026 09:06:12 +0000 (09:06 +0000)] 
match.pd: rearrange (VCE (BFR)) simplification conditions [PR125259]

The precondition for (view_convert (BIT_FIELD_REF)) simplification at
match.pd:5881 last fixed in r16-4735-g44c27171c36a91 is still wrong,
as it allows a vector type to be converted to/from _BitInt types (for
which precision can be smaller than size).  Address this by always
checking type_has_mode_precision_p () for all integer types.  (This fix
was posted by Richard B. at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125259#c5.)

Add a testcase as reduced in the PR as tree-ssa/pr125259.c.

Bootstrapped and regtested on aarch64, arm, and x86_64.

OK for trunk and 16?

PR middle-end/125259

gcc/ChangeLog:

* match.pd: Fix the view_convert (BIT_FIELD_REF) pattern.

gcc/testsuite/ChangeLog:

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

5 weeks agovxworks: support aarch64 errata
Alexandre Oliva [Mon, 11 May 2026 06:47:03 +0000 (03:47 -0300)] 
vxworks: support aarch64 errata

I noticed that aarch64 errata required specs tweaks that were missing
on vxworks.  To my surprise, adding those specs enabled even the
linker tests to pass, despite using vxlink and not always performing
final links.  Ok, then, reverting the skip directives added not too
long ago.

for  gcc/ChangeLog

* config.gcc [aarch64*-wrs-vxworks*] (tm_file): Add
aarch64/aarch64-errata.h.
* config/aarch64/aarch64-vxworks.h (LINK_SPEC): Add
AARCH64_ERRATA_LINK_SPEC.
(CC1_SPEC, CC1PLUS_SPEC): Add AARCH64_ERRATA_COMPILE_SPEC.

for  gcc/testsuite/ChangeLog

* gcc.target/aarch64/erratas_opt_0.c: Revert skip on VxWorks.
* gcc.target/aarch64/erratas_opt_1.c: Likewise.
* gcc.target/aarch64/erratas_opt_2.c: Likewise.
* gcc.target/aarch64/erratas_opt_3.c: Likewise.
* gcc.target/aarch64/erratas_opt_4.c: Likewise.
* gcc.target/aarch64/erratas_opt_5.c: Likewise.
* gcc.target/aarch64/erratas_opt_6.c: Likewise.
* gcc.target/aarch64/erratas_opt_7.c: Likewise.
* gcc.target/aarch64/erratas_opt_8.c: Likewise.
* gcc.target/aarch64/erratas_opt_9.c: Likewise.
* gcc.target/aarch64/erratas_opt_10.c: Likewise.
* gcc.target/aarch64/erratas_opt_11.c: Likewise.
* gcc.target/aarch64/erratas_opt_12.c: Likewise.
* gcc.target/aarch64/erratas_opt_13.c: Likewise.
* gcc.target/aarch64/erratas_opt_14.c: Likewise.
* gcc.target/aarch64/erratas_opt_15.c: Likewise.

5 weeks agolibstdc++: vxworks: enable clock_gettime
Alexandre Oliva [Mon, 11 May 2026 06:46:46 +0000 (03:46 -0300)] 
libstdc++: vxworks: enable clock_gettime

We've been using gettimeofday() on VxWorks, because configury didn't
state clock_gettime was available.  It has been since at least
vxworks6.9, possibly earlier.  Indeed, it's been available for longer
than gettimeofday(), so this enables libstdc++'s chrono.cc to work
with earlier 6.9 releases.

We've used clock_gettime unconditionally in __gthread_cond_timedwait
for a very long time, so it's not like this brings in a new
dependency, but it allows clocks and deadlines to work with the same
precision.  Before this change, we'd use gettimeofday's coarser
clocks, and finer timed waits, which makes room for imprecisions.

for  libstdc++-v3/ChangeLog

* acinclude.m4 (GLIBXX_ENABLE_LIBSTDCXX_TIME) [vxworks*]:
Enable monotonic and realtime clocks.
* configure: Rebuilt.

5 weeks agotestsuite: pr94994: include stddef.h for size_t
Alexandre Oliva [Tue, 12 May 2026 06:29:29 +0000 (03:29 -0300)] 
testsuite: pr94994: include stddef.h for size_t

The testcase refers to size_t without including stddef.h.

for  gcc/testsuite/ChangeLog

* gcc.dg/vect/pr94994.c: Include stddef.h.

5 weeks agotestsuite: riscv: reset -march for tests with -mcpu
Alexandre Oliva [Tue, 12 May 2026 06:29:10 +0000 (03:29 -0300)] 
testsuite: riscv: reset -march for tests with -mcpu

The tests fail when --target_board sets -march to a 32-bit
architecture.  Override that -march by resetting it, so that the arch
implied by -mcpu prevails.

for  gcc/testsuite/ChangeLog

* gcc.target/riscv/pr114139.c: Reset arch.
* gcc.target/riscv/pr118170.c: Likewise.

5 weeks agotree-optimization: Fold SAT_ADD at gimple level
Naveen [Tue, 12 May 2026 04:08:11 +0000 (21:08 -0700)] 
tree-optimization: Fold SAT_ADD at gimple level

Extend scalar SAT_ADD constant folding to recognize cases where one operand is
zero. It allows SAT_ADD expressions with constant operands to fold away early.
The change improves optimization opportunities and avoids emitting unnecessary
SAT_ADD operations.
Bootstrapped and tested on aarch64-linux-gnu.

PR middle-end/123286

gcc/ChangeLog:
* fold-const-call.cc (fold_internal_fn_sat_add): New function.
(fold_const_call): Handle CFN_SAT_ADD.
* match.pd: Add simplifications for x SAT_ADD 0 == x.
* genmatch.cc (commutative_op): Add CFN_SAT_ADD.

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

Signed-off-by: Naveen <naveen.siddegowda@oss.qualcomm.com>
5 weeks ago[Aarch64]: Make aarch64_output_simd_mov_imm_low return const char *
Naveen [Tue, 12 May 2026 04:04:38 +0000 (21:04 -0700)] 
[Aarch64]: Make aarch64_output_simd_mov_imm_low return const char *

aarch64_output_simd_mov_imm_low emits the instruction directly using
output_asm_insn and returns an empty string to indicate that no further
template needs to be emitted.  Since the returned empty string is a string
literal, the function should return const char * rather than char *.

This fixes a bootstrap failure with -Werror=write-strings.

gcc/ChangeLog:

* config/aarch64/aarch64-protos.h (aarch64_output_simd_mov_imm_low):
Change return type to const char *.
* config/aarch64/aarch64.cc (aarch64_output_simd_mov_imm_low): Likewise.

Signed-off-by: Naveen <naveen.siddegowda@oss.qualcomm.com>