]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
3 months agors6000: Ignore OPTION_MASK_SAVE_TOC_INDIRECT differences in inlining decisions [PR119327]
Jakub Jelinek [Tue, 22 Apr 2025 19:27:28 +0000 (21:27 +0200)] 
rs6000: Ignore OPTION_MASK_SAVE_TOC_INDIRECT differences in inlining decisions [PR119327]

The following testcase FAILs because the always_inline function can't
be inlined.
The rs6000 backend has similarly to other targets a hook which rejects
inlining which would bring in new ISAs which aren't there in the caller.
And this hook rejects this because of OPTION_MASK_SAVE_TOC_INDIRECT
differences.
This flag is set if explicitly requested or by default depending on
whether the current function looks hot (or at least not cold):
  if ((rs6000_isa_flags_explicit & OPTION_MASK_SAVE_TOC_INDIRECT) == 0
      && flag_shrink_wrap_separate
      && optimize_function_for_speed_p (cfun))
    rs6000_isa_flags |= OPTION_MASK_SAVE_TOC_INDIRECT;
The target nodes that are being compared here are actually the default
target node (which was created when cfun was NULL) vs. one that was
created for the always_inline function when it wasn't NULL, so one
doesn't have it, the other does.
In any case, this flag feels like a tuning decision rather than hard
ISA requirement and I see no problems why we couldn't inline
even explicit -msave-toc-indirect function into -mno-save-toc-indirect
or vice versa.
We already ignore OPTION_MASK_P{8,10}_FUSION which are also more
like tuning flags.

2025-04-22  Jakub Jelinek  <jakub@redhat.com>

PR target/119327
* config/rs6000/rs6000.cc (rs6000_can_inline_p): Ignore also
OPTION_MASK_SAVE_TOC_INDIRECT differences.

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

(cherry picked from commit 4b62cf555b5446cb02fc471519cf1afa09e1a108)

3 months agoAdjust gcc_release for id href web transformations
Jakub Jelinek [Fri, 25 Apr 2025 08:23:15 +0000 (10:23 +0200)] 
Adjust gcc_release for id href web transformations

We now have some script which transforms e.g.
<h2 id="15.1">GCC 15.1</h2>
line in gcc-15/changes.html to
<h2 id="15.1"><a href="#15.1">GCC 15.1</a></h2>

This unfortunately breaks the gcc_release script, which looks for
GCC 15.1 appearing in gennews after optional blanks from the start of
the line in the NEWS file, which is no longer the case, there is
[129]GCC 15.1
or something like that with an URL later on
 129. https://gcc.gnu.org/gcc-15/changes.html#15.1

The following patch handles this.

2025-04-25  Jakub Jelinek  <jakub@redhat.com>

* gcc_release: Allow optional \[[0-9]+\] before GCC major.minor
in the NEWS file.

(cherry picked from commit fef3a3c8b5d35c7a8eeae67f95a264a90120dd29)

3 months agoBump BASE-VER
Jakub Jelinek [Fri, 25 Apr 2025 09:14:05 +0000 (11:14 +0200)] 
Bump BASE-VER

2025-04-25  Jakub Jelinek  <jakub@redhat.com>

* BASE-VER: Set to 15.1.1.

3 months agoUpdate ChangeLog and version files for release releases/gcc-15.1.0
Jakub Jelinek [Fri, 25 Apr 2025 08:21:07 +0000 (08:21 +0000)] 
Update ChangeLog and version files for release

3 months agoUpdate gennews for GCC 15.
Jakub Jelinek [Fri, 25 Apr 2025 07:53:35 +0000 (09:53 +0200)] 
Update gennews for GCC 15.

2025-04-25  Jakub Jelinek  <jakub@redhat.com>

* gennews (files): Add files for GCC 15.

(cherry picked from commit 865d0f23d2ba08b3b6df6066e7dc5e807a14f5fa)

3 months agoDaily bump.
GCC Administrator [Fri, 25 Apr 2025 00:25:53 +0000 (00:25 +0000)] 
Daily bump.

3 months agoopts.cc: Use opts rather than opts_set for validating -fipa-reorder-for-locality
Kyrylo Tkachov [Thu, 24 Apr 2025 12:33:54 +0000 (05:33 -0700)] 
opts.cc: Use opts rather than opts_set for validating -fipa-reorder-for-locality

This ensures -fno-ipa-reorder-for-locality doesn't complain with an explicit
-flto-partition=.

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
* opts.cc (validate_ipa_reorder_locality_lto_partition): Check opts
instead of opts_set for x_flag_ipa_reorder_for_locality.
(finish_options): Update call site.

(cherry picked from commit fbf8443961f484ed7fb7e953206af1ee60558a24)

3 months agoopts.cc Simplify handling of explicit -flto-partition= and -fipa-reorder-for-locality
Kyrylo Tkachov [Thu, 24 Apr 2025 07:34:09 +0000 (00:34 -0700)] 
opts.cc Simplify handling of explicit -flto-partition= and -fipa-reorder-for-locality

The handling of an explicit -flto-partition= and -fipa-reorder-for-locality
should be simpler.  No need to have a new default option.  We can use opts_set
to check if -flto-partition is explicitly set and use that information in the
error handling.
Remove -flto-partition=default and update accordingly.

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

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

* common.opt (LTO_PARTITION_DEFAULT): Delete.
(flto-partition=): Change default back to balanced.
* flag-types.h (lto_partition_model): Remove LTO_PARTITION_DEFAULT.
* opts.cc (validate_ipa_reorder_locality_lto_partition):
Check opts_set->x_flag_lto_partition instead of LTO_PARTITION_DEFAULT.
(finish_options): Remove handling of LTO_PARTITION_DEFAULT.

gcc/testsuite/

* gcc.dg/completion-2.c: Remove check for default.

(cherry picked from commit 040f94d1f63c3607a2f3faf5c329c3b2b6bf7d1e)

3 months agoRegenerate gcc.pot
Joseph Myers [Wed, 23 Apr 2025 19:28:13 +0000 (19:28 +0000)] 
Regenerate gcc.pot

* gcc.pot: Regenerate.

3 months agoFortran: Fix checking for IMPURE in DO CONCURRENT.
Steven G. Kargl [Sat, 19 Apr 2025 01:05:10 +0000 (18:05 -0700)] 
Fortran: Fix checking for IMPURE in DO CONCURRENT.

PR fortran/119836

gcc/fortran/ChangeLog:

* resolve.cc (check_pure_function): Fix checking for
an impure subprogram within a DO CONCURRENT construct.
(pure_subroutine): Ditto.

gcc/testsuite/ChangeLog:

* gfortran.dg/do_concurrent_all_clauses.f90: Remove invalid
dg-error test.
* gfortran.dg/pr119836_1.f90: New test.
* gfortran.dg/pr119836_2.f90: New test.
* gfortran.dg/pr119836_3.f90: New test.
* gfortran.dg/pr119836_4.f90: New test.

(cherry picked from commit f9ea46d946887a05d7ecbca5aeeb99fd868f6e70)

3 months agoUpdate gcc sv.po
Joseph Myers [Wed, 23 Apr 2025 15:02:59 +0000 (15:02 +0000)] 
Update gcc sv.po

* sv.po: Update.

3 months agotestsuite: AMDGCN test for vect-early-break_38.c as well to consistent architecture...
Tamar Christina [Wed, 23 Apr 2025 07:07:23 +0000 (08:07 +0100)] 
testsuite: AMDGCN test for vect-early-break_38.c as well to consistent architecture [PR119286]

I had missed this one during the AMDGCN test failures.

Like vect-early-break_18.c this test is also scalaring the
loads and thus leading to unexpected vectorization for this
testcase.

gcc/testsuite/ChangeLog:

PR target/119286
* gcc.dg/vect/vect-early-break_38.c: Force -march=gfx908 for amdgcn.

(cherry picked from commit 50a747215e45783de4fd64e47d0851f07d3a44df)

3 months agoDaily bump.
GCC Administrator [Wed, 23 Apr 2025 00:25:10 +0000 (00:25 +0000)] 
Daily bump.

3 months agoaarch64: Define __ARM_FEATURE_FAMINMAX
Richard Sandiford [Tue, 22 Apr 2025 17:41:51 +0000 (18:41 +0100)] 
aarch64: Define __ARM_FEATURE_FAMINMAX

We implemented FAMINMAX ACLE support but failed to define the
associated feature macro.

gcc/
* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins): Define
__ARM_FEATURE_FAMINMAX.

gcc/testsuite/
* gcc.target/aarch64/pragma_cpp_predefs_4.c: Test
__ARM_FEATURE_FAMINMAX.

(cherry picked from commit a544a9c5bbfce013ab020f82acd2470d610fb3c8)

3 months agoRevert "libstdc++: Optimize std::projected<I, std::identity>" [PR119888]
Patrick Palka [Tue, 22 Apr 2025 16:55:05 +0000 (12:55 -0400)] 
Revert "libstdc++: Optimize std::projected<I, std::identity>" [PR119888]

This non-standard optimization breaks real-world code that expects the
result of std::projected to always (be a class type and) have a value_type
member, which isn't true for e.g. I=int*, so revert it for now.

PR libstdc++/119888

This reverts commit 51761c50f843d5be4e24172535e4524b5072f24c.

3 months agoaarch64: Update FP8 dependencies for -mcpu=olympus
Kyrylo Tkachov [Tue, 22 Apr 2025 13:17:34 +0000 (06:17 -0700)] 
aarch64: Update FP8 dependencies for -mcpu=olympus

We had not noticed that after g:299a8e2dc667e795991bc439d2cad5ea5bd379e2 the
FP8FMA and FP8DOT4 features aren't implied by FP8FMA.  The intent is for
-mcpu=olympus to support all of them.
Fix the definition to include the relevant sub-features explicitly.

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

* config/aarch64/aarch64-cores.def (olympus): Add fp8fma, fp8dot4
explicitly.

(cherry picked from commit 5d5e8e87a42af8c0d962fa16dc9835fb71778250)

3 months agotestsuite: XFAIL predcom-8.c on aarch64 [PR118407]
Richard Sandiford [Tue, 22 Apr 2025 13:19:51 +0000 (14:19 +0100)] 
testsuite: XFAIL predcom-8.c on aarch64 [PR118407]

gcc.dg/tree-ssa/predcom-8.c fails on aarch64 for the reasons discussed
in the PR trail.  The fix didn't make it into GCC 15, so this patch
XFAILs the test instead.

Other targets might benefit from an XFAIL too, but people who work on
those targets would be better placed to know the right conditions.

gcc/testsuite/
PR tree-optimization/118407
* gcc.dg/tree-ssa/predcom-8.c: Add XFAIL for aarch64.

3 months agocobol: Restrict COBOL to supported Linux arches [PR119217]
Rainer Orth [Tue, 22 Apr 2025 11:47:17 +0000 (13:47 +0200)] 
cobol: Restrict COBOL to supported Linux arches [PR119217]

The COBOL frontend is currently built on all x86_64 and aarch64 hosts
although the code contains some Linux/glibc specifics that break the build
e.g. on Solaris/amd64.

Tested on Linux/x86_64 and Solaris/amd64.

2025-03-17  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

PR cobol/119217
* configure.ac: Restrict cobol to aarch64-*-linux*,
x86_64-*-linux*.
Fix indentation.
* configure: Regenerate.

(cherry picked from commit 6390fc86995fbd5239497cb9e1797a3af51d3936)

3 months agolibstdc++: Update baseline symbols for m68k-linux
Andreas Schwab [Tue, 22 Apr 2025 09:22:09 +0000 (11:22 +0200)] 
libstdc++: Update baseline symbols for m68k-linux

