public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/guojiufu/heads/personal-branch)] Pass bootstrap-O3 and regtest
@ 2021-06-09 4:55 Jiu Fu Guo
0 siblings, 0 replies; only message in thread
From: Jiu Fu Guo @ 2021-06-09 4:55 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:2caa0d6f3c759b6c5507093e09fff188cb7b9bfd
commit 2caa0d6f3c759b6c5507093e09fff188cb7b9bfd
Author: Jiufu Guo <guojiufu@linux.ibm.com>
Date: Wed Jun 9 10:25:02 2021 +0800
Pass bootstrap-O3 and regtest
Diff:
---
gcc/tree-ssa-loop-split.c | 89 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 86 insertions(+), 3 deletions(-)
diff --git a/gcc/tree-ssa-loop-split.c b/gcc/tree-ssa-loop-split.c
index abc81a6144c..ccde6bb24a7 100644
--- a/gcc/tree-ssa-loop-split.c
+++ b/gcc/tree-ssa-loop-split.c
@@ -1778,7 +1778,7 @@ get_wrap_assumption (class loop *loop, edge *exit, idx_elements &data)
code = swap_tree_comparison (code);
if ((e->flags & EDGE_TRUE_VALUE) && code == EQ_EXPR)
code = NE_EXPR;
- if (code != NE_EXPR && code != LT_EXPR)
+ if (code != NE_EXPR && code != LT_EXPR && code != LE_EXPR)
continue;
/* Check if idx is iv with base and step. */
@@ -1823,6 +1823,84 @@ 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. */
+
+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;
+
+ /* 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);
+ gimple_seq seq = NULL;
+ new_base = force_gimple_operand (new_base, &seq, true, NULL_TREE);
+ if (seq)
+ gsi_insert_seq_on_edge_immediate (pre_e, seq);
+ seq = NULL;
+ new_bnd = force_gimple_operand (new_bnd, &seq, true, NULL_TREE);
+ if (seq)
+ gsi_insert_seq_on_edge_immediate (pre_e, seq);
+
+ /* new_i = phi (new_b, new_n)
+ 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);
+ 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);
+
+ /* New increase stmt. */
+ gimple *inc_stmt = data.inc_stmt;
+ tree step = gimple_assign_rhs2 (inc_stmt);
+ step = fold_convert (fast_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);
+ gimple_stmt_iterator gsi = gsi_for_stmt (inc_stmt);
+ gsi_insert_before (&gsi, new_inc, GSI_SAME_STMT);
+
+ /* Update gcond. */
+ gcond *gc = data.gc;
+ bool inv = bnd == gimple_cond_lhs (gc);
+ tree cmp_idx = data.cmp_on_next ? new_next : new_idx;
+ gimple_cond_set_lhs (gc, inv ? new_bnd : cmp_idx);
+ gimple_cond_set_rhs (gc, inv ? cmp_idx : new_bnd);
+ update_stmt (gc);
+
+ /* next = (next type)new_next
+ And remove next = prev + 1. */
+ tree next = data.next;
+ tree type = TREE_TYPE (next);
+ gimple *stmt = gimple_build_assign (next, fold_convert (type, new_next));
+ gsi = gsi_for_stmt (inc_stmt);
+ gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
+
+ gsi = gsi_for_stmt (inc_stmt);
+ gsi_remove (&gsi, true);
+
+ /* prev = (prev type)new_prev
+ And remove prev = phi. */
+ tree idx = PHI_RESULT (phi);
+ type = TREE_TYPE (idx);
+ stmt = gimple_build_assign (idx, fold_convert (type, new_idx));
+ gsi = gsi_start_bb (loop->header);
+ gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
+
+ gsi = gsi_for_stmt (phi);
+ gsi_remove (&gsi, true);
+
+ return true;
+}
+
/* Split out a new loop which would not wrap,
under the guard that NO_WRAP_COND will not be true. */
@@ -1925,8 +2003,13 @@ split_loop_on_wrap (class loop *loop)
idx_elements data;
tree no_wrap_assumption = get_wrap_assumption (loop, &e, data);
- if (no_wrap_assumption && split_wrap_boundary (loop, e, no_wrap_assumption))
- return true;
+ if (no_wrap_assumption
+ && (integer_onep (no_wrap_assumption)
+ || split_wrap_boundary (loop, e, no_wrap_assumption)))
+ {
+ update_idx_bnd_type (loop, data);
+ return true;
+ }
return false;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-06-09 4:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 4:55 [gcc(refs/users/guojiufu/heads/personal-branch)] Pass bootstrap-O3 and regtest Jiu Fu Guo
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).