]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
7 hours agoc++/modules: Import purview using-directives in the same module [PR122279] master trunk
Nathaniel Shead [Wed, 15 Oct 2025 07:13:38 +0000 (18:13 +1100)] 
c++/modules: Import purview using-directives in the same module [PR122279]

[namespace.qual] p1 says that a namespace nominated by a using-directive
is searched if the using-directive precedes that point.

[basic.lookup.general] p2 says that a declaration in a different TU
within a module purview is visible if either the declaration is
exported, or the other TU is part of the same module as the point of
lookup.  This patch implements the second half of that.

PR c++/122279

gcc/cp/ChangeLog:

* module.cc (depset::hash::add_namespace_entities): Seed any
purview using-decls.
(module_state::write_using_directives): Stream if the udir was
exported or not.
(module_state::read_using_directives): Add the using-directive
if it's either exported or part of this module.

gcc/testsuite/ChangeLog:

* g++.dg/modules/namespace-13_b.C: Adjust expected results.
* g++.dg/modules/namespace-13_c.C: Test non-exported
using-directive is not used.
* g++.dg/modules/namespace-14_a.C: New test.
* g++.dg/modules/namespace-14_b.C: New test.
* g++.dg/modules/namespace-14_c.C: New test.
* g++.dg/modules/namespace-14_d.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
13 hours agoAArch64: Implement widen_[us]sum using 2-way [US]UDOT for SVE2p1 [PR122069]
Tamar Christina [Sat, 18 Oct 2025 07:22:50 +0000 (08:22 +0100)] 
AArch64: Implement widen_[us]sum using 2-way [US]UDOT for SVE2p1 [PR122069]

SVE2p1 adds 2-way dotproduct which we can use when we have to do a single step
widening addition.  This is useful for instance when the value to be widened
does not come from a load.  For example for

int foo2_int(unsigned short *x, unsigned short * restrict y) {
  int sum = 0;
  for (int i = 0; i < 8000; i++)
    {
      x[i] = x[i] + y[i];
      sum += x[i];
    }
  return sum;
}

we used to generate

.L12:
        ld1h    z30.h, p7/z, [x0, x2, lsl 1]
        ld1h    z29.h, p7/z, [x1, x2, lsl 1]
        add     z30.h, z30.h, z29.h
        uaddwb  z31.s, z31.s, z30.h
        uaddwt  z31.s, z31.s, z30.h
        st1h    z30.h, p7, [x0, x2, lsl 1]
        mov     x3, x2
        inch    x2
        cmp     w2, w4
        bls     .L12
        inch    x3
        uaddv   d31, p7, z31.s

but with +sve2p1

.L12:
        ld1h    z31.h, p7/z, [x0, x2, lsl 1]
        ld1h    z29.h, p7/z, [x1, x2, lsl 1]
        add     z31.h, z31.h, z29.h
        udot    z30.s, z31.h, z28.h
        st1h    z31.h, p7, [x0, x2, lsl 1]
        mov     x3, x2
        inch    x2
        cmp     w2, w4
        bls     .L12
        inch    x3
        uaddv   d30, p7, z30.s

gcc/ChangeLog:

PR middle-end/122069
* config/aarch64/aarch64-sve2.md
(widen_ssum<mode><Vnarrow>3): Update.
(widen_usum<mode><Vnarrow>3): Update.

gcc/testsuite/ChangeLog:

PR middle-end/122069
* gcc.target/aarch64/sve2/pr122069_3.c: New test.
* gcc.target/aarch64/sve2/pr122069_4.c: New test.

13 hours agoAArch64: Implement widen_[us]sum using [US]ADDW[TB] for SVE2 [PR122069]
Tamar Christina [Sat, 18 Oct 2025 07:22:18 +0000 (08:22 +0100)] 
AArch64: Implement widen_[us]sum using [US]ADDW[TB] for SVE2 [PR122069]

SVE2 adds [US]ADDW[TB] which we can use when we have to do a single step
widening addition.  This is useful for instance when the value to be widened
does not come from a load.  For example for

int foo2_int(unsigned short *x, unsigned short * restrict y) {
  int sum = 0;
  for (int i = 0; i < 8000; i++)
    {
      x[i] = x[i] + y[i];
      sum += x[i];
    }
  return sum;
}

we used to generate

.L6:
        ld1h    z1.h, p7/z, [x0, x2, lsl 1]
        ld1h    z29.h, p7/z, [x1, x2, lsl 1]
        add     z29.h, z29.h, z1.h
        punpklo p6.h, p7.b
        uunpklo z0.s, z29.h
        add     z31.s, p6/m, z31.s, z0.s
        punpkhi p6.h, p7.b
        uunpkhi z30.s, z29.h
        add     z31.s, p6/m, z31.s, z30.s
        st1h    z29.h, p7, [x0, x2, lsl 1]
        add     x2, x2, x4
        whilelo p7.h, w2, w3
        b.any   .L6
        ptrue   p7.b, all
        uaddv   d31, p7, z31.s

but with +sve2

.L12:
        ld1h    z30.h, p7/z, [x0, x2, lsl 1]
        ld1h    z29.h, p7/z, [x1, x2, lsl 1]
        add     z30.h, z30.h, z29.h
        uaddwb  z31.s, z31.s, z30.h
        uaddwt  z31.s, z31.s, z30.h
        st1h    z30.h, p7, [x0, x2, lsl 1]
        mov     x3, x2
        inch    x2
        cmp     w2, w4
        bls     .L12
        inch    x3
        uaddv   d31, p7, z31.s

gcc/ChangeLog:

PR middle-end/122069
* config/aarch64/aarch64-sve2.md: (widen_ssum<mode><Vnarrow>3): New.
(widen_usum<mode><Vnarrow>3): New.
* config/aarch64/iterators.md (Vnarrow): New, to match VNARROW.

gcc/testsuite/ChangeLog:

PR middle-end/122069
* gcc.target/aarch64/sve2/pr122069_1.c: New test.
* gcc.target/aarch64/sve2/pr122069_2.c: New test.

13 hours agoAArch64: Implement widen_[us]sum using dotproduct for SVE [PR122069]
Tamar Christina [Sat, 18 Oct 2025 07:21:56 +0000 (08:21 +0100)] 
AArch64: Implement widen_[us]sum using dotproduct for SVE [PR122069]

This patch implements support for using dotproduct to do sum reductions by
changing += a into += (a * 1).  i.e. we seed the multiplication with 1.

Given the example

int foo_int(unsigned char *x, unsigned char * restrict y) {
  int sum = 0;
  for (int i = 0; i < 8000; i++)
     sum += char_abs(x[i] - y[i]);
  return sum;
}

we used to generate

.L2:
        ld1b    z1.b, p7/z, [x0, x2]
        ld1b    z29.b, p7/z, [x1, x2]
        sub     z29.b, z1.b, z29.b
        uunpklo z0.h, z29.b
        uunpkhi z29.h, z29.b
        uunpklo z30.s, z0.h
        add     z31.s, p6/m, z31.s, z30.s
        uunpkhi z0.s, z0.h
        add     z31.s, p5/m, z31.s, z0.s
        uunpklo z28.s, z29.h
        add     z31.s, p4/m, z31.s, z28.s
        uunpkhi z29.s, z29.h
        add     z31.s, p3/m, z31.s, z29.s
        add     x2, x2, x7
        whilelo p7.b, w2, w3
        whilelo p3.s, w2, w6
        whilelo p4.s, w2, w5
        whilelo p5.s, w2, w4
        whilelo p6.s, w2, w3
        b.any   .L2
        ptrue   p7.b, all
        uaddv   d31, p7, z31.s

but now generates with +dotprod

.L3:
        ld1b    z30.b, p7/z, [x5, x2]
        ld1b    z29.b, p7/z, [x1, x2]
        sub     z30.b, z30.b, z29.b
        udot    z31.s, z30.b, z28.b
        mov     x3, x2
        add     x2, x2, x6
        cmp     w2, w0
        bls     .L3
        incb    x3
        uaddv   d31, p7, z31.s

gcc/ChangeLog:

PR middle-end/122069
* config/aarch64/aarch64-sve.md (widen_<sur>sum<mode><vsi2qi>3): New.

gcc/testsuite/ChangeLog:

PR middle-end/122069
* gcc.target/aarch64/sve/pr122069_1.c: New test.
* gcc.target/aarch64/sve/pr122069_2.c: New test.

13 hours agors6000: convert widen_[us]sum into convert optab [PR122069]
Tamar Christina [Sat, 18 Oct 2025 07:21:30 +0000 (08:21 +0100)] 
rs6000: convert widen_[us]sum into convert optab [PR122069]

This patch is a mechanical rewrite of the widen_[us]sum optabs from a direct to
a conversion optab.  The result of which requires the output mode to be added to
the existing patterns.

No change in functionality is expected.

gcc/ChangeLog:

PR middle-end/122069
* config/rs6000/altivec.md (widen_usum<mode>3): Rename ...
(widen_usumv4si<mode>3): ... to this.
(widen_ssumv16qi3): Rename ...
(widen_ssumv4siv16qi3): ... to this.
(widen_ssumv8hi3): Rename ...
(widen_ssumv4siv8hi3): ... to this.

13 hours agoia64: convert widen_[us]sum into convert optab [PR122069]
Tamar Christina [Sat, 18 Oct 2025 07:21:09 +0000 (08:21 +0100)] 
ia64: convert widen_[us]sum into convert optab [PR122069]

The target does not seem to have a maintainer listed, I've CC'ed a group of
global maintainers instead hoping one of you could approve it.

This patch is a mechanical rewrite of the widen_[us]sum optabs from a direct to
a conversion optab.  The result of which requires the output mode to be added to
the existing patterns.

No change in functionality is expected.

gcc/ChangeLog:

PR middle-end/122069
* config/ia64/vect.md (widen_usumv8qi3): Renamed ...
(widen_usumv4hiv8qi3): ... into this.
(widen_usumv4hi3): Renamed ...
(widen_usumv2siv4hi3): ... into this.
(widen_ssumv8qi3): Renamed ...
(widen_ssumv4hiv8qi3): ... into this.
(widen_ssumv4hi3): Renamed ...
(widen_ssumv2siv4hi3): ... into this.

13 hours agoarm: convert widen_[us]sum into convert optab [PR122069]
Tamar Christina [Sat, 18 Oct 2025 07:20:47 +0000 (08:20 +0100)] 
arm: convert widen_[us]sum into convert optab [PR122069]

This patch is a mechanical rewrite of the widen_[us]sum optabs from a direct to
a conversion optab.  The result of which requires the output mode to be added to
the existing patterns.

No change in functionality is expected.

gcc/ChangeLog:

PR middle-end/122069
* config/arm/iterators.md (v_double_width): New, matching
V_double_width.
* config/arm/neon.md (widen_ssum<mode>3): Renamed ...
(widen_ssum<v_double_width><mode>3, widen_ssum<V_widen_l><mode>3): ...
into these.
(widen_usum<mode>3): Renamed ...
(widen_usum<v_double_width><mode>3, widen_usum<V_widen_l><mode>3): ...
into these.

13 hours agoAArch64: add double widen_sum optab using dotprod for Adv.SIMD [PR122069]
Tamar Christina [Sat, 18 Oct 2025 07:20:07 +0000 (08:20 +0100)] 
AArch64: add double widen_sum optab using dotprod for Adv.SIMD [PR122069]

This patch implements support for using dotproduct to do sum reductions by
changing += a into += (a * 1).  i.e. we seed the multiplication with 1.

Given the example

int foo_int(unsigned char *x, unsigned char * restrict y) {
  int sum = 0;
  for (int i = 0; i < 8000; i++)
     sum += char_abs(x[i] - y[i]);
  return sum;
}

we used to generate

.L2:
        ldr     q0, [x0, x2]
        ldr     q28, [x1, x2]
        sub     v28.16b, v0.16b, v28.16b
        zip1    v29.16b, v28.16b, v31.16b
        zip2    v28.16b, v28.16b, v31.16b
        uaddw   v30.4s, v30.4s, v29.4h
        uaddw2  v30.4s, v30.4s, v29.8h
        uaddw   v30.4s, v30.4s, v28.4h
        uaddw2  v30.4s, v30.4s, v28.8h
        add     x2, x2, 16
        cmp     x2, x3
        bne     .L2
        addv    s31, v30.4s

but now generates with +dotprod

.L2:
        ldr     q29, [x0, x2]
        ldr     q28, [x1, x2]
        sub     v28.16b, v29.16b, v28.16b
        udot    v31.4s, v28.16b, v30.16b
        add     x2, x2, 16
        cmp     x2, x3
        bne     .L2
        addv    s31, v31.4s

gcc/ChangeLog:

PR middle-end/122069
* config/aarch64/aarch64-simd.md (widen_ssum<mode><vsi2qi>3): New.
(widen_usum<mode><vsi2qi>3): New.

gcc/testsuite/ChangeLog:

PR middle-end/122069
* gcc.target/aarch64/pr122069_3.c: New test.
* gcc.target/aarch64/pr122069_4.c: New test.

13 hours agoAArch64: convert widen_sum optabs to convert [PR122069]
Tamar Christina [Sat, 18 Oct 2025 07:19:28 +0000 (08:19 +0100)] 
AArch64: convert widen_sum optabs to convert [PR122069]

This patch is a mechanical rewrite of the widen_[us]sum optabs from a direct to
a conversion optab.  The result of which requires the output mode to be added to
the existing patterns.

No change in functionality is expected.

gcc/ChangeLog:

PR middle-end/122069
* config/aarch64/aarch64-simd.md (widen_ssum<mode>3): Change into..
(widen_ssum<Vdblw><mode>3, widen_ssum<Vwide><mode>3): ... these.
(widen_usum<mode>3): Change into ...
(widen_usum<Vdblw><mode>3, widen_usum<Vwide><mode>3): ... these.
* config/aarch64/iterators.md (Vdblw): New.
(Vwide): Extend to match VWIDE.

gcc/testsuite/ChangeLog:

PR middle-end/122069
* gcc.target/aarch64/pr122069_1.c: New test.
* gcc.target/aarch64/pr122069_2.c: New test.

13 hours agomiddle-end: refactor WIDEN_SUM_EXPR into convert optab [PR122069]
Tamar Christina [Sat, 18 Oct 2025 07:18:14 +0000 (08:18 +0100)] 
middle-end: refactor WIDEN_SUM_EXPR into convert optab [PR122069]

This patch changes the widen_[us]sum optabs into a convert optabs such that
targets and specify more than one conversion.

Following this patch are patches rewriting all targets using this change.

While working on this I noticed that the pattern does miss some cases it
could handle if it tried multiple attempts. e.g. if the promotion is from
qi to si, and the target doesn't have this, it should try hi -> si.

But I'm leaving that for now.

gcc/ChangeLog:

PR middle-end/122069
* doc/md.texi (widen_ssum@var{n}@var{m}3, widen_usum@var{n}@var{m}3):
Update docs.
* optabs.cc (expand_widen_pattern_expr): Add WIDEN_SUM_EXPR as widening.
* optabs.def (ssum_widen_optab, usum_widen_optab): Convert from direct
to a conversion optab.
* tree-vect-patterns.cc (vect_recog_widen_sum_pattern): Change
vect_supportable_direct_optab_p into vect_supportable_conv_optab_p.

13 hours agofortran: allow character in conditional expression
Yuao Ma [Thu, 16 Oct 2025 14:32:52 +0000 (22:32 +0800)] 
fortran: allow character in conditional expression

This patch allows the use of character types in conditional expressions.

gcc/fortran/ChangeLog:

* resolve.cc (resolve_conditional): Allow character in cond-expr.
* trans-const.cc (gfc_conv_constant): Handle want_pointer.
* trans-expr.cc (gfc_conv_conditional_expr): Fill se->string_length.
(gfc_conv_string_parameter): Handle COND_EXPR tree code.

gcc/testsuite/ChangeLog:

* gfortran.dg/conditional_1.f90: Test character type.
* gfortran.dg/conditional_2.f90: Test print constants.
* gfortran.dg/conditional_4.f90: Test diagnostic message.
* gfortran.dg/conditional_6.f90: Test character cond-arg.

19 hours agotree-object-size.cc: Fix assert constant offset in check_for_plus_in_loops [PR122012]
Linsen Zhou [Fri, 17 Oct 2025 03:05:04 +0000 (11:05 +0800)] 
tree-object-size.cc: Fix assert constant offset in check_for_plus_in_loops [PR122012]

After commit 51b85dfeb19652bf3e0aaec08828ba7cee1e641c, when the
pointer offset is a variable in the loop, the object size of the
pointer may also need to be reexamined.
Which make gcc_assert in the check_for_plus_in_loops failed.

gcc/ChangeLog:

PR tree-optimization/122012
* tree-object-size.cc (check_for_plus_in_loops): Skip check
for the variable offset

gcc/testsuite/ChangeLog:

PR tree-optimization/122012
* gcc.dg/torture/pr122012.c: New test.

Signed-off-by: Linsen Zhou <i@lin.moe>
20 hours agoDaily bump.
GCC Administrator [Sat, 18 Oct 2025 00:18:06 +0000 (00:18 +0000)] 
Daily bump.

29 hours agobpf: fix memset miscompilation with larger stores [PR122139]
David Faust [Wed, 15 Oct 2025 20:36:38 +0000 (13:36 -0700)] 
bpf: fix memset miscompilation with larger stores [PR122139]

The BPF backend expansion of setmem was broken, because it could elect
to use stores of HI, SI or DI modes based on the destination alignment
when the value was QI, but fail to duplicate the byte value across to
those larger sizes.  This resulted in not all bytes of the destination
actually being set to the desired value.

Fix bpf_expand_setmem to ensure the desired byte value is really
duplicated as necessary, whether it is constant or a (sub)reg:QI.

PR target/122139

gcc/

* config/bpf/bpf.cc (bpf_expand_setmem): Duplicate byte value
across to new mode when using larger modes for store.

gcc/testsuite/

* gcc.target/bpf/memset-3.c: New.
* gcc.target/bpf/memset-4.c: New.

30 hours agoAArch64: Extend intrinsics framework to account for merging predications without...
Tamar Christina [Fri, 17 Oct 2025 14:43:04 +0000 (15:43 +0100)] 
AArch64: Extend intrinsics framework to account for merging predications without gp [PR121604]

In PR121604 the problem was noted that currently the SVE intrinsics
infrastructure assumes that for any predicated operation that the GP is at the
first argument position which has a svbool_t or for a unary merging operation
that it's in the second position.

However you have intrinsics like fmov_lane which have an svbool_t but it's not
a GP but instead it's the inactive lanes.

You also have instructions like BRKB which work only on predicates so it
incorrectly determines the first operand to be the GP, while that's also the
inactive lanes.

However during apply_predication we do have the information about where the GP
is.  This patch re-organizes the code to record this information into the
function_instance such that folders have access to this information.

For functions that are outliers like pmov_lane we can now override the
availability of the intrinsics having a GP.

gcc/ChangeLog:

PR target/121604
* config/aarch64/aarch64-sve-builtins-shapes.cc (apply_predication):
Store gp_index.
(struct pmov_to_vector_lane_def): Mark instruction as has no GP.
* config/aarch64/aarch64-sve-builtins.h (function_instance::gp_value,
function_instance::inactive_values, function_instance::gp_index,
function_shape::has_gp_argument_p): New.
* config/aarch64/aarch64-sve-builtins.cc (gimple_folder::fold_pfalse):
Simplify code and use GP helpers.

gcc/testsuite/ChangeLog:

PR target/121604
* gcc.target/aarch64/sve/pr121604_brk.c: New test.
* gcc.target/aarch64/sve2/pr121604_pmov.c: New test.

Co-authored-by: Jennifer Schmitz <jschmitz@nvidia.com>
31 hours agotree-optimization/122308 - apply LIM after unroll-and-jam
Richard Biener [Fri, 17 Oct 2025 13:12:11 +0000 (15:12 +0200)] 
tree-optimization/122308 - apply LIM after unroll-and-jam

Just like with loop interchange, unroll-and-jam can leave invariant
stmts in the inner loop from outer loop stmts inbetween the two
inner loop copies.  Do a per-function invariant motion when we
applied unroll-and-jam.  This avoids failed dataref analysis
and fallback to gather/scatter during vectorization.

PR tree-optimization/122308
* gimple-loop-jam.cc (tree_loop_unroll_and_jam): Do LIM
after applying unroll-and-jam.

* gcc.dg/vect/vect-pr122308.c: New testcase.

35 hours agoipa, cgraph: Enable constant propagation to OpenMP kernels.
Josef Melcr [Thu, 16 Oct 2025 14:25:29 +0000 (16:25 +0200)] 
ipa, cgraph: Enable constant propagation to OpenMP kernels.

This patch enables constant propagation to outlined OpenMP kernels.
It does so using a new function attribute called ' callback' (note the
space).

The attribute ' callback' captures the notion of a function calling one
of its arguments with some of its parameters as arguments.  An OpenMP
example of such function is GOMP_parallel.
We implement the attribute with new callgraph edges called callback
edges. They are imaginary edges pointing from the caller of the function
with the attribute (e.g. caller of GOMP_parallel) to the body function
itself (e.g. the outlined OpenMP body).  They share their call statement
with the edge from which they are derived (direct edge caller -> GOMP_parallel
in this case).  These edges allow passes such as ipa-cp to see the hidden
call site to the body function and optimize the function accordingly.

To illustrate on an example, the body GOMP_parallel looks something
like this:

void GOMP_parallel (void (*fn) (void *), void *data, /* ... */)
{
  /* ... */
  fn (data);
  /* ... */
}

If we extend it with the attribute ' callback(1, 2)', we express that the
function calls its first argument and passes it its second argument.
This is represented in the call graph in this manner:

             direct                         indirect
caller -----------------> GOMP_parallel ---------------> fn
  |
  ----------------------> fn
          callback

The direct edge is then the callback-carrying edge, all new edges
are the derived callback edges.
While constant propagation is the main focus of this patch, callback
edges can be useful for different passes (for example, they improve icf
for OpenMP kernels), as they allow for address redirection.
If the outlined body function gets optimized and cloned, from body_fn to
body_fn.optimized, the callback edge allows us to replace the
address in the arguments list:

GOMP_parallel (body_fn, &data_struct, /* ... */);

becomes

GOMP_parallel (body_fn.optimized, &data_struct, /* ... */);

This redirection is possible for any function with the attribute.

This callback attribute implementation is partially compatible with
clang's implementation. Its semantics, arguments and argument indexing style are
the same, but we represent an unknown argument position with 0
(precedent set by attributes such as 'format'), while clang uses -1 or '?'.
We use the index 1 for the 'this' pointer in member functions, clang
uses 0. We also allow for multiple callback attributes on the same function,
while clang only allows one.

The attribute is currently for GCC internal use only, thanks to the
space in its name.  Originally, it was supposed to be called
'callback' like its clang counterpart, but we cannot use this name, as
clang uses non-standard indexing style, leading to inconsistencies.  The
attribute will be introduced into the public API as 'gnu::callback_only'
in a future patch.

The attribute allows us to propagate constants into body functions of
OpenMP constructs. Currently, GCC won't propagate the value 'c' into the
OpenMP body in the following example:

int a[100];
void test(int c) {
#pragma omp parallel for
  for (int i = 0; i < c; i++) {
    if (!__builtin_constant_p(c)) {
      __builtin_abort();
    }
    a[i] = i;
  }
}
int main() {
  test(100);
  return a[5] - 5;
}

With this patch, the body function will get cloned and the constant 'c'
will get propagated.

Some functions may utilize the attribute's infrastructure without being
declared with it, for example GOMP_task.  These functions are special
cases and use the special case functions found in attr-callback.h.  Special
cases use the attribute under certain circumstances, for example
GOMP_task uses it when the copy function is not being used required.

gcc/ChangeLog:

* Makefile.in: Add attr-callback.o to OBJS.
* builtin-attrs.def (ATTR_CALLBACK): Callback attr identifier.
(DEF_CALLBACK_ATTRIBUTE): Macro for callback attr creation.
(GOMP): Attr for libgomp functions.
(ATTR_CALLBACK_GOMP_LIST): ATTR_NOTHROW_LIST with GOMP callback
attr added.
* cgraph.cc (cgraph_add_edge_to_call_site_hash): Always hash the
callback-carrying edge.
(cgraph_node::get_edge): Always return the callback-carrying
edge.
(cgraph_edge::set_call_stmt): Add cascade for callback edges.
(symbol_table::create_edge): Allow callback edges to share call
stmts, initialize new flags.
(cgraph_edge::make_callback): New method, derives a new callback
edge.
(cgraph_edge::get_callback_carrying_edge): New method.
(cgraph_edge::first_callback_edge): Likewise.
(cgraph_edge::next_callback_edge): Likewise.
(cgraph_edge::purge_callback_edges): Likewise.
(cgraph_edge::redirect_callee): When redirecting a callback
edge, redirect its ref as well.
(cgraph_edge::redirect_call_stmt_to_callee): Add callback edge
redirection logic, set update_derived_edges to true hwne
redirecting the carrying edge.
(cgraph_node::remove_callers): Add cascade for callback edges.
(cgraph_edge::dump_edge_flags): Print callback flags.
(cgraph_node::verify_node): Add sanity checks for callback
edges.
* cgraph.h: Add new 1 bit flags and 16 bit callback_id to
cgraph_edge class.
* cgraphclones.cc (cgraph_edge::clone): Copy over callback data.
* cif-code.def (CALLBACK_EDGE): Add CIF_CALLBACK_EDGE code.
* ipa-cp.cc (purge_useless_callback_edges): New function,
deletes callback edges when necessary.
(ipcp_decision_stage): Call purge_useless_callback_edges.
* ipa-fnsummary.cc (ipa_call_summary_t::duplicate): Add
an exception for callback edges.
(analyze_function_body): Copy over summary from carrying to
callback edge.
* ipa-inline-analysis.cc (do_estimate_growth_1): Skip callback
edges when estimating growth.
* ipa-inline-transform.cc (inline_transform): Add redirection
cascade for callback edges.
* ipa-param-manipulation.cc
(drop_decl_attribute_if_params_changed_p): New function.
(ipa_param_adjustments::build_new_function_type): Add
args_modified out param.
(ipa_param_adjustments::adjust_decl): Drop callback attrs when
modifying args.
* ipa-param-manipulation.h: Adjust decl of
build_new_function_type.
* ipa-prop.cc (ipa_duplicate_jump_function): Add decl.
(init_callback_edge_summary): New function.
(ipa_compute_jump_functions_for_edge): Add callback edge
creation logic.
* lto-cgraph.cc (lto_output_edge): Stream out callback data.
(input_edge): Input callback data.
* omp-builtins.def (BUILT_IN_GOMP_PARALLEL_LOOP_STATIC): Use new
attr list.
(BUILT_IN_GOMP_PARALLEL_LOOP_GUIDED): Likewise.
(BUILT_IN_GOMP_PARALLEL_LOOP_NONMONOTONIC_DYNAMIC): Likewise.
(BUILT_IN_GOMP_PARALLEL_LOOP_NONMONOTONIC_RUNTIME): Likewise.
(BUILT_IN_GOMP_PARALLEL): Likewise.
(BUILT_IN_GOMP_PARALLEL_SECTIONS): Likewise.
(BUILT_IN_GOMP_TEAMS_REG): Likewise.
* tree-core.h (ECF_CB_1_2): New constant for callback(1,2).
* tree-inline.cc (copy_bb): Copy callback edges when copying the
carrying edge.
(redirect_all_calls): Redirect callback edges.
* tree.cc (set_call_expr_flags): Create callback attr according
to the ECF_CB flag.
* attr-callback.cc: New file.
* attr-callback.h: New file.

gcc/c-family/ChangeLog:

* c-attribs.cc: Define callback attr.

gcc/fortran/ChangeLog:

* f95-lang.cc (ATTR_CALLBACK_GOMP_LIST): New attr list
corresponding to the list in builtin-attrs.def.

gcc/testsuite/ChangeLog:

* gcc.dg/ipa/ipcp-cb-spec1.c: New test.
* gcc.dg/ipa/ipcp-cb-spec2.c: New test.
* gcc.dg/ipa/ipcp-cb1.c: New test.

Signed-off-by: Josef Melcr <jmelcr02@gmail.com>
36 hours agoFix missing style violation report for package instantiation
Eric Botcazou [Fri, 17 Oct 2025 09:02:28 +0000 (11:02 +0200)] 
Fix missing style violation report for package instantiation

Unlike for subprogram instantiation, -gnatyr does not report style violation
for package instantiation, more precisely for the generic package's name.

Fixing it uncovered style violations in the sources of the compiler itself!

gcc/ada/
PR ada/122295
* sem_ch12.adb (Analyze_Package_Instantiation): Force Style_Check
to False only after possibly installing the parent.
* aspects.adb (UAD_Pragma_Map): Fix style violation.
* inline.adb (To_Pending_Instantiations): Likewise.
* lib.ads (Unit_Names): Likewise.
* repinfo.adb (Relevant_Entities): Likewise.
* sem_ch7.adb (Subprogram_Table): Likewise.
(Traversed_Table): Likewise.
* sem_util.adb (Interval_Sorting): Likewise.

gcc/testsuite/
* gnat.dg/specs/style1.ads: New test.

36 hours agolibstdc++: Fix typo in in __atomic_ref_base::_S_required_alignment.
Tomasz Kamiński [Fri, 17 Oct 2025 08:24:09 +0000 (10:24 +0200)] 
libstdc++: Fix typo in in __atomic_ref_base::_S_required_alignment.

libstdc++-v3/ChangeLog:

* include/bits/atomic_base.h
(__atomic_ref_base::_S_required_alignment): Renamed from...
(__atomic_ref_base::_S_required_aligment): Renamed.

36 hours agotree-optimization/122301 - fix ICE and improve vectorization of min/max reduction
Richard Biener [Fri, 17 Oct 2025 07:26:25 +0000 (09:26 +0200)] 
tree-optimization/122301 - fix ICE and improve vectorization of min/max reduction

The following fixes another issue with updating of reduc_idx in pattern
sequences.  But the testcase also shows the pattern in question is
harmful for vectorization since a reduction path may not contain
promotions/demotions.  So the already existing but ineffective check
to guard the pattern is fixed.

PR tree-optimization/122301
* tree-vect-patterns.cc (vect_recog_over_widening_pattern):
Fix reduction guard.
(vect_mark_pattern_stmts): Fix reduction def check.

* gcc.dg/vect/vect-pr122301.c: New testcase.

37 hours agovect: Add pattern recognition for vectorizing {FLOOR,CEIL,ROUND}_{MOD, DIV}_EXPR
Avinash Jayakar [Fri, 17 Oct 2025 07:08:59 +0000 (12:38 +0530)] 
vect: Add pattern recognition for vectorizing {FLOOR,CEIL,ROUND}_{MOD, DIV}_EXPR

Added a new helper function "add_code_for_floorceilround_divmod" in
tree-vect-patterns.cc for adding compensating code for each of the op
{FLOOR,ROUND,CEIL}_{DIV,MOD}_EXPR. This function checks if target supports all
required operations required to implement these operation and generates
vectorized code for the respective operations. Based on the following logic
FLOOR_{DIV,MOD}
r = x %[fl] y;
r = x % y; if (r && (x ^ y) < 0) r += y;
r = x/[fl] y;
r = x % y; d = x/y; if (r && (x ^ y) < 0) d--;
CEIL_{DIV,MOD} (unsigned)
r = x %[cl] y;
r = x % y; if (r) r -= y;
r = x/[cl] y;
r = x % y; d = x/y; if (r) d++;
CEIL_{DIV,MOD} (signed)
r = x %[cl] y;
r = x % y; if (r && (x ^ y) >= 0) r -= y;
r = x/[cl] y;
r = x % y; d = x/y; if (r && (x ^ y) >= 0) d++;
ROUND_{DIV,MOD} (unsigned)
r = x %[rd] y;
r = x % y; if (r > ((y-1)/2)) r -= y;
r = x/[rd] y;
r = x % y; d = x/y; if (r > ((y-1)/2)) d++;
ROUND_{DIV,MOD} (signed)
r = x %[rd] y;
r = x % y; if (r > ((y-1)/2))
{if ((x ^ y) >= 0) r -= y; else r += y;}
r = x/[rd] y;
r = x % y; d = x/y; if ((r > ((y-1)/2)) && (x ^ y) >= 0)
{if ((x ^ y) >= 0) d++; else d--;}
each of the case is implemented in a vectorized form.
This function is then called in each of the path in vect_recog_divmod_pattern,
which there are 3, based on value of constant operand1,
1. == 2
2. == power of 2
3. otherwise