* config/abi/post/m68k-linux-gnu/baseline_symbols.txt: Update.

(cherry picked from commit f9cfb3735cf301c4b943d9ed1cd8b887e11d6be5)

3 months agolibstdc++: Update baseline symbols for riscv64-linux
Andreas Schwab [Tue, 22 Apr 2025 10:39:35 +0000 (12:39 +0200)] 
libstdc++: Update baseline symbols for riscv64-linux

* config/abi/post/riscv64-linux-gnu/baseline_symbols.txt: Update.

(cherry picked from commit 89259795a5a6e637144c7054e7c09c5182d1df56)

3 months agoDocument locality partitioning params in invoke.texi
Kyrylo Tkachov [Thu, 17 Apr 2025 17:50:44 +0000 (10:50 -0700)] 
Document locality partitioning params in invoke.texi

Filip Kastl pointed out that contrib/check-params-in-docs.py complains
about params not documented in invoke.texi, so this patch adds the short
explanation from params.opt for these to the invoke.texi section.
Thanks for the reminder.

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

* doc/invoke.texi (lto-partition-locality-frequency-cutoff,
lto-partition-locality-size-cutoff, lto-max-locality-partition):
Document.

(cherry picked from commit b7fb18dcf79476aa30ed2ad6cc2eaeab1f266107)

3 months agolibstdc++: Update Linux/sparc64 baselines for GCC 15.1
Rainer Orth [Tue, 22 Apr 2025 09:38:19 +0000 (11:38 +0200)] 
libstdc++: Update Linux/sparc64 baselines for GCC 15.1

The Linux/sparc64 libstdc++ baselines haven't been updated for years.
This patch fixes that.

Tested on sparc64-unknown-linux-gnu on both the gcc-15 branch and trunk.

2025-04-21  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libstdc++-v3:
* config/abi/post/sparc64-linux-gnu/baseline_symbols.txt: Regenerate.
* config/abi/post/sparc64-linux-gnu/32/baseline_symbols.txt: Likewise.

(cherry picked from commit 496b2ed86c41f50adac99e15c0d1a7c2d5428eba)

3 months agolibstdc++: Update Solaris baselines for GCC 15.1
Rainer Orth [Tue, 22 Apr 2025 09:36:00 +0000 (11:36 +0200)] 
libstdc++: Update Solaris baselines for GCC 15.1

This patch updates the Solaris libstdc++ baselines for GCC 15.1.

Tested on i386-pc-solaris2.11 and sparc-sun-solaris2.11 on both the
gcc-15 branch and trunk.

2025-02-11  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libstdc++-v3:
* config/abi/post/i386-solaris/baseline_symbols.txt: Regenerate.
* config/abi/post/i386-solaris/amd64/baseline_symbols.txt:
Likewise.
* config/abi/post/sparc-solaris/baseline_symbols.txt: Likewise.
* config/abi/post/sparc-solaris/sparcv9/baseline_symbols.txt:
Likewise.

(cherry picked from commit 0c8f5e9f7a3cf5cb853ae485796021653ef4be7c)

