]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
3 months agoi386: Adjust some c86-4g*.md modeling to reduce build time
Kewen Lin [Fri, 1 May 2026 13:50:57 +0000 (13:50 +0000)] 
i386: Adjust some c86-4g*.md modeling to reduce build time

Commit r17-203 caused significant increase in GCC build time
on several environments as folks reported, mainly due to
excessively long execution time of genautomata.

As Alexander pointed out, the current division modeling in
c86-4g*.md can cause a combinatorial explosion in the
automaton, that further leads to significant build time
increase.

Following Alexander's suggestion, this patch introduces the
dedicated automatons and cpu_units for idiv and fdiv, uses
them to updates the integer, floating point division and
square root modeling for now.  Some evaluated statistics
are listed below.

With r17-202:

    *Tested stage-1 i686 build -j 32: 255 seconds*

    $ nm -CS -t d --defined-only gcc/insn-automata.o \
  | sed 's/^[0-9]* 0*//' \
  | sort -n | tail -20
13896 r slm_transitions
15360 r znver4_fp_store_transitions
16760 r znver4_ieu_transitions
17776 r bdver1_ieu_transitions
20068 r bdver1_fp_check
20068 r bdver1_fp_transitions
20983 t internal_state_transition(int, DFA_chip*)
22270 t internal_min_issue_delay(int, DFA_chip*)
26208 r slm_min_issue_delay
27244 r bdver1_fp_min_issue_delay
28518 r glm_check
28518 r glm_transitions
33690 r geode_min_issue_delay
45436 r znver4_fpu_min_issue_delay
46980 r bdver3_fp_min_issue_delay
49428 r glm_min_issue_delay
53730 r btver2_fp_min_issue_delay
53760 r znver1_fp_transitions
93960 r bdver3_fp_transitions
181744 r znver4_fpu_transitions

With culprit commit r17-203:

    *Tested stage-1 i686 build -j 32: 949 seconds*

$ nm -CS -t d --defined-only gcc/insn-automata.o \
  | sed 's/^[0-9]* 0*//' \
  | sort -n | tail -20
28518 r glm_check
28518 r glm_transitions
33690 r geode_min_issue_delay
45436 r znver4_fpu_min_issue_delay
46980 r bdver3_fp_min_issue_delay
49428 r glm_min_issue_delay
53730 r btver2_fp_min_issue_delay
53760 r znver1_fp_transitions
68160 r c86_4g_ieu_min_issue_delay
93960 r bdver3_fp_transitions
110080 r c86_4g_fp_min_issue_delay
136320 r c86_4g_ieu_transitions
181744 r znver4_fpu_transitions
220160 r c86_4g_fp_transitions
262988 r c86_4g_m7_fpu_base
475225 r c86_4g_m7_ieu_min_issue_delay
950450 r c86_4g_m7_ieu_transitions
4010567 r c86_4g_m7_fpu_min_issue_delay
5496908 r c86_4g_m7_fpu_check
5496908 r c86_4g_m7_fpu_transitions

With this patch:

    *Tested stage-1 i686 build -j 32: 257 seconds*

$ nm -CS -t d --defined-only gcc/insn-automata.o \
  | sed 's/^[0-9]* 0*//' \
  | sort -n | tail -20

20068 r bdver1_fp_transitions
22354 r c86_4g_m7_ieu_min_issue_delay
25705 t internal_state_transition(int, DFA_chip*)
26208 r slm_min_issue_delay
27164 t internal_min_issue_delay(int, DFA_chip*)
27244 r bdver1_fp_min_issue_delay
28518 r glm_check
28518 r glm_transitions
33690 r geode_min_issue_delay
33728 r c86_4g_fp_transitions
45436 r znver4_fpu_min_issue_delay
46980 r bdver3_fp_min_issue_delay
49428 r glm_min_issue_delay
53730 r btver2_fp_min_issue_delay
53760 r znver1_fp_transitions
89414 r c86_4g_m7_ieu_transitions
93960 r bdver3_fp_transitions
181744 r znver4_fpu_transitions
326322 r c86_4g_m7_fpu_min_issue_delay
1305288 r c86_4g_m7_fpu_transitions

I noticed the number of c86_4g_m7_fpu_transitions is still
large, but this patch can address the build time issue.
To avoid impacting folks' daily builds and regular testings,
I'd like to land this patch first if possible.  We can then further
refine the c86-4g modeling and investigate large transition
count as part of the follow-up work, even potentially part
of PR 87832.

gcc/ChangeLog:

* config/i386/c86-4g-m7.md (c86_4g_m7_idiv): New automaton.
(c86_4g_m7_fdiv): Ditto.
(c86-4g-m7-idiv): New unit.
(c86-4g-m7-fdiv): Ditto.
(c86_4g_m7_idiv_DI): Adjust unit in the reservation.
(c86_4g_m7_idiv_SI): Ditto.
(c86_4g_m7_idiv_HI): Ditto.
(c86_4g_m7_idiv_QI): Ditto.
(c86_4g_m7_idiv_DI_load): Ditto.
(c86_4g_m7_idiv_SI_load): Ditto.
(c86_4g_m7_idiv_HI_load): Ditto.
(c86_4g_m7_idiv_QI_load): Ditto.
(c86_4g_m7_fp_div): Ditto.
(c86_4g_m7_fp_div_load): Ditto.
(c86_4g_m7_fp_idiv_load): Ditto.
(c86_4g_m7_avx512_ssediv): Ditto.
(c86_4g_m7_avx512_ssediv_mem): Ditto.
(c86_4g_m7_avx512_ssediv_z): Ditto.
(c86_4g_m7_avx512_ssediv_zmem): Ditto.
(c86_4g_m7_avx512_sse_sqrt): Ditto.
(c86_4g_m7_avx512_sse_sqrt_load): Ditto.
(c86_4g_m7_fp_sqrt): Ditto.  Rename from ...
(c86_4g_m7fp_sqrt): ... here.
* config/i386/c86-4g.md (c86_4g_idiv): New automaton.
(c86_4g_fdiv): Ditto.
(c86-4g-idiv): New unit.
(c86-4g-fdiv): Ditto.
(c86_4g_idiv_DI): Ditto.
(c86_4g_idiv_SI): Ditto.
(c86_4g_idiv_HI): Ditto.
(c86_4g_idiv_QI): Ditto.
(c86_4g_idiv_mem_DI): Ditto.
(c86_4g_idiv_mem_SI): Ditto.
(c86_4g_idiv_mem_HI): Ditto.
(c86_4g_idiv_mem_QI): Ditto.
(c86_4g_fp_sqrt): Ditto.
(c86_4g_sse_sqrt_sf): Ditto.
(c86_4g_sse_sqrt_sf_mem): Ditto.
(c86_4g_sse_sqrt_df): Ditto.
(c86_4g_sse_sqrt_df_mem): Ditto.
(c86_4g_fp_op_div): Ditto.
(c86_4g_fp_op_div_load): Ditto.
(c86_4g_fp_op_idiv_load): Ditto.
(c86_4g_ssediv_ss_ps): Ditto.
(c86_4g_ssediv_ss_ps_load): Ditto.
(c86_4g_ssediv_ss_pd): Ditto.
(c86_4g_ssediv_ss_pd_load): Ditto.
(c86_4g_ssediv_avx256_ps): Ditto.
(c86_4g_ssediv_avx256_ps_load): Ditto.
(c86_4g_ssediv_avx256_pd): Ditto.
(c86_4g_ssediv_avx256_pd_load): Ditto.

Signed-off-by: Kewen Lin <linkewen@hygon.cn>
3 months ago[PATCH v2] RISC-V: Add Synopsys RMX-100 series pipeline description.
Michiel Derhaeg [Fri, 1 May 2026 13:41:54 +0000 (07:41 -0600)] 
[PATCH v2] RISC-V: Add Synopsys RMX-100 series pipeline description.

This patch introduces the pipeline description for the Synopsys RMX-100 series
processor to the RISC-V GCC backend.  The RMX-100 has a short, three-stage,
in-order execution pipeline with configurable multiply unit options.

The option -mmpy-option was added to control which version of the MPY unit the
core has and what the latency of multiply instructions should be similar to
ARCv2 cores (see gcc/config/arc/arc.opt:60).

gcc/ChangeLog:

* config/riscv/riscv-cores.def (RISCV_TUNE): Add arc-v-rmx-100-series.
* config/riscv/riscv-opts.h (enum riscv_microarchitecture_type):
Add arcv_rmx100.
(enum arcv_mpy_option_enum): New enum for ARC-V multiply options.
* config/riscv/riscv-protos.h (arcv_mpy_1c_bypass_p): New declaration.
(arcv_mpy_2c_bypass_p): New declaration.
(arcv_mpy_10c_bypass_p): New declaration.
* config/riscv/riscv.cc (arcv_mpy_1c_bypass_p): New function.
(arcv_mpy_2c_bypass_p): New function.
(arcv_mpy_10c_bypass_p): New function.
* config/riscv/riscv.md: Add arcv_rmx100.
* config/riscv/riscv.opt: New option for RMX-100 multiply unit
configuration.
* doc/riscv-mtune.texi: Document arc-v-rmx-100-series.
* config/riscv/arcv-rmx100.md: New file.

Co-authored-by: Artemiy Volkov <artemiyv@acm.org>
Co-authored-by: Luis Silva <luiss@synopsys.com>
Signed-off-by: Michiel Derhaeg <michiel@synopsys.com>
3 months ago[PATCH v2] RISC-V: Add Synopsys RHX-100 series pipeline description
Michiel Derhaeg [Fri, 1 May 2026 13:35:43 +0000 (07:35 -0600)] 
[PATCH v2] RISC-V: Add Synopsys RHX-100 series pipeline description

This patch introduces the pipeline description for the Synopsys RHX-100 series
processor to the RISC-V GCC backend.  The RHX-100 features a 10-stage,
dual-issue, in-order execution pipeline architecture.

It has support for instruction fusion, which will be addressed by subsequent
patches.  Due to fusion, up to four instructions can be issued in a single
cycle.  It is modeled as four separate pipelines and the issue_rate is set to
four.

gcc/ChangeLog:

* config/riscv/riscv-cores.def (RISCV_TUNE): Add arc-v-rhx-100-series.
* config/riscv/riscv-opts.h (enum riscv_microarchitecture_type): Add
arcv_rhx100.
* config/riscv/riscv.cc (arcv_rhx100_tune_info): New riscv_tune_param.
* config/riscv/riscv.md: Add arcv_rhx100 to tune attribute.
* doc/riscv-mtune.texi: Add RHX-100 documentation.
* config/riscv/arcv-rhx100.md: New file.

Co-authored-by: Artemiy Volkov <artemiyv@acm.org>
Co-authored-by: Luis Silva <luiss@synopsys.com>
Signed-off-by: Michiel Derhaeg <michiel@synopsys.com>
3 months ago[PATCH GCC17-stage1] riscv: Optimize power-of-2 boundary comparisons in conditional...
Philipp Tomsich [Fri, 1 May 2026 13:32:17 +0000 (07:32 -0600)] 
[PATCH GCC17-stage1] riscv: Optimize power-of-2 boundary comparisons in conditional moves

In riscv_expand_conditional_move, detect unsigned comparisons against
power-of-2 boundaries and convert them to shift-based equality tests.
This avoids materializing large constants (e.g. 2^56 - 1) that may
require multiple instructions (bseti + sltu), replacing them with a
single srli that feeds directly into czero.eqz/czero.nez.

The transformation handles four cases:
  GTU x, (2^N-1)  ->  NE (x >> N), 0
  LEU x, (2^N-1)  ->  EQ (x >> N), 0
  GEU x, 2^N      ->  NE (x >> N), 0
  LTU x, 2^N      ->  EQ (x >> N), 0

For example, `(a & (0xff << 56)) ? b : 0` previously generated:
  bseti  a5, zero, 56
  sltu   a0, a0, a5
  czero.nez  a0, a1, a0

Now generates:
  srli      a0, a0, 56
  czero.eqz a0, a1, a0

Existing define_split patterns in riscv.md (lines 3727-3748) handle
the same optimization for standalone SCC operations, but they don't
fire in the conditional move expansion path which goes through
riscv_expand_int_scc directly.

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_expand_conditional_move):
Convert unsigned comparisons against power-of-2 boundaries
to shift-based equality tests.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/zicond-shift-cond.c: New test.

3 months agoc++/reflection: propagate cv-quals for SPLICE_SCOPE [PR125096]
Marek Polacek [Wed, 29 Apr 2026 21:24:19 +0000 (17:24 -0400)] 
c++/reflection: propagate cv-quals for SPLICE_SCOPE [PR125096]

tsubst_splice_scope isn't propagating cv-quals from the template tree
to the result, which means wrongly failed asserts in the new test due to
a missing 'const'.  So let's add the cv-quals like we do in so many
other places in tsubst.

PR c++/125096

gcc/cp/ChangeLog:

* pt.cc (tsubst_splice_scope): Don't return early for
dependent_splice_p.  Propagate cv-qualifiers from the
SPLICE_SCOPE to the result.
* reflect.cc (valid_splice_scope_p): Accept SPLICE_SCOPE.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/mangle4.C: Move dg-error.
* g++.dg/reflect/dep16.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agobuild: Check solaris_{as,ld} where appropriate
Rainer Orth [Fri, 1 May 2026 13:18:04 +0000 (15:18 +0200)] 
build: Check solaris_{as,ld} where appropriate

Several of the gas and gnu_ld checks in gcc/configure actually need to
determine if Solaris as and ld are in use.  Since solaris_as and
solaris_ld are determined reliably now, it's clearer to check them
directly instead of !gas and !gnu_ld.

This patch does just that.  Since solaris_as/solaris_ld imply target
*-*-solaris2*, the tests can be simplified and sometimes converted from
case/esac to if/else.

Bootstrapped on amd64-pc-solaris2.11, sparcv9-sun-solaris2.11,
x86_64-pc-linux-gnu, amd64-pc-freebsd15.0, and
x86_64-apple-darwin21.6.0.

When there are different flavours of as and/or ld depending on PATH
(/usr/bin/as vs. /usr/gnu/bin/as resp. ld on Solaris, /usr/bin/ld, LLD,
and /usr/local/bin/ld, GNU ld on FreeBSD), the builds were configured
with --with-as/--with-ld.

The Solaris tests were run for as/ld, gas/ld, and gas/gld
configurations, the FreeBSD tests with gas/gld.

In all cases, gcc/auto-host.h and gcc/Makefile were unchanged.

2026-02-08  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc:
* configure.ac: Test solaris_as, solaris_ld instead of gas, gnu_ld.
(gcc_cv_as_working_gdwarf_n_flag): Escape '.' in filename.
* acinclude.m4 (gcc_cv_initfini_array): Test solaris_as,
solaris_ld instead of gas, gnu_ld.
* configure: Regenerate.

3 months ago[PATCH] RISC-V: Fix missing braces in riscv_rtx_costs for slli.uw pattern [PR???]
Jin Ma [Fri, 1 May 2026 13:06:01 +0000 (07:06 -0600)] 
[PATCH] RISC-V: Fix missing braces in riscv_rtx_costs for slli.uw pattern [PR???]

The AND case in riscv_rtx_costs for the slli.uw pattern (zba extension) has a
multi-statement if body without braces.  This causes the 'return true' to
execute unconditionally whenever the left operand of AND is an ASHIFT,
regardless of whether the inner condition (checking register_operand,
CONST_INT_P, and the 0xffffffff mask) is satisfied.

This effectively short-circuits the entire AND cost calculation for any
AND+ASHIFT combination when TARGET_ZBA && TARGET_64BIT && DImode,
skipping subsequent pattern checks (bclri, bclr, etc.) and the
fallthrough to PLUS/MINUS.

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_rtx_costs): Add missing braces
around the if body for the slli.uw pattern in the AND case.

3 months agostrlen: Adjust objsz arg in __strcat_chk -> __stpcpy_chk transformation [PR125079]
Jakub Jelinek [Fri, 1 May 2026 12:54:35 +0000 (14:54 +0200)] 
strlen: Adjust objsz arg in __strcat_chk -> __stpcpy_chk transformation [PR125079]

As the following testcase shows, we have two different transformations
of __strcat_chk.  One done in strlen_pass::handle_builtin_strcat,
which transforms __strcat_chk (x, y, z) if we know beforehand strlen (x),
so something like:
  l = strlen (x);
  __strcat_chk (x, y, z);
and since PR87672 we change that to
  l = strlen (x);
  __strcpy_chk (x + l, y, z - l);
i.e. decrease the objsz in
  if (objsz)
    {
      objsz = fold_build2_loc (loc, MINUS_EXPR, TREE_TYPE (objsz), objsz,
                               fold_convert_loc (loc, TREE_TYPE (objsz),
                                                 unshare_expr (dstlen)));
      objsz = force_gimple_operand_gsi (&m_gsi, objsz, true, NULL_TREE, true,
                                        GSI_SAME_STMT);
    }
