From patchwork Mon Mar 28 09:33:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 52399 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CF7E1385E446 for ; Mon, 28 Mar 2022 09:33:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CF7E1385E446 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1648460037; bh=1ekf+70bUk4eC2uYU7vDNSjiWYDT05RrPyx1blSxpj8=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=NZfCc+W6Joo+NGIhd8oBLwRwlLA2aQEIeiPVrPkri3h59/sadE0Q6t2QqdYVIvhj3 cdhFdGQGyJaafmz4CrdSx1f6+/gpURVj/9uYJMfZ6JeIU0+rRxzo1090WjpsrLL7Dq dZWtenegT7nIFpC2aY6qxXGKCpLj/RP428ghlcEY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 9B2CB3858C56 for ; Mon, 28 Mar 2022 09:33:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9B2CB3858C56 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7656A210DC for ; Mon, 28 Mar 2022 09:33:26 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5851B13B08 for ; Mon, 28 Mar 2022 09:33:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id NeRsFOaAQWIxLAAAMHmgww (envelope-from ) for ; Mon, 28 Mar 2022 09:33:26 +0000 Date: Mon, 28 Mar 2022 11:33:26 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/105070 - annotate bit cluster tests with locations MIME-Version: 1.0 Message-Id: <20220328093326.5851B13B08@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed to trunk sofar. 2022-03-28 Richard Biener PR tree-optimization/105070 * tree-switch-conversion.h (bit_test_cluster::hoist_edge_and_branch_if_true): Add location argument. * tree-switch-covnversion.cc (bit_test_cluster::hoist_edge_and_branch_if_true): Annotate cond with location. (bit_test_cluster::emit): Annotate all generated expressions with location. --- gcc/tree-switch-conversion.cc | 28 ++++++++++++++++------------ gcc/tree-switch-conversion.h | 3 ++- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/gcc/tree-switch-conversion.cc b/gcc/tree-switch-conversion.cc index 670397c87e4..e14b4e6c94a 100644 --- a/gcc/tree-switch-conversion.cc +++ b/gcc/tree-switch-conversion.cc @@ -1498,7 +1498,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) { case_bit_test test[m_max_case_bit_tests] = { {} }; unsigned int i, j, k; @@ -1622,9 +1622,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); @@ -1638,15 +1638,15 @@ 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); } - 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)); /* csui = (1 << (word_mode) idx) */ if (count > 1) @@ -1672,13 +1672,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 (NE_EXPR, boolean_type_node, tmp, word_mode_zero); + tmp = fold_build2_loc (loc, BIT_AND_EXPR, word_type_node, csui, tmp); + tmp = fold_build2_loc (loc, NE_EXPR, boolean_type_node, + tmp, word_mode_zero); tmp = force_gimple_operand_gsi (&gsi, tmp, /*simple=*/true, NULL_TREE, /*before=*/true, GSI_SAME_STMT); 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); } @@ -1708,7 +1710,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; @@ -1722,6 +1725,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 e969c051a05..2b677d9f7e9 100644 --- a/gcc/tree-switch-conversion.h +++ b/gcc/tree-switch-conversion.h @@ -429,7 +429,8 @@ public: 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); /* Return whether bit test expansion is allowed. */ static inline bool is_enabled (void)