aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2024-10-25Fixed extract_types_for_resx functiondevel/nothrow-detectionPranil Dey1-45/+44
The function was recursive in nature and there is a chance of runnign out of stack, so now ann iterative approach was used to get the types for resx
2024-10-07Formatting for all functions done according to GNU standards and fixed ↵Pranil Dey1-192/+256
testsuite fail bugs
2024-10-06Added function bool extract_types_for_resx and fixed more functions for ↵Pranil Dey2-65/+65
testcases 1. bool extract_types_for_resx (gimple *,vec<tree> *) - This is for intiating the function static bool extract_types_for_resx (basic_block, vec<tree> *) which gets the resx stmt from a basic block and aclears the aux value for all blocks 2. update_stmt_eh_region - This is changed to unlink and reinsert the regions incase of a resx stmt properly
2024-10-05Updated code for unlinking regions and update stmt_eh_regions as wellPranil Dey1-4/+19
2024-10-04Updated code for unlinking regionsPranil Dey1-19/+36
2024-10-03Updated code for inserting regions and changed the return parameters of ↵Pranil Dey2-32/+41
extract_types_for call
2024-10-01Added code for inserting regionsPranil Dey2-10/+43
2024-10-01Updated tree-eh.hPranil Dey1-0/+1
2024-10-01resolved more conflictsPranil Dey1-2/+0
2024-10-01removed conflictsPranil Dey1-99/+0
2024-10-01Reolved some conflictsPranil Dey1-36/+0
2024-10-01Added functions extract_fun_resx_typesPranil Dey1-0/+138
2024-10-01Merge remote-tracking branch 'origin/devel/nothrow-detection' into ↵Pranil Dey2-2/+5
devel/nothrow-detection
2024-10-01Updated parameters of functions and typecasted resx stmtsPranil Dey2-11/+14
2024-10-01Integrated the resx functions with stmt_throw_typesPranil Dey1-7/+27
update_stmt_eh_region updated for resx stmt support and extract_fun_resx_types fixed
2024-10-01Added the previous functions to the tree-eh.h filePranil Dey1-0/+2
Functions added: 1. void extract_types_for_resx (gimple *, vec<tree> *); 2. void extract_fun_resx_types (function *);
2024-10-01RESX statement processing functions added:Pranil Dey1-0/+65
1. extract_types_for_resx - Used as a helper for getting the types from a resx statement to use later in the extract_fun_resx_types 2. extract_fun_resx_types - Used for getting the types thrown and propagated outside a function
2024-10-01Fixed some indentations and function namesPranil Dey1-16/+16
1. Changed function name extract_exception_types_for_call to extract_types_for_call due to length of the name 2. Fixed space indentation in some places
2024-10-01Added some functions and fixed some testcase failuresPranil Dey3-1/+51
1. odr_equivalent_or_derived_p in ipa-devirt.cc 2. same_or_derived_type in in tree-eh.cc 3. Fixed catch-all handling in match_lp function
2024-10-01Edge redirection for exceptions.Pranil Dey3-2/+122
This commit is contains change in code for the tree-eh.cc, tree-eh.h, MAINTAINERS and tree-cfg.cc files. Specifically it contains four functions - 1. void extract_exception_types_for_call which extracts the exception types in a call stmt and adds them into a vector tree. 2. bool stmt_throw_types does the same as stmt_could_throw the difference being that it also gives the list of exception types as given by the extract_exception_types_for_call function. 3. bool match_lp checks if a landing pad can handle any of the exception types given as input parameters by looking into the catch handlers. 4. update_stmt_eh_region is the function that walks up the EH tree and changes the landing pad for the last statement in a basic block in the control flow graph so that when the edge by make_eh_edge is created it points to the correct handlers. Further work to be done regarding RESX stmts.
2024-10-01Daily bump.GCC Administrator7-1/+721
2024-10-01[testcase] Fix-absfloat16.c-testcaseKugan Vivekanandarajah1-1/+1
gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/absfloat16.c: Fix testcase. Signed-off-by: Kugan Vivekanandarajah <kvivekananda@nvidia.com>
2024-09-30c++: concept in default argument [PR109859]Marek Polacek3-2/+25
1) We're hitting the assert in cp_parser_placeholder_type_specifier. It says that if it turns out to be false, we should do error() instead. Do so, then. 2) lambda-targ8.C should compile fine, though. The problem was that local_variables_forbidden_p wasn't cleared when we're about to parse the optional template-parameter-list for a lambda in a default argument. PR c++/109859 gcc/cp/ChangeLog: * parser.cc (cp_parser_lambda_declarator_opt): Temporarily clear local_variables_forbidden_p. (cp_parser_placeholder_type_specifier): Turn an assert into an error. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-defarg3.C: New test. * g++.dg/cpp2a/lambda-targ8.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-30Fix internal error during inlining after ICF passEric Botcazou2-2/+27
The problem is that the ICF pass identifies two functions, one of which has a static chain while the other does not. The fix is simply to prevent this identification from occurring. gcc/ PR ipa/113996 * ipa-icf.cc (sem_function::get_hash): Hash DECL_STATIC_CHAIN. (sem_function::equals_wpa): Compare it. (sem_function::equals_private): Likewise. gcc/testsuite/ * gnat.dg/lto27.adb: New test.
2024-09-30diagnostics: return text buffer from test_show_locus [PR116613]David Malcolm3-168/+88
As work towards supporting multiple diagnostic outputs (where each output has its own pretty_printer), avoid referencing dc.m_printer throughout the selftests of diagnostic-show-locus.cc. Instead have test_diagnostic_context::test_show_locus return the result buffer, hiding the specifics of which printer is in use in such test cases. No functional change intended. gcc/ChangeLog: PR other/116613 * diagnostic-show-locus.cc (selftest::test_diagnostic_show_locus_unknown_location): Move call to dc.test_show_locus into ASSERT_STREQ, and compare against its result, rather than explicitly using dc.m_printer. (selftest::test_one_liner_simple_caret): Likewise. (selftest::test_one_liner_no_column): Likewise. (selftest::test_one_liner_caret_and_range): Likewise. (selftest::test_one_liner_multiple_carets_and_ranges): Likewise. (selftest::test_one_liner_fixit_insert_before): Likewise. (selftest::test_one_liner_fixit_insert_after): Likewise. (selftest::test_one_liner_fixit_remove): Likewise. (selftest::test_one_liner_fixit_replace): Likewise. (selftest::test_one_liner_fixit_replace_non_equal_range): Likewise. (selftest::test_one_liner_fixit_replace_equal_secondary_range): Likewise. (selftest::test_one_liner_fixit_validation_adhoc_locations): Likewise. (selftest::test_one_liner_many_fixits_1): Likewise. (selftest::test_one_liner_many_fixits_2): Likewise. (selftest::test_one_liner_labels): Likewise. (selftest::test_one_liner_simple_caret_utf8): Likewise. (selftest::test_one_liner_multiple_carets_and_ranges_utf8): Likewise. (selftest::test_one_liner_fixit_insert_before_utf8): Likewise. (selftest::test_one_liner_fixit_insert_after_utf8): Likewise. (selftest::test_one_liner_fixit_remove_utf8): Likewise. (selftest::test_one_liner_fixit_replace_utf8): Likewise. (selftest::test_one_liner_fixit_replace_non_equal_range_utf8): Likewise. (selftest::test_one_liner_fixit_replace_equal_secondary_range_utf8): Likewise. (selftest::test_one_liner_fixit_validation_adhoc_locations_utf8): Likewise. (selftest::test_one_liner_many_fixits_1_utf8): Likewise. (selftest::test_one_liner_many_fixits_2_utf8): Likewise. (selftest::test_one_liner_labels_utf8): Likewise. (selftest::test_one_liner_colorized_utf8): Likewise. (selftest::test_add_location_if_nearby): Likewise. (selftest::test_diagnostic_show_locus_fixit_lines): Likewise. (selftest::test_overlapped_fixit_printing): Likewise. (selftest::test_overlapped_fixit_printing_utf8): Likewise. (selftest::test_overlapped_fixit_printing_utf8): Likewise. (selftest::test_overlapped_fixit_printing_2): Likewise. (selftest::test_fixit_insert_containing_newline): Likewise. (selftest::test_fixit_insert_containing_newline_2): Likewise. (selftest::test_fixit_replace_containing_newline): Likewise. (selftest::test_fixit_deletion_affecting_newline): Likewise. (selftest::test_tab_expansion): Likewise. (selftest::test_escaping_bytes_1): Likewise. (selftest::test_escaping_bytes_2): Likewise. (selftest::test_line_numbers_multiline_range): Likewise. * selftest-diagnostic.cc (selftest::test_diagnostic_context::test_show_locus): Return the formatted text of m_printer. * selftest-diagnostic.h (selftest::test_diagnostic_context::test_show_locus): Convert return type from void to const char *. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-09-30diagnostics: require callers of diagnostic_show_locus to be explicit about ↵David Malcolm4-11/+9
the printer [PR116613] As work towards supporting multiple diagnostic outputs (where each output has its own pretty_printer), update diagnostic_show_locus so that the pretty_printer must always be explicitly passed in. No functional change intended. gcc/c-family/ChangeLog: PR other/116613 * c-format.cc (selftest::test_type_mismatch_range_labels): Explicitly pass in dc.m_printer to diagnostic_show_locus. gcc/ChangeLog: PR other/116613 * diagnostic-show-locus.cc (diagnostic_context::maybe_show_locus): Convert param "pp" from * to &. Drop logic for using the context's m_printer when the param is null. * diagnostic.h (diagnostic_context::maybe_show_locus): Convert param "pp" from * to &. (diagnostic_show_locus): Drop default "nullptr" value for pp param. Assert that it and context are nonnull. Pass pp by reference to maybe_show_locus. gcc/testsuite/ChangeLog: PR other/116613 * gcc.dg/plugin/expensive_selftests_plugin.c (test_richloc): Explicitly pass in dc.m_printer to diagnostic_show_locus. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-09-30diagnostics: isolate diagnostic_context with interface classes [PR116613]David Malcolm14-447/+765
As work towards supporting multiple diagnostic outputs (where each output has its own pretty_printer), avoid passing around diagnostic_context to the various printing routines, so that we can be more explicit about which pretty_printer is in use. Introduce a set of "policy" classes that capture the parts of diagnostic_context that are needed, and use these rather than diagnostic_context *. Pass around pretty_printer & rather than taking value from context. Split out the pretty_printer-using code from class layout into a new class layout_printer, separating the responsibilities of determining layout when quoting source versus actually printing the source. No functional change intended. gcc/analyzer/ChangeLog: PR other/116613 * program-point.cc (function_point::print_source_line): Replace call to diagnostic_show_locus with a call to diagnostic_source_print_policy::print. gcc/ChangeLog: PR other/116613 * diagnostic-format-json.cc (json_from_expanded_location): Replace call to diagnostic_context::converted_column with call to diagnostic_column_policy::converted_column. * diagnostic-format-sarif.cc (sarif_builder::make_location_object): Replace call to diagnostic_show_locus with call to diagnostic_source_print_policy::print. * diagnostic-format-text.cc (get_location_text): Replace call to diagnostic_context::get_location_text with call to diagnostic_column_policy::get_location_text. (diagnostic_text_output_format::report_current_module): Replace call to diagnostic_context::converted_column with call to diagnostic_column_policy::converted_column. * diagnostic-format-text.h (diagnostic_text_output_format::diagnostic_output_format): Initialize m_column_policy. (diagnostic_text_output_format::get_column_policy): New. (diagnostic_text_output_format::m_column_policy): New. * diagnostic-path.cc (class path_print_policy): New. (event_range::maybe_add_event): Replace diagnostic_context param with path_print_policy. (event_range::print): Convert "pp" from * to &. Convert first param of start_span callback from diagnostic_context to diagnostic_location_print_policy. (path_summary::path_summary): Convert first param from diagnostic_text_output_format to path_print_policy. Add colorize param. Update for changes to event_range::maybe_add_event. (thread_event_printer::print_swimlane_for_event_range): Assert that pp is non-null. Update for change to event_range::print. (diagnostic_text_output_format::print_path): Pass path_print_policy to path_summary's ctor. (selftest::test_empty_path): Likewise. (selftest::test_intraprocedural_path): Likewise. (selftest::test_interprocedural_path_1): Likewise. (selftest::test_interprocedural_path_2): Likewise. (selftest::test_recursion): Likewise. (selftest::test_control_flow_1): Likewise. (selftest::test_control_flow_2): Likewise. (selftest::test_control_flow_3): Likewise. (selftest::assert_cfg_edge_path_streq): Likewise. (selftest::test_control_flow_5): Likewise. (selftest::test_control_flow_6): Likewise. * diagnostic-show-locus.cc (colorizer::set_range): Update for change to m_pp. (colorizer::m_pp): Convert from * to &. (class layout): Add friend class layout_printer and move various decls to it. (layout::m_pp): Drop field. (layout::m_policy): Rename to... (layout::m_char_policy): ...this. (layout::m_colorizer): Move field to class layout_printer. (layout::m_diagnostic_path_p): Drop field. (class layout_printer): New class, by refactoring class layout. (colorizer::colorizer): Convert "pp" param from * to &. (colorizer::set_named_color): Update for above change. (colorizer::begin_state): Likewise. (colorizer::finish_state): Likewise. (make_policy): Rename to... (make_char_policy): ...this, and update param from diagnostic_context to diagnostic_source_print_policy. (layout::layout): Update param from diagnostic_context to diagnostic_source_print_policy. Drop params "diagnostic_kind" and "pp", moving these and other material to class layout_printer. (layout::maybe_add_location_range): Update for renamed field. (layout::print_gap_in_line_numbering): Convert to... (layout_printer::print_gap_in_line_numbering): ...this. (layout::calculate_x_offset_display): Update for renamed field. (layout::print_source_line): Convert to... (layout_printer::print_source_line): ...this. (layout::print_leftmost_column): Convert to... (layout_printer::print_leftmost_column): ...this. (layout::start_annotation_line): Convert to... (layout_printer::start_annotation_line): ...this. (layout::print_annotation_line): Convert to... (layout_printer::print_annotation_line): ...this. (layout::print_any_labels): Convert to... (layout_printer::print_any_labels): ...this. (layout::print_leading_fixits): Convert to... (layout_printer::print_leading_fixits): ...this. (layout::print_trailing_fixits): Convert to... (layout_printer::print_trailing_fixits): ...this. (layout::print_newline): Convert to... (layout_printer::print_newline): ...this. (layout::get_state_at_point): Make const. (layout::get_x_bound_for_row): Make const. (layout::move_to_column): Convert to... (layout_printer::move_to_column): ...this. (layout::show_ruler): Convert to... (layout_printer::show_ruler): ...this. (layout::print_line): Convert to... (layout_printer::print_line): ...this. (layout::print_any_right_to_left_edge_lines): Convert to... (layout_printer::print_any_right_to_left_edge_lines): ...this. (layout::print_any_right_to_left_edge_lines): Likewise. (layout_printer::layout_printer): New. (layout::update_any_effects): Delete, moving logic to layout_printer::print. (gcc_rich_location::add_location_if_nearby): Update param from diagnostic_context to diagnostic_source_print_policy. Add overload taking a diagnostic_context. (diagnostic_context::maybe_show_locus): Move handling of null pretty_printer here, from layout ctor. Convert call to diagnostic_context::show_locus to diagnostic_source_print_policy::print. (diagnostic_source_print_policy::diagnostic_source_print_policy): New. (diagnostic_context::show_locus): Convert to... (diagnostic_source_print_policy::print): ...this. Convert pp from * to &. (layout_printer::print): New, based on material in diagnostic_context::show_locus. (selftest::make_char_policy): New. (selftest::test_display_widths): Update for above changes. (selftest::test_offset_impl): Likewise. (selftest::test_layout_x_offset_display_utf8): Likewise. (selftest::test_layout_x_offset_display_tab): Likewise. (selftest::test_diagnostic_show_locus_unknown_location): Use test_diagnostic_context::test_show_locus rather than diagnostic_show_locus. (selftest::test_one_liner_no_column): Likewise. (selftest::test_one_liner_caret_and_range): Likewise. (selftest::test_one_liner_multiple_carets_and_ranges): Likewise. (selftest::test_one_liner_fixit_insert_before): Likewise. (selftest::test_one_liner_fixit_insert_after): Likewise. (selftest::test_one_liner_fixit_remove): Likewise. (selftest::test_one_liner_fixit_replace): Likewise. (selftest::test_one_liner_fixit_replace_non_equal_range): Likewise. (selftest::test_one_liner_fixit_replace_equal_secondary_range): Likewise. (selftest::test_one_liner_fixit_validation_adhoc_locations): Likewise. (selftest::test_one_liner_many_fixits_1): Likewise. (selftest::test_one_liner_many_fixits_2): Likewise. (selftest::test_one_liner_labels): Likewise. (selftest::test_one_liner_simple_caret_utf8): Likewise. (selftest::test_one_liner_caret_and_range_utf8): Likewise. (selftest::test_one_liner_multiple_carets_and_ranges_utf8): Likewise. (selftest::test_one_liner_fixit_insert_before_utf8): Likewise. (selftest::test_one_liner_fixit_insert_after_utf8): Likewise. (selftest::test_one_liner_fixit_remove_utf8): Likewise. (selftest::test_one_liner_fixit_replace_utf8): Likewise. (selftest::test_one_liner_fixit_replace_non_equal_range_utf8): Likewise. (selftest::test_one_liner_fixit_replace_equal_secondary_range_utf8): Likewise. (selftest::test_one_liner_fixit_validation_adhoc_locations_utf8): Likewise. (selftest::test_one_liner_many_fixits_1_utf8): Likewise. (selftest::test_one_liner_many_fixits_2_utf8): Likewise. (selftest::test_one_liner_labels_utf8): Likewise. (selftest::test_one_liner_colorized_utf8): Likewise. (selftest::test_add_location_if_nearby): Likewise. (selftest::test_diagnostic_show_locus_fixit_lines): Likewise. (selftest::test_overlapped_fixit_printing): Likewise. (selftest::test_overlapped_fixit_printing_utf8): Likewise. (selftest::test_overlapped_fixit_printing_2): Likewise. (selftest::test_fixit_insert_containing_newline): Likewise. (selftest::test_fixit_insert_containing_newline_2): Likewise. (selftest::test_fixit_replace_containing_newline): Likewise. (selftest::test_fixit_deletion_affecting_newline): Likewise. (selftest::test_tab_expansion): Likewise. (selftest::test_escaping_bytes_1): Likewise. (selftest::test_escaping_bytes_2): Likewise. (selftest::test_line_numbers_multiline_range): Likewise. * diagnostic.cc (diagnostic_column_policy::diagnostic_column_policy): New. (diagnostic_context::converted_column): Convert to... (diagnostic_column_policy::converted_column): ...this. (diagnostic_context::get_location_text): Convert to... (diagnostic_column_policy::get_location_text): ...this, adding "show_column" param. (diagnostic_location_print_policy::diagnostic_location_print_policy): New ctors. (default_diagnostic_start_span_fn): Convert param from diagnostic_context * to const diagnostic_location_print_policy &. Add "pp" param. (selftest::assert_location_text): Update for above changes. (selftest::test_diagnostic_get_location_text): Rename to... (selftest::test_get_location_text): ...this. (selftest::c_diagnostic_cc_tests): Update for renaming. * diagnostic.h (class diagnostic_location_print_policy): New forward decl. (class diagnostic_source_print_policy): New forward decl. (diagnostic_start_span_fn): Convert first param from diagnostic_context * to const diagnostic_location_print_policy & and add pretty_printer * param. (class diagnostic_column_policy): New. (class diagnostic_location_print_policy): New. (class diagnostic_source_print_policy): New. (class diagnostic_context): Add friend class diagnostic_source_print_policy. (diagnostic_context::converted_column): Drop decl in favor of diagnostic_column_policy::converted_column. (diagnostic_context::get_location_text): Drop decl in favor of diagnostic_column_policy::get_location_text. (diagnostic_context::show_locus): Drop decl in favor of diagnostic_source_print_policy::print. (default_diagnostic_start_span_fn): Update for change to diagnostic_start_span_fn. * gcc-rich-location.h (class diagnostic_source_print_policy): New forward decl. (gcc_rich_location::add_location_if_nearby): Convert first param from diagnostic_context to diagnostic_source_print_policy. Add overload taking diagnostic_context. * selftest-diagnostic.cc (selftest::test_diagnostic_context::test_diagnostic_context): Turn off colorization. (selftest::test_diagnostic_context::start_span_cb): Update for change to callback type. (test_diagnostic_context::test_show_locus): New. * selftest-diagnostic.h (selftest::test_diagnostic_context::start_span_cb): Update for change to callback type. (test_diagnostic_context::test_show_locus): New decl. gcc/fortran/ChangeLog: PR other/116613 * error.cc (gfc_diagnostic_build_locus_prefix): Convert first param from diagnostic_context * to const diagnostic_location_print_policy &. Add colorize param. Likewise for the "two expanded_locations" overload. (gfc_diagnostic_text_starter): Update for above changes. (gfc_diagnostic_start_span): Update for change to callback type. gcc/testsuite/ChangeLog: PR other/116613 * gcc.dg/plugin/diagnostic_group_plugin.c (test_diagnostic_start_span_fn): Update for change to callback type. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-09-30diagnostics: avoid using diagnostic_context's m_printer [PR116613]David Malcolm5-58/+64
As work towards supporting multiple diagnostic outputs (where each output has its own pretty_printer), avoid using diagnostic_context's m_printer field. Instead, use the output format's printer. Currently this *is* the dc's printer, but eventually it might not be. No functional change intended. gcc/ChangeLog: PR other/116613 * diagnostic-format-json.cc (diagnostic_output_format_init_json): Pass in the format. Use the format's printer when disabling colorization. Move the call to set_output_format into here. (diagnostic_output_format_init_json_stderr): Update for above change. (diagnostic_output_format_init_json_file): Likewise. * diagnostic-format-sarif.cc (diagnostic_output_format_init_sarif): Use the format's printer when disabling colorization. * diagnostic-path.cc (selftest::test_empty_path): Use the text_output's printer. (selftest::test_intraprocedural_path): Likewise. (selftest::test_interprocedural_path_1): Likewise. (selftest::test_interprocedural_path_2): Likewise. (selftest::test_recursion): Likewise. (selftest::test_control_flow_1): Likewise. (selftest::test_control_flow_2): Likewise. (selftest::test_control_flow_3): Likewise. (selftest::assert_cfg_edge_path_streq): Likewise. (selftest::test_control_flow_5): Likewise. (selftest::test_control_flow_6): Likewise. gcc/testsuite/ChangeLog: PR other/116613 * gcc.dg/plugin/diagnostic_group_plugin.c (test_output_format::on_begin_group): Use get_printer () rather than accessing m_context.m_printer. (test_output_format::on_end_group): Likewise. * gcc.dg/plugin/diagnostic_plugin_xhtml_format.c (xhtml_builder::m_printer): New field. (xhtml_builder::xhtml_builder): Add "pp" param and use it to initialize m_printer. (xhtml_builder::on_report_diagnostic): Drop "context" param. (xhtml_builder::make_element_for_diagnostic): Likewise. Use this->m_printer rather than the context's m_printer. Pass m_printer to call to diagnostic_show_locus. (xhtml_builder::emit_diagram): Drop "context" param. (xhtml_output_format::on_report_diagnostic): Drop context param from call to m_builder. (xhtml_output_format::on_diagram): Likewise. (xhtml_output_format::xhtml_output_format): Pass result of get_printer as printer for builder. (diagnostic_output_format_init_xhtml): Use the fmt's printer rather than the context's. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-09-30diagnostics: use "%e" to avoid intermediate strings [PR116613]David Malcolm8-55/+179
Various diagnostics build an intermediate string, potentially with colorization, and then use this in a diagnostic message. This won't work if we have multiple diagnostic sinks, where some might be colorized and some not. This patch reworks such places using "%e" and pp_element subclasses, so that any colorization happens within report_diagnostic's call to pp_format. gcc/analyzer/ChangeLog: PR other/116613 * kf-analyzer.cc: Include "pretty-print-markup.h". (kf_analyzer_dump_escaped::impl_call_pre): Defer colorization choices by eliminating the construction of a intermediate string, replacing it with a new pp_element subclass via "%e". gcc/ChangeLog: PR other/116613 * attribs.cc: Include "pretty-print-markup.h". (decls_mismatched_attributes): Defer colorization choices by replacing printing to a pretty_printer * param with appending to a vec of strings. (maybe_diag_alias_attributes): As above, replacing pretty_printer with usage of pp_markup::comma_separated_quoted_strings and "%e" in two places. * attribs.h (decls_mismatched_attributes): Update decl. * gimple-ssa-warn-access.cc: Include "pretty-print-markup.h". (pass_waccess::maybe_warn_memmodel): Defer colorization choices by replacing printing to a pretty_printer * param with use of pp_markup::comma_separated_quoted_strings and "%e". (pass_waccess::maybe_warn_memmodel): Likewise, replacing printing to a temporary buffer. * pretty-print-markup.h (class pp_markup::comma_separated_quoted_strings): New. * pretty-print.cc (pp_markup::comma_separated_quoted_strings::add_to_phase_2): New. (selftest::test_pp_printf_within_pp_element): New. (selftest::test_comma_separated_quoted_strings): New. (selftest::pretty_print_cc_tests): Call the new tests. gcc/cp/ChangeLog: PR other/116613 * pt.cc: Include "pretty-print-markup.h". (warn_spec_missing_attributes): Defer colorization choices by replacing printing to a pretty_printer * param with appending to a vec of strings. Replace pretty_printer with usage of pp_markup::comma_separated_quoted_strings and "%e". gcc/testsuite/ChangeLog: PR other/116613 * c-c++-common/analyzer/escaping-1.c: Update expected results to remove type information from C++ results. Previously we were using %qD with default_tree_printer, which used lang_hooks.decl_printable_name, whereas now we're using %qD with a clone of the cxx_pretty_printer. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-09-30diagnostics: add "dump" to pretty_printer and output_bufferDavid Malcolm2-0/+29
No functional change intended. gcc/ChangeLog: * pretty-print.cc (output_buffer::dump): New. (pretty_printer::dump): New. * pretty-print.h (output_buffer::dump): New decls. (pretty_printer::dump): New decls. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-09-30diagnostics: fix typo in XHTML output [PR116792]David Malcolm1-1/+1
gcc/testsuite/ChangeLog: PR other/116792 * gcc.dg/plugin/diagnostic_plugin_xhtml_format.c: Fix stray reference to JSON. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-09-30diagnostics: fix memory leak in SARIF selftestsDavid Malcolm2-0/+16
"make selftest-valgrind" was complaining about leaks of artifact objects in SARIF's selftest::test_make_location_object: -fself-test: 7638695 pass(es) in 89.999249 seconds ==3306525== ==3306525== HEAP SUMMARY: ==3306525== in use at exit: 1,215,639 bytes in 2,808 blocks ==3306525== total heap usage: 2,860,898 allocs, 2,858,090 frees, 1,336,446,579 bytes allocated ==3306525== ==3306525== 11,728 (1,536 direct, 10,192 indirect) bytes in 16 blocks are definitely lost in loss record 353 of 375 ==3306525== at 0x514FE7D: operator new(unsigned long) (vg_replace_malloc.c:342) ==3306525== by 0x36E5FD2: sarif_builder::get_or_create_artifact(char const*, diagnostic_artifact_role, bool) (diagnostic-format-sarif.cc:2884) ==3306525== by 0x36E3D57: sarif_builder::maybe_make_physical_location_object(unsigned int, diagnostic_artifact_role, int, content_renderer const*) (diagnostic-format-sarif.cc:2097) ==3306525== by 0x36E34CE: sarif_builder::make_location_object(sarif_location_manager&, rich_location const&, logical_location const*, diagnostic_artifact_role) (diagnostic-format-sarif.cc:1922) ==3306525== by 0x36E72C6: selftest::test_make_location_object(selftest::line_table_case const&) (diagnostic-format-sarif.cc:3500) ==3306525== by 0x375609B: selftest::for_each_line_table_case(void (*)(selftest::line_table_case const&)) (input.cc:3898) ==3306525== by 0x36E9668: selftest::diagnostic_format_sarif_cc_tests() (diagnostic-format-sarif.cc:3910) ==3306525== by 0x3592A11: selftest::run_tests() (selftest-run-tests.cc:100) ==3306525== by 0x17DBEF3: toplev::run_self_tests() (toplev.cc:2268) ==3306525== by 0x17DC2BF: toplev::main(int, char**) (toplev.cc:2376) ==3306525== by 0x36A1919: main (main.cc:39) ==3306525== ==3306525== 12,400 (1,536 direct, 10,864 indirect) bytes in 16 blocks are definitely lost in loss record 355 of 375 ==3306525== at 0x514FE7D: operator new(unsigned long) (vg_replace_malloc.c:342) ==3306525== by 0x36E5FD2: sarif_builder::get_or_create_artifact(char const*, diagnostic_artifact_role, bool) (diagnostic-format-sarif.cc:2884) ==3306525== by 0x36E2323: sarif_builder::sarif_builder(diagnostic_context&, line_maps const*, char const*, bool) (diagnostic-format-sarif.cc:1500) ==3306525== by 0x36E70AA: selftest::test_make_location_object(selftest::line_table_case const&) (diagnostic-format-sarif.cc:3469) ==3306525== by 0x375609B: selftest::for_each_line_table_case(void (*)(selftest::line_table_case const&)) (input.cc:3898) ==3306525== by 0x36E9668: selftest::diagnostic_format_sarif_cc_tests() (diagnostic-format-sarif.cc:3910) ==3306525== by 0x3592A11: selftest::run_tests() (selftest-run-tests.cc:100) ==3306525== by 0x17DBEF3: toplev::run_self_tests() (toplev.cc:2268) ==3306525== by 0x17DC2BF: toplev::main(int, char**) (toplev.cc:2376) ==3306525== by 0x36A1919: main (main.cc:39) ==3306525== ==3306525== LEAK SUMMARY: ==3306525== definitely lost: 3,072 bytes in 32 blocks ==3306525== indirectly lost: 21,056 bytes in 368 blocks ==3306525== possibly lost: 0 bytes in 0 blocks ==3306525== still reachable: 1,191,511 bytes in 2,408 blocks ==3306525== suppressed: 0 bytes in 0 blocks ==3306525== Reachable blocks (those to which a pointer was found) are not shown. ==3306525== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==3306525== ==3306525== For lists of detected and suppressed errors, rerun with: -s ==3306525== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0) Fixed thusly. gcc/ChangeLog: * diagnostic-format-sarif.cc (sarif_builder::~sarif_builder): New, deleting any remaining artifact objects. (sarif_builder::make_run_object): Empty the artifact map. * ordered-hash-map.h (ordered_hash_map::empty): New. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-09-30autovectorizer: Test autovectorization of different dot-prod modes.Victor Do Nascimento3-0/+116
Given the novel treatment of the dot product optab as a conversion, we are now able to target different relationships between output modes and input modes. This is made clearer by way of example. Previously, on AArch64, the following loop was vectorizable: uint32_t udot4(int n, uint8_t* data) { uint32_t sum = 0; for (int i=0; i<n; i+=1) sum += data[i] * data[i]; return sum; } while the following was not: uint32_t udot2(int n, uint16_t* data) { uint32_t sum = 0; for (int i=0; i<n; i+=1) sum += data[i] * data[i]; return sum; } Under the new treatment of the dot product optab, they are both now vectorizable. This adds the relevant target-agnostic check to ensure this behavior in the autovectorizer, gated behind the new check_effective_target `vect_dotprod_hisi' as well a runtime check targeting aarch64. gcc/testsuite/ChangeLog: * lib/target-supports.exp (check_effective_target_vect_dotprod_hisi): New. * gcc.dg/vect/vect-dotprod-conv-optab.c: Likewise. * gcc.target/aarch64/vect-dotprod-twoway-hisi.c: Likewise.
2024-09-30c6x: Adjust dot-product backend patternsVictor Do Nascimento1-1/+1
Following the migration of the dot_prod optab from a direct to a conversion-type optab, ensure all back-end patterns incorporate the second machine mode into pattern names. gcc/ChangeLog: * config/c6x/c6x.md (sdot_prodv2hi): Renamed to... (sdot_prodsiv2hi): ...this.
2024-09-30rs6000: Adjust altivec dot-product backend patternsVictor Do Nascimento1-2/+2
Following the migration of the dot_prod optab from a direct to a conversion-type optab, ensure all back-end patterns incorporate the second machine mode into pattern names. gcc/ChangeLog: * config/rs6000/altivec.md (udot_prod<mode>): Renamed to... (udot_prodv4si<mode>): ...this. (sdot_prodv8hi): Renamed to... (sdot_prodv4siv8hi): ...this.
2024-09-30mips: Adjust dot-product backend patternsVictor Do Nascimento1-1/+1
Following the migration of the dot_prod optab from a direct to a conversion-type optab, ensure all back-end patterns incorporate the second machine mode into pattern names. gcc/ChangeLog: * config/mips/loongson-mmi.md (sdot_prodv4hi): Renamed to... (sdot_prodv2siv4hi): ...this.
2024-09-30arc: Adjust dot-product backend patternsVictor Do Nascimento1-4/+4
Following the migration of the dot_prod optab from a direct to a conversion-type optab, ensure all back-end patterns incorporate the second machine mode into pattern names. gcc/ChangeLog: * config/arc/simdext.md (sdot_prodv2hi): Renamed to... (sdot_prodsiv2hi): ...this. (udot_prodv2hi): Renamed to... (udot_prodsiv2hi): ...this. (sdot_prodv4hi): Renamed to... (sdot_prodv2siv4hi): ...this. (udot_prodv4hi): Renamed to... (udot_prodv2siv4hi): ...this.
2024-09-30i386: Fix dot_prod backend patterns for mmx and sse targetsVictor Do Nascimento2-34/+37
Following the migration of the dot_prod optab from a direct to a conversion-type optab, ensure all back-end patterns incorporate the second machine mode into pattern names. gcc/ChangeLog: * config/i386/mmx.md (usdot_prodv8qi): Renamed to... (usdot_prodv2siv8qi): ...this. (sdot_prodv8qi): Renamed to... (sdot_prodv2siv8qi): ...this. (udot_prodv8qi): Renamed to... (udot_prodv2siv8qi): ...this. (usdot_prodv4hi): Renamed to... (usdot_prodv2siv4hi): ...this. (udot_prodv4hi): Renamed to... (udot_prodv2siv4hi): ...this. (sdot_prodv4hi): Renamed to... (sdot_prodv2siv4hi): ...this. * config/i386/sse.md (sdot_prod<mode>): Renamed to... (sdot_prod<sseunpackmodelower><mode>): ...this. (sdot_prodv4si): Renamed to... (sdot_prodv2div4si): ...this. (usdot_prod<mode>): Renamed to... (usdot_prod<ssedvecmodelower><mode>): ...this. (sdot_prod<mode>): Renamed to... (sdot_prod<ssedvecmodelower><mode>): ...this. (sdot_prodv64qi): Renamed to... (sdot_prodv16siv64qi): ...this. (udot_prod<mode>): Renamed to... (udot_prod<ssedvecmodelower><mode>): ...this. (udot_prodv64qi): Renamed to... (udot_prodv16qiv64qi): ...this. (usdot_prod<mode>): Renamed to... (usdot_prod<sseunpackmodelower><mode>): ...this. (udot_prod<mode>): Renamed to... (udot_prod<sseunpackmodelower><mode>): ...this.
2024-09-30arm: Fix arm backend-use of (u|s|us)dot_prod patternsVictor Do Nascimento2-4/+11
Given recent changes to the dot_prod standard pattern name, this patch fixes the arm back-end by implementing the following changes: 1. Add 2nd mode to all patterns relating to the dot-product in .md files. 2. redirect the single-mode CODE_FOR_neon_(u|s|us)dot<mode> values generated from `arm_neon_builtins.def' to their new 2-mode equivalents via means of simple aliases, as per the following example: constexpr insn_code CODE_FOR_neon_sdotv8qi = CODE_FOR_neon_sdotv2siv8qi; gcc/ChangeLog: * config/arm/neon.md (<sup>dot_prod<vsi2qi>): Renamed to... (<sup>dot_prod<mode><vsi2qi>): ...this. (neon_<sup>dot<vsi2qi>): Renamed to... (neon_<sup>dot<mode><vsi2qi>): ...this. (neon_usdot<vsi2qi>): Renamed to... (neon_usdot<mode><vsi2qi>): ...this. (usdot_prod<vsi2qi>): Renamed to... (usdot_prod<mode><vsi2qi>): ...this. * config/arm/arm-builtins.cc (CODE_FOR_neon_sdotv8qi): Definie as alias to new CODE_FOR_neon_sdotv2siv8qi. (CODE_FOR_neon_udotv8qi): Definie as alias to new CODE_FOR_neon_udotv2siv8qi. (CODE_FOR_neon_usdotv8qi): Definie as alias to new CODE_FOR_neon_usdotv2siv8qi. (CODE_FOR_neon_sdotv16qi): Definie as alias to new CODE_FOR_neon_sdotv4siv16qi. (CODE_FOR_neon_udotv16qi): Definie as alias to new CODE_FOR_neon_udotv4siv16qi. (CODE_FOR_neon_usdotv16qi): Definie as alias to new CODE_FOR_neon_usdotv4siv16qi.
2024-09-30aarch64: Fix aarch64 backend-use of (u|s|us)dot_prod patternsVictor Do Nascimento9-17/+77
Given recent changes to the dot_prod standard pattern name, this patch fixes the aarch64 back-end by implementing the following changes: 1. Add 2nd mode to all (u|s|us)dot_prod patterns in .md files. 2. Rewrite initialization and function expansion mechanism for simd builtins. 3. Fix all direct calls to back-end `dot_prod' patterns in SVE builtins. Finally, given that it is now possible for the compiler to differentiate between the two- and four-way dot product, we add a test to ensure that autovectorization picks up on dot-product patterns where the result is twice the width of the operands. gcc/ChangeLog: * config/aarch64/aarch64-simd.md (<sur>dot_prod<vsi2qi><vczle><vczbe>): Renamed to... (<sur>dot_prod<mode><vsi2qi><vczle><vczbe>): ...this. (usdot_prod<vsi2qi><vczle><vczbe>): Renamed to... (usdot_prod<mode><vsi2qi><vczle><vczbe>): ...this. (<su>sadv16qi): Adjust call to gen_udot_prod take second mode. (popcount<mode2>): fix use of `udot_prod_optab'. * config/aarch64/aarch64-sve.md (<sur>dot_prod<vsi2qi>): Renamed to... (<sur>dot_prod<mode><vsi2qi>): ...this. (@<sur>dot_prod<vsi2qi>): Renamed to... (@<sur>dot_prod<mode><vsi2qi>): ...this. (<su>sad<vsi2qi>): Adjust call to gen_udot_prod take second mode. * config/aarch64/aarch64-sve2.md (@aarch64_sve_<sur>dotvnx4sivnx8hi): Renamed to... (<sur>dot_prodvnx4sivnx8hi): ...this. * config/aarch64/aarch64-simd-builtins.def: Modify macro expansion-based initialization and expansion of (u|s|us)dot_prod builtins. * config/aarch64/aarch64-builtins.cc (CODE_FOR_aarch64_sdot_prodv8qi): Define as alias to new CODE_FOR_sdot_prodv2siv8qi. (CODE_FOR_aarch64_udot_prodv8qi): Define as alias to new CODE_FOR_udot_prodv2siv8qi. (CODE_FOR_aarch64_usdot_prodv8qi): Define as alias to new CODE_FOR_usdot_prodv2siv8qi. (CODE_FOR_aarch64_sdot_prodv16qi): Define as alias to new CODE_FOR_sdot_prodv4siv16qi. (CODE_FOR_aarch64_udot_prodv16qi): Define as alias to new CODE_FOR_udot_prodv4siv16qi. (CODE_FOR_aarch64_usdot_prodv16qi): Define as alias to new CODE_FOR_usdot_prodv4siv16qi. * config/aarch64/aarch64-sve-builtins-base.cc (svdot_impl::expand): s/direct/convert/ in `convert_optab_handler_for_sign' function call. (svusdot_impl::expand): add second mode argument in call to `code_for_dot_prod'. * config/aarch64/aarch64-sve-builtins.cc (function_expander::convert_optab_handler_for_sign): New class method. * config/aarch64/aarch64-sve-builtins.h (class function_expander): Add prototype for new `convert_optab_handler_for_sign' method. gcc/testsuite/ChangeLog: * gcc.target/aarch64/sme/vect-dotprod-twoway.c (udot2): New.
2024-09-30autovectorizer: Add basic support for convert optabsVictor Do Nascimento5-3/+59
Given the shift from modeling dot products as direct optabs to treating them as conversion optabs, we make necessary changes to the autovectorizer code to ensure that given the relevant tree code, together with the input and output data modes, we can retrieve the relevant optab and subsequently the insn_code for it. gcc/ChangeLog: * gimple-match-exports.cc (directly_supported_p): Add overload for conversion-type optabs. * gimple-match.h (directly_supported_p): Add new function prototype. * optabs.cc (expand_widen_pattern_expr): Make the DOT_PROD_EXPR tree code use `find_widening_optab_handler' to retrieve icode. * tree-vect-loop.cc (vect_is_emulated_mixed_dot_prod): make it call conversion-type overloaded `directly_supported_p'. * tree-vect-patterns.cc (vect_supportable_conv_optab_p): New. (vect_recog_dot_prod_pattern): s/direct/conv/ in call to `vect_supportable_direct_optab_p'.
2024-09-30optabs: Make all `*dot_prod_optab's modeled as conversionsVictor Do Nascimento2-27/+25
Given the specification in the GCC internals manual defines the {u|s}dot_prod<m> standard name as taking "two signed elements of the same mode, adding them to a third operand of wider mode", there is currently ambiguity in the relationship between the mode of the first two arguments and that of the third. This vagueness means that, in theory, different modes may be supportable in the third argument. This flexibility would allow for a given backend to add to the accumulator a different number of vectorized products, e.g. A backend may provide instructions for both: accum += a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3] and accum += a[0] * b[0] + a[1] * b[1], as is now seen in the SVE2.1 extension to AArch64. In spite of the aforementioned flexibility, modeling the dot-product operation as a direct optab means that we have no way to encode both input and the accumulator data modes into the backend pattern name, which prevents us from harnessing this flexibility. We therefore make all dot_prod optabs conversions, allowing, for example, for the encoding of both 2-way and 4-way dot product backend patterns. gcc/ChangeLog: * optabs.def (sdot_prod_optab): Convert from OPTAB_D to OPTAB_CD. (udot_prod_optab): Likewise. (usdot_prod_optab): Likewise. * doc/md.texi (Standard Names): update entries for u,s and us dot_prod names.
2024-09-30tree-optimization/116879 - failure to recognize non-empty latchRichard Biener2-4/+26
When we relaxed the vectorizers constraint on loop structure verifying the emptiness of the latch became too lose as can be seen in the case for PR116879 where the latch effectively contains two basic-blocks which one being an unmerged forwarder that's not empty. PR tree-optimization/116879 * tree-vect-loop.cc (vect_analyze_loop_form): Scan all blocks that form the latch. * gcc.dg/pr116879.c: New testcase.
2024-09-30Merge branch 'master' of git+ssh://gcc.gnu.org/git/gcc into ↵Pranil Dey4196-107670/+315082
devel/nothrow-detection
2024-09-30middle-end: check explicitly for external or constants when checking for ↵Tamar Christina2-1/+20
loop invariant [PR116817] The previous check if a value was external was checking !vect_get_internal_def (vinfo, var) but this of course isn't completely right as they could reductions etc. This changes the check to just explicitly look at externals and constants. Note that reductions remain unhandled here, but we don't support codegen of boolean reductions today anyway. So at the time we do then this would have the be handled as well in lowering. gcc/ChangeLog: PR tree-optimization/116817 * tree-vect-patterns.cc (vect_recog_bool_pattern): Check for const or externals. gcc/testsuite/ChangeLog: PR tree-optimization/116817 * g++.dg/vect/pr116817.cc: New test.
2024-09-30Ensure coarrays in calls use a descriptor [PR81265]Andre Vehreschild2-1/+81
gcc/fortran/ChangeLog: PR fortran/81265 * trans-expr.cc (gfc_conv_procedure_call): Ensure coarrays use a descriptor when passed. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/pr81265.f90: New test.
2024-09-30tree-optimization/116842 - vectorizer load hosting breaks UID orderRichard Biener2-12/+40
The following fixes the case when vectorizing a load hoists an invariant load and dependent stmts, thereby breaking UID order of said stmts. While we duplicate the load we just move the dependences. PR tree-optimization/116842 * tree-vect-stmts.cc (hoist_defs_of_uses): Sort stmts to hoist after UID to avoid breaking vect_stmt_dominates_stmt_p. * g++.dg/torture/pr116842.C: New testcase.
2024-09-30tree-optimization/116785 - relax volatile handling in PTARichard Biener1-2/+2
When there's volatile qualified stores we do not have to treat the destination as pointing to ANYTHING. It's only when reading from it that we want to treat the resulting pointers as pointing to ANYTHING. PR tree-optimization/116785 * tree-ssa-structalias.cc (get_constraint_for_1): Only volatile qualified reads produce ANYTHING.
2024-09-30tree-optimization/116850 - corrupt post-dom infoRichard Biener2-3/+32
Path isolation computes post-dominators on demand but can end up splitting blocks after that, wrecking it. We can delay splitting of blocks until we no longer need the post-dom info which is what the following patch does to solve the issue. PR tree-optimization/116850 * gimple-ssa-isolate-paths.cc (bb_split_points): New global. (insert_trap): Delay BB splitting if post-doms are computed. (find_explicit_erroneous_behavior): Process delayed BB splitting after releasing post dominators. (gimple_ssa_isolate_erroneous_paths): Do not free post-dom info here. * gcc.dg/pr116850.c: New testcase.
2024-09-30Match: Support form 1 for scalar signed integer SAT_SUBPan Li2-3/+19
This patch would like to support the form 1 of the scalar signed integer SAT_SUB. Aka below example: Form 1: #define DEF_SAT_S_SUB_FMT_1(T, UT, MIN, MAX) \ T __attribute__((noinline)) \ sat_s_sub_##T##_fmt_1 (T x, T y) \ { \ T minus = (UT)x - (UT)y; \ return (x ^ y) >= 0 \ ? minus \ : (minus ^ x) >= 0 \ ? minus \ : x < 0 ? MIN : MAX; \ } DEF_SAT_S_SUB_FMT_1(int8_t, uint8_t, INT8_MIN, INT8_MAX) Before this patch: 4 │ __attribute__((noinline)) 5 │ int8_t sat_s_sub_int8_t_fmt_1 (int8_t x, int8_t y) 6 │ { 7 │ int8_t minus; 8 │ unsigned char x.0_1; 9 │ unsigned char y.1_2; 10 │ unsigned char _3; 11 │ signed char _4; 12 │ signed char _5; 13 │ int8_t _6; 14 │ _Bool _11; 15 │ signed char _12; 16 │ signed char _13; 17 │ signed char _14; 18 │ signed char _15; 19 │ 20 │ ;; basic block 2, loop depth 0 21 │ ;; pred: ENTRY 22 │ x.0_1 = (unsigned char) x_7(D); 23 │ y.1_2 = (unsigned char) y_8(D); 24 │ _3 = x.0_1 - y.1_2; 25 │ minus_9 = (int8_t) _3; 26 │ _4 = x_7(D) ^ y_8(D); 27 │ _5 = x_7(D) ^ minus_9; 28 │ _15 = _4 & _5; 29 │ if (_15 < 0) 30 │ goto <bb 3>; [41.00%] 31 │ else 32 │ goto <bb 4>; [59.00%] 33 │ ;; succ: 3 34 │ ;; 4 35 │ 36 │ ;; basic block 3, loop depth 0 37 │ ;; pred: 2 38 │ _11 = x_7(D) < 0; 39 │ _12 = (signed char) _11; 40 │ _13 = -_12; 41 │ _14 = _13 ^ 127; 42 │ ;; succ: 4 43 │ 44 │ ;; basic block 4, loop depth 0 45 │ ;; pred: 2 46 │ ;; 3 47 │ # _6 = PHI <minus_9(2), _14(3)> 48 │ return _6; 49 │ ;; succ: EXIT 50 │ 51 │ } After this patch: 4 │ __attribute__((noinline)) 5 │ int8_t sat_s_sub_int8_t_fmt_1 (int8_t x, int8_t y) 6 │ { 7 │ int8_t _6; 8 │ 9 │ ;; basic block 2, loop depth 0 10 │ ;; pred: ENTRY 11 │ _6 = .SAT_SUB (x_7(D), y_8(D)); [tail call] 12 │ return _6; 13 │ ;; succ: EXIT 14 │ 15 │ } The below test suites are passed for this patch. * The rv64gcv fully regression test. * The x86 bootstrap test. * The x86 fully regression test. gcc/ChangeLog: * match.pd: Add case 1 matching pattern for signed SAT_SUB. * tree-ssa-math-opts.cc (gimple_signed_integer_sat_sub): Add new decl for generated SAT_SUB matching func. (match_unsigned_saturation_sub): Rename from... (match_saturation_sub): ...Rename to and add signed SAT_SUB matching. (math_opts_dom_walker::after_dom_children): Leverage the named match func for both the unsigned and signed SAT_SUB. Signed-off-by: Pan Li <pan2.li@intel.com>