And another transformation is when we have earlier __strcat_chk (x, y, z)
call and want to compute strlen (x) after that.  In that case
get_string_length transforms
  __strcat_chk (x, y, z);
to
  t = strlen (x);
  l = __stpcpy_chk (x + t, y, z) - x;
where l is the len we are looking for.  This patch changes it similarly to
the PR87672 to
  t = strlen (x);
  l = __stpcpy_chk (x + t, y, z - t) - x;
instead.

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

PR tree-optimization/125079
* tree-ssa-strlen.cc (get_string_length): Transform
__strcat_chk (x, y, z) when we need strlen (x) afterwards into
l1 = strlen (x); l = __stpcpy_chk (x + l1, y, z - l1) - x;
where l is the strlen (x), instead of using z as last __stpcpy_chk
argument.

* gcc.dg/strlenopt-97.c: New test.

Reviewed-by: Richard Biener <rguenth@suse.de>
3 months ago[PR target/124559][RISC-V] Improve RISC-V constant synthesis for some HImode constants
Jeff Law [Fri, 1 May 2026 12:47:07 +0000 (06:47 -0600)] 
[PR target/124559][RISC-V] Improve RISC-V constant synthesis for some HImode constants

So this is a trivial little bug we found doing some comparisons against LLVM.

For the function sub2 in load-immediate.c we get this code:

        li      a5,-32768
        sh      a5,0(a0)
        xori    a5,a5,-1
        sh      a5,0(a1)

Note carefully that li+xori.  There's a slightly better sequence here from an
encoding standpoint.  Instead of using xori we can adjust the synthesis
sequence to target an "addi" for that statement and in doing so we can save two
code bytes of space.

The xori sequence was used because we can't do this in gcc:

(set (dest:HI) (const_int 0x8000))

We're in HI mode so the constant must be sign extended from bit 15 to a
HOST_WIDE_INT.

Fixing this isn't hard.  The key is realizing the vast majority of the time we
really don't want/need to load in HImode and in fact we're typically going to
be generating objects in word_mode.  So instead of passing in the pre-promoted
mode, pass in the post-promoted mode.

That's fine and good with one caveat.   CSE fails to use NEG/NOT to derive a
new constant from an older constant, even if the cost is smaller, which caused
a code quality regression elsewhere on the RISC-V port.  So this patch adjusts
CSE ever-so-slightly to allow it to derive constants from a previous constant
using NOT/NEG in a fairly obvious way.

This has been in my tester for a while, so it's been through the usual
bootstrap & regression test on the Pioneer, BPI, x86 and aarch64 and others as
well as testing across the various embedded targets.

Waiting on pre-commit testing to do its thing.

PR target/124559
gcc/
* config/riscv/riscv-protos.h (riscv_move_integer): Drop mode argument.
* config/riscv/riscv.cc (riscv_move_integer): Pass mode after promotions
to riscv_build_integer.  All callers changed.
* config/riscv/riscv.md: Corresponding changes.
* cse.cc (cse_insn): Try to derive one constant from another using NOT/NEG.

3 months agolibstdc++: Tweak Doxygen comments for experimental simd
Jonathan Wakely [Fri, 1 May 2026 09:58:57 +0000 (10:58 +0100)] 
libstdc++: Tweak Doxygen comments for experimental simd

I noticed that Doxygen was not documenting the contents of
<experimental/simd> as part of namespace std, because it didn't know
about the _GLIBCXX_SIMD_BEGIN_NAMESPACE and _GLIBCXX_SIMD_END_NAMESPACE
macros which open and close namespace std::experimental::parallelism_v2.

After defining those macros in the Doxygen config, the Doxygen comments
in experimental/bits/simd.h were causing namespace std to be documented
as part of the Parallelism TS v2. That's because the preprocessed code
looks like:

/** @ingroup ts_simd
 * @{
 */
