aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2025-03-07vect: Fix build on MacOSSimon Martin1-0/+1
The build is broken on MacOS since r15-7881-ge8651b80aeb86d because tree-vect-data-refs.cc uses std::min but does not include <algorithm>. This patch fixes it by defining INCLUDE_ALGORITHM in that file. gcc/ChangeLog: * tree-vect-data-refs.cc: Define INCLUDE_ALGORITHM.
2025-03-07middle-end: delay checking for alignment to load [PR118464]Tamar Christina35-96/+509
This fixes two PRs on Early break vectorization by delaying the safety checks to vectorizable_load when the VF, VMAT and vectype are all known. This patch does add two new restrictions: 1. On LOAD_LANES targets, where the buffer size is known, we reject non-power of two group sizes, as they are unaligned every other iteration and so may cross a page unwittingly. For those cases require partial masking support. 2. On LOAD_LANES targets when the buffer is unknown, we reject vectorization if we cannot peel for alignment, as the alignment requirement is quite large at GROUP_SIZE * vectype_size. This is unlikely to ever be beneficial so we don't support it for now. There are other steps documented inside the code itself so that the reasoning is next to the code. As a fall-back, when the alignment fails we require partial vector support. For VLA targets like SVE return element alignment as the desired vector alignment. This means that the loads are never misaligned and so annoying it won't ever need to peel. So what I think needs to happen in GCC 16 is that. 1. during vect_compute_data_ref_alignment we need to take the max of POLY_VALUE_MIN and vector_alignment. 2. vect_do_peeling define skip_vector when PFA for VLA, and in the guard add a check that ncopies * vectype does not exceed POLY_VALUE_MAX which we use as a proxy for pagesize. 3. Force LOOP_VINFO_USING_PARTIAL_VECTORS_P to be true in vect_determine_partial_vectors_and_peeling since the first iteration has to be partial. Require LOOP_VINFO_MUST_USE_PARTIAL_VECTORS_P otherwise we have to fail to vectorize. 4. Create a default mask to be used, so that vect_use_loop_mask_for_alignment_p becomes true and we generate the peeled check through loop control for partial loops. From what I can tell this won't work for LOOP_VINFO_FULLY_WITH_LENGTH_P since they don't have any peeling support at all in the compiler. That would need to be done independently from the above. In any case, not GCC 15 material so I've kept the WIP patches I have downstream. Bootstrapped Regtested on aarch64-none-linux-gnu, arm-none-linux-gnueabihf, x86_64-pc-linux-gnu -m32, -m64 and no issues. gcc/ChangeLog: PR tree-optimization/118464 PR tree-optimization/116855 * doc/invoke.texi (min-pagesize): Update docs with vectorizer use. * tree-vect-data-refs.cc (vect_analyze_early_break_dependences): Delay checks. (vect_compute_data_ref_alignment): Remove alignment checks and move to get_load_store_type, increase group access alignment. (vect_enhance_data_refs_alignment): Add note to comment needing investigating. (vect_analyze_data_refs_alignment): Likewise. (vect_supportable_dr_alignment): For group loads look at first DR. * tree-vect-stmts.cc (get_load_store_type): Perform safety checks for early break pfa. * tree-vectorizer.h (dr_set_safe_speculative_read_required, dr_safe_speculative_read_required, DR_SCALAR_KNOWN_BOUNDS): New. (need_peeling_for_alignment): Renamed to... (safe_speculative_read_required): .. This (class dr_vec_info): Add scalar_access_known_in_bounds. gcc/testsuite/ChangeLog: PR tree-optimization/118464 PR tree-optimization/116855 * gcc.dg/vect/bb-slp-pr65935.c: Update, it now vectorizes because the load type is relaxed later. * gcc.dg/vect/vect-early-break_121-pr114081.c: Update. * gcc.dg/vect/vect-early-break_22.c: Require partial vectors. * gcc.dg/vect/vect-early-break_128.c: Likewise. * gcc.dg/vect/vect-early-break_26.c: Likewise. * gcc.dg/vect/vect-early-break_43.c: Likewise. * gcc.dg/vect/vect-early-break_44.c: Likewise. * gcc.dg/vect/vect-early-break_2.c: Require load_lanes. * gcc.dg/vect/vect-early-break_7.c: Likewise. * gcc.dg/vect/vect-early-break_132-pr118464.c: New test. * gcc.dg/vect/vect-early-break_133_pfa1.c: New test. * gcc.dg/vect/vect-early-break_133_pfa11.c: New test. * gcc.dg/vect/vect-early-break_133_pfa10.c: New test. * gcc.dg/vect/vect-early-break_133_pfa2.c: New test. * gcc.dg/vect/vect-early-break_133_pfa3.c: New test. * gcc.dg/vect/vect-early-break_133_pfa4.c: New test. * gcc.dg/vect/vect-early-break_133_pfa5.c: New test. * gcc.dg/vect/vect-early-break_133_pfa6.c: New test. * gcc.dg/vect/vect-early-break_133_pfa7.c: New test. * gcc.dg/vect/vect-early-break_133_pfa8.c: New test. * gcc.dg/vect/vect-early-break_133_pfa9.c: New test. * gcc.dg/vect/vect-early-break_39.c: Update testcase for misalignment. * gcc.dg/vect/vect-early-break_18.c: Likewise. * gcc.dg/vect/vect-early-break_20.c: Likewise. * gcc.dg/vect/vect-early-break_21.c: Likewise. * gcc.dg/vect/vect-early-break_38.c: Likewise. * gcc.dg/vect/vect-early-break_6.c: Likewise. * gcc.dg/vect/vect-early-break_53.c: Likewise. * gcc.dg/vect/vect-early-break_56.c: Likewise. * gcc.dg/vect/vect-early-break_57.c: Likewise. * gcc.dg/vect/vect-early-break_81.c: Likewise.
2025-03-07libstdc++: Add missing static_assert to std::expected<void,E>::value()&&Jonathan Wakely2-0/+70
The r15-2326-gea435261ad58ea change missed a static_assert for is_move_constructible_v in expected<cv void, E>::value()&&. When exceptions are enabled, the program is ill-formed if the error type is not move constructible, because we can't construct the std::bad_expected_access. But prior to r15-7856-gd87c0d5443ba86, using -fno-exceptions meant that we never constructed an exception, so didn't need to copy/move the error value. So that we don't rely on the r15-7856-gd87c0d5443ba86 change to the _GLIBCXX_THROW_OR_ABORT macro to consistently enforce the Mandates: conditions whether exceptions are enabled or not, we should check the requirement explicitly. This adds the missing static_assert. It also adds a test that verifies the Mandates: conditions added by LWG 3843 and 3490 are enforced even with -fno-exceptions. libstdc++-v3/ChangeLog: * include/std/expected (expected<cv void,E>::value()&&): Add missing static_assert for LWG 3940. * testsuite/20_util/expected/lwg3843.cc: New test. Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-03-07aarch64: add support for partial modes to last extractions [PR118464]Tamar Christina2-13/+17
The last extraction instructions work full both full and partial SVE vectors, however we currrently only define them for FULL vectors. Early break code for VLA now however requires partial vector support, which relies on extract_last support. I have not added any new testcases as they overlap with the existing Early break tests which now fail without this. gcc/ChangeLog: PR tree-optimization/118464 PR tree-optimization/116855 * config/aarch64/aarch64-sve.md (@extract_<last_op>_<mode>, @fold_extract_<last_op>_<mode>, @aarch64_fold_extract_vector_<last_op>_<mode>): Change SVE_FULL to SVE_ALL. * config/aarch64/iterators.md (vccore): Add more partial types.
2025-03-07tree-optimization/119145 - avoid stray .MASK_CALL after vectorizationRichard Biener2-1/+38
When we BB vectorize an if-converted loop body we make sure to not leave around .MASK_LOAD or .MASK_STORE created by if-conversion but we failed to check for .MASK_CALL. PR tree-optimization/119145 * tree-vectorizer.cc (try_vectorize_loop_1): Avoid BB vectorizing an if-converted loop body when there's a .MASK_CALL in the loop body. * gcc.dg/vect/pr119145.c: New testcase.
2025-03-07arm: Handle fixed PIC register in require_pic_register (PR target/115485)Christophe Lyon2-2/+19
Commit r9-4307-g89d7557202d25a forgot to accept a fixed PIC register when extending the assert in require_pic_register. arm_pic_register can be set explicitly by the user (e.g. -mpic-register=r9) or implicitly as the default value with -fpic/-fPIC/-fPIE and -mno-pic-data-is-text-relative -mlong-calls, and we want to use/accept it when recording cfun->machine->pic_reg as used to be the case. PR target/115485 gcc/ * config/arm/arm.cc (require_pic_register): Fix typos in comment. Handle fixed arm_pic_register. gcc/testsuite/ * g++.target/arm/pr115485.C: New test.
2025-03-07vect: Enforce dr_with_seg_len::align precondition [PR116125]Richard Sandiford3-3/+38
tree-data-refs.cc uses alignment information to try to optimise the code generated for alias checks. The assumption for "normal" non-grouped, full-width scalar accesses was that the access size would be a multiple of the alignment. As Richi notes in the PR, this is a documented precondition of dr_with_seg_len: /* The minimum common alignment of DR's start address, SEG_LEN and ACCESS_SIZE. */ unsigned int align; PR115192 was a case in which this assumption didn't hold. The access was part of an aligned 4-element group, but only the first 2 elements of the group were accessed. The alignment was therefore double the access size. In r15-820-ga0fe4fb1c8d78045 I'd "fixed" that by capping the alignment in one of the output routines. But I think that was misconceived. The precondition means that we should cap the alignment at source instead. Failure to do that caused a similar wrong code bug in this PR, where the alignment comes from a short bitfield access rather than from a group access. gcc/ PR tree-optimization/116125 * tree-vect-data-refs.cc (vect_prune_runtime_alias_test_list): Make the dr_with_seg_len alignment fields describe tha access sizes as well as the pointer alignment. * tree-data-ref.cc (create_intersect_range_checks): Don't compensate for invalid alignment fields here. gcc/testsuite/ PR tree-optimization/116125 * gcc.dg/vect/pr116125.c: New test.
2025-03-07aarch64: Use force_lowpart_subreg in a BFI splitter [PR119133]Richard Sandiford2-2/+10
lowpart_subreg ICEs are the gift that keeps giving. This is another case where we need to use force_lowpart_subreg instead, to handle cases where the input is already a subreg and where the combined subreg is not allowed as a single operation. We don't need to check can_create_pseudo_p since the input should be a hard register rather than a subreg if !can_create_pseudo_p. gcc/ PR target/119133 * config/aarch64/aarch64.md (*aarch64_bfi<GPI:mode><ALLX:mode>_<SUBDI_BITS>): Use force_lowpart_subreg. gcc/testsuite/ PR target/119133 * gcc.dg/torture/pr119133.c: New test.
2025-03-07c++: Handle TU_LOCAL_ENTITY in tsubst_expr and potential_constant_expressionNathaniel Shead2-66/+19
This cleans up the TU_LOCAL_ENTITY handling to avoid unnecessary tree walks and make the logic more robust. gcc/cp/ChangeLog: * constexpr.cc (potential_constant_expression_1): Handle TU_LOCAL_ENTITY. * pt.cc (expr_contains_tu_local_entity): Remove. (function_contains_tu_local_entity): Remove. (dependent_operand_p): Remove special handling for TU_LOCAL_ENTITY. (tsubst_expr): Handle TU_LOCAL_ENTITY when tsubsting OVERLOADs; remove now-unnecessary extra handling. (type_dependent_expression_p): Handle TU_LOCAL_ENTITY. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Patrick Palka <ppalka@redhat.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2025-03-07middle-end/118801 - excessive redundant DEBUG BEGIN_STMTRichard Biener1-0/+10
The following addresses the fact that we keep an excessive amount of redundant DEBUG BEGIN_STMTs - in the testcase it sums up to 99.999% of all stmts, sucking up compile-time in IL walks. The patch amends the GIMPLE DCE code that elides redundant DEBUG BIND stmts, also pruning uninterrupted sequences of DEBUG BEGIN_STMTs, keeping only the last of each set of DEBUG BEGIN_STMT with unique location. PR middle-end/118801 * tree-ssa-dce.cc (eliminate_unnecessary_stmts): Prune sequences of uninterrupted DEBUG BEGIN_STMTs, keeping only the last of a set with unique location.
2025-03-07Documentation: Improve -Wstringop-overflow documentation [PR 113515]Sandra Loosemore1-6/+29
This option can warn about things other than string and memory functions. Say so explicitly, and give an example. I also did some copy-editing of the text and added some paragraph breaks. gcc/ChangeLog PR c/113515 * doc/invoke.texi (Warning Options): Improve -Wstringop-overflow documentation.
2025-03-07i386: Correct mask width for bf8->fp16 intrin on 256/512 bitHaochen Jiang4-8/+8
For bf8 -> fp16 convert, when dst is 256 bit, the mask should be 16 bit since 16*16=256, not the 8 bit in the current intrin. In 512 bit intrin, the mask size is also halved. This patch will fix both of them. gcc/ChangeLog: * config/i386/avx10_2-512convertintrin.h (_mm512_mask_cvtbf8_ph): Correct mask width. (_mm512_maskz_cvtbf8_ph): Ditto. * config/i386/avx10_2convertintrin.h (_mm256_mask_cvtbf8_ph): Ditto. (_mm256_maskz_cvtbf8_ph): Ditto. gcc/testsuite/ChangeLog: * gcc.target/i386/avx10_2-512-convert-1.c: Change function call. * gcc.target/i386/avx10_2-convert-1.c: Ditto.
2025-03-07Daily bump.GCC Administrator8-1/+341
2025-03-06[PR rtl-optimization/119099] Avoid infinite loop in ext-dce.Alexey Merzlyakov2-10/+22
This fixes the ping-ponging of live sets in ext-dce which is left unresolved can lead to infinite loops in the ext-dce pass as seen by the P1 regression 119099. At its core instead of replacing the livein set with the just recomputed data, we IOR in the just recomputed data to the existing livein set. That ensures the existing livein set never shrinks. Bootstrapped and regression tested on x86. I've also thrown this into my tester to verify it across multiple targets and that we aren't regressing the (limited) tests we have in place for ext-dce's optimization behavior. While it's a generic patch, I'll wait for the RISC-V tester to run is course before committing. PR rtl-optimization/119099 gcc/ * ext-dce.cc (ext_dce_rd_transfer_n): Do not allow the livein set to shrink. gcc/testsuite/ * gcc.dg/torture/pr119099.c: New test. Co-authored-by: Jeff Law <jlaw@ventanamicro.com>
2025-03-06Fortran: improve checking of substring bounds [PR119118]Harald Anlauf5-3/+125
After the fix for pr98490 no substring bounds check was generated if the substring start was not a variable. While the purpose of that fix was to suppress a premature check before implied-do indices were substituted, this prevented a check if the substring start was an expression or a constant. A better solution is to defer the check until implied-do indices have been substituted in the start and end expressions. PR fortran/119118 gcc/fortran/ChangeLog: * dependency.cc (gfc_contains_implied_index_p): Helper function to determine if an expression has a dependence on an implied-do index. * dependency.h (gfc_contains_implied_index_p): Add prototype. * trans-expr.cc (gfc_conv_substring): Adjust logic to not generate substring bounds checks before implied-do indices have been substituted. gcc/testsuite/ChangeLog: * gfortran.dg/bounds_check_23.f90: Generalize test. * gfortran.dg/bounds_check_26.f90: New test.
2025-03-06Fix comment typosSimon Martin7-18/+17
While investigating PR c++/99538 I noticed two comment typos: "delared" and "paramter". The first has a single occurrence, but the second a few more. This patch fixes all of them. gcc/ChangeLog: * config/i386/x86-tune-sched.cc (ix86_fuse_mov_alu_p): Fix comment typo, paramter -> parameter. * config/lm32/lm32.cc (lm32_std_gimplify_va_arg_expr): Likewise. gcc/cp/ChangeLog: * cp-tree.h (processing_contract_condition): Fix comment typo, paramter -> parameter. * parser.cc (cp_parser_requires_expression): Fix comment typo, delared -> declared. gcc/rust/ChangeLog: * rust-diagnostics.h (RUST_ATTRIBUTE_GCC_DIAG): Fix comment typo, paramter -> parameter. gcc/testsuite/ChangeLog: * gcc.target/powerpc/ppc64-abi-1.c: Fix comment typos, paramter -> parameter. * gcc.target/powerpc/ppc64-abi-2.c: Likewise.
2025-03-06AArch64: Enable early scheduling for -O3 and higher (PR118351)Wilco Dijkstra2-2/+6
Enable the early scheduler on AArch64 for O3/Ofast. This means GCC15 benefits from much faster build times with -O2, but avoids the regressions in lbm which is very sensitive to minor scheduling changes due to long FMA chains. gcc: PR target/118351 PR other/38768 * common/config/aarch64/aarch64-common.cc: Enable early scheduling with -O3 and higher. * doc/invoke.texi (-fschedule-insns): Update comment.
2025-03-06c++: Update TYPE_FIELDS of variant types if ↵Jakub Jelinek3-30/+68
cp_parser_late_parsing_default_args etc. modify it [PR98533] The following testcases ICE during type verification, because TYPE_FIELDS of e.g. S RECORD_TYPE in pr119123.C is different from TYPE_FIELDS of const S. Various decls are added to S's TYPE_FIELDS first, then finish_struct indirectly calls fixup_type_variants to sync the variant copies. But later on cp_parser_class_specifier calls cp_parser_late_parsing_default_args and that apparently adds a lambda type (from default argument) to TYPE_FIELDS of S. Dunno if that is right or not, assuming it is right, the following patch fixes it by updating TYPE_FIELDS of variant types if there were any changes in the various functions cp_parser_class_specifier defers and calls on the outermost enclosing class. There was quite a lot of code repetition already before, so the patch uses a lambda to avoid the repetitions. To my surprise, in some of the contract testcases ( g++.dg/contracts/contracts-friend1.C g++.dg/contracts/contracts-nested-class1.C g++.dg/contracts/contracts-nested-class2.C g++.dg/contracts/contracts-redecl7.C g++.dg/contracts/contracts-redecl8.C ) it is actually setting class_type and pushing TRANSLATION_UNIT_DECL rather than some class types in some cases. Or should the lambda pushing into the containing class be somehow avoided? 2025-03-06 Jakub Jelinek <jakub@redhat.com> PR c++/98533 PR c++/119123 * parser.cc (cp_parser_class_specifier): Update TYPE_FIELDS of variant types in case cp_parser_late_parsing_default_args etc. change TYPE_FIELDS on the main variant. Add switch_to_class lambda and use it to simplify repeated class switching code. * g++.dg/cpp0x/pr98533.C: New test. * g++.dg/cpp0x/pr119123.C: New test.
2025-03-06c++: Fix up instantiation of pointer/reference/array types with attributes ↵Jakub Jelinek2-3/+22
[PR119138] My r15-7822 PR118787 change unfortunately broke build on x86_64-w64-mingw32. The reduced testcase below shows what is going on. va_list on this target is char * with extra (non-dependent) attributes on it. Before my r15-7822 change, instantiation of such type used the fast path and just returned t, but as it has non-NULL TYPE_ATTRIBUTES, it now falls through, builds a pointer type and then calls apply_late_template_attributes. And in there triggers a bug, that function has been written for types with RECORD_TYPE/UNION_TYPE (or ENUMERAL_TYPE?) in mind, where we call apply_late_template_attributes with ATTR_FLAG_TYPE_IN_PLACE and can just apply the non-dependent attributes directly to TYPE_ATTRIBUTES. That is wrong for shared types like {POINTER,REFERENCE,ARRAY}_TYPE etc., we should just force cp_build_type_attribute_variant to build a variant type for the non-dependent attributes and then process dependent attributes (which given attr_flag will DTRT already). The second change in the patch is an optimization, we can actually return back to returning t even when TYPE_ATTRIBUTES is non-NULL, as long as it is non-dependent (dependent attributes are stored first, so it is enough to check the first attribute). 2025-03-06 Jakub Jelinek <jakub@redhat.com> PR c++/119138 * pt.cc (apply_late_template_attributes): Set p to NULL if ATTR_FLAG_TYPE_IN_PLACE is not set in attr_flags. (tsubst) <case POINTER_TYPE, case REFERENCE_TYPE, case ARRAY_TYPE>: Reuse original type even if TYPE_ATTRIBUTES is non-NULL, but all the attributes are non-dependent. * g++.dg/template/pr119138.C: New test.
2025-03-06libstdc++: Make std::unique_lock self-move-assignableJonathan Wakely4-7/+59
LWG 4172 was approved in Hagenberg, February 2025, fixing std::unique_lock and std::shared_lock to work correctly for self-move-assignment. Our std::shared_lock was already doing the right thing (contradicting the standard) so just add a comment there. Our std::unique_lock needs to be fixed to do the right thing. libstdc++-v3/ChangeLog: * include/bits/unique_lock.h (unique_lock::operator=): Fix for self-move-assignment. * include/std/shared_mutex (shared_lock::operator=): Add comment. * testsuite/30_threads/shared_lock/cons/lwg4172.cc: New test. * testsuite/30_threads/unique_lock/cons/lwg4172.cc: New test. Reviewed-by: Patrick Palka <ppalka@redhat.com>
2025-03-06testsuite: Add test for already fixed PR [PR104826]Jakub Jelinek1-0/+8
ICE on this test was fixed by r15-2131. This just adds test for it. 2025-03-06 Jakub Jelinek <jakub@redhat.com> PR fortran/104826 * gfortran.dg/gomp/pr104826.f90: New test.
2025-03-06libstdc++: Add assertions to std::list::pop_{front,back}Jonathan Wakely1-2/+8
The recently-approved Standard Library Hardening proposal (P3471R4) gives pop_front and pop_back member functions hardened preconditions, but std::list was missing assertions on them. Our other sequence containers do have assertions on those members. libstdc++-v3/ChangeLog: * include/bits/stl_list.h (list::pop_front, list::pop_back): Add non-empty assertions. Reviewed-by: Patrick Palka <ppalka@redhat.com>
2025-03-06libstdc++: Ensure <bits/ranges_util.h> defines __pair_likeJonathan Wakely1-0/+3
We need to include <bits/stl_pair.h> in C++23 and later, so that __pair_like_convertible_from can use __pair_like, and so that __is_tuple_like_v is declared before we define a partial specialization. libstdc++-v3/ChangeLog: * include/bits/ranges_util.h: Include <bits/stl_pair.h>. Reviewed-by: Patrick Palka <ppalka@redhat.com>
2025-03-06libstdc++: Remove redundant std::span destructorJonathan Wakely1-2/+0
This destructor declaration serves no purpose, as pointed out by LWG 3903 which was approved at Varna, June 2023. libstdc++-v3/ChangeLog: * include/std/span (span::~span): Remove, as per LWG 3903. Reviewed-by: Patrick Palka <ppalka@redhat.com>
2025-03-06libstdc++: Fix failures in new std::complex test [PR119144]Jonathan Wakely1-4/+5
This test fails due to duplicate explicit instantiations on targets where size_t and unsigned int are the same type. It also fails with -D_GLIBCXX_USE_CXX11_ABI=0 due to using std::string in constexpr functions, and with --disable-libstdcxx-pch due to not including <algorithm> for ranges::fold_left. libstdc++-v3/ChangeLog: PR libstdc++/119144 * testsuite/26_numerics/complex/tuple_like.cc: Include <algorithm>, replace std::string with std::string_view, instantiate tests for long instead of size_t.
2025-03-06Revert "ira: Add new hooks for callee-save vs spills [PR117477]"Richard Sandiford14-459/+39
This reverts commit e836d80374aa03a5ea5bd6cca00d826020c461da.
2025-03-06lto/114501 - missed free-lang-data for CONSTRUCTOR indexRichard Biener2-0/+34
The following makes sure to also walk CONSTRUCTOR element indexes which can be FIELD_DECLs, referencing otherwise unused types we need to clean. walk_tree only walks CONSTRUCTOR element data. PR lto/114501 * ipa-free-lang-data.cc (find_decls_types_r): Explicitly handle CONSTRUCTORs as walk_tree handling of those is incomplete. * g++.dg/pr114501_0.C: New testcase.
2025-03-06Fix 'libstdc++-v3/src/c++20/tzdb.cc' build for '__GTHREADS && ↵Jonathan Wakely1-1/+11
!__GTHREADS_CXX0X' configurations libstdc++-v3/ * src/c++20/tzdb.cc [__GTHREADS && !__GTHREADS_CXX0X]: Use '__gnu_cxx::__mutex'. Co-authored-by: Thomas Schwinge <tschwinge@baylibre.com>
2025-03-06libstdc++: Avoid '-Wunused-parameter' for 'out' in member function ↵Thomas Schwinge1-1/+1
'std::codecvt_base::result std::__format::{anonymous}::__encoding::conv(std::string_view, std::string&) const' In a newlib configuration: ../../../../../source-gcc/libstdc++-v3/src/c++20/format.cc: In member function ‘std::codecvt_base::result std::__format::{anonymous}::__encoding::conv(std::string_view, std::string&) const’: ../../../../../source-gcc/libstdc++-v3/src/c++20/format.cc:100:35: error: unused parameter ‘out’ [-Werror=unused-parameter] 100 | conv(string_view input, string& out) const | ~~~~~~~~^~~ libstdc++-v3/ * src/c++20/format.cc (conv): Tag 'out' as '[[maybe_unused]]'.
2025-03-06libstdc++: Avoid '-Wunused-parameter' for 'is_directory' in member function ↵Thomas Schwinge1-1/+1
'bool std::filesystem::__cxx11::_Dir::do_unlink(bool, std::error_code&) const' In a newlib configuration: ../../../../../source-gcc/libstdc++-v3/src/c++17/fs_dir.cc: In member function ‘bool std::filesystem::__cxx11::_Dir::do_unlink(bool, std::error_code&) const’: ../../../../../source-gcc/libstdc++-v3/src/c++17/fs_dir.cc:147:18: error: unused parameter ‘is_directory’ [-Werror=unused-parameter] 147 | do_unlink(bool is_directory, error_code& ec) const noexcept | ~~~~~^~~~~~~~~~~~ libstdc++-v3/ * src/c++17/fs_dir.cc (do_unlink): Tag 'is_directory' as '[[maybe_unused]]'.
2025-03-06libstdc++: Avoid '-Wunused-parameter' for 'nofollow' in static member ↵Thomas Schwinge1-1/+1
function 'static std::filesystem::__gnu_posix::DIR* std::filesystem::_Dir_base::openat(const _At_path&, bool)' In a newlib configuration: In file included from ../../../../../source-gcc/libstdc++-v3/src/c++17/fs_dir.cc:37, from ../../../../../source-gcc/libstdc++-v3/src/c++17/cow-fs_dir.cc:26: ../../../../../source-gcc/libstdc++-v3/src/c++17/../filesystem/dir-common.h: In static member function ‘static std::filesystem::__gnu_posix::DIR* std::filesystem::_Dir_base::openat(const _At_path&, bool)’: ../../../../../source-gcc/libstdc++-v3/src/c++17/../filesystem/dir-common.h:210:36: error: unused parameter ‘nofollow’ [-Werror=unused-parameter] 210 | openat(const _At_path& atp, bool nofollow) | ~~~~~^~~~~~~~ libstdc++-v3/ * src/filesystem/dir-common.h (openat): Tag 'nofollow' as '[[maybe_unused]]'.
2025-03-06libstdc++: Avoid '-Wunused-parameter' for '__what' in function 'void ↵Thomas Schwinge1-1/+1
std::__throw_format_error(const char*)' In a '-fno-exceptions' configuration: In file included from ../../../../../source-gcc/libstdc++-v3/src/c++20/format.cc:29: [...]/build-gcc/[...]/libstdc++-v3/include/format: In function ‘void std::__throw_format_error(const char*)’: [...]/build-gcc/[...]/libstdc++-v3/include/format:200:36: error: unused parameter ‘__what’ [-Werror=unused-parameter] 200 | __throw_format_error(const char* __what) | ~~~~~~~~~~~~^~~~~~ libstdc++-v3/ * include/bits/c++config [!__cpp_exceptions] (_GLIBCXX_THROW_OR_ABORT): Reference '_EXC'. Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
2025-03-06libstdc++: Fix constexpr memory algo tests for COW std::stringJonathan Wakely5-0/+10
The old COW std::string is not usable in constant expressions, so these new tests fail with -D_GLIBCXX_USE_CXX11_ABI=0. The parts of the tests using std::string can be conditionally skipped. libstdc++-v3/ChangeLog: * testsuite/20_util/specialized_algorithms/uninitialized_copy/constexpr.cc: Do not test COW std::string in constexpr contexts. * testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constexpr.cc: Likewise. * testsuite/20_util/specialized_algorithms/uninitialized_fill/constexpr.cc: Likewise. * testsuite/20_util/specialized_algorithms/uninitialized_move/constexpr.cc: Likewise. * testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constexpr.cc: Likewise. Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2025-03-06pair-fusion: Add singleton move_range asserts [PR114492]Alex Coplan1-2/+4
The PR claims that pair-fusion has invalid uses of gcc_assert (such that the pass will misbehave with --disable-checking). As noted in the comments, in the case of the calls to restrict_movement, the only way we can possibly depend on the side effects is if we call it with a non-singleton move range. However, the intent is that we always have a singleton move range here, and thus we do not rely on the side effects. This patch therefore adds asserts to check for a singleton move range before calling restrict_movement, thus clarifying the intent and hopefully dispelling any concerns that having the calls wrapped in asserts is problematic here. gcc/ChangeLog: PR rtl-optimization/114492 * pair-fusion.cc (pair_fusion_bb_info::fuse_pair): Check for singleton move range before calling restrict_movement. (pair_fusion::try_promote_writeback): Likewise.
2025-03-06libstdc++: implement tuple protocol for std::complex (P2819R2)Giuseppe D'Angelo6-1/+316
This commit implements P2819R2 for C++26, making std::complex destructurable and tuple-like (see [complex.tuple]). std::get needs to get forward declared in stl_pair.h (following the existing precedent for the implementation of P2165R4, cf. r14-8710-g65b4cba9d6a9ff), and implemented in <complex>. Also, std::get(complex<T>) needs to return *references* to the real and imaginary parts of a std::complex object, honoring the value category and constness of the argument. In principle a straightforward task, it gets a bit convoluted by the fact that: 1) std::complex does not have existing getters that one can use for this (real() and imag() return values, not references); 2) there are specializations for language/extended floating-point types, which requires some duplication -- need to amend the primary and all the specializations; 3) these specializations use a `__complex__ T`, but the primary template uses two non-static data members, making generic code harder to write. The implementation choice used here is to add the overloads of std::get for complex as declared in [complex.tuple]. In turn they dispatch to a newly added getter that extracts references to the real/imaginary parts of a complex<T>. This getter is private API, and the implementation depends on whether it's the primary (bind the data member) or a specialization (use the GCC language extensions for __complex__). To avoid duplication and minimize template instantiations, the getter uses C++23's deducing this (this avoids const overloads). The value category is dealt with by the std::get overloads. Add a test that covers the aspects of the tuple protocol, as well as the tuple-like interface. While at it, add a test for the existing tuple-like feature-testing macro. PR libstdc++/113310 libstdc++-v3/ChangeLog: * include/bits/stl_pair.h (get): Forward-declare std::get for std::complex. * include/bits/version.def (tuple_like): Bump the value of the feature-testing macro in C++26. * include/bits/version.h: Regenerate. * include/std/complex: Implement the tuple protocol for std::complex. (tuple_size): Specialize for std::complex. (tuple_element): Ditto. (__is_tuple_like_v): Ditto. (complex): Add a private getter to obtain references to the real and the imaginary part, on the primary class template and on its specializations. (get): Add overloads of std::get for std::complex. * testsuite/20_util/tuple/tuple_like_ftm.cc: New test. * testsuite/26_numerics/complex/tuple_like.cc: New test.
2025-03-06ira: Add new hooks for callee-save vs spills [PR117477]Richard Sandiford14-39/+459
Following on from the discussion in: https://gcc.gnu.org/pipermail/gcc-patches/2025-February/675256.html this patch removes TARGET_IRA_CALLEE_SAVED_REGISTER_COST_SCALE and replaces it with two hooks: one that controls the cost of using an extra callee-saved register and one that controls the cost of allocating a frame for the first spill. (The patch does not attempt to address the shrink-wrapping part of the thread above.) On AArch64, this is enough to fix PR117477, as verified by the new tests. The patch does not change the SPEC2017 scores significantly. (I saw a slight improvement in fotonik3d and roms, but I'm not convinced that the improvements are real.) The patch makes IRA use caller saves for gcc.target/aarch64/pr103350-1.c, which is a scan-dump correctness test that relies on not using caller saves. The decision to use caller saves looks appropriate, and saves an instruction, so I've just added -fno-caller-saves to the test options. The x86 parts were written by Honza. gcc/ PR rtl-optimization/117477 * config/aarch64/aarch64.cc (aarch64_count_saves): New function. (aarch64_count_above_hard_fp_saves, aarch64_callee_save_cost) (aarch64_frame_allocation_cost): Likewise. (TARGET_CALLEE_SAVE_COST): Define. (TARGET_FRAME_ALLOCATION_COST): Likewise. * config/i386/i386.cc (ix86_ira_callee_saved_register_cost_scale): Replace with... (ix86_callee_save_cost): ...this new hook. (TARGET_IRA_CALLEE_SAVED_REGISTER_COST_SCALE): Delete. (TARGET_CALLEE_SAVE_COST): Define. * target.h (spill_cost_type, frame_cost_type): New enums. * target.def (callee_save_cost, frame_allocation_cost): New hooks. (ira_callee_saved_register_cost_scale): Delete. * doc/tm.texi.in (TARGET_IRA_CALLEE_SAVED_REGISTER_COST_SCALE): Delete. (TARGET_CALLEE_SAVE_COST, TARGET_FRAME_ALLOCATION_COST): New hooks. * doc/tm.texi: Regenerate. * hard-reg-set.h (hard_reg_set_popcount): New function. * ira-color.cc (allocated_memory_p): New variable. (allocated_callee_save_regs): Likewise. (record_allocation): New function. (assign_hard_reg): Use targetm.frame_allocation_cost to model the cost of the first spill or first caller save. Use targetm.callee_save_cost to model the cost of using new callee-saved registers. Apply the exit rather than entry frequency to the cost of restoring a register or deallocating the frame. Update the new variables above. (improve_allocation): Use record_allocation. (color): Initialize allocated_callee_save_regs. (ira_color): Initialize allocated_memory_p. * targhooks.h (default_callee_save_cost): Declare. (default_frame_allocation_cost): Likewise. * targhooks.cc (default_callee_save_cost): New function. (default_frame_allocation_cost): Likewise. gcc/testsuite/ PR rtl-optimization/117477 * gcc.target/aarch64/callee_save_1.c: New test. * gcc.target/aarch64/callee_save_2.c: Likewise. * gcc.target/aarch64/callee_save_3.c: Likewise. * gcc.target/aarch64/pr103350-1.c: Add -fno-caller-saves. Co-authored-by: Jan Hubicka <hubicka@ucw.cz>
2025-03-06lto: Fix missing cleanup with incremental LTO.Michal Jires1-0/+11
Incremental LTO disabled cleanup of output_files since they have to persist in ltrans cache. This unintetionally also kept temporary early debug "*.debug.temp.o" files. Bootstrapped/regtested on x86_64-linux. Ok for trunk? lto-plugin/ChangeLog: * lto-plugin.c (cleanup_handler): Keep only files in ltrans cache.
2025-03-06middle-end/119119 - re-gimplification of empty CTOR assignmentsRichard Biener2-1/+22
The following testcase runs into a re-gimplification issue during inlining when processing MEM[(struct e *)this_2(D)].a = {}; where re-gimplification does not handle assignments in the same way than the gimplifier but instead relies on rhs_predicate_for and gimplifying the RHS standalone. This fails to handle special-casing of CTORs. The is_gimple_mem_rhs_or_call predicate already handles clobbers but not empty CTORs so we end up in the fallback code trying to force the CTOR into a separate stmt using a temporary - but as we have a non-copyable type here that ICEs. The following generalizes empty CTORs in is_gimple_mem_rhs_or_call since those need no additional re-gimplification. PR middle-end/119119 * gimplify.cc (is_gimple_mem_rhs_or_call): All empty CTORs are OK when not a register type. * g++.dg/torture/pr11911.C: New testcase.
2025-03-06c++: Don't replace INDIRECT_REFs by a const capture proxy too eagerly [PR117504]Simon Martin3-5/+72
We have been miscompiling the following valid code since GCC8, and r8-3497-g281e6c1d8f1b4c === cut here === struct span { span (const int (&__first)[1]) : _M_ptr (__first) {} int operator[] (long __i) { return _M_ptr[__i]; } const int *_M_ptr; }; void foo () { constexpr int a_vec[]{1}; auto vec{[&a_vec]() -> span { return a_vec; }()}; } === cut here === The problem is that perform_implicit_conversion_flags (via mark_rvalue_use) replaces "a_vec" in the return statement by a CONSTRUCTOR representing a_vec's constant value, and then takes its address when invoking span's constructor. So we end up with an instance that points to garbage instead of a_vec's storage. As per Jason's suggestion, this patch simply removes the calls to mark_*_use from perform_implicit_conversion_flags, which fixes the PR. PR c++/117504 gcc/cp/ChangeLog: * call.cc (perform_implicit_conversion_flags): Don't call mark_{l,r}value_use. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/constexpr-117504.C: New test. * g++.dg/cpp2a/constexpr-117504a.C: New test.
2025-03-06RISC-V: Tweak asm check for test case multiple_rgroup_zbb.cPan Li1-1/+4
The changes to vsetvl pass since 14 result in the asm check failure, update the asm check to meet the newest behavior. The below test suites are passed for this patch. * The rv64gcv fully regression test. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_zbb.c: Tweak the asm check for vsetvl. Signed-off-by: Pan Li <pan2.li@intel.com>
2025-03-05Improve coverage of ext-dce tests in risc-v testsuiteJeff Law2-2/+4
Inspired by Liao Shihua, this adjusts two tests in the RISC-V testsuite to get more coverage. Drop the -O1 argument and replace it with -fext-dce. That way the test gets run across the full set of flags. We just need to make sure to skip -O0. gcc/testsuite/ChangeLog: * gcc.target/riscv/core_list_init.c: Use -fext-dce rather than -O1. Skip for -O0. * gcc.target/riscv/pr111384.c: Ditto.
2025-03-06Daily bump.GCC Administrator9-1/+304
2025-03-05PR modula2/118998 Rotate of a packetset causes different types to binary ↵Gaius Mulley5-6/+118
operator error This patch allow a packedset to be rotated by the system module intrinsic procedure function. It ensures that both operands to the tree rotate are of the same type. In turn the result will be the same type and the assignment into the designator (of the same set type) will succeed. gcc/m2/ChangeLog: PR modula2/118998 * gm2-gcc/m2expr.cc (m2expr_BuildLRotate): Convert nBits to the return type. (m2expr_BuildRRotate): Ditto. (m2expr_BuildLogicalRotate): Convert op3 to an integer type. Replace op3 aith rotateCount. Negate rotateCount if it is negative and call rotate right. * gm2-gcc/m2pp.cc (m2pp_bit_and_expr): New function. (m2pp_binary_function): Ditto. (m2pp_simple_expression): BIT_AND_EXPR new case clause. LROTATE_EXPR ditto. RROTATE_EXPR ditto. gcc/testsuite/ChangeLog: PR modula2/118998 * gm2/iso/pass/testrotate.mod: New test. * gm2/pim/fail/tinyconst.mod: New test. * gm2/sets/run/pass/simplepacked.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2025-03-05libstdc++: Make enumerate_view::iterator::operator- noexceptJonathan Wakely2-1/+12
Implement LWG 3912, approved in Varna, June 2023. libstdc++-v3/ChangeLog: * include/std/ranges (enumerate_view::_Iterator::operator-): Add noexcept, as per LWG 3912. * testsuite/std/ranges/adaptors/enumerate/1.cc: Check iterator difference is noexcept.
2025-03-05libstdc++: fix possible undefined std::timespec in module stdyxj-github-4371-1/+1
I notice std::timespec and std::timespec_get are used in preprocessor condition _GLIBCXX_HAVE_TIMESPEC_GET. So in module std, it should be the same. libstdc++-v3: * src/c++23/std-clib.cc.in (timespec): Move within preprocessor group guarded by _GLIBCXX_HAVE_TIMESPEC_GET.
2025-03-05libstdc++: Move new functions to separate files [PR119110]Jonathan Wakely4-58/+66
The new test functions I added in r15-7765-g3866ca796d5281 are causing those tests to FAIL on Solaris and arm-thumb due to the linker complaining about undefined functions. The new test functions are not called, so it shouldn't matter that they call undefined member functions, but it does. Move those functions to separate { dg-do compile } files so the linker isn't used and won't complain. libstdc++-v3/ChangeLog: PR libstdc++/119110 * testsuite/25_algorithms/move/constrained.cc: Move test06 function to ... * testsuite/25_algorithms/move/105609.cc: New test. * testsuite/25_algorithms/move_backward/constrained.cc: Move test04 function to ... * testsuite/25_algorithms/move_backward/105609.cc: New test.
2025-03-05Regenerate fortran/lang.opt.urlsMark Wielaard1-0/+3
fortran added a new -Wexternal-argument-mismatch option, but the lang.opt.urls file wasn't regenerated. Fixes: 21ca9153ebe5 ("C prototypes for external arguments; add warning for mismatch.") gcc/fortran/ChangeLog: * lang.opt.urls: Regenerated.
2025-03-05libstdc++: Implement P3138R5 views::cache_latestPatrick Palka4-0/+279
libstdc++-v3/ChangeLog: * include/bits/version.def (ranges_cache_latest): Define. * include/bits/version.h: Regenerate. * include/std/ranges (__detail::__non_propagating_cache::_M_reset): Export from base class _Optional_base. (cache_latest_view): Define for C++26. (cache_latest_view::_Iterator): Likewise. (cache_latest_view::_Sentinel): Likewise. (views::__detail::__can_cache_latest): Likewise. (views::_CacheLatest, views::cache_latest): Likewise. * testsuite/std/ranges/adaptors/cache_latest/1.cc: New test. Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2025-03-05c++: disable -Wnonnull in unevaluated context [PR115580]Marek Polacek2-0/+19
This PR complains that we issue a -Wnonnull even in a decltype. This fix disables even -Wformat and -Wrestrict. I think that's fine. PR c++/115580 gcc/c-family/ChangeLog: * c-common.cc (check_function_arguments): Return early if c_inhibit_evaluation_warnings. gcc/testsuite/ChangeLog: * g++.dg/warn/Wnonnull16.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2025-03-05libstdc++: use if consteval in stable_sortGiuseppe D'Angelo1-5/+5
This is a C++ >= 26 codepath for supporting constexpr stable_sort, so we know that we have if consteval available; it just needs protection with the feature-testing macro. Also merge the return in the same statement. Amends r15-7708-gff43f9853d3b10. libstdc++-v3/ChangeLog: * include/bits/stl_algo.h (__stable_sort): Use if consteval instead of is_constant_evaluated. Reviewed-by: Jonathan Wakely <jwakely@redhat.com>