aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2025-08-04optinfo: use enum classDavid Malcolm6-88/+90
Modernization; no functional change intended. gcc/ChangeLog: * dump-context.h: Convert "enum optinfo_item_kind" into "enum class kind" within class optinfo_item. * dumpfile.cc: Likewise. Use "auto" in a few places. Convert "enum optinfo_kind" to "enum class kind" within class optinfo. * opt-problem.cc: Likewise. * optinfo-emit-json.cc: Likewise. * optinfo.cc: Likewise. * optinfo.h: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-04diagnostics: improve support for nesting levels [PR116253]David Malcolm17-10/+408
This patch adds support to sarif-replay for "nestingLevel" from "P3358R0 SARIF for Structured Diagnostics" https://wg21.link/P3358R0 Doing so revealed a bug where libgdiagnostics was always creating new location_t values (and thus also diagnostic_physical_location instances), rather than reusing existing location_t values, leading to excess source printing. The patch also fixes this bug, adding a new flag to libgdiagnostics for debugging physical locations, and exposing this in sarif-replay via a new "-fdebug-physical-locations" maintainer option. Finally, the patch adds test coverage for the HTML sink's output of nested diagnostics (both from a GCC plugin, and from sarif-replay). gcc/ChangeLog: PR diagnostics/116253 * diagnostics/context.cc (context::set_nesting_level): New. * diagnostics/context.h (context::set_nesting_level): New decl. * doc/libgdiagnostics/topics/compatibility.rst (LIBGDIAGNOSTICS_ABI_5): New. * doc/libgdiagnostics/topics/physical-locations.rst (diagnostic_manager_set_debug_physical_locations): New. * libgdiagnostics++.h (manager::set_debug_physical_locations): New. * libgdiagnostics-private.h (private_diagnostic_set_nesting_level): New decl. * libgdiagnostics.cc (diagnostic_manager::diagnostic_manager): Initialize m_debug_physical_locations. (diagnostic_manager::new_location_from_file_and_line): Add debug printing. (diagnostic_manager::new_location_from_file_line_column): Likewise. (diagnostic_manager::new_location_from_range): Likewise. (diagnostic_manager::set_debug_physical_locations): New. (diagnostic_manager::ensure_linemap_for_file_and_line): Avoid redundant calls to linemap_add. (diagnostic_manager::new_location): Add debug printing. (diagnostic_manager::m_debug_physical_locations): New field. (diagnostic::diagnostic): Initialize m_nesting_level. (diagnostic::get_nesting_level): New accessor. (diagnostic::set_nesting_level): New. (diagnostic::m_nesting_level): New field. (diagnostic_manager::emit_va): Set and reset the nesting level of the context from that of the diagnostic. (diagnostic_manager_set_debug_physical_locations): New. (private_diagnostic_set_nesting_level): New. * libgdiagnostics.h (diagnostic_manager_set_debug_physical_locations): New decl. * libgdiagnostics.map (LIBGDIAGNOSTICS_ABI_5): New. * libsarifreplay.cc (sarif_replayer::handle_result_obj): Support the "nestingLevel" property. * libsarifreplay.h (replay_options::m_debug_physical_locations): New field. * sarif-replay.cc: Add -fdebug-physical-locations. gcc/testsuite/ChangeLog: PR diagnostics/116253 * gcc.dg/plugin/diagnostic-test-nesting-html.c: New test. * gcc.dg/plugin/diagnostic-test-nesting-html.py: New test script. * gcc.dg/plugin/plugin.exp: Add it. * libgdiagnostics.dg/test-multiple-lines.c: Update expected output to show fix-it hint. * sarif-replay.dg/2.1.0-valid/nested-diagnostics-1.sarif: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-04diagnostics: avoid stray trailing space in html sink in sarif-replay [PR116792]David Malcolm4-7/+11
For the common case where a diagnostic has no metadata, sarif-replay's html output was adding a stray space followed by an empty <div> for the metadata. Fixed thusly. gcc/ChangeLog: PR diagnostics/116792 * diagnostics/html-sink.cc (html_builder::make_element_for_diagnostic): Don't add the metadata element if it's empty. (html_builder::make_element_for_metadata): Return null rather than an empty element. gcc/testsuite/ChangeLog: PR diagnostics/116792 * gcc.dg/plugin/diagnostic-test-graphs-html.py: Remove trailing space from expected text of message. * sarif-replay.dg/2.1.0-valid/embedded-links-check-html.py: Likewise. * sarif-replay.dg/2.1.0-valid/graphs-check-html.py: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-04diagnostics: move diagnostics::counters to its own headerDavid Malcolm2-22/+52
gcc/ChangeLog: * diagnostics/context.h: Move struct counters to its own header and include it. * diagnostics/counters.h: New file, from the above. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-04diagnostics: split source_printing_options out into its own headerDavid Malcolm2-49/+77
No functional change intended. gcc/ChangeLog: * diagnostics/context.h: Split struct source_printing_options out into "diagnostics/source-printing-options.h" and include it. * diagnostics/source-printing-options.h: New file, from the above. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-04diagnostics: rename option_manager to option_id_manager and split out from ↵David Malcolm9-73/+103
context.h This patch splits out class option_manager to its own header, and renames it to class option_id_manager to better describe its purpose. No functional change intended. gcc/ChangeLog: * diagnostics/context.cc: Update for renaming of option_manager to option_id_manager and of context::m_option_mgr to context::m_option_id_mgr. * diagnostics/context.h: Likewise, moving class declaration to a new diagnostics/option-id-manager.h. * diagnostics/lazy-paths.cc: Likewise. * diagnostics/option-id-manager.h: New file, from material in diagnostics/context.h. * lto-wrapper.cc: Update for renaming of option_manager to option_id_manager. * opts-common.cc: Likewise. * opts-diagnostic.h: Likewise. * opts.cc: Likewise. * toplev.cc: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-04diagnostics: fix comment in buffering.hDavid Malcolm1-5/+5
gcc/ChangeLog: * diagnostics/buffering.h: Update comment to refer to output sinks rather than output formats. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-04gimple-warn-recursion.cc: add missing auto_diagnostic_groupDavid Malcolm1-0/+1
gcc/ChangeLog: * gimple-warn-recursion.cc (pass_warn_recursion::execute): Add missing auto_diagnostic_group. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-04asf: Fix null pointer dereference in is_store_forwarding [PR121303]Konstantinos Eleftheriou2-1/+34
We were calling `is_store_forwarding` with a NULL value for `off_val`, which was causing a null pointer dereference in `is_constant`, leading to an ICE. This patch updates the call to `is_constant` in `is_store_forwarding` and adds a check for `off_val`, in order to update it with the right value. Bootstrapped/regtested on AArch64 and x86_64. PR rtl-optimization/121303 gcc/ChangeLog: * avoid-store-forwarding.cc (is_store_forwarding): Add check for `off_val` in `is_store_forwarding`. gcc/testsuite/ChangeLog: * gcc.target/i386/pr121303.c: New test.
2025-08-04c++: Add #line testcase for CWG2580 [PR120778]Jakub Jelinek1-0/+87
Contrary to what the paper says, I think for #line directives we diagnose everything we should (sure, some diagnostics are pedwarns). 2025-08-04 Jakub Jelinek <jakub@redhat.com> PR preprocessor/120778 * g++.dg/DRs/dr2580.C: New test.
2025-08-04ada: Update Assertion_Policy handling in GNATProve modeViljar Indus14-77/+87
Previously in GNATProve_Mode the frontend would overwrite all of the assertion policies to check in order to force the generation of all of the assertions. This however prevents GNATProve from performing policy related checks in the tool. Since they are all artificially changed to check. This patch removes the modifications to the applicable assertion policies and instead prevents code from ignored entities being removed when in GNATProve_Mode. gcc/ada/ChangeLog: * contracts.adb: Use Is_Ignored_In_Codegen instead of just using Is_Ignored. * exp_ch6.adb: Likewise. * exp_prag.adb: Likewise. * exp_util.adb: Likewise. * frontend.adb: Avoid removal of ignored nodes in GNATProve_Mode. * gnat1drv.adb: Avoid forcing Assertions_Enabled in GNATProve_Mode. * lib-writ.adb (Write_With_File_Names): Avoid early exit with ignored entities in GNATProve_Mode. * lib-xref.adb: Likewise. * opt.adb: Remove check for Assertions_Enabled. * sem_attr.adb: Use Is_Ignored_In_Codegen instead of Is_Ignored. * sem_ch13.adb: Likewise. Additionally always add predicates in GNATProve_Mode. * sem_prag.adb: Likewise. Additionally remove modifications to applied policies in GNATProve_Mode. * sem_util.adb (Is_Ignored_In_Codegen): New function that overrides Is_Ignored in GNATProve_Mode and Codepeer_Mode. (Is_Ignored_Ghost_Pragma_In_Codegen): Likewise for Is_Ignored_Ghost_Pragma. (Is_Ignored_Ghost_Entity_In_Codegen): Likewise for Is_Ignored_Ghost_Entity. (Policy_In_List): Remove overriding of policies in GNATProve_Mode. * sem_util.ads: Add specs for new functions. * (Predicates_Enabled): Always generate predicates in GNATProve_Mode.
2025-08-04ada: Make pp and friends more robustBob Duff1-9/+7
Print_Node_Ref, which is called by pp, sometimes calls Compile_Time_Known_Value, which blows up if Entity (N) is empty. Rearrange the tests here, and test for Present (Entity (N)) before calling Compile_Time_Known_Value. Remove test "Nkind (N) in N_Subexpr", which is redundant with other tests. We don't want to make Compile_Time_Known_Value more robust; you shouldn't call it on half-baked nodes. But ideally pp should be able to print such nodes. This change fixes one of many such cases. gcc/ada/ChangeLog: * treepr.adb (Print_Node_Ref): Protect against Entity (N) being empty before calling Compile_Time_Known_Value.
2025-08-04ada: Check Compile_Time_Errors removed in Ghost codeViljar Indus1-0/+8
gcc/ada/ChangeLog: * sem_prag.adb (Validate_Compile_Time_Warning_Errors): Check if the original compile time pragma was replaced and validate the original node instead.
2025-08-04ada: Refactor Validate_Compile_Time_Warning_Or_ErrorViljar Indus1-90/+102
Simplify the creation of the control characters in Validate_Compile_Time_Warning_Or_Error. gcc/ada/ChangeLog: * sem_prag.adb (Validate_Compile_Time_Warning_Or_Error): simplify the implementation.
2025-08-04ada: Implement accessibility legality check for discriminated function result.Steve Baird1-1/+11
If a function result type has an access discriminant, then we already generate a run-time accessibility check for a return statement. But if we know statically that the check (if executed) is going to fail, then that should be rejected at compile-time as a violation of RM 6.5(5.9). Add this additional compile-time check. gcc/ada/ChangeLog: * exp_ch6.adb (Apply_Access_Discrims_Accessibility_Check): If the accessibility level being checked is known statically, then statically check it against the level of the function being returned from.
2025-08-04ada: Keep Ghost_Mode related variables in a recordViljar Indus20-156/+128
Simplify the storing process for ghost mode related variables and make the process more extendable if new ghost mode related features are added. gcc/ada/ChangeLog: * atree.adb: update references to Ghost_Mode. * exp_ch3.adb: use a structure type to store all of the existing ghost mode related state variables. * exp_disp.adb: Likewise. * exp_spark.adb: Likewise. * exp_util.adb: Likewise. * expander.adb: Likewise. * freeze.adb: Likewise and replace references to existing ghost mode variables. * ghost.adb (Install_Ghost_Region): install the changes of the region in to the new Ghost_Config structure. (Restore_Ghost_Region): Use the new Ghost_Config instead. In general replace all references to the existing ghost mode variables with the new structure equivalent. * ghost.ads (Restore_Ghost_Region): update the spec. * opt.ads (Ghost_Config_Type): A new type that has two of the previous ghost code related global variables as memembers - Ghost_Mode and Ignored_Ghost_Region. (Ghost_Config) New variable to store the previous Ghost_Mode and Ignored_Ghost_Region info. * rtsfind.adb: Replace references to existing ghost mode variables. * sem.adb: Likewise. * sem_ch12.adb: Likewise. * sem_ch13.adb: Likewise. * sem_ch3.adb: Likewise. * sem_ch5.adb: Likewise. * sem_ch6.adb: Likewise. * sem_ch7.adb: Likewise. * sem_prag.adb: Likewise. * sem_util.adb: Likewise.
2025-08-04ada: Avoid generating incorrect warningSteve Baird1-0/+2
Do not generate a warning stating that the size of a formal parameter is 8 bits unless the size of the formal parameter is 8 bits. gcc/ada/ChangeLog: * freeze.adb (Freeze_Profile): Do not emit a warning stating that a formal parameter's size is 8 if the parameter's size is not 8.
2025-08-04ada: Fix code quality issue in table.adbViljar Indus2-3/+3
gcc/ada/ChangeLog: * table.adb (Max): Move variable to the body and initialize it with the same value as in the Init function. * table.ads (Max): Likewise.
2025-08-04ada: Misc parser cleanupBob Duff5-229/+236
...which might make it easier to deal with incorrectly shared subtrees created during parsing. There were several Idents arrays, with duplicated code and commentary. And the related code had somewhat diverged -- different comments, different index subtypes (Pos vs. Int), etc. DRY: Move at least some of the code into Par.Util. Raise Program_Error if the array overflows; there is really no reason not to check, along with several comments saying we don't check. In the unlikely event that the array overflows, the compiler will now crash, which seems better than erroneous execution (which could conceivably cause bad code to be generated). Move the block comments titled "Handling Semicolon Used in Place of IS" and "Handling IS Used in Place of Semicolon" so they are together, which seems obviously desirable. Rewrite the latter comment. No need to denigrate other parsers. gcc/ada/ChangeLog: * par.adb: Move and rewrite some comments. (Util): Shared code and comments for dealing with defining_identifier_lists. * par-util.adb (Append): Shared code for appending one identifier onto Defining_Identifiers. (P_Def_Ids): Shared code for parsing a defining_identifier_list. Unfortunately, this is not used in all cases, because some of them mix in sophisticated error recovery, which we do not modify here. * par-ch12.adb (P_Formal_Object_Declarations): Use Defining_Identifiers and related code. * par-ch3.adb (P_Identifier_Declarations): Likewise. (P_Known_Discriminant_Part_Opt): Likewise. (P_Component_Items): Likewise. * par-ch6.adb (P_Formal_Part): Likewise.
2025-08-04Fail early when SLP instance build failsRichard Biener1-32/+56
The following makes us fail earlier when parts of the SLP build fails. Currently we rely on hybrid stmt detection later to discover not all stmts are covered by SLP, but this code should go away. I've also seen a case of a missed gcond SLP build that went undetected. So the following makes us fail during vect_analyze_slp if any of the SLP instances we expect to discover fails. * tree-vect-slp.cc (vect_analyze_slp): When analyzing a loop and slp instance discovery fails, immediately fail the whole process.
2025-08-04libcpp: Use pedwarn instead of warning for CWG2578 diagnostics [PR120778]Jakub Jelinek1-0/+10
This is another case which changed from compile time undefined behavior to ill-formed, diagnostic required. Now, we warn on this, so pedantically that is good enough, maybe all we need is a testcase, but the following patch changes it to a pedwarn for C++26. 2025-08-04 Jakub Jelinek <jakub@redhat.com> PR preprocessor/120778 * macro.cc (stringify_arg): For C++26 emit a pedarn instead of warning for \ at the end of stringification. * g++.dg/DRs/dr2578.C: New test.
2025-08-04aarch64: Check the mode of SVE ACLE function resultsRichard Sandiford1-1/+21
After previous patches, we should always get a VNx16BI result for ACLE intrinsics that return svbool_t. This patch adds an assert that checks a more general condition than that. gcc/ * config/aarch64/aarch64-sve-builtins.cc (function_expander::expand): Assert that the return value has an appropriate mode.
2025-08-04aarch64: Use VNx16BI for svdupq_b*Richard Sandiford4-13/+63
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the predicate forms of svdupq. The general predicate expansion builds an equivalent integer vector and then compares it with zero. This patch therefore relies on the earlier patches to the comparison patterns. gcc/ * config/aarch64/aarch64-protos.h (aarch64_convert_sve_data_to_pred): Remove the mode argument. * config/aarch64/aarch64.cc (aarch64_sve_emit_int_cmp): Allow PRED_MODE to be VNx16BI or the natural predicate mode for the data mode. (aarch64_convert_sve_data_to_pred): Remove the mode argument and instead always create a VNx16BI result. (aarch64_expand_sve_const_pred): Update call accordingly. * config/aarch64/aarch64-sve-builtins-base.cc (svdupq_impl::expand): Likewise, ensuring that the result has mode VNx16BI. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general/dupq_13.c: New test.
2025-08-04aarch64: Use VNx16BI for svdup_b*Richard Sandiford5-5/+87
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the predicate forms of svdup. gcc/ * config/aarch64/aarch64-protos.h (aarch64_emit_sve_pred_vec_duplicate): Declare. * config/aarch64/aarch64.cc (aarch64_emit_sve_pred_vec_duplicate): New function. * config/aarch64/aarch64-sve.md (vec_duplicate<PRED_ALL:mode>): Use it. * config/aarch64/aarch64-sve-builtins-base.cc (svdup_impl::expand): Handle boolean values specially. Check for constants and fall back on aarch64_emit_sve_pred_vec_duplicate for the variable case, ensuring that the result has mode VNx16BI. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general/dup_1.c: New test.
2025-08-04aarch64: Use VNx16BI for svpnext*Richard Sandiford3-5/+204
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the svpnext* intrinsics. gcc/ * config/aarch64/iterators.md (PNEXT_ONLY): New int iterator. * config/aarch64/aarch64-sve.md (@aarch64_sve_<sve_pred_op><mode>): Restrict SVE_PITER pattern to VNx16BI_ONLY. (@aarch64_sve_<sve_pred_op><mode>): New PNEXT_ONLY pattern for PRED_HSD. (*aarch64_sve_<sve_pred_op><mode>): Likewise. (*aarch64_sve_<sve_pred_op><mode>_cc): Likewise. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general/pnext_3.c: New test.
2025-08-04aarch64: Use VNx16BI for sv(n)match*Richard Sandiford3-2/+146
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the svmatch* and svnmatch* intrinsics. gcc/ * config/aarch64/aarch64-sve2.md (@aarch64_pred_<sve_int_op><mode>): Split SVE2_MATCH pattern into a VNx16QI_ONLY define_ins and a VNx8HI_ONLY define_expand. Use a VNx16BI destination for the latter. (*aarch64_pred_<sve_int_op><mode>): New SVE2_MATCH pattern for VNx8HI_ONLY. (*aarch64_pred_<sve_int_op><mode>_cc): Likewise. gcc/testsuite/ * gcc.target/aarch64/sve2/acle/general/match_4.c: New test. * gcc.target/aarch64/sve2/acle/general/nmatch_1.c: Likewise.
2025-08-04aarch64: Use VNx16BI for svac*Richard Sandiford6-17/+465
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the svac* intrinsics (floating- point compare absolute). gcc/ * config/aarch64/aarch64-sve.md (@aarch64_pred_fac<cmp_op><mode>): Replace with... (@aarch64_pred_fac<cmp_op><mode>_acle): ...this new expander. (*aarch64_pred_fac<cmp_op><mode>_strict_acle): New pattern. * config/aarch64/aarch64-sve-builtins-base.cc (svac_impl::expand): Update accordingly. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general/acge_1.c: New test. * gcc.target/aarch64/sve/acle/general/acgt_1.c: Likewise. * gcc.target/aarch64/sve/acle/general/acle_1.c: Likewise. * gcc.target/aarch64/sve/acle/general/aclt_1.c: Likewise.
2025-08-04aarch64: Use VNx16BI for floating-point svcmp*Richard Sandiford9-2/+802
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the floating-point forms of svcmp*. gcc/ * config/aarch64/aarch64-sve.md (@aarch64_pred_fcm<cmp_op><mode>_acle) (*aarch64_pred_fcm<cmp_op><mode>_acle, @aarch64_pred_fcmuo<mode>_acle) (*aarch64_pred_fcmuo<mode>_acle): New patterns. * config/aarch64/aarch64-sve-builtins-base.cc (svcmp_impl::expand, svcmpuo_impl::expand): Use them. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general/cmpeq_6.c: New test. * gcc.target/aarch64/sve/acle/general/cmpge_9.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpgt_9.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmple_9.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmplt_9.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpne_5.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpuo_1.c: Likewise.
2025-08-04aarch64: Use VNx16BI for svcmp*_wideRichard Sandiford11-1/+608
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the svcmp*_wide intrinsics. Since the only uses of these patterns are for ACLE intrinsics, there didn't seem much point adding an "_acle" suffix. gcc/ * config/aarch64/aarch64-sve.md (@aarch64_pred_cmp<cmp_op><mode>_wide): Split into VNx16QI_ONLY and SVE_FULL_HSI patterns. Use VNx16BI results for both. (*aarch64_pred_cmp<cmp_op><mode>_wide): New pattern. (*aarch64_pred_cmp<cmp_op><mode>_wide_cc): Likewise. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general/cmpeq_5.c: New test. * gcc.target/aarch64/sve/acle/general/cmpge_7.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpge_8.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpgt_7.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpgt_8.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmple_7.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmple_8.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmplt_7.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmplt_8.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpne_4.c: Likewise.
2025-08-04aarch64: Drop unnecessary GPs in svcmp_wide PTEST patternsRichard Sandiford11-2/+679
Patterns that fuse a predicate operation P with a PTEST use aarch64_sve_same_pred_for_ptest_p to test whether the governing predicates of P and the PTEST are compatible. Most patterns were also written as define_insn_and_rewrites, with the rewrite replacing P's original governing predicate with PTEST's. This ensures that we don't, for example, have both a .H PTRUE for the PTEST and a .B PTRUE for a comparison that feeds the PTEST. The svcmp_wide* patterns were missing this rewrite, meaning that we did have redundant PTRUEs. gcc/ * config/aarch64/aarch64-sve.md (*aarch64_pred_cmp<cmp_op><mode>_wide_cc): Turn into a define_insn_and_rewrite and rewrite the governing predicate of the comparison so that it is identical to the PTEST's. (*aarch64_pred_cmp<cmp_op><mode>_wide_ptest): Likewise. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general/cmpeq_1.c: Check the number of PTRUEs. * gcc.target/aarch64/sve/acle/general/cmpge_5.c: New test. * gcc.target/aarch64/sve/acle/general/cmpge_6.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpgt_5.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpgt_6.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmple_5.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmple_6.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmplt_5.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmplt_6.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpne_3.c: Likewise.
2025-08-04aarch64: Use the correct GP mode in the svcmp_wide patternsRichard Sandiford2-4/+55
The patterns for the svcmp_wide intrinsics used a VNx16BI input predicate for all modes, instead of the usual <VPRED>. That unnecessarily made some input bits significant, but more importantly, it triggered an ICE in aarch64_sve_same_pred_for_ptest_p when testing whether a comparison pattern could be fused with a PTEST. A later patch will add tests for other comparisons. gcc/ * config/aarch64/aarch64-sve.md (@aarch64_pred_cmp<cmp_op><mode>_wide) (*aarch64_pred_cmp<cmp_op><mode>_wide_cc): Use <VPRED> instead of VNx16BI for the governing predicate. (*aarch64_pred_cmp<cmp_op><mode>_wide_ptest): Likewise. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general/cmpeq_1.c: Add more tests.
2025-08-04aarch64: Use VNx16BI for non-widening integer svcmp*Richard Sandiford25-7/+3133
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the non-widening integer forms of svcmp*. The handling of the PTEST patterns is similar to that for the earlier svwhile* patch. Unfortunately, on its own, this triggers a failure in the pred_clobber_*.c tests. The problem is that, after the patch, we have a comparison instruction followed by a move into p0. Combine combines the instructions together, so that the destination of the comparison is the hard register p0 rather than a pseudo. This defeats IRA's make_early_clobber_and_input_conflicts, which requires the source and destination to be pseudo registers. Before the patch, there was a subreg move between the comparison and the move into p0, so it was that subreg move that ended up with a hard register destination. Arguably the fix for PR87600 should be extended to destination registers as well as source registers, but in the meantime, the patch just disables combine for these tests. The tests are really testing the constraints and register allocation. gcc/ * config/aarch64/aarch64-sve.md (@aarch64_pred_cmp<cmp_op><mode>_acle) (*aarch64_pred_cmp<cmp_op><mode>_acle, *cmp<cmp_op><mode>_acle_cc) (*cmp<cmp_op><mode>_acle_and): New patterns that yield VNx16BI results for all element types. * config/aarch64/aarch64-sve-builtins-base.cc (svcmp_impl::expand): Use them. (svcmp_wide_impl::expand): Likewise when implementing an svcmp_wide against an in-range constant. gcc/testsuite/ * gcc.target/aarch64/sve/pred_clobber_1.c: Disable combine. * gcc.target/aarch64/sve/pred_clobber_2.c: Likewise. * gcc.target/aarch64/sve/pred_clobber_3.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpeq_2.c: Add more cases. * gcc.target/aarch64/sve/acle/general/cmpeq_4.c: New test. * gcc.target/aarch64/sve/acle/general/cmpge_1.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpge_2.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpge_3.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpge_4.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpgt_1.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpgt_2.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpgt_3.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpgt_4.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmple_1.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmple_2.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmple_3.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmple_4.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmplt_1.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmplt_2.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmplt_3.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmplt_4.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpne_1.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpne_2.c: Likewise.
2025-08-04aarch64: Use VNx16BI for svunpklo/hi_bRichard Sandiford4-1/+77
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the svunpk* intrinsics. gcc/ * config/aarch64/aarch64-sve.md (@aarch64_sve_punpk<perm_hilo>_acle) (*aarch64_sve_punpk<perm_hilo>_acle): New patterns. * config/aarch64/aarch64-sve-builtins-base.cc (svunpk_impl::expand): Use them for boolean svunpk*. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general/unpkhi_1.c: New test. * gcc.target/aarch64/sve/acle/general/unpklo_1.c: Likewise.
2025-08-04aarch64: Use VNx16BI for svrev_b* [PR121294]Richard Sandiford4-2/+56
The previous patch for PR121294 handled svtrn1/2, svuzp1/2, and svzip1/2. This one extends it to handle svrev intrinsics, where the same kind of wrong code can be generated. gcc/ PR target/121294 * config/aarch64/aarch64.md (UNSPEC_REV_PRED): New unspec. * config/aarch64/aarch64-sve.md (@aarch64_sve_rev<mode>_acle) (*aarch64_sve_rev<mode>_acle): New patterns. * config/aarch64/aarch64-sve-builtins-base.cc (svrev_impl::expand): Use the new patterns for boolean svrev. gcc/testsuite/ PR target/121294 * gcc.target/aarch64/sve/acle/general/rev_2.c: New test.
2025-08-04aarch64: Use VNx16BI for more permutations [PR121294]Richard Sandiford10-12/+613
The patterns for the predicate forms of svtrn1/2, svuzp1/2, and svzip1/2 are shared with aarch64_vectorize_vec_perm_const. The .H, .S, and .D forms operate on VNx8BI, VNx4BI, and VNx2BI respectively. Thus, for all four element widths, there is one significant bit per element, for both the inputs and the output. That's appropriate for aarch64_vectorize_vec_perm_const but not for the ACLE intrinsics, where every bit of the output is significant, and where every bit of the selected input elements is therefore also significant. The current expansion can lead the optimisers to simplify inputs by changing the upper bits of the input elements (since the current patterns claim that those bits don't matter), which in turn leads to wrong code. The ACLE expansion should operate on VNx16BI instead, for all element widths. There was already a pattern for a VNx16BI-only form of TRN1, for constructing certain predicate constants. The patch generalises it to handle the other five permutations as well. For the reasons given in the comments, this is done by making the permutation unspec an operand to a new UNSPEC_PERMUTE_PRED, rather than overloading the existing unspecs, and rather than adding a new unspec for each permutation. gcc/ PR target/121294 * config/aarch64/iterators.md (UNSPEC_TRN1_CONV): Delete. (UNSPEC_PERMUTE_PRED): New unspec. * config/aarch64/aarch64-sve.md (@aarch64_sve_trn1_conv<mode>): Replace with... (@aarch64_sve_<perm_insn><mode>_acle) (*aarch64_sve_<perm_insn><mode>_acle): ...these new patterns. * config/aarch64/aarch64.cc (aarch64_expand_sve_const_pred_trn): Update accordingly. * config/aarch64/aarch64-sve-builtins-functions.h (binary_permute::expand): Use the new _acle patterns for predicate operations. gcc/testsuite/ PR target/121294 * gcc.target/aarch64/sve/acle/general/perm_2.c: New test. * gcc.target/aarch64/sve/acle/general/perm_3.c: Likewise. * gcc.target/aarch64/sve/acle/general/perm_4.c: Likewise. * gcc.target/aarch64/sve/acle/general/perm_5.c: Likewise. * gcc.target/aarch64/sve/acle/general/perm_6.c: Likewise. * gcc.target/aarch64/sve/acle/general/perm_7.c: Likewise.
2025-08-04aarch64: Use VNx16BI for more SVE WHILE* results [PR121118]Richard Sandiford13-5/+895
PR121118 is about a case where we try to construct a predicate constant using a permutation of a PFALSE and a WHILELO. The WHILELO is a .H operation and its result has mode VNx8BI. However, the permute instruction expects both inputs to be VNx16BI, leading to an unrecognisable insn ICE. VNx8BI is effectively a form of VNx16BI in which every odd-indexed bit is insignificant. In the PR's testcase that's OK, since those bits will be dropped by the permutation. But if the WHILELO had been a VNx4BI, so that only every fourth bit is significant, the input to the permutation would have had undefined bits. The testcase in the patch has an example of this. This feeds into a related ACLE problem that I'd been meaning to fix for a long time: every bit of an svbool_t result is significant, and so every ACLE intrinsic that returns an svbool_t should return a VNx16BI. That doesn't currently happen for ACLE svwhile* intrinsics. This patch fixes both issues together. We still need to keep the current WHILE* patterns for autovectorisation, where the result mode should match the element width. The patch therefore adds a new set of patterns that are defined to return VNx16BI instead. For want of a better scheme, it uses an "_acle" suffix to distinguish these new patterns from the "normal" ones. The formulation used is: (and:VNx16BI (subreg:VNx16BI normal-pattern 0) C) where C has mode VNx16BI and is a canonical ptrue for normal-pattern's element width (so that the low bit of each element is set and the upper bits are clear). This is a bit clunky, and leads to some repetition. But it has two advantages: * After g:965564eafb721f8000013a3112f1bba8d8fae32b, converting the above expression back to normal-pattern's mode will reduce to normal-pattern, so that the pattern for testing the result using a PTEST doesn't change. * It gives RTL optimisers a bit more information, as the new tests demonstrate. In the expression above, C is matched using a new "special" predicate aarch64_ptrue_all_operand, where "special" means that the mode on the predicate is not necessarily the mode of the expression. In this case, C always has mode VNx16BI, but the mode on the predicate indicates which kind of canonical PTRUE is needed. gcc/ PR testsuite/121118 * config/aarch64/iterators.md (VNx16BI_ONLY): New mode iterator. * config/aarch64/predicates.md (aarch64_ptrue_all_operand): New predicate. * config/aarch64/aarch64-sve.md (@aarch64_sve_while_<while_optab_cmp><GPI:mode><VNx16BI_ONLY:mode>_acle) (@aarch64_sve_while_<while_optab_cmp><GPI:mode><PRED_HSD:mode>_acle) (*aarch64_sve_while_<while_optab_cmp><GPI:mode><PRED_HSD:mode>_acle) (*while_<while_optab_cmp><GPI:mode><PRED_HSD:mode>_acle_cc): New patterns. * config/aarch64/aarch64-sve-builtins-functions.h (while_comparison::expand): Use the new _acle patterns that always return a VNx16BI. * config/aarch64/aarch64-sve-builtins-sve2.cc (svwhilerw_svwhilewr_impl::expand): Likewise. * config/aarch64/aarch64.cc (aarch64_sve_move_pred_via_while): Likewise. gcc/testsuite/ PR testsuite/121118 * gcc.target/aarch64/sve/acle/general/pr121118_1.c: New test. * gcc.target/aarch64/sve/acle/general/whilele_13.c: Likewise. * gcc.target/aarch64/sve/acle/general/whilelt_6.c: Likewise. * gcc.target/aarch64/sve2/acle/general/whilege_1.c: Likewise. * gcc.target/aarch64/sve2/acle/general/whilegt_1.c: Likewise. * gcc.target/aarch64/sve2/acle/general/whilerw_5.c: Likewise. * gcc.target/aarch64/sve2/acle/general/whilewr_5.c: Likewise.
2025-08-04aarch64: Improve svdupq_lane expension for big-endian [PR121293]Richard Sandiford2-2/+11
If the index to svdupq_lane is variable, or is outside the range of the .Q form of DUP, the fallback expansion is to convert to VNx2DI and use TBL. The problem in this PR was that the conversion used subregs, and on big-endian targets, a bitcast from VNx2DI to another element size requires a REV[BHW] in the best case or a spill and reload in the worst case. (See the comment at the head of aarch64-sve.md for details.) Here we want the conversion to act like svreinterpret, so it should use aarch64_sve_reinterpret instead of subregs. gcc/ PR target/121293 * config/aarch64/aarch64-sve-builtins-base.cc (svdupq_lane::expand): Use aarch64_sve_reinterpret instead of subregs. Explicitly reinterpret the result back to the required mode, rather than leaving the caller to take a subreg. gcc/testsuite/ PR target/121293 * gcc.target/aarch64/sve/acle/general/dupq_lane_9.c: New test.
2025-08-04tree-optimization/121362 - missed FRE through aggregate copyRichard Biener3-21/+153
The following streamlines and generalizes how we find the common base of the lookup ref and a kill ref when looking through aggregate copies. In particular this tries to deal with all variants of punning that happens on the inner MEM_REF after forwarding of address taken components of the common base. PR tree-optimization/121362 * tree-ssa-sccvn.cc (vn_reference_lookup_3): Generalize aggregate copy handling. * gcc.dg/tree-ssa/ssa-fre-105.c: New testcase. * gcc.dg/tree-ssa/ssa-fre-106.c: Likewise.
2025-08-04invoke.texi: Update docs of -fdump-{rtl,tree}-<pass>-<options>Filip Kastl1-7/+10
This patch changes two things. Firstly, we document -fdump-rtl-<whatever>-graph and other such options under -fdump-tree. At least write a remark about this under -fdump-rtl. Secondly, the documentation incorrectly says that -fdump-tree-<whatever>-graph is not implemented. Change that. gcc/ChangeLog: * doc/invoke.texi: Add remark about -options being documented under -fdump-tree. Remove remark about -graph working only for RTL. Signed-off-by: Filip Kastl <fkastl@suse.cz>
2025-08-03x86: Don't hoist non all 0s/1s vector set outside of loopH.J. Lu2-50/+106
Don't hoist non all 0s/1s vector set outside of the loop to avoid extra spills. gcc/ PR target/120941 * config/i386/i386-features.cc (x86_cse_kind): Moved before ix86_place_single_vector_set. (redundant_load): Likewise. (ix86_place_single_vector_set): Replace the last argument to the pointer to redundant_load. For X86_CSE_VEC_DUP, don't place the vector set outside of the loop to avoid extra spills. (remove_redundant_vector_load): Pass load to ix86_place_single_vector_set. gcc/testsuite/ PR target/120941 * gcc.target/i386/pr120941-1.c: New test. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-04Daily bump.GCC Administrator3-1/+34
2025-08-03c++: Add stringification testcase for CWG1709 [PR120778]Jakub Jelinek1-0/+18
The CWG1709 just codifies existing GCC (and clang) behavior, so this just adds a testcase for that. 2025-08-03 Jakub Jelinek <jakub@redhat.com> PR preprocessor/120778 * g++.dg/DRs/dr1709.C: New test.
2025-08-03libcpp: Fix up cpp_maybe_module_directive [PR120845]Jakub Jelinek1-0/+8
My changes for "Module Declarations Shouldn’t be Macros" paper broke the following testcase. The backup handling intentionally tries to drop CPP_PRAGMA_EOL token if things go wrong, which is desirable for the case where we haven't committed to the module preprocessing directive (i.e. changed the first token to the magic one). In that case there is no preprocessing directive start and so CPP_PRAGMA_EOL would be wrong. If there is a premature new-line after we've changed the first token though, we shouldn't drop CPP_PRAGMA_EOL, because otherwise we ICE in the FE. While clang++ and MSVC accept the testcase, in my reading it is incorrect at least in the C++23 and newer wordings and I think the changes have been a DR, https://eel.is/c++draft/cpp.module has no exception for new-lines and https://eel.is/c++draft/cpp.pre#1.sentence-2 says that new-line (unless deleted during phase 2 when after backslash) ends the preprocessing directive. The patch arranges for eol being set only in the not_module case. 2025-08-03 Jakub Jelinek <jakub@redhat.com> PR c++/120845 libcpp/ * lex.cc (cpp_maybe_module_directive): Move eol variable declaration to the start of the function, initialize to false and only set it to peek->type == CPP_PRAGMA_EOL in the not_module case. Formatting fix. gcc/testsuite/ * g++.dg/modules/cpp-21.C: New test.
2025-08-03AVR: Use avr_add_ccclobber / DONE_ADD_CCC in md instead of repeats.Georg-Johann Lay3-961/+436
There are many post-reload define_insn_and_split's that just append a (clobber (reg:CC REG_CC)) to the pattern. Instead of repeating the original patterns, avr_add_ccclobber (curr_insn) is used to do that job. This avoids repeating patterns all over the place, and splits that do something different (like using a canonical form) stand out clearly. gcc/ * config/avr/avr.md (define_insn_and_split) [reload_completed]: For splits that just append a (clobber (reg:CC REG_CC)) to the pattern, use avr_add_ccclobber (curr_insn) instead of repeating the original pattern. * config/avr/avr-dimode.md: Same. * config/avr/avr-fixed.md: Same.
2025-08-03AVR: Add avr.cc::avr_add_ccclobber().Georg-Johann Lay2-0/+25
gcc/ * config/avr/avr.cc (avr_add_ccclobber): New function. * config/avr/avr-protos.h (avr_add_ccclobber): New proto. (DONE_ADD_CCC): New define.
2025-08-03tree-optimization/90242 - UBSAN error in vn_reference_compute_hashRichard Biener1-3/+3
The following plugs possible overflow issues in vn_reference_compute_hash and possibly in vn_reference_eq. The inchash "integer" adds are a bit of a mess, but I know overloads with different integer types can get messy, so not this time. For hashing simply truncate to 64bits. PR tree-optimization/90242 * tree-ssa-sccvn.cc (vn_reference_compute_hash): Use poly_offset_int for offset accumulation. For hashing truncate to 64 bits and also hash 64 bits. (vn_reference_eq): Likewise.
2025-08-03Daily bump.GCC Administrator6-1/+33
2025-08-03doc: Drop note on 16-bit Windows supportGerald Pfeifer1-7/+0
gcc: PR target/69374 * doc/install.texi (Specific) <windows>: Drop note on 16-bit Windows support. Streamline note on 32-bit support.
2025-08-02cobol: Use %td in error_msg in 3 spotsJakub Jelinek3-5/+5
On Thu, Jul 31, 2025 at 11:33:07PM +0200, Jakub Jelinek via Gcc wrote: > > this was all described in excruciating detail in the patch submission > > > > https://gcc.gnu.org/pipermail/gcc-patches/2025-June/687385.html > > > > and the commit message. > > Looking at that patch, the dbgmsg change looks correct (dbgmsg is > ATTRIBUTE_PRINTF_1), while the last 3 hunks are suboptimal, they should > really use %td and keep the ptrdiff_t arguments without casts. Here it is in patch form. I couldn't find other similar casts in calls to ATTRIBUTE_GCOBOL_DIAG functions. 2025-08-02 Jakub Jelinek <jakub@redhat.com> * parse.y (intrinsic): Use %td format specifier with no cast on argument instead of %ld with cast to long. * scan_ante.h (numstr_of): Likewise. * util.cc (cbl_field_t::report_invalid_initial_value): Likewise.
2025-08-02c: rewrite implementation of `arg spec' attributeMartin Uecker4-199/+145
Rewrite the implementation of the `arg spec' attribute to pass the the original type of an array parameter instead of passing a string description and a list of bounds. The string and list are then created from this type during the integration of the information of `arg spec' into the access attribute because it still needed later for various warnings. This change makes the implementation simpler and more robust as the declarator is not processed and information that is already encoded in the type is not duplicated. A similar change to the access attribute could then completely remove the string processing. With this change, the original type is now available and can be used for other warnings or for _Countof. The new implementation tries to be faithful to the original, but this is not entirely true as it fixes a bug in the old implementation. gcc/c-family/ChangeLog: * c-attribs.cc (handle_argspec_attribute): Update. (build_arg_spec): New function. (build_attr_access_from_parms): Rewrite `arg spec' handling. gcc/c/ChangeLog: * c-decl.cc (get_parm_array_spec): Remove. (push_parm_decl): Do not add `arg spec` attribute. (build_arg_spec_attribute): New function. (grokdeklarator): Add `arg spec` attribute. gcc/testsuite/ChangeLog: * gcc.dg/Warray-parameter-11.c: Change Warray-parameter to -Wvla-parameter as these are VLAs. * gcc.dg/Warray-parameter.c: Remove xfail.