namespace std::experimental::inline parallelism_v2 {

This causes Doxygen to apply the @ingroup command to all three of
namespace std, namespace std::experimental, and namespace
std::experimental::parallelism_v2. I don't know if this is the intended
behaviour, but it doesn't seem useful so I've opened an issue about it:
https://github.com/doxygen/doxygen/issues/12114

To workaround this, we can move the _GLIBCXX_SIMD_BEGIN_NAMESPACE macro
before the @{ group and document it separately with a @namespace
comment. That makes the @ingroup only apply to the namespace named by
the @namespace command, not to its enclosing namespaces as well. Moving
the position of the BEGIN macro also fixes the nesting, as previously we
had @{ then BEGIN then @} then END. Now we have BEGIN @{ @} END which
seems preferable.

libstdc++-v3/ChangeLog:

* doc/doxygen/user.cfg.in (PREDEFINED): Add BEGIN/END macros for
the <experimental/simd> namespace.
* include/experimental/bits/simd.h: Move BEGIN macro before
Doxygen @{ group.

3 months agolibstdc++: Suppress Doxygen docs for internals in <bits/locale_conv.h>
Jonathan Wakely [Fri, 1 May 2026 11:36:20 +0000 (12:36 +0100)] 
libstdc++: Suppress Doxygen docs for internals in <bits/locale_conv.h>

libstdc++-v3/ChangeLog:

* include/bits/locale_conv.h: Prevent namespace __detail from
being documented as part of the Locales topic.

3 months agolibstdc++: Improve Doxygen comments for <iterator> contents
Jonathan Wakely [Fri, 1 May 2026 11:15:17 +0000 (12:15 +0100)] 
libstdc++: Improve Doxygen comments for <iterator> contents

Use markdown and suppress unwanted docs for internal helpers.

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h: Prevent Doxygen from documenting
namespace __detail as part of the Iterators topic.
* include/bits/stl_iterator_base_funcs.h: Likewise. Also mark
internal helpers as undocumented.
(distance, advance): Improve Doxygen comments.
* include/bits/stl_iterator_base_types.h (iterator): Use
markdown in Doxygen comment. Add @deprecated.
(iterator_traits): Improve wording of Doxygen comment.

3 months agolibstdc++: Do not assume URBG::result_type exists [PR121919]
Jonathan Wakely [Thu, 30 Apr 2026 12:27:48 +0000 (13:27 +0100)] 
libstdc++: Do not assume URBG::result_type exists [PR121919]

The ranges::sample and ranges::shuffle algorithms are supposed to work
with types which model std::uniform_random_bit_generator, which means
they should not assume that G::result_type is present. That isn't needed
to satisfy the concept. Change the algorithms to use decltype(__g())
instead of using result_type.

This isn't sufficient to fix the bug though, because those algorithms
use std::uniform_int_distribution and that class template's operator()
overloads depend on the more restrictive uniform random bit generator
requirements, which do include the presence of a nested result_type
member.

We need to change std::uniform_int_distribution to also use decltype
instead of the nested result_type, even though the standard says that
std::uniform_int_distribution is allowed to assume that result_type
exists.

There's yet another problem, which is that a type that returns random
bool values can model the concept, but doesn't meet the named
requirements and can't be used with std::uniform_int_distribution. That
isn't addressed by this change.

libstdc++-v3/ChangeLog:

PR libstdc++/121919
* include/bits/ranges_algo.h (__sample_fn, __shuffle_fn): Use
decltype(__g()) instead of remove_reference_t<_G>::result_type.
* include/bits/uniform_int_dist.h
(uniform_int_distribution::operator()): Use decltype(__urng())
instead of _UniformRandomBitGenerator::result_type
(uniform_int_distribution::__generate_impl): Likewise.
* testsuite/25_algorithms/sample/121919.cc: New test.
* testsuite/25_algorithms/shuffle/121919.cc: New test.

Reviewed-by: Nathan Myers <nmyers@redhat.com>
3 months agoAda: Link with PIC static Ada runtime when -pie is specified
Eric Botcazou [Fri, 1 May 2026 10:54:38 +0000 (12:54 +0200)] 
Ada: Link with PIC static Ada runtime when -pie is specified

This changes gnatlink to append _pic to the name of the static Ada runtime
when -pie is passed on the command line.

gcc/ada/
PR ada/87936
* gnatlink.adb (Gnatlink): Rename local variable and add Output_PIE
local variable; when it is set, compile the binder file with -fPIE.
(Process_Args): Set Output_PIE upon seeing -pie.
(Process_Binder_File): Append "_pic" to the name of the static Ada
runtime if Output_PIE is set.

gcc/testsuite/
* gnat.dg/pie1.adb: New file.

3 months agox86: Correct last_4x_vec_label in ix86_expand_movmem
H.J. Lu [Fri, 1 May 2026 01:13:21 +0000 (09:13 +0800)] 
x86: Correct last_4x_vec_label in ix86_expand_movmem

commit b41f96465190751561f6909e858604ceab00595b
Author: H.J. Lu <hjl.tools@gmail.com>

    x86-64: Inline memmove with overlapping unaligned loads and stores

has

      rtx_code_label *last_4x_vec_label = nullptr;
      if (min_size == 0 || min_size < 4 * move_max)
        last_4x_vec_label = gen_label_rtx ();

      /* Jump to LAST_4X_VEC_LABEL if size < 4 * MOVE_MAX.  */
      if (last_4x_vec_label)
        emit_cmp_and_jump_insns (count_exp, GEN_INT (4 * move_max), LTU,
                                 nullptr, count_mode, 1,
                                 last_4x_vec_label);

...

      if (last_4x_vec_label)
        {
          /* Size > 2 * MOVE_MAX and size <= 4 * MOVE_MAX.  */
          emit_label (last_4x_vec_label);

The last_4x_vec_label block covers min_size <= 4 * MOVE_MAX, not
min_size < 4 * MOVE_MAX.  When MOVE_MAX == 16 bytes and min_size == 64,
the last_4x_vec_label isn't generated.  Change min_size < 4 * move_max
to min_size <= 4 * move_max to correct the last_4x_vec_label condition.

Tested on Linux/x86-64.

gcc/

PR target/125117
* config/i386/i386-expand.cc (ix86_expand_movmem): Generate
last_4x_vec_label when min_size <= 4 * MOVE_MAX.

gcc/testsuite/

PR target/125117
* gcc.dg/pr125117.c: New test.
* gfortran.dg/pr125117.f90: Likewise.
* gcc.target/i386/builtin-memmove-10.c: Updated.
* gcc.target/i386/builtin-memmove-15.c: Likewise.
* gcc.target/i386/builtin-memmove-2a.c: Likewise.
* gcc.target/i386/builtin-memmove-2b.c: Likewise.
* gcc.target/i386/builtin-memmove-2c.c: Likewise.
* gcc.target/i386/builtin-memmove-2d.c: Likewise.
* gcc.target/i386/builtin-memmove-3a.c: Likewise.
* gcc.target/i386/builtin-memmove-3b.c: Likewise.
* gcc.target/i386/builtin-memmove-3c.c: Likewise.
* gcc.target/i386/builtin-memmove-4a.c: Likewise.
* gcc.target/i386/builtin-memmove-4b.c: Likewise.
* gcc.target/i386/builtin-memmove-4c.c: Likewise.
* gcc.target/i386/builtin-memmove-5b.c: Likewise.
* gcc.target/i386/builtin-memmove-5c.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 months agos390: Fix dealing with HF vector modes in s390_secondary_reload
Stefan Schulze Frielinghaus [Fri, 1 May 2026 07:16:48 +0000 (09:16 +0200)] 
s390: Fix dealing with HF vector modes in s390_secondary_reload

Initial HF mode support was added in commit r16-6682-g5d6d56d837c which
is missing HF vector mode support when dealing with secondary reloads
for instructions which do not accept relative operands.

gcc/ChangeLog:

* config/s390/s390.cc (s390_secondary_reload): Add cases for HF
vector modes.
* config/s390/s390.md: Add modes V{1,2,4,8}HF to mode iterator
ALL.

3 months agotree-vect-loop: Remove useless && 1.
Jakub Jelinek [Fri, 1 May 2026 06:36:24 +0000 (08:36 +0200)] 
tree-vect-loop: Remove useless && 1.

r16-476 has replaced && slp_node with && 1 and it remained that way
until now.  THis patch just removes that.

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

* tree-vect-loop.cc (vectorizable_reduction): Remove pointless
&& 1.

3 months ago[V3][RISC-V][PR rtl-optimization/96692] Improve xor+xor+ior sequence when possible
Jeff Law [Fri, 1 May 2026 03:37:34 +0000 (21:37 -0600)] 
[V3][RISC-V][PR rtl-optimization/96692] Improve xor+xor+ior sequence when possible

Consider this code:

int f(int a, int b, int c)
{
    return (a ^ b) ^ (a | c);
}

For RISC-V we generate something like this:

        xor     a1,a0,a1
        or      a0,a0,a2
        xor     a0,a1,a0

But this would be better:

        andn    a0,a2,a0
        xor     a0,a0,a1

It looks like Roger tackled this earlier with splitters for x86. I'd have
leaned more towards simplify-rtx, but there may be secondary concerns at play.
So I'll attack in the RISC-V target files in a similar manner.

The patch, but not the testcase, have been in my tester for a while, so it's
been bootstrapped and regression tested on the Pioneer and BPI-F3 board and
regression tested on riscv32-elf and riscv64-elf. Obviously I'll wait for
pre-commit CI before moving forward.

PR rtl-optimization/96692
gcc/
* config/riscv/bitmanip.md (xor+xor+ior splitters): New splitters
that ultimately generate andn+xor when possible.

gcc/testsuite

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

3 months agoDaily bump.
GCC Administrator [Fri, 1 May 2026 00:16:27 +0000 (00:16 +0000)] 
Daily bump.

3 months agox86: Remove DI_REG/SI_REG from x86_64_int_return_registers
H.J. Lu [Wed, 15 Apr 2026 05:43:08 +0000 (13:43 +0800)] 
x86: Remove DI_REG/SI_REG from x86_64_int_return_registers

Since only AX/DX register pair and XMM0/XMM1 register pair are used for
function return values in 64-bit mode, remove DI_REG and SI_REG registers
from x86_64_int_return_registers and limit the number of registers used
in return values to 2 in 64-bit mode.

Tested on Linux/x86-64 and Linux/i686.

PR target/124878
* config/i386/i386.cc (x86_64_int_return_registers): Remove
DI_REG and SI_REG.
(ix86_function_value_regno_p): Remove DI_REG and SI_REG cases.
(function_value_64): Replace X86_64_REGPARM_MAX and
X86_64_SSE_REGPARM_MAX with X86_64_MAX_RETURN_NREGS and
X86_64_MAX_SSE_RETURN_NREGS for the number of registers used
in return values.
* config/i386/i386.h (X86_64_MAX_RETURN_NREGS): New.  Defined
to 2.
(X86_64_MAX_SSE_RETURN_NREGS): Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 months agox86: Disable 16-bit imm store for TARGET_LCP_STALL
H.J. Lu [Thu, 30 Apr 2026 07:37:13 +0000 (15:37 +0800)] 
x86: Disable 16-bit imm store for TARGET_LCP_STALL

When TARGET_LCP_STALL is enabled, 16-bit immediate integer store should
be avoided.  Update V_16_32_64:*mov<mode>_imm to disable 16-bit immediate
integer store when TARGET_LCP_STALL is enabled.

Tested on Linux/x86-64 and Linux/i686.

PR target/125102
* config/i386/mmx.md (V_16_32_64:*mov<mode>_imm): Disable
16-bit immediate integer store if TARGET_LCP_STALL is true.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 months agolibstdc++: Add <bits/binders.h> to freestanding headers [PR125112]
Felix Morgner [Thu, 30 Apr 2026 16:24:07 +0000 (17:24 +0100)] 
libstdc++: Add <bits/binders.h> to freestanding headers [PR125112]

The <ranges> header was added to the freestanding headers in
r16-3575-g1a41e52d7ecb58 but bits/binders.h that it depends on was not
moved, making <ranges> unusable with --disable-libstdcxx-hosted.

libstdc++-v3/ChangeLog:

PR libstdc++/125112
* include/Makefile.am: Move bits/binders.h from bits_headers to
bits_freestanding.
* include/Makefile.in:

3 months agoAda: Fix build of GNAT tools with coverage enabled
Eric Botcazou [Thu, 30 Apr 2026 18:56:25 +0000 (20:56 +0200)] 
Ada: Fix build of GNAT tools with coverage enabled

This removes an obsolete comment in the process.

gcc/
* Makefile.in (COVERAGE_FLAGS): Remove obsolete comment.

gcc/ada/
PR ada/110336
* gcc-interface/Makefile.in (COVERAGE_FLAGS): New variable
(GCC_LINK_FLAGS): Add $(COVERAGE_FLAGS).
(ALL_CFLAGS): Likewise.
(enable_host_pie): Fold into single use.

3 months ago[IRA]: Process operand NO_REGS class for reg cost calculation
Vladimir N. Makarov [Thu, 30 Apr 2026 13:02:51 +0000 (09:02 -0400)] 
[IRA]: Process operand NO_REGS class for reg cost calculation

In record_reg_classes there is no special processing of case op_class ==
NO_REGS.  It can result in very high cost of the insn alternative cost.
The patch fixes this and can change generated code.

gcc/ChangeLog:

* ira-costs.cc (record_reg_classes): Process correctly case
op_class == NO_REGS.

3 months ago[IRA]: Fix soft conflict and hard reg cost calculation
Vladimir N. Makarov [Thu, 30 Apr 2026 13:01:54 +0000 (09:01 -0400)] 
[IRA]: Fix soft conflict and hard reg cost calculation

When finding soft conflict in IRA, we wrongly use conflict allocno mode.
This can result in more shuffling on the region borders and worse code
generation. The patch fixes this.

gcc/ChangeLog:

* ira-color.cc (assign_hard_reg): Use the right allocno mode to
call note_conflict.

3 months ago- ICE verify_vssa exceeds stack space for big functions [PR124805]
Heiko Eißfeldt [Wed, 8 Apr 2026 21:36:12 +0000 (23:36 +0200)] 
- ICE verify_vssa exceeds stack space for big functions [PR124805]

The source from PR124561 led to an ICE with --enable-checking, caused by a stack overflow.
The recursive verification code verify_vssa in tree-ssa.cc could not handle the extreme
number of basic blocks within the typical limits of stack space.

As for PR124561 the recursive code was transformed into an iterative version, which
avoided the recursive calls.

A worklist is used, which has as entries a pair of a basic_block and a tree (vdef).
The logic of verification steps for each basic_block is unchanged, although the order
of basic_blocks is changed.

This fixes PR124805.

Reg tested OK.

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

PR middle-end/124805
* tree-ssa.cc (verify_vssa):
replace recursive calls with iteration for lower stack usage

3 months agogcc/toplev.cc: Output mangled function names with -fstack-usage
Tomas Härdin [Tue, 28 Apr 2026 20:49:32 +0000 (22:49 +0200)] 
gcc/toplev.cc: Output mangled function names with -fstack-usage

This is more useful for automated stack checking tools such
as Daniel Beer's avstack.pl

gcc/ChangeLog:

* toplev.cc (output_stack_usage_1): Pass RINT_DECL_UNIQUE_NAME
instead of PRINT_DECL_NAME to print_decl_identifier.

Signed-off-by: Tomas Härdin <git@haerdin.se>
3 months agomatch: Simplify patterns for `a != b` implies a or b is non-zero
Andrew Pinski [Wed, 29 Apr 2026 21:34:32 +0000 (14:34 -0700)] 
match: Simplify patterns for `a != b` implies a or b is non-zero

This simplified the patterns by using a for loop. Also noticed
that the `:c` on the inner ne/eq is not needed as it will match
the same canonicalization as the inner bit_ior too so removes that too.

This removes a little more 300 lines from the generated gimple-match*.cc files too.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* match.pd (`(a !=/== b) &\| ((a|b) ==/!= 0)`):
Simplify patterns using for loop and remove the `:c`
on the inner ne/eq.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 months agoaarch64: Handle opts_set parameter properly in aarch64_option_restore
Christopher Bazley [Wed, 29 Apr 2026 12:26:42 +0000 (12:26 +0000)] 
aarch64: Handle opts_set parameter properly in aarch64_option_restore

Previously, the AArch64 implementation of TARGET_OPTION_RESTORE ignored
the opts_set parameter and its callee, aarch64_override_options_internal,
invoked SET_OPTION_IF_UNSET with &global_options_set instead of with
opts_set.

That was bad for maintainability, because it was based on an assumption
that cl_target_option_restore would only be called with &global_options_set.
Otherwise, if an option were set in *opts_set but not in global_options_set,
the corresponding value would have been wrongly overridden; conversely, if
an option were set in global_options_set but not in *opts_set then its
value would not have been overridden as expected.

It looks as though cl_target_option_restore is not currently called with
an argument expression other than &global_options_set except by the arm,
i386 and s390 backends. However, ascertaining that and ensuring it will
always be true wastes more time than simply doing the right thing.

gcc/ChangeLog:

* config/aarch64/aarch64-c.cc (aarch64_pragma_target_parse):
Pass &global_options_set as an argument to
aarch64_override_options_internal.
* config/aarch64/aarch64-protos.h (aarch64_override_options_internal):
Add a parameter declaration for opts_set.
* config/aarch64/aarch64.cc (aarch64_override_options_internal):
Add a parameter declaration for opts_set and use the argument
when invoking SET_OPTION_IF_UNSET.
(aarch64_override_options): Pass &global_options_set as an argument to
aarch64_override_options_internal.
(aarch64_option_restore): As above.
(aarch64_set_current_function): As above.
(aarch64_option_valid_attribute_p): As above.
(aarch64_option_valid_version_attribute_p): As above.

3 months agoMAINTAINERS: Add myself to write after approval
Christopher Bazley [Thu, 30 Apr 2026 10:29:14 +0000 (10:29 +0000)] 
MAINTAINERS: Add myself to write after approval

Add an entry for myself to the write after approval list.

ChangeLog:

* MAINTAINERS: Add myself to write after approval.

3 months agoAda: Fix spurious error on primitive function of tagged task type
Eric Botcazou [Thu, 30 Apr 2026 07:27:06 +0000 (09:27 +0200)] 
Ada: Fix spurious error on primitive function of tagged task type

This comes from an internal confusion about the subtype of the controlling
result.  This has probably never worked, but the fix is trivial.

gcc/ada/
PR ada/125044
* sem_disp.adb (Check_Controlling_Formals): Apply the same massaging
to the result subtype as to the parameter subtypes.

gcc/testsuite/
* gnat.dg/task6.ads, gnat.dg/task6.adb: New test.

3 months agotree-optimization/125088 - some TLC to the new vect_bb_slp_scalar_cost
Richard Biener [Thu, 30 Apr 2026 06:39:52 +0000 (08:39 +0200)] 
tree-optimization/125088 - some TLC to the new vect_bb_slp_scalar_cost

This realizes that orig_stmt_info == stmt and refactors control flow
around cost recording to avoid the do { } while (false); loop which
had continue stmts confusing coverity.

PR tree-optimization/125088
* tree-vect-slp.cc (vect_bb_slp_scalar_cost): Refactor and
simplify.
* tree-vect-stmts.cc (vect_nop_conversion_p): Exclude
copies with memory accesses.

3 months agox86_cse: Convert CONST_VECTOR load to constant integer load
H.J. Lu [Wed, 29 Apr 2026 11:50:38 +0000 (19:50 +0800)] 
x86_cse: Convert CONST_VECTOR load to constant integer load

Convert CONST_VECTOR load no larger than integer register:

  (set (reg:V2SI 106)
       (const_vector:V2SI [(const_int 1 [1]) repeated x2]))

to constant integer load:

  (set (subreg:DI (reg:V2SI 106 [ _20 ]) 0)
       (const_int 4294967297 [0x100000001]))

and keep redundant constant integer load.  Generate zero CONST_VECTOR
load which works for both MMX and XMM registers.

Tested on Linux/x86-64 and Linux/i686.

gcc/

PR target/125026
PR target/125032
* config/i386/i386-features.cc (ix86_place_single_vector_set):
Don't check CONST_VECTOR load size.
(replace_vector_const): Handle constant integer load.
(x86_cse::x86_cse): Convert CONST_VECTOR load no larger than
integer to constant integer load and keep redundant constant
integer load.  Generate zero CONST_VECTOR load.

gcc/testsuite/

PR target/125026
PR target/125032
* gcc.target/i386/pr125026.c: New test.
* gcc.target/i386/pr125032-1.c: Likewise.
* gcc.target/i386/pr125032-2.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 months agoUpdate gennews for GCC 16.
Jakub Jelinek [Thu, 30 Apr 2026 08:19:01 +0000 (10:19 +0200)] 
Update gennews for GCC 16.

2026-04-30  Jakub Jelinek  <jakub@redhat.com>

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

3 months agoniter: Make MAX_DOMINATORS_TO_WALK configurable at runtime
Michiel Derhaeg [Wed, 29 Apr 2026 15:38:58 +0000 (08:38 -0700)] 
niter: Make MAX_DOMINATORS_TO_WALK configurable at runtime

MAX_DOMINATORS_TO_WALK can be too small for very large function bodies.
Made it an option such that we can increase the value when needed.

gcc/ChangeLog:

* doc/params.texi: Added --param=max-niter-dominators-walk.
* params.opt: Added --param=max-niter-dominators-walk.
* tree-ssa-loop-niter.cc (MAX_DOMINATORS_TO_WALK): Removed.
(determine_value_range): Updated.
(bound_difference): Updated.
(simplify_using_initial_conditions): Updated.

Signed-off-by: Michiel Derhaeg <michiel@synopsys.com>
3 months agoflip --param ix86-vect-compare-costs default
Richard Biener [Fri, 24 Apr 2026 12:35:49 +0000 (14:35 +0200)] 
flip --param ix86-vect-compare-costs default

The following flips the default of ix86-vect-compare-costs as discussed
during stage3/4.  It adds the testcase from PR120398 and ensures the
existing one works without specifying the --param.

Testcases have been adjusted with simple dump scan adjustments.
gcc.target/i386/vect-epilogues-10.c shows that we compute the
masked epilog to be more expensive than the not masked one.  That's
probably correct as we're facing an in-order reduction.  I have
added -fno-vect-cost-model given this is a testcase for a missing
feature.

PR tree-optimization/120398
PR tree-optimization/123603
* config/i386/i386.opt (ix86-vect-compare-costs): Default to 1.

* gcc.dg/vect/costmodel/x86_64/costmodel-pr120398.c: New testcase.
* gcc.dg/vect/costmodel/x86_64/costmodel-pr123603.c: Adjust.
* gcc.target/i386/vect-alignment-peeling-1.c: Likewise.
* gcc.target/i386/vect-alignment-peeling-2.c: Likewise.
* gcc.target/i386/vect-epilogues-10.c: Add -fno-vect-cost-model.

3 months ago[x86] Avoid gcc.target/i386/shift-gf2p8affine-?.c fails with compare costs
Richard Biener [Wed, 29 Apr 2026 13:26:35 +0000 (15:26 +0200)] 
[x86] Avoid gcc.target/i386/shift-gf2p8affine-?.c fails with compare costs

The following disables epilogue vectorization for the
gcc.target/i386/shift-gf2p8affine-?.c tests so they pass with both
--param ix86-vect-compare-costs=1 and =0.

* gcc.target/i386/shift-gf2p8affine-1.c: Disable epilogue
vectorization.
* gcc.target/i386/shift-gf2p8affine-3.c: Likewise.
* gcc.target/i386/shift-gf2p8affine-7.c: Likewise.

3 months ago[x86] Adjust gcc.target/i386/vect-epilogues-2.c and vect-pr113078.c
Richard Biener [Wed, 29 Apr 2026 09:07:06 +0000 (11:07 +0200)] 
[x86] Adjust gcc.target/i386/vect-epilogues-2.c and vect-pr113078.c

The following adjusts two very similar testcases that when
vector cost comparison is enabled and with generic tuning,
chose to use SSE vector size for the vector epilogue as that
reduces the possible iterations through the scalar epilogue
following that and thus speeds up the overall epilogue processing
for a majority of cases.  I have chosen to duplicate the
testcases for --param ix86-vect-compare-costs=0 and =1.

* gcc.target/i386/vect-epilogues-2.c: Add
--param ix86-vect-compare-costs=0.
* gcc.target/i386/vect-epilogues-2b.c: Duplicate from
gcc.target/i386/vect-epilogues-2.c, add
--param ix86-vect-compare-costs=1 and adjust expected
vectorization.
* gcc.target/i386/vect-pr113078.c: Likewise.
* gcc.target/i386/vect-pr113078b.c: Likewise.

3 months ago[x86] Adjust gcc.target/i386/vect-strided-?.c for cost compare
Richard Biener [Tue, 28 Apr 2026 13:44:41 +0000 (15:44 +0200)] 
[x86] Adjust gcc.target/i386/vect-strided-?.c for cost compare

With cost comparison and MMX-with-SSE vector width available we
prefer to use V2SImode over V4SImode with shuffles, rightfully
so I think.  The following adds variants with explicit cost
compare enabled and disabled and adjusts the cost comparison
variant accordingly.

* gcc.target/i386/vect-strided-1.c: Disable vector cost
comparison.
* gcc.target/i386/vect-strided-2.c: Likewise.
* gcc.target/i386/vect-strided-3.c: Likewise.
* gcc.target/i386/vect-strided-4.c: Likewise.
* gcc.target/i386/vect-strided-1b.c: Copy of
gcc.target/i386/vect-strided-1.c, enable vector cost comparison
and adjust expected code generation.
* gcc.target/i386/vect-strided-2b.c: Likewise.
* gcc.target/i386/vect-strided-3b.c: Likewise.
* gcc.target/i386/vect-strided-4b.c: Likewise.

3 months ago[x86] override vector_costs::better_epilogue_loop_than_p
Richard Biener [Tue, 28 Apr 2026 12:55:04 +0000 (14:55 +0200)] 
[x86] override vector_costs::better_epilogue_loop_than_p

The following resolves the gcc.target/i386/vect-epilogues-3.c failure
when --param ix86-vect-compare-costs=1 is specified.  When the target
requests multiple epilogues to be used and the new candidate is the
epilogue of choice of the currently prevailing epilogue keep that.

But avoid doing so if the new candidate uses a vectorization factor
of one which should be an optimal vector epilog.  This avoids
regressing gcc.dg/vect/costmodel/x86_64/costmodel-pr122573.c

* config/i386/i386.cc (ix86_vector_costs::better_epilogue_loop_than_p):
New.  If the other loop suggests this as epilog prefer other.

3 months ago[x86] override vector_costs::better_main_loop_than_p
Richard Biener [Tue, 28 Apr 2026 09:00:38 +0000 (11:00 +0200)] 
[x86] override vector_costs::better_main_loop_than_p

This overrides vector_costs::better_main_loop_than_p to avoid
regressing gcc.target/i386/vect-partial-vectors-2.c with
--param ix86-vect-compare-costs=1.  As the user (or a tuning model)
asks for masked epilogs the vectorizer considers to mask the
main loop in case it effectively works as a standalone vector epilog
due to known small number of iterations of the loop.  While the
generic cost compare rightfully figures masking of AVX is more expensive
than not masking with SSE it does not consider the cost of the epilog.

This compensates with a x86 specific heuristic that prefers the
masked loop if the loop cannot be vectorized with a non-masked
main loop and at most a single vector epilog plus a single scalar
epilog iteration.  This is a reasonable heuristic for x86 and
a small number of iterations as icache footprint matters here,
so considering the possibility of 3 vector epilogs and 1 scalar
iteration does not look profitable.  Unless testcases will prove
to us otherwise.

I'm not sure if it makes sense to preserve --param ix86-vect-compare-costs=0
in the end, if people think so I'll duplicate the testcase with
both modes explicitly specified.

* tree-vectorizer.h (vector_costs::vinfo): New accessor.
* config/i386/i386.cc (ix86_vector_costs::better_main_loop_than_p):
Prefer a masked main loop if we can elide enough of (vector)
epilog loop iterations.

3 months agolibstdc++: Rework P0952 generate_cannonical tests.
Tomasz Kamiński [Tue, 13 Jan 2026 09:35:42 +0000 (10:35 +0100)] 
libstdc++: Rework P0952 generate_cannonical tests.

This expands on the changes from test fix r16-6710-gda5a5c55284969:
* test name now reflect the size of the generator range,
* extracted code repeated between tests was exctracted to run_generator,
* expanded non-power of two ranges types to cover all IEC559 floating point,
* select values to test based on the size of mantisa instead of type,
  handling different long double representations.

The test now cover the cases, where mutliple value greater than one are
produced (and skipped) in the row. To avoid test running infinite loop,
the number of skips per element is limited by max_skips_per_elem template
parameter of run_generator.

The values checked in test_2p31m1<double> differs from their old test03<double>
counterpart, as we now request mantissa - 5 bits for each type (48bits for
ieee64) instead of previously hardoced 30bits.

libstdc++-v3/ChangeLog:

* testsuite/26_numerics/random/uniform_real_distribution/operators/gencanon.cc:
Updated tests.

Reviewed-by: Nathan Myers <ncm@cantrip.org>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
3 months agoDaily bump.
GCC Administrator [Thu, 30 Apr 2026 00:16:31 +0000 (00:16 +0000)] 
Daily bump.

3 months agomatch: Add MIN<a,b> {<=,>,<,>=} MAX<a,b> simplifications [PR113379]
Pengxuan Zheng [Thu, 26 Mar 2026 18:42:57 +0000 (11:42 -0700)] 
match: Add MIN<a,b> {<=,>,<,>=} MAX<a,b> simplifications [PR113379]

The following patterns and their variants are added.

min(a,b) {<=,>,<,>=} max(a,b) -> {true,false,a!=b,a==b}

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

PR tree-optimization/113379

gcc/ChangeLog:

* match.pd (min(a,b) {<=,>,<,>=} max(a,b)): New patterns.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pengxuan Zheng <pengxuan.zheng@oss.qualcomm.com>
3 months agotestsuite: Fix cond-add-vec-2.C and make cond-add-vec-1.C test some more
Andrew Pinski [Wed, 29 Apr 2026 19:49:49 +0000 (12:49 -0700)] 
testsuite: Fix cond-add-vec-2.C and make cond-add-vec-1.C test some more

With -march=cascadelake/-mavx512f, the VEC_COND_EXPR is turned into a COND_ADD.
This breaks cond-add-vec-2.C check to make sure the conditional add is still there.
So we need to check for COND_ADD or VEC_COND_EXPR in forwprop1.
Even though cond-add-vec-1.C works right now, it is best to make sure COND_ADD is
not there.

Pushed as obvious after testing with and without -march=cascadelake on x86_64.

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/cond-add-vec-1.C: Add a check to make sure COND_ADD
is not there either.
* g++.dg/tree-ssa/cond-add-vec-2.C: Change the check for VEC_COND_EXPR
to allow for COND_ADD.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 months agohppa64: doc/install.texi - Remove incorrect statement regarding GNU ld support
John David Anglin [Wed, 29 Apr 2026 18:09:55 +0000 (14:09 -0400)] 
hppa64: doc/install.texi - Remove incorrect statement regarding GNU ld support

2026-04-29  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

* doc/install.texi (hppa64-hp-hpux11*): Remove incorrect
statement.

3 months agoAArch64: Deprecate -mpc-relative-literal-loads
Wilco Dijkstra [Tue, 3 Feb 2026 18:31:51 +0000 (18:31 +0000)] 
AArch64: Deprecate -mpc-relative-literal-loads

Deprecate -mpc-relative-literal-loads.  Emitting special symbols in
the text section causes issues (see PR123791).  Since the option is
relatively obscure and GCC now uses anchors for literals, there is
no need to keep it.

gcc:
* config/aarch64/aarch64.opt (mpc-relative-literal-loads):
Deprecate.
* config/aarch64/aarch64.cc (aarch64_override_options):
Add deprecated warning for -mpc-relative-literal-loads.
* doc/invoke.texi (mpc-relative-literal-loads): Update docs.

gcc/testsuite:
* gcc.target/aarch64/pr123791.c: Add -Wno-deprecated.
* gcc.target/aarch64/pr78733.c: Likewise.
* gcc.target/aarch64/pr79041-2.c: Likewise.
* gcc.target/aarch64/pr94530.c: Likewise.

3 months agoAArch64: Cleanup code models
Wilco Dijkstra [Wed, 29 Apr 2026 16:04:07 +0000 (16:04 +0000)] 
AArch64: Cleanup code models

Cleanup code models - remove the confusing AARCH64_CMODEL_TINY_PIC,
AARCH64_CMODEL_SMALL_PIC and AARCH64_CMODEL_SMALL_SPIC.  This simplifies
a lot of code. No change to generated code.

gcc:
* config/aarch64/aarch64.h (HAS_LONG_COND_BRANCH): Unused, remove.
(HAS_LONG_UNCOND_BRANCH): unused, remove.
* config/aarch64/aarch64.cc (aarch64_use_pseudo_pic_reg): Declare.
(aarch64_rtx_costs): Update.
(aarch64_override_options_after_change_1): Likewise.
(initialize_aarch64_code_model): Simplify.
(aarch64_classify_tls_symbol): Likewise.
(aarch64_classify_symbol): Simplify, remove duplicated code.
(aarch64_asm_preferred_eh_data_format): Update.
(aarch64_use_pseudo_pic_reg): Update.
* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins):
Remove uses of AARCH64_CMODEL_TINY_PIC, AARCH64_CMODEL_SMALL_PIC,
and AARCH64_CMODEL_SMALL_SPIC.
* config/aarch64/aarch64-opts.h (aarch64_code_model):
Remove AARCH64_CMODEL_TINY_PIC, AARCH64_CMODEL_SMALL_PIC and
AARCH64_CMODEL_SMALL_SPIC.

3 months ago[LRA]: Fix a bug in updating live info in rematerialization
Vladimir N. Makarov [Wed, 29 Apr 2026 13:37:11 +0000 (09:37 -0400)] 
[LRA]: Fix a bug in updating live info in rematerialization

LRA rematerialization ignores that a pseudo can require more one hard reg
when updating live hard reg info.  This can result in wrong
rematerialization. The patch fixes this.

gcc/ChangeLog:

* lra-remat.cc (do_remat): Use the right nregs for pseudo hard reg
when updating live hard regs.

3 months ago[LRA]: Fix a bug in finding conflicts in rematerialization
Vladimir N. Makarov [Wed, 29 Apr 2026 12:50:32 +0000 (08:50 -0400)] 
[LRA]: Fix a bug in finding conflicts in rematerialization

In LRA rematerialization wrong mode is used to find register conflicts. It
can result in wrong rematerialization. The patch fixes this.

gcc/ChangeLog:

* lra-remat.cc (reg_overlap_for_remat_p): Use the right mode for
regno2.

3 months ago[IRA]: Use correct allocno when building conflicts
Vladimir N. Makarov [Wed, 29 Apr 2026 12:15:49 +0000 (08:15 -0400)] 
[IRA]: Use correct allocno when building conflicts

When conflicts are built in IRA a wrong conflict allocno is taken.  The
allocno is used only in assertion which becomes always true and checks
nothing. The patch fixes this.

gcc/ChangeLog:

* ira-conflicts.cc (build_object_conflicts): Use the right
conflicting allocno.

3 months agotree-optimization/125080 - fix SLP scalar stmt coverage for instance roots
Richard Biener [Wed, 29 Apr 2026 12:28:49 +0000 (14:28 +0200)] 
tree-optimization/125080 - fix SLP scalar stmt coverage for instance roots

Even instance roots can be mentioned in externs of other instances
and thus have to be kept scalar.  Consider that.

PR tree-optimization/125080
* tree-vect-slp.cc (vect_bb_slp_mark_stmts_vectorized): Only
add instance root stmts to scalar coverage if they do not
appear in externs.

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

3 months agoc++/modules: memfn merging wrt to obj-ness [PR125035]
Patrick Palka [Wed, 29 Apr 2026 12:48:50 +0000 (08:48 -0400)] 
c++/modules: memfn merging wrt to obj-ness [PR125035]

Here we ICE during declaration merging for the streamed-in static A::f
because we incorrectly match with the in-TU iobj A::f instead of the
in-TU static A::f.

The problem is the merge key doesn't have enough information to discern
between two overloads that essentially only differ by whether they have
an object parameter (and whether it's implicit or explicit).  To that end
this patch adds iobj_p and xobj_p bits to merge_key.

PR c++/125035

gcc/cp/ChangeLog:

* module.cc (merge_key): Add iobj_p and xobj_p bits.
(trees_out::key_mergeable) <case MK_named>: Set and stream
merge_key's iobj_p and xobj_p bits.
(check_mergeable_decl) <case FUNCTION_DECL>: Compare merge_key's
iobj_p and xobj_p bits with that of the given function.
(trees_in::key_mergeable): Stream merge_key's iobj_p and xobj_p
bits.

gcc/testsuite/ChangeLog:

* g++.dg/modules/merge-22.h: New test.
* g++.dg/modules/merge-22_a.H: New test.
* g++.dg/modules/merge-22_b.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoc++/modules+reflection: fix merging typedef struct { } A [PR124582]
Patrick Palka [Wed, 29 Apr 2026 12:48:31 +0000 (08:48 -0400)] 
c++/modules+reflection: fix merging typedef struct { } A [PR124582]

r16-7903 changed the representation of typedefs to an unnamed type, such
as typedef struct { } A, so that we preserve both the unnamed and typedef
TYPE_DECL rather than replacing the unnamed decl.  This patch teaches
modules declaration merging to handle the new representation when streaming
in the unnamed decl, working around the fact that the unnamed decl isn't
visible to name lookup but still has the same DECL_NAME as the typedef decl.

PR c++/124582
PR c++/123810

gcc/cp/ChangeLog:

* module.cc (check_mergeable_decl) <case TYPE_DECL>: Handle
merging a typedef to an unnamed type with the -freflection
representation.

gcc/testsuite/ChangeLog:

* g++.dg/modules/anon-4.h: New test.
* g++.dg/modules/anon-4_a.H: New test.
* g++.dg/modules/anon-4_b.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoFortran: Use internal names for local symbols.
Andre Vehreschild [Tue, 28 Apr 2026 12:30:23 +0000 (14:30 +0200)] 
Fortran: Use internal names for local symbols.

Prevent collision of Fortran symbols with internally generated symbols by
prefixing internals with two underscores.

PR fortran/125021

gcc/fortran/ChangeLog:

* coarray.cc (check_add_new_comp_handle_array): Prefix internal
symbols by two underscores.
(create_get_callback): Same.
(create_allocated_callback): Same.
(create_send_callback): Same.

gcc/testsuite/ChangeLog:

* gfortran.dg/coarray/pr125021.f90: New test.

3 months agoi386: Support HYGON c86-4g series processors
Xin Liu [Wed, 29 Apr 2026 10:56:50 +0000 (10:56 +0000)] 
i386: Support HYGON c86-4g series processors

This patch enables new x86 CPU vendor HYGON ID detection
and adds c86-4g series c86-4g-m{4,6,7} processor supports.
Without such support, if users use -march=native option on
HYGON machines, they can get some old arch like core2, it
would be suboptimal.  It also enables -m{arch,tune}=c86-4g
-m{4,6,7} supports.  Based on the hardware characteristics,
appropriate cost models and tuning parameters are provided.

New machine description files are introduced: c86-4g.md is
used to describe the pipeline for c86-4g-m4 and c86-4g-m6,
while c86-4g-m7.md describes the pipeline for c86-4g-m7.
To better model some pipeline information, it introduces
new attrs c86_attr and c86_decode by following existing
practice.

Bootstrapped and regtested on hygon c86-4g-m4 and c86-4g-m7
machine, as well as a cfarm x86-64 machine.

Co-authored-by: Zhaoling Bao <baozhaoling@hygon.cn>
Signed-off-by: Xin Liu <liulxx@hygon.cn>
Signed-off-by: Zhaoling Bao <baozhaoling@hygon.cn>
gcc/ChangeLog:

* common/config/i386/cpuinfo.h (get_hygon_cpu): Detect the specific
type of HYGON CPU and return HYGON CPU name.
(cpu_indicator_init): Handle HYGON CPU.
* common/config/i386/i386-common.cc (processor_names): Add HYGON
C86-4G processors c86-4g-m{4,6,7}.
(processor_alias_table): Add hygon, hygonfam18h and c86-4g-m{4,6,7}
entries.
(ARRAY_SIZE): Update as new entries added.
* common/config/i386/i386-cpuinfo.h (enum processor_vendor): Add
VENDOR_HYGON.
(enum processor_types): Add HYGONFAM18H.
(enum processor_subtypes): Add HYGONFAM18H_C86_4G_M{4,6,7}.
* config.gcc: Add support for c86_4g_m{4,6,7}.
* config/i386/cpuid.h (signature_HYGON_ebx):  Add signature for HYGON.
(signature_HYGON_ecx): Ditto.
(signature_HYGON_edx): Ditto.
* config/i386/driver-i386.cc (host_detect_local_cpu): Support HYGON
c86-4g-m4{4,6,7} processors.
* config/i386/i386-c.cc (ix86_target_macros_internal): Ditto.
* config/i386/i386-options.cc (m_C86_4G_M4): New definition.
(m_C86_4G_M6): Ditto.
(m_C86_4G_M7): Ditto.
(m_C86_4G): Ditto.
(processor_cost_table): Add cost entries for c86-4g-m4{4,6,7}.
* config/i386/i386.cc (ix86_reassociation_width): Add handlings for
PROCESSOR_C86_4G_M{4,6,7}.
* config/i386/i386.h (enum processor_type): Define
PROCESSOR_C86_4G_M{4,6,7}.
(PTA_C86_4G_M4): New define.
(PTA_C86_4G_M6): Ditto.
(PTA_C86_4G_M7): Ditto.
* config/i386/x86-tune-costs.h (c86_4g_m4_memcpy): New stringop_algs.
(c86_4g_m4_cost): New processor_costs.
(c86_4g_m6_cost): Ditto.
(c86_4g_m7_cost): Ditto.
* config/i386/x86-tune-sched.cc (ix86_issue_rate): Handle
PROCESSOR_C86_4G_M{4,6,7}.
(ix86_adjust_cost): Ditto.
* config/i386/x86-tune.def (X86_TUNE_SCHEDULE): Handle m_C86_4G.
(X86_TUNE_PARTIAL_REG_DEPENDENCY): Ditto.
(X86_TUNE_SSE_PARTIAL_REG_DEPENDENCY): Ditto.
(X86_TUNE_SSE_PARTIAL_REG_FP_CONVERTS_DEPENDENCY): Ditto.
(X86_TUNE_SSE_PARTIAL_REG_CONVERTS_DEPENDENCY): Ditto.
(X86_TUNE_MEMORY_MISMATCH_STALL): Ditto.
(X86_TUNE_FUSE_CMP_AND_BRANCH_32): Ditto.
(X86_TUNE_FUSE_CMP_AND_BRANCH_64): Ditto.
(X86_TUNE_FUSE_CMP_AND_BRANCH_SOFLAGS): Ditto.
(X86_TUNE_USE_LEAVE): Ditto.
(X86_TUNE_PUSH_MEMORY): Ditto.
(X86_TUNE_INTEGER_DFMODE_MOVES): Ditto.
(X86_TUNE_MISALIGNED_MOVE_STRING_PRO_EPILOGUES): Ditto.
(X86_TUNE_USE_SAHF): Ditto.
(X86_TUNE_USE_BT): Ditto.
(X86_TUNE_AVOID_MFENCE): Ditto.
(X86_TUNE_USE_FFREEP): Ditto.
(X86_TUNE_SSE_UNALIGNED_STORE_OPTIMAL): Ditto.
(X86_TUNE_SSE_PACKED_SINGLE_INSN_OPTIMAL): Ditto.
(X86_TUNE_SSE_TYPELESS_STORES): Ditto.
(X86_TUNE_SSE_LOAD0_BY_PXOR): Ditto.
(X86_TUNE_USE_GATHER_2PARTS): Ditto.
(X86_TUNE_USE_GATHER_4PARTS): Ditto.
(X86_TUNE_USE_GATHER_8PARTS): Ditto.
(X86_TUNE_AVOID_128FMA_CHAINS): Ditto.
(X86_TUNE_AVOID_256FMA_CHAINS): Ditto.
(X86_TUNE_USE_RCR): Ditto.
(X86_TUNE_AVX256_MOVE_BY_PIECES): Handle m_C86_4G_M{4,6}.
(X86_TUNE_USE_SCATTER_2PARTS): Handle m_C86_4G_M7.
(X86_TUNE_USE_SCATTER_4PARTS): Ditto.
(X86_TUNE_USE_SCATTER_8PARTS): Ditto.
(X86_TUNE_SSE_REDUCTION_PREFER_PSHUF): Ditto.
(X86_TUNE_AVX512_SPLIT_REGS): Ditto.
(X86_TUNE_AVX512_MOVE_BY_PIECES): Ditto.
(X86_TUNE_AVX512_MASKED_EPILOGUES): Ditto.
* doc/extend.texi: Document about hygonfam18h and c86-4g-m{4,6,7}.
* doc/invoke.texi: Document about c86-4g-m{4,6,7}.
* config/i386/c86-4g-m7.md: New file for c86-4g-m7 scheduling model
information.
* config/i386/c86-4g.md: New file for c86-4g-m{4,6} scheduling model
information.
* config/i386/i386.md (cpu attr): Add c86_4g_m{4,6,7}.
(c86-4g.md): New include.
(c86-4g-m7.md): Ditto.
(*cmpi<unord>xf_i387): Set attr c86_decode.
(*cmpi<unord><MODEF:mode>): Ditto.
(swap<mode>): Ditto.
(*swap<mode>): Ditto.
(extendhisi2): Ditto.
(floathi<mode>2): Ditto.
(float<SWI48x:mode>xf2): Ditto.
(*float<SWI48:mode><MODEF:mode>2): Ditto.
(*floatdi<MODEF:mode>2_i387): Ditto.
(*anddi_1_bt): Ditto.
(*iordi_1_bts): Ditto.
(*xordi_1_btc): Ditto.
(*<btsc><mode>): Ditto.
(*btr<mode>): Ditto.
(*btsq_imm): Ditto.
(*btrq_imm): Ditto.
(*btcq_imm): Ditto.
(*tzcnt<mode>_1): Ditto.
(*tzcnt<mode>_1_falsedep): Ditto.
(*bsf<mode>_1): Ditto.
(*ctz<mode>2_falsedep): Ditto.
(*ctzsi2_zext): Ditto.
(*ctzsi2_zext_falsedep): Ditto.
(bsr_rex64): Ditto.
(bsr_rex64_1): Ditto.
(bsr_rex64_1_zext): Ditto.
(bsr): Ditto.
(bsr_1): Ditto.
(bsr_zext_1): Ditto.
(*bswaphi2_movbe): Ditto.
(*bswaphi2): Ditto.
(bswaphisi2_lowpart): Ditto.
(fpremxf4_i387): Ditto.
(fprem1xf4_i387): Ditto.
(<sincos>xf2): Ditto.
(sincosxf3): Ditto.
(fptanxf4_i387): Ditto.
(atan2xf3): Ditto.
(fyl2xxf3_i387): Ditto.
(fyl2xp1xf3_i387): Ditto.
(fxtractxf3_i387): Ditto.
(*f2xm1xf2_i387): Ditto.
(fscalexf4_i387): Ditto.
(rintxf2): Ditto.
(*movxi_internal_avx512f): Set attr c86_attr.
(*movoi_internal_avx): Ditto.
(*movti_internal): Ditto.
(*movdi_internal): Ditto.
(*movsi_internal): Ditto.
(*movhi_internal): Ditto.
(*movtf_internal): Ditto.
(*movdf_internal): Ditto.
(*movsf_internal): Ditto.
(*zero_extendsidi2): Ditto.
(sqrtxf2): Ditto.
(<smaxmin:code><mode>3): Ditto.
(*ieee_s<ieee_maxmin><mode>3): Ditto.
* config/i386/mmx.md (*mmx_maskmovq): Set attr c86_decode.
(*mmx_maskmovq): Ditto.
(sse_movntq): Set attr c86_attr.
(*mmx_blendps): Ditto.
(mmx_blendvps): Ditto.
(*mmx_pmaddwd): Ditto.
(mmx_pblendvb_v8qi): Ditto.
(mmx_pblendvb_<mode>): Ditto.
(sse4_1_<code>v4qiv4hi2): Ditto.
(sse4_1_<code>v2hiv2si2): Ditto.
(sse4_1_<code>v2qiv2si2): Ditto.
(sse4_1_<code>v2qiv2hi2): Ditto.
(*mmx_pinsrd): Ditto.
(*mmx_pinsrw): Ditto.
(*mmx_pinsrb): Ditto.
(*mmx_pextrw): Ditto.
(*mmx_pextrw<mode>): Ditto.
(*mmx_pextrw_zext): Ditto.
(*mmx_pextrb): Ditto.
(*mmx_pextrb_zext): Ditto.
(*mmx_pblendw64): Ditto.
(*mmx_pblendw32): Ditto.
(*vec_extractv2si_1): Ditto.
(*vec_extractv2si_1_zext): Ditto.
(*pinsrw): Ditto.
(*pinsrb): Ditto.
(*pextrw): Ditto.
(*pextrw<mode>): Ditto.
(*pextrw_zext): Ditto.
(*pextrb): Ditto.
(*pextrb_zext): Ditto.
(*mmx_psadbw): Ditto.
* config/i386/sse.md (ktest<mode>): Set attr c86_decode.
(*kortest<mode>): Ditto.
(sse_cvtsi2ss<rex64namesuffix><round_name>): Ditto.
(sse2_cvtsi2sd): Ditto.
(sse2_maskmovdqu): Ditto.
(*<sse>_dp<ssemodesuffix><avxsizesuffix>): Ditto.
(*<sse4_1_avx2>_mpsadbw): Ditto.
(pclmulqdq): Ditto.
(<mask_codefor>conflict<mode><mask_name>): Ditto.
(<avx512>_blendm<mode>): Set attr c86_attr.
(sse2_movnti<mode>): Ditto.
(<sse>_movnt<mode>): Ditto.
(<sse2>_movnt<mode>): Ditto.
(<sse>_rcp<mode>2): Ditto.
(sse_vmrcpv4sf2): Ditto.
(<mask_codefor>rcp14<mode><mask_name>): Ditto.
(srcp14<mode>): Ditto.
(srcp14<mode>_mask): Ditto.
(<sse>_sqrt<mode>2<mask_name><round_name>): Ditto.
(<sse>_vmsqrt<mode>2<mask_scalar_name><round_scalar_name>): Ditto.
(*<sse>_vmsqrt<mode>2<mask_scalar_name><round_scalar_name>): Ditto.
(<mask_codefor>rsqrt14<mode><mask_name>): Ditto.
(rsqrt14<mode>): Ditto.
(rsqrt14_<mode>_mask"): Ditto.
(*<code><mode>3<mask_name><round_saeonly_name>): Ditto.
(ieee_<ieee_maxmin><mode>3<mask_name><round_saeonly_name>): Ditto.
(*<sse>_vm<code><mode>3<mask_scalar_name><round_saeonly_scalar_name>):
Ditto.
(<sse>_ieee_vm<ieee_maxmin><mode>3<mask_scalar_name>
<round_saeonly_scalar_name>): Ditto.
(*ieee_<ieee_maxmin><mode>3): Ditto.
(avx_h<insn>v4df3): Ditto.
(*sse3_haddv2df3): Ditto.
(sse3_hsubv2df3): Ditto.
(*sse3_haddv2df3_low): Ditto.
(*sse3_hsubv2df3_low): Ditto.
(avx_h<insn>v8sf3): Ditto.
(sse3_h<insn>v4sf3): Ditto.
(*<mask_codefor>reducep<mode><mask_name><round_saeonly_name>): Ditto.
(reduces<mode><mask_scalar_name><round_saeonly_scalar_name>): Ditto.
(*<avx512>_eq<mode>3<mask_scalar_merge_name>_1): Ditto.
(<sse>_andnot<mode>3<mask_name>): Ditto.
(*<code><mode>3<mask_name>): Ditto.
(*andnot<mode>3): Ditto.
(<code><mode>3): Ditto.
(*<code>tf3): Ditto.
(vec_set<mode>_0): Ditto.
(@vec_set<mode>_0): Ditto.
(*sse4_1_extractps): Ditto.
(vec_extract<mode>): Ditto.
(<mask_codefor><avx512>_align<mode><mask_name>): Ditto.
(avx512bw_pmaddwd512<mode><mask_name>): Ditto.
(*avx2_pmaddw): Ditto.
(*sse2_pmaddwd): Ditto.
(*avx2_<code><mode>3): Ditto.
(*avx512f_<code><mode>3<mask_name>): Ditto.
(*avx512bw_<code><mode>3<mask_name>): Ditto.
(*sse4_1_<code><mode>3<mask_name>): Ditto.
(*<code>v8hi3): Ditto.
(*<code>v16qi3): Ditto.
(*andnot<mode>3_mask): Ditto.
(*<code><mode>3): Ditto.
(<code>v1ti3): Ditto.
(<sse2p4_1>_pinsr<ssemodesuffix>): Ditto.
(*<extract_type>_vinsert<shuffletype><extract_suf>_0): Ditto.
(<mask_codefor><extract_type>_vinsert<shuffletype><extract_suf>
_1<mask_name>): Ditto.
(vec_set_lo_<mode><mask_name>): Ditto.
(vec_set_hi_<mode><mask_name>): Ditto.
(<mask_codefor>avx512dq_shuf_<shuffletype>64x2_1<mask_name>): Ditto.
(avx512f_shuf_<shuffletype>64x2_1<mask_name>): Ditto.
(*avx512f_shuf_<shuffletype>64x2_1<mask_name>_1): Ditto.
(avx512vl_shuf_<shuffletype>32x4_1<mask_name>): Ditto.
(avx512f_shuf_<shuffletype>32x4_1<mask_name>): Ditto.
(*avx512f_shuf_<shuffletype>32x4_1<mask_name>_1): Ditto.
(*vec_extract<mode>): Ditto.
(*vec_extract<PEXTR_MODE12:mode>_zext): Ditto.
(*vec_extractv16qi_zext): Ditto.
(*vec_extractv4si): Ditto.
(*vec_extractv4si_zext): Ditto.
(*vec_extractv2di_1): Ditto.
(*vec_concatv2si_sse4_1): Ditto.
(vec_concatv2di): Ditto.
(*<sse2_avx2>_uavg<mode>3<mask_name>): Ditto.
(*<sse2_avx2>_psadbw): Ditto.
(<sse>_movmsk<ssemodesuffix><avxsizesuffix>): Ditto.
(*<sse>_movmsk<ssemodesuffix><avxsizesuffix>_<u>ext): Ditto.
(<sse2_avx2>_pmovmskb): Ditto.
(*<sse2_avx2>_pmovmskb_zext): Ditto.
(*sse2_maskmovdqu): Ditto.
(avx2_ph<plusminus_mnemonic>wv16hi3): Ditto.
(ssse3_ph<plusminus_mnemonic>wv8hi3): Ditto.
(ssse3_ph<plusminus_mnemonic>dv4si3): Ditto.
(avx2_ph<plusminus_mnemonic>dv8si3): Ditto.
(avx2_pmaddubsw256): Ditto.
(avx512bw_pmaddubsw512<mode><mask_name>): Ditto.
(ssse3_pmaddubsw128): Ditto.
(<ssse3_avx2>_psign<mode>3): Ditto.
(ssse3_psign<mode>3): Ditto.
(*abs<mode>2): Ditto.
(abs<mode>2_mask): Ditto.
(abs<mode>2_mask): Ditto.
(sse4a_movnt<mode>): Ditto.
(sse4a_vmmovnt<mode>): Ditto.
(<sse4_1>_blend<ssemodesuffix><avxsizesuffix>): Ditto.
(<sse4_1>_blendv<ssemodesuffix><avxsizesuffix>): Ditto.
(sse4_1_blendv<ssemodesuffix>): Ditto.
(<vi8_sse4_1_avx2_avx512>_movntdqa): Ditto.
(<sse4_1_avx2>_pblendvb): Ditto.
(sse4_1_pblend<ssemodesuffix>): Ditto.
(*avx2_pblend<ssemodesuffix>): Ditto.
(avx2_pblendd<mode>): Ditto.
(avx2_<code>v16qiv16hi2<mask_name>): Ditto.
(avx512bw_<code>v32qiv32hi2<mask_name>): Ditto.
(sse4_1_<code>v8qiv8hi2<mask_name>): Ditto.
(*sse4_1_<code>v8qiv8hi2<mask_name>_1): Ditto.
(<mask_codefor>avx512f_<code>v16qiv16si2<mask_name>): Ditto.
(avx2_<code>v8qiv8si2<mask_name>): Ditto.
(*avx2_<code>v8qiv8si2<mask_name>_1): Ditto.
(sse4_1_<code>v4qiv4si2<mask_name>): Ditto.
(*sse4_1_<code>v4qiv4si2<mask_name>_1): Ditto.
(avx512f_<code>v16hiv16si2<mask_name>): Ditto.
(avx2_<code>v8hiv8si2<mask_name>): Ditto.
(sse4_1_<code>v4hiv4si2<mask_name>): Ditto.
(*sse4_1_<code>v4hiv4si2<mask_name>_1): Ditto.
(avx512f_<code>v8qiv8di2<mask_name>): Ditto.
(*avx512f_<code>v8qiv8di2<mask_name>_1): Ditto.
(avx2_<code>v4qiv4di2<mask_name>): Ditto.
(*avx2_<code>v4qiv4di2<mask_name>_1): Ditto.
(sse4_1_<code>v2qiv2di2<mask_name>): Ditto.
(*sse4_1_<code>v2qiv2di2<mask_name>_1): Ditto.
(avx512f_<code>v8hiv8di2<mask_name>): Ditto.
(avx2_<code>v4hiv4di2<mask_name>): Ditto.
(*avx2_<code>v4hiv4di2<mask_name>_1): Ditto.
(sse4_1_<code>v2hiv2di2<mask_name>): Ditto.
(*sse4_1_<code>v2hiv2di2<mask_name>_1): Ditto.
(avx512f_<code>v8siv8di2<mask_name>): Ditto.
(avx2_<code>v4siv4di2<mask_name>): Ditto.
(sse4_1_<code>v2siv2di2<mask_name>): Ditto.
(*sse4_1_<code>v2siv2di2<mask_name>_1): Ditto.
(sse4_1_round<ssescalarmodesuffix>): Ditto.
(*sse4_1_round<ssescalarmodesuffix>"): Ditto.
(sse4_2_pcmpestri): Ditto.
(sse4_2_pcmpestrm): Ditto.
(sse4_2_pcmpestr_cconly): Ditto.
(sse4_2_pcmpistri): Ditto.
(sse4_2_pcmpistrm): Ditto.
(sse4_2_pcmpistr_cconly): Ditto.
(xop_phadd<u>bw): Ditto.
(xop_phadd<u>bd): Ditto.
(xop_phadd<u>bq): Ditto.
(xop_phadd<u>wd): Ditto.
(xop_phadd<u>wq): Ditto.
(xop_phadd<u>dq): Ditto.
(xop_phsubbw): Ditto.
(xop_phsubwd): Ditto.
(xop_phsubdq): Ditto.
(aesenc): Ditto.
(aesenclast): Ditto.
(aesdec): Ditto.
(aesdeclast): Ditto.
(aesimc): Ditto.
(aeskeygenassist): Ditto.
(<avx2_avx512>_permvar<mode><mask_name>): Ditto.
(avx2_perm<mode>_1<mask_name>): Ditto.
(<avx512>_permvar<mode><mask_name>): Ditto.
(avx512f_perm<mode>_1<mask_name>): Ditto.
(<mask_codefor>avx512f_broadcast<mode><mask_name>): Ditto.
(avx_vbroadcastf128_<mode>): Ditto.
(<mask_codefor>avx512vl_broadcast<mode><mask_name>_1): Ditto.
(<mask_codefor>avx512dq_broadcast<mode><mask_name>_1): Ditto.
(*<avx512>_vpermi2var<mode>3_mask): Ditto.
(<avx512>_vpermt2var<mode>3<sd_maskz_name>): Ditto.
(<avx512>_vpermt2var<mode>3_mask): Ditto.
(*avx_vperm2f128<mode>_nozero): Ditto.
(vec_set_lo_<mode><mask_name>): Ditto.
(vec_set_hi_<mode><mask_name>): Ditto.
(vec_set_lo_<mode>): Ditto.
(vec_set_hi_<mode>): Ditto.
(vec_set_lo_v32qi): Ditto.
(<avx_avx2>_maskload<ssemodesuffix><avxsizesuffix>): Ditto.
(<avx_avx2>_maskstore<ssemodesuffix><avxsizesuffix>): Ditto.
(avx_vec_concat<mode>): Ditto.
(<avx512>_compress<mode>_mask): Ditto.
(compress<mode>_mask): Ditto.
(<avx512>_compressstore<mode>_mask): Ditto.
(compressstore<mode>_mask): Ditto.
(expand<mode>_mask): Ditto.
(<mask_codefor>avx512bw_dbpsadbw<mode><mask_name>): Ditto.
(clz<mode>2<mask_name>): Ditto.
(vpmadd52<vpmadd52type>v8di): Ditto.
(vpmadd52<vpmadd52type><mode>): Ditto.
(vpmadd52<vpmadd52type><mode>_maskz_1): Ditto.
(vpmadd52<vpmadd52type><mode>_mask): Ditto.
(vaesdec_<mode>): Ditto.
(vaesdeclast_<mode>): Ditto.
(vaesenc_<mode>): Ditto.
(vaesenclast_<mode>): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/builtin_target.c: Add handling for HYGON CPUs by
validating the vendor and invoking HYGON-specific CPU detection.
* gcc.target/i386/funcspec-56.inc: Test function target attribute on
{arch,tune}=c86-4g-m{4,6,7}.
* g++.target/i386/mv33.C: New test.

3 months agoOpenMP: Expand "declare mapper" mappers for target {enter,exit,} data directives
Julian Brown [Wed, 29 Apr 2026 10:12:13 +0000 (12:12 +0200)] 
OpenMP: Expand "declare mapper" mappers for target {enter,exit,} data directives

This patch allows 'declare mapper' mappers to be used on 'omp target
data', 'omp target enter data' and 'omp target exit data' directives.
For each of these, only explicit mappings are supported, unlike for
'omp target' directives where implicit uses of variables inside an
offload region might trigger mappers also.

Add support for C and C++.

The patch also adjusts 'map kind decay' to match OpenMP 5.2 semantics,
which is particularly important with regard to 'exit data' operations.

gcc/c-family/
* c-common.h (c_omp_region_type): Add C_ORT_EXIT_DATA,
C_ORT_OMP_EXIT_DATA.
(c_omp_instantiate_mappers): Add region type parameter.
* c-omp.cc (omp_split_map_kind, omp_join_map_kind,
omp_map_decayed_kind): New functions.
(omp_instantiate_mapper): Add ORT parameter.  Implement map kind decay
for instantiated mapper clauses.
(c_omp_instantiate_mappers): Add ORT parameter, pass to
omp_instantiate_mapper.

gcc/c/
* c-parser.cc (c_parser_omp_target_data): Instantiate mappers for
'omp target data'.
(c_parser_omp_target_enter_data): Instantiate mappers for 'omp target
enter data'.
(c_parser_omp_target_exit_data): Instantiate mappers for 'omp target
exit data'.
(c_parser_omp_target): Add c_omp_region_type argument to
c_omp_instantiate_mappers call.
* c-tree.h (c_omp_instantiate_mappers): Remove spurious prototype.

gcc/cp/
* parser.cc (cp_parser_omp_target_data): Instantiate mappers for 'omp
target data'.
(cp_parser_omp_target_enter_data): Instantiate mappers for 'omp target
enter data'.
(cp_parser_omp_target_exit_data): Instantiate mappers for 'omp target
exit data'.
(cp_parser_omp_target): Add c_omp_region_type argument to
c_omp_instantiate_mappers call.
* pt.cc (tsubst_omp_clauses): Instantiate mappers for OMP regions other
than just C_ORT_OMP_TARGET.
(tsubst_expr): Update call to tsubst_omp_clauses for OMP_TARGET_UPDATE,
OMP_TARGET_ENTER_DATA, OMP_TARGET_EXIT_DATA stanza.
* semantics.cc (cxx_omp_map_array_section): Avoid calling
build_array_ref for non-array/non-pointer bases (error reported
already).

gcc/testsuite/
* c-c++-common/gomp/declare-mapper-15.c: New test.
* c-c++-common/gomp/declare-mapper-16.c: New test.
* g++.dg/gomp/declare-mapper-1.C: Adjust expected scan output.

3 months agoRISC-V: Add test for vec_duplicate + vmsgtu.vv combine with GR2VR cost 0, 1 and 15
Pan Li [Mon, 27 Apr 2026 02:04:06 +0000 (10:04 +0800)] 
RISC-V: Add test for vec_duplicate + vmsgtu.vv combine with GR2VR cost 0, 1 and 15

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

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u16.c: Add asm check
for vmsgtu.vx.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary.h: Add test
helper macro.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary_data.h: Add test
data for run test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmsgtu-run-1-u16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmsgtu-run-1-u32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmsgtu-run-1-u64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmsgtu-run-1-u8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
3 months agoRISC-V: Combine vec_duplicate + vmsgtu.vv to vmsgtu.vx on GR2VR cost
Pan Li [Mon, 27 Apr 2026 02:01:52 +0000 (10:01 +0800)] 
RISC-V: Combine vec_duplicate + vmsgtu.vv to vmsgtu.vx on GR2VR cost

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

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

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

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

gcc/ChangeLog:

* config/riscv/predicates.md: Add ltu to swappable
cmp operator.
* config/riscv/riscv-v.cc (get_swapped_cmp_rtx_code): Handle
the swapped rtx code as well.

Signed-off-by: Pan Li <pan2.li@intel.com>
3 months agolibstdc++: Test ATOMIC_*_LOCK_FREE macros for <stdatomic.h>
Tomasz Kamiński [Wed, 29 Apr 2026 07:39:01 +0000 (09:39 +0200)] 
libstdc++: Test ATOMIC_*_LOCK_FREE macros for <stdatomic.h>

Coverage for LWG 4480, "<stdatomic.h> should provide ATOMIC_CHAR8_T_LOCK_FREE".

libstdc++-v3/ChangeLog:

* testsuite/29_atomics/headers/stdatomic.h/macros.cc:
Copy of ../atomic/macros.cc with header include changed.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agolibsanitizer: Fix up build against latest kernel headers
Jakub Jelinek [Wed, 29 Apr 2026 09:14:03 +0000 (11:14 +0200)] 
libsanitizer: Fix up build against latest kernel headers

The Linux kernel recently removed the linux/scc.h header, so gcc (both
16.1-rc2 and trunk) fails to build e.g. on Fedora rawhide now.

The following patch cherry picks a recent upstream fix for this, the macros
defined in that header haven't been really used since 2013-ish.

2026-04-29  Jakub Jelinek  <jakub@redhat.com>

* sanitizer_common/sanitizer_platform_limits_posix.cpp: Cherry picked
from LLVM commit 3dc4fd6dd41100f051a63642f449b16324389c96.

Reviewed-by: Richard Biener <rguenth@suse.de>
3 months agobitintlower: Padding bit fixes, part 6 [PR123635]
Jakub Jelinek [Wed, 29 Apr 2026 09:12:47 +0000 (11:12 +0200)] 
bitintlower: Padding bit fixes, part 6 [PR123635]

I've missed torture/bitint-{93,94}.c FAILs on s390x-linux (i.e. big endian).
For __builtin_mul_overflow, the code to extend the partial most significant
limb is done before memmoving it down, so that limb actually isn't on big
endian at offset 0 but is nelts - obj_nelts.  The following patch computes
obj_nelts first, uses it on big-endian and so that the offset checking
asserts don't trigger, on big-endian also uses NULL_TREE first argument to
limb_access.

2026-04-29  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/123635
* gimple-lower-bitint.cc (bitint_large_huge::finish_arith_overflow):
Move obj_nelts/atype computation before bitint_extended handling.  For
bitint_big_endian in the bitint_extended handling use size_zero_node
only for limb_access_type calls, otherwise use
size_int (nelts - obj_nelts) and pass NULL_TREE as first argument to
limb_access calls.

Reviewed-by: Richard Biener <rguenth@suse.de>
3 months agoBB SLP: Enabling reduction root finding for sum-of-diff kind of patterns
Raghesh Aloor [Tue, 28 Apr 2026 12:24:36 +0000 (17:54 +0530)] 
BB SLP: Enabling reduction root finding for sum-of-diff kind of patterns

Add an optional parameter allow_alt_code to vect_slp_linearize_chain
(default true).  When false, do not follow into MINUS_EXPR when
building a PLUS reduction chain; treat MINUS results as leaves.

This will allow "sum of diffs" (d_i = a[i]-b[i], sum = d0+...+dN)
kind of pattern to be recognized and vectorized. Pure PLUS chains
will still work; other callers of vect_slp_linearize_chain keep the
default.  Once support for MINUS_EXPR in the chain is added, this
call site can be switched to allow_alt_code true.

gcc/ChangeLog:

* tree-vect-slp.cc (vect_slp_linearize_chain): Optional parameter
allow_alt_code added (default true), check added not to follow
MINUS_EXPR, when false.
(vect_slp_check_for_roots): Calls vect_slp_linearize_chain with
parameter allow_alt_code set to false.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/bb-slp-sum-of-diffs.c: New test.

3 months agoc++: Fix up REFLECT_BASE comparison
Jakub Jelinek [Wed, 29 Apr 2026 06:01:02 +0000 (08:01 +0200)] 
c++: Fix up REFLECT_BASE comparison

While writing testcase for PR125007 I found an ICE in cp_tree_equal.
The r16-7260 change to compare_reflections broke REFLECT_BASE comparisons.
It now calls cp_tree_equal on their REFLECT_EXPR_HANDLE which is TREE_BINFO.
It works if lhs == rhs, returns true, or if TREE_CODE is different (returns
false), but otherwise the function isn't prepared to handle TREE_BINFO
and because TREE_BINFO is tcc_exceptional, ends with
     default:
       gcc_unreachable ();
(for --disable-checking it actually works by doing return false; after
this).  This patch fixes that in the third hunk by doing lhs == rhs
comparison only.

2026-04-29  Jakub Jelinek  <jakub@redhat.com>

* reflect.cc (compare_reflection): For REFLECT_BASE use lhs == rhs rather
than cp_tree_equal.

* g++.dg/reflect/compare12.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agotestsuite: Diagnose non-uglified names even in requires exprs
Jakub Jelinek [Wed, 29 Apr 2026 05:58:46 +0000 (07:58 +0200)] 
testsuite: Diagnose non-uglified names even in requires exprs

I was worried we don't handle lambda parameters/captures,
but apparently we do (so I have just added tests to verify that),
and noticed we don't handle params of requires expressions, so
added test coverage for that and handled those in the plugins.

2026-04-29  Jakub Jelinek  <jakub@redhat.com>

* g++.dg/plugin/uglification_plugin.cc (plugin_check_tree): Walk
REQUIRES_EXPR_PARMS of REQUIRES_EXPR.
(plugin_walk_decl): Walk TEMPLATE_PARMS_CONSTRAINTS using
plugin_check_tree.  Walk DECL_INITIAL of CONCEPT_DECL as well.
* g++.dg/plugin/uglification.C: Add tests for non-uglified names
in lambda parameters, lambda captures and requires expressions.

Reviewed-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 months agotestsuite: Add plugin to verify bits/std.cc exports
Jakub Jelinek [Wed, 29 Apr 2026 05:55:02 +0000 (07:55 +0200)] 
testsuite: Add plugin to verify bits/std.cc exports

The following patch adds another g++.dg/plugin/ testsuite plugin,
this time to verify whether some std.cc exports aren't mistakenly
omitted.

The patch is a reworked version of the
https://gcc.gnu.org/pipermail/libstdc++/2025-August/thread.html#62859
proof of concept.  That version just dumped out everything it saw
in the std namespace and its child namespaces (excluding non-inline
subnamespaces with identifiers starting with underscore) and then I've
used sed&grep to form a list of omissions.

This patch keeps the previous walk of std namespace and namespaces children
of it, but it only reports (in this version using error_at instead of inform
previously) what it finds if it isn't exported from the module and is not
deprecated (deprecated attribute is used usually for zombie.names in the
standard).

I've been strugling with the detection of what is and what isn't exported,
had to try several different methods.
What is DECL_MODULE_EXPORT_P is ignored, but that is not set on everything
actually exported.  In other cases there is OVL_EXPORT_P flag on OVERLOAD
(but OVL_HIDDEN_P at the start doesn't have it).  Another case are inline
namespaces, e.g. for std::filesystem::__cxx11::begin or
std::filesystem::__cxx11::directory_iterator.  In the latter case, there
is no sign of the above flags in __cxx11 binding entry, but there is a
USING_DECL with the same name directly in std::filesystem.  And for begin
there is OVERLOAD with OVL_EXPORT_P in std::filesystem but not in
std::filesystem::__cxx11.

2026-04-29  Jakub Jelinek  <jakub@redhat.com>

* g++.dg/plugin/plugin.exp: Set PLUGIN_DEFAULT_REPO.  Add
set*module*exports* to plugin_test_list.  Remove *.gcm files
at the start and end.
* g++.dg/plugin/std_module_exports_plugin.cc: New file.
* g++.dg/plugin/std-module-exports-c++20.C: New test.
* g++.dg/plugin/std-module-exports-c++23.C: New test.
* g++.dg/plugin/std-module-exports-c++26.C: New test.

Reviewed-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 months agotestsuite: Add C++ plugin to check for libstdc++ header uglification
Jakub Jelinek [Wed, 29 Apr 2026 05:49:32 +0000 (07:49 +0200)] 
testsuite: Add C++ plugin to check for libstdc++ header uglification

The following patch adds a plugin (sorry, to check-g++ testsuite rather
than libstdc++ testsuite because in plugin.exp we have all the needed
infrastructure.

The plugin diagnoses non-obfuscated function parameter names, automatic
variable names, template arguments, requires arguments etc., but as an
exception allows non-obfuscated names which appear as function/template
etc. names in std namespace.  The uglification.C test verifies the plugin
diagnoses what it should be.

2026-04-29  Jakub Jelinek  <jakub@redhat.com>

* g++.dg/plugin/plugin.exp (plugin_test_list): Add uglification tests.
* g++.dg/plugin/uglification_plugin.cc: New file.
* g++.dg/plugin/uglification.C: New test.
* g++.dg/plugin/uglification-c++98.C: New test.
* g++.dg/plugin/uglification-c++11.C: New test.
* g++.dg/plugin/uglification-c++14.C: New test.
* g++.dg/plugin/uglification-c++17.C: New test.
* g++.dg/plugin/uglification-c++20.C: New test.
* g++.dg/plugin/uglification-c++23.C: New test.
* g++.dg/plugin/uglification-c++26.C: New test.

Reviewed-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 months agolibstdc++: simd: x86: accept 64-bit long double as double [PR124657]
Alexandre Oliva [Wed, 29 Apr 2026 01:31:32 +0000 (22:31 -0300)] 
libstdc++: simd: x86: accept 64-bit long double as double [PR124657]

Various simd_x86 functions that handle double need to be adjusted to
match 64-bit long double as well.

Introduce __is_x86_ps<_Tp>() and __is_x86_pd<_Tp>() and use them
instead of is_same_v<_Tp, float> and is_same_v<_Tp, double>,
respectively.

for  libstdc++-v3/ChangeLog

PR libstdc++/124657
* include/experimental/bits/simd_x86.h
(__is_x86_ps<_Tp>): New.  Replace is_same_v<_Tp, float> with it.
(__is_x86_pd<_Tp>): New.  Replace is_same_v<_Tp, double> with it.

3 months agolibstdc++: simd: map 64-bit long double to double on sse [PR124657]
Alexandre Oliva [Wed, 29 Apr 2026 01:31:27 +0000 (22:31 -0300)] 
libstdc++: simd: map 64-bit long double to double on sse [PR124657]

When long double is as wide as double on x86 (-mlong-double-64), make
the __intrinsic_type a vector of double.

for  libstdc++-v3/ChangeLog

PR libstdc++/124657
* include/experimental/bits/simd.h (__intrinsic_type::type):
Map long double to double.

3 months agolibstdc++: follow std in numeric_limits<bool>::traps and integral traps
Alexandre Oliva [Wed, 29 Apr 2026 01:31:23 +0000 (22:31 -0300)] 
libstdc++: follow std in numeric_limits<bool>::traps and integral traps

There's a comment from 2002 suggesting that
numeric_limits<bool>::traps was in a DR, but C++ standards including
11, 17 and 23 explicitly set it to false, presumably in response to
issue 184.

Issue 554 clarifies that traps is about values that may trap, rather
than operations that may trap, so we were wrong in the interpretation
about divide-by-zero operations' trapping on integral types that led
to __glibcxx_integral_traps's defaulting to true, and some of its
overrides.

Align numeric_limits<bool>::traps with the standard, default
__glibcxx_integral_traps to false, drop the overriders based on the
incorrect interpretation, but keep __glibcxx_integral_traps to allow
command-line restoring of this ABI fix, and for the admittedly
unlikely case of trapping integral values' coming to exist on some
architecture.

for  libstdc++-v3/ChangeLog

* include/std/limits (__glibcxx_integral_traps): Set to
false.  Update comments.
(numeric_limits<bool>::traps): Drop comments.
* config/cpu/arm/cpu_defines.h: Remove.
* config/cpu/powerpc/cpu_defines.h: Likewise.
* configure.host (cpu_defines_dir): Adjust.

3 months agotestsuite: flag failure to detect failures
Alexandre Oliva [Wed, 29 Apr 2026 01:31:13 +0000 (22:31 -0300)] 
testsuite: flag failure to detect failures

There are various ways for tests to report an execution failure.

Make sure the testing infrastructure can detect all of them, so that
failures don't go silent.

for  gcc/testsuite/ChangeLog

* gcc.dg/shouldfail-abort.c: New.
* gcc.dg/shouldfail-exit-neg.c: New.
* gcc.dg/shouldfail-exit-pos.c: New.
* gcc.dg/shouldfail-return-neg.c: New.
* gcc.dg/shouldfail-return-pos.c: New.

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

3 months agoanalyzer: new warning: -Wanalyzer-div-by-zero (PR analyzer/124217)
David Malcolm [Tue, 24 Feb 2026 23:47:35 +0000 (18:47 -0500)] 
analyzer: new warning: -Wanalyzer-div-by-zero (PR analyzer/124217)

gcc/analyzer/ChangeLog:
PR analyzer/124217
* analyzer.opt (Wanalyzer-div-by-zero): New.
* analyzer.opt.urls: Regenerate.
* region-model.cc (class div_by_zero_diagnostic): New.
(region_model::get_gassign_result): Add warning for division by
zero if ctxt is non-null.  Bail out on such cases even if ctxt
is null.
* svalue.cc (type_can_have_value_range_p): Also handle frange.

gcc/ChangeLog:
PR analyzer/124217
* doc/invoke.texi: Add -Wanalyzer-div-by-zero.

gcc/testsuite/ChangeLog:
PR analyzer/124217
* c-c++-common/analyzer/divide-by-zero-1.c: Update to expect
-Wanalyzer-div-by-zero.
* c-c++-common/analyzer/divide-by-zero-pr124195-2.c: Likewise.
* gcc.dg/analyzer/data-model-1.c (test_21): Split out division by
zero cases into...
(test_21_division_by_zero): ...this, and...
(test_21_modulus_by_zero): ...this, updating these to expect
-Wanalyzer-div-by-zero warnings.
* gcc.dg/analyzer/divide-by-zero-float.c: New test.
* gcc.dg/analyzer/divide-by-zero-ice-pr124433.c: Update to expect
-Wanalyzer-div-by-zero.
* gcc.dg/analyzer/divide-by-zero-pr124195-1.c: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 months agoanalyzer: split out exploded_path into its own files
David Malcolm [Wed, 25 Mar 2026 17:46:51 +0000 (13:46 -0400)] 
analyzer: split out exploded_path into its own files

No functional change intended.

gcc/ChangeLog:
* Makefile.in (ANALYZER_OBJS): Add analyzer/exploded-path.o.

gcc/analyzer/ChangeLog:
* diagnostic-manager.cc: Include "analyzer/exploded-path.h".
* engine.cc: Likewise.
(exploded_path::exploded_path): Move to exploded-path.cc.
(exploded_path::find_stmt_backwards): Likewise.
(exploded_path::get_final_enode): Likewise.
(exploded_path::feasible_p): Likewise.
(exploded_path::dump_to_pp): Likewise.
(exploded_path::dump): Likewise.
(exploded_path::dump_to_file): Likewise.
* exploded-graph.h (class exploded_path): Move to exploded-path.h.
(shortest_exploded_paths): Likewise.
* exploded-path.cc: New file, taken from the above.
* exploded-path.h: Likewise.
* feasible-graph.cc: Include "analyzer/exploded-path.h".

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 months agoanalyzer: split setjmp/longjmp implementation to their own file
David Malcolm [Mon, 23 Mar 2026 20:51:32 +0000 (16:51 -0400)] 
analyzer: split setjmp/longjmp implementation to their own file

No functional change intended.

gcc/ChangeLog:
* Makefile.in (ANALYZER_OBJS): Add analyzer/setjmp-longjmp.o.

gcc/analyzer/ChangeLog:
* analyzer.cc (is_setjmp_call_p): Move to setjmp-longjmp.cc.
(is_longjmp_call_p): Likewise.
* engine.cc (setjmp_record::cmp): Likewise.
(setjmp_svalue::accept): Likewise.
(setjmp_svalue::dump_to_pp): Likewise.
(setjmp_svalue::print_dump_widget_label): Likewise.
(setjmp_svalue::add_dump_widget_children): Likewise.
(setjmp_svalue::get_enode_index): Likewise.
(valid_longjmp_stack_p): Likewise.
(class stale_jmp_buf): Likewise.
(exploded_node::on_longjmp): Likewise.
(rewind_info_t::update_model): Likewise.
(rewind_info_t::add_events_to_path): Likewise.
* region-model.cc (region_model::on_setjmp): Likewise.
(region_model::on_longjmp): Likewise.
* setjmp-longjmp.cc: New file, made from the above material.
* svalue.cc: Update comment.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 months agoanalyzer: split out various pending_diagnostic subclasses from region-model.cc
David Malcolm [Mon, 23 Mar 2026 18:29:27 +0000 (14:29 -0400)] 
analyzer: split out various pending_diagnostic subclasses from region-model.cc

Split up region-model.cc somewhat.  No functional change intended.

gcc/ChangeLog:
* Makefile.in (ANALYZER_OBJS): Add
analyzer/poisoned-value-diagnostic.o,
analyzer/shift-diagnostics.o, and
analyzer/write-to-const-diagnostics.o.

gcc/analyzer/ChangeLog:
* poisoned-value-diagnostic.cc: New file, taken from material in
region-model.cc.
* region-model.cc (class poisoned_value_diagnostic): Move to
poisoned-value-diagnostic.cc.
(class shift_count_negative_diagnostic): Move to
shift-diagnostics.cc.
(class shift_count_overflow_diagnostic): Likewise.
(region_model::get_gassign_result): Use factory functions when
creating diagnostics so that the subclasses can be moved to their
own source files.
(region_model::check_for_poison): Likewise.
(region_model::deref_rvalue): Likewise.
(class write_to_const_diagnostic): Move to
write-to-const-diagnostics.cc.
(class write_to_string_literal_diagnostic): Likewise.
(region_model::check_for_writable_region): Use factory functions
when creating diagnostics so that the subclasses can be moved to
their own source files.
* region-model.h (make_poisoned_value_diagnostic): New decl.
(make_shift_count_negative_diagnostic): New decl.
(make_shift_count_overflow_diagnostic): New decl.
(make_write_to_const_diagnostic): New decl.
(make_write_to_string_literal_diagnostic): New decl.
* shift-diagnostics.cc: New file, taken from material in
region-model.cc.
* write-to-const-diagnostics.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 months agoanalyzer: use concrete_binding_map for compound_svalue (PR analyzer/123145)
David Malcolm [Thu, 15 Jan 2026 19:17:08 +0000 (14:17 -0500)] 
analyzer: use concrete_binding_map for compound_svalue (PR analyzer/123145)

A compound_svalue can only have concrete bindings.  Capture this in the
type system by splitting out the concrete parts of class binding_map
into a new class concrete_binding_map, and use the latter for
compound_svalue.  This also allows some simplifications and
optimizations, where we can use bit_range rather than binding keys.

No functional change intended.

gcc/analyzer/ChangeLog:
PR analyzer/123145
* access-diagram.cc
(compound_svalue_spatial_item::compound_svalue_spatial_item):
Update for compound_svalue using concrete_binding_map rather than
binding_map.
* bounds-checking.cc (strip_types): Likewise.
* call-summary.cc
(call_summary_replay::convert_svalue_from_summary_1): Update for
reimplementation of class binding_map.
(call_summary_replay::convert_svalue_from_summary_1): Likewise.
* infinite-recursion.cc (contains_unknown_p): Update for
compound_svalue using concrete_binding_map rather than
binding_map.
* program-state.cc (sm_state_map::impl_set_state): Likewise.
* region-model-manager.cc (maybe_undo_optimize_bit_field_compare):
Likewise.
(maybe_undo_optimize_bit_field_compare): Avoid building a
concrete_binding key by using get_any_exact_binding.
(region_model_manager::get_or_create_compound_svalue): New
overload, consuming a concrete_binding_map &&.
* region-model-manager.h
(region_model_manager::get_or_create_compound_svalue): New decl
for the above.
* region-model-reachability.cc (reachable_regions::handle_sval):
Update for compound_svalue using concrete_binding_map rather than
binding_map.
(reachable_regions::handle_parm): Likewise.
* region-model.cc (region_model::scan_for_null_terminator_1): Port
from binding_map to concrete_binding_map.
(exposure_through_uninit_copy::calc_num_uninit_bits): Update for
compound_svalue using concrete_binding_map rather than
binding_map.
(contains_uninit_p): Likewise.
* region.cc (decl_region::calc_svalue_for_constructor): Port from
binding_map to concrete_binding_map.
(decl_region::get_svalue_for_initializer): Update call to
get_or_create_compound_svalue.
* store.cc (concrete_binding_map::dump_to_pp): New.
(concrete_binding_map::dump): New.
(concrete_binding_map::add_to_tree_widget): New.
(concrete_binding_map::validate): New.
(binding_map::cmp): Convert to...
(concrete_binding_map::cmp): ...this.
(concrete_binding_map::get_any_exact_binding): New.
(concrete_binding_map::calc_complexity): New.
(concrete_binding_map::remove_overlapping_binding): New.
(concrete_binding_map::remove_overlapping_bindings): New.
(concrete_binding_map::get_overlapping_bindings): New.
(binding_map::put): Update for change to m_concrete.
(binding_map::validate): Likewise.
(binding_map::apply_ctor_to_region): Convert to...
(concrete_binding_map::apply_ctor_to_region): ...this.
(binding_map::apply_ctor_val_to_range): Convert to...
(concrete_binding_map::apply_ctor_val_to_range): ...this.
(binding_map::apply_ctor_pair_to_child_region): Convert to...
(concrete_binding_map::apply_ctor_pair_to_child_region): ...this.
(binding_map::remove_overlapping_bindings): Move part of
implementation to
concrete_binding_map::remove_overlapping_binding.
(binding_cluster::bind_compound_sval): Simplify using
concrete_binding_map.
(binding_cluster::maybe_get_compound_binding): Likewise.
(store::replay_call_summary_cluster): Update for change
to compound_svalue.
* store.h: Include "analyzer/complexity.h".
(class concrete_binding_map): New, based on
binding_map::concrete_bindings_t.
(binding_map::concrete_bindings_t): Use concrete_binding_map.
(binding_map::empty_p): Update for above.
(binding_map::apply_ctor_to_region): Drop decl.
(binding_map::cmp): Likewise.
(binding_map::apply_ctor_val_to_range): Likewise.
(binding_map::apply_ctor_pair_to_child_region): Likewise.
* svalue.cc (svalue::cmp_ptr): Update for change to
compound_svalue.
(compound_svalue::compound_svalue): Port from binding_map to
concrete_binding_map.
(compound_svalue::accept): Likewise.
(compound_svalue::calc_complexity): Drop.
(compound_svalue::maybe_fold_bits_within): Port from binding_map
to concrete_binding_map.
* svalue.h (class compound_svalue): Update leading comment.  Port
from binding_map to concrete_binding_map.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 months agoanalyzer: add known_function handler for strcasecmp
Virginia Kodsy [Wed, 25 Mar 2026 15:39:39 +0000 (17:39 +0200)] 
analyzer: add known_function handler for strcasecmp

This patch adds a known_function handler for strcasecmp to the
static analyzer. It ensures the analyzer checks for null-terminated
string arguments and, when a return value is expected (LHS),
it conjures a symbolic value for the result.

gcc/analyzer/ChangeLog:
* kf.cc (class kf_strcasecmp): New.
(kf_strcasecmp::impl_call_post): New.
(register_known_functions): Register BUILT_IN_STRCASECMP,
"strcasecmp", and "__builtin_strcasecmp".

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/strcasecmp-1.c: New test.

Signed-off-by: Virginia Kodsy <virginiahany9@gmail.com>
3 months agoanalyzer: add test_passthrough for getenv
Ridham Khurana [Sat, 21 Mar 2026 19:37:40 +0000 (01:07 +0530)] 
analyzer: add test_passthrough for getenv

Add a test_passthrough case for getenv to ensure the known_function
correctly handles purely symbolic arguments.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/getenv-1.c (test_passthrough): New test.

Signed-off-by: Ridham Khurana <khurana.ridham222@gmail.com>
3 months agoanalyzer: model getenv
Ridham Khurana [Wed, 18 Mar 2026 14:44:25 +0000 (10:44 -0400)] 
analyzer: model getenv

Model getenv as a known function so that the analyzer bifurcates on
its return value, handling both the NULL and non-NULL cases.

Also check that its argument is a null-terminated string.

gcc/analyzer/ChangeLog:
* kf.cc (class kf_getenv): New.
(kf_getenv::impl_call_post): New.
(register_known_functions): Register kf_getenv.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/getenv-1.c: New test.

Signed-off-by: Ridham Khurana <khurana.ridham222@gmail.com>
3 months agoanalyzer: model mktemp-family success/failure outcomes [PR105890]
Tomás Ortín Fernández [Fri, 20 Mar 2026 14:57:13 +0000 (15:57 +0100)] 
analyzer: model mktemp-family success/failure outcomes [PR105890]

The known_function handlers for the mktemp family all use
set_any_lhs_with_defaults, leaving the return value unconstrained.
This means the analyzer cannot distinguish the success path from the
failure path and cannot, for example, detect use of an invalid file
descriptor returned by mkstemp.

This patch makes the analyzer aware of each function's return
convention.  A nested enum kf_mktemp_family::outcome describes the
three conventions used by the family:

  fd         -- returns a non-negative fd on success, -1 on failure
                (mkstemp, mkostemp, mkstemps, mkostemps).
  null_ptr   -- returns a pointer on success, NULL on failure
                (mkdtemp).
  modif_tmpl -- returns the template pointer; sets template[0] to
                '\0' on failure (mktemp).

Each call is bifurcated into success and failure paths, modeling
the return value and errno according to the outcome.  This enables
fd leak and double-close detection for the fd-returning variants.

A new helper region_model::update_for_null_return is added for the
null_ptr failure path.

The template placeholder check is now in impl_call_post and influences
bifurcation: when the placeholder is definitely invalid, only the
failure path is explored.

Bootstrapped and tested on x86_64-pc-linux-gnu.

gcc/analyzer/ChangeLog:

PR analyzer/105890
* kf.cc (class kf_mktemp_family): Add nested outcome enum,
constructor, and nested failure and success classes.
(kf_mktemp_family::check_template_with_suffixlen_arg): Remove.
(kf_mktemp_family::check_template): Remove.  Both replaced
by...
(kf_mktemp_family::check_for_string_literal_arg): ...this.
(kf_mktemp_family::get_trailing_len): New.
(kf_mktemp_family::impl_call_post): New.
(class kf_mktemp_simple): Add constructor taking outcome.
Replace check_template with check_for_string_literal_arg.
Remove set_any_lhs_with_defaults call.
(class kf_mkostemp): Add constructor.  Replace check_template
with check_for_string_literal_arg.  Remove
set_any_lhs_with_defaults call.
(class kf_mkostemps): Likewise.
(class kf_mkstemps): Likewise.
(register_known_functions): Pass outcome to kf_mktemp_simple
instantiations.
* region-model.cc (region_model::update_for_null_return): New.
* region-model.h (class region_model): Add
update_for_null_return.

gcc/testsuite/ChangeLog:

PR analyzer/105890
* gcc.dg/analyzer/mkdtemp-1.c: Add tests for errno on
success/failure, non-null return identity, and no-lhs call.
* gcc.dg/analyzer/mkostemp-1.c: Prune fd leak warnings.
* gcc.dg/analyzer/mkostemps-1.c: Likewise.
* gcc.dg/analyzer/mkstemp-1.c: Likewise.
* gcc.dg/analyzer/mkstemps-1.c: Likewise.
* gcc.dg/analyzer/mktemp-1.c: Add errno, failure, and success
path tests.
* gcc.dg/analyzer/fd-mktemp-family.c: New test.

Signed-off-by: Tomas Ortin Fernandez (quanrong) <quanrong@mailbox.org>
3 months agoanalyzer: generalize mktemp-family warnings; add -Wanalyzer-mkostemp-redundant-flags...
Tomás Ortín Fernández [Tue, 17 Mar 2026 08:59:41 +0000 (09:59 +0100)] 
analyzer: generalize mktemp-family warnings; add -Wanalyzer-mkostemp-redundant-flags [PR105890]

The patch "analyzer: new warnings -Wanalyzer-mkstemp-missing-suffix
and -Wanalyzer-mkstemp-of-string-literal [PR105890]" added those two
warnings for mkstemp only.  This patch generalizes them to the whole
mktemp family (including GNU extensions): mktemp, mkstemp, mkostemp,
mkstemps, mkostemps, and mkdtemp.

The two warnings are renamed to reflect their broader scope:

  -Wanalyzer-mkstemp-missing-suffix becomes
  -Wanalyzer-mktemp-missing-placeholder.  For the suffixed variants
  (mkstemps, mkostemps), the diagnostic accounts for the suffix length
  when locating the "XXXXXX" placeholder.

  -Wanalyzer-mkstemp-of-string-literal becomes
  -Wanalyzer-mktemp-of-string-literal.

A new warning is also added:

  -Wanalyzer-mkostemp-redundant-flags warns when mkostemp or
  mkostemps is called with flags that include O_RDWR, O_CREAT, or
  O_EXCL, which are already implied by these functions and produce
  errors on some systems.

All three warnings are enabled by default under -fanalyzer.

Bootstrapped and tested on x86_64-pc-linux-gnu.

gcc/analyzer/ChangeLog:

PR analyzer/105890
* analyzer-language.cc (stash_named_constants): Stash O_CREAT,
O_EXCL, and O_RDWR for use by kf.cc.
* analyzer.opt: Rename -Wanalyzer-mkstemp-missing-suffix to
-Wanalyzer-mktemp-missing-placeholder and
-Wanalyzer-mkstemp-of-string-literal to
-Wanalyzer-mktemp-of-string-literal.  Add
-Wanalyzer-mkostemp-redundant-flags.  Fix alphabetical ordering.
* analyzer.opt.urls: Regenerate.
* kf.cc (class mkstemp_of_string_literal): Rename to...
(class mktemp_of_string_literal): ...this.
(class mkstemp_missing_suffix): Rename to...
(class mktemp_missing_placeholder): ...this.  Add trailing_len
parameter for suffixed variants.
(class mkostemp_redundant_flags): New diagnostic class.
(class kf_mktemp_family): New base class with shared template
and flags checking logic.
(kf_mktemp_family::check_template_with_suffixlen_arg): New.
(kf_mktemp_family::check_template): New.
(kf_mktemp_family::check_flags): New.
(kf_mktemp_family::check_placeholder): New.
(class kf_mkstemp): Rename to...
(class kf_mktemp_simple): ...this.  Generalize to handle mktemp,
mkstemp, and mkdtemp.
(class kf_mkostemp): New known_function handler.
(class kf_mkostemps): New known_function handler.
(class kf_mkstemps): New known_function handler.
(register_known_functions): Register all mktemp family handlers.

gcc/ChangeLog:

PR analyzer/105890
* doc/invoke.texi: Rename -Wanalyzer-mkstemp-missing-suffix to
-Wanalyzer-mktemp-missing-placeholder and
-Wanalyzer-mkstemp-of-string-literal to
-Wanalyzer-mktemp-of-string-literal.  Add
-Wanalyzer-mkostemp-redundant-flags.  Fix alphabetical ordering
of detailed descriptions.

gcc/testsuite/ChangeLog:

PR analyzer/105890
* gcc.dg/analyzer/mkstemp-1.c: Update terminology from "suffix"
to "placeholder".
* gcc.dg/analyzer/mkdtemp-1.c: New test.
* gcc.dg/analyzer/mkostemp-1.c: New test.
* gcc.dg/analyzer/mkostemps-1.c: New test.
* gcc.dg/analyzer/mkstemps-1.c: New test.
* gcc.dg/analyzer/mktemp-1.c: New test.

Signed-off-by: Tomas Ortin Fernandez (quanrong) <quanrong@mailbox.org>
3 months agoanalyzer: new warnings -Wanalyzer-mkstemp-missing-suffix and -Wanalyzer-mkstemp-of...
Tomás Ortín Fernández [Thu, 12 Mar 2026 07:58:42 +0000 (08:58 +0100)] 
analyzer: new warnings -Wanalyzer-mkstemp-missing-suffix and -Wanalyzer-mkstemp-of-string-literal [PR105890]

This patch adds two new analyzer warnings for misuse of mkstemp(3):

  -Wanalyzer-mkstemp-of-string-literal warns when a string literal is
  passed to mkstemp.  Since mkstemp modifies its argument in place,
  passing a string literal is undefined behavior (SEI CERT C rule
  STR30-C).  The diagnostic suggests using a writable character array
  instead.

  -Wanalyzer-mkstemp-missing-suffix warns when the template argument
  does not end with the required "XXXXXX" suffix.  This addresses PR
  analyzer/105890.

Both warnings are enabled by default under -fanalyzer.

The checks are in the analyzer rather than -Wformat because mkstemp
does not use a format attribute.  Placing the checks in the analyzer
could also allow interprocedural analysis in the future, once the
analyzer can fully track string contents across function calls.

Bootstrapped and tested on x86_64-pc-linux-gnu.

gcc/analyzer/ChangeLog:

PR analyzer/105890
* analyzer.opt: Add -Wanalyzer-mkstemp-missing-suffix and
-Wanalyzer-mkstemp-of-string-literal.
* analyzer.opt.urls: Add URL entries for the new warnings.
* kf.cc (class mkstemp_of_string_literal): New diagnostic class
for mkstemp called on a string literal.
(class mkstemp_missing_suffix): New diagnostic class for mkstemp
called with a template missing the "XXXXXX" suffix.
(class kf_mkstemp): New known_function handler for mkstemp.
(register_known_functions): Register kf_mkstemp.

gcc/ChangeLog:

PR analyzer/105890
* doc/invoke.texi: Add -Wanalyzer-mkstemp-missing-suffix and
-Wanalyzer-mkstemp-of-string-literal.

gcc/testsuite/ChangeLog:

PR analyzer/105890
* gcc.dg/analyzer/mkstemp-1.c: New test.

Signed-off-by: Tomas Ortin Fernandez (quanrong) <quanrong@mailbox.org>
3 months agoanalyzer: add known function handling for atoi, atol, and atoll
Saksham Gupta [Mon, 9 Mar 2026 06:20:36 +0000 (11:50 +0530)] 
analyzer: add known function handling for atoi, atol, and atoll

This patch adds kf_atoi_family to handle atoi, atol, and atoll functions in the
analyzer, ensuring that the argument is checked for a valid,
null-terminated string.

gcc/analyzer/ChangeLog:
* kf.cc (class kf_atoi_family): New class.
(register_known_functions): Register atoi, atol, and atoll.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/atoi-1.c: Update test coverage.

Signed-off-by: Saksham Gupta <io.sakshamgupta@gmail.com>
3 months agodiagnostics: update status comment in html-sink.cc
David Malcolm [Mon, 27 Apr 2026 15:46:15 +0000 (11:46 -0400)] 
diagnostics: update status comment in html-sink.cc

gcc/ChangeLog:
* diagnostics/html-sink.cc: Update status comment.

3 months agolibgdiagnostics: doc fixes
David Malcolm [Mon, 27 Apr 2026 15:21:42 +0000 (11:21 -0400)] 
libgdiagnostics: doc fixes

Fix a couple of missing API entrypoints:
- diagnostic_execution_path_add_event_via_msg_buf
- diagnostic_message_buffer_end_quote

gcc/ChangeLog:
* doc/libgdiagnostics/topics/execution-paths.rst
(diagnostic_execution_path_add_event_via_msg_buf): Fix
indentation.
* doc/libgdiagnostics/topics/message-buffers.rst: Replace
duplicate entry for diagnostic_message_buffer_end_url with entry
for diagnostic_message_buffer_end_quote.

3 months agodiagnostics: use label_text in diagnostics::option_id_manager
David Malcolm [Thu, 12 Mar 2026 12:48:31 +0000 (08:48 -0400)] 
diagnostics: use label_text in diagnostics::option_id_manager

Eliminate some manual memory management.

gcc/ChangeLog:
* diagnostics/context.h (diagnostics::context::make_option_name):
Convert return type from char * to label_text, and rename to...
(diagnostics::context::get_option_name): ...this.
(diagnostics::context::make_option_url): Likewise, renaming to...
(diagnostics::context::get_option_url): ...this.
* diagnostics/html-sink.cc
(html_builder::make_element_for_diagnostic): Update for above
changes.
* diagnostics/lazy-paths.cc (selftest::all_warnings_disabled):
Update for above changes.
* diagnostics/option-id-manager.h
(diagnostics::option_id_manager::make_option_name): Convert return
type from char * to label_text, and rename to...
(diagnostics::option_id_manager::get_option_name): ...this.
(diagnostics::option_id_manager::make_option_url): Likewise,
renaming to...
(diagnostics::option_id_manager::get_option_url): ...this.
* diagnostics/sarif-sink.cc: Add #define INCLUDE_SET.
(sarif_builder::m_rule_id_set): Convert from
hash_set <free_string_hash> to std::set<std::string>.
(sarif_builder::make_result_object): Update for above changes,
removing manual memory management.
(sarif_builder::make_reporting_descriptor_object_for_warning):
Likewise.
* diagnostics/text-sink.cc (text_sink::print_option_information):
Likewise.
* lto-wrapper.cc (print_lto_docs_link): Likewise.
(lto_diagnostic_option_id_manager::make_option_name): Convert
return type from char * to label_text, and rename to...
(lto_diagnostic_option_id_manager::get_option_name): ...this.
* opts-diagnostic.h (gcc_diagnostic_option_id_manager): Update for
above changes.
* opts.cc
(compiler_diagnostic_option_id_manager::make_option_name): Update
as above, renaming to...
(compiler_diagnostic_option_id_manager::get_option_name): ...this.
(gcc_diagnostic_option_id_manager::make_option_url): Likewise,
renaming to...
(gcc_diagnostic_option_id_manager::get_option_url): ...this.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 months agosarif-replay: decode event IDs [PR123056]
David Malcolm [Tue, 24 Feb 2026 22:54:39 +0000 (17:54 -0500)] 
sarif-replay: decode event IDs [PR123056]

Attempt to round-trip event IDs through in execution paths
through SARIF.

gcc/ChangeLog:
PR sarif-replay/123056
* libsarifreplay.cc: Include "json-pointer-parsing.h".
(sarif_replayer::sarif_replayer): Initialize m_root_val.
(sarif_replayer::m_root_val): New field.
(sarif_replayer::replay_file): Store m_root_val.
(sarif_replayer::append_embeddded_link): Add message_obj param.
Attempt to decode intra-sarif links, turning them into event IDs.
(sarif_replayer::decode_link_within_sarif): New.
(sarif_replayer::make_plain_text_within_result_message): Pass
message_obj to append_embeddded_link.

gcc/testsuite/ChangeLog:
PR sarif-replay/123056
* sarif-replay.dg/2.1.0-invalid/3.10.3-bad-json-pointer.sarif: New
test.
* sarif-replay.dg/2.1.0-valid/embedded-links-pr123056-check-sarif-roundtrip.py
(test_roundtrip_of_url_in_generated_sarif): Update expected
result, to expect the URL for the event.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 months agojson: implement JSON Pointer parsing (RFC 6901)
David Malcolm [Tue, 24 Feb 2026 22:52:30 +0000 (17:52 -0500)] 
json: implement JSON Pointer parsing (RFC 6901)

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Add json-pointer-parsing.o.
* json-pointer-parsing.cc: New file.
* json-pointer-parsing.h: New file.
* json.cc (json::object::set_string): Return a borrowed pointer to
the new json::value.
(json::object::set_integer): Likewise.
(json::array::append_string): Likewise.
* json.h (json::object::set_string): Likewise.
(json::object::set_integer): Likewise.
(json::array::append_string): Likewise.
* selftest-run-tests.cc (selftest::run_tests): Call
selftest::json_pointer_parsing_cc_tests.
* selftest.h (selftest::json_pointer_parsing_cc_tests): New decl.

gcc/testsuite/ChangeLog:
* selftests/json-pointer.json: New support file, taken directly
from RFC 6901.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 months agoIntroduce pretty-print-token-buffer.{cc,h}
David Malcolm [Tue, 24 Feb 2026 22:44:31 +0000 (17:44 -0500)] 
Introduce pretty-print-token-buffer.{cc,h}

Move the implementation of diagnostic_message_buffer from libdiagnostics
to a new pretty-print-token-buffer.{cc,h}, for capturing the tokens from
a pretty-print.

Implement a new class pp_token_buffer_element for replaying the tokens
in a pretty_print_token_buffer into another pretty-print, using "%e".

Add selftests.

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Add pretty-print-token-buffer.o.
* libgdiagnostics.cc: Drop include of "auto-obstack.h".
Include "pretty-print-token-buffer.h".
(class copying_token_printer): Move to
pretty-print-token-buffer.cc.
(struct diagnostic_message_buffer): Reimplement as a subclass of
pretty_print_token_buffer.
(diagnostic_message_buffer::to_string): Rename to
pretty_print_token_buffer::to_string and move to
pretty-print-token-buffer.cc.
* pretty-print-token-buffer.cc: New file, based on material from
libgdiagnostics.cc.
* pretty-print-token-buffer.h: New file, based on material from
libgdiagnostics.h.
* selftest-run-tests.cc (selftest::run_tests): Call
selftest::pretty_print_token_buffer_cc_tests.
* selftest.h (selftest::pretty_print_token_buffer_cc_tests): New
decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 months agojson: move pp_markup::quoted_json_pointer to its own header
David Malcolm [Tue, 24 Feb 2026 22:41:17 +0000 (17:41 -0500)] 
json: move pp_markup::quoted_json_pointer to its own header

gcc/ChangeLog:
* json-diagnostic.cc: Include "pretty-print-markup-json.h".
(class pp_markup::quoted_json_pointer): Move to...
* pretty-print-markup-json.h: ...this new file.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 months agoanalyzer: avoid naked "new"
David Malcolm [Mon, 19 Jan 2026 17:25:55 +0000 (12:25 -0500)] 
analyzer: avoid naked "new"

Modernization; no functional change intended.

gcc/analyzer/ChangeLog:
* access-diagram.cc
(access_diagram_impl::add_aligned_child_table): Use
std::make_unique rather than "new".
(access_diagram_impl::add_valid_vs_invalid_ruler): Likewise.
* checker-path.h (checker_path::replace_event): Use
std::unique_ptr.
* diagnostic-manager.cc
(diagnostic_manager::consolidate_conditions): Use std::make_unique
rather than "new".
* feasible-graph.cc (feasible_graph::make_epath): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 months ago[V3][RISC-V][PR target/124760] Promote SI to DI in some cases to encourage shNadd...
Jeff Law [Tue, 28 Apr 2026 22:55:13 +0000 (16:55 -0600)] 
[V3][RISC-V][PR target/124760] Promote SI to DI in some cases to encourage shNadd insns

So for this testcase:

int foo (int t)
 {
   return 3 * t - 1;
 }

We currently generate:

    slliw    a5,a0,1
    addw    a0,a5,a0
    addiw    a0,a0,-1
    ret

Intuitively we can see we're doing a 32->64 sign extension at each step and we
could drop the intermediate sign extensions.  In fact, not only can we drop the
intermediate sign extensions, we can safely "promote" the intermediate
operations from SI to DI with a final sign extending add.  Conceptually that
unlocks combining the first shift+add into a shNadd insn resulting in this
code:

    sh1add    a0, a0, a0
    addiw    a0, a0, -1
    ret

The patch, but not the testcase, has been in my tree for a while, so it's been
through bootstrap & regression testing on the BPI and Pioneer as well as
testing on riscv32-elf and riscv64-elf. Obviously I'll wait for pre-commit CI
to do its thing before pushing.

PR target/124760
gcc/
* config/riscv/bitmanip.md (SI->DI promoting shadd pattern): Promote
intermediate SI ops to DI ops when there's a final extending op.

gcc/testsuite

* gcc.target/riscv/pr124760.c: New test.

3 months agophiprop: Fix typo [PR125067]
Andrew Pinski [Tue, 28 Apr 2026 19:46:31 +0000 (12:46 -0700)] 
phiprop: Fix typo [PR125067]

When I factored out the code in can_handle_load, I had a small typo
which seemed to work for most cases but I had noticed later on was
broken. Basically the bb where the vop definition has to be dominated
by the current bb (and can't be the current bb).

Pushed as obvious afte a quick bootstrapped.

PR tree-optimization/125067

gcc/ChangeLog:

* tree-ssa-phiprop.cc (can_handle_load): Fix copy and pasto
on dominated_by_p.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 months agoc++/reflection: disallow reflecting block-scope externs (CWG 3065) [PR124756]
Marek Polacek [Fri, 24 Apr 2026 21:30:43 +0000 (17:30 -0400)] 
c++/reflection: disallow reflecting block-scope externs (CWG 3065) [PR124756]

The proposed resolution of CWG 3065 suggests that reflection on a block-scope
extern declaration be ill-formed.  This patch makes it so, and it also
happens to fix a crash.

PR c++/124756

gcc/cp/ChangeLog:

* reflect.cc (get_reflection): Give an error when taking the
reflection of a block-scope extern.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/identifier_of3.C: Add dg-error.
* g++.dg/reflect/pr123612.C: Likewise.
* g++.dg/reflect/error13.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoc++/reflection: improve diagnostic for dependent splices
Marek Polacek [Mon, 20 Apr 2026 17:00:52 +0000 (13:00 -0400)] 
c++/reflection: improve diagnostic for dependent splices

In the parser we've changed the "not usable in a splice" error messages
to the more helpful "expected a reflection of ...", but tsubst_splice_scope
still uses the former.  This patch updates the diagnostic there as well.
Let's also teach inform_tree_category about concepts and alias templates
now that a testcase exercises them.

gcc/cp/ChangeLog:

* error.cc (inform_tree_category): Also print concept and alias
template.
* pt.cc (tsubst_splice_scope): Reword the diagnostic messages.
Call inform_tree_category.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/ns5.C: Adjust expected diagnostics.
* g++.dg/reflect/type9.C: Likewise.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 months ago[LRA]: Fix elimination recognition for INC/DEC RTL
Vladimir N. Makarov [Tue, 28 Apr 2026 13:02:13 +0000 (09:02 -0400)] 
[LRA]: Fix elimination recognition for INC/DEC RTL

There is a typo when we processing {PRE,POST}_{INC,DEC} and
{PRE,POST}_MODIFY to prevent elimination of hard reg operand.  The
condition actually makes to consider pseudos instead of hard reg.  The
patch fixes this.

gcc/ChangeLog:

* lra-eliminations.cc (mark_not_eliminable): Fix condition to
consider hard regs instead of pseudos for INC/DEC/MODIFY operands.

3 months ago[LRA]: Fix mode of subreg of const in the const pool
Vladimir N. Makarov [Tue, 28 Apr 2026 12:51:13 +0000 (08:51 -0400)] 
[LRA]: Fix mode of subreg of const in the const pool

When LRA puts a constant which is part of subreg, it uses wrong mode for
subreg of the pool memory.  The patch fixes this.

gcc/ChangeLog:

* lra-constraints.cc (curr_insn_transform): When recreating subreg
of a const put in pool, use the original subreg mode.

3 months ago[IRA]: Fix implicit preference calculation.
Vladimir N. Makarov [Tue, 28 Apr 2026 12:36:13 +0000 (08:36 -0400)] 
[IRA]: Fix implicit preference calculation.

When searching prefered hard regs from too strict constraints we can ignore
some alternatives for subsequent operands.  This can result in worse code
generation.  The patch fixes this.

gcc/ChangeLog:

* ira-lives.cc (ira_implicitly_set_insn_hard_regs): Use the same
start prefered for all operand.

3 months agophiprop: Move vuse variable declaration to right before use
Andrew Pinski [Fri, 27 Mar 2026 23:05:39 +0000 (16:05 -0700)] 
phiprop: Move vuse variable declaration to right before use

This is just a small cleanup moving the variable declaration
of vuse to right before its use.

Bootstrappd and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-ssa-phiprop.cc (propagate_with_phi): Move vuse variable
declaration right before its use.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>