]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
5 weeks 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.

5 weeks 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

5 weeks 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>
5 weeks 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>
5 weeks 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.

5 weeks 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.

5 weeks 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.

5 weeks 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.

5 weeks 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>
5 weeks 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.

5 weeks 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>
5 weeks 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.

5 weeks 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.

5 weeks 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.

5 weeks 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.

5 weeks 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.

5 weeks 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.

5 weeks 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>
5 weeks agoDaily bump.
GCC Administrator [Thu, 30 Apr 2026 00:16:31 +0000 (00:16 +0000)] 
Daily bump.

5 weeks 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>
5 weeks 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>
5 weeks 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.

5 weeks 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.

5 weeks 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.

5 weeks 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.

5 weeks 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.

5 weeks 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.

5 weeks 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.

5 weeks 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>
5 weeks 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>
5 weeks 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.

5 weeks 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.

5 weeks 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.

5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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.

5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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.

5 weeks 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.

5 weeks 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.

5 weeks 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.

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

5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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.

5 weeks 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.

5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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.

5 weeks 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>
5 weeks 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>
5 weeks 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>
5 weeks 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.

5 weeks 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.

5 weeks 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.

5 weeks 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>
5 weeks agophiprop: Move the check on vuse before the dominator tests
Andrew Pinski [Fri, 27 Mar 2026 22:42:16 +0000 (15:42 -0700)] 
phiprop: Move the check on vuse before the dominator tests

This again is some small optimization of the order of checks here.
The dom tests don't say if the prop can happen any more so putting
them after tests that will cause the prop not to happen is a good thing.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-ssa-phiprop.cc (propagate_with_phi): Move vuse checks
before the dominator tests.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
5 weeks agophiprop: Factor out the vdef check into new function
Andrew Pinski [Fri, 27 Mar 2026 22:25:13 +0000 (15:25 -0700)] 
phiprop: Factor out the vdef check into new function

This is just a small cleanup and should make the code easier
to understand. And it should make it easier to add/allow
to skip over some store statements that don't affect the
variable being loadded.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-ssa-phiprop.cc (propagate_with_phi): Factor out
checking the load for vdef to ....
(can_move_into_conditional): Here.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
5 weeks agotestsuite: Add phiprop testcase that is already fixed [PR116823]
Andrew Pinski [Thu, 9 Apr 2026 19:40:22 +0000 (12:40 -0700)] 
testsuite: Add phiprop testcase that is already fixed [PR116823]

This testcase was extracted from fold-const.cc but was fixed
by r16-4212-gf256a13f8aed83 which removed the clobber.
Since this is fixed seperately from the other improvements,
it is in a seperate patch.

Tested on x86_64-linux-gnu.

PR tree-optimization/116823

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/phiprop-1.C: New test.

5 weeks agolibstdc++: Update C++23 status table
Jonathan Wakely [Tue, 28 Apr 2026 17:09:15 +0000 (18:09 +0100)] 
libstdc++: Update C++23 status table

This hasn't been updated to reflect the new features in GCC 16 (and one
that was backported to gcc-15 for GCC 15.3 but not released yet).

libstdc++-v3/ChangeLog:

* doc/xml/manual/status_cxx2023.xml: Update status table.
* doc/html/manual/status.html: Regenerate.

5 weeks agolibstdc++: Update documentation about default -std option
Jonathan Wakely [Tue, 28 Apr 2026 16:44:35 +0000 (17:44 +0100)] 
libstdc++: Update documentation about default -std option

libstdc++-v3/ChangeLog:

* doc/xml/manual/using.xml (Flags): Update description of
default value for -std option.
* doc/html/manual/using.html: Regenerate.

5 weeks ago[4/6] fold-mem-offsets: Move RISC-V size-optimization workaround to the backend
Philipp Tomsich [Tue, 28 Apr 2026 17:22:35 +0000 (11:22 -0600)] 
[4/6] fold-mem-offsets: Move RISC-V size-optimization workaround to the backend

The fold-mem-offsets pass contained a target-specific workaround that
skipped basic blocks optimized for size, to avoid conflicting with
RISC-V's shorten-memrefs pass.  This penalized all targets.

