Alfie Richards [Tue, 18 Nov 2025 10:50:04 +0000 (10:50 +0000)]
aarch64: Cache the PCS value for a function
As aarch64_function_arg_regno_p is a very hot function called many times for a
function it should not call fndecl_abi every time as it is expensive and
unecessasary.
This caches the result and in doing so fixes a regression in compile time
introduced by r16-5076-g7197d8062fddc2.
gcc/ChangeLog:
* config/aarch64/aarch64.cc (aarch64_fndecl_abi): New function.
(aarch64_function_abi): New function.
(aarch64_function_arg_regno_p): Update to use aarch64_fndecl_abi.
(aarch64_output_mi_thunk): Likewise.
(aarch64_is_variant_pcs): Likewise.
(aarch64_set_current_function): Update to initialize pcs value.
* config/aarch64/aarch64.h (enum arm_pcs): Move location earlier in
file.
(machine_function) Add pcs value.
supers1ngular [Thu, 11 Dec 2025 14:27:09 +0000 (06:27 -0800)]
[PATCH v2 1/4] openmp: Bump Version from 4.5 to 5.2 (1/4)
Bumps OpenMP from 4.5 (201511) to 5.2 (202111), with deprecation and
test support to 5.1 (202011). Adds new tests and a new warning.
Suppresses deprecation warnings in all relevant tests and removes
suppression pragmas visible outside of the testsuite. Additionally
implements new warning in the relevant frontends. Otherwise, cleans
up some whitespace and fixed a misspelled pragma in a testcase. Also
fixes an indentation error.
Eric Botcazou [Thu, 11 Dec 2025 09:02:35 +0000 (10:02 +0100)]
i386: Fix and rework Windows TLS support
The compiler can emit invalid movabs instructions at -O0 for TLS accesses in
64-bit mode on Windows, for example with the attached testcase:
eric@fomalhaut:~/build/gcc/x86_64-w64-mingw32> gcc/xgcc -Bgcc -c struct-2.c
/tmp/ccOM8wdd.s: Assembler messages:
/tmp/ccOM8wdd.s:34: Error: operand type mismatch for `movabs'
This fixes the issue by leveraging the existing pic_32bit_operand predicate,
and fixing an oversight present in it for a couple of decades. The patch
also reworks the support to make use of the get_thread_pointer machinery as
for other platforms, of more comments and of shorter lines.
gcc/
PR target/80881
* config/i386/i386.h (DEFAULT_TLS_SEG_OFFSET): New define.
* config/mingw/mingw32.h (DEFAULT_TLS_SEG_OFFSET): Likewise.
* config/i386/i386.cc (ix86_tls_index): Fix long line.
(legitimize_tls_address): Use get_thread_pointer, add comments and
fix long lines.
* config/i386/i386.md (*load_tp_<mode>): Use DEFAULT_TLS_SEG_OFFSET
(*load_tp_x32_zext): Likewise.
(*add_tp_<mode>): Likewise.
(*add_tp_x32_zext): Likewise.
* config/i386/predicates.md (pic_32bit_operand): Fix oversight.
(symbolic_operand): Accept UNSPEC_SECREL32 with or without offset.
Mark Wielaard [Thu, 11 Dec 2025 10:15:46 +0000 (11:15 +0100)]
libatomic: Regenerate Makefile.in
After regeneration in commit e5d853bbe9b0 ("Factor out thread model
detection with new `GCC_AC_THREAD_MODEL` macro") some whitespace was
removed from the Makefile.in files under libatomic. Fix this by
regenerating them again.
Alexandre Oliva [Wed, 10 Dec 2025 23:56:17 +0000 (20:56 -0300)]
x86: improve lea peepholes
gcc.target/i386/lea-3.c fails on ia32 with PIE enabled by default.
There are two reasons for that:
- setting up the PIC register requires one addl instruction, and the
testcase wants none
- the expected lea-combining peephole doesn't get applied for two
reasons:
-- the second insn of the pair that could be turned into a single lea
doesn't clobber CC, but the existing peephole2 requires an add with
such a clobber
-- the first and second insns set different regs, and the existing
peephole2 requires them to be the same
Add extra peephole2s for when the second insn doesn't clobber CC, and
for when the first set reg is different, but it dies at the second
insn.
Adjust lea-3.c to run with -fno-PIE, and add lea-4.c with -fPIE.
The last of the newly-added peephole2s, that enables lea-4.c to pass,
also hits during an i686-linux-gnu bootstrap (without PIE enabled),
while building shared libraries for the target. I haven't been able
to exercise the other 2, but I haven't tried very hard, and I see no
why they couldn't possibly hit, so I left them in.
for gcc/ChangeLog
* config/i386/i386.md (lea peephole2): Add 3 new variants.
for gcc/testsuite/ChangeLog
* gcc.target/i386/lea-3.c: Add -fno-PIE.
* gcc.target/i386/lea-4.c: New, with -fPIE.
Jakub Jelinek [Wed, 10 Dec 2025 17:07:02 +0000 (18:07 +0100)]
vect-generic: Fix expand_vector_mult [PR123069]
The r16-5095 PR122065 change added build_int_cst call on vector types.
That is never correct, it ICEs already on the TYPE_PRECISION used at the
start of wide_int_to_tree_1.
Fixed by using build_zero_cst instead.
2025-12-10 Jakub Jelinek <jakub@redhat.com>
Andrew Pinski <andrew.pinski@oss.qualcomm.com>
PR middle-end/123069
* tree-vect-generic.cc (expand_vector_mult): Use
build_zero_cst (vectype) instead of build_int_cst (vectype, 0).
Jose E. Marchesi [Wed, 10 Dec 2025 03:30:54 +0000 (04:30 +0100)]
a68: add entry for OPT_L in algol68/lang.opt
We need to handle OPT_L in ga68 in order to add the specified
directories to the modules search path. This patch adds the necessary
entry in algol68/lang.opt.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog
Jose E. Marchesi [Wed, 10 Dec 2025 03:30:37 +0000 (04:30 +0100)]
a68: do not try extensionless packet files in a68_get_packet_exports
This commit makes ga68 to not look to exports data in files without
extensions, i.e. to not look in a file `foo' for packet Foo. The files
to try are: first foo.m68, then libfoo.so, then libfoo.a, finally
foo.o.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog
* a68-imports.cc (a68_try_packet_in_directory): do not try
extensionless packet files.
This commit fixes the asserts in a68_loer_char_mult3 so it expects
either int*char or char*int. It also expands the mult-char-1.a68
testcase to cover this case.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog
Since the standard library doesn't preclude an #include of a standard
library header from bringing in declarations from other headers, we can
translate an #include of any of the importable headers as an import of
<bits/stdc++.h>.
To reduce the amount of C++ standard knowledge encoded in libcpp, I extend
the translate_include callback to allow it to suggest an alternate header to
try translating. It's a bit awkward to bounce back and forth, but this
seems like the right division of responsibilities.
* module.cc (maybe_translate_include): Suggest <bits/stdc++.h>
as an alternate for importable standard library headers.
(importable_headers, is_importable_header): New.
gcc/ChangeLog:
* doc/invoke.texi (C++ Modules): Remove standard library header
units from missing pieces, mention importable header redirection.
gcc/testsuite/ChangeLog:
* g++.dg/modules/compile-std1.C: Test <vector> translation.
Jason Merrill [Wed, 10 Dec 2025 09:32:59 +0000 (17:32 +0800)]
c++: clean up gcms from compile-std1.C
I noticed that the .gcms from compile-std1.C were sticking around and
confusing other tests; this patch enhances dg-module-cmi to understand
<header> and adds the appropriate directives to the test.
Rainer Orth [Wed, 10 Dec 2025 08:24:53 +0000 (09:24 +0100)]
libsanitizer: Restore local sanitizer_redefine_builtins.h patch
The recent libsanitizer update broke the Solaris/SPARC build with the
native assembler: many files don't compile any longer like
/usr/bin/as: "/var/tmp//ccYsT60a.s", line 5: error: unknown opcode ".set"
/usr/bin/as: "/var/tmp//ccYsT60a.s", line 5: error: statement syntax
/usr/bin/as: "/var/tmp//ccYsT60a.s", line 6: error: unknown opcode ".set"
/usr/bin/as: "/var/tmp//ccYsT60a.s", line 6: error: statement syntax
/usr/bin/as: "/var/tmp//ccYsT60a.s", line 7: error: unknown opcode ".set"
/usr/bin/as: "/var/tmp//ccYsT60a.s", line 7: error: statement syntax
This happens because sanitizer_common/sanitizer_redefine_builtins.h lost
a local patch that guards use of .set in asm by HAVE_AS_SYM_ASSIGN.
This patch restores that patch.
Although the Darwin assembler accepts .set (thus HAVE_AS_SYM_ASSIGN is
defined), the __APPLE__ guard is kept to guard against the link failures
that prompted its upstreadm addition in LLVM commit
gcc/testsuite:
* g++.dg/lookup/extern-c-redecl3.C (pid_t): Define.
Use it for fork return type.
terms of __builtin_fork.
* g++.dg/pid_t-1.C: New test.
* gcc.dg/pid_t-1.c: Likewise.
John Ericson [Tue, 9 Dec 2025 22:06:51 +0000 (22:06 +0000)]
Move NO_PIE_CFLAGS logic from gcc to libgcc
My goal is to be able to build libgcc cleanly in isolation --- today one
needs to figure `make ...` misc things in the gcc subdir.
Following Andrew Pinski's suggestions in
https://gcc.gnu.org/pipermail/gcc-patches/2025-July/689683.html, this
commit moves the NO_PIE_CFLAGS logic.
gcc/ChangeLog:
* Makefile.in:: Remove NO_PIE_CFLAGS logic, since it is now in
libgcc.
* configure: Regenerate.
* configure.ac: Remove the enable_default_pie substitution, since
libgcc now has its own logic.
libgcc/ChangeLog:
* Makefile.in: Define NO_PIE_CFLAGS make variable via autoconf
substitution.
* configure: Regenerate.
* configure.ac: New configure check to define NO_PIE_CFLAGS
using the algorithm Andrew asked for in the linked mail.
Suggested-by: Andrew Pinski <quic_apinski@quicinc.com> Signed-off-by: John Ericson <git@JohnEricson.me>
John Ericson [Tue, 9 Dec 2025 22:06:48 +0000 (22:06 +0000)]
Factor out thread model detection with new `GCC_AC_THREAD_MODEL` macro
This macro deduplicates the
$CC -v 2>&1 | sed -n 's/^Thread model: //p'
check that was occurring in various runtime libs.
Additionally, as a bit of an Easter egg, this also allows overriding
what the compiler would return by setting the
`gcc_cv_target_thread_file` cache variable first. I admit that it is in
fact this Easter egg that led me to write the patch. The use-case for it
is for making multilib builds where the library sets do not all share
the same thread model easier. See also `THREAD_MODEL_SPEC` for more
about the varying thread models use-case.
Arguably one could could try to define on `THREAD_MODEL_SPEC` on more
platforms (besides e.g. AIX) but the ramifications of this are a bit
unclear. Setting `gcc_cv_target_thread_file` directly is a "low tech"
solution that will work for now for sure. Of course, since setting a
cache variable like this a hacky trick, I will not expect this to be at
all stable/guaranteed to work, going forward.
Thanks to Arsen who on IRC discussed these things with me, including in
particular making it a cache var not `--with-model` flag, to not
prematurely foster expectations that this is stable.
Luc Grosheintz [Mon, 8 Dec 2025 20:23:46 +0000 (21:23 +0100)]
libstdc++: Set __cpp_lib_submdspan to 202411.
The submdspan feature is complete and this commit sets the feature
testing macros accordingly. Also makes the feature testing macro
submdspan depend on constant_wrapper.
Also changes the value of the internal feature testing macro for padded
layouts to 202403.
libstdc++-v3/ChangeLog:
* include/bits/version.def (padded_layouts): Set to 202403.
(submdspan): Set to 202411 add dependency.
* include/bits/version.h: Regenerate.
Reviewed-by: Tomasz KamiĆski <tkaminsk@redhat.com> Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
Robin Dapp [Tue, 9 Dec 2025 12:07:36 +0000 (13:07 +0100)]
vect: Reset using_select_vl_p before starting over [PR123074].
In the PR we ICE accessing the loop lens in
vect_get_loop_variant_data_ptr_increment when building 510.parest.
This function only gets called when we use SELECT_VL for the loop
control, however during initialization of the loop lens partial
vectors, a prerequisite for SELECT_VL, was false while using_select_vl
was true. We reset using_partial_vectors when restarting the analysis
after forcing single-lane SLP but don't reset using_select_vl.
Pan Li [Mon, 8 Dec 2025 12:45:56 +0000 (20:45 +0800)]
RISC-V: Combine vec_duplicate + vmslt.vv to vmslt.vx on GR2VR cost
This patch would like to combine the vec_duplicate + vmslt.wv to the
vmslt.vx. From example as below code. The related pattern will depend
on the cost of vec_duplicate from GR2VR. Then the late-combine will
take action if the cost of GR2VR is zero, and reject the combination
if the GR2VR cost is greater than zero.
Assume we have asm code like below, GR2VR cost is 0.
Richard Biener [Mon, 8 Dec 2025 13:36:58 +0000 (14:36 +0100)]
target/121230 - x86 vector CTOR cost with 387 math
The following adjusts costing of vector construction from scalars for
FP modes which with 387 math can reside in FP regs which need spilling
to be reloaded to XMM. I've played on the safe side with mixed
SSE/387 math.
PR target/121230
* config/i386/i386.cc (ix86_vector_costs::add_stmt_cost):
With FP mode and 387 math cost spill/reload.
Luc Grosheintz [Mon, 8 Dec 2025 20:23:41 +0000 (21:23 +0100)]
libstdc++: Implement submdspan and submdspan_mapping for layout_left. [PR110352]
Implements `submdspan` and `submdspan_mapping` for layout_left as
described in P3663 (Future proofing mdspan).
When computing the offset of the submdspan, one must check that the
lower bound of the slice range isn't out-of-range. There's a few
cases when the lower bound is never out-of-range:
- full_extent and exts.extent(k) != 0,
- collapsing slice types.
If those conditions are known to hold, no checks are generated.
Similarly, if all slices are full_extent, there's no need to call
mapping(0,...,0) for standardized mappings.
The implementation prepares to use the symmetry between layout_left and
layout_right and introduces concepts like a "layout side", i.e. left,
right or unknown/strided.
The tests use an iterator to replace nested for-loops. Which also makes
it easier to write the core test logic in a rank-independent manner.
PR libstdc++/110352
libstdc++-v3/ChangeLog:
* include/std/mdspan (__mdspan::__is_submdspan_mapping_result)
(__mdspan::__submdspan_mapping_result, __mdspan::__fwd_prod)
(__mdspan::__acceptable_slice_type, __mdspan::__slice_begin)
(__mdspan::__suboffset, __mdspan::_LayoutSide, __mdspan::__mapping_side)
(__mdspan::_StridesTrait, __mdspan::__substrides_generic)
(__mdspan::__substrides_standardized, __mdspan::__substrides)
(__mdspan::__is_unit_stride_slice, __mdspan::_SliceKind)
(__mdspan::__make_slice_kind, __mdspan::__make_slice_kind_array)
(__mdspan::__is_block, __mdspan::__padded_block_begin_generic)
(__mdspan::__padded_block_begin, __mpdspan::_SubMdspanMapping)
(__mdspan::__submdspan_mapping_impl): Define.
(__mdspan::__dynamic_slice_extent, __mdspan::__static_slice_extent)
(__mdspan::__subextents): Move earlier in the file.
(layout_left::mapping::submdspan_mapping, __mdspan::__sliceable_mapping)
(__mdspan::__submapping, submdspan): Define.
* src/c++23/std.cc.in: Add submdspan.
* testsuite/23_containers/mdspan/submdspan/generic.cc: New test.
* testsuite/23_containers/mdspan/submdspan/selections/left.cc:
Instantiate selection tests for layout_left.
* testsuite/23_containers/mdspan/submdspan/selections/testcases.h: Generic
tests different selections.
* testsuite/23_containers/mdspan/submdspan/submdspan_mapping.cc: New test.
* testsuite/23_containers/mdspan/submdspan/submdspan_neg.cc: New test.
Reviewed-by: Tomasz KamiĆski <tkaminsk@redhat.com> Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
Luc Grosheintz [Mon, 8 Dec 2025 20:23:40 +0000 (21:23 +0100)]
libstdc++: Silence warning in mdspan.
Splitting the tests for submdspan triggered a compiler warning. This
commit changes the implementation of __dynamic_extents. In particular,
how the span is created. Functionally, the two are equivalent.
libstdc++-v3/ChangeLog:
* include/std/mdspan (_ExtentsStorage::_M_dynamic_extents):
Create span from pointer + size, not begin and end iterators.
Reviewed-by: Tomasz KamiĆski <tkaminsk@redhat.com> Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
Andrew Stubbs [Mon, 8 Dec 2025 16:18:59 +0000 (16:18 +0000)]
amdgcn: Adjust failure mode for gfx908 USM
Unified Shared Memory does not appear to work well on gfx908, which is why we
disabled xnack by default. For this reason it makes sense to inform the user
as compile time, but this is causing trouble in the testsuite which assumes
that USM only fails at runtime.
This patch changes the gfx908 compile time message to a warning only (in case
some other target does this differently), and prevents the tests from
attempting to run in host-fallback mode (given that that is not what they are
trying to test). It also changes the existing warning to only fire once.
The patch assumes that effective target "omp_usm" also implies self-maps.
gcc/ChangeLog:
* config/gcn/gcn.cc (gcn_init_cumulative_args): Only warn once.
Use "required" instead of "enabled" in the warning.
* config/gcn/mkoffload.cc (process_asm): Warn, don't error.
Use "required" instead of "on" in the warning.
Jakub Jelinek [Tue, 9 Dec 2025 09:22:26 +0000 (10:22 +0100)]
c: Reject vector type bit-fields [PR123018]
The following testcase ICEs since checking has been added to TYPE_PRECISION
macro. check_bitfield_type_and_width is called when attributes haven't
been applied to the bit-field decl yet and so it still has INTEGER_TYPE
type, while at finish_struct time it already has VECTOR_TYPE.
The following patch just repeats the check_bitfield_type_and_width
in there.
Another option would be let handle_vector_size_attribute check for
bit-fields and error out there.
2025-12-09 Jakub Jelinek <jakub@redhat.com>
PR c/123018
* c-decl.cc (finish_struct): Diagnose bit-fields with vector type.
Robin Dapp [Tue, 25 Nov 2025 09:34:55 +0000 (10:34 +0100)]
fold: Elide MASK_LEN_LOAD/STORE with zero length [PR122635].
This patch adds zero-length handling to gimple_fold_partial_store and
gimple_fold_partial_load and unifies them into
gimple_fold_partial_load_store.
It introduces a new function partial_load_store_mask_state that
returns
MASK_ALL_INACTIVE,
MASK_ALL_ACTIVE, or
MASK_UNKNOWN.
This result is used to either replace a load with its else value and
elide a store (when all inactive), turn the load/store into a regular
mem ref (all_active), or do nothing.
PR tree-optimization/122635
gcc/ChangeLog:
* gimple-fold.cc (enum mask_load_store_state): New enum.
(gimple_fold_partial_load_store_mem_ref): Only fold
"all active" loads/stores.
(partial_load_store_mask_state): New function to compute mask
state.
(gimple_fold_partial_load): Remove.
(gimple_fold_partial_load_store): New function.
(gimple_fold_partial_store): Remove.
(gimple_fold_call): Use new function.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/sve/pfalse-store.c: Expect more elided
stores.
* gcc.target/riscv/rvv/autovec/pr122635-1.c: New test.
* gcc.target/riscv/rvv/autovec/pr122635-2.c: New test.
* gcc.target/powerpc/p9-vec-length-epil-8.c: Expect two lxvl
less.
Robin Dapp [Fri, 28 Nov 2025 15:24:38 +0000 (16:24 +0100)]
optabs: Add else operand to LEN_LOAD.
When adding else operands to maskload and friends we didn't bother to do
the same for len_load (as we never use the residual elements anyway).
In order to simplify handling in gimple-fold, this patch adds the else
operand now. Both, power and s390, zero out inactive elements.
gcc/ChangeLog:
* config/rs6000/predicates.md (lxvl_else_operand): New
predicate.
* config/rs6000/vsx.md: Add else operand.
* config/s390/predicates.md (vll_else_operand): New predicate.
* config/s390/vector.md: Add else operand.
* doc/md.texi: Document else operand.
* internal-fn.cc (internal_fn_len_index): Adjust IFN_LEN_LOAD.
(internal_fn_else_index): Add IFN_LEN_LOAD.
* optabs-tree.cc (target_supports_len_load_store_p): Get else
value for len_load.
* tree-vect-stmts.cc (vectorizable_load): Pun the else value
type.
Robin Dapp [Fri, 14 Nov 2025 14:50:05 +0000 (15:50 +0100)]
RISC-V: -mmax-vectorization.
This adds an -mmax-vectorization option to riscv, a verbatim copy from
aarch64. It is an option for vector code analysis. Internally it increases
scalar costs by a large factor so every vector approach will be
profitable. As opposed to -fno-vect-cost-model, we will still compare
the vector approaches amongst each other, though.
In order to handle this argument without an '=' I needed to change the
parsing flow slightly.
gcc/ChangeLog:
* config/riscv/riscv-target-attr.cc (riscv_target_attr_parser::handle_max_vect):
New parser entry.
(riscv_target_attr_parser::update_settings): Set max-vect
option.
(riscv_process_one_target_attr): Change null-arg handling.
* config/riscv/riscv.cc (riscv_override_options_internal): Set
max-vect option.
* config/riscv/riscv.opt: Add -mmax-vectorization option.
* doc/extend.texi: Document new option.
* doc/invoke.texi: Ditto.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/max-vect-1.c: New test.
* gcc.target/riscv/rvv/autovec/max-vect-2.c: New test.
Robin Dapp [Mon, 8 Dec 2025 09:22:51 +0000 (10:22 +0100)]
RISC-V: Add more mode_idx attributes [PR123022].
Similar to 116149 we use the mode size of operand MODE_IDX but that
one could refer to a broadcast scalar. Use operand 3 for scalar
broadcast patterns instead.
PR target/123022
gcc/ChangeLog:
* config/riscv/vector.md: Add mode_idx attribute.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/pr123022-2.c: New test.
* gcc.target/riscv/rvv/autovec/pr123022.c: New test.
Robin Dapp [Mon, 20 Oct 2025 08:47:45 +0000 (10:47 +0200)]
RISC-V: Implement mask reduction.
This implements mask reductions by first counting the bits in the mask
(vcpop.m) and then comparing the resulting scalar against 0 or len.
gcc/ChangeLog:
* config/riscv/autovec.md (reduc_sbool_and_scal_<mode>): New
expander.
(reduc_sbool_ior_scal_<mode>): Ditto.
(reduc_sbool_xor_scal_<mode>): Ditto.
* config/riscv/riscv-protos.h (expand_mask_reduction): Declare.
* config/riscv/riscv-v.cc (expand_mask_reduction): New function.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-1-run.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-1.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-2-run.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-2.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-3-run.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-3.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-4-run.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-4.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-5-run.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-5.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-6-run.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-6.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-7-run.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-7.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-8-run.c: New test.
* gcc.target/riscv/rvv/autovec/reduc/reduc-bool-8.c: New test.
Nathaniel Shead [Sun, 7 Dec 2025 12:17:15 +0000 (23:17 +1100)]
c++: Non-inline temploid friends should still be COMDAT [PR122819]
Modules allow temploid friends to no longer be implicitly inline, as
functions defined in a class body will not be implicitly inline if
attached to a named module.
This requires us to clean up linkage handling a little bit, mostly by
replacing usages of 'DECL_TEMPLATE_INSTANTIATION' with
'DECL_TEMPLOID_INSTANTIATION' when determining if an entity has vague
linkage.
PR c++/122819
gcc/cp/ChangeLog:
* decl.cc (start_preparsed_function): Use
DECL_TEMPLOID_INSTANTIATION instead of
DECL_TEMPLATE_INSTANTIATION to check vague linkage.
* decl2.cc (vague_linkage_p): Likewise.
(c_parse_final_cleanups): Simplify condition.
* semantics.cc (expand_or_defer_fn_1): Also check for temploid
friend functions.
gcc/testsuite/ChangeLog:
* g++.dg/modules/tpl-friend-22.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
This fixes a regression introduced with r16-5258-g1d8e2d51e5c5cb.
With GCC 12+, we would not merge forwarders (with phis, vops included),
this meant that after the last cddce, degenerate phis would stay not
merged which allowed for better expansion. Now after my patch, the forwarder
block would be removed and get worse expansion. This fixes the problem
by creating the forwarder blocks in "optimized" and no other cleanupcfg
is called afterwards.
Oh this also fixes the problem at -O1 which was missed because the agressive
version of dce was not done at -O1.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/46555
gcc/ChangeLog:
* tree-cfgcleanup.cc (execute_cleanup_cfg_post_optimizing):
Don't set todo to include cleanupcfg; do it manually.
Call make_forwarders_with_degenerate_phis if optimizing.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pr46555.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Andrew Pinski [Sat, 6 Dec 2025 09:05:47 +0000 (01:05 -0800)]
cfg: Move make_forwarders_with_degenerate_phis to tree-cfg
This moves make_forwarders_with_degenerate_phis to tree-cfg.cc
from tree-ssa-dce.cc to be able to use in a different pass.
Bootstrapped and tested on x86_64-linux-gnu.
gcc/ChangeLog:
* tree-ssa-dce.cc (sort_phi_args): Move to tree-cfg.cc.
(make_forwarders_with_degenerate_phis): Move to tree-cfg.cc.
(perform_tree_ssa_dce): Update for the updated return type
of make_forwarders_with_degenerate_phis.
* tree-cfg.cc (sort_phi_args): Moved from tree-ssa-dce.cc.
(make_forwarders_with_degenerate_phis): Moved from tree-ssa-dce.cc.
Update return type to bool and return true if an edge was split.
* tree-cfg.h (make_forwarders_with_degenerate_phis): New decl.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Harald Anlauf [Mon, 8 Dec 2025 19:48:29 +0000 (11:48 -0800)]
Fortran: [PR123025] Catch Old-style character declarations.
Before this patch we missed the two cases here:
character*5 string5 ! Gives obsolescent message
character*(5) string5const ! Silent with constant
character*(2+3) string5expr ! Silent with expression
PR fortran/123025
gcc/fortran/ChangeLog:
* decl.cc (match_char_length): Add a check for the
obsolete '*' style of character declarations in the
alternate branch of checking so we dont miss two
use cases:
gcc/testsuite/ChangeLog:
* gfortran.dg/assumed_charlen_dummy.f90: These tests failed
with the change because of the default -pedantic option
used by the dg.exp mechanisms. Overide this default.
* gfortran.dg/automatic_char_len_1.f90: Ditto.
* gfortran.dg/entry_23.f: Ditto.
* gfortran.dg/finalize_59.f90: Dito.
* gfortran.dg/g77/f90-intrinsic-bit.f: Ditto.
* gfortran.dg/g77/f90-intrinsic-mathematical.f: Ditto.
* gfortran.dg/g77/f90-intrinsic-numeric.f: Ditto.
* gfortran.dg/g77/intrinsic-unix-bessel.f: Ditto.
* gfortran.dg/g77/intrinsic-unix-erf.f: Ditto.
* gfortran.dg/initialization_9.f90: Ditto.
* gfortran.dg/intrinsic_actual_4.f90: Ditto.
* gfortran.dg/namelist_assumed_char.f90: Ditto.
* gfortran.dg/pr15140.f90: Ditto.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
Egas Ribeiro [Mon, 8 Dec 2025 18:04:42 +0000 (18:04 +0000)]
c++: Document why TARGET_EXPR is not handled in tsubst_expr
TARGET_EXPR represents semantic temporary objects and is deliberately
not handled by tsubst routines, which expect syntactic templated trees.
Add a comment and gcc_unreachable to make this explicit.
gcc/cp/ChangeLog:
* pt.cc (tsubst_expr): Add TARGET_EXPR case with explanatory
comment and gcc_unreachable.
Signed-off-by: Egas Ribeiro <egas.g.ribeiro@tecnico.ulisboa.pt> Reviewed-by: Patrick Palka <ppalka@redhat.com>
Jonathan Wakely [Thu, 4 Dec 2025 14:45:53 +0000 (14:45 +0000)]
libstdc++: Implement P2404R3 relaxations to comparable_with concepts [PR122946]
This implements the C++23 proposal P2404R3 "Move-only types for
equality_comparable_with, totally_ordered_with, and
three_way_comparable_with". As agreed with the maintainers of libc++ and
MSVC STL, we treat this as a DR for C++20. It allows reasonable code to
compile which wasn't originally allowed in C++20, and only affects some
obscure subsumption cases for valid C++20 code.
libstdc++-v3/ChangeLog:
PR libstdc++/122946
* include/bits/version.def (concepts): Set value to 202207.
* include/bits/version.h: Regenerate.
* include/std/concepts (__comparison_common_type_with_impl)
(__comparison_common_type_with): New helper concepts.
(equality_comparable_with): Use __comparison_common_type_with.
* libsupc++/compare (three_way_comparable_with): Likewise.
(__glibcxx_want_concepts): Define to get __cpp_lib_concepts
here.
* testsuite/std/concepts/concepts.compare/move_only.cc: New
test.
Reviewed-by: Tomasz KamiĆski <tkaminsk@redhat.com>
Jonathan Wakely [Fri, 5 Dec 2025 20:54:32 +0000 (20:54 +0000)]
libstdc++: Extend __is_standard_integer to cover extended integer types
We have __is_signed_integer and __is_unsigned_integer traits which
should have been updated by r16-2190-g4faa42ac0dee2c when making
__int128 an extended integer type (for PR libstdc++/96710). Currently
they check whether the type is a signed integer type or an unsigned
integer type, or a cv-qualified version of one of those. This doesn't
match the standard's definition, which does not include cv-qualified
types. This change ensures that signed __int128 and unsigned __int128
are included in those traits in strict -std modes, and it removes the
use of remove_cv_t so that they are not true for cv-qualified types.
This makes the traits match the meaning of "signed integer type" and
"unsigned integer type" in the standard ([basic.fundamental]).
We also have an __is_standard_integer trait, which is true if either
__is_signed_integer or __is_unsigned_integer is true, but that's also
not a match for the definition in the standard. The definitions of
"signed integer type" and "unsigned integer type" include both standard
and extended integer types, so only saying "standard" in the trait name
is misleading (even before this change, because in non-strict -std modes
the __GLIBCXX_TYPE_INT_N_0 .. __GLIBCXX_TYPE_INT_N_3 types were always
included in the trait, and they aren't standard integer types).
This change renames __is_standard_integer to the more accurate
__is_signed_or_unsigned_integer. Because the set of signed and
unsigned integer types is the same as the set of standard and extended
integer types, the trait could instead have been renamed to
__is_standard_or_extended_integer. I think it's clearer and more
self-explanatory to avoid "standard and extended" and name it for the
signed and unsigned integer types.
N.B. we don't want to call it just __is_integer_type because the integer
types includes cv-qualified types and also bool and the character types
char, wchar_t, char16_t etc.
The consequences of redefining and renaming these traits are small, and
only positive.
Apart from the uses in the __is_standard_integer trait, the only other
uses of __is_signed_integer and __is_unsigned_integer are in <format>
and those uses are unaffected by this change to add 128-bit integers to
the traits. In both uses the type argument is already cv-unqualified,
and there is already explicit handling for 128-bit integers where that
is required.
The existing uses of __is_standard_integer can simply be changed to use
the new name. This does change the behaviour of those uses of the trait,
because the __is_signed_or_unsigned_integer trait now includes
128-bit integers in strict modes. However, that is a desirable change
that fixes some bugs. Specifically, the [utility.intcmp] functions such
as std::cmp_less and the [numeric.sat.arith] functions such as
std::add_sat did not support 128-bit integers in strict modes. Since the
standard says they should be enabled for all signed and unsigned integer
types (or equivalently, for all standard and extended integer types),
those functions should all support __int128 and unsigned __int128. That
is fixed by this change. Additionally, the same changes in <charconv>,
<mdspan>, and <stdckdint.h> enable the use of 128-bit integers for those
APIs in strict modes.
Finally, this also make a drive-by fix to the enable_if constraints for
the integer overloads of std::from_chars. That used remove_cv_t and so
enabled the overload for lvalue arguments of type const char, which
won't work and should not be enabled.
libstdc++-v3/ChangeLog:
* include/bits/intcmp.h: Replace all uses of
__is_standard_integer with __is_signed_or_unsigned_integer.
* include/bits/max_size_type.h: Fix outdated comment.
* include/bits/sat_arith.h: Replace all uses of
__is_standard_integer with __is_signed_or_unsigned_integer.
* include/c_compatibility/stdckdint.h: Replace all uses of the
__cv_unqual_signed_or_unsigned_integer_type concept with
__is_signed_or_unsigned_integer.
(__cv_unqual_signed_or_unsigned_integer_type): Remove.
* include/ext/numeric_traits.h: Fix outdated comment.
* include/std/charconv (from_chars): Replace use of
__is_standard_integer with __is_signed_or_unsigned_integer.
Do not enable for cv-qualified char.
* include/std/mdspan: Likewise.
* include/std/type_traits (__is_unsigned_integer): Include
unsigned __int128 in type list.
(__is_signed_integer): Include signed __int128 in type list.
(__is_standard_integer): Rename to ...
(__is_signed_or_unsigned_integer): ... this.
* testsuite/23_containers/mdspan/extents/ctor_ints.cc: Test
with 128-bit integers.
* testsuite/23_containers/mdspan/submdspan/strided_slice.cc:
Likewise.
* testsuite/20_util/integer_comparisons/extended.cc: New test.
* testsuite/26_numerics/saturation/extended.cc: New test.
* testsuite/26_numerics/stdckdint/extended.cc: New test.
Egas Ribeiro [Sun, 7 Dec 2025 23:35:00 +0000 (23:35 +0000)]
c++: Fix SFINAE for deleted explicit specializations [PR119343]
When checking a deleted explicit specialization in a SFINAE context,
we were incorrectly selecting a partial specialization because
resolve_nondeduced_context was calling mark_used. But resolving an
overload to a single function (per DR 115) does not constitute ODR-use,
so mark_used shouldn't be called there. Instead callers should call
mark_used or mark_single_function on the result to uniformly handle all
resolvable overloads (even non-template-id ones).
This turns out to fix the below testcase because it causes convert_to_void
for void(X::template g<0>) to properly propagate ODR-use failure (due to
deleted g<0>) and return error_mark_node instead of returning void_node.
Joseph Myers [Mon, 8 Dec 2025 17:02:22 +0000 (17:02 +0000)]
contrib: Set more site.exp variables in test_installed
Add support in contrib/test_installed for more variables (via
associated command-line options to the script) that gcc/Makefile.in
can set:
* ALT_CC_UNDER_TEST, ALT_CXX_UNDER_TEST and COMPAT_OPTIONS are used in
compat testing (against the same or a different compiler).
* The libiconv variable is used for testing iconv support for
particular character sets, and defaults to -liconv if not set in
site.exp, which is wrong on systems with iconv in libc; keep the
default, but add an option to override this.
Note that the dg-require-iconv testing is currently bogus in a cross
environment, and this patch does nothing to address that. The tests
using dg-require-iconv actually care about character set support on
the *host*, for character conversions carried out in the compiler,
and the libiconv setting put in site.exp by gcc/Makefile.in is a
*host* library setting. But dg-require-iconv /
check_iconv_available tests availability when compiling, linking and
executing for the *target*. If the host and target have close
enough to the same OS, this may work by accident, but otherwise it
will incorrectly enable / disable these tests based on target
information (but using a libiconv setting designed for the host)
when it should be based on host information.
* test_installed (--with-alt-cc=, --with-alt-cxx=)
(--with-compat-options=, --with-libiconv=): New options.
Eric Botcazou [Mon, 8 Dec 2025 16:47:56 +0000 (17:47 +0100)]
MinGW: Fix native TLS bug with -fdata-sections
The problem comes from a quirk of the GNU PE-COFF linker, which wants
to make sure that .tls$ZZZ is laid out last among the TLS sections,
but first globs all .tls$* sections together. The solution matches
Clang's output.
gcc/
PR target/80881
* config/mingw/winnt.cc (mingw_pe_unique_section): Put two dollar
signs for TLS sections after the prefix.
(mingw_pe_asm_named_section): Deal with all TLS sections uniformly.
gcc/testsuite/
* gcc.dg/tls/data-sections-1.c: New test.
Richard Biener [Mon, 8 Dec 2025 10:06:54 +0000 (11:06 +0100)]
tree-optimization/123040 - handle nary -> ifn simplification in VN
The following handles (by rejecting) simplifications that end up
turning a VN NARY operation into a call which would be a VN REFERENCE
and is unexpected and not handled.
PR tree-optimization/123040
* tree-ssa-sccvn.cc (vn_nary_build_or_lookup_1): Only insert
nary results.
libstdc++: Refactor _Variadic_union so _Unitialized<T, false> is not needed [PR112591].
The changes the _Variadic_union implementation, in a way that the
_Unitialized<T, false> partial specialization for non-trivial types is not
necessary.
This is simply done by separating the specialization for __trivially_destructible
being true and false, and for the later defining an empty destructor (similarly
as it was done using concepts).
We also reduce the number of specialization of _Variadic_union, so specialization
(int, int) is reused by (string, int, int) and (int, int). This is done by
initialization __trivially_destructible with conjunction of
is_trivially_destructible_v for remaining components. This is only necessary
for non-trivial (false) specialization, as if both _First and _Rest... are
trivially destructible, then _Rest must also be.
The above change does not regress the fix r14-7259-g2d55d94e5df389 for
template depth, and both before and after the change template depth is 266.
I have added dg-options to the 87619.cc to catch future regressions.
This also add test for PR112591.
PR libstdc++/112591
libstdc++-v3/ChangeLog:
* include/std/variant (_Variadic_union): Separate specializations for
for union of only trivially destructible types (true as first template
argument). Unconditionally define destructor for _Variadic_union<false,
_First, _Rest...>.
* testsuite/20_util/variant/87619.cc: Add limit for the template depth.
* testsuite/20_util/variant/112591.cc: New test.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz KamiĆski <tkaminsk@redhat.com>
Josef Melcr [Mon, 8 Dec 2025 08:21:38 +0000 (09:21 +0100)]
ipa/122798: Adjust local and address_taken flags for callback clones.
Hi,
previously, clones of callback functions had their local flag set.
Because callback edges are direct rather than indirect, GCC falsely
assumes that their callsites are available and that it can change their
ABI, leading to segfaults. This patch fixes that. Additionally, this
patch fixes a check in redirect_callee for clearing the address_taken
flag.
PR ipa/122798
gcc/ChangeLog:
* cgraph.cc (cgraph_edge::redirect_callee): Use
iterate_referring instead of referred_to_p.
* cgraphclones.cc (set_new_clone_decl_and_node_flags): Set local
to true iff the node does not have its address taken.
Jonathan Wakely [Fri, 5 Dec 2025 15:59:23 +0000 (15:59 +0000)]
libstdc++: Remove redundant diagnostic pragmas from <bits/iterator_concepts.h>
Since r16-2190-g4faa42ac0dee2c this header no longer mentions __int128
explicitly, because it's just handled like other integer types now. So
we don't need the diagnostic pragmas to disables pedwarns for referring
to __int128.
Richard Biener [Sun, 7 Dec 2025 10:30:48 +0000 (11:30 +0100)]
tree-optimization/123038 - FFS/CTZ pattern incompatible with reductions
The pattern ends up using the argument more than one time which
isn't supported. When FFS directly maps to CTZ + 1 it works though.
PR tree-optimization/123038
* tree-vect-patterns.cc (vect_recog_ctz_ffs_pattern): Reject
pattern for reductions when the call argument is used multiple
times.
Tamar Christina [Mon, 8 Dec 2025 09:12:01 +0000 (09:12 +0000)]
AArch64: fix subregs in boolean reductions [PR123026]
The Adv. SIMD boolean reduction patterns were accidentally
overriding one of the input arguments. This fixes it and
removes unneeded intermediate moves around the subreg type
castings.
Tamar Christina [Mon, 8 Dec 2025 09:10:58 +0000 (09:10 +0000)]
vect: move the condition down into the loop checking every scalar load [PR122868]
As Richi suggested this moves the check into the loop so we check every load.
I had initially not done this because I figured the loads would be treated as a
group anyway and the group would be valid or not as a whole. But for invariants
they could be a group, but not all the loads within range of a known bounds.
gcc/ChangeLog:
PR tree-optimization/122868
* tree-vect-stmts.cc (vectorizable_load): Move check for invariant loads
down into the loop.
H.J. Lu [Mon, 8 Dec 2025 05:29:59 +0000 (13:29 +0800)]
x86: Don't allow 2 volatile memory references
Don't allow 2 volatile memory references in *<avx512>_cmp<mode>3_dup_op
so that gcc.target/i386/avx2-vpcmpeqq-1.c will generate 2 loads when
-march=cascadelake is used.
Eric Botcazou [Sun, 7 Dec 2025 22:40:25 +0000 (23:40 +0100)]
Ada: Fix wrong Accum_Type inferred for a reduction expression
This was reported as a regression in GCC 14: the compiler resolves
Accum_Type to Positive for a reduction expression whose "expected
subtype" is Positive, which means that 0 cannot be used as initial
value in the expression:
Sum : Positive := V'Reduce ("+", 0);
without always raising Constraint_Error as run time. That's not the
intent according to T. Taft in
https://forum.ada-lang.io/t/regression-in-gnat-14/890
so this changes the resolution to use the base type (Integer) instead.
gcc/ada/
PR ada/115349
* sem_attr.adb (Resolve_Attribute) <Attribute_Reduce>: Use the base
type as Accum_Type if the reducer is an operator from Standard and
the type is numeric. Use the type of the first operand for other
operators. Streamline the error message given for limited types.
Jason Merrill [Sun, 7 Dec 2025 07:34:15 +0000 (15:34 +0800)]
libcpp: adjust _cpp_file accessors
Back in r78875 mrs added cpp_get_path/dir accessors for _cpp_file in order
to interface with the darwin framework system. But now I notice that the
latter duplicates the better-named _cpp_get_file_dir, and I'm inclined to
rename the former to match.
Perhaps we should drop the initial underscore since these are no
longer internal interfaces; OTOH, _cpp_hashnode_value and
_cpp_backup_tokens still have the initial underscore in cpplib.h.
H.J. Lu [Fri, 24 Oct 2025 01:00:59 +0000 (09:00 +0800)]
Add -ffuse-ops-with-volatile-access
Volatile memory can be used as source operand for any operations. Add
-ffuse-ops-with-volatile-access to fuse operations with volatile memory
reference and update simplify_binary_operation_1 to keep PLUS for 2
volatile memory references. On x86, this optimizes
extern volatile int bar;
int
foo (int z)
{
z *= 123;
return bar + z;
}
into
foo:
imull $123, %edi, %eax
addl bar(%rip), %eax
ret
Alexandre Oliva [Sun, 7 Dec 2025 01:08:04 +0000 (22:08 -0300)]
cselib: dump_cselib_* fixes
Rework dump_cselib_table to not crash when cselib_preserved_hash_table
is not allocated, and to remove the extraneous indirection from
dump_cselib_val that made it inconvenient to call from a debugger.
for gcc/ChangeLog
* cselib.cc (dump_cselib_val): Split out of and rename to...
(dump_cselib_val_ptr): ... this.
(dump_cselib_table): Adjust. Skip cselib_preserved_hash_table
when not allocated.
Alexandre Oliva [Sat, 6 Dec 2025 23:11:46 +0000 (20:11 -0300)]
add fusage for non-ACCUMULATE_OUTGOING_ARGS calls [PR122947]
Since we may delete stores that are found to be redundant in
postreload cse, we need cselib to invalidate argument stores at calls,
and to that end we need CALL_INSN_FUNCTION_USAGE to mention all MEM
stack space that may be legitimately modified by a const/pure callee,
i.e., all arguments passed to it on the stack.
When ACCUMULATE_OUTGOING_ARGS, each on-stack argument gets its own
usage information, but when it's not, each argument is pushed
incrementally, without precomputed stack slots.
Since we only mentioned such precomputed stack slots in
CALL_INSN_FUNCTION_USAGE, non-ACCUMULATE_OUTGOING_ARGS configurations
miss the stack usage data, and cselib fails to invalidate the stores.
Stores in such slots are anonymous, and they often invalidate other
anonymous slots, even part of the same object, but as the testcase
demonstrates, we may occasionally be unlucky that consecutive calls
have the stores to multi-word objects reordered by scheduling in such
a way that the last store for the first call survives the call in the
cselib tables, and then it is found to be redundant with the first
store for the subsequent call, as in the testcase.
So, if we haven't preallocated outgoing arguments for a call (which
would give us preassigned stack slots), and we have used any stack
space, add function call usage covering the entire stack range where
arguments were stored.
for gcc/ChangeLog
PR rtl-optimization/122947
* calls.cc (expand_call): Add stack function usage in
non-ACCUMULATE_OUTGOING_ARGS configurations.
Alexandre Oliva [Sat, 6 Dec 2025 23:11:42 +0000 (20:11 -0300)]
[riscv] avoid auipc overflow with large offsets [PR91420]
When computing an address plus a large offset on riscv64 with a
PC-relative sequence, we may hit the range limit for auipc and get a
relocation overflow, where on riscv32 the computation wraps around.
Since -mcmodel=medany requires the entire program to fit in a 2GiB
address range, a +/-1GiB+ offset added to an in-range symbol in a
barely-fitting program is more likely than not to be out-of-range.
Since such large constants are unlikely to come up by chance, separate
them from the symbol so as to avoid the relocation overflow.
for gcc/ChangeLog
PR target/91420
* config/riscv/riscv.cc (riscv_symbolic_constant_p): Require
offsets smaller than +/- 1GiB for PCREL symbols.
Denis Mazzucato [Sat, 6 Dec 2025 18:13:26 +0000 (19:13 +0100)]
Ada: Fix spurious warning if the reducer subprogram is a procedure
If the reducer is a function and the accumulator type isn't constrained,
at runtime the reduction will likely raise a Constraint_Error since the
reducer is repeatedly assigned to the accumulator variable (likely changing
its length). However, if the reducer is a procedure, no such assignment
occurs, and thus the runtime error only depends on the reducer logic.
This patch prevents the spurious warning in that case.
gcc/ada/
* sem_attr.adb (Resolve_Attribute): Check if the reducer is a
procedure before giving the warning.
Jeff Law [Sat, 6 Dec 2025 16:01:11 +0000 (09:01 -0700)]
Adjust expected output of new risc-v test
Just a minor update to Dimitar's patch for the RISC-V testcase.
The cfi directives are not emitted for the -elf configurations causing the new
test to fail. The cfi directives (and associated labels) don't seem relevant
to the test at hand, so this just drops them.
Jason Merrill [Sat, 6 Dec 2025 10:31:44 +0000 (18:31 +0800)]
libstdc++: add more #if to std.cc
compile-std1.C was breaking on arm-eabi because these interfaces aren't
declared. So for exporting let's check the same macros that control
declaring them.
Jakub Jelinek [Sat, 6 Dec 2025 10:08:05 +0000 (11:08 +0100)]
attribs: Use attribute_value_equal in decl_attributes
This is another thing discussed in the 1/9 Reflection thread,
also not dependent on reflection.
decl_attributes calls simple_cst_equal on TREE_VALUEs of the
current and preexisting attributes, but that is just a small
part of how attribute values should be compared.
The following patch fixes that.
2025-12-06 Jakub Jelinek <jakub@redhat.com>
* attribs.cc (decl_attributes): Use attribute_value_equal to
compare attribute values instead of simple_cst_equal.
Jakub Jelinek [Sat, 6 Dec 2025 10:07:18 +0000 (11:07 +0100)]
c++: is_late_template_attribute and tsubst_attribute fixes
This has been discussed in the 1/9 Reflection thread, but doesn't depend on
reglection in any way.
cp_parser_std_attribute calls lookup_attribute_spec as:
const attribute_spec *as
= lookup_attribute_spec (TREE_PURPOSE (attribute));
so with TREE_LIST where TREE_VALUE is attribute name and TREE_PURPOSE
attribute ns. Similarly c_parser_std_attribute. And for
attribute_takes_identifier_p those do:
else if (attr_ns == gnu_identifier
&& attribute_takes_identifier_p (attr_id))
and
bool takes_identifier
= (ns != NULL_TREE
&& strcmp (IDENTIFIER_POINTER (ns), "gnu") == 0
&& attribute_takes_identifier_p (name));
when handling std attributes (for GNU attributes they just call those
with the IDENTIFIER_NODE name.
is_late_template_attribute and tsubst_attribute pass to these functions
just get_attribute_name though, so handle attributes in all namespaces
as GNU attributes only, which means that lookup_attribute_spec can
return NULL or find a different attribute if it is not from gnu:: or
say standard attribute mapped to gnu::, or attribute_takes_identifier_p
can return true even for attributes for which it shouldn't.
I thought about changing attribute_takes_identifier_p to take optionally
TREE_LIST, but that would mean handling it in the target hooks too and
they only care about GNU attributes right now, so given the above
parser.cc/c-parser.cc snippets, the following patch just follow
what they do.
2025-12-06 Jakub Jelinek <jakub@redhat.com>
* decl2.cc (is_late_template_attribute): Call lookup_attribute_spec
on TREE_PURPOSE (attr) rather than name. Only call
attribute_takes_identifier_p if get_attribute_namespace (attr) is
gnu_identifier.
* pt.cc (tsubst_attribute): Only call attribute_takes_identifier_p
if get_attribute_namespace (t) is gnu_identifier.
Paul Thomas [Sat, 6 Dec 2025 08:00:21 +0000 (08:00 +0000)]
Fortran: [PDT] Mismatched types with same name in assignment [PR122670]
2025-12-06 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/122670
* decl.cc (gfc_get_pdt_instance): Ensure that, in an interface
body, PDT instances imported implicitly if the template has
been explicitly imported.
* module.cc (read_module): If a PDT template appears in a use
only statement, implicitly add the instances as well.
gcc/testsuite
PR fortran/122670
* gfortran.dg/pdt_74.f03: New test.
Paul Thomas [Sat, 6 Dec 2025 07:54:39 +0000 (07:54 +0000)]
Fortran: ALLOCATE with array-valued MOLD expression fails [PR122669]
2025-12-06 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/122669
* resolve.cc (resolve_allocate_deallocate): Mold expressions
with an array reference and a constant size must be resolved
for each allocate object.
gcc/testsuite
PR fortran/122669
* gfortran.dg/pdt_73.f03: New test.
Paul Thomas [Sat, 6 Dec 2025 07:51:21 +0000 (07:51 +0000)]
Fortran: [PDT] Unresolved component and generic binding [PR122578]
2025-12-06 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/122578
* primary.cc (gfc_match_varspec): Try to resolve a typebound
generic procedure selector expression to provide the associate
name with a type. Also, resolve component calls. In both cases,
make a copy of the selector expression to guard against changes
made by gfc_resolve_expr.
gcc/testsuite
PR fortran/122578
* gfortran.dg/pdt_72.f03: New test.
Mark Zhuang [Sat, 6 Dec 2025 05:16:25 +0000 (22:16 -0700)]
[PATCH] prepare-commit-msg: Add compatibility check for --default-prefix option
From: Mark Zhuang <mark.zhuang@spacemit.com>
The previous commit added --default-prefix to handle non-default git
prefix configurations, but this option is not available in older git
versions. This patch adds a compatibility check.
Starting with r16-4438-ga93f80feeef744, the edge sorting order was
switched to lowest execution frequency first. But the "bbro"
optimization pass chooses the first edge as a fallthrough. Thus the
most unlikely branches were optimized to fallthroughs.
Fix by restoring the sorting order prior to r16-4438-ga93f80feeef744.
Now the branches most likely to be executed are picked as fallthroughs.
There are no regressions for C and C++ on x86_64-pc-linux-gnu.
The new tests fail for the respective targets without this patch, and
pass with it.
PR rtl-optimization/122675
gcc/ChangeLog:
* bb-reorder.cc (edge_order): Fix BB edge ordering to be
descending.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/pr122675-1.c: New test.
* gcc.target/i386/pr122675-1.c: New test.
* gcc.target/riscv/pr122675-1.c: New test.
Patrick Palka [Sat, 6 Dec 2025 02:09:34 +0000 (21:09 -0500)]
libstdc++: Use deducing this in std::bind when available [PR80564]
Implement the forwarding performed by std::bind via deducing this when
available, instead of needing 4 operator() overloads. Using deducing
this here is more complicated than in other standard call wrappers
because std::bind is not really "perfect forwarding": it doesn't
consider value category, and along with const-ness it also forwards
volatile-ness (until C++20).
The old implementation suffers from the same problem that other
pre-C++23 SFINAE-friendly call wrappers have which is solved by using
deducing this (see p5.5 of the deducing this paper P0847R7).
PR libstdc++/80564
libstdc++-v3/ChangeLog:
* include/std/functional (__cv_like): New.
(_Bind::_Res_type): Don't define when not needed.
(_Bind::__dependent): Likewise.
(_Bind::_Res_type_cv): Likewise.
(_Bind::operator()) [_GLIBCXX_EXPLICIT_THIS_PARAMETER]:
Define as two instead of four overloads using deducing
this.
* testsuite/20_util/bind/cv_quals_2.cc: Ignore SFINAE
diagnostics inside headers.
* testsuite/20_util/bind/ref_neg.cc: Likewise.
* testsuite/20_util/bind/80564.cc: New test.
Reviewed-by: Tomasz KamiĆski <tkaminsk@redhat.com> Reviewed-by: Jonathan Wakely <jwakely@redhat.com>