]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 weeks agogccrs: Support generic constant impl items
Philip Herron [Sun, 9 Nov 2025 20:28:50 +0000 (20:28 +0000)] 
gccrs: Support generic constant impl items

Impl items can have constants defined which could in turn be generic this was
not supported by gccrs and missed. So for example:

  impl<T> Foo<T> {
    const MAGIC: usize = mem::size_of::<T>();
  }

This is a normal type parameter but in order to setup the generics we need to
create a synthetic TyTy::FnType so we can bind the parent's impl generics to
the type system and it just works like any other generic item at that point.
Then for example we have:

  impl<const N: usize> Foo<N> {
    const VALUE: usize = N;
  }

Again we consistently bind the this const generic parameter the same way so
the lazy evaluation of the generic can take place.

gcc/rust/ChangeLog:

* backend/rust-compile-item.cc (CompileItem::visit): support the synthetic function consts
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::Resolve): likewise
* typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItem::visit): create the synth
* typecheck/rust-tyty.h: new flag for synthetic constant

gcc/testsuite/ChangeLog:

* rust/execute/torture/const-generics-5.rs: New test.
* rust/execute/torture/const-generics-6.rs: New test.
* rust/execute/torture/const-generics-7.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2 weeks agogccrs: Fix const generics handling on array types
Philip Herron [Sun, 9 Nov 2025 15:49:09 +0000 (15:49 +0000)] 
gccrs: Fix const generics handling on array types

When we were processing generic const param types on arrays the size type
was overriding the const param decl because of a hirid reference mismatch

Fixes Rust-GCC#3879

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): fix mappings

gcc/testsuite/ChangeLog:

* rust/compile/const_generics_18.rs: New test.
* rust/compile/const_generics_19.rs: New test.
* rust/execute/torture/const-generics-3.rs: New test.
* rust/execute/torture/const-generics-4.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2 weeks agogccrs: make invalid inner attributes show error
Lucas Ly Ba [Mon, 3 Nov 2025 16:28:56 +0000 (16:28 +0000)] 
gccrs: make invalid inner attributes show error

gcc/rust/ChangeLog:

* ast/rust-ast.cc (Attribute::is_derive):
Change is_derive method with its valid path.
* util/rust-attribute-values.h:
Delete redudant derive attribute.
* util/rust-attributes.cc (AttributeChecker::check_inner_attribute):
Helper method for check_inner_attributes
(AttributeChecker::check_inner_attributes):
Implement method for errors check.
* util/rust-attributes.h:
Add methods above in header.

gcc/testsuite/ChangeLog:

* rust/compile/issue-4212.rs:
* rust/compile/issue-4219.rs: New test.

Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
2 weeks agogccrs: fix ICE on missing pattern in while loop
Lucas Ly Ba [Mon, 13 Oct 2025 11:01:54 +0000 (11:01 +0000)] 
gccrs: fix ICE on missing pattern in while loop

Adds a proper check for missing patterns in while expressions.

Fixes Rust-GCC#4162

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h(Parser<ManagedTokenSource>::parse_while_let_loop_expr):
Add check for missing pattern.

gcc/testsuite/ChangeLog:
* rust/compile/issue-4162.rs: New test.

Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
2 weeks agogccrs: fix cfg attribute error with literal predicate
Lucas Ly Ba [Thu, 6 Nov 2025 16:26:12 +0000 (16:26 +0000)] 
gccrs: fix cfg attribute error with literal predicate

gcc/rust/ChangeLog:

* ast/rust-ast.cc (MetaItemLitExpr::check_cfg_predicate): Make error.

gcc/testsuite/ChangeLog:

* rust/compile/issue-4222.rs: New test.

Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
2 weeks agogccrs: fix segfault with empty cfg attribute
Lucas Ly Ba [Thu, 6 Nov 2025 14:57:45 +0000 (14:57 +0000)] 
gccrs: fix segfault with empty cfg attribute

gcc/rust/ChangeLog:

* ast/rust-ast.cc (Attribute::check_cfg_predicate): add cfg path in condition

gcc/testsuite/ChangeLog:

* rust/compile/issue-4261.rs: New test.

Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
2 weeks agogccrs: fix error multiple cfg predicates
Lucas Ly Ba [Thu, 6 Nov 2025 16:53:00 +0000 (16:53 +0000)] 
gccrs: fix error multiple cfg predicates

gcc/rust/ChangeLog:

* ast/rust-ast.cc (Attribute::check_cfg_predicate):
Make error.

gcc/testsuite/ChangeLog:

* rust/compile/issue-4267.rs: New test.

Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
2 weeks agogccrs: Add support for binding const generic values to paths
Philip Herron [Mon, 3 Nov 2025 16:48:56 +0000 (16:48 +0000)] 
gccrs: Add support for binding const generic values to paths

Const generics bind values which can be accessed like a normal path but the difference
is that they can be true expression values not just type paths. This patch adds support
to resolving a method inference which passes a generic value into the method and fixes
some missed bugs along the way. The tricky part was that there is a case where in the
return position of a method returning a const param type vs the type of the method
there is a special case in the unify rules so that we unify the specified type of the
const param type not the const param itself.

gcc/rust/ChangeLog:

* backend/rust-compile-resolve-path.cc: handle const param values
* typecheck/rust-hir-type-check-item.cc: generate const infer vars when required
* typecheck/rust-type-util.cc (unify_site_and): handle a null param cleanup
* typecheck/rust-tyty-util.cc (TyVar::get_implicit_const_infer_var): helper interface
* typecheck/rust-tyty-util.h: update header prototypes
* typecheck/rust-tyty.cc (BaseType::is_concrete): correctly handle const types
(ConstParamType::get_name): emit the specified type
(ConstParamType::is_equal): fix recursion loop
* typecheck/rust-unify.cc (UnifyRules::go): const infer vars need cleanup too
* typecheck/rust-unify.h: support base generics

gcc/testsuite/ChangeLog:

* rust/execute/torture/const-generics-2.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2 weeks agogccrs: Implement E0579 error checking in RangePattern compilation
Yap Zhi Heng [Mon, 20 Oct 2025 06:01:40 +0000 (14:01 +0800)] 
gccrs: Implement E0579 error checking in RangePattern compilation

Checks whether upper bound of range is not lower or equal to the lower bound.

gcc/rust/ChangeLog:

* backend/rust-compile-pattern.cc(compilePatternCheckExpr::visit(RangePattern)):
Add E0579 check to ensure that lower bound is always below upper bound.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
2 weeks agogccrs: Fix `RangePattern` negative literal bounds being treated as positive
Yap Zhi Heng [Sun, 26 Oct 2025 03:13:25 +0000 (11:13 +0800)] 
gccrs: Fix `RangePattern` negative literal bounds being treated as positive

GIMPLE output for compile/issue-4242.rs:

...

  x = 1;
  RUSTTMP.2 = x;
  _1 = RUSTTMP.2 >= -55;
  _2 = RUSTTMP.2 < 0;
  _3 = _1 & _2;
  if (_3 != 0) goto <D.112>; else goto <D.113>;
  <D.112>:
  {
    RUSTTMP.1 = 2;
    goto <D.105>;
  }
  <D.113>:
  _4 = RUSTTMP.2 >= -99;
  _5 = RUSTTMP.2 < -55;
  _6 = _4 & _5;
  if (_6 != 0) goto <D.114>; else goto <D.115>;
  <D.114>:
  {
    RUSTTMP.1 = 3;
    goto <D.105>;
  }
...

gcc/rust/ChangeLog:

* backend/rust-compile-pattern.cc (compile_range_pattern_bound): Set litexpr
to negative if has_minus is present in the RangePatternBoundLiteral param.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
2 weeks agogccrs: Fix ICE with non-trailing const defaults
vishruth-thimmaiah [Wed, 29 Oct 2025 17:20:49 +0000 (22:50 +0530)] 
gccrs: Fix ICE with non-trailing const defaults

When a const generic with a default value is not trailing, emit an
error.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_generic_params): Emit
an error when const generics with a default value is not
trailing.

gcc/testsuite/ChangeLog:

* rust/compile/const_generics_17.rs: New test.
* rust/compile/generics14.rs: New test.

Signed-off-by: vishruth-thimmaiah <vishruththimmaiah@gmail.com>
2 weeks agogccrs: Add minus sign compilation for LiteralPattern
Yap Zhi Heng [Sun, 26 Oct 2025 02:49:28 +0000 (10:49 +0800)] 
gccrs: Add minus sign compilation for LiteralPattern

GIMPLE output for literalpattern_neg.rs test case:

...
  x = -55;
  RUSTTMP.2 = x;
  if (RUSTTMP.2 == 55) goto <D.113>; else goto <D.114>;
  <D.113>:
  {
    RUSTTMP.1 = 1;
    goto <D.107>;
  }
  <D.114>:
  if (RUSTTMP.2 == -55) goto <D.115>; else goto <D.116>;
  <D.115>:
  {
    RUSTTMP.1 = 0;
    goto <D.107>;
  }
  <D.116>:
  if (1 != 0) goto <D.117>; else goto <D.118>;
  <D.117>:
  {
    RUSTTMP.1 = 1;
    goto <D.107>;
  }
...

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (parse_literal_or_range_pattern): Parse minus sign
properly for LiteralPattern.
* ast/rust-pattern.h (LiteralPattern): Add has_minus boolean for LiteralPattern.
* hir/tree/rust-hir-pattern.h (LiteralPattern): Ditto.
* ast/rust-pattern.cc (LiteralPattern::as_string): Update to include minus sign
if present.
* hir/tree/rust-hir.cc (LiteralPattern::as_string): Ditto.
* hir/rust-ast-lower-pattern.cc (visit(LiteralPattern)): Pass has_minus boolean
from AST to HIR.
* backend/rust-compile-pattern.cc (CompilePatternCheckExpr::visit(LiteralPattern)):
Compile litexpr as negative if minus sign is present.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
2 weeks agogccrs: fix segfault on exported macro
Lucas Ly Ba [Wed, 15 Oct 2025 13:23:05 +0000 (13:23 +0000)] 
gccrs: fix segfault on exported macro

An imbricated exported macro leads to a segfault.

gcc/rust/ChangeLog:

* metadata/rust-export-metadata.cc (ExportContext::emit_macro):
Change method argument NodeId to AST::MacroRulesDefinition.
* metadata/rust-export-metadata.h:
Likewise.
* util/rust-hir-map.cc (Mappings::insert_exported_macro):
Insert AST::MacroRulesDefinition instead of NodeId.
* util/rust-hir-map.h:
Change methods declarations of exported macros.

gcc/testsuite/ChangeLog:

* rust/compile/issue-3617.rs: New test.

Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.fr>
2 weeks agoc++: Add testcase for CWG3079
Jakub Jelinek [Mon, 17 Nov 2025 14:27:04 +0000 (15:27 +0100)] 
c++: Add testcase for CWG3079

We already implement anonymous unions that way, the following patch
just adds a testcase for it.

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

* g++.dg/DRs/dr3079.C: New test.

2 weeks agoc++: Add testcase for CWG3061
Jakub Jelinek [Mon, 17 Nov 2025 14:26:22 +0000 (15:26 +0100)] 
c++: Add testcase for CWG3061

We already implement expansion statements that way, the following patch
just adds a testcase for it.

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

* g++.dg/DRs/dr3061.C: New test.

2 weeks agoc++: Add testcase for CWG3045
Jakub Jelinek [Mon, 17 Nov 2025 14:25:39 +0000 (15:25 +0100)] 
c++: Add testcase for CWG3045

We already implement expansion statements that way, the following patch
just adds a testcase for it.

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

* g++.dg/DRs/dr3045.C: New test.

2 weeks agoImprove LIM dump and some testcases
Richard Biener [Mon, 17 Nov 2025 10:29:46 +0000 (11:29 +0100)] 
Improve LIM dump and some testcases

The following avoids the newline between 'Moving statement' and the
actual stmt in dumps to make specific scanning easier.

* tree-ssa-loop-im.cc (move_computations_worker): Avoid newline
between 'Moving statement' and actual statement dump in dumpfile.