Move the workaround to the RISC-V backend by disabling fold-mem-offsets
via SET_OPTION_IF_UNSET in riscv_option_override when optimizing for
size with compressed instructions enabled (the same condition that gates
the shorten-memrefs pass).  This preserves the RISC-V behavior while
allowing other targets to fold offsets in size-optimized blocks.

gcc/ChangeLog:

* fold-mem-offsets.cc (pass_fold_mem_offsets::execute): Remove
optimize_bb_for_size_p check.
* config/riscv/riscv.cc (riscv_option_override): Disable
flag_fold_mem_offsets when optimizing for size with compressed
instructions.

5 weeks ago[PATCH] RISC-V: Support Zalasr extension.
Jiawei [Tue, 28 Apr 2026 17:09:05 +0000 (11:09 -0600)] 
[PATCH] RISC-V: Support Zalasr extension.

This patch support RISC-V Zalasr[1](load-acquire/store-release) extension. Based on Edwin Lu's old patch:
https://patchwork.sourceware.org/project/gcc/patch/20250410214940.2712673-1-ewlu@rivosinc.com/

[1] https://docs.riscv.org/reference/isa/extensions/zalasr/_attachments/riscv-zalasr.pdf

Co-Authored-by: Edwin Lu <ewlu@rivosinc.com>
gcc/ChangeLog:

