* [PATCH GCC 3/9]Support rewriting non-lcssa phis for vars live outside of vect-loop
@ 2016-09-06 18:51 Bin Cheng
2016-09-07 12:29 ` Jeff Law
0 siblings, 1 reply; 2+ messages in thread
From: Bin Cheng @ 2016-09-06 18:51 UTC (permalink / raw)
To: gcc-patches; +Cc: nd
[-- Attachment #1: Type: text/plain, Size: 523 bytes --]
Hi,
Current implementation requires that variables live outside of vect-loop satisfying LCSSA form, this patch relaxes the restriction. It keeps the old behavior for LCSSA PHI node by replacing use of live var with result of that PHI; for other uses of live var, it simply replaces all uses outside loop with the newly computed var.
Thanks,
bin
2016-09-01 Bin Cheng <bin.cheng@arm.com>
* tree-vect-loop.c (vectorizable_live_operation): Support handling
for live variable outside loop but not in lcssa form.
[-- Attachment #2: 003-handle-no-lcssaphi-in-vect_live-20160901.txt --]
[-- Type: text/plain, Size: 1784 bytes --]
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index fa06505..45e18af 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -6478,14 +6478,6 @@ vectorizable_live_operation (gimple *stmt,
: gimple_get_lhs (stmt);
lhs_type = TREE_TYPE (lhs);
- /* Find all uses of STMT outside the loop - there should be at least one. */
- auto_vec<gimple *, 4> worklist;
- FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, lhs)
- if (!flow_bb_inside_loop_p (loop, gimple_bb (use_stmt))
- && !is_gimple_debug (use_stmt))
- worklist.safe_push (use_stmt);
- gcc_assert (worklist.length () >= 1);
-
bitsize = TYPE_SIZE (TREE_TYPE (vectype));
vec_bitsize = TYPE_SIZE (vectype);
@@ -6536,12 +6528,24 @@ vectorizable_live_operation (gimple *stmt,
if (stmts)
gsi_insert_seq_on_edge_immediate (single_exit (loop), stmts);
- /* Replace all uses of the USE_STMT in the worklist with the newly inserted
- statement. */
- while (!worklist.is_empty ())
+ /* Replace use of lhs with newly computed result. If the use stmt is a
+ single arg PHI, just replace all uses of PHI result. It's necessary
+ because lcssa PHI defining lhs may be before newly inserted stmt. */
+ use_operand_p use_p;
+ FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, lhs)
+ if (!flow_bb_inside_loop_p (loop, gimple_bb (use_stmt))
+ && !is_gimple_debug (use_stmt))
{
- use_stmt = worklist.pop ();
- replace_uses_by (gimple_phi_result (use_stmt), new_tree);
+ if (gimple_code (use_stmt) == GIMPLE_PHI
+ && gimple_phi_num_args (use_stmt) == 1)
+ {
+ replace_uses_by (gimple_phi_result (use_stmt), new_tree);
+ }
+ else
+ {
+ FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
+ SET_USE (use_p, new_tree);
+ }
update_stmt (use_stmt);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH GCC 3/9]Support rewriting non-lcssa phis for vars live outside of vect-loop
2016-09-06 18:51 [PATCH GCC 3/9]Support rewriting non-lcssa phis for vars live outside of vect-loop Bin Cheng
@ 2016-09-07 12:29 ` Jeff Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2016-09-07 12:29 UTC (permalink / raw)
To: Bin Cheng, gcc-patches; +Cc: nd
On 09/06/2016 12:51 PM, Bin Cheng wrote:
> Hi,
> Current implementation requires that variables live outside of vect-loop satisfying LCSSA form, this patch relaxes the restriction. It keeps the old behavior for LCSSA PHI node by replacing use of live var with result of that PHI; for other uses of live var, it simply replaces all uses outside loop with the newly computed var.
>
> Thanks,
> bin
>
> 2016-09-01 Bin Cheng <bin.cheng@arm.com>
>
> * tree-vect-loop.c (vectorizable_live_operation): Support handling
> for live variable outside loop but not in lcssa form.
>
OK.
jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-09-07 12:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-06 18:51 [PATCH GCC 3/9]Support rewriting non-lcssa phis for vars live outside of vect-loop Bin Cheng
2016-09-07 12:29 ` Jeff Law
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).