aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2024-10-01range-cache: Fix ICE on SSA_NAME with def_stmt not yet in the IL [PR116898]Jakub Jelinek2-3/+26
Some passes like the bitint lowering queue some statements on edges and only commit them at the end of the pass. If they use ranger at the same time, the ranger might see such SSA_NAMEs and ICE on those. The following patch instead just punts on them. 2024-10-01 Jakub Jelinek <jakub@redhat.com> PR middle-end/116898 * gimple-range-cache.cc (ranger_cache::block_range): If a SSA_NAME with NULL def_bb isn't SSA_NAME_IS_DEFAULT_DEF, return false instead of failing assertion. Formatting fix. * gcc.dg/bitint-110.c: New test.
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-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>
2024-09-30Daily bump.GCC Administrator3-1/+60
2024-09-30RISC-V: Add testcases for form 1 of scalar signed SAT_SUBPan Li10-0/+267
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) The below test are passed for this patch. * The rv64gcv fully regression test. It is test only patch and obvious up to a point, will commit it directly if no comments in next 48H. gcc/testsuite/ChangeLog: * gcc.target/riscv/sat_arith.h: Add test helper macros. * gcc.target/riscv/sat_arith_data.h: Add test data for SAT_SUB. * gcc.target/riscv/sat_s_sub-1-i16.c: New test. * gcc.target/riscv/sat_s_sub-1-i32.c: New test. * gcc.target/riscv/sat_s_sub-1-i64.c: New test. * gcc.target/riscv/sat_s_sub-1-i8.c: New test. * gcc.target/riscv/sat_s_sub-run-1-i16.c: New test. * gcc.target/riscv/sat_s_sub-run-1-i32.c: New test. * gcc.target/riscv/sat_s_sub-run-1-i64.c: New test. * gcc.target/riscv/sat_s_sub-run-1-i8.c: New test. Signed-off-by: Pan Li <pan2.li@intel.com>
2024-09-30RISC-V: Implement scalar SAT_SUB for signed integerPan Li3-0/+81
This patch would like to implement the sssub form 1. Aka: 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: 10 │ sat_s_sub_int8_t_fmt_1: 11 │ subw a5,a0,a1 12 │ slliw a5,a5,24 13 │ sraiw a5,a5,24 14 │ xor a1,a0,a1 15 │ xor a4,a0,a5 16 │ and a1,a1,a4 17 │ blt a1,zero,.L4 18 │ mv a0,a5 19 │ ret 20 │ .L4: 21 │ srai a0,a0,63 22 │ xori a5,a0,127 23 │ mv a0,a5 24 │ ret After this patch: 10 │ sat_s_sub_int8_t_fmt_1: 11 │ sub a4,a0,a1 12 │ xor a5,a0,a4 13 │ xor a1,a0,a1 14 │ and a5,a5,a1 15 │ srli a5,a5,7 16 │ andi a5,a5,1 17 │ srai a0,a0,63 18 │ xori a3,a0,127 19 │ neg a0,a5 20 │ addi a5,a5,-1 21 │ and a3,a3,a0 22 │ and a0,a4,a5 23 │ or a0,a0,a3 24 │ slliw a0,a0,24 25 │ sraiw a0,a0,24 26 │ ret The below test suites are passed for this patch. * The rv64gcv fully regression test. gcc/ChangeLog: * config/riscv/riscv-protos.h (riscv_expand_sssub): Add new func decl for expanding signed SAT_SUB. * config/riscv/riscv.cc (riscv_expand_sssub): Add new func impl for expanding signed SAT_SUB. * config/riscv/riscv.md (sssub<mode>3): Add new pattern sssub for scalar signed integer. Signed-off-by: Pan Li <pan2.li@intel.com>
2024-09-29cselib: Discard useless locs of preserved VALUEs [PR116627]Jakub Jelinek1-0/+5
remove_useless_values iteratively discards useless locs (locs of cselib_val which refer to non-preserved VALUEs with no locations), which in turn can make further values useless until no further VALUEs are made useless and then discards the useless VALUEs. Preserved VALUEs (something done during var-tracking only I think) live in a different hash table, cselib_preserved_hash_table rather than cselib_hash_table. cselib_find_slot first looks up slot in cselib_preserved_hash_table and only if not found looks it up in cselib_hash_table (and INSERTs only into the latter), whereas preservation of a VALUE results in move of a cselib_val from the latter to the former hash table. The testcase in the PR (apparently too fragile, it only reproduces on 14 branch with various flags on a single arch, not on trunk) ICEs, because we have a preserved VALUE (QImode with (const_int 0) as one of the locs). In a different BB SImode r2 is looked up, a non-preserved VALUE is created for it, and the r13-2916 added code attempts to lookup also SUBREGs of that in narrower modes, among those QImode, so adds to that SImode r2 non-preserve VALUE a new loc of (subreg:QI (value:SI) 0). That SImode value is considered useless, so remove_useless_value discards it, but nothing discarded it from the preserved VALUE's loc_list, so when looking something up in the hash table we ICE trying to derevence CSELIB_VAL of the discarded VALUE. I think we need to discuard useless locs even from the preserved VALUEs. That IMHO shouldn't create any further useless VALUEs, the preserved VALUEs are never useless, so we don't need to iterate with it, can do it just once, but IMHO it needs to be done because actually discard_useless_values. The following patch does that. 2024-09-29 Jakub Jelinek <jakub@redhat.com> PR target/116627 * cselib.cc (remove_useless_values): Discard useless locs even from preserved cselib_vals in cselib_preserved_hash_table hash table.
2024-09-29testsuite: XFAIL gfortran.dg/initialization_25.f90 properly (again)Sam James1-1/+1
dg-error needs an argument for "why" / a comment. gcc/testsuite/ChangeLog: PR fortran/116858 * gfortran.dg/initialization_25.f90: Fix dg-error arguments.
2024-09-29[PATCH] SH: Document extended asm operand modifersPietro Monteiro1-0/+29
From: Pietro Monteiro <pietro@sociotechnical.xyz> SH: Document extended asm operand modifers Tested by running "make info pdf html" and looking at the pdf and html output. I used the comment on "gcc/config/sh.cc:sh_print_operand()", SH's TARGET_PRINT_OPERAND function, as a guide. gcc/ChangeLog: * doc/extend.texi (SH Operand Modifiers): New. Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
2024-09-29[PATCH] [PATCH] Avoid integer overflow in gcc.dg/cpp/charconst-3.c (PR ↵Mikael Pettersson1-1/+1
testsuite/116806) The intermediate expression (unsigned char) '\234' * scale overflows int on int16 targets, causing the test case to fail there. Fixed by performing the arithmetic in unsigned type, as suggested by Andrew Pinski. Regression tested on x86_64-pc-linux-gnu, and on an out-of-tree 16-bit target with simulator. Manually checked the generated code for pdp11 and xstormy16. Ok for trunk? (I don't have commit rights so I'd need help committing it.) gcc/testsuite/ PR testsuite/116806 * gcc.dg/cpp/charconst-3.c: Perform arithmetic in unsigned type to avoid integer overflow.
2024-09-29[PATCH v2] RISC-V: Improve code generation for select of consecutive constantsJovan Vukic2-0/+71
Based on the valuable feedback I received, I decided to implement the patch in the RTL pipeline. Since a similar optimization already exists in simplify_binary_operation_1, I chose to generalize my original approach and place it directly below that code. The expression (X xor C1) + C2 is simplified to X xor (C1 xor C2) under the conditions described in the patch. This is a more general optimization, but it still applies to the RISC-V case, which was my initial goal: long f1(long x, long y) { return (x > y) ? 2 : 3; } Before the patch, the generated assembly is: f1(long, long): sgt a0,a0,a1 xori a0,a0,1 addi a0,a0,2 ret After the patch, the generated assembly is: f1(long, long): sgt a0,a0,a1 xori a0,a0,3 ret The patch optimizes cases like x LT/GT y ? 2 : 3 (and x GE/LE y ? 3 : 2), as initially intended. Since this optimization is more general, I noticed it also optimizes cases like x < CONST ? 3 : 2 when CONST < 0. I’ve added tests for these cases as well. A bit of logic behind the patch: The equality A + B == A ^ B + 2 * (A & B) always holds true. This can be simplified to A ^ B if 2 * (A & B) == 0. In our case, we have A == X ^ C1, B == C2 and X is either 0 or 1. PR target/108038 gcc/ChangeLog: * simplify-rtx.cc (simplify_context::simplify_binary_operation_1): New simplification. gcc/testsuite/ChangeLog: * gcc.target/riscv/slt-1.c: New test.
2024-09-29doc: Document struct-layout-1.exp for ABI checksDimitar Dimitrov1-1/+17
This test helped discover PR116621, so it is worth being documented. gcc/ChangeLog: * doc/sourcebuild.texi: Document struct-layout-1.exp. Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2024-09-29Daily bump.GCC Administrator4-1/+30
2024-09-28Implement FINDLOC for UNSIGNED.Thomas Koenig4-3/+90
gcc/fortran/ChangeLog: * check.cc (intrinsic_type_check): Handle unsigned. (gfc_check_findloc): Likewise. * gfortran.texi: Include FINDLOC in unsigned documentation. * iresolve.cc (gfc_resolve_findloc): Use INTEGER version for UNSIGNED. gcc/testsuite/ChangeLog: * gfortran.dg/unsigned_33.f90: New test.
2024-09-28Implement CSHIFT and EOSHIFT for unsigned.Thomas Koenig5-1/+66
gcc/fortran/ChangeLog: * check.cc (gfc_check_eoshift): Handle BT_UNSIGNED. * simplify.cc (gfc_simplify_eoshift): Likewise. * gfortran.texi: Document CSHIFT and EOSHIFT for UNSIGNED. gcc/testsuite/ChangeLog: * gfortran.dg/unsigned_31.f90: New test. * gfortran.dg/unsigned_32.f90: New test.
2024-09-28doc: Remove i?86-*-linux* installation note from 2003Gerald Pfeifer1-3/+0
gcc: PR target/69374 * doc/install.texi (Specific) <i?86-*-linux*>: Remove note from 2003.
2024-09-28Daily bump.GCC Administrator5-1/+228
2024-09-28c++: Implement resolution for DR 36 [PR116160]Nathaniel Shead4-7/+18
This implements part of P1787 to no longer complain about redeclaring an entity via using-decl other than in a class scope. PR c++/116160 gcc/cp/ChangeLog: * name-lookup.cc (supplement_binding): Allow redeclaration via USING_DECL if not in class scope. (do_nonmember_using_decl): Remove function-scope exemption. (push_using_decl_bindings): Remove outdated comment. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/using-enum-3.C: No longer expect an error. * g++.dg/lookup/using53.C: Remove XFAIL. * g++.dg/cpp2a/using-enum-11.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-28c++: Don't strip USING_DECLs when updating local bindings [PR116748]Nathaniel Shead3-7/+19
Currently update_binding strips USING_DECLs too eagerly, leading to ICEs in pop_local_decl as it can't find the decl it's popping in the binding list. Let's rather try to keep the original USING_DECL around. This also means that using59.C can point to the location of the using-decl rather than the underlying object directly; this is in the direction required to fix PR c++/106851 (though more work is needed to emit properly helpful diagnostics here). PR c++/116748 gcc/cp/ChangeLog: * name-lookup.cc (update_binding): Maintain USING_DECLs in the binding slots. gcc/testsuite/ChangeLog: * g++.dg/lookup/using59.C: Update location. * g++.dg/lookup/using69.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-28c++/modules: Propagate purview/import for templates in duplicate_decls ↵Nathaniel Shead4-0/+41
[PR116803] We need to ensure that for a declaration in the module purview, that the resulting declaration has PURVIEW_P set and IMPORT_P cleared so that we understand it might be something requiring exporting. This is normally handled for a declaration by set_instantiating_module, but when this declaration is a redeclaration duplicate_decls needs to propagate this to olddecl. This patch only changes the logic for template declarations, because in the non-template case the whole contents of olddecl's DECL_LANG_SPECIFIC is replaced with newdecl's (which includes these flags), so there's nothing to do. PR c++/116803 gcc/cp/ChangeLog: * decl.cc (duplicate_decls): Propagate DECL_MODULE_PURVIEW_P and DECL_MODULE_IMPORT_P for template redeclarations. gcc/testsuite/ChangeLog: * g++.dg/modules/merge-18_a.H: New test. * g++.dg/modules/merge-18_b.H: New test. * g++.dg/modules/merge-18_c.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-27c++: ICE with structured bindings and m-d array [PR102594]Marek Polacek2-1/+35
We ICE in decay_conversion with this test: struct S { S() {} }; S arr[1][1]; auto [m](arr3); But not when the last line is: auto [n] = arr3; Therefore the difference is between copy- and direct-init. In particular, in build_vec_init we have: if (direct_init) from = build_tree_list (NULL_TREE, from); and then we call build_vec_init again with init==from. Then decay_conversion gets the TREE_LIST and it crashes. build_aggr_init has: /* Wrap the initializer in a CONSTRUCTOR so that build_vec_init recognizes it as direct-initialization. */ init = build_constructor_single (init_list_type_node, NULL_TREE, init); CONSTRUCTOR_IS_DIRECT_INIT (init) = true; so I propose to do the same in build_vec_init. PR c++/102594 gcc/cp/ChangeLog: * init.cc (build_vec_init): Build up a CONSTRUCTOR to signal direct-initialization rather than a TREE_LIST. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/decomp61.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-09-27diagnostic: Save/restore diagnostic context history and push/pop state for ↵Jakub Jelinek5-1/+80
PCH [PR116847] The following patch on top of the just posted cleanup patch saves/restores the m_classification_history and m_push_list vectors for PCH. Without that as the testcase shows during parsing of the templates we don't report ignored diagnostics, but after loading PCH header when instantiating those templates those warnings can be emitted. This doesn't show up on x86_64-linux build because configure injects there -fcf-protection -mshstk flags during library build (and so also during PCH header creation), but make check doesn't use those flags and so the PCH header is ignored. 2024-09-26 Jakub Jelinek <jakub@redhat.com> PR libstdc++/116847 gcc/ * diagnostic.h (diagnostic_option_classifier): Add pch_save and pch_restore method declarations. (diagnostic_context): Add pch_save and pch_restore inline method definitions. * diagnostic.cc (diagnostic_option_classifier::pch_save): New method. (diagnostic_option_classifier::pch_restore): Likewise. gcc/c-family/ * c-pch.cc: Include diagnostic.h. (c_common_write_pch): Call global_dc->pch_save. (c_common_read_pch): Call global_dc->pch_restore. gcc/testsuite/ * g++.dg/pch/pr116847.C: New test. * g++.dg/pch/pr116847.Hs: New test.
2024-09-27diagnostic: Use vec instead of custom array reallocations for ↵Jakub Jelinek2-46/+30
m_classification_history/m_push_list [PR116847] diagnostic.h already relies on vec.h, it uses auto_vec in one spot. The following patch converts m_classification_history and m_push_list hand-managed arrays to vec templates. The main advantage is exponential rather than linear reallocation, e.g. with current libstdc++ headers if one includes all the standard headers there could be ~ 300 reallocations of the m_classification_history array (sure, not all of them will result in actually copying the data, but still). In addition to that it fixes some formatting issues in the code. 2024-09-26 Jakub Jelinek <jakub@redhat.com> PR libstdc++/116847 * diagnostic.h (diagnostic_option_classifier): Change type of m_classification_history from diagnostic_classification_change_t * to vec<diagnostic_classification_change_t>. Change type of m_push_list from int * to vec<int>. Remove m_n_classification_history and m_n_push members. * diagnostic.cc (diagnostic_option_classifier::init): Set m_push_list to vNULL rather than nullptr. Don't initialize m_n_push. Initialize m_classification_history to vNULL. (diagnostic_option_classifier::fini): Call release () method on m_push_list instead of free on it. Call release () on m_classification_history. Don't clear m_n_push. (diagnostic_option_classifier::push): Adjust for m_push_list and m_classification_history being vectors rather than custom allocated arrays with counter. (diagnostic_option_classifier::pop): Likewise. (classify_diagnostic): Adjust for m_classification_history being vector rather than custom allocated array with counter. (update_effective_level_from_pragmas): Likewise.