From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2066) id C0E033988030; Wed, 9 Jun 2021 04:55:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C0E033988030 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Jiu Fu Guo To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/guojiufu/heads/personal-branch)] find previous does not update idx type in real. X-Act-Checkin: gcc X-Git-Author: Jiufu Guo X-Git-Refname: refs/users/guojiufu/heads/personal-branch X-Git-Oldrev: 87a45055059fa44401d9cc7a11f20130c12394d3 X-Git-Newrev: 1efb69362eb63d864c324a5f2b42ef029544c494 Message-Id: <20210609045528.C0E033988030@sourceware.org> Date: Wed, 9 Jun 2021 04:55:27 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jun 2021 04:55:28 -0000 https://gcc.gnu.org/g:1efb69362eb63d864c324a5f2b42ef029544c494 commit 1efb69362eb63d864c324a5f2b42ef029544c494 Author: Jiufu Guo Date: Wed Jun 9 10:54:28 2021 +0800 find previous does not update idx type in real. Diff: --- gcc/tree-ssa-loop-split.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/gcc/tree-ssa-loop-split.c b/gcc/tree-ssa-loop-split.c index c2c10bdbf37..3d9cd2e4cc3 100644 --- a/gcc/tree-ssa-loop-split.c +++ b/gcc/tree-ssa-loop-split.c @@ -1824,22 +1824,24 @@ get_wrap_assumption (class loop *loop, edge *exit, idx_elements &data) return NULL_TREE; } -/* Update the idx and bnd with faster type for no wrap/oveflow loop. */ +/* Update the idx and bnd with a suitable type for no wrap/oveflow loop. + Suitable type would be the largest type of the type conversion which + occur on index, if the largest type is unsigned, using sizetype. */ static bool update_idx_bnd_type (class loop *loop, idx_elements &data) { - return false; - /* Use sizetype as machine fast type, ok for most targets? */ - tree fast_type = sizetype; + tree suitable_type = data.large_type; + if (TYPE_UNSIGNED (suitable_type)) + suitable_type = sizetype; /* New base and new bound. */ gphi *phi = data.phi; tree bnd = data.bnd; edge pre_e = loop_preheader_edge (loop); tree base = PHI_ARG_DEF_FROM_EDGE (phi, pre_e); - tree new_base = fold_convert (fast_type, base); - tree new_bnd = fold_convert (fast_type, bnd); + tree new_base = fold_convert (suitable_type, base); + tree new_bnd = fold_convert (suitable_type, bnd); gimple_seq seq = NULL; new_base = force_gimple_operand (new_base, &seq, true, NULL_TREE); if (seq) @@ -1853,8 +1855,8 @@ update_idx_bnd_type (class loop *loop, idx_elements &data) new_n = new_i + 1 */ edge latch_e = loop_latch_edge (loop); const char *name = "idx"; - tree new_idx = make_temp_ssa_name (fast_type, NULL, name); - tree new_next = make_temp_ssa_name (fast_type, NULL, name); + tree new_idx = make_temp_ssa_name (suitable_type, NULL, name); + tree new_next = make_temp_ssa_name (suitable_type, NULL, name); gphi *newphi = create_phi_node (new_idx, loop->header); add_phi_arg (newphi, new_base, pre_e, UNKNOWN_LOCATION); add_phi_arg (newphi, new_next, latch_e, UNKNOWN_LOCATION); @@ -1862,7 +1864,7 @@ update_idx_bnd_type (class loop *loop, idx_elements &data) /* New increase stmt. */ gimple *inc_stmt = data.inc_stmt; tree step = gimple_assign_rhs2 (inc_stmt); - step = fold_convert (fast_type, step); + step = fold_convert (suitable_type, step); new_idx = PHI_RESULT (newphi); tree_code inc_code = gimple_assign_rhs_code (inc_stmt); gimple *new_inc = gimple_build_assign (new_next, inc_code, new_idx, step); @@ -2014,7 +2016,7 @@ split_loop_on_wrap (class loop *loop) free (bbs); if (integer_onep (no_wrap_assumption) - || split_wrap_boundary (loop, e, no_wrap_assumption))) + || split_wrap_boundary (loop, e, no_wrap_assumption)) { update_idx_bnd_type (loop, data); return true;