public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r9-10045] tree-optimization/105070 - annotate bit cluster tests with locations Date: Fri, 6 May 2022 11:09:16 +0000 (GMT) [thread overview] Message-ID: <20220506110916.3AA60394FC11@sourceware.org> (raw) https://gcc.gnu.org/g:4be43dbbed4b217201cb395449a7682cd98301ce commit r9-10045-g4be43dbbed4b217201cb395449a7682cd98301ce Author: Richard Biener <rguenther@suse.de> Date: Mon Mar 28 10:07:53 2022 +0200 tree-optimization/105070 - annotate bit cluster tests with locations The following makes sure to annotate the tests generated by switch lowering bit-clustering with locations which otherwise can be completely lost even at -O0. 2022-03-28 Richard Biener <rguenther@suse.de> PR tree-optimization/105070 * tree-switch-conversion.h (bit_test_cluster::hoist_edge_and_branch_if_true): Add location argument. * tree-switch-conversion.c (bit_test_cluster::hoist_edge_and_branch_if_true): Annotate cond with location. (bit_test_cluster::emit): Annotate all generated expressions with location. (cherry picked from commit b285999440c000685c4e4dae9c2a9a8a8fe9e176) Diff: --- gcc/tree-switch-conversion.c | 28 ++++++++++++++++------------ gcc/tree-switch-conversion.h | 3 ++- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c index 3d4a093d828..32c5f794ff2 100644 --- a/gcc/tree-switch-conversion.c +++ b/gcc/tree-switch-conversion.c @@ -1480,7 +1480,7 @@ case_bit_test::cmp (const void *p1, const void *p2) void bit_test_cluster::emit (tree index_expr, tree index_type, - tree, basic_block default_bb, location_t) + tree, basic_block default_bb, location_t loc) { struct case_bit_test test[m_max_case_bit_tests] = { {} }; unsigned int i, j, k; @@ -1574,9 +1574,9 @@ bit_test_cluster::emit (tree index_expr, tree index_type, gsi = gsi_last_bb (m_case_bb); /* idx = (unsigned)x - minval. */ - idx = fold_convert (unsigned_index_type, index_expr); - idx = fold_build2 (MINUS_EXPR, unsigned_index_type, idx, - fold_convert (unsigned_index_type, minval)); + idx = fold_convert_loc (loc, unsigned_index_type, index_expr); + idx = fold_build2_loc (loc, MINUS_EXPR, unsigned_index_type, idx, + fold_convert_loc (loc, unsigned_index_type, minval)); idx = force_gimple_operand_gsi (&gsi, idx, /*simple=*/true, NULL_TREE, /*before=*/true, GSI_SAME_STMT); @@ -1589,17 +1589,17 @@ bit_test_cluster::emit (tree index_expr, tree index_type, fold_convert (unsigned_index_type, range), /*simple=*/true, NULL_TREE, /*before=*/true, GSI_SAME_STMT); - tmp = fold_build2 (GT_EXPR, boolean_type_node, idx, range); + tmp = fold_build2_loc (loc, GT_EXPR, boolean_type_node, idx, range); basic_block new_bb = hoist_edge_and_branch_if_true (&gsi, tmp, default_bb, - profile_probability::unlikely ()); + profile_probability::unlikely (), loc); gsi = gsi_last_bb (new_bb); } /* csui = (1 << (word_mode) idx) */ csui = make_ssa_name (word_type_node); - tmp = fold_build2 (LSHIFT_EXPR, word_type_node, word_mode_one, - fold_convert (word_type_node, idx)); + tmp = fold_build2_loc (loc, LSHIFT_EXPR, word_type_node, word_mode_one, + fold_convert_loc (loc, word_type_node, idx)); tmp = force_gimple_operand_gsi (&gsi, tmp, /*simple=*/false, NULL_TREE, /*before=*/true, GSI_SAME_STMT); @@ -1617,13 +1617,15 @@ bit_test_cluster::emit (tree index_expr, tree index_type, bt_range); bt_range -= test[k].bits; tmp = wide_int_to_tree (word_type_node, test[k].mask); - tmp = fold_build2 (BIT_AND_EXPR, word_type_node, csui, tmp); + tmp = fold_build2_loc (loc, BIT_AND_EXPR, word_type_node, csui, tmp); tmp = force_gimple_operand_gsi (&gsi, tmp, /*simple=*/true, NULL_TREE, /*before=*/true, GSI_SAME_STMT); - tmp = fold_build2 (NE_EXPR, boolean_type_node, tmp, word_mode_zero); + tmp = fold_build2_loc (loc, NE_EXPR, boolean_type_node, + tmp, word_mode_zero); basic_block new_bb - = hoist_edge_and_branch_if_true (&gsi, tmp, test[k].target_bb, prob); + = hoist_edge_and_branch_if_true (&gsi, tmp, test[k].target_bb, + prob, loc); gsi = gsi_last_bb (new_bb); } @@ -1653,7 +1655,8 @@ bit_test_cluster::emit (tree index_expr, tree index_type, basic_block bit_test_cluster::hoist_edge_and_branch_if_true (gimple_stmt_iterator *gsip, tree cond, basic_block case_bb, - profile_probability prob) + profile_probability prob, + location_t loc) { tree tmp; gcond *cond_stmt; @@ -1667,6 +1670,7 @@ bit_test_cluster::hoist_edge_and_branch_if_true (gimple_stmt_iterator *gsip, tmp = force_gimple_operand_gsi (gsip, cond, /*simple=*/true, NULL, /*before=*/true, GSI_SAME_STMT); cond_stmt = gimple_build_cond_from_tree (tmp, NULL_TREE, NULL_TREE); + gimple_set_location (cond_stmt, loc); gsi_insert_before (gsip, cond_stmt, GSI_SAME_STMT); e_false = split_block (split_bb, cond_stmt); diff --git a/gcc/tree-switch-conversion.h b/gcc/tree-switch-conversion.h index d8a2fbac1d7..e174b47e191 100644 --- a/gcc/tree-switch-conversion.h +++ b/gcc/tree-switch-conversion.h @@ -411,7 +411,8 @@ struct bit_test_cluster: public group_cluster static basic_block hoist_edge_and_branch_if_true (gimple_stmt_iterator *gsip, tree cond, basic_block case_bb, - profile_probability prob); + profile_probability prob, + location_t); /* True when the jump table handles an entire switch statement. */ bool m_handles_entire_switch;
reply other threads:[~2022-05-06 11:09 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220506110916.3AA60394FC11@sourceware.org \ --to=rguenth@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).