* config/riscv/riscv-ext.def: New extension.
* config/riscv/riscv-ext.opt: Ditto.
* config/riscv/sync-rvwmo.md: Add check for zalasr.
* config/riscv/sync-ztso.md: Ditto.
* doc/riscv-ext.texi: New extension.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/amo/a-rvwmo-fence.c: Disable zalasr from -march.
* gcc.target/riscv/amo/a-rvwmo-load-acquire.c: Ditto.
* gcc.target/riscv/amo/a-rvwmo-load-relaxed.c: Ditto.
* gcc.target/riscv/amo/a-rvwmo-load-seq-cst.c: Ditto.
* gcc.target/riscv/amo/a-rvwmo-store-compat-seq-cst.c: Ditto.
* gcc.target/riscv/amo/a-rvwmo-store-relaxed.c: Ditto.
* gcc.target/riscv/amo/a-rvwmo-store-release.c: Ditto.
* gcc.target/riscv/amo/a-ztso-fence.c: Ditto.
* gcc.target/riscv/amo/a-ztso-load-acquire.c: Ditto.
* gcc.target/riscv/amo/a-ztso-load-relaxed.c: Ditto.
* gcc.target/riscv/amo/a-ztso-load-seq-cst.c: Ditto.
* gcc.target/riscv/amo/a-ztso-store-compat-seq-cst.c: Ditto.
* gcc.target/riscv/amo/a-ztso-store-relaxed.c: Ditto.
* gcc.target/riscv/amo/a-ztso-store-release.c: Ditto.
* gcc.target/riscv/amo/zaamo-preferred-over-zalrsc.c: Ditto.
* gcc.target/riscv/amo/zaamo-rvwmo-amo-add-int.c: Ditto.
* gcc.target/riscv/amo/zaamo-ztso-amo-add-int.c: Ditto.
* gcc.target/riscv/amo/zabha-rvwmo-all-amo-ops-char.c: Ditto.
* gcc.target/riscv/amo/zabha-rvwmo-all-amo-ops-short.c: Ditto.
* gcc.target/riscv/amo/zabha-rvwmo-amo-add-char.c: Ditto.
* gcc.target/riscv/amo/zabha-rvwmo-amo-add-short.c: Ditto.
* gcc.target/riscv/amo/zabha-zacas-atomic-cas.c: Ditto.
* gcc.target/riscv/amo/zabha-zacas-preferred-over-zalrsc.c: Ditto.
* gcc.target/riscv/amo/zabha-ztso-amo-add-char.c: Ditto.
* gcc.target/riscv/amo/zabha-ztso-amo-add-short.c: Ditto.
* gcc.target/riscv/amo/zacas-char-requires-zabha.c: Ditto.
* gcc.target/riscv/amo/zacas-char-requires-zacas.c: Ditto.
* gcc.target/riscv/amo/zacas-preferred-over-zalrsc.c: Ditto.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-char-acq-rel.c: Ditto.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-char-acquire.c: Ditto.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-char-relaxed.c: Ditto.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-char-release.c: Ditto.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-char-seq-cst.c: Ditto.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-compatability-mapping-no-fence.c: Ditto.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-compatability-mapping.cc: Ditto.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-int-acq-rel.c: Ditto.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-int-acquire.c: Ditto.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-int-relaxed.c: Ditto.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-int-release.c: Ditto.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-int-seq-cst.c: Ditto.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-short-acq-rel.c: Ditto.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-short-acquire.c: Ditto.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-short-relaxed.c: Ditto.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-short-release.c: Ditto.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-short-seq-cst.c: Ditto.
* gcc.target/riscv/amo/zacas-ztso-compare-exchange-char.c: Ditto.
* gcc.target/riscv/amo/zacas-ztso-compare-exchange-compatability-mapping-no-fence.c: Ditto.
* gcc.target/riscv/amo/zacas-ztso-compare-exchange-compatability-mapping.cc: Ditto.
* gcc.target/riscv/amo/zacas-ztso-compare-exchange-int-seq-cst.c: Ditto.
* gcc.target/riscv/amo/zacas-ztso-compare-exchange-int.c: Ditto.
* gcc.target/riscv/amo/zacas-ztso-compare-exchange-short-seq-cst.c: Ditto.
* gcc.target/riscv/amo/zacas-ztso-compare-exchange-short.c: Ditto.
* gcc.target/riscv/amo/zalrsc-rvwmo-amo-add-int.c: Ditto.
* gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-acquire-release.c: Ditto.
* gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-acquire.c: Ditto.
* gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-consume.c: Ditto.
* gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-relaxed.c: Ditto.
* gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-release.c: Ditto.
* gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-seq-cst-relaxed.c: Ditto.
* gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-seq-cst.c: Ditto.
* gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-acq-rel.c: Ditto.
* gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-acquire.c: Ditto.
* gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-relaxed.c: Ditto.
* gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-release.c: Ditto.
* gcc.target/riscv/amo/zalrsc-rvwmo-subword-amo-add-char-seq-cst.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-amo-add-int.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-acquire-release.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-acquire.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-consume.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-relaxed.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-release.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-seq-cst-relaxed.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-seq-cst.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-acq-rel.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-acquire.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-relaxed.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-release.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-subword-amo-add-char-seq-cst.c: Ditto.
* lib/target-supports.exp: Add zalasr checks.
* gcc.target/riscv/amo/zalasr-rvwmo-load-acquire.c: New test.
* gcc.target/riscv/amo/zalasr-rvwmo-load-relaxed.c: New test.
* gcc.target/riscv/amo/zalasr-rvwmo-load-seq-cst.c: New test.
* gcc.target/riscv/amo/zalasr-rvwmo-store-compat-seq-cst.c: New test.
* gcc.target/riscv/amo/zalasr-rvwmo-store-relaxed.c: New test.
* gcc.target/riscv/amo/zalasr-rvwmo-store-release.c: New test.
* gcc.target/riscv/amo/zalasr-ztso-load-acquire.c: New test.
* gcc.target/riscv/amo/zalasr-ztso-load-relaxed.c: New test.
* gcc.target/riscv/amo/zalasr-ztso-load-seq-cst.c: New test.
* gcc.target/riscv/amo/zalasr-ztso-store-compat-seq-cst.c: New test.
* gcc.target/riscv/amo/zalasr-ztso-store-relaxed.c: New test.
* gcc.target/riscv/amo/zalasr-ztso-store-release.c: New test.

Co-Authored-by: Edwin Lu <ewlu@rivosinc.com>
5 weeks ago[PATCH 3/3] libsanitizer: RISC-V supports HWASAN.
Maximilian Ciric [Tue, 28 Apr 2026 17:04:17 +0000 (11:04 -0600)] 
[PATCH 3/3] libsanitizer: RISC-V supports HWASAN.

With both libsanitizer and the RISC-V back end supporting HWASAN, enable
building libsanitizer with HWASAN support for RISC-V targets.

------

libsanitizer/ChangeLog:

* configure.tgt: Enable HWASAN support for RISC-V target.