3 months agolibstdc++: Update baseline_symbols.txt for {x86_64,i486,powerpc64le,s390x,aarch64...
Jakub Jelinek [Tue, 22 Apr 2025 09:30:46 +0000 (11:30 +0200)] 
libstdc++: Update baseline_symbols.txt for {x86_64,i486,powerpc64le,s390x,aarch64}-linux

We forgot to update these timely, sorry for that, the following patch
updates them from the 15.1-rc1 builds in Fedora.

2025-04-22  Jakub Jelinek  <jakub@redhat.com>

* config/abi/post/x86_64-linux-gnu/baseline_symbols.txt: Update.
* config/abi/post/x86_64-linux-gnu/32/baseline_symbols.txt: Update.
* config/abi/post/i486-linux-gnu/baseline_symbols.txt: Update.
* config/abi/post/aarch64-linux-gnu/baseline_symbols.txt: Update.
* config/abi/post/s390x-linux-gnu/baseline_symbols.txt: Update.
* config/abi/post/powerpc64le-linux-gnu/baseline_symbols.txt: Update.

(cherry picked from commit cbd0d8e76a9403096907c179d2be6c163fb50414)

3 months agotestsuite: Use sigsetjmp in gcc.misc-tests/gcov-31.c
Rainer Orth [Tue, 22 Apr 2025 09:16:09 +0000 (11:16 +0200)] 
testsuite: Use sigsetjmp in gcc.misc-tests/gcov-31.c

The gcc.misc-tests/gcov-31.c test FAILs on Solaris and Darwin:

FAIL: gcc.misc-tests/gcov-31.c (test for excess errors)

Excess errors:
/vol/gcc/src/hg/master/local/gcc/testsuite/gcc.misc-tests/gcov-31.c:23:5:
error: implicit declaration of function '__sigsetjmp'; did you mean
'sigsetjmp'? [-Wimplicit-function-declaration]

__sigsetjmp is a Linux/glibc implementation detail.  Other tests just
use sigsetjmp directly, so this patch follows suit.

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

2025-04-22  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
* gcc.misc-tests/gcov-31.c (run_pending_traps): Use sigsetjmp
instead of __sigsetjmp.

(cherry picked from commit ab41f146cf077b89cff8d86e2f698ed0fabd12d9)

3 months agoDaily bump.
GCC Administrator [Tue, 22 Apr 2025 00:25:49 +0000 (00:25 +0000)] 
Daily bump.

3 months agoDaily bump.
GCC Administrator [Mon, 21 Apr 2025 00:22:33 +0000 (00:22 +0000)] 
Daily bump.

3 months agoDaily bump.
GCC Administrator [Sun, 20 Apr 2025 00:25:24 +0000 (00:25 +0000)] 
Daily bump.

3 months agoDaily bump.
GCC Administrator [Sat, 19 Apr 2025 00:24:55 +0000 (00:24 +0000)] 
Daily bump.

3 months agotree-optimization/119858 - type mismatch with POINTER_PLUS
Richard Biener [Fri, 18 Apr 2025 12:52:41 +0000 (14:52 +0200)] 
tree-optimization/119858 - type mismatch with POINTER_PLUS

The recent PFA early-break vectorization fix left us with a POINTER_PLUS
and non-sizetype offset.

PR tree-optimization/119858
* tree-vect-loop.cc (vectorizable_live_operation): Convert
pointer offset to sizetype.

3 months agoLoongArch: Change {dg-do-what-default} save and restore logical.
Xing Li [Wed, 16 Apr 2025 02:29:57 +0000 (10:29 +0800)] 
LoongArch: Change {dg-do-what-default} save and restore logical.

The set of {dg-do-what-default} to 'run' may lead some test hang
during make check.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/vector/loongarch-vector.exp: Change
{dg-do-what-default} save and restore logical.

(cherry picked from commit dd982198656d914a4958bf86356a4c996c728b9d)

3 months agoDaily bump.
GCC Administrator [Fri, 18 Apr 2025 00:24:20 +0000 (00:24 +0000)] 
Daily bump.

3 months agolibstdc++: Update status tables to refer to GCC 15 not mainline
Jonathan Wakely [Fri, 26 Apr 2024 10:46:01 +0000 (11:46 +0100)] 
libstdc++: Update status tables to refer to GCC 15 not mainline

libstdc++-v3/ChangeLog:

* doc/html/manual/status.html: Regenerate.
* doc/xml/manual/status_cxx1998.xml: Replace references to
mainline GCC.
* doc/xml/manual/status_cxx2011.xml: Likewise.
* doc/xml/manual/status_cxx2014.xml: Likewise.
* doc/xml/manual/status_cxx2017.xml: Likewise.
* doc/xml/manual/status_cxx2020.xml: Likewise.
* doc/xml/manual/status_cxx2023.xml: Likewise.
* doc/xml/manual/status_cxxtr1.xml: Likewise.
* doc/xml/manual/status_cxxtr24733.xml: Likewise.

3 months agoSet DEV-PHASE to prerelease.
Jakub Jelinek [Thu, 17 Apr 2025 10:56:00 +0000 (12:56 +0200)] 
Set DEV-PHASE to prerelease.

2025-04-17  Jakub Jelinek  <jakub@redhat.com>

* DEV-PHASE: Set to prerelease.

3 months agolibgomp: Don't test ompx::allocator::gnu_pinned_mem on non-linux targets.
Jakub Jelinek [Thu, 17 Apr 2025 10:14:15 +0000 (12:14 +0200)] 
libgomp: Don't test ompx::allocator::gnu_pinned_mem on non-linux targets.

The libgomp.c/alloc-pinned*.c test have
/* { dg-skip-if "Pinning not implemented on this host" { ! *-*-linux-gnu* } } */
so they are only run on Linux targets right now.  Duplicating the tests or
reworking them into headers looked like too much work for me right now this
late in stage4, so I've just #ifdefed the uses at least for now.

2025-04-17  Jakub Jelinek  <jakub@redhat.com>

PR libgomp/119849
* testsuite/libgomp.c++/allocator-1.C (test_inequality, main): Guard
ompx::allocator::gnu_pinned_mem uses with #ifdef __gnu_linux__.
* testsuite/libgomp.c++/allocator-2.C (main): Likewise.

3 months agolibstdc++: Fixed signed comparision in _M_parse_fill_and_align [PR119840]
Tomasz Kamiński [Thu, 17 Apr 2025 08:33:10 +0000 (10:33 +0200)] 
libstdc++: Fixed signed comparision in _M_parse_fill_and_align [PR119840]

Explicitly cast elements of __not_fill to _CharT. Only '{' and ':'
are used as `__not_fill`, so they are never negative.

PR libstdc++/119840

libstdc++-v3/ChangeLog:

* include/std/format (_M_parse_fill_and_align): Cast elements of
__not_fill to _CharT.

3 months agomiddle-end: fix masking for partial vectors and early break [PR119351]
Tamar Christina [Thu, 17 Apr 2025 09:25:43 +0000 (10:25 +0100)] 
middle-end: fix masking for partial vectors and early break [PR119351]

The following testcase shows an incorrect masked codegen:

#define N 512
#define START 1
#define END 505

int x[N] __attribute__((aligned(32)));

int __attribute__((noipa))
foo (void)
{
  int z = 0;
  for (unsigned int i = START; i < END; ++i)
    {
      z++;
      if (x[i] > 0)
        continue;

      return z;
    }
  return -1;
}

notice how there's a continue there instead of a break.  This means we generate
a control flow where success stays within the loop iteration:

  mask_patt_9.12_46 = vect__1.11_45 > { 0, 0, 0, 0 };
  vec_mask_and_47 = mask_patt_9.12_46 & loop_mask_41;
  if (vec_mask_and_47 == { -1, -1, -1, -1 })
    goto <bb 4>; [41.48%]
  else
    goto <bb 15>; [58.52%]

However when loop_mask_41 is a partial mask this comparison can lead to an
incorrect match.  In this case the mask is:

  # loop_mask_41 = PHI <next_mask_63(6), { 0, -1, -1, -1 }(2)>

due to peeling for alignment with masking and compiling with
-msve-vector-bits=128.

At codegen time we generate:

ptrue   p15.s, vl4
ptrue   p7.b, vl1
not     p7.b, p15/z, p7.b
.L5:
ld1w    z29.s, p7/z, [x1, x0, lsl 2]
cmpgt   p7.s, p7/z, z29.s, #0
not     p7.b, p15/z, p7.b
ptest   p15, p7.b
b.none  .L2
...<early exit>...

Here the basic blocks are rotated and a not is generated.
But the generated not is unmasked (or predicated over an ALL true mask in this
case).  This has the unintended side-effect of flipping the results of the
inactive lanes (which were zero'd by the cmpgt) into -1.  Which then incorrectly
causes us to not take the branch to .L2.

This is happening because we're not comparing against the right value for the
forall case.  This patch gets rid of the forall case by rewriting the
if(all(mask)) into if (!all(mask)) which is the same as if (any(~mask)) by
negating the masks and flipping the branches.

1. For unmasked loops we simply reduce the ~mask.
2. For masked loops we reduce (~mask & loop_mask) which is the same as
   doing (mask & loop_mask) ^ loop_mask.

For the above we now generate:

.L5:
        ld1w    z28.s, p7/z, [x1, x0, lsl 2]
        cmple   p7.s, p7/z, z28.s, #0
        ptest   p15, p7.b
        b.none  .L2

This fixes gromacs with > 1 OpenMP threads and improves performance.

gcc/ChangeLog:

PR tree-optimization/119351
* tree-vect-stmts.cc (vectorizable_early_exit): Mask both operands of
the gcond for partial masking support.

gcc/testsuite/ChangeLog:

PR tree-optimization/119351
* gcc.target/aarch64/sve/pr119351.c: New test.
* gcc.target/aarch64/sve/pr119351_run.c: New test.

3 months agolibstdc++: Do not use 'not' alternative token in <format>
Jonathan Wakely [Wed, 16 Apr 2025 10:44:46 +0000 (11:44 +0100)] 
libstdc++: Do not use 'not' alternative token in <format>

This fixes:
FAIL: 17_intro/headers/c++1998/operator_names.cc  -std=gnu++23 (test for excess errors)
FAIL: 17_intro/headers/c++1998/operator_names.cc  -std=gnu++26 (test for excess errors)

The purpose of 'not defined<format_kind<R>>' is to be ill-formed (as
required by [format.range.fmtkind]) and to give an error that includes
the string "not defined<format_kind<R>>". That was intended to tell you
that format_kind<R> is not defined, just like it says!

But user code can use -fno-operator-names so we can't use 'not' here,
and "! defined" in the diagnostic doesn't seem as user-friendly. It also
raises questions about whether it was intended to be the preprocessor
token 'defined' (it's not) or where 'defined' is defined (it's not).

Replace it with __primary_template_not_defined<format_kind<R>> and a
comment, which seems to give a fairly clear diagnostic with both GCC and
Clang. The diagnostic now looks like:

.../include/c++/15.0.1/format:5165:7: error: use of 'std::format_kind<int>' before deduction of 'auto'
 5165 |       format_kind<_Rg> // you can specialize this for non-const input ranges
      |       ^~~~~~~~~~~~~~~~
.../include/c++/15.0.1/format:5164:35: error: '__primary_template_not_defined' was not declared in this scope
 5164 |     __primary_template_not_defined(
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
 5165 |       format_kind<_Rg> // you can specialize this for non-const input ranges
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 5166 |     );
      |     ~

libstdc++-v3/ChangeLog:

* include/std/format (format_kind): Do not use 'not'
alternative token to make the primary template ill-formed. Use
the undeclared identifier __primary_template_not_defined and a
comment that will appear in diagnostics.
* testsuite/std/format/ranges/format_kind_neg.cc: New test.

3 months agos390: Use match_scratch instead of scratch in define_split [PR119834]
Jakub Jelinek [Thu, 17 Apr 2025 08:57:18 +0000 (10:57 +0200)] 
s390: Use match_scratch instead of scratch in define_split [PR119834]

The following testcase ICEs since r15-1579 (addition of late combiner),
because *clrmem_short can't be split.
The problem is that the define_insn uses
   (use (match_operand 1 "nonmemory_operand" "n,a,a,a"))
   (use (match_operand 2 "immediate_operand" "X,R,X,X"))
   (clobber (match_scratch:P 3 "=X,X,X,&a"))
and define_split assumed that if operands[1] is const_int_operand,
match_scratch will be always scratch, and it will be reg only if
it was the last alternative where operands[1] is a reg.
The pattern doesn't guarantee it though, of course RA will not try to
uselessly assign a reg there if it is not needed, but during RA
on the testcase below we match the last alternative, but then comes
late combiner and propagates const_int 3 into operands[1].  And that
matches fine, match_scratch matches either scratch or reg and the constraint
in that case is X for the first variant, so still just fine.  But we won't
split that because the splitters only expect scratch.

The following patch fixes it by using match_scratch instead of scratch,
so that it accepts either.

2025-04-17  Jakub Jelinek  <jakub@redhat.com>

PR target/119834
* config/s390/s390.md (define_split after *cpymem_short): Use
(clobber (match_scratch N)) instead of (clobber (scratch)).  Use
(match_dup 4) and operands[4] instead of (match_dup 3) and operands[3]
in the last of those.
(define_split after *clrmem_short): Use (clobber (match_scratch N))
instead of (clobber (scratch)).
(define_split after *cmpmem_short): Likewise.

* g++.target/s390/pr119834.C: New test.

3 months agolibstdc++: Remove dead code in range_formatter::format [PR109162]
Tomasz Kamiński [Wed, 16 Apr 2025 13:28:46 +0000 (15:28 +0200)] 
libstdc++: Remove dead code in range_formatter::format [PR109162]

Because the _M_format(__rg, __fc) were placed outside of if constexpr,
these method and its children  where instantiated, even if
_M_format<const _Range> could be used.

To simplify the if constexpr chain, we introduce a __simply_formattable_range
(name based on simple-view) exposition only concept, that checks if range is
const and mutable formattable and uses same formatter specialization for
references in each case.

PR libstdc++/109162

libstdc++-v3/ChangeLog:

* include/std/format (__format::__simply_formattable_range): Define.
(range_formatter::format): Do not instantiate _M_format for mutable
_Rg if const _Rg can be used.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agonvptx: Remove 'TARGET_ASM_NEED_VAR_DECL_BEFORE_USE'
Thomas Schwinge [Mon, 24 Feb 2025 18:06:28 +0000 (19:06 +0100)] 
nvptx: Remove 'TARGET_ASM_NEED_VAR_DECL_BEFORE_USE'

Unused; remnant of an (internal) experiment, before we had nvptx 'as'.

gcc/
* config/nvptx/nvptx.cc (TARGET_ASM_NEED_VAR_DECL_BEFORE_USE):
Don't '#define'.

3 months agolibgomp.texi: For HIP interop, mention cpp defines to set
Tobias Burnus [Thu, 17 Apr 2025 08:21:05 +0000 (10:21 +0200)] 
libgomp.texi: For HIP interop, mention cpp defines to set

The HIP header files recognize the used compiler, defaulting to either AMD
or Nvidia/CUDA; thus, the alternative way of explicitly defining a macro is
less prominently documented. With GCC, the user has to define the
preprocessor macro manually. Hence, as a service to the user, mention
__HIP_PLATFORM_AMD__ and __HIP_PLATFORM_NVIDIA__ in the interop documentation,
even though it has only indirectly to do with GCC and its interop support.

Note to commit-log readers, only: For Fortran, the hipfort modules can be
used; when compiling the hipfort package (defaults to use gfortran), it
generates the module (*.mod) files in include/hipfort/{amdgcn,nvidia}/ such
that the choice is made by setting the respective include path.

libgomp/ChangeLog:

* libgomp.texi (gcn interop, nvptx interop): For HIP with C/C++, add
a note about setting a preprocessor define.

3 months agod: Fix infinite loop regression in CTFE
Iain Buclaw [Thu, 17 Apr 2025 06:21:40 +0000 (08:21 +0200)] 
d: Fix infinite loop regression in CTFE

An infinite loop was introduced by a previous refactoring in the
semantic pass for DeclarationExp nodes. Ensure the loop properly
terminates and add tests cases.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 956e73d64e.

gcc/testsuite/ChangeLog:

* gdc.test/fail_compilation/test21247.d: New test.
* gdc.test/fail_compilation/test21247b.d: New test.

Reviewed-on: https://github.com/dlang/dmd/pull/21248

3 months agocombine: Correct comments about combine_validate_cost
Hans-Peter Nilsson [Tue, 15 Apr 2025 04:08:36 +0000 (06:08 +0200)] 
combine: Correct comments about combine_validate_cost

Fix misleading comments.  That function only determines whether
replacements cost more; it doesn't actually *validate* costs as being
cheaper.

For example, it returns true also if it for various reasons cannot
determine the costs, or if the new cost is the same, like when doing
an identity replacement.  The code has been the same since
r0-59417-g64b8935d4809f3.

* combine.cc: Correct comments about combine_validate_cost.

3 months agoc++: ill-formed constexpr function [PR113360]
Jason Merrill [Tue, 31 Aug 2021 21:01:22 +0000 (17:01 -0400)] 
c++: ill-formed constexpr function [PR113360]

If we already gave an error while parsing a function, we don't also need to
try to explain what's wrong with it when we later try to use it in a
constant-expression.  In the new testcase explain_invalid_constexpr_fn
couldn't find anything still in the function to complain about, so it said
because: followed by nothing.

We still try to constant-evaluate it to reduce error cascades, but we
shouldn't complain if it doesn't work very well.

This flag is similar to CLASSTYPE_ERRONEOUS that I added a while back.

PR c++/113360

gcc/cp/ChangeLog:

* cp-tree.h (struct language_function): Add erroneous bit.
* constexpr.cc (explain_invalid_constexpr_fn): Return if set.
(cxx_eval_call_expression): Quiet if set.
* parser.cc (cp_parser_function_definition_after_declarator)
* pt.cc (instantiate_body): Set it.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/constexpr-nonlit18.C: Remove redundant message.
* g++.dg/cpp1y/constexpr-diag2.C: New test.
* g++.dg/cpp1y/pr63996.C: Adjust expected errors.
* g++.dg/template/explicit-args6.C: Likewise.
* g++.dg/cpp0x/constexpr-ice21.C: Likewise.

3 months agoDaily bump.
GCC Administrator [Thu, 17 Apr 2025 00:18:03 +0000 (00:18 +0000)] 
Daily bump.

3 months ago[testsuite] [ppc] ipa-sra-19.c: pass -Wno-psabi on powerpc-*-elf as well
Alexandre Oliva [Wed, 16 Apr 2025 22:30:48 +0000 (19:30 -0300)] 
[testsuite] [ppc] ipa-sra-19.c: pass -Wno-psabi on powerpc-*-elf as well

Like other ppc targets, powerpc-*-elf needs -Wno-psabi to compile
gcc.dg/ipa/ipa-sra-19.c without an undesired warning about vector
argument passing.

for  gcc/testsuite/ChangeLog

* gcc.dg/ipa/ipa-sra-19.c: Add -Wno-psabi on ppc-elf too.

3 months agoDoc: Document raw string literals as GNU C extension [PR88382]
Sandra Loosemore [Wed, 16 Apr 2025 22:16:16 +0000 (22:16 +0000)] 
Doc: Document raw string literals as GNU C extension [PR88382]

gcc/ChangeLog
PR c/88382
* doc/extend.texi (Syntax Extensions): Adjust menu.
(Raw String Literals): New section.

3 months agotestsuite: Replace altivec vector attribute with generic equivalent [PR112822]
Peter Bergner [Wed, 16 Apr 2025 21:48:59 +0000 (21:48 +0000)] 
testsuite: Replace altivec vector attribute with generic equivalent [PR112822]

Usage of the altivec vector attribute requires use of the -maltivec option.
Replace with a generic equivalent which allows building the test case on
multiple other targets and non-altivec ppc cpus, but still diagnoses the
ICE on unfixed compilers.

2025-04-16  Peter Bergner  <bergner@linux.ibm.com>

gcc/testsuite/
PR tree-optimization/112822
* g++.dg/pr112822.C: Replace altivec vector attribute with a generic
vector attribute.

3 months agocobol: Eliminate gcc/cobol/LICENSE. [PR119759]
Bob Dubner [Wed, 16 Apr 2025 18:41:06 +0000 (14:41 -0400)] 
cobol: Eliminate gcc/cobol/LICENSE. [PR119759]

gcc/cobol

PR cobol/119759
* LICENSE: Deleted.

3 months ago[PATCH] rx: avoid adding setpsw for rx_cmpstrn when len is const
Keith Packard [Wed, 16 Apr 2025 20:10:18 +0000 (14:10 -0600)] 
[PATCH] rx: avoid adding setpsw for rx_cmpstrn when len is const

pattern using rx_cmpstrn is cmpstrsi for which len is a constant -1,
so we'll be moving the setpsw instructions from rx_cmpstrn to
cmpstrnsi as follows:

 1. Adjust the predicate on the length operand from "register_operand"
    to "nonmemory_operand". This will allow constants to appear here,
    instead of having them already transferred into a register.

 2. Check to see if the len value is constant, and then check if it is
    actually zero. In that case, short-circuit the rest of the pattern
    and set the result register to 0.

 3. Emit 'setpsw c' and 'setpsw z' instructions when the len is not a
    constant, in case it turns out to be zero at runtime.

 4. Remove the two 'setpsw' instructions from rx_cmpstrn.

gcc/
* config/rx/rx.md (cmpstrnsi): Allow constant length.  For
static length 0, just store 0 into the output register.
For dynamic zero, set C/Z appropriately.
(rxcmpstrn): No longer set C/Z.

3 months agoFix wrong optimization of conditional expression with enumeration type
Eric Botcazou [Wed, 16 Apr 2025 20:01:31 +0000 (22:01 +0200)] 
Fix wrong optimization of conditional expression with enumeration type

This is a regression introduced on the mainline and 14 branch by:
  https://gcc.gnu.org/pipermail/gcc-cvs/2023-October/391658.html

The change bypasses int_fits_type_p (essentially) to work around the
signedness constraints, but in doing so disregards the peculiarities
of boolean types whose precision is not 1 dealt with by the predicate,
leading to the creation of a problematic conversion here.

Fixed by special-casing boolean types whose precision is not 1, as done
in several other places.

gcc/
* tree-ssa-phiopt.cc (factor_out_conditional_operation): Do not
bypass the int_fits_type_p test for boolean types whose precision
is not 1.

gcc/testsuite/
* gnat.dg/opt105.adb: New test.
* gnat.dg/opt105_pkg.ads, gnat.dg/opt105_pkg.adb: New helper.

3 months agoDoc: make regenerate-opt-urls
Sandra Loosemore [Wed, 16 Apr 2025 18:51:28 +0000 (18:51 +0000)] 
Doc: make regenerate-opt-urls

gcc/ChangeLog
* common.opt.urls: Regenerated.

3 months agoc++: templates, attributes, #pragma target [PR114772]
Jason Merrill [Wed, 16 Apr 2025 16:02:58 +0000 (12:02 -0400)] 
c++: templates, attributes, #pragma target [PR114772]

Since r12-5426 apply_late_template_attributes suppresses various global
state to avoid applying active pragmas to earlier declarations; we also
need to override target_option_current_node.

PR c++/114772
PR c++/101180

gcc/cp/ChangeLog:

* pt.cc (apply_late_template_attributes): Also override
target_option_current_node.

gcc/testsuite/ChangeLog:

* g++.dg/ext/pragma-target2.C: New test.

3 months agoc++: format attribute redeclaration [PR116954]
Jason Merrill [Wed, 16 Apr 2025 15:15:14 +0000 (11:15 -0400)] 
c++: format attribute redeclaration [PR116954]

Here when merging the two decls, remove_contract_attributes loses
ATTR_IS_DEPENDENT on the format attribute, so apply_late_template_attributes
just returns, so the attribute doesn't get propagated to the type where the
warning looks for it.

Fixed by using copy_node instead of tree_cons to preserve flags.

PR c++/116954

gcc/cp/ChangeLog:

* contracts.cc (remove_contract_attributes): Preserve flags
on the attribute list.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wformat-3.C: New test.

3 months agoi386: Enable -mnop-mcount for -fpic with PLTs [PR119386]
Ard Biesheuvel [Thu, 10 Apr 2025 12:26:41 +0000 (14:26 +0200)] 
i386: Enable -mnop-mcount for -fpic with PLTs [PR119386]

-mnop-mcount can be trivially enabled for -fPIC codegen as long as PLTs
are being used, given that the instruction encodings are identical, only
the target may resolve differently depending on how the linker decides
to incorporate the object file.

So relax the option check, and add a test to ensure that 5-byte NOPs are
emitted when -mnop-mcount is being used.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
gcc/ChangeLog:

PR target/119386
* config/i386/i386-options.cc: Permit -mnop-mcount when
using -fpic with PLTs.

gcc/testsuite/ChangeLog:

PR target/119386
* gcc.target/i386/pr119386-3.c: New test.

3 months agoi386: Prefer PLT indirection for __fentry__ calls under -fPIC [PR119386]
Ard Biesheuvel [Thu, 10 Apr 2025 12:26:40 +0000 (14:26 +0200)] 
i386: Prefer PLT indirection for __fentry__ calls under -fPIC [PR119386]

Commit bde21de1205 ("i386: Honour -mdirect-extern-access when calling
__fentry__") updated the logic that emits mcount() / __fentry__() calls
into function prologues when profiling is enabled, to avoid GOT-based
indirect calls when a direct call would suffice.

There are two problems with that change:
- it relies on -mdirect-extern-access rather than -fno-plt to decide
  whether or not a direct [PLT based] call is appropriate;
- for the PLT case, it falls through to x86_print_call_or_nop(), which
  does not emit the @PLT suffix, resulting in the wrong relocation to be
  used (R_X86_64_PC32 instead of R_X86_64_PLT32)

Fix this by testing flag_plt instead of ix86_direct_extern_access, and
updating x86_print_call_or_nop() to take flag_pic and flag_plt into
account. This also ensures that -mnop-mcount works as expected when
emitting the PLT based profiling calls.

While at it, fix the 32-bit logic as well, and issue a PLT call unless
PLTs are explicitly disabled.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119386

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
gcc/ChangeLog:

PR target/119386
* config/i386/i386.cc (x86_print_call_or_nop): Add @PLT suffix
where appropriate.
(x86_function_profiler): Fall through to x86_print_call_or_nop()
for PIC codegen when flag_plt is set.

gcc/testsuite/ChangeLog:

PR target/119386
* gcc.target/i386/pr119386-1.c: New test.
* gcc.target/i386/pr119386-2.c: New test.

3 months agoDoc: Add pointer to --help use to main entry for -Q option [PR90465]
Sandra Loosemore [Wed, 16 Apr 2025 18:17:11 +0000 (18:17 +0000)] 
Doc: Add pointer to --help use to main entry for -Q option [PR90465]

-Q does something completely different in conjunction with --help than it
does otherwise; its main entry in the manual didn't mention that, nor did
-Q have an entry in the index for the --help usage.

gcc/ChangeLog
PR driver/90465
* doc/invoke.texi (Overall Options): Add a @cindex for -Q in
connection with --help=.
(Developer Options): Point at --help= documentation for the
other use of -Q.

3 months agoFortran: pure subroutine with pure procedure as dummy [PR106948]
Harald Anlauf [Tue, 15 Apr 2025 18:43:05 +0000 (20:43 +0200)] 
Fortran: pure subroutine with pure procedure as dummy [PR106948]

PR fortran/106948

gcc/fortran/ChangeLog:

* resolve.cc (gfc_pure_function): If a function has been resolved,
but esym is not yet set, look at its attributes to see whether it
is pure or elemental.

gcc/testsuite/ChangeLog:

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

3 months agoRemove 'ALWAYS_INLINE' workaround in 'libgomp.c++/target-exceptions-pr118794-1.C'
Thomas Schwinge [Wed, 16 Apr 2025 14:52:08 +0000 (16:52 +0200)] 
Remove 'ALWAYS_INLINE' workaround in 'libgomp.c++/target-exceptions-pr118794-1.C'

With commit ca9cffe737d20953082333dacebb65d4261e0d0c
"For nvptx offloading, make sure to emit C++ constructor, destructor aliases [PR97106]",
we're able to remove the 'ALWAYS_INLINE' workaround added in
commit fe283dba774be57b705a7a871b000d2894d2e553
"GCN, nvptx: Support '-mfake-exceptions', and use it for offloading compilation [PR118794]".

libgomp/
* testsuite/libgomp.c++/target-exceptions-pr118794-1.C: Remove
'ALWAYS_INLINE' workaround.

3 months agolibatomic: Fix up libat_{,un}lock_n for mingw [PR119796]
Jakub Jelinek [Wed, 16 Apr 2025 15:22:49 +0000 (17:22 +0200)] 
libatomic: Fix up libat_{,un}lock_n for mingw [PR119796]

Here is just a port of the previously posted patch to mingw which
clearly has the same problems.

2025-04-16  Jakub Jelinek  <jakub@redhat.com>

PR libgcc/101075
PR libgcc/119796
* config/mingw/lock.c (libat_lock_n, libat_unlock_n): Start with
computing how many locks will be needed and take into account
((uintptr_t)ptr % WATCH_SIZE).  If some locks from the end of the
locks array and others from the start of it will be needed, first
lock the ones from the start followed by ones from the end.

3 months agolibatomic: Fix up libat_{,un}lock_n [PR119796]
Jakub Jelinek [Wed, 16 Apr 2025 15:21:39 +0000 (17:21 +0200)] 
libatomic: Fix up libat_{,un}lock_n [PR119796]

As mentioned in the PR (and I think in PR101075 too), we can run into
deadlock with libat_lock_n calls with larger n.
As mentioned in PR66842, we use multiple locks (normally 64 mutexes
for each 64 byte cache line in 4KiB page) and currently can lock more
than one lock, in particular for n [0, 64] a single lock, for n [65, 128]
2 locks, for n [129, 192] 3 locks etc.
There are two problems with this:
1) we can deadlock if there is some wrap-around, because the locks are
   acquired always in the order from addr_hash (ptr) up to
   locks[NLOCKS-1].mutex and then if needed from locks[0].mutex onwards;
   so if e.g. 2 threads perform libat_lock_n with n = 2048+64, in one
   case at pointer starting at page boundary and in another case at
   page boundary + 2048 bytes, the first thread can lock the first
   32 mutexes, the second thread can lock the last 32 mutexes and
   then first thread wait for the lock 32 held by second thread and
   second thread wait for the lock 0 held by the first thread;
   fixed below by always locking the locks in order of increasing
   index, if there is a wrap-around, by locking in 2 loops, first
   locking some locks at the start of the array and second at the
   end of it
2) the number of locks seems to be determined solely depending on the
   n value, I think that is wrong, we don't know the structure alignment
   on the libatomic side, it could very well be 1 byte aligned struct,
   and so how many cachelines are actually (partly or fully) occupied
   by the atomic access depends not just on the size, but also on
   ptr % WATCH_SIZE, e.g. 2 byte structure at address page_boundary+63
   should IMHO lock 2 locks because it occupies the first and second
   cacheline

Note, before this patch it locked exactly one lock for n = 0, while
with this patch it could lock either no locks at all (if it is at cacheline
boundary) or 1 (otherwise).
Dunno of libatomic APIs can be called for zero sizes and whether
we actually care that much how many mutexes are locked in that case,
because one can't actually read/write anything into zero sized memory.
If you think it is important, I could add else if (nlocks == 0) nlocks = 1;
in both spots.

2025-04-16  Jakub Jelinek  <jakub@redhat.com>

PR libgcc/101075
PR libgcc/119796
* config/posix/lock.c (libat_lock_n, libat_unlock_n): Start with
computing how many locks will be needed and take into account
((uintptr_t)ptr % WATCH_SIZE).  If some locks from the end of the
locks array and others from the start of it will be needed, first
lock the ones from the start followed by ones from the end.

3 months agoAdd 'libgomp.c++/pr106445-1{,-O0}.C' [PR106445]
Thomas Schwinge [Thu, 20 Mar 2025 16:25:14 +0000 (17:25 +0100)] 
Add 'libgomp.c++/pr106445-1{,-O0}.C' [PR106445]

PR target/106445
libgomp/
* testsuite/libgomp.c++/pr106445-1.C: New.
* testsuite/libgomp.c++/pr106445-1-O0.C: Likewise.

3 months agoFor nvptx offloading, make sure to emit C++ constructor, destructor aliases [PR97106]
Thomas Schwinge [Wed, 16 Apr 2025 12:00:31 +0000 (14:00 +0200)] 
For nvptx offloading, make sure to emit C++ constructor, destructor aliases [PR97106]

PR target/97106
gcc/
* config/nvptx/nvptx.cc (nvptx_asm_output_def_from_decls)
[ACCEL_COMPILER]: Make sure to emit C++ constructor, destructor
aliases.
libgomp/
* testsuite/libgomp.c++/pr96390.C: Un-XFAIL nvptx offloading.
* testsuite/libgomp.c-c++-common/pr96390.c: Adjust.

3 months agoStream ipa_return_value_summary
Jan Hubicka [Wed, 16 Apr 2025 13:28:32 +0000 (15:28 +0200)] 
Stream ipa_return_value_summary

Add streaming of return summaries from compile time to ltrans
which are now needed for vrp to not ouput false errors on musttail.

Co-authored-by: Jakub Jelinek <jakub@redhat.com>
gcc/ChangeLog:
PR tree-optimization/119614

* ipa-prop.cc (ipa_write_return_summaries): New function.
(ipa_record_return_value_range_1): Break out from ....
(ipa_record_return_value_range): ... here.
(ipa_read_return_summaries): New function.
(ipa_prop_read_section): Read return summaries.
(read_ipcp_transformation_info): Read return summaries.
(ipcp_write_transformation_summaries): Write return summaries;
do not stream stray 0.

gcc/testsuite/ChangeLog:

* g++.dg/lto/pr119614_0.C: New test.

3 months agoMAINTAINERS: Add myself to Write After Approval
Waffl3x [Wed, 16 Apr 2025 13:26:50 +0000 (07:26 -0600)] 
MAINTAINERS: Add myself to Write After Approval

ChangeLog:

* MAINTAINERS: Add myself.

3 months agolibstdc++: Fix constification in range_formatter::format [PR109162]
Tomasz Kamiński [Wed, 16 Apr 2025 11:39:04 +0000 (13:39 +0200)] 
libstdc++: Fix constification in range_formatter::format [PR109162]

The _Rg is deduced to lvalue reference for the lvalue arguments,
and in such case __format::__maybe_const_range<_Rg, _CharT> is always _Rg
(adding const to reference does not change behavior).

Now we correctly check if _Range = remove_reference_t<_Rg> is const
formattable range, furthermore as range_formatter<T> can only format
ranges of values of type (possibly const) _Tp, we additional check if the
remove_cvref_t<range_reference_t<const _Range>> is _Tp.

The range_reference_t<R> and range_reference_t<const R> have different
types (modulo remove_cvref_t) for std::vector<bool> (::reference and bool)
or flat_map<T, U> (pair<const T&, U&> and pair<const T&, const U&>).

PR libstdc++/109162

libstdc++-v3/ChangeLog:

* include/std/format (range_formatter::format): Format const range,
only if reference type is not changed.
* testsuite/std/format/ranges/formatter.cc: New tests.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agomiddle-end: force AMDGCN test for vect-early-break_18.c to consistent architecture...
Tamar Christina [Wed, 16 Apr 2025 12:11:20 +0000 (13:11 +0100)] 
middle-end: force AMDGCN test for vect-early-break_18.c to consistent architecture [PR119286]

The given test is intended to test vectorization of a strided access done by
having a step of > 1.

GCN target doesn't support load lanes, so the testcase is expected to fail,
other targets create a permuted load here which we then then reject.

However some GCN arch don't seem to support the permuted loads either, so the
vectorizer tries a gather/scatter.  But the indices aren't supported by some
target, so instead the vectorizer scalarizes the loads.

I can't really test for which architecture is being used by the compiler, so
instead this updates the testcase to use one single architecture so we get a
consistent result.

gcc/testsuite/ChangeLog:

PR target/119286
* gcc.dg/vect/vect-early-break_18.c: Force -march=gfx908 for amdgcn.

3 months agomiddle-end: Fix incorrect codegen with PFA and VLS [PR119351]
Tamar Christina [Wed, 16 Apr 2025 12:09:05 +0000 (13:09 +0100)] 
middle-end: Fix incorrect codegen with PFA and VLS [PR119351]

The following example:

#define N 512
#define START 2
#define END 505

int x[N] __attribute__((aligned(32)));

int __attribute__((noipa))
foo (void)
{
  for (signed int i = START; i < END; ++i)
    {
      if (x[i] == 0)
        return i;
    }
  return -1;
}

generates incorrect code with fixed length SVE because for early break we need
to know which value to start the scalar loop with if we take an early exit.

Historically this means that we take the first element of every induction.
this is because there's an assumption in place, that even with masked loops the
masks come from a whilel* instruction.

As such we reduce using a BIT_FIELD_REF <, 0>.

When PFA was added this assumption was correct for non-masked loop, however we
assumed that PFA for VLA wouldn't work for now, and disabled it using the
alignment requirement checks.  We also expected VLS to PFA using scalar loops.

However as this PR shows, for VLS the vectorizer can, and does in some
circumstances choose to peel using masks by masking the first iteration of the
loop with an additional alignment mask.

When this is done, the first elements of the predicate can be inactive. In this
example element 1 is inactive based on the calculated misalignment.  hence the
-1 value in the first vector IV element.

When we reduce using BIT_FIELD_REF we get the wrong value.

This patch updates it by creating a new scalar PHI that keeps track of whether
we are the first iteration of the loop (with the additional masking) or whether
we have taken a loop iteration already.

The generated sequence:

pre-header:
  bb1:
    i_1 = <number of leading inactive elements>

header:
  bb2:
    i_2 = PHI <i_1(bb1), 0(latch)>
    …

early-exit:
  bb3:
    i_3 = iv_step * i_2 + PHI<vector-iv>

Which eliminates the need to do an expensive mask based reduction.

This fixes gromacs with one OpenMP thread. But with > 1 there is still an issue.

gcc/ChangeLog:

PR tree-optimization/119351
* tree-vectorizer.h (LOOP_VINFO_MASK_NITERS_PFA_OFFSET,
LOOP_VINFO_NON_LINEAR_IV): New.
(class _loop_vec_info): Add mask_skip_niters_pfa_offset and
nonlinear_iv.
* tree-vect-loop.cc (_loop_vec_info::_loop_vec_info): Initialize them.
(vect_analyze_scalar_cycles_1): Record non-linear inductions.
(vectorizable_induction): If early break and PFA using masking create a
new phi which tracks where the scalar code needs to start...
(vectorizable_live_operation): ...and generate the adjustments here.
(vect_use_loop_mask_for_alignment_p): Reject non-linear inductions and
early break needing peeling.

gcc/testsuite/ChangeLog:

PR tree-optimization/119351
* gcc.target/aarch64/sve/peel_ind_10.c: New test.
* gcc.target/aarch64/sve/peel_ind_10_run.c: New test.
* gcc.target/aarch64/sve/peel_ind_5.c: New test.
* gcc.target/aarch64/sve/peel_ind_5_run.c: New test.
* gcc.target/aarch64/sve/peel_ind_6.c: New test.
* gcc.target/aarch64/sve/peel_ind_6_run.c: New test.
* gcc.target/aarch64/sve/peel_ind_7.c: New test.
* gcc.target/aarch64/sve/peel_ind_7_run.c: New test.
* gcc.target/aarch64/sve/peel_ind_8.c: New test.
* gcc.target/aarch64/sve/peel_ind_8_run.c: New test.
* gcc.target/aarch64/sve/peel_ind_9.c: New test.
* gcc.target/aarch64/sve/peel_ind_9_run.c: New test.

3 months agolibstdc++: Implement formatters for pair and tuple [PR109162]
Tomasz Kamiński [Mon, 14 Apr 2025 14:00:57 +0000 (16:00 +0200)] 
libstdc++: Implement formatters for pair and tuple [PR109162]

This patch implements formatter specializations for pair and tuple form
P2286R8. In addition using 'm` and range_format::map (from P2585R1) for
ranges are now supported.

The formatters for pairs and tuples whose corresponding elements are the same
(after applying remove_cvref_t) derive from the same __tuple_formatter class.
This reduce the code duplication, as most of the parsing and formatting is the
same in such cases. We use a custom reduced implementation of the tuple
(__formatters_storage) to store the elements formatters.

Handling of the padding (width and fill) options, is extracted to
__format::__format_padded function, that is used both by __tuple_formatter and
range_formatter. To reduce number of instantations range_formatter::format
triggers, we cast incoming range to __format::__maybe_const_range<_Rg, _CharT>&,
before formatting it.

As in the case of previous commits, the signatures of the user-facing parse
and format methods of the provided formatters deviate from the standard by
constraining types of parameters:
* _CharT is constrained __formatter::__char
* basic_format_parse_context<_CharT> for parse argument
* basic_format_context<_Out, _CharT> for format second argument
The standard specifies last three of above as unconstrained types.

Finally, test for tuple-like std::array and std::ranges::subrange,
that illustrate that they remain formatted as ranges.

PR libstdc++/109162

libstdc++-v3/ChangeLog:

* include/std/format (__formatter_int::_M_format_character_escaped)
(__formatter_str::format): Use __sink.out() to produce _Sink_iter.
(__format::__const_formattable_range): Moved closer to range_formatter.
(__format::__maybe_const_range): Use `__conditional_t` and moved closer
to range_formatter.
(__format::__format_padded, __format::maybe_const)
(__format::__indexed_formatter_storage, __format::__tuple_formatter)
(std::formatter<pair<_Fp, _Sp>, _CharT>>)
(std::formatter<tuple<_Tps...>, _CharT): Define.
(std::formatter<_Rg, _CharT>::format): Cast incoming range to
__format::__maybe_const_range<_Rg, _CharT>&.
(std::formatter<_Rg, _CharT>::_M_format): Extracted from format,
and use __format_padded.
(std::formatter<_Rg, _CharT>::_M_format_no_padding): Rename...
(std::formatter<_Rg, _CharT>::_M_format_elems): ...to this.
(std::formatter<_Rg, _CharT>::_M_format_with_padding): Extracted as
__format_padded.
* testsuite/util/testsuite_iterators.h (test_input_range_nocopy):
Define.
* testsuite/std/format/ranges/formatter.cc: Tests for `m` specifier.
* testsuite/std/format/ranges/sequence.cc: Tests for array and subrange.
* testsuite/std/format/ranges/map.cc: New test.
* testsuite/std/format/tuple.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agobitintlower: Fix interaction of gimple_assign_copy_p stmts vs. has_single_use [PR119808]
Jakub Jelinek [Wed, 16 Apr 2025 07:11:06 +0000 (09:11 +0200)] 
bitintlower: Fix interaction of gimple_assign_copy_p stmts vs. has_single_use [PR119808]

The following testcase is miscompiled, because we emit a CLOBBER in a place
where it shouldn't be emitted.
Before lowering we have:
  b_5 = 0;
  b.0_6 = b_5;
  b.1_1 = (unsigned _BitInt(129)) b.0_6;
...
  <retval> = b_5;
The bitint coalescing assigns the same partition/underlying variable
for both b_5 and b.0_6 (possible because there is a copy assignment)
and of course a different one for b.1_1 (and other SSA_NAMEs in between).
This is -O0 so stmts aren't DCEd and aren't propagated that much etc.
It is -O0 so we also don't try to optimize and omit some names from m_names
and handle multiple stmts at once, so the expansion emits essentially
  bitint.4 = {};
  bitint.4 = bitint.4;
  bitint.2 = cast of bitint.4;
  bitint.4 = CLOBBER;
...
  <retval> = bitint.4;
and the CLOBBER is the problem because bitint.4 is still live afterwards.
We emit the clobbers to improve code generation, but do it only for
(initially) has_single_use SSA_NAMEs (remembered in m_single_use_names)
being used, if they don't have the same partition on the lhs and a few
other conditions.
The problem above is that b.0_6 which is used in the cast has_single_use
and so was in m_single_use_names bitmask and the lhs in that case is
bitint.2, so a different partition.  But there is gimple_assign_copy_p
with SSA_NAME rhs1 and the partitioning special cases those and while
b.0_6 is single use, b_5 has multiple uses.  I believe this ought to be
a problem solely in the case of such copy stmts and its special case
by the partitioning, if instead of b.0_6 = b_5; there would be
b.0_6 = b_5 + 1; or whatever other stmts that performs or may perform
changes on the value, partitioning couldn't assign the same partition
to b.0_6 and b_5 if b_5 is used later, it couldn't have two different
(or potentially different) values in the same bitint.N var.  With
copy that is possible though.

So the following patch fixes it by being more careful when we set
m_single_use_names, don't set it if it is a has_single_use SSA_NAME
but SSA_NAME_DEF_STMT of it is a copy stmt with SSA_NAME rhs1 and that
rhs1 doesn't have single use, or has_single_use but SSA_NAME_DEF_STMT of it
is a copy stmt etc.

Just to make sure it doesn't change code generation too much, I've gathered
statistics how many times
      if (m_first
          && m_single_use_names
          && m_vars[p] != m_lhs
          && m_after_stmt
          && bitmap_bit_p (m_single_use_names, SSA_NAME_VERSION (op)))
        {
          tree clobber = build_clobber (TREE_TYPE (m_vars[p]),
                                        CLOBBER_STORAGE_END);
          g = gimple_build_assign (m_vars[p], clobber);
          gimple_stmt_iterator gsi = gsi_for_stmt (m_after_stmt);
          gsi_insert_after (&gsi, g, GSI_SAME_STMT);
        }
emits a clobber on
make check-gcc GCC_TEST_RUN_EXPENSIVE=1 RUNTESTFLAGS="--target_board=unix\{-m64,-m32\} GCC_TEST_RUN_EXPENSIVE=1 dg.exp='*bitint* pr112673.c builtin-stdc-bit-*.c pr112566-2.c pr112511.c pr116588.c pr116003.c pr113693.c pr113602.c flex-array-counted-by-7.c' dg-torture.exp='*bitint* pr116480-2.c pr114312.c pr114121.c' dfp.exp=*bitint* i386.exp='pr118017.c pr117946.c apx-ndd-x32-2a.c' vect.exp='vect-early-break_99-pr113287.c' tree-ssa.exp=pr113735.c"
and before this patch it was 41010 clobbers and after it is 40968,
so difference is 42 clobbers, 0.1% fewer.

2025-04-16  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/119808
* gimple-lower-bitint.cc (gimple_lower_bitint): Don't set
m_single_use_names bits for SSA_NAMEs which have single use but
their SSA_NAME_DEF_STMT is a copy from another SSA_NAME which doesn't
have a single use, or single use which is such a copy etc.

* gcc.dg/bitint-121.c: New test.

3 months agoriscv: Fix incorrect gnu property alignment on rv32
Jesse Huang [Fri, 11 Apr 2025 04:25:21 +0000 (21:25 -0700)] 
riscv: Fix incorrect gnu property alignment on rv32

Codegen is incorrectly emitting a ".p2align 3" that coerces the
alignment of the .note.gnu.property section from 4 to 8 on rv32.

2025-04-11  Jesse Huang  <jesse.huang@sifive.com>

gcc/ChangeLog

* config/riscv/riscv.cc (riscv_file_end): Fix .p2align value.

gcc/testsuite/ChangeLog

* gcc.target/riscv/gnu-property-align-rv32.c: New file.
* gcc.target/riscv/gnu-property-align-rv64.c: New file.

3 months agoRISC-V: Put jump table in text for large code model
Kito Cheng [Mon, 14 Apr 2025 08:03:07 +0000 (16:03 +0800)] 
RISC-V: Put jump table in text for large code model

Large code model assume the data or rodata may put far away from
text section.  So we need to put jump table in text section for
large code model.

gcc/ChangeLog:

* config/riscv/riscv.h (JUMP_TABLES_IN_TEXT_SECTION): Check if
large code model.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/jump-table-large-code-model.c: New test.

3 months agotestsuite: Add testcase for already fixed PR [PR116093]
Jakub Jelinek [Wed, 16 Apr 2025 06:42:35 +0000 (08:42 +0200)] 
testsuite: Add testcase for already fixed PR [PR116093]

This testcase got fixed with r15-9397 PR119722 fix.

2025-04-16  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/116093
* gcc.dg/bitint-122.c: New test.

3 months agoAArch64: Fix operands order in vec_extract expander
Tejas Belagod [Sat, 12 Apr 2025 19:38:00 +0000 (01:08 +0530)] 
AArch64: Fix operands order in vec_extract expander

The operand order to gen_vcond_mask call in the vec_extract pattern is wrong.
Fix the order where predicate is operand 3.

Tested and bootstrapped on aarch64-linux-gnu. OK for trunk?

gcc/ChangeLog

* config/aarch64/aarch64-sve.md (vec_extract<vpred><Vel>): Fix operand
order to gen_vcond_mask_*.

3 months agoaarch64: Disable sysreg feature gating
Alice Carlotti [Tue, 15 Apr 2025 16:36:25 +0000 (17:36 +0100)] 
aarch64: Disable sysreg feature gating

This applies to the sysreg read/write intrinsics __arm_[wr]sr*.  It does
not depend on changes to Binutils, because GCC converts recognised
sysreg names to an encoding based form, which is already ungated in Binutils.

We have, however, agreed to make an equivalent change in Binutils (which
would then disable feature gating for sysreg accesses in inline
assembly), but this has not yet been posted upstream.

In the future we may introduce a new flag to renable some checking,
but these checks could not be comprehensive because many system
registers depend on architecture features that don't have corresponding
GCC/GAS --march options.  This would also depend on addressing numerous
inconsistencies in the existing list of sysreg feature dependencies.

gcc/ChangeLog:

* config/aarch64/aarch64.cc
(aarch64_valid_sysreg_name_p): Remove feature check.
(aarch64_retrieve_sysreg): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/acle/rwsr-ungated.c: New test.

3 months agoDaily bump.
GCC Administrator [Wed, 16 Apr 2025 00:18:18 +0000 (00:18 +0000)] 
Daily bump.

3 months agod: Fix ICE: type variant differs by TYPE_MAX_VALUE with -g [PR119826]
Iain Buclaw [Tue, 15 Apr 2025 23:28:53 +0000 (01:28 +0200)] 
d: Fix ICE: type variant differs by TYPE_MAX_VALUE with -g [PR119826]

Forward referenced enum types were never fixed up after the main
ENUMERAL_TYPE was finished.  All flags set are now propagated to all
variants after its mode, size, and alignment has been calculated.

PR d/119826

gcc/d/ChangeLog:

* types.cc (TypeVisitor::visit (TypeEnum *)): Propagate flags of main
enum types to all forward-referenced variants.

gcc/testsuite/ChangeLog:

* gdc.dg/debug/imports/pr119826b.d: New test.
* gdc.dg/debug/pr119826.d: New test.

3 months agoc++: Prune lambda captures from more places [PR119755]
Nathaniel Shead [Sun, 13 Apr 2025 02:20:37 +0000 (12:20 +1000)] 
c++: Prune lambda captures from more places [PR119755]

Currently, pruned lambda captures are still leftover in the function's
BLOCK and topmost BIND_EXPR; this doesn't cause any issues for normal
compilation, but does break modules streaming as we try to reconstruct a
FIELD_DECL that no longer exists on the type itself.

PR c++/119755

gcc/cp/ChangeLog:

* lambda.cc (prune_lambda_captures): Remove pruned capture from
function's BLOCK_VARS and BIND_EXPR_VARS.

gcc/testsuite/ChangeLog:

* g++.dg/modules/lambda-10_a.H: New test.
* g++.dg/modules/lambda-10_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agotestsuite: Fix up completion-2.c test
Jakub Jelinek [Tue, 15 Apr 2025 22:30:09 +0000 (00:30 +0200)] 
testsuite: Fix up completion-2.c test

The r15-9487 change has added -flto-partition=default, which broke
the completion-2.c testcase because that case is now also printed
during completion.

2025-04-16  Jakub Jelinek  <jakub@redhat.com>

* gcc.dg/completion-2.c: Expect also -flto-partition=default line.

3 months agolibgomp.texi (gcn, nvptx): Mention self_maps alongside USM
Tobias Burnus [Tue, 15 Apr 2025 21:19:50 +0000 (23:19 +0200)] 
libgomp.texi (gcn, nvptx): Mention self_maps alongside USM

libgomp/ChangeLog:

* libgomp.texi (gcn, nvptx): Mention self_maps clause
besides unified_shared_memory in the requirements item.

3 months agoc: Fully fold each parameter for call to .ACCESS_WITH_SIZE [PR119717]
Qing Zhao [Mon, 14 Apr 2025 19:41:12 +0000 (19:41 +0000)] 
c: Fully fold each parameter for call to .ACCESS_WITH_SIZE [PR119717]

C_MAYBE_CONST_EXPR is a C FE operator that will be removed by c_fully_fold.
In c_fully_fold, it assumes that operands of function calls have already
been folded. However, when we build call to .ACCESS_WITH_SIZE, all its
operands are not fully folded. therefore the C FE specific operator is
passed to middle-end.

In order to fix this issue, fully fold the parameters before building the
call to .ACCESS_WITH_SIZE.

PR c/119717

gcc/c/ChangeLog:

* c-typeck.cc (build_access_with_size_for_counted_by): Fully fold the
parameters for call to .ACCESS_WITH_SIZE.

gcc/testsuite/ChangeLog:

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

3 months agoOpenMP: omp.h omp::allocator C++ Allocator interface
waffl3x [Tue, 15 Apr 2025 20:34:38 +0000 (14:34 -0600)] 
OpenMP: omp.h omp::allocator C++ Allocator interface

The implementation of each allocator is simplified by inheriting from
__detail::__allocator_templ.  At the moment, none of the implementations
diverge in any way, simply passing in the allocator handle to be used when
an allocation is made.  In the future, const_mem will need special handling
added to it to support constant memory space.

libgomp/ChangeLog:

* omp.h.in: Add omp::allocator::* and ompx::allocator::* allocators.
(__detail::__allocator_templ<T, omp_allocator_handle_t>):
New struct template.
(null_allocator<T>): New struct template.
(default_mem<T>): Likewise.
(large_cap_mem<T>): Likewise.
(const_mem<T>): Likewise.
(high_bw_mem<T>): Likewise.
(low_lat_mem<T>): Likewise.
(cgroup_mem<T>): Likewise.
(pteam_mem<T>): Likewise.
(thread_mem<T>): Likewise.
(ompx::allocator::gnu_pinned_mem<T>): Likewise.
* testsuite/libgomp.c++/allocator-1.C: New test.
* testsuite/libgomp.c++/allocator-2.C: New test.

Signed-off-by: waffl3x <waffl3x@baylibre.com>
3 months agox86: Update gcc.target/i386/apx-interrupt-1.c
H.J. Lu [Mon, 14 Apr 2025 22:49:26 +0000 (15:49 -0700)] 
x86: Update gcc.target/i386/apx-interrupt-1.c

ix86_add_cfa_restore_note omits the REG_CFA_RESTORE REG note for registers
pushed in red-zone.  Since

commit 0a074b8c7e79f9d9359d044f1499b0a9ce9d2801
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sun Apr 13 12:20:42 2025 -0700

    APX: Don't use red-zone with 32 GPRs and no caller-saved registers

disabled red-zone, update gcc.target/i386/apx-interrupt-1.c to expect
31 .cfi_restore directives.

PR target/119784
* gcc.target/i386/apx-interrupt-1.c: Expect 31 .cfi_restore
directives.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 months agoDocs: Address -fivopts, -O0, and -Q confusion [PR71094]
Sandra Loosemore [Tue, 15 Apr 2025 18:37:37 +0000 (18:37 +0000)] 
Docs: Address -fivopts, -O0, and -Q confusion [PR71094]

There's a blurb at the top of the "Optimize Options" node telling
people that most optimization options are completely disabled at -O0
and a similar blurb in the entry for -Og, but nothing at the entry for
-O0.  Since this is a continuing point of confusion it seems wise to
duplicate the information in all the places users are likely to look
for it.

gcc/ChangeLog
PR tree-optimization/71094
* doc/invoke.texi (Optimize Options): Document that -fivopts is
enabled at -O1 and higher.  Add blurb about -O0 causing GCC to
completely ignore most optimization options.

3 months agoc++: constexpr, trivial, and non-alias target [PR111075]
Jason Merrill [Tue, 15 Apr 2025 15:23:57 +0000 (11:23 -0400)] 
c++: constexpr, trivial, and non-alias target [PR111075]

On Darwin and other targets with !can_alias_cdtor, we instead go to
maybe_thunk_ctor, which builds a thunk function that calls the general
constructor.  And then cp_fold tries to constant-evaluate that call, and we
ICE because we don't expect to ever be asked to constant-evaluate a call to
a trivial function.

No new test because this fixes g++.dg/torture/tail-padding1.C on affected
targets.

PR c++/111075

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_call_expression): Allow trivial
call from a thunk.