* gcc.dg/vect/slp-9.c: Use noipa function attribute, drop
-fno-early-inlining option.
* c-c++-common/restrict-2.c: Explicitly look for hoisted loads.
* gfortran.dg/pr104466.f90: Adjust.

2 weeks agoAvoid scanning all stmts outside of loops in LIM
Richard Biener [Mon, 17 Nov 2025 08:56:13 +0000 (09:56 +0100)] 
Avoid scanning all stmts outside of loops in LIM

The following avoids scanning stmts outside of loops for possibly
not returning calls.

* tree-ssa-loop-im.cc (fill_always_executed_in): Skip
blocks not in loops when looking for possibly not returning
calls.

2 weeks agocfgloop: Modify loop_exits_{to,from}_bb_p return type to edge
Victor Do Nascimento [Thu, 13 Nov 2025 13:54:05 +0000 (13:54 +0000)] 
cfgloop: Modify loop_exits_{to,from}_bb_p return type to edge

Given that when finding whether the predicate in question is satisfied
or not we already do the heavy-lifting of identifying the specific
edge that matches the particular criterion, it is wasteful to throw
the edge information away, only to potentially have to recalculate it
when true is returned.

Rather, given the ability of treating a valid pointer as true and,
conversely, the NULL pointer as false, we can return the edge for
should we wish to use it, while keeping the function's existing calls
in the code as is.

gcc/ChangeLog:

* cfgloop.cc (loop_exits_to_bb_p): Change return type.
(loop_exits_from_bb_p): Likewise.
* cfgloop.h: (loop_exits_to_bb_p): Likewise.
(loop_exits_from_bb_p): Likewise.

2 weeks agodocs: aarch64: arm: Update ACLE documentation.
Alfie Richards [Tue, 14 Oct 2025 15:04:25 +0000 (15:04 +0000)] 
docs: aarch64: arm: Update ACLE documentation.

Updates the Arm C Language Extension url and description to be up to date.

gcc/ChangeLog:

* doc/extend.texi: (ARM C Language Extensions (ACLE)) Update ACLE URL
and description.

2 weeks agoforwprop: restrict vector load decomposition in optimize_vector_load ()
Artemiy Volkov [Wed, 12 Nov 2025 20:18:44 +0000 (20:18 +0000)] 
forwprop: restrict vector load decomposition in optimize_vector_load ()

Since r15-778-g1d1ef1c22752b3, we are compiling the following snippet:

void foo (int16_t *dst, const uint8_t *src0, const uint8_t *src1)
{
  uint8x16_t s0 = vld1q_u8 (src0);
  uint8x16_t s1 = vld1q_u8 (src1);

  uint16x8_t d0_lo = vsubl_u8 (vget_low_u8 (s0), vget_low_u8 (s1));
  uint16x8_t d0_hi = vsubl_u8 (vget_high_u8 (s0), vget_high_u8 (s1));

  vst1q_s16 (dst, vreinterpretq_s16_u16 (d0_lo));
  vst1q_s16 (dst + 8, vreinterpretq_s16_u16 (d0_hi));
}

into:

        ldp     d0, d29, [x1]
        ldp     d30, d31, [x2]
        usubl   v30.8h, v0.8b, v30.8b
        usubl   v31.8h, v29.8b, v31.8b
        stp     q30, q31, [x0]
ret

rather than:

        ldr     q31, [x1]
        ldr     q30, [x2]
        usubl   v29.8h, v31.8b, v30.8b
        usubl2  v30.8h, v31.16b, v30.16b
        stp     q29, q30, [x0]
ret

That is, rather than keeping two 128-bit loads and using the usubl2
instruction designed to operate on upper halves of 128-bit vector
registers, we are doing four 64-bit scalar loads and operate on 64-bit
values, which leads to increased register pressure.

What happens here is the aforementioned commit lowers the vget_half_* ()
intrinsics to BIT_FIELD_REFs, at which point the logic in
tree-ssa-forwprop.cc::optimize_vector_load () kicks in, breaking down
vector loads into scalar loads as long as all uses are through
BIT_FIELD_REFs.  AFAICT, this function (or before it existed, the code
comprising it) handles the following scenarios:

(1) Introduced in r10-135-ga7eb97ad269b65 in response to PR88983, this
code broke down vector loads into smaller loads whenever the target
doesn't natively support wider loads, fixing code quality issues.  This
should always be a win since the original loads weren't even available in
the first place.

(2) Since r12-2728-g2724d1bba6b364, it is now also handling loads that
feed into VEC_UNPACK expressions to prefer extending scalar loads to
vector loads + vector unpack, which is beneficial at least on some
microarchitectures.

This patch restricts the optimization to those scenarios explicitly, while
adding another one on top:

(3) If any of the BIT_FIELD_REFs have scalar type, prefer scalar loads to
vector loads to reduce possible traffic between scalar and vector register
files.  IOW, only if all BIT_FIELD_REFs are used as subvectors, assume
there might be other instructions operating on those subvectors that do
not leave the vector register file, and do not perform the transformation.

To summarize, after this patch, if either (1), (2), or (3) holds, narrow
loads are preferred, otherwise vector loads are left intact.

Bootstrapped and regtested on aarch64 and x86_64, no regressions on
SPEC2017, the code snippet above added as an aarch64-specific test.

gcc/ChangeLog:

* tree-ssa-forwprop.cc (optimize_vector_load): Inhibit
optimization when all uses are through subvectors without
extension.

gcc/testsuite/ChangeLog:

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

2 weeks agoGCC, meet C++20
Jakub Jelinek [Mon, 17 Nov 2025 08:44:05 +0000 (09:44 +0100)] 
GCC, meet C++20

I've tried to test a patch to switch -std=gnu++17 C++ default
to -std=gnu++20 (will post momentarily), but ran into various problems
during GCC bootstraps, our codebase isn't fully C++20 ready.

The most common problems are arithmetic or bitwise operations
between enumerators of different enum types (or between enumerator
and floating point in the testsuite), ambiguous overloaded
operator == because of forgotten const qualification of const inside
of the argument and then libcody being largely stuck in C++ and incompatible
with C++20 which introduced char8_t type and uses it for u8 literals.

The following patch fixes various issues I've run into, for libcody
this patch just makes sure code including cody.hh can be compiled
with -std=gnu++20, libcody itself I have a tweak in the other patch.

Nothing in this patch will make the code invalid for C++14.

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

gcc/
* tree-core.h (enum built_in_function): Avoid arithmetics or
bitwise operations between enumerators from different enums.
* lto-streamer.h (lto_tag_is_gimple_code_p): Likewise.
* gimple.h (gimple_omp_atomic_set_memory_order): Likewise.
* common/config/i386/i386-cpuinfo.h (M_CPU_SUBTYPE_START,
M_CPU_TYPE): Likewise.
* tree-complex.cc (expand_complex_libcall): Likewise.
* ipa-modref-tree.h (modref_access_node::operator ==): Change
argument type from modref_access_node & to
const modref_access_node &.
* ipa-modref-tree.cc (modref_access_node::operator ==): Likewise.
gcc/cobol/
* symbols.cc (symbol_table_init): Avoid arithmetics or
bitwise operations between enumerators from different enums.
gcc/fortran/
* parse.cc (gfc_parse_file): Avoid arithmetics or
bitwise operations between enumerators from different enums.
libcody/
* cody.hh (MessageBuffer::Space): For C++14 or newer use
(char) u8' ' instead of Detail::S2C(u8" ").

2 weeks agoOpenMP/OpenACC tests. vs C++26
Jakub Jelinek [Mon, 17 Nov 2025 08:42:56 +0000 (09:42 +0100)] 
OpenMP/OpenACC tests. vs C++26