2025-10-17  Avinash Jayakar  <avinashd@linux.ibm.com>

gcc/ChangeLog:
PR tree-optimization/104116
* tree-vect-patterns.cc (add_code_for_floorceilround_divmod): patt recog
for {FLOOR,ROUND,CEIL}_{DIV,MOD}_EXPR.
(vect_recog_divmod_pattern): Call add_code_for_floorceilround_divmod
after computing div/mod for each control path.

gcc/testsuite/ChangeLog:
PR tree-optimization/104116
* gcc.dg/vect/pr104116-ceil-div-2.c: New test.
* gcc.dg/vect/pr104116-ceil-div-pow2.c: New test.
* gcc.dg/vect/pr104116-ceil-div.c: New test.
* gcc.dg/vect/pr104116-ceil-mod-2.c: New test.
* gcc.dg/vect/pr104116-ceil-mod-pow2.c: New test.
* gcc.dg/vect/pr104116-ceil-mod.c: New test.
* gcc.dg/vect/pr104116-ceil-udiv-2.c: New test.
* gcc.dg/vect/pr104116-ceil-udiv-pow2.c: New test.
* gcc.dg/vect/pr104116-ceil-udiv.c: New test.
* gcc.dg/vect/pr104116-ceil-umod-2.c: New test.
* gcc.dg/vect/pr104116-ceil-umod-pow2.c: New test.
* gcc.dg/vect/pr104116-ceil-umod.c: New test.
* gcc.dg/vect/pr104116-floor-div-2.c: New test.
* gcc.dg/vect/pr104116-floor-div-pow2.c: New test.
* gcc.dg/vect/pr104116-floor-div.c: New test.
* gcc.dg/vect/pr104116-floor-mod-2.c: New test.
* gcc.dg/vect/pr104116-floor-mod-pow2.c: New test.
* gcc.dg/vect/pr104116-floor-mod.c: New test.
* gcc.dg/vect/pr104116-round-div-2.c: New test.
* gcc.dg/vect/pr104116-round-div-pow2.c: New test.
* gcc.dg/vect/pr104116-round-div.c: New test.
* gcc.dg/vect/pr104116-round-mod-2.c: New test.
* gcc.dg/vect/pr104116-round-mod-pow2.c: New test.
* gcc.dg/vect/pr104116-round-mod.c: New test.
* gcc.dg/vect/pr104116-round-udiv-2.c: New test.
* gcc.dg/vect/pr104116-round-udiv-pow2.c: New test.
* gcc.dg/vect/pr104116-round-udiv.c: New test.
* gcc.dg/vect/pr104116-round-umod-2.c: New test.
* gcc.dg/vect/pr104116-round-umod-pow2.c: New test.
* gcc.dg/vect/pr104116-round-umod.c: New test.
* gcc.dg/vect/pr104116.h: New test.

40 hours agomatch: Fix (a != b) | ((a|b) != 0) and (a == b) & ((a|b) == 0) match pattern [PR122296]
Andrew Pinski [Fri, 17 Oct 2025 00:02:52 +0000 (17:02 -0700)] 
match: Fix (a != b) | ((a|b) != 0) and (a == b) & ((a|b) == 0) match pattern [PR122296]

There are 2 fixes for these 2 patterns.
1) Reuse the (a|b) expression instead of recreating it
   Fixed by capturing the bit_ior expression and using that instead
   of a new expression.
2) Use the correct 0. Fixed by capturing the integer_zerop and using that
   instead of integer_zero_node.

2) could be fuxed by using `build_cst_zero (TREE_TYPE (@0))` But since
we already have the correct 0, capturing it would be faster.

Pushed as obvious after a bootstrap/test on x86_64-linux-gnu.

PR tree-optimization/122296

gcc/ChangeLog:

* match.pd (`(a != b) | ((a|b) != 0)`): Reuse both
the ior and zero instead of recreating them.
(`(a == b) & ((a|b) == 0)`): Likewise

gcc/testsuite/ChangeLog:

* gcc.dg/torture/int-bwise-opt-1.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
40 hours agomatch: Fix `(a == b) | ((a|b) != 0)` pattern for vectors [PR122296]
Andrew Pinski [Thu, 16 Oct 2025 23:10:59 +0000 (16:10 -0700)] 
match: Fix `(a == b) | ((a|b) != 0)` pattern for vectors [PR122296]

The pattern `(a == b) | ((a|b) != 0)` uses build_one_cst to build boolean true
but boolean can be a signed multi-bit type. So this changes the result to
use constant_boolean_node isntead.
`(a != b) & ((a|b) == 0)` has a similar issue but in that case it is less likely
to be an issue as false is almost always just 0 but this changes it to be consistent.

Pushed as obvious after a bootstrap/test on x86_64-linux-gnu.

PR tree-optimization/122296

gcc/ChangeLog:

* match.pd (`(a == b) | ((a|b) != 0)`): Fix true value.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/int-bwise-opt-vect01.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
41 hours agox86: Cast stride to __PTRDIFF_TYPE__ for AMX-MOVRS intrinsics. [PR122119]
Hu, Lin1 [Fri, 10 Oct 2025 06:30:19 +0000 (14:30 +0800)] 
x86: Cast stride to __PTRDIFF_TYPE__ for AMX-MOVRS intrinsics. [PR122119]

On 64-bit windows, long can't be used, because it is 32 bits. Use
__PTRDIFF_TYPE__ instead of long.

gcc/ChangeLog:

PR target/122119
* config/i386/amxmovrsintrin.h
(_tile_loaddrs_internal): Use __PTRDIFF_TYPE__ instead of long.
(_tile_loaddrst1_internal): Ditto.

44 hours agoDaily bump.
GCC Administrator [Fri, 17 Oct 2025 00:18:48 +0000 (00:18 +0000)] 
Daily bump.

47 hours agodiagnostics: generalize state graph code to use json::property instances (v2)
David Malcolm [Thu, 16 Oct 2025 21:39:03 +0000 (17:39 -0400)] 
diagnostics: generalize state graph code to use json::property instances (v2)

In r16-1631-g2334d30cd8feac I added support for capturing state
information from -fanalyzer in the form of embedded XML strings
in SARIF output.

In r16-2211-ga5d9debedd2f46 I rewrote this so the state was captured in
the form of a SARIF directed graph, using various custom types.

I want to add the ability to capture other kinds of graph in our SARIF
output (e.g. inheritance hierarchies, CFGs, etc), so  the following patch
reworks the state graph handling code to minimize the use of custom types.
Instead, the patch introduces various json::property types, and
describes the state graph serialization in terms of instances of these
properties, rather than hardcoding string attribute names in readers and
writers.  The custom SARIF properties live in a new
"gcc/custom-sarif-properties/" directory.

The "experimental-html" scheme keys "show-state-diagrams-dot-src" and
"show-state-diagrams-sarif" become "show-graph-dot-src" and
"show-graph-dot-src" in preparation for new kinds of graph in the output.