3 months agoconfigure, Darwin: Recognise new naming for Xcode ld.
Iain Sandoe [Tue, 15 Apr 2025 13:02:21 +0000 (14:02 +0100)] 
configure, Darwin: Recognise new naming for Xcode ld.

The latest editions of XCode have altered the identify reported by 'ld -v'
(again).  This means that GCC configure no longer detects the version.

Fixed by adding the new name to the set checked.

gcc/ChangeLog:

* configure: Regenerate.
* configure.ac: Recognise PROJECT:ld-mmmm.nn.aa as an identifier
for Darwin's static linker.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
3 months agoincludes, Darwin: Handle modular use for macOS SDKs [PR116827].
Iain Sandoe [Sun, 29 Dec 2024 23:06:54 +0000 (23:06 +0000)] 
includes, Darwin: Handle modular use for macOS SDKs [PR116827].

Recent changes to the OS SDKs have altered the way in which include guards
are used for a number of headers when C++ modules are enabled.  Instead of
placing the guards in the included header, they are being placed in the
including header.  This breaks the assumptions in the current GCC stddef.h
specifically, that the presence of __PTRDIFF_T and __SIZE_T means that the
relevant defs are already made.  However in the case of the module-enabled
C++ with these SDKs, that is no longer true.

stddef.h has a large body of special-cases already, but it seems that the
only viable solution here is to add a new one specifically for __APPLE__
and modular code.