5 weeks ago[PATCH 2/3] RISC-V: Enable address tagging on 64-bit targets supporting pointer masking.
Maximilian Ciric [Tue, 28 Apr 2026 17:00:45 +0000 (11:00 -0600)] 
[PATCH 2/3] RISC-V: Enable address tagging on 64-bit targets supporting pointer masking.

Implements TARGET_MEMTAG_CAN_TAG_ADDRESSES and TARGET_MEMTAG_TAG_BITSIZE
for the RISC-V back end, allowing -fsanitize=hwaddress if the target
machine supports the pointer masking extension.

------

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_can_tag_addresses): New function.
(RISCV_HWASAN_TAG_SIZE): New definition.
(riscv_memtag_tag_bitsize): New function.
(TARGET_MEMTAG_CAN_TAG_ADDRESSES): New definition.
(TARGET_MEMTAG_TAG_BITSIZE): Likewise.

5 weeks agopru: Allow device spec to append assembler command line
Dimitar Dimitrov [Sat, 7 Mar 2026 21:16:13 +0000 (23:16 +0200)] 
pru: Allow device spec to append assembler command line

Intended use case is for asm_device spec to specify the PRU core
revision.

This could alternatively be implemented with spec append for *asm.
But linker and cpp already use *_device spec variables, so let's
be consistent.

gcc/ChangeLog:

