"insn 8" -1 operand can't match Yx constraint low_bitmask_len condition.
low_bitmask_len can selects a field of low-order bits within an item but not
the entire word. Add (match_test "INTVAL (op) == -1") to low_bitmask_operand
predicate.
Note: "uint64_t a & 0xffffffffffffffff" and "uint32_t a & 0xffffffff" are
optimized away before expand with -O0, can't cause this error.
gcc/ChangeLog:
* config/loongarch/predicates.md: Add CONSTM1_RTX for low_bitmask_operand.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/la32/and.c: New test.
* gcc.target/loongarch/la32/la32.exp: New test.
Reviewed-by: Xi Ruoyao <xry111@xry111.site> Reviewed-by: Lulu Cheng <chenglulu@loongson.cn>
mengqinggang [Tue, 25 Nov 2025 11:07:42 +0000 (19:07 +0800)]
LoongArch: C and .h files for LA32
gcc/ChangeLog:
* config/loongarch/loongarch-opts.cc (loongarch_target_option_override):
Delete opts->x_flag_pcc_struct_return and enable mstrict-align by
default on LA32.
* config/loongarch/loongarch.cc (loongarch_for_each_saved_reg): Save reg
depend on float abi.
(loongarch_explicit_relocs_p): Disable explicit relocs on LA32.
(loongarch_valid_offset_p): Disable const_imm16_operand with 4 byte aligned.
(loongarch_valid_lo_sum_p): Allow lo_sum to be used with DF in ilp32d.
(loongarch_valid_index_p): Disable ADDRESS_REG_REG on LA32.
(loongarch_legitimize_address): Disable mem_shadd_or_shadd_rtx_p on LA32.
(loongarch_output_move_index): Assert TARGET_64BIT for ldx/stx.
(loongarch_output_move): Disable ldptr/stptr if offset is 0.
(loongarch_output_equal_conditional_branch): Disable beqz/bnez on LA32R.
(loongarch_trampoline_init): Change pcaddi to pcaddu12i.
(loongarch_get_separate_components): Disable ldptr/stptr on LA32.
(loongarch_c_mode_for_floating_type): Use TFmode for long double
regardless of target bitness.
(loongarch_bitint_type_info): Disable BitInt on LA32.
(loongarch_call_tls_get_addr): Use call30 on LA32.
(loongarch_split_move): Add split for DI, DF, TF.
* config/loongarch/loongarch.h (LA_LONG_DOUBLE_TYPE_SIZE): Set
LONG_DOUBLE_TYPE_SIZE to 128 regardless of target bitness.
(MAX_FIXED_MODE_SIZE): Set to 64 on LA32.
(DEFAULT_PCC_STRUCT_RETURN): New.
(STACK_BOUNDARY): Set to 128 on LA64 and LA32.
(LARCH_STACK_ALIGN): Set to 16 on LA64 and LA32.
(TRAMPOLINE_SIZE): Set to same value on LA64 and LA32.
include/ChangeLog:
* longlong.h (count_leading_zeros): Delete because LA32R no clz.
(count_trailing_zeros): Delete because LA32R no ctz.
(COUNT_LEADING_ZEROS_0): Delete.
mengqinggang [Wed, 5 Nov 2025 02:55:13 +0000 (10:55 +0800)]
LoongArch: Introduce LoongArch32 target
Introduce LoongArch32 (LA32) ilp32d abi and LoongArch32 Reduced (LA32R) ilp32s abi.
Add march la32v1.0 and la32rv1.0.
Add mtune loongarch32 as a general tune.
Add la32 march and mtune to gcc/doc/invoke.texi.
contrib/ChangeLog:
* config-list.mk: Add loongarch32-linux-gnu*.
gcc/ChangeLog:
* config.gcc: Add target triple loongarch32-*-*-* and
corresponding abi ilp32f, ilp32d and ilp32s.
* config/loongarch/genopts/loongarch-strings: Add strings for
loongarch32 and ilp32 abi variants.
* config/loongarch/genopts/loongarch.opt.in: Add
-march=la32v1.0/la32rv1.0 and -mabi=ilp32d/ilp32f/ilp32s.
* config/loongarch/gnu-user.h: Add ilp32 abi variants to spec.
* config/loongarch/linux.h: Add ABI_LIBDIR for ilp32 abi
variants.
* config/loongarch/loongarch-c.cc (loongarch_define_unconditional_macros):
Add builtin definitions for loongarch32 target.
* config/loongarch/loongarch-def.cc: Add loongarch32 and ilp32
definitions.
* config/loongarch/loongarch-def.h: Add loongarch32 and ilp32
definitions.
* config/loongarch/loongarch-driver.h: Add ilp32 abi variants to
spec.
* config/loongarch/loongarch-opts.cc: Handle ilp32 abi variants.
* config/loongarch/loongarch-opts.h: Add loongarch32 case to
macros.
* config/loongarch/loongarch-str.h: Add loongarch32 and ilp32
strings.
* config/loongarch/loongarch.opt: Add -march=la32v1.0/la32rv1.0
and -mabi=ilp32d/ilp32f/ilp32s.
* config/loongarch/t-linux: Add ilp32 abi variants to multilib.
* doc/invoke.texi: Add LA32 arch and tune.
Jose E. Marchesi [Fri, 12 Dec 2025 02:43:38 +0000 (03:43 +0100)]
a68: emit proper error for empty source file
Ok this is an embarrassing one. A source file that is either empty or
that contains just blanks, characters and/or pragmats, is not a proper
particular program nor a prelude packet. This patch makes ga68 to
emit an error mesage rather than ICEing.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog
* a68-parser-scanner.cc (a68_lexical_analyser): New argument
empty_program.
* a68.h: Update prototype of a68_lexical_analyser.
* a68-parser.cc (a68_parser): Emit error for empty input files.
Joseph Myers [Thu, 11 Dec 2025 23:20:54 +0000 (23:20 +0000)]
contrib: Use config.sub in test_installed
Correctly running GCC testsuites with an installed compiler requires
both the canonical and noncanonical versions of the target triplet:
the canonical one for where the testsuite matches on target triplets,
and the noncanonical one for various "transform" calls used to find
binutils programs. Make test_installed use config.sub to determine
the canonical target from any value passed with --target= (and thus
make logic to locate the toplevel source directory from its own
location unconditional, as it's now used to locate config.sub).
* test_installed: Use config.sub to determine canonical target.
Jeff Law [Thu, 11 Dec 2025 20:57:25 +0000 (13:57 -0700)]
MAINTAINERS file updates
So with the acquisition of Ventana Microsystems by Qualcomm, Daniel, Robin,
Shreya, Raphael and I all work for Qualcomm now and ongoing contributions will
be under that umbrella.
I also realized that Raphael has write-after-approval access, but didn't have a
suitable entry in the MAINTAINERS file. So I updated that as well.
/
* MAINTAINERS: Update entries for contributors formerly at
Ventana Microsystems to refer to Qualcomm instead.
The recent -Wdeprecated-openmp changes broke various tests.
This patch limits the - reduction diagnostics to OpenMP, as the code is used
by OpenACC and even if OpenACC deprecates it, it should be changed independently
and not mention OpenMP versions in that case.
The rest are just testsuite tweaks to make stuff pass, sometimes adding
-Wno-deprecated-openmp, in other cases using newer syntax.
2025-12-11 Jakub Jelinek <jakub@redhat.com>
PR testsuite/123098
gcc/c/
* c-parser.cc (c_parser_omp_clause_reduction): Only emit
-Wdeprecated-openmp warning for CPP_MINUS if is_omp.
gcc/cp/
* parser.cc (cp_parser_omp_clause_reduction): Only emit
-Wdeprecated-openmp warning for CPP_MINUS if is_omp.
gcc/fortran/
* openmp.cc (gfc_match_omp_clause_reduction): Only emit
-Wdeprecated-openmp warning for '-' if !openacc.
gcc/testsuite/
* gcc.dg/vect/vect-simd-clone-15.c (foo): Use OpenMP 5.2
syntax for linear clause.
* g++.dg/vect/simd-clone-6.cc (foo): Likewise.
* c-c++-common/goacc-gomp/pr93465-1.c: Use
#pragma omp begin declare target instead of
#pragma omp declare target.
* c-c++-common/goacc-gomp/nesting-fail-1.c: Use #pragma omp masked
instead of #pragma omp master.
* gfortran.dg/goacc-gomp/pr102330-1.f90 (r1): Use
!$omp masked taskloop simd instead of !$omp master taskloop simd.
* gfortran.dg/vect/pr86421.f90 (foo): Use OpenMP 5.2 syntax for
linear clause.
* gfortran.dg/gomp/allocate-16.f90: Use \\\$ instead of $ in dg-error
and use relative line numbers instead of absolute.
* gfortran.dg/gomp/groupprivate-2.f90: Add -Wno-deprecated-openmp
to dg-additional-options.
* gfortran.dg/gomp/groupprivate-5.f90: Likewise.
* gfortran.dg/goacc/pr93329.f90: Likewise.
The following patch attempts to implement the C++26 P3378R2 - constexpr
exception types paper.
This is quite complicated, because most of these classes which should
be constexpr-ized use solely or mostly out of line definitions in
libstdc++, both for historical, code size and dual ABI reasons, so that
one can throw these as exceptions between TUs with old vs. new (or vice
versa) ABIs.
For this reason, logic_error/runtime_error and classes derived from it
have the old ABI std::string object inside of them and the exported
APIs from libstdc++.so.6 ensure the right thing.
Now, because new invoked during constant evaluation needs to be deleted
during the same constant evaluation and can't leak into the constant
expressions, I think we don't have to use COW strings under the hood
(which aren't constexpr I guess because of reference counting/COW) and
we can use something else, the patch uses heap allocated std::string
object (where __cow_constexpr_string class has just a pointer to that).
As I think we still want to hide the ugly details if !consteval in the
library, the patch exports 8 __cow_string class symbols (6 existing which
were previously just not exported and 2 new ones) and if !consteval
calls those through extern "C" _Zmangled_name symbols. The functions
are always_inline.
And then logic_error etc. have for C++26 (precisely for
__cpp_lib_constexpr_exceptions >= 202502L) constexpr definitions of
cdtors/methods. This results in slightly larger code (a few insns at most)
at runtime for C++26, e.g. instead of calling say some logic error
cdtor/method with 2 arguments it calls some __cow_string one with 2
arguments but + 8 bytes pointer additions on both.
The patch also removes the __throw_format_error forward declaration
which apparently wasn't needed for anything as all __throw_format_error
users were either in <format> or included <format> before the uses,
reverts the
https://gcc.gnu.org/pipermail/libstdc++/2025-July/062598.html
patch and makes sure __throw_* functions (only those for exception types
which the P3378R2 or P3068R5 papers made constexpr usable and there are
actually constexpr/consteval uses of those) are constexpr for C++26
constexpr exceptions.
The patch does that by splitting the bits/functexcept.h header:
1) bits/functexcept.h stays for the __throw_* functions which are (at
least for now) never constexpr (the <ios>, <system_error>, <future>
and <functional> std::exception derived classes) or are never used
or never used in constexpr/consteval contexts (<exception>, <typeinfo>
std::exception derived classes and std::range_error).
2) bits/new_{throw,except}.h for __throw_bad_alloc/__throw_bad_array_new_length
and std::bad_alloc/std::bad_array_new_length (where <new> includes
<bits/new_except.h> and <bits/new_throw.h> as well for the C++26 constexpr
exceptions case)
3) for the most complicated <stdexcept> stuff, one header
addition to bits/stdexcept.h one header for the __throw_logic_error etc.
forward declarations, one header for the __throw_logic_error etc.
definitions and one header without header guards which will
depending on __glibcxx_exc_in_string include one or the other because
<string> vs. <string_view> vs. <stdexcept> have heavy interdependencies
2025-12-11 Jakub Jelinek <jakub@redhat.com>
PR libstdc++/121114
libstdc++-v3/
* include/bits/version.def: Implement C++26 P3378R2 - constexpr
exception types.
(constexpr_exceptions): Change value from 1 to 202502, remove
no_stdname and TODO comments.
* include/bits/version.h: Regenerate.
* src/c++11/cow-stdexcept.cc (__cow_string(const char*)): New
ctor.
(__cow_string::c_str()): New method.
* config/abi/pre/gnu.ver (GLIBCXX_3.4.35): Export 8 __cow_string
symbols.
* include/bits/new_except.h: New file.
* include/bits/new_throw.h: New file.
* include/bits/stdexcept_throw.h: New file.
* include/bits/stdexcept_throwdef.h: New file.
* include/bits/stdexcept_throwfwd.h: New file.
* include/std/stdexcept: Include bits/stdexcept_except.h and move
everything after <string> include except for std::range_error into
include/bits/stdexcept_except.h.
(std::range_error): If __cpp_lib_constexpr_exceptions >= 202502L
make all cdtors and methods constexpr.
* include/bits/stdexcept_except.h: New file.
* include/std/optional (__glibcxx_want_constexpr_exceptions): Define
before including bits/version.h.
(bad_optional_access::what): Make constexpr for
__cpp_lib_constexpr_exceptions >= 202502L.
(__throw_bad_optional_access): Likewise.
* include/std/expected (__glibcxx_want_constexpr_exceptions): Define
before including bits/version.h.
(bad_expected_access): Make cdtors and all methods constexpr for
__cpp_lib_constexpr_exceptions >= 202502L.
* include/std/format (__glibcxx_want_constexpr_exceptions): Define
before including bits/version.h.
(_GLIBCXX_CONSTEXPR_FORMAT_ERROR): Define and undef later.
(format_error): Use _GLIBCXX_CONSTEXPR_FORMAT_ERROR on ctors.
* include/std/variant (__glibcxx_want_constexpr_exceptions): Define
before including bits/version.h.
(_GLIBCXX_CONSTEXPR_BAD_VARIANT_ACCESS): Define and undef later.
(bad_variant_access): Use it on ctors and what() method.
(__throw_bad_variant_access): Use it here too.
* testsuite/18_support/exception/version.cc: Adjust expected
__cpp_lib_constexpr_exceptions value.
* testsuite/19_diagnostics/runtime_error/constexpr.cc: New test.
* testsuite/19_diagnostics/headers/stdexcept/version.cc: New test.
* testsuite/19_diagnostics/logic_error/constexpr.cc: New test.
* testsuite/20_util/expected/observers.cc (test_value_throw): Change
return type to bool from void, return true at the end, add test
to dereference what() first character. Make it constexpr for
__cpp_lib_constexpr_exceptions >= 202502L and add static_assert.
* testsuite/20_util/expected/version.cc: Add tests for
__cpp_lib_constexpr_exceptions value.
* testsuite/20_util/variant/constexpr.cc: For
__cpp_lib_constexpr_exceptions >= 202502L include <string>.
(test_get): New function if __cpp_lib_constexpr_exceptions >= 202502L,
assert calling it is true.
* testsuite/20_util/variant/version.cc: Add tests for
__cpp_lib_constexpr_exceptions value.
* testsuite/20_util/optional/constexpr/observers/3.cc: Include
testsuite_hooks.h.
(eat, test01): New functions. Assert test01() is true.
* testsuite/20_util/optional/version.cc: Add tests for
__cpp_lib_constexpr_exceptions value.
* include/std/future: Add #include <bits/functexcept.h>.
* include/std/shared_mutex: Include <bits/new_throw.h>.
* include/std/flat_map: Include <bits/stdexcept_throw.h> instead of
<bits/functexcept.h>.
* include/std/syncstream: Remove <bits/functexcept.h> include.
* include/std/flat_set: Likewise.
* include/std/bitset: Include <bits/stdexcept_throw.h> instead of
<bits/functexcept.h>.
* include/std/string_view: Don't include <bits/functexcept.h>, include
<bits/stdexcept_throw.h> early if __glibcxx_exc_in_string is not
defined and include <bits/stdexcept_throw.h> at the end of
the header again if __glibcxx_exc_in_string is 2 and C++26 constexpr
exceptions are enabled.
(__glibcxx_exc_in_string): Define if __glibcxx_exc_in_string wasn't
defined before including <bits/stdexcept_throw.h>.
* include/std/array: Include <bits/stdexcept_throw.h> instead of
<bits/functexcept.h>.
* include/std/inplace_vector: Likewise.
* include/std/string: Include <bits/stdexcept_except.h> and
<bits/stdexcept_throw.h> after bits/basic_string.tcc include if
C++26 constexpr exceptions are enabled and include
<bits/stdexcept_throw.h> instead of <bits/functexcept.h> early.
(__glibcxx_exc_in_string): Define early to 1, undefine at the end.
* include/std/deque: Include <bits/stdexcept_throw.h>.
* include/bits/new_allocator.h: Include <bits/new_throw.h> instead
of <bits/functexcept.h>.
* include/bits/stl_algobase.h: Remove <bits/functexcept.h> include.
* include/bits/stl_vector.h: Include <bits/stdexcept_throw.h> instead
of <bits/functexcept.h>.
* include/bits/memory_resource.h: Include <bits/new_throw.h> instead
of <bits/functexcept.h>.
* include/bits/functexcept.h: Guard everything after includes with
#if _GLIBCXX_HOSTED.
(__throw_bad_alloc, __throw_bad_array_new_length, __throw_logic_error,
__throw_domain_error, __throw_invalid_argument, __throw_length_error,
__throw_out_of_range, __throw_out_of_range_fmt, __throw_runtime_error,
__throw_overflow_error, __throw_underflow_error): Move declarations to
other headers - <bits/new_throw.h> and <bits/stdexcept_throwfwd.h>.
* include/bits/stl_map.h: Include <bits/stdexcept_throw.h> instead
of <bits/functexcept.h>.
* include/bits/hashtable_policy.h: Include <bits/stdexcept_throw.h>
instead of <bits/functexcept.h>.
* include/bits/formatfwd.h (std::__throw_format_error): Remove
declaration.
* include/bits/specfun.h: Include <bits/stdexcept_throw.h> instead of
<bits/functexcept.h>.
* include/bits/basic_ios.h: Include <bits/functexcept.h>.
* include/bits/locale_classes.h: Likewise.
* include/tr1/cmath: Include <bits/stdexcept_throw.h> instead of
<bits/functexcept.h>.
* include/tr1/memory: Remove <bits/functexcept.h> include.
* include/tr1/array: Include <bits/stdexcept_throw.h>.
* include/ext/vstring_util.h: Include <bits/stdexcept_throw.h> instead
of <bits/functexcept.h>.
* include/ext/bitmap_allocator.h: Include <bits/new_throw.h> instead
of <bits/functexcept.h>.
* include/ext/mt_allocator.h: Likewise.
* include/ext/malloc_allocator.h: Likewise.
* include/ext/debug_allocator.h: Include <bits/stdexcept_throw.h>
instead of <bits/functexcept.h>.
* include/ext/concurrence.h: Include <bits/exception_defines.h>
instead of <bits/functexcept.h>.
* include/ext/throw_allocator.h: Include <bits/new_throw.h> and
<bits/stdexcept_throw.h> instead of <bits/functexcept.h>.
* include/ext/string_conversions.h: Include <bits/stdexcept_throw.h>
instead of <bits/functexcept.h>.
* include/ext/pool_allocator.h: Include <bits/new_throw.h> instead
of <bits/functexcept.h>.
* include/ext/ropeimpl.h: Include <bits/stdexcept_throw.h> instead of
<bits/functexcept.h>.
* include/tr2/dynamic_bitset: Likewise.
* include/experimental/optional: Include <bits/exception_defines.h>
instead of <bits/functexcept.h>.
* include/Makefile.am (bits_freestanding): Add
${bits_srcdir}/{new,stdexcept}_{except,throw}.h
and ${bits_srcdir}/stdexcept_throw{fwd,def}.h.
* include/Makefile.in: Regenerate.
* src/c++17/floating_from_chars.cc: Remove <bits/functexcept.h>
include.
* src/c++11/regex.cc: Likewise.
* src/c++11/functexcept.cc: Likewise.
* src/c++11/snprintf_lite.cc: Include <bits/stdexcept_throw.h> instead
of <bits/functexcept.h>.
* src/c++11/thread.cc: Include <bits/functexcept.h>.
* testsuite/util/testsuite_hooks.h: Include <bits/stdexcept_throw.h>
instead of <bits/functexcept.h>.
* testsuite/util/io/verified_cmd_line_input.cc: Include
<bits/exception_defines.h> instead of <bits/functexcept.h>.
* testsuite/20_util/allocator/105975.cc: Expect different diagnostics
for C++26.
* testsuite/23_containers/inplace_vector/access/capacity.cc: Remove
#error, guard if consteval { return; } with
#ifndef __cpp_lib_constexpr_exceptions.
* testsuite/23_containers/inplace_vector/access/elem.cc: Likewise.
* testsuite/23_containers/inplace_vector/cons/1.cc: Likewise.
* testsuite/23_containers/inplace_vector/cons/from_range.cc: Likewise.
* testsuite/23_containers/inplace_vector/modifiers/single_insert.cc:
Likewise.
* testsuite/23_containers/inplace_vector/modifiers/assign.cc:
Likewise.
* testsuite/23_containers/inplace_vector/modifiers/multi_insert.cc:
Likewise.
* libsupc++/new: Include <bits/new_except.h>.
(std::bad_alloc, std::bad_array_new_length): Move defintion to
<bits/new_except.h>.
libgomp/
* omp.h.in: Include <bits/new_throw.h> instead of
<bits/functexcept.h>.
gcc/testsuite/
* g++.dg/tree-ssa/pr110819.C: Guard scan-tree-dump-not delete on
c++23_down and add comment explaining why C++26 fails that.
* g++.dg/tree-ssa/pr96945.C: Likewise.
* g++.dg/tree-ssa/pr109442.C: Likewise.
* g++.dg/tree-ssa/pr116868.C: Likewise.
* g++.dg/tree-ssa/pr58483.C: Likewise.
Jakub Jelinek [Thu, 11 Dec 2025 18:34:20 +0000 (19:34 +0100)]
Some typo fixes (mostly comment but some messages too)
There is one issue I haven't touched in auto-profile.cc,
fprintf (dump_file,
" Annotating edge %i->%i with count 0;"
" static profile aggress",
e->src->index, e->dest->index);
Not sure if the last word should be agrees or something completely
different.
Paul Thomas [Thu, 11 Dec 2025 17:24:07 +0000 (17:24 +0000)]
Fortran: Fix ICE arising from PDT class components [PR107142]
2025-12-11 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/107142
* match.cc (gfc_match_type_spec): Change original declaration
to static match_type_spec and call from gfc_match_type_spec,
where the gfc_current_ns is stashed and restored after call.
(gfc_match_type_is): Before emitting the syntax error message
check if there are any pending error messages and use them
instead.
gcc/testsuite
PR fortran/107142
* gfortran.dg/pdt_78.f03: New test.
Paul Thomas [Thu, 11 Dec 2025 16:51:53 +0000 (16:51 +0000)]
Fortran: Fix ICE arising from PDT class components [PR110012]
2025-12-11 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/110012
* decl.cc (gfc_get_pdt_instance): Continue to loop through the
type parameters components if param_list is null and the
parameter is not KIND with a default initializer.
* resolve.cc (resolve_fl_derived): If the data component is a
PDT template, find the instance and build the class.
gcc/testsuite
PR fortran/110012
* gfortran.dg/pdt_77.f03: New test.
Jason Merrill [Thu, 11 Dec 2025 16:31:18 +0000 (23:31 +0700)]
c++, libstdc++: add "modules" std to testsuite
Since modules aren't enabled by default at any -std= yet, let's add a
pseudo-std for them, like we already have for -fimplicit-constexpr. And
also add to target-supports so dg lines can check { target modules }.
To run library tests with modules we need to compile them; this patch makes
us build a header unit for bits/stdc++.h and module interface units for std
and std.compat, if v3_std_list includes "modules". So this doesn't happen
by default without a further change.
libstdc++-v3/ChangeLog:
* testsuite/Makefile.am (CLEANFILES): Add gcm.cache.
* testsuite/Makefile.in: Regenerate.
* testsuite/lib/dg-options.exp (add_options_for_no_pch): Also add
-fno-modules.
* testsuite/lib/libstdc++.exp (v3_std_list): Handle "modules" std.
(v3_modules_std): New global.
(v3-build_support): Build gcms for bits/stdc++.h, std, and
std.compat.
supers1ngular [Thu, 11 Dec 2025 16:12:50 +0000 (08:12 -0800)]
openmp: Bump Version from 4.5 to 5.2 (3/4)
Implements the OpenMP 5.2 Fortran deprecations. Uses the warning
established in patch 1/4, -Wdeprecated-openmp, for said deprecations.
Similarly, we do not implement the relaxing of constraints for the
interop construct since it is not a deprecation. However, the
deprecation for 'uses_allocators' is implemented, since support
exists in Fortran mainline. Additionally implements the
Fortran-specific deprecation for executable allocate directives,
and adds new tests.
gcc/fortran/ChangeLog:
* openmp.cc (gfc_match_omp_clause_reduction): Deprecate '-'
operator for reductions.
(gfc_match_omp_clause_uses_allocators): Deprecate
allocator(traits) pattern for 'uses_allocators'.
(gfc_match_omp_clauses): Deprecate 'sink' and 'source' for
'depend' clause. Deprecate list items as arguments with 'linear'
clause. Deprecate non-comma-separated modifiers for the map
clause. Deprecate 'to' clause with declare target.
(gfc_match_omp_declare_target): Whitespace.
(match_omp_metadirective): Deprecate 'default' clause on
metadirectives.
(resolve_omp_clauses): Deprecate executable allocate directives.
Tamar Christina [Thu, 11 Dec 2025 15:51:23 +0000 (15:51 +0000)]
vect: only move update_e if edge is split [PR123014]
This is an alternative fix for PR122959 where the issue is that in order to
maintain LOOPS_HAVE_PREHEADERS slpeel_add_loop_guard may add an empty block that
becomes the pre-header edge of the epilog loop.
If the epilog loop already had a pre-header we insert nothing and update_e is
already pointing to the right thing. However if we do insert the intermediate
block we have this situation
guard block
|
pre-header
|
epilog
vect_update_ivs_after_vectorizer now needs to use the guard block to identify
the PHI nodes, but use the edge from pre-header -> epilog as the update_e.
The first fix moved update_e detection and we picked the guard pre-header ->
epilog edge and would use the pre-header block to fill in any new adjustments
needed.
This doesn't work because due to skip_epilog we have to put all adjustments in
the guard block, since the skip_epilog edge also skips the pre-header.
This patch instead addresses this in vect_update_ivs_after_vectorizer by if
you have an empty pre-header, it moves the edge down through the fall-through
edge, but keeps exit_bb as guard block.
supers1ngular [Thu, 11 Dec 2025 15:45:04 +0000 (07:45 -0800)]
openmp: Bump Version from 4.5 to 5.2 (2/4)
Implements the OpenMP 5.2 C and C++ deprecations. Uses the warning
established in patch 1/4, -Wdeprecated-openmp, for said deprecations.
Not implemented is 'uses_allocators', since the base is not yet in
mainline, along with the relaxing of constraints for the interop
construct, since this is not a deprecation. Additionally does not
deprecate 'destroy' with no arguments on depobj construct, since
this was undeprecated in OpenMP 6.0. Adds new tests.
gcc/c/ChangeLog:
* c-parser.cc (c_parser_omp_clause_reduction): Deprecate '-'
operator for reductions.
(c_parser_omp_clause_linear): Deprecate modifiers with parens.
(c_parser_omp_clause_depend): Deprecate 'sink' and 'source'
modifiers for 'depend' clause.
(c_parser_omp_clause_map): Map clause modifiers comma-separated.
(c_parser_omp_declare_target): Deprecate synonymous omp declare
target for omp begin declare target. Deprecate 'to' clause.
(c_parser_omp_metadirective): Deprecate default clause on
metadirectives.
gcc/cp/ChangeLog:
* parser.cc (cp_parser_omp_clause_reduction): Deprecate '-'
operator.
(cp_parser_omp_clause_linear): Deprecate modifiers with parens.
(cp_parser_omp_clause_depend): Deprecate sink and source.
(cp_parser_omp_clause_map): Map clause modifiers
comma-separated.
(cp_parser_omp_declare_target): Deprecate synonymous omp declare
target for omp begin declare target. Deprecate to clause.
(cp_parser_omp_metadirective): Deprecate default clause on
metadirectives.
Eric Botcazou [Thu, 11 Dec 2025 14:58:37 +0000 (15:58 +0100)]
Ada: Fix ICE when building spawn-25.0.0 with GTK support
This is a regression introduced on the mainline by the freezing change for
the designated type of anonymous access-to-subprogram types, which has
uncovered a small oversight in Analyze_Subprogram_Instantiation, whereby
we propagate the Convention of the generic subprogram onto the named actual
only, and not onto the anonymous actual built alongside the named one.
gcc/ada/
PR ada/123062
* sem_ch12.adb (Analyze_Subprogram_Instantiation): Also propagate
the Convention and Is_Exported flag onto the anonymous actual.
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.
Tomasz Kamiński [Mon, 8 Dec 2025 07:49:45 +0000 (08:49 +0100)]
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.