This fixes around 280 new fails in the modules test-suite; it is needed on
all open branches that support modules.

PR target/116827

gcc/ChangeLog:

* ginclude/stddef.h: Undefine __PTRDIFF_T and __SIZE_T for module-
enabled c++ on Darwin/macOS platforms.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
3 months agoRegenerate common.opt.urls
Kyrylo Tkachov [Tue, 15 Apr 2025 16:22:05 +0000 (09:22 -0700)] 
Regenerate common.opt.urls

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
* common.opt.urls: Regenerate.

3 months agocobol/119302 - transform gcobol.3 name during install, install as gcobol-io.3
Richard Biener [Sat, 15 Mar 2025 14:56:49 +0000 (15:56 +0100)] 
cobol/119302 - transform gcobol.3 name during install, install as gcobol-io.3

The following installs gcobol.3 as gcobol-io.3 and applies
program-transform-name to the gcobol-io part.  This follows
naming of the pdf and the html variants.
It also uses $(man1ext) and $(man3ext) consistently.

PR cobol/119302
gcc/cobol/
* Make-lang.in (GCOBOLIO_INSTALL_NAME): Define.
Use $(GCOBOLIO_INSTALL_NAME) for gcobol.3 manpage source
upon install.

3 months agoSet znver5 issue rate to 4.
Jan Hubicka [Tue, 15 Apr 2025 17:09:20 +0000 (19:09 +0200)] 
Set znver5 issue rate to 4.