* config/pru/pru.h (ASM_SPEC): Define.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
5 weeks ago[HWASAN] [RISC-V] Update EnableTaggingAbi for RISC-V linux. (#176616)
Tharo [Tue, 28 Apr 2026 16:19:13 +0000 (10:19 -0600)] 
[HWASAN] [RISC-V] Update EnableTaggingAbi for RISC-V linux. (#176616)

Cherry-picked from LLVM commit: 32d21326f3b60874fd72bbe509c06dbe5b729a32
Enabling pointer tagging in the userspace ABI for RISC-V kernels differs
to that of Aarch64. It requires requesting a particular number of masked
pointer bits, an error is returned if the platform could not accommodate
the request:
https://docs.kernel.org/arch/riscv/uabi.html#pointer-masking

While experimenting with enabling RISC-V HWASAN on GCC I was hitting the
error

> HWAddressSanitizer failed to enable tagged address syscall ABI

when attempting to run instrumented programs in the spike simulator
running kernel release 6.18. This patch successfully allows the tagged
address syscall ABI to be enabled by the support runtime.

5 weeks ago[RISC-V][PR tree-optimization/94892] Improve equality test of sign bit splat against...
Jeff Law [Tue, 28 Apr 2026 16:07:07 +0000 (10:07 -0600)] 
[RISC-V][PR tree-optimization/94892] Improve equality test of sign bit splat against zero

One of the tests in pr94892 showed a case where we failed to convert a
sign bit splat + equality test against into a simple lt/ge test which
doesn't require the sign bit splat.

This is only failing on rv64, probably because the case in question has
a DI sign bit splat, then we take a lowpart SI subreg.  The lowpart
dance isn't needed for rv32, though I've structured the test to verify
that we get sensible code on rv32 as well as rv64.

Like many other patches I'm submitting now, this has been in my tester
for a while, but the test has not.  I'll be waiting on the pre-commit
tester to verify sanity before moving forward.  I'm particularly
interested to see how it behaves with no -march flags.  It should be
taking the defaults from when the toolchain was built, which should do
what we want.

Jeff

PR tree-optimization/94892
gcc/
* config/riscv/riscv.md (sign_bit_splat_equality_test): New pattern.

gcc/testsuite/

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

5 weeks agolibstdc++: Make pointer_traits::pointer_to constexpr for main template.
Tomasz Kamiński [Tue, 28 Apr 2026 14:01:47 +0000 (16:01 +0200)] 
libstdc++: Make pointer_traits::pointer_to constexpr for main template.

This resolves LWG3454, "pointer_traits::pointer_to should be constexpr",
accepted in Kona 2025.

The change is applied since C++20, i.e. standard in which pointer_to
was made constexpr for T* specialization.

libstdc++-v3/ChangeLog:

* include/bits/ptr_traits.h (__ptr_traits_ptr_to::pointer_to):
Define as constexpr since C++20.
* testsuite/20_util/pointer_traits/pointer_to_constexpr.cc:
New test for custom pointer-like type.

5 weeks agolibstdc++: Expand tests for std::type_order.
Tomasz Kamiński [Wed, 22 Apr 2026 10:30:19 +0000 (12:30 +0200)] 
libstdc++: Expand tests for std::type_order.

Expanded test coverage to include:
* array of unknown bounds
* function types and pointers
* data and function member pointers

libstdc++-v3/ChangeLog:

* testsuite/18_support/comparisons/type_order/1.cc: Add tests
for more type.

gcc/testsuite/ChangeLog:

* g++.dg/cpp26/type-order1.C: Add tests for more type.

Reviewed-by: Jakub Jelinek <jakub@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 weeks agolibgomp.fortran/map-subarray-6.f90: Fix and robustify
Tobias Burnus [Tue, 28 Apr 2026 12:15:21 +0000 (14:15 +0200)] 
libgomp.fortran/map-subarray-6.f90: Fix and robustify

Changes:
* Actually initialize the proper variable.
* Handle the three cases explicitly: self mapping/host fallback, mapping
  but host accessible and mapping and (potentially) not host accessible.
  Hence, remove 'dg-should-fail' - as the code should now always run.
* Add more checks for not pointer attaching, using values outside mapped
  range.
* Add several comments and handle the case that 'tgt' is actually removed
  during gimplification as unused. (Two cases: once the result with 'tgt'
  removed - and once using 'tgt'/'tgt2' in the target region - and checking
  then for the result).

libgomp/ChangeLog:

* testsuite/libgomp.fortran/map-subarray-6.f90: Fix, extend, and
robustify.

5 weeks agoAvoid live code-generation for stmts kept as scalars
Richard Biener [Thu, 5 Mar 2026 10:20:44 +0000 (11:20 +0100)] 
Avoid live code-generation for stmts kept as scalars

The following avoids trying to code-generate live lane extracts for
scalar defs that we have to keep anyway because they are used in
SLP graph leafs as extern inputs.

This resolves the known cases of one of the workarounds in live
code-generation.

* tree-vect-slp.cc (vect_bb_slp_mark_live_stmts): Do not
attempt to live code-generate defs that are kept in scalar
form anyway.
* tree-vect-loop.cc (vectorizable_live_operation): Update
comment.

5 weeks agoCost each BB vect live lane only once
Richard Biener [Tue, 3 Mar 2026 14:09:22 +0000 (15:09 +0100)] 
Cost each BB vect live lane only once

The following makes sure to cost live scalar stmts appearing in multiple
SLP nodes only once and code-generate them from the SLP node we verified
we can replace all scalar uses from.

* tree-vectorizer.h (_slp_tree::live_lanes): New vector.
(SLP_TREE_LIVE_LANES): New.
* tree-vect-loop.cc (vectorizable_live_operation): Append
to SLP_TREE_LIVE_LANES.
* tree-vect-slp.cc (_slp_tree::_slp_tree): Initialize
SLP_TREE_LIVE_LANES.
(_slp_tree::~_slp_tree): Release SLP_TREE_LIVE_LANES.
(vect_print_slp_tree): Adjust live lane dumping, indicating
the SLP node a lane is code generated from.
(vect_bb_slp_mark_live_stmts): No longer verify we can
code-generate from all SLP nodes but at least one, picking
the first.
* tree-vect-stmts.cc (vect_transform_stmt): Iterate over
SLP_TREE_LIVE_LANES.
(vect_analyze_stmt): Also analyze reductions for live
lanes.

5 weeks agotree-optimization/124222 - rewrite BB SLP costing scalar coverage
Richard Biener [Wed, 25 Feb 2026 08:08:07 +0000 (09:08 +0100)] 
tree-optimization/124222 - rewrite BB SLP costing scalar coverage

The following uses the vector coverage indicated by SLP_TREE_TYPE to
improve and simplify BB vector scalar costing, finally handling SLP
patterns properly.

PR tree-optimization/124222
* tree-vect-slp.cc (vect_slp_gather_vectorized_scalar_stmts): Remove.
(vect_bb_slp_scalar_cost): Simplify by using SLP_TREE_TYPE and
a use-def walk of the scalar stmts SSA uses.
(vect_bb_vectorization_profitable_p): Simplify.

* gcc.dg/vect/costmodel/x86_64/costmodel-pr124222.c: New testcase.

5 weeks agoSimplify vect_bb_slp_mark_live_stmts
Richard Biener [Mon, 2 Mar 2026 13:53:04 +0000 (14:53 +0100)] 
Simplify vect_bb_slp_mark_live_stmts

The following uses the full scalar stmt coverage now denoted by
SLP_TREE_TYPE to simplify computing STMT_VINFO_LIVE_P for code
generation of live lanes.

* tree-vect-slp.cc (vec_slp_has_scalar_use): Remove.
(vect_bb_slp_mark_live_stmts): Simplify.

5 weeks agoRe-do vect_mark_slp_stmts to compute full scalar stmt coverage
Richard Biener [Tue, 3 Mar 2026 12:48:17 +0000 (13:48 +0100)] 
Re-do vect_mark_slp_stmts to compute full scalar stmt coverage

The following re-purposes STMT_SLP_TYPE for BB vectorization to indicate
the scalar (non-pattern) stmt coverage of the vectorized SLP graph.
This will allow for simpler and more precise determining of live lanes
and scalar costing.

* tree-vect-slp.cc (vect_slp_analyze_bb_1): Split out pure_slp
marking into ...
(vect_bb_slp_mark_stmts_vectorized): ... new function.  Compute
full scalar stmt coverage of the SLP graph.
(vect_slp_gather_extern_scalar_stmts): New helper.
(vect_bb_slp_mark_live_stmts): Adjust.
* tree-vect-loop.cc (vectorizable_live_operation): Likewise.

5 weeks agoAdd slp_oprnds class
Richard Biener [Thu, 26 Feb 2026 12:30:41 +0000 (13:30 +0100)] 
Add slp_oprnds class

This adds a helper class to marshall between SLP and GIMPLE operands.

* tree-vect-slp.cc (struct slp_oprnds): New.

5 weeks agoMove BB analysis code to make flow more obvious
Richard Biener [Mon, 2 Mar 2026 14:10:14 +0000 (15:10 +0100)] 
Move BB analysis code to make flow more obvious

The following moves BB vect live stmt marking out of
vect_slp_analyze_operations to vect_slp_analyze_bb_1 and SLP stmt marking,
marking some vectorized stmts as PURE_SLP, right before it which
is the only remaining consumer.

* tree-vect-slp.cc (vect_slp_analyze_operations): Move
vect_bb_slp_mark_live_stmts call ...
(vect_slp_analyze_bb_1): ... here.  Move SLP stmt marking
right before it.
(vect_mark_slp_stmts): Remove unused overload.

5 weeks agoCleanup vect_slp_child_index_for_operand and vect_get_operand_map APIs
Richard Biener [Thu, 26 Feb 2026 12:27:53 +0000 (13:27 +0100)] 
Cleanup vect_slp_child_index_for_operand and vect_get_operand_map APIs

This makes them get a stmt_vec_info, eliding the separate gather-scatter
flag argument.

* tree-vectorizer.h (vect_slp_child_index_for_operand): Get
a stmt_vec_info, elide gather-scatter flag.
* tree-vect-stmts.cc (vect_check_store_rhs): Adjust.
(vectorizable_simd_clone_call): Likewise.
(vectorizable_store): Likewise.
(vectorizable_load): Likewise.
* tree-vect-slp.cc (vect_get_operand_map): New overload
with a stmt_vec_info argument.
(vect_slp_child_index_for_operand): Adjust.
(vect_get_and_check_slp_defs): Likewise.
(compatible_calls_p): Likewise.
(vect_build_slp_tree_2): Likewise.

5 weeks agoHandle VIEW_CONVERT_EXPR via vect_get_operand_map
Richard Biener [Wed, 25 Feb 2026 15:08:37 +0000 (16:08 +0100)] 
Handle VIEW_CONVERT_EXPR via vect_get_operand_map

The following makes VIEW_CONVERT_EXPR handling in vect_get_and_check_slp_defs
transparent via vect_get_operand_map, thereby applying some TLC there.

* tree-vect-slp.cc (vect_get_operand_map): Put operand map
data here.  Handle VIEW_CONVERT_EXPR, use else if, factor
out assertion.
(vect_get_and_check_slp_defs): Remove explicit VIEW_CONVERT_EXPR
handling here.