OpenMP/OpenACC array sections, generally expr[expr:expr] or
expr[expr:expr:expr] can have any of the exprs between [ and ]
omitted, low-bound (first defaults to 0, last (stride) defaults to
1 and the middle (length) for some arrays defaults to
ceil((size − lower_bound)/stride).
People have been writing this for years without spaces between [ and :
and : and ] when that expr has been omitted, but guess for C++26
one needs to add a space.  I think [ :: ] isn't going to be parsed
as the same as [ : : ] either.

gcc/testsuite/
* c-c++-common/goacc/cache-3-1.c: Add dg-skip-if for c++26.
* g++.dg/goacc/data-clause-2.C: Likewise.
* g++.dg/gomp/allocate-3.C: Likewise.
* c-c++-common/gomp/affinity-2.c: Use { c || c++23_down } effective
target.
* c-c++-common/goacc/cache-3-2.c: Replace [: in OpenMP or OpenACC
pragmas or attributes with [ : and :] with : ].
* c-c++-common/goacc/data-clause-1.c: Likewise.
* c-c++-common/goacc/data-clause-2.c: Likewise.
* c-c++-common/goacc/data-clause-duplicate-1.c: Likewise.
* c-c++-common/goacc/mdc-2.c: Likewise.
* c-c++-common/goacc/readonly-1.c: Likewise.
* c-c++-common/gomp/allocate-4.c: Likewise.
* c-c++-common/gomp/clauses-3.c: Likewise.
* c-c++-common/gomp/declare-mapper-3.c: Likewise.
* c-c++-common/gomp/depend-1.c: Likewise.
* c-c++-common/gomp/depend-2.c: Likewise.
* c-c++-common/gomp/depend-3.c: Likewise.
* c-c++-common/gomp/depend-4.c: Likewise.
* c-c++-common/gomp/depend-5.c: Likewise.
* c-c++-common/gomp/depend-6.c: Likewise.
* c-c++-common/gomp/dispatch-1.c: Likewise.
* c-c++-common/gomp/loop-5.c: Likewise.
* c-c++-common/gomp/map-1.c: Likewise.
* c-c++-common/gomp/map-2.c: Likewise.
* c-c++-common/gomp/map-4.c: Likewise.
* c-c++-common/gomp/map-7.c: Likewise.
* c-c++-common/gomp/pr100902-1.c: Likewise.
* c-c++-common/gomp/pr103642.c: Likewise.
* c-c++-common/gomp/pr120180-1.c: Likewise.
* c-c++-common/gomp/pr61486-1.c: Likewise.
* c-c++-common/gomp/pr81006.c: Likewise.
* c-c++-common/gomp/pr91920.c: Likewise.
* c-c++-common/gomp/pr96867.c: Likewise.
* c-c++-common/gomp/pr99928-16.c: Likewise.
* c-c++-common/gomp/reduction-1.c: Likewise.
* c-c++-common/gomp/scan-1.c: Likewise.
* c-c++-common/gomp/target-data-1.c: Likewise.
* c-c++-common/gomp/target-enter-data-1.c: Likewise.
* c-c++-common/gomp/target-has-device-addr-1.c: Likewise.
* c-c++-common/gomp/target-implicit-map-2.c: Likewise.
* c-c++-common/gomp/target-map-iterators-1.c: Likewise.
* c-c++-common/gomp/target-map-iterators-3.c: Likewise.
* c-c++-common/gomp/target-update-iterators-1.c: Likewise.
* c-c++-common/gomp/target-update-iterators-3.c: Likewise.
* g++.dg/goacc/cache-3-1.C: Likewise.
* g++.dg/goacc/cache-3-2.C: Likewise.
* g++.dg/goacc/data-clause-1.C: Likewise.
* g++.dg/goacc/mdc.C: Likewise.
* g++.dg/gomp/array-section-2.C: Likewise.
* g++.dg/gomp/bad-array-section-10.C: Likewise.
* g++.dg/gomp/bad-array-section-11.C: Likewise.
* g++.dg/gomp/bad-array-section-9.C: Likewise.
* g++.dg/gomp/declare-mapper-1.C: Likewise.
* g++.dg/gomp/declare-mapper-2.C: Likewise.
* g++.dg/gomp/depend-1.C: Likewise.
* g++.dg/gomp/depend-2.C: Likewise.
* g++.dg/gomp/ind-base-3.C: Likewise.
* g++.dg/gomp/map-1.C: Likewise.
* g++.dg/gomp/map-2.C: Likewise.
* g++.dg/gomp/map-ptrmem-1.C: Likewise.
* g++.dg/gomp/map-ptrmem-2.C: Likewise.
* g++.dg/gomp/member-array-2.C: Likewise.
* g++.dg/gomp/target-this-3.C: Likewise.
* g++.dg/gomp/target-this-4.C: Likewise.
libgomp/
* testsuite/libgomp.c++/allocate-1.C: Replace [: in OpenMP or OpenACC
pragmas or attributes with [ : and :] with : ].
* testsuite/libgomp.c++/baseptrs-3.C: Likewise.
* testsuite/libgomp.c++/baseptrs-5.C: Likewise.
* testsuite/libgomp.c++/class-array-1.C: Likewise.
* testsuite/libgomp.c++/examples-4/target_data-5.C: Likewise.
* testsuite/libgomp.c++/lvalue-tofrom-2.C: Likewise.
* testsuite/libgomp.c++/pr101544-1.C: Likewise.
* testsuite/libgomp.c++/pr108286.C: Likewise.
* testsuite/libgomp.c++/reduction-10.C: Likewise.
* testsuite/libgomp.c++/reduction-11.C: Likewise.
* testsuite/libgomp.c++/reduction-12.C: Likewise.
* testsuite/libgomp.c++/reduction-5.C: Likewise.
* testsuite/libgomp.c++/reduction-6.C: Likewise.
* testsuite/libgomp.c++/reduction-7.C: Likewise.
* testsuite/libgomp.c++/reduction-8.C: Likewise.
* testsuite/libgomp.c++/reduction-9.C: Likewise.
* testsuite/libgomp.c++/target-18.C: Likewise.
* testsuite/libgomp.c++/target-19.C: Likewise.
* testsuite/libgomp.c++/target-2.C: Likewise.
* testsuite/libgomp.c++/target-22.C: Likewise.
* testsuite/libgomp.c++/target-23.C: Likewise.
* testsuite/libgomp.c++/target-9.C: Likewise.
* testsuite/libgomp.c++/target-flex-100.C: Likewise.
* testsuite/libgomp.c++/target-flex-101.C: Likewise.
* testsuite/libgomp.c++/target-flex-12.C: Likewise.
* testsuite/libgomp.c++/target-flex-2003.C: Likewise.
* testsuite/libgomp.c++/target-flex-30.C: Likewise.
* testsuite/libgomp.c++/target-flex-300.C: Likewise.
* testsuite/libgomp.c++/target-flex-32.C: Likewise.
* testsuite/libgomp.c++/target-flex-33.C: Likewise.
* testsuite/libgomp.c++/target-flex-41.C: Likewise.
* testsuite/libgomp.c++/target-flex-60.C: Likewise.
* testsuite/libgomp.c++/target-flex-61.C: Likewise.
* testsuite/libgomp.c++/target-flex-62.C: Likewise.
* testsuite/libgomp.c++/target-flex-80.C: Likewise.
* testsuite/libgomp.c++/target-flex-81.C: Likewise.
* testsuite/libgomp.c++/target-has-device-addr-7.C: Likewise.
* testsuite/libgomp.c++/target-in-reduction-1.C: Likewise.
* testsuite/libgomp.c++/target-in-reduction-2.C: Likewise.
* testsuite/libgomp.c++/target-lambda-1.C: Likewise.
* testsuite/libgomp.c++/target-lambda-3.C: Likewise.
* testsuite/libgomp.c++/target-map-class-1.C: Likewise.
* testsuite/libgomp.c++/target-std__array-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__bitset-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__deque-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__flat_map-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__flat_multimap-concurrent.C:
Likewise.
* testsuite/libgomp.c++/target-std__flat_multiset-concurrent.C:
Likewise.
* testsuite/libgomp.c++/target-std__flat_set-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__forward_list-concurrent.C:
Likewise.
* testsuite/libgomp.c++/target-std__list-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__map-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__multimap-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__multiset-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__set-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__span-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__unordered_map-concurrent.C:
Likewise.
* testsuite/libgomp.c++/target-std__unordered_multimap-concurrent.C:
Likewise.
* testsuite/libgomp.c++/target-std__unordered_multiset-concurrent.C:
Likewise.
* testsuite/libgomp.c++/target-std__unordered_set-concurrent.C:
Likewise.
* testsuite/libgomp.c++/target-std__valarray-1.C: Likewise.
* testsuite/libgomp.c++/target-std__valarray-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__vector-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-this-3.C: Likewise.
* testsuite/libgomp.c++/target-this-4.C: Likewise.
* testsuite/libgomp.c++/target-virtual-1.C: Likewise.
* testsuite/libgomp.c++/task-reduction-11.C: Likewise.
* testsuite/libgomp.c++/task-reduction-12.C: Likewise.
* testsuite/libgomp.c++/task-reduction-13.C: Likewise.
* testsuite/libgomp.c++/task-reduction-17.C: Likewise.
* testsuite/libgomp.c++/task-reduction-18.C: Likewise.
* testsuite/libgomp.c++/task-reduction-19.C: Likewise.
* testsuite/libgomp.c++/task-reduction-4.C: Likewise.
* testsuite/libgomp.c++/task-reduction-5.C: Likewise.
* testsuite/libgomp.c++/task-reduction-6.C: Likewise.
* testsuite/libgomp.c++/task-reduction-7.C: Likewise.
* testsuite/libgomp.c++/taskloop-reduction-2.C: Likewise.
* testsuite/libgomp.c++/taskloop-reduction-3.C: Likewise.
* testsuite/libgomp.c++/taskloop-reduction-4.C: Likewise.
* testsuite/libgomp.c-c++-common/allocate-1.c: Likewise.
* testsuite/libgomp.c-c++-common/allocate-3.c: Likewise.
* testsuite/libgomp.c-c++-common/baseptrs-2.c: Likewise.
* testsuite/libgomp.c-c++-common/dispatch-1.c: Likewise.
* testsuite/libgomp.c-c++-common/dispatch-2.c: Likewise.
* testsuite/libgomp.c-c++-common/interop-2.c: Likewise.
* testsuite/libgomp.c-c++-common/matrix-omp-target-teams-distribute-parallel-for-1.c:
Likewise.
* testsuite/libgomp.c-c++-common/ptr-attach-1.c: Likewise.
* testsuite/libgomp.c-c++-common/ptr-attach-2.c: Likewise.
* testsuite/libgomp.c-c++-common/refcount-1.c: Likewise.
* testsuite/libgomp.c-c++-common/struct-elem-4.c: Likewise.
* testsuite/libgomp.c-c++-common/target-2.c: Likewise.
* testsuite/libgomp.c-c++-common/target-has-device-addr-1.c: Likewise.
* testsuite/libgomp.c-c++-common/target-implicit-map-2.c: Likewise.
* testsuite/libgomp.c-c++-common/target-implicit-map-5.c: Likewise.
* testsuite/libgomp.c-c++-common/target-in-reduction-1.c: Likewise.
* testsuite/libgomp.c-c++-common/target-in-reduction-2.c: Likewise.
* testsuite/libgomp.c-c++-common/target-map-iterators-1.c: Likewise.
* testsuite/libgomp.c-c++-common/target-map-iterators-2.c: Likewise.
* testsuite/libgomp.c-c++-common/target-map-iterators-3.c: Likewise.
* testsuite/libgomp.c-c++-common/target-map-zlas-1.c: Likewise.
* testsuite/libgomp.c-c++-common/target-update-iterators-1.c: Likewise.
* testsuite/libgomp.c-c++-common/target-update-iterators-2.c: Likewise.
* testsuite/libgomp.c-c++-common/target-update-iterators-3.c: Likewise.
* testsuite/libgomp.c-c++-common/task-reduction-11.c: Likewise.
* testsuite/libgomp.c-c++-common/task-reduction-12.c: Likewise.
* testsuite/libgomp.c-c++-common/task-reduction-16.c: Likewise.
* testsuite/libgomp.c-c++-common/task-reduction-3.c: Likewise.
* testsuite/libgomp.c-c++-common/task-reduction-7.c: Likewise.
* testsuite/libgomp.c-c++-common/task-reduction-9.c: Likewise.
* testsuite/libgomp.c-c++-common/taskloop-reduction-2.c: Likewise.
* testsuite/libgomp.c-c++-common/teams-nteams-icv-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-16.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-3.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-4.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-5.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-6.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-7.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-8.c: Likewise.

2 weeks ago[x86] avoid using masked vector epilogues when no scalar epilog is needed
Richard Biener [Thu, 6 Nov 2025 12:19:35 +0000 (13:19 +0100)] 
[x86] avoid using masked vector epilogues when no scalar epilog is needed

The following arranges for avoiding masked vector epilogues when we'll
eventually arrive at a vector epilogue with VF == 1 which implies no
scalar epilog will be necessary.

This avoids regressing performance in OpenColorIO when the
avx512_masked_epilogues tuning is enabled.  A testcase for one
example case is shown in PR122573.

PR tree-optimization/122573
* config/i386/i386.cc (ix86_vector_costs::finish_cost): Avoid
using masked epilogues when an SSE epilogue would have a VF of one.

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

2 weeks agobuild: Check for ld -z compress-sections=zstd on Solaris
Rainer Orth [Mon, 17 Nov 2025 08:08:03 +0000 (09:08 +0100)] 
build: Check for ld -z compress-sections=zstd on Solaris

The Solaris 11.4 ld recently gained support for zstd compression.  This
patch adds a configure check for it.

I also noticed that we don't currently document -gz=zstd, so this patch
adds that, too.

Tested on i386-pc-solaris2.11 (with pre-zstd and post-zstd ld) and
x86_64-pc-linux-gnu.

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

gcc:
* configure.ac (gcc_cv_ld_compress_debug) <*-*-solaris2*>: Check
for zstd compression support.
* configure: Regenerate.

* doc/invoke.texi (Debugging Options, gz): Document zstd.

2 weeks agoRISC-V: Add test for vec_duplicate + vmsne.vv combine case 1 with GR2VR cost 0, 1...
Pan Li [Sun, 16 Nov 2025 11:25:48 +0000 (19:25 +0800)] 
RISC-V: Add test for vec_duplicate + vmsne.vv combine case 1 with GR2VR cost 0, 1 and 15

Add asm dump check and run test for vec_duplicate + vmsne.vv
combine to vmseq.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 vmsne.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 the helper
macros.
* 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_vmsne-run-1-u16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmsne-run-1-u32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmsne-run-1-u64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmsne-run-1-u8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 weeks agoRISC-V: Add test for vec_duplicate + vmsne.vv combine case 0 with GR2VR cost 0, 1...
Pan Li [Sun, 16 Nov 2025 11:12:35 +0000 (19:12 +0800)] 
RISC-V: Add test for vec_duplicate + vmsne.vv combine case 0 with GR2VR cost 0, 1 and 15

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

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i16.c: Add asm check
for vmsne.vx.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary.h: Add test
helper macros.
* 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_vmsne-run-1-i16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmsne-run-1-i32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmsne-run-1-i64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmsne-run-1-i8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 weeks agoDaily bump.
GCC Administrator [Mon, 17 Nov 2025 00:19:25 +0000 (00:19 +0000)] 
Daily bump.

2 weeks agoAllow single PHI initial values.
Andrew MacLeod [Fri, 14 Nov 2025 21:11:30 +0000 (16:11 -0500)] 
Allow single PHI initial values.

There are some single PHI groups that can benefit from an initial
value.  Also improve the iteration calculation by bounding each
iteration with the known global value.

PR tree-optimization/121345
gcc/
* gimple-range-phi.cc (phi_group::phi_group): Add modifier name.
(phi_group::is_modifier_p): Set modifier stmt operand name.
(phi_group::calculate_using_modifier): Bound the iteration range
by known global range.
(phi_analyzer::process_phi): Allow single PHIS if they meet certain
criteria.
* gimple-range-phi.h (m_modifier_name): New member.
(is_modifier_p): Adjust prototype.

gcc/testsuite/
* g++.dg/pr121345.C: New.

2 weeks agoTurn PHI analyzer to a simple pre-pass
Andrew MacLeod [Fri, 14 Nov 2025 21:06:42 +0000 (16:06 -0500)] 
Turn PHI analyzer to a simple pre-pass

Rather than having a dynamic analyzer around that is handcuffed by
only global values, invoke it as a prepass in VRP and put all values it finds
in the query's global cache via update_range_info.

gcc/
* gimple-range-fold.cc (fold_using_range::range_of_phi): Remove
the PHI analysis query.
* gimple-range-phi.cc (phi_analysis_object): Delete.
(phi_analysis_initialize): Delete.
(phi_analysis_finalize): Delete.
(phi_analysis_available_p): Delete.
(phi_analysis): Invoke a phi analyzer.
(phi_analyzer::phi_analyzer): Preprocess all phi nodes and set
global values for them in a query.
(phi_analyzer::process_phi): Use query, and export any inital
values found to the query.
* gimple-range-phi.h (m_global): Delete.
(phi_analysis_initialize): Delete.
(phi_analysis_finalize): Delete.
(phi_analysis_available_p): Delete.
(phi_analysis): Change prototype.
* tree-vrp.cc (execute_ranger_vrp): Call phi_analysis.

gcc/testsuite/
* gcc.dg/pr102983.c: Adjust final check.

2 weeks agoForce recalculation when relations are registered.
Andrew MacLeod [Fri, 14 Nov 2025 20:44:27 +0000 (15:44 -0500)] 
Force recalculation when relations are registered.

Whena relation is registered between 2 ssa-names, update their timestamps.
Any calculations using those names will be stale and forced to recalculate.

* gimple-range-cache.cc (ranger_cache::update_consumers): New.
* gimple-range-cache.h (update_consumers): New prototype.
* gimple-range-fold.cc (fur_depend::fur_depend): Add cache ptr.
(fur_depend::register_relation): call update_consumers.
* gimple-range-fold.h (fur_depend): Add a cache pointer.
* gimple-range.cc (gimple_ranger::fold_range_internal): Add cache ptr.

2 weeks agoUpdate current query global when system global changes.
Andrew MacLeod [Fri, 14 Nov 2025 20:39:18 +0000 (15:39 -0500)] 
Update current query global when system global changes.

This ensures a the current range_query's internal tracking of a global value
matches anything another entity sets.

* gimple-range.cc (gimple_ranger::update_range_info): New.
* gimple-range.h (update_range_info): New prototype.
* tree-ssanames.cc (set_range_info): Update the range info for
the current range query.
* value-query.h (update_range_info): New prototype.
* value-query.cc (update_range_info): New default stub.

2 weeks agocfglceanup: Fix check for preheaders
Andrew Pinski [Sat, 15 Nov 2025 22:51:32 +0000 (14:51 -0800)] 
cfglceanup: Fix check for preheaders

I had messed up the check in r16-5258-g1d8e2d51e5c5cb for preheaders
where return to remvoe the forwarder preheader block even if LOOPS_HAVE_PREHEADERS
was set. I am not sure how often this happens because most of the time the pre-header
will have an incoming phi block anyways but it is safer not to remove it in this case.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-cfgcleanup.cc (tree_forwarder_block_p): Restore check on
LOOPS_HAVE_PREHEADERS.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks agolibstdc++: Include <mutex> in syncbuf.cc [PR122698]
Jonathan Wakely [Sun, 16 Nov 2025 13:57:25 +0000 (13:57 +0000)] 
libstdc++: Include <mutex> in syncbuf.cc [PR122698]

For most configurations bits/std_mutex.h would already be included by
<syncstream>, but not if configured with _GLIBCXX_USE_CXX11_ABI=0 as the
default, because syncbuf is disabled in that case.

libstdc++-v3/ChangeLog:

PR libstdc++/122698
* src/c++20/syncbuf.cc (__syncbuf_get_mutex): Include <mutex>.
Fix indentation of function body.

2 weeks agoRemove /usr/ccs references on Solaris
Rainer Orth [Sun, 16 Nov 2025 13:00:11 +0000 (14:00 +0100)] 
Remove /usr/ccs references on Solaris

/usr/ccs/bin has been replaced by a symlink to /usr/bin since at least
Solaris 11.3, so there's no reason to use that path any longer.

This patch removes all references to it.

Tested on i386-pc-solaris2.11.

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

* configure.ac (md_exec_prefix): Don't set on Solaris.
* configure: Regenerate.

contrib:
* make_sunver.pl ($elfdump): Remove ccs from path.

gcc:
* config/sol2.h (MD_EXEC_PREFIX): Remove.

libstdc++-v3:
* scripts/extract_symvers.pl: Remove ccs from elfdump path.

2 weeks agoc++/modules: Keep tracking instantiations of static class variable templates [PR122625]
Nathaniel Shead [Sat, 15 Nov 2025 04:11:55 +0000 (15:11 +1100)] 
c++/modules: Keep tracking instantiations of static class variable templates [PR122625]

r16-4930-gfd5c057c2d01 ensured that we noted all class-scope variables.
But I also added a clause to 'read_var_def' to skip all class-scope
instantiations, under the mistaken belief that this would be handled in
read_class_def.

But as the testcase shows, read_class_def cannot (and should not)
register instantiations of member variable templates, as when reading
the class it just sees the template declaration.  So this patch
re-enables tracking instantiations of class-scope variable templates.

PR c++/122625

gcc/cp/ChangeLog:

* module.cc (trees_in::read_var_def): Also track class-scope
primary template specialisations.

gcc/testsuite/ChangeLog:

* g++.dg/modules/inst-7_a.C: New test.
* g++.dg/modules/inst-7_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2 weeks agoAlways analyze possible partial vector usage
Richard Biener [Fri, 14 Nov 2025 12:40:50 +0000 (13:40 +0100)] 
Always analyze possible partial vector usage

The following makes us always start with LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P
as true and only makes vect_determine_partial_vectors_and_peeling
honor --param vect-partial-vector-usage or explicit requests from the
target for epilog vectorization.  This exposes whether we could have
used partial vectors to the target at costing time as even when the
main loop is never supposed to get masked the value is useful to
determine possible epilog loop masking.

* tree-vect-loop.cc (_loop_vec_info::_loop_vec_info):
Initialize can_use_partial_vectors_p to true.
(vect_determine_partial_vectors_and_peeling): Add masked_p
parameter and honor it.
(vect_analyze_loop_2): Pass through masked_p.
(vect_analyze_loop_1): Pass down masked_p.
(vect_analyze_loop): Simplify check on possible masking of
the epilog when there's no .WHILE_ULT.

2 weeks agoDecide on LOOP_VINFO_USING_SELECT_VL_P after determining partial vectors
Richard Biener [Fri, 14 Nov 2025 13:07:01 +0000 (14:07 +0100)] 
Decide on LOOP_VINFO_USING_SELECT_VL_P after determining partial vectors

The following makes us decide on partial vectors first so we can
use LOOP_VINFO_USING_PARTIAL_VECTORS_P to decide on a decrementing IV
and LOOP_VINFO_USING_SELECT_VL_P as followup.

* tree-vect-loop.cc (vect_determine_partial_vectors_and_peeling):
Remove resetting of LOOP_VINFO_USING_SELECT_VL_P.
(vect_analyze_loop_2): Decide on partial vectors before
deciding on decrementing IV or .SELECT_VL usage.

2 weeks agoDo not call vect_determine_partial_vectors_and_peeling from transform
Richard Biener [Fri, 14 Nov 2025 13:10:24 +0000 (14:10 +0100)] 
Do not call vect_determine_partial_vectors_and_peeling from transform

It gets more difficult to maintain this doesn't do any changes late
(see followups), so kill it.  We do have to retain re-setting of
LOOP_VINFO_PEELING_FOR_NITER though, since
vect_need_peeling_or_partial_vectors_p is incorrect for epilogues
when done during analysis.  We should fix this of course.

* tree-vectorizer.h (vect_determine_partial_vectors_and_peeling):
Remove.
(vect_need_peeling_or_partial_vectors_p): Declare.
* tree-vect-loop.cc (vect_determine_partial_vectors_and_peeling):
Make static.
(vect_need_peeling_or_partial_vectors_p): Export.
* tree-vect-loop-manip.cc (vect_do_peeling): Do not call
vect_determine_partial_vectors_and_peeling but instead
re-compute LOOP_VINFO_PEELING_FOR_NITER using
vect_need_peeling_or_partial_vectors_p.

2 weeks agoRemove LOOP_VINFO_EPIL_USING_PARTIAL_VECTORS_P
Richard Biener [Fri, 14 Nov 2025 12:54:20 +0000 (13:54 +0100)] 
Remove LOOP_VINFO_EPIL_USING_PARTIAL_VECTORS_P

This is a write-only parameter, it cannot be relied upon either.
So remove it.

* tree-vectorizer.h (_loop_vec_info::epil_using_partial_vectors_p):
Remove.
(LOOP_VINFO_EPIL_USING_PARTIAL_VECTORS_P): Likewise.
* tree-vect-loop.cc (_loop_vec_info::_loop_vec_info):
Do not initialize epil_using_partial_vectors_p.
(vect_determine_partial_vectors_and_peeling): Do not set it.

2 weeks agodiagnostics: Fix -fdump-internal-locations for 64-bit location_t
Lewis Hyatt [Sun, 16 Nov 2025 04:10:52 +0000 (23:10 -0500)] 
diagnostics: Fix -fdump-internal-locations for 64-bit location_t

When adding support for 64-bit location_t in GCC 15, I missed a couple
changes needed for the internal debugging tool -fdump-internal-locations to
work properly. This would previously ICE on a location_t large enough to
overflow a signed 32-bit int.

gcc/ChangeLog:

* diagnostics/context.cc (num_digits): Change argument type from
`int' to `uint64_t'.
(test_num_digits): Add test for 64-bit argument.
* diagnostic.h (num_digits): Adjust prototype.
* input.cc (write_digit): Accept argument in range 0-9 instead of
an arbitrary int.
(write_digit_row): Adjust to change in write_digit().

gcc/testsuite/ChangeLog:

* gcc.dg/plugin/location-overflow-test-3.c: New test.
* gcc.dg/plugin/plugin.exp: Add the new test.

2 weeks agoaarch64: unxfail pr117123.C
Andrew Pinski [Sun, 16 Nov 2025 04:13:45 +0000 (20:13 -0800)] 
aarch64: unxfail pr117123.C

This testcase now passes for aarch64 after r16-5258-1d8e2d51e5c5.
The keeping around the loop pre-header helped to better thread the jumps
and fix the issue at hand.

Pushed as obvious.

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/pr117123.C: un-xfail.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks agoaarch64: change another CRC test
Sam James [Sun, 30 Mar 2025 15:38:09 +0000 (16:38 +0100)] 
aarch64: change another CRC test

Fixed the iteration number in crc-crc32-data16.c test from 8 to 16 to
match the test name, just like in r15-9038-gdf55a933cfc675.

gcc/testsuite/ChangeLog:
* gcc.target/aarch64/crc-crc32-data16.c: Fix iteration
count to match testname.

2 weeks agoDaily bump.
GCC Administrator [Sun, 16 Nov 2025 00:19:20 +0000 (00:19 +0000)] 
Daily bump.

2 weeks agolibstdc++: Tweak static_assert messages for volatile atomic waits
Jonathan Wakely [Sat, 15 Nov 2025 10:55:55 +0000 (10:55 +0000)] 
libstdc++: Tweak static_assert messages for volatile atomic waits

libstdc++-v3/ChangeLog:

* include/bits/atomic_base.h: Tweak grammar of static assert
messages for unsupported atomic wait on volatile.

2 weeks agolibstdc++: Minor refactoring in __wait_until_impl in atomic.cc
Jonathan Wakely [Fri, 14 Nov 2025 15:51:52 +0000 (15:51 +0000)] 
libstdc++: Minor refactoring in __wait_until_impl in atomic.cc

libstdc++-v3/ChangeLog:

* src/c++20/atomic.cc (__wait_impl): Fix outdated comment.
(__wait_until_impl): Simplify return statements.

2 weeks agogcc: Make aarch64-mingw32 target install wrap stdint.h
Jason Xu [Sun, 3 Aug 2025 22:19:04 +0000 (18:19 -0400)] 
gcc: Make aarch64-mingw32 target install wrap stdint.h

Wrapped stdint.h for AArch64 MinGW32 is useful for bare-matal PE
target e.g. UEFI, as those platform does not provide a system
stdint.h, this would align with x86_64 mingw32 target which provides a
wrapped stdint.h

I have tested this by compiling a AArch64 UEFI Application using gcc's
stdint.h, with -ffreestanding flag, and execute the application with
AAVMF(edk2) inside QEMU.

gcc/ChangeLog:
* config.gcc (aarch64-*-mingw*): Set use_gcc_stdint to wrap.

2 weeks agoc++/modules: explicit inst of constructor
Jason Merrill [Sat, 15 Nov 2025 17:43:37 +0000 (23:13 +0530)] 
c++/modules: explicit inst of constructor

The extern template __shared_ptr<filesystem::_Dir> in bits/fs_dir.h was
leading to an ICE in import_export_decl in 29_atomics/atomic_ref/address.cc
because we had the nonsensical combination of DECL_REALLY_EXTERN and
!DECL_INTERFACE_KNOWN.  This turned out to be because mark_decl_instantiated
was exiting early if TREE_ASM_WRITTEN since way back in the pre-cgraph days,
and expand_or_defer_fn_1 sets TREE_ASM_WRITTEN on maybe-in-charge ctors.
The mark_decl_instantiated code is long-obsolete, so let's just remove it.

gcc/cp/ChangeLog:

* module.cc (trees_out::write_function_def): Check flag consistency.
* pt.cc (mark_decl_instantiated): Ignore TREE_ASM_WRITTEN.

2 weeks ago[RISC-V] Avoid most calls to gen_extend_insn
Jeff Law [Sat, 15 Nov 2025 16:26:25 +0000 (09:26 -0700)] 
[RISC-V] Avoid most calls to gen_extend_insn

Yet more infrastructure on our way to eliminating some define_insn_and_split
constructs.

The RISC-V port is using gen_extend_insn to directly generate a SIGN or ZERO
extend insn.  This is undesirable because we don't actually have a full set of
extension instructions, particularly zero extension for the base architecture.

We've gotten away with this because we've had a define_insn_and_splits which
claim to support the full set of zero/sign extensions.  We very much want to
eliminate that little white lie.  So we need to fix those pesky calls to
gen_extend_insn.

Similar to a patch from earlier this week convert_modes comes to the rescue.
It'll run through the expander path allowing us to generate the desired code.
In most cases it's a trivial replacement.

One case is left in the tree.  For that case the source operand is known to be
a MEM and we can always extend a load from a MEM.  Converting this one would
result in infinite recursion through riscv_legitimize_move.

One case is perhaps nontrivial.  convert_move will emit the code to perform the
conversion into a fresh pseudo register.  In one case we need to make sure that
value is copied into the output register for an insn.  So a trivial
emit_move_insn is needed.

Built and regression tested on riscv32-elf and riscv64-elf.  It's also
bootstrapped on the Pioneer.  Regression testing is in progress, but won't
finish for many hours.  The BPI is spinning this change right now, but won't
have results until tomorrow night.

gcc/
* config/riscv/riscv.cc (risc_legitimize_move): Use convert_modes
rather than gen_extend_insn for most cases.
* config/riscv/riscv.md (addv<mode>4): Likewise.
(uaddv<mode>4, subv<mode>4, usubv<mode>4): Likewise.
(mulv<mode>4, umulv<mode>4): Likewise.
* config/riscv/sync.md (atomic_compare_and_swap<mode>): Likewise.

2 weeks agotestsuite: Fix up c-c++-common/asan/asan-stack-small.c test
Jakub Jelinek [Sat, 15 Nov 2025 15:06:05 +0000 (16:06 +0100)] 
testsuite: Fix up c-c++-common/asan/asan-stack-small.c test

Here is a fix for the test I've talked about today in the libsanitizer
update mail.

The test relied on a coming before b coming before c, all with 32 byte
distances, but gcc can actually emit them in the exact opposite order
or some other one.

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

* c-c++-common/asan/asan-stack-small.c (pa, pb, pc): Make these
vars volatile.
(uintptr_t): New typedef.
(main): Use access of b using pa pointer with offset depending on
how exactly the 3 variables are laid out in the frame.

2 weeks agocobol: Fix bootstrap [PR122691]
Jakub Jelinek [Sat, 15 Nov 2025 15:04:56 +0000 (16:04 +0100)] 
cobol: Fix bootstrap [PR122691]

Andrew's recent r16-5258 change broke bootstrap on x86_64-linux with
cobol enabled, the error is
../../gcc/cobol/lexio.cc: In function ‘std::pair<std::__cxx11::list<replace_t>,
char*> parse_replace_pairs(const char*, const char*, bool)’:
../../gcc/cobol/lexio.cc:907:76: error: ‘%.*s’ directive argument is null
[-Werror=format-overflow=]
  907 |     dbgmsg( "%s:%d: %s: " HOST_SIZE_T_PRINT_UNSIGNED " pairs parsed from  '%.*s'",
      |                                                                            ^~~~
The problem is that some jump threading is happening now that didn't happen
before and a dbgmsg call is duplicated, once with 0, NULL as the last two
arguments, once with some size and pointer.

The following patch makes sure we never call it with NULL pointer, even when
the size is 0, to silence the warning.

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

PR cobol/122691
* lexio.cc (parse_replace_pairs): Replace parsed.stmt.p with
parsed.stmt.size() ? parsed.stmt.p : "" in the last argument to
dbgmsg.

2 weeks agoc++/modules: if translation fails fall back to #include
Jason Merrill [Wed, 5 Nov 2025 12:29:17 +0000 (17:59 +0530)] 
c++/modules: if translation fails fall back to #include

If a user wrote #include and the .gcm we found won't work, instead of
failing the compile let's do the #include that the source code called for.

This case also prints a note about the failure, like those from
-flang-info-include-translate{,-not} but unconditional.

gcc/cp/ChangeLog:

* module.cc (module_state::read_config): Add complain parm.
(module_state::open_slurp): Split out...
(module_state::do_import): ...from here.
(module_state::read_initial): Move begin call to open_slurp.
(module_state::check_importable): New.
(maybe_translate_include): Call it.

2 weeks agoc++/modules: fix hash_map issue
Jason Merrill [Fri, 14 Nov 2025 12:22:57 +0000 (17:52 +0530)] 
c++/modules: fix hash_map issue

Building std.compat.cc was crashing for me because we would first get a
pointer into imported_temploid_friends, then insert a new entry, causing the
hash_map to expand, and then dereference the pointer into the former
location of the hash table.  Fixed by dereferencing the pointer before
inserting rather than after.

gcc/cp/ChangeLog:

* module.cc (transfer_defining_module): Dereference
pointer into hash_map before possible insertion.

2 weeks agoc++/modules: using builtin
Jason Merrill [Fri, 14 Nov 2025 17:59:38 +0000 (23:29 +0530)] 
c++/modules: using builtin

Here, when we try to bring "memset" back into the global namespace, we find
the built-in, see that it's the same declaration (because the module brought
it into the other namespace with a using-declaration), and decide that we
don't need to do anything.  But we still need a non-hidden overload.

gcc/cp/ChangeLog:

* name-lookup.cc (do_nonmember_using_decl): Handle hidden better.

gcc/testsuite/ChangeLog:

* g++.dg/modules/using-33_a.C: New test.
* g++.dg/modules/using-33_b.C: New test.

2 weeks agoc++/modules: friend void foo<bar>()
Jason Merrill [Wed, 12 Nov 2025 09:33:46 +0000 (15:03 +0530)] 
c++/modules: friend void foo<bar>()

23_containers/mdspan/layouts/padded.cc was failing because on load we were
wrongly treating the __get_static_stride friends as equivalent between
layout_left_padded and layout_right_padded.  This happened because we were
wrongly pushing these declarations into namespace scope even though we don't
yet know what template they instantiate.  Fixed by using the same
MK_local_friend mechanism as template friends.

gcc/cp/ChangeLog:

* decl.cc (grokfndecl): Set DECL_CHAIN of a friend f<>.
* module.cc (trees_out::get_merge_kind): Give it MK_local_friend.
(trees_out::decl_container): Its container is the befriender.
(trees_out::key_mergeable): Expand comment.
* cp-tree.h (decl_specialization_friend_p): New.
* friend.cc (do_friend): Use it.
* pt.cc (tsubst_friend_function): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/modules/friend-11_a.C: New test.
* g++.dg/modules/friend-11_b.C: New test.

2 weeks agoaarch64: Remove unused pattern
Karl Meakin [Fri, 17 Oct 2025 14:18:30 +0000 (14:18 +0000)] 
aarch64: Remove unused pattern

The `mov<GPF:mode><GPI:mode>cc` expander was not used anywhere. Delete
it.

gcc/ChangeLog:

* config/aarch64/aarch64.md (mov<GPF:mode><GPI:mode>cc): Delete.

2 weeks agoaarch64: Add `aarch64_comparison_operator_cc`
Karl Meakin [Fri, 17 Oct 2025 13:32:59 +0000 (13:32 +0000)] 
aarch64: Add `aarch64_comparison_operator_cc`

Deduplicate the checks against `ccmode` by extracting to a new
predicate.

gcc/ChangeLog:

* config/aarch64/aarch64.md(mov<ALLI_GPF:mode>cc): Use new predicate.
(mov<GPF:mode><GPI:mode>cc): Likewise.
(<neg_not_op><mode>cc): Likewise.
* config/aarch64/predicates.md (aarch64_comparison_operator_cc):
New predicate.

2 weeks agoaarch64: Remove redundant checks
Karl Meakin [Thu, 16 Oct 2025 15:56:42 +0000 (15:56 +0000)] 
aarch64: Remove redundant checks

The checks for `code == UNEQ || code == LTGT` are unecessary, because
they are already excluded by `aarch64_comparison_operator`

gcc/ChangeLog:

* config/aarch64/aarch64.md (mov<ALLI_GPF:mode>): Delete
redundant check.
(mov<GPF:mode><GPI:mode>cc): Likewise.
(<neg_not_op><mode>cc): Likewise.

2 weeks agoaarch64: Merge mov<ALLI>cc with mov<GPF>cc
Karl Meakin [Tue, 30 Sep 2025 15:50:35 +0000 (15:50 +0000)] 
aarch64: Merge mov<ALLI>cc with mov<GPF>cc

The bodies of `mov<ALLI>cc` and `mov<GPF>cc` are identical, so merge
them by using a new mode iterator that combines `ALLI` and `GPF`.

gcc/ChangeLog:

* config/aarch64/aarch64.md (mov<ALLI>cc): Merge with ...
(mov<ALLI>cc): ... this.
* config/aarch64/iterators.md(ALLI_GPF): New mode iterator.

2 weeks agoaarch64: Fix condition accepted by mov<GPF>cc
Karl Meakin [Tue, 30 Sep 2025 12:05:00 +0000 (12:05 +0000)] 
aarch64: Fix condition accepted by mov<GPF>cc

Apply the same fix from bc11cbff9e648fdda2798bfa2d7151d5cd164b87
("aarch64: Fix condition accepted by mov<ALLI>cc") to `MOV<GPF>cc`.
Fixes ICEs when compiling code such as `cmpbr-4.c` and `cmpbr-5.c` with `+cmpbr`.

gcc/ChangeLog:

* config/aarch64/aarch64.md(mov<GPF>cc): Accept MODE_CC
conditions directly; reject QI/HImode conditions.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/cmpbr-4.c: New test.
* gcc.target/aarch64/cmpbr-5.c: New test.

2 weeks agoDaily bump.
GCC Administrator [Sat, 15 Nov 2025 00:21:45 +0000 (00:21 +0000)] 
Daily bump.

2 weeks ago[RISC-V] Drop scan-tests of marginal value
Jeff Law [Fri, 14 Nov 2025 21:46:32 +0000 (14:46 -0700)] 
[RISC-V] Drop scan-tests of marginal value

gcc/testsuite
* gcc.target/riscv/rvv/vsetvl/avl_single-37.c: Drop unnecessary output
test(s).
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-1.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-2.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-3.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-4.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-5.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-6.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-7.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-8.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-9.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-10.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-11.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-12.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-13.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-14.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-15.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-16.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-17.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-18.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-19.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-20.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-21.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-22.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-23.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-24.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-25.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-26.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-27.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-28.c: Likewise.

2 weeks agoRISC-V: Add missing member for andes_25_tune_info
Kuan-Lin Chen [Fri, 14 Nov 2025 21:35:18 +0000 (14:35 -0700)] 
RISC-V: Add missing member for andes_25_tune_info

gcc/ChangeLog:

* config/riscv/riscv.cc (andes_25_tune_info): Add prefer-agnostic.

2 weeks agoarm: [MVE intrinsics] rework sqrshr sqshl srshr uqrshl uqshl urshr
Christophe Lyon [Sun, 24 Aug 2025 21:04:35 +0000 (21:04 +0000)] 
arm: [MVE intrinsics] rework sqrshr sqshl srshr uqrshl uqshl urshr

Implement sqrshr, sqshl, srshr, uqrshl, uqshl and urshr using the new
MVE builtins framework.

The patch fixes a probable copy/paste typo in mve_sqshl_si and
mve_srshr_si: operand 1 should have mode SI, and not DI.

gcc/ChangeLog:

* config/arm/arm-mve-builtins-base.cc (enum which_scalar_shift):
Add ss_SQRSHR, ss_SQSHL, ss_SRSHR, ss_UQRSHL, ss_UQSHL, and
ss_URSHR.
(mve_function_scalar_shift): Add support for ss_SQRSHR, ss_SQSHL,
ss_SRSHR, ss_UQRSHL, ss_UQSHL, and ss_URSHR.
(sqrshr, sqshl, srshr, uqrshl, uqshl, urshr): New.
* config/arm/arm-mve-builtins-base.def (sqrshr, sqshl, srshr)
(uqrshl, uqshl, urshr): New.
* config/arm/arm-mve-builtins-base.h (sqrshr, sqshl, srshr)
(uqrshl, uqshl, urshr): New.
* config/arm/arm-mve-builtins-shapes.cc (scalar_s32_shift): New.
(scalar_s32_shift_imm): New.
(scalar_u32_shift): New.
(scalar_u32_shift_imm): New.
* config/arm/arm-mve-builtins-shapes.h (scalar_s32_shift): New.
(scalar_s32_shift_imm): New.
(scalar_u32_shift): New.
(scalar_u32_shift_imm): New.
* config/arm/arm_mve.h (sqrshr): Delete.
(sqshl): Delete.
(srshr): Delete.
(uqrshl): Delete.
(uqshl): Delete.
(urshr): Delete.
(__arm_uqrshl): Delete.
(__arm_sqrshr): Delete.
(__arm_uqshl): Delete.
(__arm_urshr): Delete.
(__arm_sqshl): Delete.
(__arm_srshr): Delete.
* config/arm/mve.md (mve_sqshl_si, mve_srshr_si): Fix operand 1
mode.

gcc/testsuite/ChangeLog:
* gcc.target/arm/mve/intrinsics/sqshl_check_shift.c: New test.
* gcc.target/arm/mve/intrinsics/srshr_check_shift.c: New test.
* gcc.target/arm/mve/intrinsics/uqshl_check_shift.c: New test.
* gcc.target/arm/mve/intrinsics/urshr_check_shift.c: New test.

2 weeks agoarm: [MVE intrinsics] rework sqshll srshrl uqshll urshrl
Christophe Lyon [Fri, 19 Sep 2025 13:14:51 +0000 (13:14 +0000)] 
arm: [MVE intrinsics] rework sqshll srshrl uqshll urshrl

Implement sqshll, srshrl, uqshll and urshrl using the new MVE builtins
framework.

gcc/ChangeLog:
* config/arm/arm-mve-builtins-base.cc (enum which_scalar_shift):
Add ss_SQSHLL, ss_SRSHRL, ss_UQSHLL, ss_URSHRL.
(mve_function_scalar_shift): Add support for ss_SQSHLL, ss_SRSHRL,
ss_UQSHLL, ss_URSHRL.
* config/arm/arm-mve-builtins-base.def (sqshll, srshrl, uqshll)
(urshrl): New.
* config/arm/arm-mve-builtins-base.h (sqshll, srshrl, uqshll)
(urshrl): New.
* config/arm/arm-mve-builtins-shapes.cc (scalar_s64_shift_imm)
(scalar_u64_shift_imm): New.
* config/arm/arm-mve-builtins-shapes.h (scalar_s64_shift_imm)
(scalar_u64_shift_imm): New.
* config/arm/arm_mve.h (sqshll): Delete.
(srshrl): Delete.
(uqshll): Delete.
(urshrl): Delete.
(__arm_uqshll): Delete.
(__arm_urshrl): Delete.
(__arm_srshrl): Delete.
(__arm_sqshll): Delete.

gcc/testsuite/ChangeLog:
* gcc.target/arm/mve/intrinsics/sqshll_check_shift.c: New test.
* gcc.target/arm/mve/intrinsics/srshrl_check_shift.c: New test.
* gcc.target/arm/mve/intrinsics/uqshll_check_shift.c: New test.
* gcc.target/arm/mve/intrinsics/urshrl_check_shift.c: New test.

2 weeks agoarm: [MVE intrinsics] rework sqrshrl sqrshrl_sat48
Christophe Lyon [Fri, 19 Sep 2025 13:11:29 +0000 (13:11 +0000)] 
arm: [MVE intrinsics] rework sqrshrl sqrshrl_sat48

Implement sqrshrl and sqrshrl_sat48 using the new MVE builtins
framework.

gcc/ChangeLog:
* config/arm/arm-mve-builtins-base.cc (enum which_scalar_shift):
Add ss_SQRSHRL, ss_SQRSHRL_SAT48.
(mve_function_scalar_shift): Add support for ss_SQRSHRL,
ss_SQRSHRL_SAT48.
(sqrshrl, sqrshrl_sat48): New.
* config/arm/arm-mve-builtins-base.def (sqrshrl, sqrshrl_sat48): New.
* config/arm/arm-mve-builtins-base.h (sqrshrl, sqrshrl_sat48): New.
* config/arm/arm_mve.h (sqrshrl): Delete.
(sqrshrl_sat48): Delete.
(__arm_sqrshrl): Delete.
(__arm_sqrshrl_sat48): Delete.
* config/arm/mve.md (mve_sqrshrl_sat<supf>_di): Add '@' prefix.

2 weeks agoarm: [MVE intrinsics] rework uqrshll uqrshll_sat48
Christophe Lyon [Fri, 19 Sep 2025 13:08:33 +0000 (13:08 +0000)] 
arm: [MVE intrinsics] rework uqrshll uqrshll_sat48

Implement uqrshll and uqrshll_sat48 using the new MVE builtins
framework.

gcc/ChangeLog:
* config/arm/arm-mve-builtins-base.cc (enum which_scalar_shift):
Add ss_UQRSHLL, ss_UQRSHLL_SAT48.
(mve_function_scalar_shift): Add support for ss_UQRSHLL,
ss_UQRSHLL_SAT48.
* config/arm/arm-mve-builtins-base.def (uqrshll, uqrshll_sat48):
New.
* config/arm/arm-mve-builtins-base.h (uqrshll, uqrshll_sat48):
New.
* config/arm/arm_mve.h (uqrshll): Delete.
(uqrshll_sat48): Delete.
(__arm_uqrshll): Delete.
(__arm_uqrshll_sat48): Delete.
* config/arm/mve.md (mve_uqrshll_sat<supf>_di): Add '@' prefix.

2 weeks agoarm: [MVE intrinsics] rework vpnot
Christophe Lyon [Wed, 20 Aug 2025 16:04:06 +0000 (16:04 +0000)] 
arm: [MVE intrinsics] rework vpnot

Implement vpnot using the new MVE builtins framework.

gcc/ChangeLog:

* config/arm/arm-mve-builtins-base.cc (class mve_function_vpnot): New.
(vpnot): New.
* config/arm/arm-mve-builtins-base.def (vpnot): New.
* config/arm/arm-mve-builtins-base.h (vpnot): New.
* config/arm/arm-mve-builtins-shapes.cc (struct vpnot): New.
* config/arm/arm-mve-builtins-shapes.h (vpnot): New.
* config/arm/arm_mve.h (vpnot): Delete.
(__arm_vpnot): Delete.

2 weeks agoAdd 'num_children' method to relevant pretty-printers
Tom Tromey [Mon, 3 Nov 2025 21:02:22 +0000 (14:02 -0700)] 
Add 'num_children' method to relevant pretty-printers

A user pointed out that, in DAP mode, gdb would hang while trying to
display a certain vector.  See

    https://sourceware.org/bugzilla/show_bug.cgi?id=33594

This is caused by a combination of things: the vector is
uninitialized, DAP requires a count of the number of children of a
variable, and libstdc++ printers don't implement the 'num_children'
method, so gdb tries to count children by iterating.

In this case, the vector has a nonsensical size:

    (gdb) p myVector
    $1 = std::vector of length -34979931, capacity -33992726

This patch adds a 'num_children' method to a subset of the
pretty-printers, in particular ones where I thought the length might
be arbitrarily large and susceptible to being garbage when the object
isn't initialized.

I've also specifically added a check to the vector printer for the
case where the length is negative.

These container printers could be further improved by adding the
'child' method, allowing random access to child objects.  However I
haven't done that here.

libstdc++-v3/ChangeLog

* python/libstdcxx/v6/printers.py (StdVectorPrinter._bounds):
New method.
(StdVectorPrinter.to_string): Use it.
(StdVectorPrinter.num_children): New method.
(StdStackOrQueuePrinter.num_children): New method.
(StdMapPrinter.num_children): New method.
(StdSetPrinter.num_children): New method.
(StdDequePrinter._size): New method.
(StdDequePrinter.to_string): Use it.
(StdDequePrinter.num_children): New method.
(Tr1UnorderedSetPrinter.num_children): New method.
(Tr1UnorderedMapPrinter.num_children): New method.
(StdSpanPrinter.num_children): New method.

2 weeks agolibstdc++: Ensure that _Utf_view is always a view.
Tomasz Kamiński [Fri, 14 Nov 2025 16:43:59 +0000 (17:43 +0100)] 
libstdc++: Ensure that _Utf_view is always a view.

Previously, _Utf_view accepted any input_range, including reference-to-array
types like char(&)[2], and stored it as the _M_base member. In such cases,
_Utf_view was not assignable, failing the requirements of view concept.

This patch addresses the issue by adding the ranges::view constraint to the
second template parameter of _Utf_view, and for clarity renaming it from
_Range to _View. The constructor is also adjusted to accept its argument
by value (views must be O(1) move-constructible). This prevents implicitly
generated CTAD from deducing a reference type.

This makes _Utf_view consistent with both other standard views and the
wording from P2728R8: Unicode in the Library, Part 1: UTF Transcoding [1].

The explicit CTAD from viewable_range is not defined for _Utf_view because
it depends on views::all_t, views::ref_view, and views::owning_view,
which are declared in <ranges>. Consequently, users must explicitly cast
the argument to a view or specify it as a template parameter.

[1] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2728r8.html

libstdc++-v3/ChangeLog:

* include/bits/unicode.h (_Utf_view): Rename the template parameter
from _Range to _View and constrain it with ranges::view.
(_Utf_view::_Utf_view): Accept by value instead of rvalue reference.
* include/std/format (__format::__write_padded): Replace _Utf_view
over const char32_t(&)[1] with span<const char32_t, 1>.
* testsuite/ext/unicode/view.cc: Add checks if specialization
of _Utf_view satisfy view. Wrap arrays into std::span before
constructing _Utf_view.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 weeks agofortran: correctly handle optional allocatable dummy arguments
Yuao Ma [Thu, 13 Nov 2025 14:50:28 +0000 (22:50 +0800)] 
fortran: correctly handle optional allocatable dummy arguments

This patch fixes a regression introduced in r14-8400-g186ae6d2cb93ad.

gcc/fortran/ChangeLog:

* trans-expr.cc (conv_dummy_value): Add check for NULL allocatable.

gcc/testsuite/ChangeLog:

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

2 weeks agolibstdc++: Add comment to __cpp_lib_bitset preprocessor condition
Jonathan Wakely [Fri, 14 Nov 2025 12:16:05 +0000 (12:16 +0000)] 
libstdc++: Add comment to __cpp_lib_bitset preprocessor condition

libstdc++-v3/ChangeLog:

* include/std/bitset: Add comment to feature test macro test.

2 weeks agolibstdc++: std::bitset<0>("zero") should throw std::invalid_argument [PR121054]
Karpalo Toivonen [Sat, 8 Nov 2025 13:51:46 +0000 (15:51 +0200)] 
libstdc++: std::bitset<0>("zero") should throw std::invalid_argument [PR121054]

According to the standard the first n characters of a bitset constructor
string need to be checked instead of only N.

libstdc++-v3/ChangeLog:

PR libstdc++/121054
* include/std/bitset: Add string check to constructor.
* testsuite/20_util/bitset/121054.cc: New test.
* testsuite/20_util/bitset/cons/constexpr_c++23.cc: Fix.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
2 weeks agoRemove --param=switch-lower-slow-alg-max-cases
Filip Kastl [Fri, 14 Nov 2025 10:31:37 +0000 (11:31 +0100)] 
Remove --param=switch-lower-slow-alg-max-cases

I removed the only use of this param in r16-348-gc14560907a9586.  Remove
the param.

gcc/ChangeLog:

* doc/invoke.texi: Remove mention of switch-lower-slow-alg-max-cases.
* params.opt: Remove switch-lower-slow-alg-max-cases.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
2 weeks agoi386: Remove 'i' from output operand constraint
Uros Bizjak [Fri, 14 Nov 2025 12:01:28 +0000 (13:01 +0100)] 
i386: Remove 'i' from output operand constraint

It is not possible to use 'i' as output operand constraint.

gcc/ChangeLog:

* config/i386/i386.md (*sub<mode>_3):
Remove 'i' from operand 0 constraint.

2 weeks agoipa/122663 - fix ICE with stmt removal during IPA modification
Richard Biener [Thu, 13 Nov 2025 12:40:27 +0000 (13:40 +0100)] 
ipa/122663 - fix ICE with stmt removal during IPA modification

We currently remove stmts inside of a FOR_EACH_IMM_USE_STMT iteration
which can be problematical.  The following adjusts purge_all_uses
to gather all stmts to remove and remove them in reverse order
afterwards which also better deals with debug stmt generation.

PR ipa/122663
* ipa-param-manipulation.cc (purge_all_uses): Collect
stmts to remove and process that list in reverse.

* g++.dg/torture/pr122663.C: New testcase.

2 weeks agolibstdc++: Use _Bind_front_t/_Bind_back_t in bind_front<f>/bind_back<f> [PR122032]
Tomasz Kamiński [Fri, 24 Oct 2025 08:24:26 +0000 (10:24 +0200)] 
libstdc++: Use _Bind_front_t/_Bind_back_t in bind_front<f>/bind_back<f> [PR122032]

This patch changes the implementation of bind_front<f> and bind_back<f> to
return a _Bind_front_t<_Bind_fn_t<f>, ...> and _Bind_back_t<_Bind_fn_t<f>, ...>
respectively, replacing the previous lambda-based implementation. The prior use
of a lambda caused non-conforming behavior with respect to C++23 [func.require]
p8, which requires that bind_front<f>(s), bind_front<f>(move(s)), and
bind_front<f>(as_const(s)) produce the same type.

Additionally, using specialized structs reduces the size of the resulting functor
in certain scenarios (see PR).

For the zero-argument case, the function still returns a _Bind_fn_t<f>. Since this
type is already a perfect forwarding call wrapper, it yields the same result as
_Bind_front_t<_Bind_fn_t<f>>.

A consequence of this change is that the types returned by bind_front<f>(args...)
and bind_back<f>(args...) are no longer structural - they are not required to be
structural by the standard.

PR libstdc++/122032

libstdc++-v3/ChangeLog:

* include/std/functional (std::bind_front<f>, std::bind_back<f>):
Define in terms of _Bind_front_t/_Bind_back_t.
* testsuite/20_util/function_objects/bind_back/nttp.cc: New tests.
* testsuite/20_util/function_objects/bind_front/nttp.cc: New tests.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 weeks agotree-optimization/122573 - enhance SLP of invariant loads
Richard Biener [Thu, 6 Nov 2025 10:49:31 +0000 (11:49 +0100)] 
tree-optimization/122573 - enhance SLP of invariant loads

Currently SLP of invariant loads is only supported for the case of
a single load that is splat, as side-effect of supporting this case
even for non-invariant loads.  The following extends this to any
set of invariant loads.  The way we have load permutations for
these makes it a bit awkward, thus adjustments in that area.

PR tree-optimization/122573
* tree-vect-slp.cc (vect_build_slp_tree_1): Support
groups of invariant loads.
(vect_build_slp_tree_2): Likewise.
(vect_transform_slp_perm_load_1): Likewise.
* tree-vect-stmts.cc (vectorizable_load): Handle non-splat
SLP for invaraint loads.

* gcc.dg/vect/slp-58.c: New testcase.

2 weeks agoFortran: procedure targets in derived-type constructors [PR117070]
Harald Anlauf [Thu, 13 Nov 2025 21:34:03 +0000 (22:34 +0100)] 
Fortran: procedure targets in derived-type constructors [PR117070]

PR fortran/117070

gcc/fortran/ChangeLog:

* array.cc (check_constructor): Allow procedures as potential
target of a procedure pointer.

gcc/testsuite/ChangeLog:

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

2 weeks agotree-optimization/122680 - avoid range query during vect transform
Richard Biener [Fri, 14 Nov 2025 07:20:56 +0000 (08:20 +0100)] 
tree-optimization/122680 - avoid range query during vect transform

Range queries during analysis on the original loop might not yield
the same result as those on the epilog during transform.  Separate
analysis from transform here.

PR tree-optimization/122680
* tree-vect-stmts.cc (vectorizable_conversion): Avoid range
queries during transform.

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

2 weeks agobuild: Require binutils 2.30+ on Solaris [PR121457, PR121458]
Rainer Orth [Fri, 14 Nov 2025 08:12:34 +0000 (09:12 +0100)] 
build: Require binutils 2.30+ on Solaris [PR121457, PR121458]

I recently noticed that gcc/configure.ac contains quite a number of
checks for Solaris ld and GNU ld versions that can be massively
simplified.  GCC trunk only supports Solaris 11.4, thus Solaris ld is at
least at version 5.11-1.3159 (the one in 11.4 FCS), and GNU ld can be
required to be at least 2.30.1, the version bundled in 11.4 FCS.

This way quite a number of special cases can simply be removed, as well
as some macros that depend on them and the code they guard.

To ensure that nobody tries to use an older self-compiled version of GNU
ld, the minimum version is checked at configure time.

This change also allowed to fix two bugs that were caused by checks for
*_sol2 among the linker emulations listed by gld -V, which are only valid
when targetting Solaris.  Before those checks were done irrespective of
target, causing checks to go wrong when a version of binutils configured
with --enable-targets=all was used.  Since now all versions of GNU ld
supported on Solaris are known to support those *_sol2 emulations, the
checks can be replaced by hardcoding the emulations when targetting
Solaris.

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

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

gcc:
PR target/121458
PR target/121457
* configure.ac: Fix typos.
<*-*-solaris2*>: Require GNU ld 2.30.
(comdat_group) <*-*-solaris2.1[1-9]*>: Always set to yes.
(ld_ix86_gld_32_opt): Only use -melf_i386_sol2 for Solaris target.
(ld_ix86_gld_64_opt): Likewise with -melf_x86_64_sol.
(gcc_cv_ld_eh_frame_hdr) <*-*-solaris2*>: Likewise.
(gcc_cv_ld_pie) <*-*-solaris2*>: Remove special cases.
(gcc_cv_ld_compress_debug) <*-*-solaris2*>: Remove guard.
(gcc_cv_ld_as_needed): Simplify guard.
(gcc_cv_ld_sol2_emulation): Remove.
(gcc_cv_solaris_crts): Remove.
* configure: Regenerate.
* config.in: Regenerate.

* config/sol2.h (STARTFILE_CRTBEGIN_SPEC): Remove !HAVE_LD_PIE
support.
(ENDFILE_CRTEND_SPEC): Likewise.
(LD_PIE_SPEC): Likewise.
[USE_GLD] (LINK_EH_SPEC): Set unconditionally.
* config/i386/sol2.h [USE_GLD]: Remove !HAVE_LD_SOL2_EMULATION
support.
* config/sparc/sol2.h: Likewise.

* doc/install.texi (Specific, *-*-solaris2*): Update bundled gcc
versions.
Raise required binutils version.
Remove binutils 2.44 caveat.

2 weeks agoarm: [MVE intrinsics] rework asrl lsll [PR122216]
Christophe Lyon [Fri, 19 Sep 2025 13:04:55 +0000 (13:04 +0000)] 
arm: [MVE intrinsics] rework asrl lsll [PR122216]

Implement asrl and lsll using the new MVE builtins framework.

gcc/ChangeLog:

PR target/122216
* config/arm/arm-mve-builtins-base.cc (enum which_scalar_shift): New.
(mve_function_scalar_shift): New.
(asrl, lsll): New.
* config/arm/arm-mve-builtins-base.def (asrl, lsll): New.
* config/arm/arm-mve-builtins-base.h (asrl, lsll): New.
* config/arm/arm_mve.h (asrl): Delete.
(lsll): Delete.
(__arm_asrl): Delete.
(__arm_lsll): Delete.

2 weeks agoarm: [MVE intrinsics] add scalar_s64_shift scalar_u64_shift shapes [PR122216]
Christophe Lyon [Fri, 19 Sep 2025 12:35:35 +0000 (12:35 +0000)] 
arm: [MVE intrinsics] add scalar_s64_shift scalar_u64_shift shapes [PR122216]

This patch adds the scalar_s64_shift and scalar_u64_shift shape
descriptions.

gcc/ChangeLog:

PR target/122216
* config/arm/arm-mve-builtins-shapes.cc (scalar_s64_shift): New.
(scalar_u64_shift): New.
* config/arm/arm-mve-builtins-shapes.h: Likewise.

2 weeks agoarm: add support for out of range shift amount in MVE asrl and lsll [PR122216]
Christophe Lyon [Thu, 18 Sep 2025 16:41:19 +0000 (16:41 +0000)] 
arm: add support for out of range shift amount in MVE asrl and lsll [PR122216]

MVE asrl and lsll instructions have two variants:
- immediate shift amount in the [1..32] range
- shift amount in a register, where negative values reverse the
  direction of the shift

However, RTL assumes that the shift amount is interpreted unsigned, so
we want to make sure undesired simplifications do not take place.
For instance if simplify_rtx optimizes
(set (reg:SI 1) (const_int -5))
(set (reg:DI 2) (ashift:DI (reg:DI 3) (reg:SI 1)))
into:
(set (reg:DI 2) (ashift:DI (reg:DI 3) (const_int -5)))
we do not want this to be interpreted as undefined behavior.

We handle this using a general pattern where:
- immediates are handled by a define_insn_and_split pattern which
  directly maps immediates in [1..32] to the shift operator and splits
  other cases as needed.
- non-immediates are handled by another pattern

gcc/ChangeLog:

PR target/122216
* config/arm/arm.md (ashldi3, ashrdi3): Force shift amount into
QImode.
* config/arm/constraints.md: Fix comment, Pg is valid in Thumb-2
state only.
* config/arm/mve.md (mve_asrl): Handle various shift amount ranges.
(mve_asrl_imm, mve_asrl_internal): New patterns.
(mve_lsll): Handle various shift amount ranges.
(mve_lsll_imm, mve_lsll_internal): New patterns.

gcc/testsuite/ChangeLog:

PR target/122216
* gcc.target/arm/mve/intrinsics/asrl-various-ranges.c: New test.
* gcc.target/arm/mve/intrinsics/lsll-various-ranges.c: New test.

2 weeks agoarm: fix MVE asrl lsll lsrl patterns [PR122216]
Christophe Lyon [Wed, 27 Aug 2025 09:42:56 +0000 (09:42 +0000)] 
arm: fix MVE asrl lsll lsrl patterns [PR122216]

The thumb2_asrl, thumb2_lsll and thumb2_lsrl patterns were incorrecly
using (match_dup 0) for the first argument of the shift operator.

This patch replaces that with (match_operand:DI 1
arm_general_register_operandarm_general_register_operand "0") and
fixes the related expanders in arm.md to use that additional argument
and get rid of the copy of operands[1] to operands[0].

Finally, since these patterns are MVE-only, rename them into mve_XXX
and move them to mve.md.

gcc/ChangeLog:

PR target/122216
* config/arm/thumb2.md (thumb2_asrl, thumb2_lsll, thumb2_lsrl):
Move to ...
* config/arm/mve.md (mve_asrl, mve_lsll, mve_lsrl): ... here. Use
match_operand instead of match_dup.
* config/arm/arm.md (ashldi3, ashrdi3, lshrdi3): Remove useless
copy. Update for new prototype.

2 weeks agoRegenerate gcc/configure
Xi Ruoyao [Fri, 14 Nov 2025 02:11:07 +0000 (10:11 +0800)] 
Regenerate gcc/configure

When I rebased r16-5226 I failed to notice the generated configure is
different after r16-5138.

gcc/

* configure: Regenerate.

2 weeks agoLoongArch: optimize half of vector copy for V4DFmode.
zhaozhou [Mon, 10 Nov 2025 07:04:01 +0000 (15:04 +0800)] 
LoongArch: optimize half of vector copy for V4DFmode.

Repalce xvpermi to xvbsrl when vector of V4DFmode high 64 bits copy to
low 64 bits, reduce 2 insn delays.

gcc/ChangeLog:

* config/loongarch/lasx.md (lasx_xvbsrl_d_f): New template.
* config/loongarch/loongarch.cc (emit_reduc_half): Replace insn.

gcc/testsuite/ChangeLog:

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

2 weeks agoLoongArch: Fix predicate for symbolic_pcrel_offset_operand.
zhaozhou [Mon, 10 Nov 2025 07:20:26 +0000 (15:20 +0800)] 
LoongArch: Fix predicate for symbolic_pcrel_offset_operand.

The predicate checks if the operand is PLUS(symbol_ref, const_int), but
the match (match_operand 0/1) is not equal XEXP(op, 0/1). It should be
adjusted to use match_test and pass XEXP(op, 0/1) into the constraint
function.

gcc/ChangeLog:

* config/loongarch/predicates.md: Update ops.

2 weeks agoLoongArch: Fix issue where data marked as GTY is cleaned up by ggc.
zhaozhou [Mon, 10 Nov 2025 07:38:26 +0000 (15:38 +0800)] 
LoongArch: Fix issue where data marked as GTY is cleaned up by ggc.

As for GGC(GCC Garbage Collection), it's use gengtype tool to scan all
source files contain the GTY mark, and generate gt-*.h files. GGC
traversal these file to find gt_root node and marks these objects that
directly or indirectly reference this node as active, then clean up
unmarked object's memory.

For the loongarch-builtins.cc file, it is necessary to add
target_gtfiles in config.gcc to generate gt-loongarch-builtins.h, and
include this header file in the .cc file, prevented the data marked
with GTY in this `.cc` file cleaned up by ggc.

gcc/ChangeLog:

* config.gcc: Add target_gtfiles.
* config/loongarch/loongarch-builtins.cc: Add header file.

2 weeks agoDaily bump.
GCC Administrator [Fri, 14 Nov 2025 00:20:34 +0000 (00:20 +0000)] 
Daily bump.

2 weeks agoFortran: Remove dg-bogus from test case.
Jerry DeLisle [Thu, 13 Nov 2025 23:31:06 +0000 (15:31 -0800)] 
Fortran: Remove dg-bogus from test case.

PR fortran/96255

gcc/testsuite/ChangeLog:

* gfortran.dg/do_concurrent_typespec_1.f90: Delete three
dg-bogus directives not needed.

2 weeks ago[vxworks] wrap base/b_NULL.h to override NULL
Alexandre Oliva [Thu, 13 Nov 2025 22:54:01 +0000 (19:54 -0300)] 
[vxworks] wrap base/b_NULL.h to override NULL

Some versions of vxworks define NULL to __nullptr in C++, assuming
C++11, which breaks at least a number of analyzer tests that get
exercised in C++98 mode.

Wrap the header that defines NULL so that, after including it, we
override the NULL definition with the one provided by stddef.h.

That required some infrastructure to enable subdirectories in extra
headers.  Since USER_H filenames appear as dependencies, that limits
the possibilities or markup, so I went for a filesystem-transparent
sequence that doesn't appear in any extra_headers whatsoever, namely
/././, to mark the beginning of the desired install name.

Co-Authored-By: Olivier Hainque <hainque@adacore.com>
for  gcc/ChangeLog

* config/vxworks/base/b_NULL.h: New.
* config.gcc (extra_headers) <*-*-vxworks*>: Add it.
* Makefile.in (stmp-int-hdrs): Support /././ markers in USER_H
to mark the beginning of the install name.  Document.
* doc/sourcebuild.texi (Headers): Document /././ marker.

2 weeks agoc++/modules: Add testcase for lookup of hidden friend [PR122646]
Nathaniel Shead [Thu, 13 Nov 2025 22:11:25 +0000 (09:11 +1100)] 
c++/modules: Add testcase for lookup of hidden friend [PR122646]

r16-5173-g52a24bcec9388a fixed this testcase, but I think it's
worthwhile still adding this reduced test for it to the modules.exp set
of tests so we don't need to rely on libstdc++ tests for it yet.

PR c++/122646

gcc/testsuite/ChangeLog:

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

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2 weeks agoMerge remove_forwarder_block_with_phi into remove_forwarder_block
Andrew Pinski [Tue, 11 Nov 2025 20:07:11 +0000 (12:07 -0800)] 
Merge remove_forwarder_block_with_phi into remove_forwarder_block

This is the last cleanup in this area. Merges the splitting functionality
of remove_forwarder_block_with_phi into remove_forwarder_block.
Now mergephi still has the ability to split the edges when merging the forwarder
block with a phi. But this reduces the non-shared code a lot.

gcc/ChangeLog:

* tree-cfgcleanup.cc (tree_forwarder_block_p): Remove must argument.
(remove_forwarder_block): Add can_split
argument. Handle the splitting case (iff phis in bb).
(cleanup_tree_cfg_bb): Update argument to tree_forwarder_block_p.
(remove_forwarder_block_with_phi): Remove.
(pass_merge_phi::execute): Update argument to tree_forwarder_block_p
and call remove_forwarder_block instead of remove_forwarder_block_with_phi.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks agocfgcleanup: Support merging forwarder blocks with phis [PR122493]
Andrew Pinski [Tue, 11 Nov 2025 19:29:38 +0000 (11:29 -0800)] 
cfgcleanup: Support merging forwarder blocks with phis [PR122493]

This adds support for merging forwarder blocks with phis in cleanupcfg.
This patch might seem small but that is because the previous patches were
done to build up to make it easier to add this support.

There is still one more patch to merge remove_forwarder_block
and remove_forwarder_block_with_phi since remove_forwarder_block_with_phi
supports splitting an edge which is not supported as an option in remove_forwarder_block.
The splitting edge option should not be enabled for cfgcleanup but only for mergephi.

Note r8-338-ge7d70c6c3bccb2 added always creating a preheader for loops so we should
protect them if we have a phi node as it goes back and forth here. And both the gimple
and RTL loop code likes to have this preheader in the case of having the same constant
value being starting of the loop.

explaination on testcase changes
gcc.target/i386/pr121062-1.c needed a small change because there is a basic block
which is not duplicated so only one `movq reg, -1` is there instead of 2.

uninit-pred-7_a.c is xfailed and filed as PR122660, some analysis in the PR already of
the difference now.

uninit-pred-5.C was actually a false positive because when
m_best_candidate is non-NULL, m_best_candidate_len is always initialized.
The log message on the testcase is wrong if you manually fall the path
you can notice that. With an extra jump threading after the merging of
some bbs, the false positive is now no longer happening. So change the
dg-warning to dg-bogus.

ssa-dom-thread-7.c now jump threads 12 times in thread2 instead of 8

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/122493
gcc/ChangeLog:

* tree-cfgcleanup.cc (tree_forwarder_block_p): Change bool argument
to a must have phi and allow phis if it is false.
(remove_forwarder_block): Add support for merging of forwarder blocks
with phis.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr121062-1.c: Update count.
* gcc.dg/uninit-pred-7_a.c: xfail line 23.
* g++.dg/uninit-pred-5.C: Change dg-warning to dg-bogus.
* gcc.dg/tree-ssa/ssa-dom-thread-7.c: Update count of jump thread.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks agofix handling of mapped and their location
Andrew Pinski [Wed, 12 Nov 2025 09:30:30 +0000 (01:30 -0800)] 
fix handling of mapped and their location

So when we using the newly mapped location, we should check if
it is not unknown location and if so just use the original location.
Note this is a latent bug in remove_forwarder_block_with_phi code too.

This fixes gcc.dg/uninit-pr40635.c when doing more mergephi.

gcc/ChangeLog:

* tree-cfg.cc (copy_phi_arg_into_existing_phi): Use the original location
if the mapped location is unknown.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks agomergephi: extend copy_phi_arg_into_existing_phi and use it for remove_forwarder_block...
Andrew Pinski [Tue, 11 Nov 2025 08:38:25 +0000 (00:38 -0800)] 
mergephi: extend copy_phi_arg_into_existing_phi and use it for remove_forwarder_block_with_phi

copy_phi_arg_into_existing_phi was added in r14-477-g78b0eea7802698
and used in remove_forwarder_block but since
remove_forwarder_block_with_phi needed to use the redirect edge var
map, it was not moved over. This extends copy_phi_arg_into_existing_phi
to have the ability to optional use the mapper.

This also makes remove_forwarder_block_with_phi and remove_forwarder_block closer to
one another. There is a few other changes needed to be able to do both
from the same function.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-cfg.cc (copy_phi_arg_into_existing_phi): New use_map argument.
* tree-cfg.h (copy_phi_arg_into_existing_phi): Update declaration.
* tree-cfgcleanup.cc (remove_forwarder_block_with_phi): Use
copy_phi_arg_into_existing_phi instead of inlining it.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks agocfgcleanup: Move ei definition into for loop for remove_forwarder_block
Andrew Pinski [Mon, 10 Nov 2025 01:22:14 +0000 (17:22 -0800)] 
cfgcleanup: Move ei definition into for loop for remove_forwarder_block

This moves the ei definition directly into for loo
like was done for remove_forwarder_block_with_phi.

gcc/ChangeLog:

* tree-cfgcleanup.cc (remove_forwarder_block): Move
variable declaration ei into for loop.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks agomergephi: use edge iterator in remove_forwarder_block_with_phi
Andrew Pinski [Mon, 10 Nov 2025 01:17:49 +0000 (17:17 -0800)] 
mergephi: use edge iterator in remove_forwarder_block_with_phi

It was always kinda of odd that while remove_forwarder_block used
an edge iterator, remove_forwarder_block_with_phi used a while loop.
remove_forwarder_block_with_phi was added after remove_forwarder_block too.

Anyways this changes remove_forwarder_block_with_phi into use the same
form of loop so it is easier to merge the 2.

gcc/ChangeLog:

* tree-cfgcleanup.cc (remove_forwarder_block_with_phi): Use
edge iterator instead of while loop.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks agocfgcleanup: Remove check on available dominator information in remove_forwarder_block
Andrew Pinski [Mon, 10 Nov 2025 00:13:05 +0000 (16:13 -0800)] 
cfgcleanup: Remove check on available dominator information in remove_forwarder_block

Since at least r9-1005-gb401e50fed4def, dominator information is
available in remove_forwarder_block so there is no reason to have a
check on if we should update the dominator information, always do it.

This is one more step into commoning remove_forwarder_block and remove_forwarder_block_with_phi.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-cfgcleanup.cc (remove_forwarder_block): Remove check
on the available dominator information.

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