this patch sets issue rate of znver5 to 4.  With current model, unless a reservation is
missing, we will never issue more than 4 instructions per cycle since that is the limit
of decoders and the model does not take into acount the fact that typically code is run
from op cache.

gcc/ChangeLog:

* config/i386/x86-tune-sched.cc (ix86_issue_rate): Set
to 4 for znver5.

3 months agoSet ADDSS cost to 3 for znver5
Jan Hubicka [Tue, 15 Apr 2025 17:04:15 +0000 (19:04 +0200)] 
Set ADDSS cost to 3 for znver5

Znver5 has latency of addss 2 in typical case while all earlier versions has latency 3.
Unforunately addss cost is used to cost many other SSE instructions than just addss and
setting the cost to 2 makes us to vectorize 4 64bit stores into one 256bit store which
in turn regesses imagemagick.

This patch sets the cost back to 3.  Next stage1 we can untie addss from the other operatoins
and set it correctly.

bootstrapped/regtested x86_64-linux and also benchmarked on SPEC2k17

gcc/ChangeLog:

PR target/119298
* config/i386/x86-tune-costs.h (znver5_cost): Set ADDSS cost to 3.

3 months agolibstdc++: Do not define __cpp_lib_ranges_iota in <ranges>
Jonathan Wakely [Tue, 15 Apr 2025 13:00:23 +0000 (14:00 +0100)] 
libstdc++: Do not define __cpp_lib_ranges_iota in <ranges>

