From e2184908ab230ea978f69c68d1ee00a1ab47302b Mon Sep 17 00:00:00 2001 From: Sameera Deshpande Date: Mon, 18 Jul 2016 13:05:34 +0530 Subject: [PATCH] Misc changes - accumulate probable root nodes for the loop in ITER_node. From-SVN: r238425 --- gcc/tree-vect-unified.c | 27 ++++++++++++++++----------- gcc/tree-vect-unified.h | 6 ++++++ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/gcc/tree-vect-unified.c b/gcc/tree-vect-unified.c index 2014f319c9e4..8b6acd67db1c 100644 --- a/gcc/tree-vect-unified.c +++ b/gcc/tree-vect-unified.c @@ -129,6 +129,7 @@ new_iter_node (struct loop *loop) ITER_NODE_PEELING_FOR_GAPS (res) = false; ITER_NODE_PEELING_FOR_NITER (res) = false; ITER_NODE_EPILOGUE (res) = vNULL; + ITER_NODE_PROBABLE_ROOT_NODES (res) = vNULL; bbs = get_loop_body (loop); @@ -170,6 +171,8 @@ destroy_iter_node_info (struct ITER_node *inode) ITER_NODE_LOOP_BODY (inode).release (); if (ITER_NODE_EPILOGUE (inode) != vNULL) ITER_NODE_EPILOGUE (inode).release (); + if (ITER_NODE_PROBABLE_ROOT_NODES (inode) != vNULL) + ITER_NODE_PROBABLE_ROOT_NODES (inode).release (); bbs = get_loop_body (ITER_NODE_LOOP (inode)); for (i = 0; i < ITER_NODE_LOOP (inode)->num_nodes; i++) @@ -1145,7 +1148,7 @@ classify_loop_stmt (gimple *stmt, struct loop * loop) */ static bool -classify_loop_stmts (struct ITER_node *inode, vec *probable_roots) +classify_loop_stmts (struct ITER_node *inode) { basic_block *bbs; int nbbs; @@ -1160,7 +1163,7 @@ classify_loop_stmts (struct ITER_node *inode, vec *probable_roots) "==== classify_loop_stmts ====\n"); } - /* Mark phi node*/ + /* Mark phi node. */ for (gphi_iterator si = gsi_start_phis (loop->header); !gsi_end_p (si); gsi_next (&si)) { @@ -1247,7 +1250,8 @@ classify_loop_stmts (struct ITER_node *inode, vec *probable_roots) } #endif - worklist = (*probable_roots).copy (); + worklist = ITER_NODE_PROBABLE_ROOT_NODES (inode).copy (); + while (worklist.length () > 0) { gimple *stmt = worklist.pop (); @@ -1280,8 +1284,7 @@ classify_loop_stmts (struct ITER_node *inode, vec *probable_roots) */ static void -mark_probable_root_nodes (struct ITER_node *inode, - vec *probable_roots) +mark_probable_root_nodes (struct ITER_node *inode) { int i; gimple *stmt; @@ -1316,7 +1319,7 @@ mark_probable_root_nodes (struct ITER_node *inode, if (dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, " : Memory def.\n"); - probable_roots->safe_push (stmt); + ITER_NODE_PROBABLE_ROOT_NODES (inode).safe_push (stmt); STMT_ATTR_PROOT (stmt) = true; } @@ -1340,7 +1343,7 @@ mark_probable_root_nodes (struct ITER_node *inode, gcc_assert (gimple_code (USE_STMT (use_p)) == GIMPLE_PHI); gcc_assert (bb == single_exit (loop)->dest); - probable_roots->safe_push (stmt); + ITER_NODE_PROBABLE_ROOT_NODES (inode).safe_push (stmt); STMT_ATTR_PROOT (stmt) = true; } } @@ -1808,7 +1811,7 @@ vectorizable_store (gimple *stmt, struct ITER_node *inode, pnode = create_primTree_memref (base, step, false, num, inode, NULL); ITER_NODE_LOOP_BODY (inode).safe_push (pnode); pchild1 = create_primTree_combine (POP_ILV, stmt, - tree_to_uhwi (step) / num, inode, parent); + tree_to_uhwi (step) / num, inode, pnode); add_child_at_index (pnode, pchild1, 0); } else @@ -2067,16 +2070,16 @@ create_ptree (struct ITER_node *inode) auto_vec worklist; bool is_ok; - mark_probable_root_nodes (inode, &worklist); + mark_probable_root_nodes (inode); - if (worklist.length () == 0) + if (ITER_NODE_PROBABLE_ROOT_NODES (inode).length () == 0) { dump_printf (MSG_MISSED_OPTIMIZATION, "Not vectorizable: no probable root nodes.\n"); return false; } - is_ok = classify_loop_stmts (inode, &worklist); + is_ok = classify_loop_stmts (inode); if (! is_ok) { dump_printf (MSG_MISSED_OPTIMIZATION, @@ -2084,6 +2087,8 @@ create_ptree (struct ITER_node *inode) return false; } + worklist = ITER_NODE_PROBABLE_ROOT_NODES (inode).copy (); + while (worklist.length () > 0) { is_ok = (analyze_and_create_ptree (NULL, worklist.pop (), inode) != NULL); diff --git a/gcc/tree-vect-unified.h b/gcc/tree-vect-unified.h index 95cb8a4bacce..df493341f4aa 100644 --- a/gcc/tree-vect-unified.h +++ b/gcc/tree-vect-unified.h @@ -72,6 +72,11 @@ struct ITER_node { /* All data dependences within the loop. */ vec ddrs; + + /* List of all statements within the loop which have side effects beyond loop + body. probable root nodes are accumulated for loop by + mark_probable_root_nodes. */ + vec probable_roots; }; #define ITER_NODE_NITERS(x) (x)->num_iter @@ -86,6 +91,7 @@ struct ITER_node { #define ITER_NODE_PEELING_FOR_NITER(x) (x)->peeling_for_niter #define ITER_NODE_DATA_REFS(x) (x)->datarefs #define ITER_NODE_DATA_DEPS(x) (x)->ddrs +#define ITER_NODE_PROBABLE_ROOT_NODES(x) (x)->probable_roots enum stmt_use_type { stmt_use_type_undef, -- 2.47.2