This is an updated version of the patch, tested to build with GCC 5
(which the previous version didn't leading to PR bootstrap/122151)

contrib/ChangeLog:
* gcc.doxy (INPUT): Add gcc/custom-sarif-properties

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Add
custom-sarif-properties/digraphs.o and
custom-sarif-properties/state-graphs.o.  Remove
diagnostics/state-graphs.o.
* configure: Regenerate.
* configure.ac: Add custom-sarif-properties to subdir iteration.
* custom-sarif-properties/digraphs.cc: New file.
* custom-sarif-properties/digraphs.h: New file.
* custom-sarif-properties/state-graphs.cc: New file.
* custom-sarif-properties/state-graphs.h: New file.
* diagnostics/diagnostics-selftests.cc
(run_diagnostics_selftests): Drop call of state_graphs_cc_tests.
* diagnostics/diagnostics-selftests.h (state_graphs_cc_tests):
Delete decl.
* diagnostics/digraphs.cc: Include
"custom-sarif-properties/digraphs.h".  Move include of
"selftest.h" to within CHECKING_P section.
(using digraph_object): New.
(namespace properties): New.
(diagnostics::digraphs::object::get_attr): Delete.
(diagnostics::digraphs::object::set_attr): Delete.
(diagnostics::digraphs::object::set_json_attr): Delete.
(digraph_object::get_property): New definitions, for various
property types.
(digraph_object::set_property): Likewise.
(digraph_object::maybe_get_property): New.
(digraph_object::get_property_as_tristate): New.
(digraph_object::ensure_property_bag): New.
(digraph::get_graph_kind): New.
(digraph::set_graph_kind): New.
Add include of "custom-sarif-properties/state-graphs.h".
(selftest::test_simple_graph): Rewrite to use json::property
instances rather than string attribute names.
(selftest::test_property_objects): New test.
(selftest::digraphs_cc_tests): Call it.
* diagnostics/digraphs.h: Include "tristate.h".
(object::get_attr): Delete.
(object::set_attr): Delete.
(object::get_property): New decls.
(object::set_property): New decls.
(object::maybe_get_property): New.
(object::get_property_as_tristate): New.
(object::set_json_attr): Delete.
(object::ensure_property_bag): New.
(graph::get_graph_kind): New.
(graph::set_graph_kind): New.
* diagnostics/html-sink.cc
(html_generation_options::html_generation_options): Update for
field renamings.
(html_generation_options::dump): Likewise.
(html_builder::maybe_make_state_diagram): Likewise.
(html_builder::add_graph): Show SARIF and .dot src inline, if
requested.
* diagnostics/html-sink.h
(html_generation_options::m_show_state_diagrams_sarif): Rename
to...
(html_generation_options::m_show_graph_sarif): ...this.
(html_generation_options::m_show_state_diagrams_dot_src): Rename
to...
(html_generation_options::m_show_graph_dot_src0): ...this.
* diagnostics/output-spec.cc
(html_scheme_handler::maybe_handle_kv): Rename keys.
(html_scheme_handler::get_keys): Likewise.
* diagnostics/state-graphs-to-dot.cc: : Reimplement throughout to
use json::property instances found within custom_sarif_properties
throughout, rather than types in diagnostics::state_graphs.
* diagnostics/state-graphs.cc: Deleted file.
* diagnostics/state-graphs.h: Delete almost all, except decl of
diagnostics::state_graphs::make_dot_graph.
* doc/invoke.texi: Update for changes to "experimental-html" sink
keys.
* json.cc (json::object::set_string): New.
(json::object::set_integer): New.
(json::object::set_bool): New.
(json::object::set_array_of_string): New.
* json.h: Include "label-text.h".
(struct json::property): New template.
(json::string_property): New.
(json::integer_property): New.
(json::bool_property): New.
(json::json_property): New.
(using json::array_of_string_property): New.
(struct json::enum_traits): New.
(enum_json::property): New.
(json::value::dyn_cast_array): New vfunc.
(json::value::dyn_cast_integer_number): New vfunc.
(json::value::set_string): New.
(json::value::set_integer): New.
(json::value::set_bool): New.
(json::value::set_array_of_string): New.
(json::value::maybe_get_enum): New.
(json::value::set_enum): New.
(json::array::dyn_cast_array): New.
(json::integer_number::dyn_cast_integer_number): New.
(object::maybe_get_enum): New.
(object::set_enum): New.

gcc/analyzer/ChangeLog:
* ana-state-to-diagnostic-state.cc: Reimplement throughout to use
json::property instances found within custom_sarif_properties
throughout, rather than types in diagnostics::state_graphs.
* ana-state-to-diagnostic-state.h: Likewise.
* checker-event.cc: Likewise.
* sm-malloc.cc: Likewise.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_test_graphs.cc
(report_diag_with_graphs): Port from set_attr to set_property.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 days agodwarf: add wiki link for DWARF GNU_annotation extensions
David Faust [Thu, 16 Oct 2025 17:39:31 +0000 (10:39 -0700)] 
dwarf: add wiki link for DWARF GNU_annotation extensions

include/

* dwarf2.def (DW_TAG_GNU_annotation): Add link to wiki page
documenting the extension.
(DW_AT_GNU_annotation): Likewise.

2 days agolibstdc++: Improve ostream output for std::stacktrace
Jonathan Wakely [Wed, 15 Oct 2025 19:10:34 +0000 (20:10 +0100)] 
libstdc++: Improve ostream output for std::stacktrace

With this change stacktrace entries always output the frame address, and
source file information no longer results in " at :0", e.g.

  16#  myfunc(int) at /tmp/bt.cc:48 [0x4008b7]
  17#  main at /tmp/bt.cc:61 [0x40091a]
  18#  __libc_start_call_main [0x7efc3d6d3574]
  19#  __libc_start_main@GLIBC_2.2.5 [0x7efc3d6d3627]
  20#  _start [0x400684]

This replaces the previous output:

  16# myfunc(int) at /tmp/bt.cc:48
  17# main at /tmp/bt.cc:61
  18# __libc_start_call_main at :0
  19# __libc_start_main@GLIBC_2.2.5 at :0
  20# _start at :0

A change that is not visible in the examples above is that for a
non-empty stacktrace_entry, we now print "<unknown>" for the function
name if description() returns an empty string.  For an empty (e.g.
default constructed) stacktrace_entry the entire string representation
is now "<unknown>" instead of an empty string.

Instead of printing "<unknown>" for the function name, we could set that
string in the stacktrace_entry::_Info object, so that description()
returns "<unknown>" and then operator<< wouldn't need to handle an empty
description() string. However, returning an empty string from that
function seems simpler for users to detect, rather than having to parse
"<unknown>".

We could also choose a different string for an empty stacktrace_entry,
maybe "<none>" or "<invalid>", but "<unknown>" seems good.

libstdc++-v3/ChangeLog:

* include/std/stacktrace
(operator<<(ostream&, const stacktrace_entry&)): Improve output
when description() or source_file() returns an empty string,
or the stacktrace_entry is invalid. Append frame address to
output.
(operator<<(ostream&, const basic_stacktrace<A>&)): Use the
size_type of the correct specialization.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Nathan Myers <nmyers@redhat.com>
2 days agoError out stack-protector unavailability on AIX
Ayappan Perumal [Mon, 1 Sep 2025 13:27:52 +0000 (08:27 -0500)] 
Error out stack-protector unavailability on AIX

stack-protector is not supported in GCC on AIX. This patch is to fail the
compilation if -fstack-protector option is passed.

gcc/ChangeLog:

* config/rs6000/aix.h (SUBTARGET_DRIVER_SELF_SPECS):
Error out when stack-protector option is used in AIX
as it is not supported on AIX

Approved By: Segher Boessenkool <segher@kernel.crashing.org>

2 days agolibgomp.c/declare-variant-4-gfx*: Add missing archs + dg-excess-errors
Tobias Burnus [Thu, 16 Oct 2025 09:11:39 +0000 (11:11 +0200)] 
libgomp.c/declare-variant-4-gfx*: Add missing archs + dg-excess-errors

Add missing tests for gfx* context selectors; mark all but the
default-arch declare-variant-4.c with 'dg-excess-errors' to
silence libgomp not-found errors (still passing the
scan-offload-tree-dump check) - or at least causing just
UNRESOLVED errors if the error is
  "built without library support ... consider compiling for
   the associated generic architecture".

In case the multilib is configured, the result will be
an XPASS.

libgomp/ChangeLog:

* testsuite/libgomp.c/declare-variant-4-gfx10-3-generic.c: Add
dg-excess-errors to handle possible missing libgomp multi lib.
* testsuite/libgomp.c/declare-variant-4-gfx1030.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx1036.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx11-generic.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx1100.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx1103.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx9-4-generic.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx9-generic.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx900.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx906.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx908.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx90a.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx90c.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx942.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx1031.c: New test.
* testsuite/libgomp.c/declare-variant-4-gfx1032.c: New test.
* testsuite/libgomp.c/declare-variant-4-gfx1033.c: New test.
* testsuite/libgomp.c/declare-variant-4-gfx1034.c: New test.
* testsuite/libgomp.c/declare-variant-4-gfx1035.c: New test.
* testsuite/libgomp.c/declare-variant-4-gfx1101.c: New test.
* testsuite/libgomp.c/declare-variant-4-gfx1102.c: New test.
* testsuite/libgomp.c/declare-variant-4-gfx1150.c: New test.
* testsuite/libgomp.c/declare-variant-4-gfx1151.c: New test.
* testsuite/libgomp.c/declare-variant-4-gfx1152.c: New test.
* testsuite/libgomp.c/declare-variant-4-gfx1153.c: New test.
* testsuite/libgomp.c/declare-variant-4-gfx902.c: New test.
* testsuite/libgomp.c/declare-variant-4-gfx904.c: New test.
* testsuite/libgomp.c/declare-variant-4-gfx909.c: New test.
* testsuite/libgomp.c/declare-variant-4-gfx950.c: New test.

2 days agotree-optimization/122292 - fix reduction code gen issue
Richard Biener [Wed, 15 Oct 2025 14:15:50 +0000 (16:15 +0200)] 
tree-optimization/122292 - fix reduction code gen issue

The following fixes a mixup of vector types checked when looking
at a conditional reduction operation.  We want the actual data
vector input type, so look at the SLP trees type instead and
special-case lane-reducing ops like the original code did.

PR tree-optimization/122292
* tree-vect-loop.cc (vect_transform_reduction): Compute the
input vector type the same way the analysis phase does.

2 days agoDaily bump.
GCC Administrator [Thu, 16 Oct 2025 00:21:56 +0000 (00:21 +0000)] 
Daily bump.

2 days agoRange snap bitmasks as they are set.
Andrew MacLeod [Tue, 7 Oct 2025 15:56:08 +0000 (11:56 -0400)] 
Range snap bitmasks as they are set.

Range bounds adjustments based on a bitmask were lazily set.  This lead
to some inconsitencies which were causing problems. Improve the bounds,
and do it every time the bitmask is adjusted.

PR tree-optimization/121468
PR tree-optimization/121206
PR tree-optimization/122200
gcc/
* value-range.cc (irange_bitmask::range_from_mask): New.
(irange::snap): Add explicit overflow flag.
(irange::snap_subranges): Use overflow flag.
(irange::set_range_from_bitmask): Use range_from_mask.
(test_irange_snap_bounds): Adjust for improved ranges.
* value-range.h (irange::range_from_mask): Add prototype.
(irange::snap): Adjust prototype.

gcc/testsuite/
* gcc.dg/pr121468.c: New.
* gcc.dg/pr122200.c: New.

3 days agolibstdc++: Add pretty printers for std::stacktrace
Jonathan Wakely [Wed, 15 Oct 2025 20:44:16 +0000 (21:44 +0100)] 
libstdc++: Add pretty printers for std::stacktrace

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py (StdStacktraceEntryPrinter):
New printer for std::stacktrace_entry.
(StdStacktracePrinter): New printer for std::basic_stacktrace.

3 days agolibstdc++: Remove invalid entry from the end of std::stacktrace
Jonathan Wakely [Wed, 15 Oct 2025 13:59:20 +0000 (14:59 +0100)] 
libstdc++: Remove invalid entry from the end of std::stacktrace

The backtrace_simple function seems to consistently invoke the callback
with an invalid -1UL value as the last entry, which seems to come from
_Unwind_Backtrace. The glibc backtrace(3) function has a special case to
not include that final invalid address, but libbacktrace doesn't seem to
handle it. Do so in std::stacktrace::current() instead.

libstdc++-v3/ChangeLog:

* include/std/stacktrace (basic_stacktrace::current): Call
_M_trim before returning.
(basic_stacktrace::_M_trim): New member function.

3 days agolibstdc++: Fix missing __to_timeout_timespec for targets using POSIX sleep [PR122293]
Jonathan Wakely [Wed, 15 Oct 2025 11:52:27 +0000 (12:52 +0100)] 
libstdc++: Fix missing __to_timeout_timespec for targets using POSIX sleep [PR122293]

The preprocessor condition for defining the new __to_timeout_timespec
function templates did not match all the conditions under which it's
needed.

std::this_thread::sleep_for is defined #if ! defined _GLIBCXX_NO_SLEEP
but it relies on __to_timeout_timespec which was only being defined for
targets that use nanosleep, or clock_gettime, or use gthreads.

For a non-gthreads target that uses POSIX sleep to implement
std::this_thread::sleep_for, the build fails with:

include/bits/this_thread_sleep.h:71:40: error: '__to_timeout_timespec' is not a member of 'std::chrono' [-Wtemplate-body]
   71 |         struct timespec __ts = chrono::__to_timeout_timespec(__rtime);
      |                                        ^~~~~~~~~~~~~~~~~~~~~

Presumably the same would happen for mingw-w64 if configured with
--disable-threads (as that would be a non-gthreads target that doesn't
use nanosleep or clock_gettime).

libstdc++-v3/ChangeLog:

PR libstdc++/122293
* include/bits/chrono.h (__to_timeout_timespec): Fix
preprocessor condition to match the conditions under which
callers of this function are defined.
* include/bits/this_thread_sleep.h: Remove unused include.

3 days ago[PATCH] Makefile.tpl: remove an extra \; from find command
Basil Milanich [Wed, 15 Oct 2025 17:31:09 +0000 (11:31 -0600)] 
[PATCH] Makefile.tpl: remove an extra \; from find command

The extra \; parameter in the find command causes it to fail immediately and
not clean any config.cache:

$ find . -name config.cache -exec rm -f {} \; \;
find: paths must precede expression: `;'

This is benign in most cases but the binutils is also using this Makefile.tpl and
as the result its 'make distclean' can leave config.cache files around, which
fails subsequent attempts to configure and build it.

I have modified the Makefile.tpl and regenerated Makefile.in from it. For testing
I ran a config/make/make distclean loop.

* Makefile.tpl (distclean): Remove extraenous semicolon.
* Makefile.in: Rebuilt.

3 days agogcn: Add missing GFX9_4_GENERIC, OpenMP context-selector update
Tobias Burnus [Wed, 15 Oct 2025 17:15:15 +0000 (19:15 +0200)] 
gcn: Add missing GFX9_4_GENERIC, OpenMP context-selector update

The definition for gfx942 and gfx950 missed the GFX9_4_GENERIC
family flag.

For OpenMP context selectors: The t-omp-device file missed the
generic selectors.

Additionally, there is now a note in the OpenMP documentation that
there is a one-to-one match for ISA names, ignoring any compatibility.
For instance, for Nvidia GPUs 'isa("sm_70")' is only true when compiling
for 'sm_70', even though sm < 7.0 code also runs on sm_70 hardware.
And, for AMD GPUs, gfx9-4-generic neither matches 'gfx942'
(even though such generic code runs on gfx942) - nor the reverse
(although all gfx9-4-generic code runs on gfx942).

gcc/ChangeLog:

* config/gcn/gcn-devices.def (gfx942, gfx950): Set generic name
to GFX9_4_GENERIC.
* config/gcn/t-omp-device: Include generic names for OpenMP's
ISA trait.

libgomp/ChangeLog:

* libgomp.texi (OpenMP Context Selectors): Add note that there is
currently an exact match between ISA and compilation, ignoring
compatibilities in both ways.
* testsuite/libgomp.c/declare-variant-4.h: Add missing variant
functions for specific and generic AMD GPUs.
* testsuite/libgomp.c/declare-variant-4-gfx10-3-generic.c: New test.
* testsuite/libgomp.c/declare-variant-4-gfx11-generic.c: New test.
* testsuite/libgomp.c/declare-variant-4-gfx9-4-generic.c: New test.
* testsuite/libgomp.c/declare-variant-4-gfx9-generic.c: New test.

3 days agodebug_tree: print out clique/base for MEM_REF/TARGET_MEM_REF
Andrew Pinski [Tue, 14 Oct 2025 17:36:03 +0000 (10:36 -0700)] 
debug_tree: print out clique/base for MEM_REF/TARGET_MEM_REF

While debugging PR 122273, I noticed that print_node was not
printing out the clique/base for MEM_REF/TARGET_MEM_REF. This
made harder to understand why operand_equal_p (without looking
into the code) would be rejecting two looking the same MEM_REFs.

Changes since v1:
* v2: Don't print out clique/base if clique is 0.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* print-tree.cc (print_node): Print out clique/base
for MEM_REF and TARGET_MEM_REF.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 days agoarm: avoid unmatched insn in movhfcc [PR118460]
Richard Earnshaw [Tue, 14 Oct 2025 12:53:05 +0000 (13:53 +0100)] 
arm: avoid unmatched insn in movhfcc [PR118460]

When compiling for m-profile with the floating-point extension we have
a vsel instruction that takes a limited set of comparisons.  In most
cases we can use this with careful selection of the operand order, but
we need to expand things in the right way.  This patch is in two parts:

1) We validate that the expansion will produce correct RTL;
2) We canonicalize the comparison to increase the chances that the
above check will pass.

gcc:

PR target/118460
* config/arm/arm.cc (arm_canonicalize_comparison): For floating-
point comparisons, swap the operand order if that will be more
likely to produce a comparison that can be used with VSEL.
(arm_validize_comparison): Make sure that HFmode comparisons
are compatible with VSEL.

gcc/testsuite:

PR target/118460
* gcc.target/arm/armv8_2-fp16-move-1.c: Adjust expected output.
* gcc.target/arm/armv8_2-fp16-move-2.c: Likewise.

3 days agodce: Remove __builtin_stack_save during dce [PR122037]
Andrew Pinski [Tue, 14 Oct 2025 16:13:51 +0000 (09:13 -0700)] 
dce: Remove __builtin_stack_save during dce [PR122037]

__builtin_stack_save can be removed when the lhs becomes unused
as it is just recording the current StackPointer into another register.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/122037

gcc/ChangeLog:

* tree-ssa-dce.cc (eliminate_unnecessary_stmts): Remove
__builtin_stack_save when the lhs is unused.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 days agolibstdc++: Enable features for RTEMS (based on GCC 15)
Chris Johns [Wed, 1 Oct 2025 18:51:05 +0000 (13:51 -0500)] 
libstdc++: Enable features for RTEMS (based on GCC 15)

libstdc++-v3/ChangeLog:

* configure: Regenerate.
* configure.ac (newlib, *-rtems*): Add HAVE_SYS_IOCTL_H,
HAVE_SYS_STAT_H, HAVE_SYS_TYPES_H, HAVE_S_ISREG, HAVE_UNISTD_H,
HAVE_UNLINKAT, _GLIBCXX_USE_CHMOD, _GLIBCXX_USE_MKDIR,
_GLIBCXX_USE_CHDIR, _GLIBCXX_USE_GETCWD, _GLIBCXX_USE_UTIME,
_GLIBCXX_USE_LINK, _GLIBCXX_USE_READLINK, _GLIBCXX_USE_SYMLINK,
_GLIBCXX_USE_TRUNCATE and _GLIBCXX_USE_FDOPENDIR.

3 days agoaarch64: Sync aarch64-sys-regs.def with Binutils
Alice Carlotti [Mon, 13 Oct 2025 16:52:02 +0000 (17:52 +0100)] 
aarch64: Sync aarch64-sys-regs.def with Binutils

This patch incorporates changes to this file in Binutils since March
2024 (excluding one patch that was already cherry-picked by
Ezra in July 2025).  It includes:
- New system registers in the 2024 and 2025 architecture extensions.
- Updated feature requirements for most system register accessors.
- Removal of registers that were dropped from the architecture.
- Removal of the unnecessary F_ARCHEXT flag.
- Fixed encoding for pmsdsfr_el1.

The updated architecture feature requirements are only relevant when the
new `-menable-sysreg-checking' option is enabled.

gcc/ChangeLog:

* config/aarch64/aarch64-sys-regs.def: Copy from Binutils.
* config/aarch64/aarch64.cc (F_ARCHEXT): Delete flag.
* config/aarch64/aarch64.h
(AARCH64_FL_AMU): Delete unused macro.
(AARCH64_FL_SCXTNUM): Ditto.
(AARCH64_FL_ID_PFR2): Ditto.
(AARCH64_FL_AIE): Ditto.
(AARCH64_FL_DEBUGv8p9): Ditto.
(AARCH64_FL_FGT2): Ditto.
(AARCH64_FL_PFAR): Ditto.
(AARCH64_FL_PMUv3_ICNTR): Ditto.
(AARCH64_FL_PMUv3_SS): Ditto.
(AARCH64_FL_PMUv3p9): Ditto.
(AARCH64_FL_S1PIE): Ditto.
(AARCH64_FL_S1POE): Ditto.
(AARCH64_FL_S2PIE): Ditto.
(AARCH64_FL_S2POE): Ditto.
(AARCH64_FL_SCTLR2): Ditto.
(AARCH64_FL_SEBEP): Ditto.
(AARCH64_FL_SPE_FDS): Ditto.
(AARCH64_FL_TCR2): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/acle/rwsr-armv8p9.c: Fix incorrect encoding.

3 days agotree-parloops: Enable runtime thread detection with -ftree-parallelize-loops
Sebastian Pop [Fri, 25 Jul 2025 15:55:03 +0000 (17:55 +0200)] 
tree-parloops: Enable runtime thread detection with -ftree-parallelize-loops

This patch adds runtime thread count detection to auto-parallelization.
-ftree-parallelize-loops option generates parallelized loops without
specifying a fixed thread count, deferring this decision to program execution
time where it is controlled by the OMP_NUM_THREADS environment variable.

Bootstrap and regression tested on aarch64-linux.  Compiled SPEC HPC pot3d
https://www.spec.org/hpc2021/docs/benchmarks/628.pot3d_s.html with
-ftree-parallelize-loops and tested without having OMP_NUM_THREADS set in the
environment and with OMP_NUM_THREADS set to different values.

gcc/ChangeLog:

* doc/invoke.texi (ftree-parallelize-loops): Update.
* common.opt (ftree-parallelize-loops): Add alias that maps to
special value INT_MAX for runtime thread detection.
* tree-parloops.cc (create_parallel_loop): Use INT_MAX for runtime
detection.  Call gimple_build_omp_parallel without building a
OMP_CLAUSE_NUM_THREADS clause.
(gen_parallel_loop): For auto-detection, use a conservative
estimate of 2 threads.
(parallelize_loops): Same.

gcc/testsuite/ChangeLog:

* gcc.dg/autopar/runtime-auto.c: New test.

Signed-off-by: Sebastian Pop <spop@nvidia.com>
3 days agoarm: [MVE] Fix carry-in support for vadcq / vsbcq [PR122189]
Christophe Lyon [Thu, 2 Oct 2025 13:52:22 +0000 (13:52 +0000)] 
arm: [MVE] Fix carry-in support for vadcq / vsbcq [PR122189]

The vadcq and vsbcq patterns had two problems:
- the adc / sbc part of the pattern did not mention the use of vfpcc
- the carry calcultation part should use a different unspec code

In addtion, the get_fpscr_nzcvqc and set_fpscr_nzcvqc were
over-cautious by using unspec_volatile when unspec is really what they
need.  Making them unspec enables to remove redundant accesses to
FPSCR_nzcvqc.

With unspec_volatile, we used to generate:
test_2:
@ args = 0, pretend = 0, frame = 8
@ frame_needed = 0, uses_anonymous_args = 0
vmov.i32 q0, #0x1  @ v4si
push {lr}
sub sp, sp, #12
vmrs r3, FPSCR_nzcvqc    ;; [1]
bic r3, r3, #536870912
vmsr FPSCR_nzcvqc, r3
vadc.i32 q3, q0, q0
vmrs r3, FPSCR_nzcvqc     ;; [2]
vmrs r3, FPSCR_nzcvqc
orr r3, r3, #536870912
vmsr FPSCR_nzcvqc, r3
vadc.i32 q0, q0, q0
vmrs r3, FPSCR_nzcvqc
ldr r0, .L8
ubfx r3, r3, #29, #1
str r3, [sp, #4]
bl print_uint32x4_t
add sp, sp, #12
@ sp needed
pop {pc}
.L9:
.align 2
.L8:
.word .LC1

with unspec, we generate:
test_2:
@ args = 0, pretend = 0, frame = 8
@ frame_needed = 0, uses_anonymous_args = 0
vmrs r3, FPSCR_nzcvqc     ;; [1]
bic r3, r3, #536870912   ;; [3]
vmov.i32 q0, #0x1  @ v4si
vmsr FPSCR_nzcvqc, r3
vadc.i32 q3, q0, q0
vmrs r3, FPSCR_nzcvqc
orr r3, r3, #536870912
vmsr FPSCR_nzcvqc, r3
vadc.i32 q0, q0, q0
vmrs r3, FPSCR_nzcvqc
push {lr}
ubfx r3, r3, #29, #1
sub sp, sp, #12
ldr r0, .L8
str r3, [sp, #4]
bl print_uint32x4_t
add sp, sp, #12
@ sp needed
pop {pc}
.L9:
.align 2
.L8:
.word .LC1

That is, unspec in get_fpscr_nzcvqc enables to:
- move [1] earlier
- delete redundant [2]

and unspec in set_fpscr_nzcvqc enables to move push {lr} and stack
manipulation later.

gcc/ChangeLog:

PR target/122189
* config/arm/iterators.md (VxCIQ_carry, VxCIQ_M_carry, VxCQ_carry)
(VxCQ_M_carry): New iterators.
* config/arm/mve.md (get_fpscr_nzcvqc, set_fpscr_nzcvqc): Use
unspec instead of unspec_volatile.
(vadciq, vadciq_m, vadcq, vadcq_m): Use vfpcc in operation.  Use a
different unspec code for carry calcultation.
* config/arm/unspecs.md (VADCQ_U_carry, VADCQ_M_U_carry)
(VADCQ_S_carry, VADCQ_M_S_carry, VSBCIQ_U_carry ,VSBCIQ_S_carry
,VSBCIQ_M_U_carry ,VSBCIQ_M_S_carry ,VSBCQ_U_carry ,VSBCQ_S_carry
,VSBCQ_M_U_carry ,VSBCQ_M_S_carry ,VADCIQ_U_carry
,VADCIQ_M_U_carry ,VADCIQ_S_carry ,VADCIQ_M_S_carry): New unspec
codes.

gcc/testsuite/ChangeLog:

PR target/122189
* gcc.target/arm/mve/intrinsics/vadcq-check-carry.c: New test.
* gcc.target/arm/mve/intrinsics/vadcq_m_s32.c: Adjust instructions
order.
* gcc.target/arm/mve/intrinsics/vadcq_m_u32.c: Likewise.
* gcc.target/arm/mve/intrinsics/vsbcq_m_s32.c: Likewise.
* gcc.target/arm/mve/intrinsics/vsbcq_m_u32.c: Likewise.

3 days agoPR rtl-optimization/122266: Handle TImode in reg_num_sign_bit_copies_for_combine
Roger Sayle [Wed, 15 Oct 2025 10:21:18 +0000 (11:21 +0100)] 
PR rtl-optimization/122266: Handle TImode in reg_num_sign_bit_copies_for_combine

This patch resolves PR rtl-optimization/122266 by changing the types
of the last_set_sign_bit_copies and sign_bit_copies fields in combine.cc's
reg_stat_type struct to be "unsigned short".  This makes both types
consistent, and fixes the issue that on platforms where char is by
default signed, combine.cc can overflow when handling TImode values,
where sign_bit_copies can be 128 bits.

Conveniently, there are holes (caused by field alignment/padding) in the
reg_stat_type struct that allows us to upgrade to "unsigned short" without
increasing the total size of the struct.  This should help reduce problems
in future handling OImode or XImode values, or possible issues with 256-bit
and 512-bit vector modes.  Note that it's important to take care when
reordering the fields of this struct, as the (partial) ordering of fields
is significant: See the use of offsetof in combine.cc's init_reg_last.

Before:
(gdb) ptype /o reg_stat_type
/* offset      |    size */  type = struct reg_stat_type {
/*      0      |       8 */    rtx_insn *last_death;
/*      8      |       8 */    rtx_insn *last_set;
/*     16      |       8 */    rtx last_set_value;
/*     24      |       4 */    int last_set_table_tick;
/*     28      |       4 */    int last_set_label;
/*     32      |       8 */    unsigned long last_set_nonzero_bits;
/*     40      |       1 */    char last_set_sign_bit_copies;
/*     41: 0   |       4 */    machine_mode last_set_mode : 16;
/*     43      |       1 */    bool last_set_invalid;
/*     44      |       1 */    unsigned char sign_bit_copies;
/* XXX  3-byte hole      */
/*     48      |       8 */    unsigned long nonzero_bits;
/*     56      |       4 */    int truncation_label;
/*     60: 0   |       4 */    machine_mode truncated_to_mode : 16;
/* XXX  2-byte padding   */
                               /* total size (bytes):   64 */
                             }

After:
/* offset      |    size */  type = struct reg_stat_type {
/*      0      |       8 */    rtx_insn *last_death;
/*      8      |       8 */    rtx_insn *last_set;
/*     16      |       8 */    rtx last_set_value;
/*     24      |       4 */    int last_set_table_tick;
/*     28      |       4 */    int last_set_label;
/*     32      |       8 */    unsigned long last_set_nonzero_bits;
/*     40      |       2 */    unsigned short last_set_sign_bit_copies;
/*     42: 0   |       4 */    machine_mode last_set_mode : 16;
/*     44      |       1 */    bool last_set_invalid;
/* XXX  1-byte hole      */
/*     46      |       2 */    unsigned short sign_bit_copies;
/*     48      |       8 */    unsigned long nonzero_bits;
/*     56      |       4 */    int truncation_label;
/*     60: 0   |       4 */    machine_mode truncated_to_mode : 16;
/* XXX  2-byte padding   */
                               /* total size (bytes):   64 */
                             }

2025-10-15  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR rtl-optimization/122266
* combine.cc (struct reg_stat_type): Change types of sign_bit_copies
and last_set_sign_bit_copies to unsigned short, to avoid overflows
on TImode (and wider) values.

gcc/testsuite/ChangeLog
PR rtl-optimization/122266
* gcc.target/i386/pr122266.c: New test case.

3 days agoCleanup max of profile_count
Jan Hubicka [Wed, 15 Oct 2025 07:49:21 +0000 (09:49 +0200)] 
Cleanup max of profile_count

profile_count::max is not implemented same way as other arithmetics on
profile counts which generally require counts to be compatible and
returns minimum of qualities of input counts.  Reason is that originally
it was used to compute statistics of whole callgraph profile so inliner
weights can be scaled to reasonable integers interprocedurally.  It also
combines qulities weird way so the same counter could be used to
determine what quality of profile is available.  That code had roundoff
error issues and was replaced by sreals.

Now max is mostly used to determine cfg->max_count which is used to
scale counts to reasonable integers intraprocedurally and is still being
used i.e. by IRA.  There are also few places where max is used for
normal arithmetics when updating profile.

For computing max_count we need max to still be a bit special so max
(uninitialized, initialized) returns initialized rather then
uninitialized. Partial profiles are later handled specially.

This patch renames max to max_prefer_initialized to make it clear and updates
implementation to require compatible profiles.  I checked this behaviour is good
for other places using it as well.
I also turned function to static, since a = a->max (b) looks odd.

gcc/ChangeLog:

* auto-profile.cc (scale_bb_profile): Use
profile_count::max_prefer_initialized.
(afdo_adjust_guessed_profile): Likewise.
* bb-reorder.cc (edge_order): Do not use max.
* cfghooks.cc (merge_blocks): Likewise.
* ipa-fnsummary.cc (param_change_prob): Likewise.
* ipa-inline-transform.cc (inline_transform): Likewise.
* predict.cc (update_max_bb_count): Likewise.
(estimate_bb_frequencies): Likewise.
(rebuild_frequencies): Likewise.
* tree-ssa-loop-unswitch.cc (struct unswitch_predicate): Likewise.
* profile-count.h (profile_count::max): Rename to
(profile_count::max_prefer_initialized): this; update handling
of qualities.

3 days agoInitial Wildcat Lake Support
Haochen Jiang [Wed, 10 Sep 2025 05:42:21 +0000 (13:42 +0800)] 
Initial Wildcat Lake Support

Add Wildcat Lake support according to ISE.

gcc/ChangeLog:

* common/config/i386/cpuinfo.h
(get_intel_cpu): Handle Wildcat Lake.
* common/config/i386/i386-common.cc (processor_name):
Add Wildcat Lake.
* doc/invoke.texi: Ditto.

3 days agoi386: Correct ISA set for Panther Lake and Diamond Rapids
Haochen Jiang [Fri, 19 Sep 2025 02:18:08 +0000 (10:18 +0800)] 
i386: Correct ISA set for Panther Lake and Diamond Rapids

In ISE, Panther Lake does not enable PREFETCHI and Diamond Rapids
does not enable USER_MSR. Correct them accordingly.

I will backport the patch to GCC15/14. For GCC14, only PTL will be
backported.

gcc/ChangeLog:

* config/i386/i386.h
(PTA_PANTHERLAKE): Remove PREFETCHI.
(PTA_DIAMONDRAPIDS): Remove USER_MSR.
* doc/invoke.texi: Correct documentation.

3 days agoRISC-V: Fix incorrect op of vwaddu/vwsubu wx combine
Pan Li [Tue, 14 Oct 2025 02:33:08 +0000 (10:33 +0800)] 
RISC-V: Fix incorrect op of vwaddu/vwsubu wx combine

The vwaddu and vwsubu combine pattern should take plus/minus
instead of any_widen_binop.  This PATCH would like to fix it.

The below test suites are passed for this patch series.
* The rv64gcv fully regression test.

gcc/ChangeLog:

* config/riscv/autovec-opt.md: Take concrete op instead
of any_widen_binop for vwaddu/vwsubu wx combine.

Signed-off-by: Pan Li <pan2.li@intel.com>
3 days agoDaily bump.
GCC Administrator [Wed, 15 Oct 2025 00:21:12 +0000 (00:21 +0000)] 
Daily bump.

4 days agoc++: mem-initializer-id qualified name lookup is type-only [PR122192]
Patrick Palka [Tue, 14 Oct 2025 16:56:23 +0000 (12:56 -0400)] 
c++: mem-initializer-id qualified name lookup is type-only [PR122192]

Since a mem-initializer needs to be able to initialize any base class,
lookup for which is type-only, we in turn need to make mem-initializer-id
qualified name lookup type-only too.

PR c++/122192

gcc/cp/ChangeLog:

* parser.cc (cp_parser_mem_initializer_id): Pass class_type
instead of typename_type to cp_parser_class_name in the
nested-name-specifier case.

gcc/testsuite/ChangeLog:

* g++.dg/template/dependent-base6.C: Verify mem-initializer-id
qualified name lookup is type-only too.

Reported-by: Vincent X
Reviewed-by: Jason Merrill <jason@redhat.com>
4 days agolibstdc++: Add negative this_thread::sleep tests [PR116586]
Mike Crowe [Sun, 21 Sep 2025 16:15:52 +0000 (17:15 +0100)] 
libstdc++: Add negative this_thread::sleep tests [PR116586]

Add tests to ensure that std::this_thread::sleep_for() and
std::this_thread::sleep_until() cope with being passed negative times
correctly. These tests prove that the functions don't suffer from
libstdc++/PR116586, and will stay that way.

libstdc++-v3/ChangeLog:

PR libstdc++/116586
* testsuite/30_threads/this_thread/sleep_for.cc: Add
test_negative() test.
* testsuite/30_threads/this_thread/sleep_until.cc: Make existing
test use both system_clock and steady_clock. Add test_negative()
test.

Signed-off-by: Mike Crowe <mac@mcrowe.com>
4 days agolibstdc++: Add std::timed_mutex tests for negative timeouts [PR116586]
Mike Crowe [Sun, 14 Sep 2025 20:21:33 +0000 (21:21 +0100)] 
libstdc++: Add std::timed_mutex tests for negative timeouts [PR116586]

Add tests to show that std::timed_mutex::try_lock_until and
std::timed_mutex::try_lock_for correctly handle negative timeouts.

libstdc++-v3/ChangeLog:

PR libstdc++/116586
* testsuite/30_threads/timed_mutex/try_lock_until/116586.cc: New
test.

Signed-off-by: Mike Crowe <mac@mcrowe.com>
4 days agolibstdc++: Add std::recursive_timed_mutex tests for negative timeouts [PR116586]
Mike Crowe [Sun, 14 Sep 2025 20:21:32 +0000 (21:21 +0100)] 
libstdc++: Add std::recursive_timed_mutex tests for negative timeouts [PR116586]

Add tests to show that std::recursive_timed_mutex::try_lock_until and
std::recursive_timed_mutex::try_lock_for correctly handle negative
timeouts.

libstdc++-v3/ChangeLog:

PR libstdc++/116586
* testsuite/30_threads/recursive_timed_mutex/try_lock_until/116586.cc:
New test.

Signed-off-by: Mike Crowe <mac@mcrowe.com>
4 days agolibstdc++: Add std::future tests for negative timeouts [PR116586]
Mike Crowe [Sun, 14 Sep 2025 20:21:31 +0000 (21:21 +0100)] 
libstdc++: Add std::future tests for negative timeouts [PR116586]

Add tests to show that std::future::wait_until and
std::future::wait_for correctly handle negative timeouts.

libstdc++-v3/ChangeLog:

PR libstdc++/116586
* testsuite/30_threads/future/members/116586.cc: New test.

Signed-off-by: Mike Crowe <mac@mcrowe.com>
4 days agolibstdc++: Add std::condition_variable tests for negative timeouts [PR116586]
Mike Crowe [Sun, 14 Sep 2025 20:21:30 +0000 (21:21 +0100)] 
libstdc++: Add std::condition_variable tests for negative timeouts [PR116586]

Add tests to show that std::condition_variable::wait_until and
std::condition_variable::wait_for correctly handle negative timeouts.

libstdc++-v3/ChangeLog:

PR libstdc++/116586
* testsuite/30_threads/condition_variable/members/116586.cc: New
test.

Signed-off-by: Mike Crowe <mac@mcrowe.com>
4 days agolibstdc++: Add std::shared_timed_mutex tests for negative timeouts [PR116586]
Jonathan Wakely [Thu, 9 Oct 2025 10:11:44 +0000 (11:11 +0100)] 
libstdc++: Add std::shared_timed_mutex tests for negative timeouts [PR116586]

Add tests to show that std::shared_timed_mutex correctly handles
negative timeouts.

libstdc++-v3/ChangeLog:

PR libstdc++/116586
* testsuite/30_threads/shared_timed_mutex/try_lock_until/116586.cc:
New test.

Signed-off-by: Mike Crowe <mac@mcrowe.com>
4 days agolibstdc++: Add std::binary_semaphore tests for negative timeouts [PR116586]
Mike Crowe [Sun, 14 Sep 2025 20:21:28 +0000 (21:21 +0100)] 
libstdc++: Add std::binary_semaphore tests for negative timeouts [PR116586]

Add test cases to prove that negative timeouts are correctly handled by
std::binary_semaphore (which is just an alias for
std::counting_semaphore<1>).  The tests exercise cases that aren't
problematic with the current code since system_clock is converted to
steady_clock before calling __platform_wait_until() is called but they
will protect against changes in the implementation reintroducing this
bug.

libstdc++-v3/ChangeLog:

PR libstdc++/116586
* testsuite/30_threads/semaphore/try_acquire_for.cc: Add tests.
* testsuite/30_threads/semaphore/try_acquire_until.cc: Add
tests.

Signed-off-by: Mike Crowe <mac@mcrowe.com>
4 days agolibstdc++: Avoid overflow in timeout conversions [PR113327]
Jonathan Wakely [Thu, 9 Oct 2025 10:09:34 +0000 (11:09 +0100)] 
libstdc++: Avoid overflow in timeout conversions [PR113327]

When converting from a coarse duration with a very large value, the
existing code scales that up to chrono::seconds which overflows the
chrono::seconds::rep type. For example, sleep_for(chrono::hours::max())
tries to calculate LLONG_MAX * 3600, which overflows to -3600 and so the
sleep returns immediately.

The solution in this commit is inspired by this_thread::sleep_for in
libc++ which compares the duration argument to
chrono::duration<long double>(nanoseconds::max()) and limits the
duration to nanoseconds::max(). Because we split the duration into
seconds and nanoseconds, we can use seconds::max() as our upper limit.

We might need to limit further if seconds::max() doesn't fit in the
type used for sleeping, which is one of std::time_t, unsigned int, or
chrono::milliseconds.

To fix this everywhere that uses timeouts, new functions are introduced
for converting from a chrono::duration or chrono::time_point to a
timespec (or __gthread_time_t which is just a timespec on Linux). These
functions provide one central place where we can avoid overflow and also
handle negative timeouts (as these produce errors when passed to OS
functions that do not accept absolute times before the epoch). All
negative durations are converted to zero, and negative time_points are
converted to the epoch.

The new __to_timeout_gthread_time_t function in <bits/std_mutex.h>
requires adding <bits/chrono.h> to that header, but that only affects
<syncstream>. All other consumers of <bits/std_mutex.h> were already
including <bits/chrono.h> for timeouts (e.g. <shared_mutex> and
<condition_variable>).

libstdc++-v3/ChangeLog:

PR libstdc++/113327
PR libstdc++/116586
PR libstdc++/119258
PR libstdc++/58931
* include/bits/chrono.h (__to_timeout_timespec): New overloaded
function templates for converting chrono types to timespec.
* include/bits/std_mutex.h (__to_timeout_gthread_time_t): New
function template for converting time_point to __gthread_time_t.
* include/bits/this_thread_sleep.h (sleep_for): Use
__to_timeout_timespec.
(__sleep_for): Remove namespace-scope declaration.
* include/std/condition_variable: Likewise.
* include/std/mutex: Likewise.
* include/std/shared_mutex: Likewise.
* src/c++11/thread.cc (limit): New helper function.
(__sleep_for): Use limit to prevent overflow when converting
chrono::seconds to time_t, unsigned, or chrono::milliseconds.
* src/c++20/atomic.cc: Use __to_timeout_timespec and
__to_timeout_gthread_time_t for timeouts.
* testsuite/30_threads/this_thread/113327.cc: New test.

Reviewed-by: Mike Crowe <mac@mcrowe.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 days agolibstdc++: Remove unused local type alias <format>.
Luc Grosheintz [Tue, 14 Oct 2025 15:16:55 +0000 (17:16 +0200)] 
libstdc++: Remove unused local type alias <format>.

After r16-4421-g59cabe08b57a26 the local type alias _String isn't used
anymore and therefore causes warnings when building the tests with
`-Wall -Wextra`.

libstdc++-v3/ChangeLog:

* include/std/format (_M_format_range): Remove unused local type
alias _String.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>0
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
4 days agolibstdc++: Test specific feature test macros instead of __cplusplus
Jonathan Wakely [Wed, 8 Oct 2025 14:24:51 +0000 (15:24 +0100)] 
libstdc++: Test specific feature test macros instead of __cplusplus

This changes the associative and unordered containers to check
__glibcxx_node_extract, __glibcxx_generic_associative_lookup, and
__glibcxx_generic_unordered_lookup instead of just checking the value of
__cplusplus.

libstdc++-v3/ChangeLog:

* include/bits/hashtable.h: Check specific feature test macros
instead of checking thevalue of __cplusplus.
* include/bits/stl_map.h: Likewise.
* include/bits/stl_multimap.h: Likewise.
* include/bits/stl_multiset.h: Likewise.
* include/bits/stl_set.h: Likewise.
* include/bits/stl_tree.h: Likewise.
* include/bits/unordered_map.h: Likewise.
* include/bits/unordered_set.h: Likewise.
* include/debug/map.h: Likewise.
* include/debug/multimap.h: Likewise.
* include/debug/multiset.h: Likewise.
* include/debug/set.h: Likewise.
* include/debug/unordered_map: Likewise.
* include/debug/unordered_set: Likewise.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 days agolibstdc++: Ensure filesystem::path internals are sufficiently aligned [PR122255]
Jonathan Wakely [Sat, 11 Oct 2025 10:22:38 +0000 (11:22 +0100)] 
libstdc++: Ensure filesystem::path internals are sufficiently aligned [PR122255]

We need the memory allocated for a path::_List::_Impl to be at least
4-byte aligned, so that we can use the two least significant bits to
store a _Type value. Use __STDCPP_DEFAULT_NEW_ALIGNMENT__ to check that
in a static_assert. Also add a static_assert to check the memory will be
aligned suitably for the _Impl object itself. In practice both
assertions should pass as long as operator new guarantees to return
memory with at least 4-byte alignment, which seems to be true for malloc
on GCC's supported targets.

Allocation of path::_List::_Impl objects is refactored into a new
_Impl::create function so that the memory allocation is done in one
place, rather than being repeated in path::_List::_Impl::copy and
path::_List::reserve. If we late decide to use aligned-new to support
targets that fail the new static assertions we won't need to do that in
two different places. Calling operator delete already only happens in
one place, the _Impl_deleter.

The create function is actually implemented in terms of another new
function, create_unchecked. The overflow checks in create aren't needed
when copying an existing object, because we already checked its size
doesn't overflow.

Destroying the components is now done by a destructor, which the
_Impl_deleter invokes.

libstdc++-v3/ChangeLog:

PR libstdc++/122255
* src/c++17/fs_path.cc (path::_List::_Impl::~_Impl): Define
destructor.
(path::_List::_Impl::copy): Use create_unchecked.
(path::_List::_Impl): Add static assertions.
(path::_List::_Impl::create): New static member function.
(path::_List::_Impl::create_unchecked): Likewise.
(path::_List::_Impl_deleter::operator()): Use destructor.
(path::_List::reserve): Use create.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 days agolibstdc++: Implement _Escaping_sink to avoid construction of string
Tomasz Kamiński [Tue, 8 Jul 2025 16:50:50 +0000 (18:50 +0200)] 
libstdc++: Implement _Escaping_sink to avoid construction of string

This patch implements _Escaping_sink that stores characters in a local (stack)
buffer. When the buffer is full, the range of characters is escaped and written
to the underlying sink.

To support above, the __write_escaped_unicode_part function are defined.
It takes __str and __prev_esc by reference. The __prev_esc value is updated
based on the last character written. If the buffer ends with an incomplete
code point sequence, __str is left non-empty and last code points are not
written. _Escaping_sink then copies these characters to the front of the
buffer to reconstruct the full code point.

__formatter__str::_M_format_range now uses _Escaping_sink to escape any
non-continuous character sequences.

libstdc++-v3/ChangeLog:

* include/std/format (__format::__write_escape_seqs)
(__format::_Escaping_sink): Define.
(__format::__write_escaped_unicode_part): Extract from
__format::__write_escaped_unicode.
(__format::__write_escaped_unicode): Forward to
__write_escaped_unicode_part.
(__formatter_str::_M_format_range): Use _Escaping sink.
* testsuite/std/format/ranges/string.cc: New tests for
character which codepoints will be split in buffer and
escaping. Invoked test_padding.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 days agoRemove REDUC_GROUP_* from public interface
Richard Biener [Tue, 14 Oct 2025 12:13:56 +0000 (14:13 +0200)] 
Remove REDUC_GROUP_* from public interface

The following removes REDUC_GROUP_* from the public vectorizer
interface and privatizes REDUC_GROUP_FIRST_ELEMENT which is now
only temporarily set during SLP discovery.

* tree-vectorizer.h (REDUC_GROUP_FIRST_ELEMENT,
REDUC_GROUP_NEXT_ELEMENT, REDUC_GROUP_SIZE): Remove.
* tree-vect-slp.cc (REDUC_GROUP_FIRST_ELEMENT): Re-instantiate
here.

4 days agolibstdc++: Make atomic<shared_ptr<T>>::wait sensitive to stored pointer only changes...
Tomasz Kamiński [Wed, 20 Aug 2025 13:56:21 +0000 (15:56 +0200)] 
libstdc++: Make atomic<shared_ptr<T>>::wait sensitive to stored pointer only changes [PR118757]

Previously, atomic<shared_ptr<T>>::wait (and the weak_ptr version) was
equivalent to waiting directly on _M_val, which corresponds to the pointer
to the control block (_M_pi). Consequently, wakeups were not triggered if
the stored pointer value was changed to a pointer that uses the same control
block but stores pointer to a different object. Such a pointer can be
constructed using an aliasing constructor.

To address this, wait now uses a generic proxy wait
std::__atomic_wait_address function, which supports waiting until any
predicate is satisfied. The provided predicate now compares both the control
block (_M_pi) and the stored pointer (_M_ptr). Comparing the latter requires
locking the pointer.

Since this function operates on raw pointers, the type of _M_val was changed
from __atomic_base<uintptr_t> to uintptr_t. Invocations of the corresponding
member functions are now replaced with direct use of __atomic builtins.

PR libstdc++/118757

libstdc++-v3/ChangeLog:

* include/bits/shared_ptr_atomic.h (_Atomic_count::_M_wait_unlock):
Add parameter capturing reference to _M_ptr. Reimplement in terms
of __atomic_wait_address.
(_Atomic_count::~_Atomic_count, _Atomic_count::lock)
(_Atomic_count::unlock, _Atomic_count::_M_swap_unlock): Replace
invocation of atomic member funcitons with __atomic builtins.
(_Atomic_count::notify_one, _Atomic_count::notify_all):
Use __atomic_notify_address.
(_Sp_atomic::element_type): Define.
(_Sp_atomic::_M_val): Change type to uintptr_t.
(_Sp_atomic::wait): Pass _M_ptr to _M_wait_unlock.
* python/libstdcxx/v6/printers.py:
* testsuite/20_util/shared_ptr/atomic/pr118757.cc: New test.
* testsuite/20_util/weak_ptr/pr118757.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 days agolibstdc++: Fix required alignment computation for floating points [PR122267]
Tomasz Kamiński [Tue, 14 Oct 2025 09:06:35 +0000 (11:06 +0200)] 
libstdc++: Fix required alignment computation for floating points [PR122267]

Before the r16-4349-g90dde804626f13 the required alignment of floating point,
and pointer specialization used __alignof__(_Vt) as required_alignment, and
mentioned commit changed them to alignof(_Vt). This values differs on i686
for double, as alignof(double) is 4, and __alignof__(double) is 8.

This patch restores the previous behavior.

PR libstdc++/122267

libstdc++-v3/ChangeLog:

* include/bits/atomic_base.h
(__atomic_ref_base<const _Tp>::_S_required_alignment):
Use __alignof__ instead of alignof.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
4 days agoMove reduction chain code fully to vect_analyze_slp_reduc_chain
Richard Biener [Tue, 14 Oct 2025 07:27:00 +0000 (09:27 +0200)] 
Move reduction chain code fully to vect_analyze_slp_reduc_chain

The following moves the initial discovery of a reduction chain
to vect_analyze_slp_reduc_chain, this makes it easier to follow.

* tree-vect-slp.cc (vect_analyze_slp_reduction): Move
reduction chain discovery ...
(vect_analyze_slp_reduc_chain): ... here.

4 days agolibstdc++: Formatting tests for std::chrono compose types.
Tomasz Kamiński [Thu, 9 Oct 2025 14:27:18 +0000 (16:27 +0200)] 
libstdc++: Formatting tests for std::chrono compose types.

This covers:
 * weekday_indexed, weekday_last
 * month_day, month_day_last,
 * month_weekday, month_weekday_last
 * year_month

libstdc++-v3/ChangeLog:

* testsuite/std/time/month_day/io.cc: New formatting tests.
* testsuite/std/time/month_day_last/io.cc: Likewise.
* testsuite/std/time/month_weekday/io.cc: Likewise.
* testsuite/std/time/month_weekday_last/io.cc: Likewise.
* testsuite/std/time/weekday_indexed/io.cc: Likewise.
* testsuite/std/time/weekday_last/io.cc: Likewise.
* testsuite/std/time/year_month/io.cc: Likewise.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 days agoClean up confusing vectype/vectype1 mixups in vect_create_epilog_for_reduction
Richard Biener [Thu, 9 Oct 2025 12:02:09 +0000 (14:02 +0200)] 
Clean up confusing vectype/vectype1 mixups in vect_create_epilog_for_reduction

The following occured to me - hope it doesn't hide anything real.

* tree-vect-loop.cc (vect_create_epilog_for_reduction): Move
bitsize compute down to where it is used and consistently
use vectype1 for element extraction.

4 days agomiddle-end: Relax vect_recog_vector_vector_shift_pattern STMT def type [PR121949]
Tamar Christina [Tue, 14 Oct 2025 09:24:13 +0000 (10:24 +0100)] 
middle-end: Relax vect_recog_vector_vector_shift_pattern STMT def type [PR121949]

The example

void f(long long* acc)
{
    for (int row = 0; row < 64; ++row)
      acc[row] = acc[row] << row;
}

fails to vectorize because the size of row is different than the size of the
being shifted value.

The vectorizer has a pattern that should deal with such shifts in
vect_recog_vector_vector_shift_pattern however this pattern is using
vect_get_internal_def to get the definition of the shift operand.

This needlessly restricts the pattern to only internal_defs.  The vectorizer
can deal with casts on any operand type so this restriction isn't needed and
this is dropped.

gcc/ChangeLog:

PR tree-optimization/121949
* tree-vect-patterns.cc (vect_recog_vector_vector_shift_pattern): Remove
restriction on internal_def.

gcc/testsuite/ChangeLog:

PR tree-optimization/121949
* gcc.dg/vect/pr121949_1.c: New test.
* gcc.dg/vect/pr121949_2.c: New test.
* gcc.dg/vect/pr121949_3.c: New test.

4 days agoobj-c/obj-c++: Enable more options in c-family for ObjC/ObjC++
Jakub Jelinek [Tue, 14 Oct 2025 09:06:08 +0000 (11:06 +0200)] 
obj-c/obj-c++: Enable more options in c-family for ObjC/ObjC++

On Mon, Oct 13, 2025 at 07:07:01AM +0100, Iain Sandoe wrote:
>       * c.opt: Enable Wignored-attributes for Objective-C and
>       Objective-C++.

I wrote a more complete version of this patch, here is it rebased
on top of your patch.

I see no reason for any of these options to be C C++ only rather than
C ObjC C++ ObjC++, or in some cases C++ only rather than C++ ObjC++.
The only cases where I think limiting to C only is desirable are
fgimple
C Var(flag_gimple) Init(0)
Enable parsing GIMPLE.
where I think we don't want to support ObjC for GIMPLE FE, and
lang-asm
C Undocumented RejectDriver
For everything else I believe people adding those options just didn't
think of ObjC or ObjC++.

2025-10-14  Jakub Jelinek  <jakub@redhat.com>

* c.opt (Wflex-array-member-not-at-end, Wignored-qualifiers,
Wopenacc-parallelism, Wstrict-flex-arrays, Wsync-nand,
fstrict-flex-arrays, fstrict-flex-arrays=): Enable also for ObjC and
ObjC++ next to C and C++.
(Wmisleading-indentation, Wopenmp-simd): Likewise.  Also change
LangEnabledBy from just C C++ to C ObjC C++ ObjC++.
(Wplacement-new, Wplacement-new=, fcontract-assumption-mode=,
fcontract-build-level=, fcontract-strict-declarations=,
fcontract-mode=, fcontract-continuation-mode=, fcontract-role=,
fcontract-semantic=, fcoroutines, flang-info-include-translate,
flang-info-include-translate-not, flang-info-include-translate=,
flang-info-module-cmi, flang-info-module-cmi=): Enable also
for ObjC++ next to C++.

4 days agovect: Move slp_perm checking into get_load_store_type.
Robin Dapp [Fri, 10 Oct 2025 16:39:01 +0000 (18:39 +0200)] 
vect: Move slp_perm checking into get_load_store_type.

This moves the setting of slp_perm, checking of basic-block SLP gaps, as
well as the final check for perm_ok to get_load_store_type.
Also, slp_perm is moved to ls_data.

gcc/ChangeLog:

* tree-vect-stmts.cc (get_load_store_type): Add load-permutation
checks and setting of slp_perm.
(vectorizable_store): Remove perm_ok argument.
(vectorizable_load): Ditto and replace slp_perm by ls.slp_perm.
* tree-vectorizer.h (struct vect_load_store_data): Add slp_perm.

4 days agoRewrite reduction chain handling
Richard Biener [Fri, 10 Oct 2025 12:09:32 +0000 (14:09 +0200)] 
Rewrite reduction chain handling

The following moves us (almost) away from REDUC_GROUP_* to recognize
reduction chaings towards making this a SLP discovery artifact.
Reduction chains are now explicitly marked in the reduction info
and discovery is done during SLP discovery rather than during
analysis of scalar cycles.  This gets rid of interactions with
patterns and it also allows to transparently fall back to non-chained
reductions even when there is a conversion involved.  This also
spurred some major TLC in vectorizable_reduction.

What's still missing is to get rid of the last REDUC_GROUP_FIRST_ELEMENT
usage in SLP discovery - by not claiming we can handle the reduction
chain itself there.  I'm leaving this for a followup (this was big
enough).

At least on x86-64 I now see XPASSes for gcc.dg/vect/vect-reduc-dot-s8b.c
and gcc.dg/vect/vect-reduc-pattern-2c.c.  I have not done careful
analysis yet, will wait for the CI with that.

* tree-vectorizer.h (vect_reduc_info_s::is_reduc_chain): New.
(_loop_vec_info::reduction_chains): Remove.
(LOOP_VINFO_REDUCTION_CHAINS): Likewise.
* tree-vect-patterns.cc (vect_reassociating_reduction_p):
Do not special-case reduction group stmts.
* tree-vect-loop.cc (vect_is_simple_reduction): Remove
reduction chain handling.
(vect_analyze_scalar_cycles_1): Remove slp parameter and adjust.
(vect_analyze_scalar_cycles): Likewise.
(vect_fixup_reduc_chain): Remove.
(vect_fixup_scalar_cycles_with_patterns): Likewise.
(vect_analyze_loop_2): Adjust.
(vect_create_epilog_for_reduction): Check the reduction info
for whether this is a reduction chain.
(vect_transform_cycle_phi): Likewise.
(vectorizable_reduction): Likewise.  Simplify code for all-SLP.
* tree-vect-slp.cc (vect_analyze_slp_reduc_chain): Simplify.
(vect_analyze_slp_reduction): New function, perform reduction
chain discovery here.
(vect_analyze_slp): Remove reduction chain handling.
Use vect_analyze_slp_reduction for possible reduction chain
processing.

* gcc.dg/vect/pr120687-1.c: Adjust.
* gcc.dg/vect/pr120687-2.c: Likewise.
* gcc.dg/vect/pr120687-3.c: Likewise.

4 days agoi386: Remove AMX-TRANSPOSE support
Haochen Jiang [Tue, 14 Oct 2025 06:52:11 +0000 (14:52 +0800)] 
i386: Remove AMX-TRANSPOSE support

AMX-TRANSPOSE is removed from ISE. Since there is no actual hardware, we
choose to directly remove it in GCC 16 and backport DMR enable part to
GCC 15.

gcc/ChangeLog:

* common/config/i386/cpuinfo.h
(get_available_features): Remove AMX-TRANSPOSE.
* common/config/i386/i386-common.cc
(OPTION_MASK_ISA2_AMX_TRANSPOSE_SET): Removed.
(OPTION_MASK_ISA2_AMX_TRANSPOSE_UNSET): Ditto.
(ix86_handle_option): Remove amx-transpose handle.
* common/config/i386/i386-cpuinfo.h
(enum processor_features): Remove FEATURE_AMX_TRANSPOSE.
Set FEATURE_AMX_MOVRS value.
* common/config/i386/i386-isas.h: Remove AMX-TRANSPOSE.
* config.gcc: Do not include amxtransposeintrin.h.
* config/i386/amxmovrsintrin.h: Remove AMX-TRANSPOSE intrins.
* config/i386/amxtransposeintrin.h: Ditto.
* config/i386/cpuid.h (bit_AMX_TRANSPOSE): Removed.
* config/i386/i386.h (PTA_DIAMONDRAPIDS): Remove AMX-TRANSPOSE.
* config/i386/i386-c.cc (ix86_target_macros_internal): Remove
AMX_TRANSPOSE.
* config/i386/i386-isa.def (AMX_TRANSPOSE): Removed.
* config/i386/i386-options.cc
(ix86_valid_target_attribute_inner_p): Remove AMX-TRANSPOSE.
* config/i386/i386.opt: Ditto.
* config/i386/i386.opt.urls: Ditto.
* config/i386/immintrin.h: Remove amxtransposeintrin.h.
* doc/extend.texi: Remove amx-transpose.
* doc/invoke.texi: Ditto.
* doc/sourcebuild.texi: Ditto.

gcc/testsuite/ChangeLog:

* g++.dg/other/i386-2.C: Remove AMX-TRANSPOSE test.
* g++.dg/other/i386-3.C: Ditto.
* gcc.target/i386/amx-check.h: Ditto.
* gcc.target/i386/amxmovrs-asmatt-1.c: Ditto.
* gcc.target/i386/amxmovrs-asmintel-1.c: Ditto.
* gcc.target/i386/funcspec-56.inc: Ditto.
* gcc.target/i386/sse-12.c: Ditto.
* gcc.target/i386/sse-13.c: Ditto.
* gcc.target/i386/sse-14.c: Ditto.
* gcc.target/i386/sse-22.c: Ditto.
* gcc.target/i386/sse-23.c: Ditto.
* lib/target-supports.exp: Ditto.
* gcc.target/i386/amxmovrs-2rpntlvwrs-2.c: Removed.
* gcc.target/i386/amxtranspose-2rpntlvw-2.c: Removed.
* gcc.target/i386/amxtranspose-asmatt-1.c: Removed.
* gcc.target/i386/amxtranspose-asmintel-1.c: Removed.
* gcc.target/i386/amxtranspose-conjtcmmimfp16ps-2.c: Removed.
* gcc.target/i386/amxtranspose-conjtfp16-2.c: Removed.
* gcc.target/i386/amxtranspose-tcmmimfp16ps-2.c: Removed.
* gcc.target/i386/amxtranspose-tcmmrlfp16ps-2.c: Removed.
* gcc.target/i386/amxtranspose-tdpbf16ps-2.c: Removed.
* gcc.target/i386/amxtranspose-tdpfp16ps-2.c: Removed.
* gcc.target/i386/amxtranspose-tmmultf32ps-2.c: Removed.
* gcc.target/i386/amxtranspose-transposed-2.c: Removed.

4 days agophi-opt: Disable parts of it for -Og
Andrew Pinski [Mon, 13 Oct 2025 23:47:55 +0000 (16:47 -0700)] 
phi-opt: Disable parts of it for -Og

While working on the cselim limited part of phiopt, I noticed
that the debugging experience for -Og case would cause jumping
execution in some cases. So this disables the store and operation
factoring parts for -Og since those 2 can cause the line information
of the debugging to be off.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-ssa-phiopt.cc (pass_phiopt::execute): Disable
cselim-limited and factor out operations for -Og.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 days agocselim: Handle clobbers too [PR122178]
Andrew Pinski [Mon, 13 Oct 2025 23:35:07 +0000 (16:35 -0700)] 
cselim: Handle clobbers too [PR122178]

With the addition of cselim-limited in phiopt, factoring
out clobbers can be added easily. Now sink handles clobbers as
a store too. So this just moves that earlier.

This adds support there with a testcase to show it happens.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/122178

gcc/ChangeLog:

* tree-ssa-phiopt.cc (cond_if_else_store_replacement_1): Handle
clobber statements.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 days agoprop: Remove may_propagate_copy_into_asm [PR122182]
Andrew Pinski [Mon, 13 Oct 2025 21:04:31 +0000 (14:04 -0700)] 
prop: Remove may_propagate_copy_into_asm  [PR122182]

may_propagate_copy_into_asm has been returning true always since r0-118216-g01c59d23df7eef.
Many places that checks may_propagate_copy don't check
may_propagate_copy_into_asm for asm_expr. may_propagate_copy_into_stmt
does not check when you would have expected it to. So let's remove may_propagate_copy_into_asm
and remove the checks from substitute_and_fold_engine and dom.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/122182
gcc/ChangeLog:

* tree-ssa-dom.cc (cprop_operand): Don't check may_propagate_copy_into_asm.
* tree-ssa-propagate.cc (substitute_and_fold_engine::replace_uses_in): Don't
check may_propagate_copy_into_asm.
(may_propagate_copy_into_asm): Remove.
* tree-ssa-propagate.h (may_propagate_copy_into_asm): Remove.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 days ago[PATCH v3] RISC-V: Implement RISC-V profile macro support
Zhongyao Chen [Tue, 14 Oct 2025 02:55:40 +0000 (20:55 -0600)] 
[PATCH v3] RISC-V: Implement RISC-V profile macro support

users can now write code like the following to adapt to the
current RISC-V profile selected at compile time:

```c
  #ifdef __riscv_rva23u64
    // Code specific to the rva23u64 profile
  #endif
```

Changes from v2:
- clarify get_profile_name comment

gcc/
* common/config/riscv/riscv-common.cc (riscv_subset_list::get_profile_name):
New function.
* config/riscv/riscv-c.cc (riscv_cpu_cpp_builtins): Define
profile macro if a profile is detected.
* config/riscv/riscv-subset.h (riscv_subset_list::get_profile_name): Declare.

gcc/testsuite/
* gcc.target/riscv/predef-profiles-1.c: New test for __riscv_rvi20u64.
* gcc.target/riscv/predef-profiles-2.c: New test for __riscv_rvi20u32.
* gcc.target/riscv/predef-profiles-3.c: New test for __riscv_rva20u64.
* gcc.target/riscv/predef-profiles-4.c: New test for __riscv_rva22u64.
* gcc.target/riscv/predef-profiles-5.c: New test for __riscv_rva23u64.
* gcc.target/riscv/predef-profiles-6.c: New test for __riscv_rva23s64.
* gcc.target/riscv/predef-profiles-7.c: New test for __riscv_rvb23u64.
* gcc.target/riscv/predef-profiles-8.c: New test for __riscv_rvb23s64.

4 days agoDaily bump.
GCC Administrator [Tue, 14 Oct 2025 00:20:06 +0000 (00:20 +0000)] 
Daily bump.

4 days agolibcpp: decode original directory strings for traditional CPP
Eric Botcazou [Mon, 13 Oct 2025 22:24:37 +0000 (00:24 +0200)] 
libcpp: decode original directory strings for traditional CPP

gcc/testsuite/
* gcc.dg/cpp/cpp.exp: Process .i files.
* gcc.dg/cpp/pr36674.i: Pass -Wno-implicit-int.
* gcc.dg/cpp/escape-3.i: New test.

4 days agolibcpp: decode original directory strings for traditional CPP
Pierre Marie de Rodat [Mon, 13 Oct 2025 22:11:37 +0000 (00:11 +0200)] 
libcpp: decode original directory strings for traditional CPP

In traditional CPP mode (-save-temps, -no-integrated-cpp, etc.), the
compilation directory is conveyed to cc1 using a line such as:

 # <line> "/path/name//"

This string literal can contain escape sequences, for instance, if the
original source file was compiled in "/tmp/a\b", then this line will be:

 # <line> "/tmp/a\\b//"

So reading the compilation directory must decode escape sequences. This
last part is currently missing and this patch implements it.

libcpp/
* init.cc (read_original_directory): Attempt to decode escape
sequences with cpp_interpret_string_notranslate.

4 days ago[RISC-V][PR target/120811] Improving address reloads in LRA
Shreya Munnangi [Mon, 13 Oct 2025 22:13:44 +0000 (16:13 -0600)] 
[RISC-V][PR target/120811] Improving address reloads in LRA

In pr120811, we have cases where GCC is emitting an extra addi instruction
instead of using the 12-bit signed-immediate of ld.

addi t1, t1, 1
ld   t1, 0(t1)

This problem occurs when fp -> sp+offset elimination results in an
out-of-range constant and we generate an address reload in LRA using
addsi/adddi expanders.

We've already adjusted the expanders to widen the set of valid operands to
allow more constants for the 2nd input operand. These expanders, rather than
constructing the constant into a register and using an add instruction, will
generate two addi instructions (or shNadd) during initial RTL generation.

We define a new pattern for cases where we need to access the current frame
and the offsets are too large. This gets reasonable code out of LRA in a form
fold-mem-offsets can handle, rather than having to wait for sched2 to do
the height reduction transformation and leaving in the unnecessary add
instruction in the RTL stream.

To avoid the two addi instructions being squashed back together in the
post-reload combine, we remove the adddi3_const_sum_of_two_s12 pattern.

We are seeing about 100 billion dynamic instructions saved which is about 5%
on cactuBSSN and a 2% improvement in performance on the BPI.

PR target/120811

gcc/

* config/riscv/riscv.cc (synthesize_add): Exchange constant terms when
generating addi pairs.
(synthesize_addsi): Similarly.
* config/riscv/riscv.md (addptr<mode>3): New define_expand.
(*add<mode>3_const_sum_of_two_s12): Remove pattern.

gcc/testsuite/

* gcc.target/riscv/add-synthesis-1.c: Adjust const to fit in range.
* gcc.target/riscv/pr120811.c: Add new test case.
* gcc.target/riscv/sum-of-two-s12-const-1.c: Adjust const to fit in range.

5 days ago[RISC-V][PR target/120674] Avoid division by zero in dwarf emitter when vector is...
Jeff Law [Mon, 13 Oct 2025 20:33:10 +0000 (14:33 -0600)] 
[RISC-V][PR target/120674] Avoid division by zero in dwarf emitter when vector is not enabled

This is a RISC-V specific failure in the dwarf2 emitter.  When vector is not
enabled riscv_convert_vector_chunks sets the riscv_vector_chunks poly_int to
[1, 0].

riscv_dwarf_poly_indeterminite_value pulls out that 0 coefficient and uses that
as FACTOR triggering a divide by zero here:

>               /* Add COEFF * ((REGNO / FACTOR) - BIAS) to the value:
>                  add COEFF * (REGNO / FACTOR) now and subtract
>                  COEFF * BIAS from the final constant part.  */
>               constant -= coeff * bias;
>               add_loc_descr (&ret, new_reg_loc_descr (regno, 0));
>               if (coeff % factor == 0)
>                 coeff /= factor;
>               else
>                 {
>                   int amount = exact_log2 (factor);
>                   gcc_assert (amount >= 0);
>                   add_loc_descr (&ret, int_loc_descriptor (amount));
>                   add_loc_descr (&ret, new_loc_descr (DW_OP_shr, 0, 0));
>                 }

Per Robin's recommendation this patch adjusts
riscv_dwarf_poly_indeterminite_value to never set FACTOR to 0, but instead
detect this case and adjust its value to 1.

That fixes the ICE and looks good across the board in my tester. Waiting on
pre-commit CI, of course.

PR target/120674
gcc/
* config/riscv/riscv.cc (riscv_dwarf_poly_indeterminite_value): Do not
set FACTOR to zero, for that case use one instead.

gcc/testsuite

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

5 days agolibstdc++: Fix grammatical error in comment in std::advance
Jonathan Wakely [Thu, 9 Oct 2025 14:21:16 +0000 (15:21 +0100)] 
libstdc++: Fix grammatical error in comment in std::advance

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator_base_funcs.h (advance): Fix comment.

5 days ago++: Fix up __PRETTY_FUNCTION__ for -fexec-charset= [PR122228]
Jakub Jelinek [Mon, 13 Oct 2025 19:36:47 +0000 (21:36 +0200)] 
++: Fix up __PRETTY_FUNCTION__ for -fexec-charset= [PR122228]

When working on reflection, I've noticed that while we correctly translate
__FUNCTION__ content into the execution charset, for C++ we don't translate
__PRETTY_FUNCTION__ content and leave it in the SOURCE_CHARSET encoding:

const char *
file ()
{
  return __FILE__;
}

const char *
func ()
{
  return __func__;
}

const char *
function ()
{
  return __FUNCTION__;
}

const char *
pretty_function ()
{
  return __PRETTY_FUNCTION__;
}
./cc1 -quiet -fexec-charset=IBM1047 /tmp/0.C -o - | grep string
        .string "a\243\224\227a\360K\303"
        .string "\206\244\225\203"
        .string "\206\244\225\203\243\211\226\225"
        .string "\227\231\205\243\243\250m\206\244\225\203\243\211\226\225"
./cc1plus -quiet -fexec-charset=IBM1047 /tmp/0.C -o - | grep string
        .string "a\243\224\227a\360K\303"
        .string "\206\244\225\203"
        .string "\206\244\225\203\243\211\226\225"
        .string "const char* pretty_function()"

The following patch fixes that.

2025-10-13  Jakub Jelinek  <jakub@redhat.com>

PR c++/122228
* decl.cc (cp_make_fname_decl): When not using fname_as_decl,
attempt to translate name into ordinary literal encoding.

* g++.dg/cpp1y/func_constexpr3.C: New test.

5 days agoPR modula2/122241: Lack of spellng hints with simple errors
Gaius Mulley [Mon, 13 Oct 2025 15:43:07 +0000 (16:43 +0100)] 
PR modula2/122241: Lack of spellng hints with simple errors

Following on from the initial bug fix for PR modula2/122241
this patch provides spell check hints for unknown types, variables
and constants.  The accuracy of the offending module end name
is also improved

gcc/m2/ChangeLog:

PR modula2/122241
* gm2-compiler/M2Quads.mod (BuildSizeFunction): Improve
error message.
(BuildTSizeFunction): Improve error message.
* gm2-compiler/P3Build.bnf (ProgramModule): New variable
namet.
Pass namet to P3EndBuildProgModule.
(ImplementationModule): New variable namet.
Pass namet to P3EndBuildImpModule.
(ModuleDeclaration): New variable namet.
Pass namet to P3EndBuildInnerModule.
(DefinitionModule): New variable namet.
Pass namet to P3EndBuildDefModule.
* gm2-compiler/P3SymBuild.def (P3EndBuildDefModule): New
parameter tokno.
(P3EndBuildImpModule): Ditto.
(P3EndBuildProgModule): Ditto.
(EndBuildInnerModule): Ditto.
* gm2-compiler/P3SymBuild.mod (P3EndBuildDefModule): New
parameter tokno.
Pass tokno to CheckForUnknownInModule.
(P3EndBuildImpModule): Ditto.
(P3EndBuildProgModule): Ditto.
(EndBuildInnerModule): Ditto.
* gm2-compiler/PCBuild.bnf (ProgramModule): New variable
namet.
Pass namet to PCEndBuildProgModule.
(ImplementationModule): New variable namet.
Pass namet to PCEndBuildImpModule.
(ModuleDeclaration): New variable namet.
Pass namet to PCEndBuildInnerModule.
(DefinitionModule): New variable namet.
Pass namet to PCEndBuildDefModule.
* gm2-compiler/PCSymBuild.def (PCEndBuildDefModule): New
parameter tokno.
(PCEndBuildImpModule): Ditto.
(PCEndBuildProgModule): Ditto.
(PCEndBuildInnerModule): Ditto.
* gm2-compiler/PCSymBuild.mod (PCEndBuildDefModule): New
parameter tokno.
Pass tokno to CheckForUnknownInModule.
(PCEndBuildImpModule): Ditto.
(PCEndBuildProgModule): Ditto.
(PCEndBuildInnerModule): Ditto.
* gm2-compiler/PHBuild.bnf (DefinitionModule): New variable
namet.
Pass namet to PHEndBuildDefModule.
(ModuleDeclaration): New variable namet.
Pass namet to PHEndBuildProgModule.
(ImplementationModule): New variable namet.
Pass namet to PHEndBuildImpModule.
(ModuleDeclaration): New variable namet.
Pass namet to PHEndBuildInnerModule.
(DefinitionModule): New variable namet.
Pass namet to PHEndBuildDefModule.
* gm2-compiler/SymbolTable.def (CheckForUnknownInModule): Add
tokno parameter.
* gm2-compiler/SymbolTable.mod (CheckForUnknownInModule): Add
tokno parameter.
Pass tokno to CheckForUnknowns.
(CheckForUnknowns): Reimplement.

gcc/testsuite/ChangeLog:

PR modula2/122241
* gm2/iso/fail/badconst.mod: New test.
* gm2/iso/fail/badtype.mod: New test.
* gm2/iso/fail/badvar.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
5 days agoaarch64, testsuite: Add -fchecking to test options [PR121772]
Alex Coplan [Mon, 13 Oct 2025 13:41:09 +0000 (13:41 +0000)] 
aarch64, testsuite: Add -fchecking to test options [PR121772]

I noticed while testing a backport of the PR121772 fix to GCC 13 that
the test wasn't triggering the ICE as expected with the unpatched
compiler.

This turned out to be because the ICE is a checking ICE, and we
configure by default with --enable-checking=release on the branches.
Additionally, I hadn't noticed when doing the backports to 15 and 14
since there we still ICE later on in emit_move_insn even if we don't
catch the invalid gimple with checking.

I'm not too sure why the 13 branch doesn't see the emit_move_insn ICE,
but it's somewhat irrelevant - the important thing is that adding
-fchecking to the options makes the test fail as expected with an
unpatched compiler (i.e. with a gimple checking failure), even on
release branches.

I considered applying this patch to just the release branches, but
figured that trunk will at some point itself become a release branch, so
it seems to make most sense just to apply it everywhere.

I've checked that the test still passes with this patch, and still fails
if I revert the PR121772 fix.

gcc/testsuite/ChangeLog:

PR tree-optimization/121772
* gcc.target/aarch64/torture/pr121772.c: Add -fchecking to
dg-options.

5 days agolibstdc++: Implement P2835R7 Expose std::atomic_ref's object address
Yuao Ma [Fri, 10 Oct 2025 15:14:48 +0000 (23:14 +0800)] 
libstdc++: Implement P2835R7 Expose std::atomic_ref's object address

This patch adds the address function to __atomic_ref_base.

libstdc++-v3/ChangeLog:

* include/bits/atomic_base.h: Implement address().
* include/bits/version.def: Bump version number.
* include/bits/version.h: Regenerate.
* testsuite/29_atomics/atomic_ref/address.cc: New test.

5 days agoMatch: Add widen_mul based unsigned SAT_MUL after gimple_convert refactor
Pan Li [Sat, 11 Oct 2025 15:12:59 +0000 (23:12 +0800)] 
Match: Add widen_mul based unsigned SAT_MUL after gimple_convert refactor

The build_and_insert_cast refactored to go the gimple_convert way, to
take care of the widen_mul.  Thus, the gimple layout from uint64_t
widen_mul to uint128_t doesn't need additional cast like other types
(uint32_t, uint16_t, uint8_t) widen to uint128_t for mul.  Thus, add
the simplifed pattern match for such forms of unsigned SAT_MUL.

The below test suites are passed for this patch:
1. The rv64gcv fully regression tests.
2. Fix rv64gcv SAT_MUL test failure of optimized .SAT_MUL check.
3. The x86 bootstrap tests.
4. The x86 fully regression tests.

gcc/ChangeLog:

* match.pd: Add simplifed pattern for widen_mul based unsigned
SAT_MUL.

Signed-off-by: Pan Li <pan2.li@intel.com>
5 days agoRemove max_count computation from ipa-inline
Jan Hubicka [Mon, 13 Oct 2025 10:13:51 +0000 (12:13 +0200)] 
Remove max_count computation from ipa-inline

Ipa inline computes max_count which used to be applied later to compute badness
before it was converted to sreal.  Now it is only used in couple of places to see
if any IPA profile is presents at all.  This patch replaces this by more specific
flag has_nonzero_ipa_profile.

gcc/ChangeLog:

* ipa-inline.cc (max_count): Remove.
(has_nonzero_ipa_profile): New.
(inline_small_functions): Update.
(dump_inline_stats): Update.

5 days agolibstdc++: Fix reverse iteration in _Utf16_view
Jonathan Wakely [Fri, 10 Oct 2025 22:56:43 +0000 (23:56 +0100)] 
libstdc++: Fix reverse iteration in _Utf16_view

When iterating over a range of char16_t in reverse the _Utf_view was
incorrectly treating U+DC00 as a valid high surrogate that can precede
the low surrogate. But U+DC00 is a low surrogate, and so should not be
allowed before another low surrogate. The check should be u2 >= 0xDC00
rather than u2 > 0xDC00.

libstdc++-v3/ChangeLog:

* include/bits/unicode.h (_Utf_view::_M_read_reverse_utf16):
Fix check for high surrogate preceding low surrogate.
* testsuite/ext/unicode/view.cc: Check unpaired low surrogates.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 days agolibstdc++: Fix check for 7-bit ASCII characters
Jonathan Wakely [Fri, 10 Oct 2025 22:16:22 +0000 (23:16 +0100)] 
libstdc++: Fix check for 7-bit ASCII characters

This should check for c <= 0x7f not x < 0x7f, because 0x7f is an ASCII
character (DEL).

libstdc++-v3/ChangeLog:

* include/bits/unicode.h (__is_single_code_unit): Fix check for
7-bit ASCII characters.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
5 days agovect: Handle grouped accesses via gather/scatter.
Robin Dapp [Fri, 5 Sep 2025 14:19:18 +0000 (16:19 +0200)] 
vect: Handle grouped accesses via gather/scatter.

This patch adds gather/scatter handling for grouped access.  The idea is
to e.g. replace an access (for uint8_t elements) like
  arr[0]
  arr[1]
  arr[2]
  arr[3]
  arr[0 + step]
  arr[1 + step]
  ...
by gather loads of uint32_t
  arr[0..3]
  arr[0 + step * 1..3 + step * 1]
  arr[0 + step * 2..3 + step * 2]
  ...
where the offset vector is a simple series with step STEP.
If supported, such a gather can be implemented as a strided load.

If we have a masked access the transformation is not performed.
Masking could still be done after converting the data back to the
original vectype but it does not seem worth it for now.

PR target/118019

gcc/ChangeLog:

* internal-fn.cc (get_supported_else_vals): Exit at invalid
index.
(internal_strided_fn_supported_p): New funtion.
* internal-fn.h (internal_strided_fn_supported_p): Declare.
* tree-vect-stmts.cc (vector_vector_composition_type):
Add vector_only argument.
(vect_use_grouped_gather): New function.
(vect_get_store_rhs): Adjust docs of
vector_vector_composition_type.
(get_load_store_type): Try grouped gather.
(vectorizable_store): Use punned vectype.
(vectorizable_load): Ditto.
* tree-vectorizer.h (struct vect_load_store_data): Add punned
vectype.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr118019-2.c: New test.

5 days agomatch.pd: Do not canonicalize division by power 2 for {ROUND, CEIL}_DIV
Avinash Jayakar [Mon, 13 Oct 2025 09:47:45 +0000 (15:17 +0530)] 
match.pd: Do not canonicalize division by power 2 for {ROUND, CEIL}_DIV

Canonicalization of unsigned division by power of 2 only applies to
{TRUNC,FLOOR,EXACT}_DIV, therefore remove the same pattern for {CEIL,ROUND}_DIV,
which was added in a previous commit.

2025-10-13  Avinash Jayakar  <avinashd@linux.ibm.com>

gcc/ChangeLog:
PR tree-optimization/122213
* match.pd: Canonicalize unsigned pow2 div only for trunk, floor and
exact div.

5 days agoopenmp: Teach OpenMP declare variant append_args handling about TYPE_NO_NAMED_ARGS_ST...
Jakub Jelinek [Mon, 13 Oct 2025 07:47:09 +0000 (09:47 +0200)] 
openmp: Teach OpenMP declare variant append_args handling about TYPE_NO_NAMED_ARGS_STDARG_P

Since my recent patch, GCC for C++26 uses the TYPE_NO_NAMED_ARGS_STDARG_P
flag like C23 uses for (...) function types.  The OpenMP declare variant
append_args handling does some very ugly hacks (modify TYPE_ARG_TYPES
temporarily instead of trying to create new function types) and had
to be tweaked to deal with that.  This fixes
-FAIL: c-c++-common/gomp/append-args-7.c  -std=c++26  scan-tree-dump-times gimple "f3 \\\\(obj1, obj2, 1, a, cp, d\\\\);" 1
-FAIL: c-c++-common/gomp/append-args-7.c  -std=c++26 (test for excess errors)

2025-10-13  Jakub Jelinek  <jakub@redhat.com>

* decl.cc (omp_declare_variant_finalize_one): If !nbase_args
and TREE_TYPE (decl) has TYPE_NO_NAMED_ARGS_STDARG_P bit set
and varg is NULL, temporarily set TYPE_NO_NAMED_ARGS_STDARG_P
on TREE_TYPE (variant).

5 days agoAvoid bool pattern for vect_extern_defs
Richard Biener [Mon, 13 Oct 2025 06:22:04 +0000 (08:22 +0200)] 
Avoid bool pattern for vect_extern_defs

The following avoids applying the new bool pattern for binary bitwise
ops when the wrongly typed operand is external or constant as we
cannot handle in-loop conversions of externs.

* tree-vect-patterns.cc (integer_type_for_mask): Add optional
output dt argument.
(vect_recog_bool_pattern): Make sure to not apply the bitwise
binary pattern to an external operand.

5 days agoFortran: Fix ICE in deallocating PDTs [PR121191]
Paul Thomas [Mon, 13 Oct 2025 06:55:18 +0000 (07:55 +0100)] 
Fortran: Fix ICE in deallocating PDTs [PR121191]

2025-10-13  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/121191
* trans-array.cc (has_parameterized_comps): New function which
checks if a derived type has parameterized components.
( gfc_deallocate_pdt_comp): Use it to prevent deallocation of
PDTs if there are no parameterized components.

gcc/testsuite/
PR fortran/121191
* gfortran.dg/pdt_59.f03: New test.

5 days agoObjective-C/C++: Enable Wignored-attributes.
Iain Sandoe [Mon, 13 Oct 2025 05:57:55 +0000 (06:57 +0100)] 
Objective-C/C++: Enable Wignored-attributes.

r16-4373 altered headers so that Wignored-attributes was named in
a diagnostic push.  This causes several Objective-C++ tests to fail
since the atomicity.h header is included there.

Since Objective-C/C++ are intended to be supersets of the base
language, there is no specific reason to exclude this warning there.

gcc/c-family/ChangeLog:

* c.opt: Enable Wignored-attributes for Objective-C and
Objective-C++.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
5 days agoDaily bump.
GCC Administrator [Mon, 13 Oct 2025 00:17:27 +0000 (00:17 +0000)] 
Daily bump.