In r14-7153-gadbc46942aee75 we removed a duplicate definition of
__glibcxx_want_range_iota from <ranges>, but __cpp_lib_ranges_iota
should be defined in <ranges> at all.

libstdc++-v3/ChangeLog:

* include/std/ranges (__glibcxx_want_ranges_iota): Do not
define.

3 months agolibstdc++: Do not declare namespace ranges in <numeric> unconditionally
Jonathan Wakely [Tue, 15 Apr 2025 13:01:55 +0000 (14:01 +0100)] 
libstdc++: Do not declare namespace ranges in <numeric> unconditionally

Move namespace ranges inside the feature test macro guard, because
'ranges' is not a reserved name before C++20.

libstdc++-v3/ChangeLog:

* include/std/numeric (ranges): Only declare namespace for C++23
and later.
(ranges::iota_result): Fix indentation.
* testsuite/17_intro/names.cc: Check ranges is not used as an
identifier before C++20.

3 months agoRISC-V: vsetvl: elide abnormal edges from LCM computations [PR119533]
Vineet Gupta [Tue, 15 Apr 2025 16:29:08 +0000 (09:29 -0700)] 
RISC-V: vsetvl: elide abnormal edges from LCM computations [PR119533]

vsetvl phase4 uses LCM guided info to insert VSETVL insns, including a
straggler loop for "mising vsetvls" on certain edges. Currently it
asserts on encountering EDGE_ABNORMAL.

When enabling go frontend with V enabled, libgo build hits the assert.

The solution is to prevent abnormal edges from getting into LCM at all
(my prior attempt at this just ignored them after LCM which is not
right). Existing invalid_opt_bb_p () current does this for BB predecessors
but not for successors which is what the patch adds.

Crucially, the ICE/fix also depends on avoiding vsetvl hoisting past
non-transparent blocks: That is taken care of by Robin's patch
"RISC-V: Do not lift up vsetvl into non-transparent blocks [PR119547]"
for a different yet related issue.

Reported-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
PR target/119533

gcc/ChangeLog:

* config/riscv/riscv-vsetvl.cc (invalid_opt_bb_p): Check for
EDGE_ABNOMAL.
(pre_vsetvl::compute_lcm_local_properties): Initialize kill
bitmap.
Debug dump skipped edge.

gcc/testsuite/ChangeLog:

* go.dg/pr119533-riscv.go: New test.
* go.dg/pr119533-riscv-2.go: New test.

3 months agoRISC-V: Do not lift up vsetvl into non-transparent blocks [PR119547].
Robin Dapp [Fri, 4 Apr 2025 15:06:44 +0000 (17:06 +0200)] 
RISC-V: Do not lift up vsetvl into non-transparent blocks [PR119547].

When lifting up a vsetvl into a block we currently don't consider the
block's transparency with respect to the vsetvl as in other parts of the
pass.  This patch does not perform the lift when transparency is not
guaranteed.

This condition is more restrictive than necessary as we can still
perform a vsetvl lift if the conflicting register is only every used
in vsetvls and no regular insns but given how late we are in the GCC 15
cycle it seems better to defer this.  Therefore
gcc.target/riscv/rvv/vsetvl/avl_single-68.c is XFAILed for now.

This issue was found in OpenCV where it manifests as a runtime error.
Zhijin Zeng debugged PR119547 and provided an initial patch.

Reported-By: 曾治金 <zhijin.zeng@spacemit.com>
PR target/119547

gcc/ChangeLog:

* config/riscv/riscv-vsetvl.cc (pre_vsetvl::earliest_fuse_vsetvl_info):
Do not perform lift if block is not transparent.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/vsetvl/avl_single-68.c: xfail.
* g++.target/riscv/rvv/autovec/pr119547.C: New test.
* g++.target/riscv/rvv/autovec/pr119547-2.C: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-10.c: Adjust.

3 months agolibstdc++: Implement formatter for ranges and range_formatter [PR109162]
Tomasz Kamiński [Fri, 28 Mar 2025 08:30:22 +0000 (09:30 +0100)] 
libstdc++: Implement formatter for ranges and range_formatter [PR109162]

This patch implements formatter specialization for input_ranges and
range_formatter class from P2286R8, as adjusted by P2585R1. The formatter
for pair/tuple is not yet provided, making maps not formattable.

This introduces an new _M_format_range member to internal __formatter_str,
that formats range as _CharT as string, according to the format spec.
This function transform any contiguous range into basic_string_view directly,
by computing size if necessary. Otherwise, for ranges for which size can be
computed (forward_range or sized_range) we use a stack buffer, if they are
sufficiently small. Finally, we create a basic_string<_CharT> from the range,
and format its content.

In case when padding is specified, this is handled by firstly formatting
the content of the range to the temporary string object. However, this can be
only implemented if the iterator of the basic_format_context is internal
type-erased iterator used by implementation. Otherwise a new basic_format_context
would need to be created, which would require rebinding of handles stored in
the arguments: note that format spec for element type could retrieve any format
argument from format context, visit and use handle to format it.
As basic_format_context provide no user-facing constructor, the user are not able
to construct object of that type with arbitrary iterators.

The signatures of the user-facing parse and format methods of the provided
formatters deviate from the standard by constraining types of params:
* _CharT is constrained __formatter::__char
* basic_format_parse_context<_CharT> for parse argument
* basic_format_context<_Out, _CharT> for format second argument
The standard specifies last three of above as unconstrained types. These types
are later passed to possibly user-provided formatter specializations, that are
required via formattable concept to only accept above types.

Finally, the formatter<input_range, _CharT> specialization is implemented
without using specialization of range-default-formatter exposition only
template as base class, while providing same functionality.

PR libstdc++/109162

libstdc++-v3/ChangeLog:

* include/std/format (__format::__has_debug_format, _Pres_type::_Pres_seq)
(_Pres_type::_Pres_str, __format::__Stackbuf_size): Define.
(_Separators::_S_squares, _Separators::_S_parens, _Separators::_S_comma)
(_Separators::_S_colon): Define additional constants.
(_Spec::_M_parse_fill_and_align): Define overload accepting
list of excluded characters for fill, and forward existing overload.
(__formatter_str::_M_format_range): Define.
(__format::_Buf_sink) Use __Stackbuf_size for size of array.
(__format::__is_map_formattable, std::range_formatter)
(std::formatter<_Rg, _CharT>): Define.
* src/c++23/std.cc.in (std::format_kind, std::range_format)
(std::range_formatter): Export.
* testsuite/std/format/formatter/lwg3944.cc: Guarded tests with
__glibcxx_format_ranges.
* testsuite/std/format/formatter/requirements.cc: Adjusted for standard
behavior.
* testsuite/23_containers/vector/bool/format.cc: Test vector<bool> formatting.
* testsuite/std/format/ranges/format_kind.cc: New test.
* testsuite/std/format/ranges/formatter.cc: New test.
* testsuite/std/format/ranges/sequence.cc: New test.
* testsuite/std/format/ranges/string.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agolibgcobol: mark riscv64-*-linux* as supported target
Andreas Schwab [Mon, 17 Mar 2025 08:51:07 +0000 (09:51 +0100)] 
libgcobol: mark riscv64-*-linux* as supported target

* configure.tgt: Set LIBGCOBOL_SUPPORTED for riscv64-*-linux* with
64-bit multilib.

3 months agoFortran/OpenMP: Support automatic mapping allocatable components (deep mapping)
Tobias Burnus [Tue, 15 Apr 2025 14:35:45 +0000 (16:35 +0200)] 
Fortran/OpenMP: Support automatic mapping allocatable components (deep mapping)

When mapping an allocatable variable (or derived-type component), explicitly
or implicitly, all its allocated allocatable components will automatically be
mapped. The patch implements the target hooks, added for this feature to
omp-low.cc with commit r15-3895-ge4a58b6f28383c.

Namely, there is a check whether there are allocatable components at all:
gfc_omp_deep_mapping_p. Then gfc_omp_deep_mapping_cnt, counting the number
of required mappings; this is a dynamic value as it depends on array
bounds and whether an allocatable is allocated or not.
And, finally, the actual mapping: gfc_omp_deep_mapping.

Polymorphic variables are partially supported: the mapping of the _data
component is fully supported, but only components of the declared type
are processed for additional allocatables. Additionally, _vptr is not
touched. This means that everything needing _vtab information requires
unified shared memory; in particular, _size data is required when
accessing elements of polymorphic arrays.
However, for scalar arrays, accessing components of the declare type
should work just fine.

As polymorphic variables are not (really) supported and OpenMP 6
explicitly disallows them, there is now a warning (-Wopenmp) when
they are encountered. Unlimited polymorphics are rejected (error).

Additionally, PRIVATE and FIRSTPRIVATE are not quite supported for
allocatable components, polymorphic components and as polymorphic
variable. Thus, those are now rejected as well.

gcc/fortran/ChangeLog:

* f95-lang.cc (LANG_HOOKS_OMP_DEEP_MAPPING,
LANG_HOOKS_OMP_DEEP_MAPPING_P, LANG_HOOKS_OMP_DEEP_MAPPING_CNT):
Define.
* openmp.cc (gfc_match_omp_clause_reduction): Fix location setting.
(resolve_omp_clauses): Permit allocatable components, reject
them and polymorphic variables in PRIVATE/FIRSTPRIVATE.
* trans-decl.cc (add_clause): Set clause location.
* trans-openmp.cc (gfc_has_alloc_comps): Add ptr_ok and
shallow_alloc_only Boolean arguments.
(gfc_omp_replace_alloc_by_to_mapping): New.
(gfc_omp_private_outer_ref, gfc_walk_alloc_comps,
gfc_omp_clause_default_ctor, gfc_omp_clause_copy_ctor,
gfc_omp_clause_assign_op, gfc_omp_clause_dtor): Update call to it.
(gfc_omp_finish_clause): Minor cleanups, improve location data,
handle allocatable components.
(gfc_omp_deep_mapping_map, gfc_omp_deep_mapping_item,
gfc_omp_deep_mapping_comps, gfc_omp_gen_simple_loop,
gfc_omp_get_array_size, gfc_omp_elmental_loop,
gfc_omp_deep_map_kind_p, gfc_omp_deep_mapping_int_p,
gfc_omp_deep_mapping_p, gfc_omp_deep_mapping_do,
gfc_omp_deep_mapping_cnt, gfc_omp_deep_mapping): New.
(gfc_trans_omp_array_section): Save array descriptor in case
deep-mapping lang hook will need it.
(gfc_trans_omp_clauses): Likewise; use better clause location data.
* trans.h (gfc_omp_deep_mapping_p, gfc_omp_deep_mapping_cnt,
gfc_omp_deep_mapping): Add function prototypes.

libgomp/ChangeLog:

* libgomp.texi (5.0 Impl. Status): Mark mapping alloc comps as 'Y'.
* testsuite/libgomp.fortran/allocatable-comp.f90: New test.
* testsuite/libgomp.fortran/map-alloc-comp-3.f90: New test.
* testsuite/libgomp.fortran/map-alloc-comp-4.f90: New test.
* testsuite/libgomp.fortran/map-alloc-comp-5.f90: New test.
* testsuite/libgomp.fortran/map-alloc-comp-6.f90: New test.
* testsuite/libgomp.fortran/map-alloc-comp-7.f90: New test.
* testsuite/libgomp.fortran/map-alloc-comp-8.f90: New test.
* testsuite/libgomp.fortran/map-alloc-comp-9.f90: New test.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/map-alloc-comp-1.f90: Remove dg-error.
* gfortran.dg/gomp/polymorphic-mapping-2.f90: Update warn wording.
* gfortran.dg/gomp/polymorphic-mapping.f90: Change expected
diagnostic; some tests moved to ...
* gfortran.dg/gomp/polymorphic-mapping-1.f90: ... here as new test.
* gfortran.dg/gomp/polymorphic-mapping-3.f90: New test.
* gfortran.dg/gomp/polymorphic-mapping-4.f90: New test.
* gfortran.dg/gomp/polymorphic-mapping-5.f90: New test.

3 months agoLocality cloning pass: -fipa-reorder-for-locality
Kyrylo Tkachov [Thu, 27 Feb 2025 17:24:10 +0000 (09:24 -0800)] 
Locality cloning pass: -fipa-reorder-for-locality

Implement partitioning and cloning in the callgraph to help locality.
A new -fipa-reorder-for-locality flag is used to enable this.
The majority of the logic is in the new IPA pass in ipa-locality-cloning.cc
The optimization has two components:
* Partitioning the callgraph so as to group callers and callees that frequently
call each other in the same partition
* Cloning functions that straddle multiple callchains and allowing each clone
to be local to the partition of its callchain.

The majority of the logic is in the new IPA pass in ipa-locality-cloning.cc.
It creates a partitioning plan and does the prerequisite cloning.
The partitioning is then implemented during the existing LTO partitioning pass.

To guide these locality heuristics we use PGO data.
In the absence of PGO data we use a static heuristic that uses the accumulated
estimated edge frequencies of the callees for each function to guide the
reordering.
We are investigating some more elaborate static heuristics, in particular using
the demangled C++ names to group template instantiatios together.
This is promising but we are working out some kinks in the implementation
currently and want to send that out as a follow-up once we're more confident
in it.

A new bootstrap-lto-locality bootstrap config is added that allows us to test
this on GCC itself with either static or PGO heuristics.
GCC bootstraps with both (normal LTO bootstrap and profiledbootstrap).

As this new pass enables a new partitioning scheme it is incompatible with
explicit -flto-partition= options so an error is introduced when the user
uses both flags explicitly.

With this optimization we are seeing good performance gains on some large
internal workloads that stress the parts of the processor that is sensitive
to code locality, but we'd appreciate wider performance evaluation.

Bootstrapped and tested on aarch64-none-linux-gnu.
Ok for mainline?
Thanks,
Kyrill

Signed-off-by: Prachi Godbole <pgodbole@nvidia.com>
Co-authored-by: Kyrylo Tkachov <ktkachov@nvidia.com>
config/ChangeLog:

* bootstrap-lto-locality.mk: New file.

gcc/ChangeLog:

* Makefile.in (OBJS): Add ipa-locality-cloning.o.
* cgraph.h (set_new_clone_decl_and_node_flags): Declare prototype.
* cgraphclones.cc (set_new_clone_decl_and_node_flags): Remove static
qualifier.
* common.opt (fipa-reorder-for-locality): New flag.
(LTO_PARTITION_DEFAULT): Declare.
(flto-partition): Change default to LTO_PARTITION_DFEAULT.
* doc/invoke.texi: Document -fipa-reorder-for-locality.
* flag-types.h (enum lto_locality_cloning_model): Declare.
(lto_partitioning_model): Add LTO_PARTITION_DEFAULT.
* lto-cgraph.cc (lto_set_symtab_encoder_in_partition): Add dumping of
node and index.
* opts.cc (validate_ipa_reorder_locality_lto_partition): Define.
(finish_options): Handle LTO_PARTITION_DEFAULT.
* params.opt (lto_locality_cloning_model): New enum.
(lto-partition-locality-cloning): New param.
(lto-partition-locality-frequency-cutoff): Likewise.
(lto-partition-locality-size-cutoff): Likewise.
(lto-max-locality-partition): Likewise.
* passes.def: Register pass_ipa_locality_cloning.
* timevar.def (TV_IPA_LC): New timevar.
* tree-pass.h (make_pass_ipa_locality_cloning): Declare.
* ipa-locality-cloning.cc: New file.
* ipa-locality-cloning.h: New file.

gcc/lto/ChangeLog:

* lto-partition.cc (add_node_references_to_partition): Define.
(create_partition): Likewise.
(lto_locality_map): Likewise.
(lto_promote_cross_file_statics): Add extra dumping.
* lto-partition.h (lto_locality_map): Declare prototype.
* lto.cc (do_whole_program_analysis): Handle
flag_ipa_reorder_for_locality.