Commit 520435ec by Bin Cheng Committed by Bin Cheng

tree-if-conv.c (any_pred_load_store): New static variable.

	* tree-if-conv.c (any_pred_load_store): New static variable.
	(if_convertible_gimple_assign_stmt_p): Remove parameter.  Use
	any_pred_load_store instead of and_mask_load_store.
	(if_convertible_stmt_p, if_convertible_loop_p_1): Ditto.
	(if_convertible_loop_p, insert_gimplified_predicates): Ditto.
	(combine_blocks, tree_if_conversion): Ditto.

From-SVN: r235437
parent 00f615af
2016-04-26 Bin Cheng <bin.cheng@arm.com> 2016-04-26 Bin Cheng <bin.cheng@arm.com>
* tree-if-conv.c (any_pred_load_store): New static variable.
(if_convertible_gimple_assign_stmt_p): Remove parameter. Use
any_pred_load_store instead of and_mask_load_store.
(if_convertible_stmt_p, if_convertible_loop_p_1): Ditto.
(if_convertible_loop_p, insert_gimplified_predicates): Ditto.
(combine_blocks, tree_if_conversion): Ditto.
2016-04-26 Bin Cheng <bin.cheng@arm.com>
PR tree-optimization/70771 PR tree-optimization/70771
PR tree-optimization/70775 PR tree-optimization/70775
* tree-if-conv.c (if_convertible_phi_p): Remove check on special * tree-if-conv.c (if_convertible_phi_p): Remove check on special
......
...@@ -113,6 +113,10 @@ along with GCC; see the file COPYING3. If not see ...@@ -113,6 +113,10 @@ along with GCC; see the file COPYING3. If not see
#include "varasm.h" #include "varasm.h"
#include "builtins.h" #include "builtins.h"
#include "params.h" #include "params.h"
/* Indicate if new load/store that needs to be predicated is introduced
during if conversion. */
static bool any_pred_load_store;
/* Hash for struct innermost_loop_behavior. It depends on the user to /* Hash for struct innermost_loop_behavior. It depends on the user to
free the memory. */ free the memory. */
...@@ -867,8 +871,7 @@ ifcvt_can_use_mask_load_store (gimple *stmt) ...@@ -867,8 +871,7 @@ ifcvt_can_use_mask_load_store (gimple *stmt)
static bool static bool
if_convertible_gimple_assign_stmt_p (gimple *stmt, if_convertible_gimple_assign_stmt_p (gimple *stmt,
vec<data_reference_p> refs, vec<data_reference_p> refs)
bool *any_mask_load_store)
{ {
tree lhs = gimple_assign_lhs (stmt); tree lhs = gimple_assign_lhs (stmt);
...@@ -906,7 +909,7 @@ if_convertible_gimple_assign_stmt_p (gimple *stmt, ...@@ -906,7 +909,7 @@ if_convertible_gimple_assign_stmt_p (gimple *stmt,
if (ifcvt_can_use_mask_load_store (stmt)) if (ifcvt_can_use_mask_load_store (stmt))
{ {
gimple_set_plf (stmt, GF_PLF_2, true); gimple_set_plf (stmt, GF_PLF_2, true);
*any_mask_load_store = true; any_pred_load_store = true;
return true; return true;
} }
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
...@@ -917,7 +920,7 @@ if_convertible_gimple_assign_stmt_p (gimple *stmt, ...@@ -917,7 +920,7 @@ if_convertible_gimple_assign_stmt_p (gimple *stmt,
/* When if-converting stores force versioning, likewise if we /* When if-converting stores force versioning, likewise if we
ended up generating store data races. */ ended up generating store data races. */
if (gimple_vdef (stmt)) if (gimple_vdef (stmt))
*any_mask_load_store = true; any_pred_load_store = true;
return true; return true;
} }
...@@ -930,8 +933,7 @@ if_convertible_gimple_assign_stmt_p (gimple *stmt, ...@@ -930,8 +933,7 @@ if_convertible_gimple_assign_stmt_p (gimple *stmt,
- it is builtins call. */ - it is builtins call. */
static bool static bool
if_convertible_stmt_p (gimple *stmt, vec<data_reference_p> refs, if_convertible_stmt_p (gimple *stmt, vec<data_reference_p> refs)
bool *any_mask_load_store)
{ {
switch (gimple_code (stmt)) switch (gimple_code (stmt))
{ {
...@@ -941,8 +943,7 @@ if_convertible_stmt_p (gimple *stmt, vec<data_reference_p> refs, ...@@ -941,8 +943,7 @@ if_convertible_stmt_p (gimple *stmt, vec<data_reference_p> refs,
return true; return true;
case GIMPLE_ASSIGN: case GIMPLE_ASSIGN:
return if_convertible_gimple_assign_stmt_p (stmt, refs, return if_convertible_gimple_assign_stmt_p (stmt, refs);
any_mask_load_store);
case GIMPLE_CALL: case GIMPLE_CALL:
{ {
...@@ -1248,9 +1249,7 @@ predicate_bbs (loop_p loop) ...@@ -1248,9 +1249,7 @@ predicate_bbs (loop_p loop)
in if_convertible_loop_p. */ in if_convertible_loop_p. */
static bool static bool
if_convertible_loop_p_1 (struct loop *loop, if_convertible_loop_p_1 (struct loop *loop, vec<data_reference_p> *refs)
vec<data_reference_p> *refs,
bool *any_mask_load_store)
{ {
unsigned int i; unsigned int i;
basic_block exit_bb = NULL; basic_block exit_bb = NULL;
...@@ -1354,8 +1353,7 @@ if_convertible_loop_p_1 (struct loop *loop, ...@@ -1354,8 +1353,7 @@ if_convertible_loop_p_1 (struct loop *loop,
/* Check the if-convertibility of statements in predicated BBs. */ /* Check the if-convertibility of statements in predicated BBs. */
if (!dominated_by_p (CDI_DOMINATORS, loop->latch, bb)) if (!dominated_by_p (CDI_DOMINATORS, loop->latch, bb))
for (itr = gsi_start_bb (bb); !gsi_end_p (itr); gsi_next (&itr)) for (itr = gsi_start_bb (bb); !gsi_end_p (itr); gsi_next (&itr))
if (!if_convertible_stmt_p (gsi_stmt (itr), *refs, if (!if_convertible_stmt_p (gsi_stmt (itr), *refs))
any_mask_load_store))
return false; return false;
} }
...@@ -1389,7 +1387,7 @@ if_convertible_loop_p_1 (struct loop *loop, ...@@ -1389,7 +1387,7 @@ if_convertible_loop_p_1 (struct loop *loop,
- if its basic blocks and phi nodes are if convertible. */ - if its basic blocks and phi nodes are if convertible. */
static bool static bool
if_convertible_loop_p (struct loop *loop, bool *any_mask_load_store) if_convertible_loop_p (struct loop *loop)
{ {
edge e; edge e;
edge_iterator ei; edge_iterator ei;
...@@ -1427,7 +1425,7 @@ if_convertible_loop_p (struct loop *loop, bool *any_mask_load_store) ...@@ -1427,7 +1425,7 @@ if_convertible_loop_p (struct loop *loop, bool *any_mask_load_store)
return false; return false;
refs.create (5); refs.create (5);
res = if_convertible_loop_p_1 (loop, &refs, any_mask_load_store); res = if_convertible_loop_p_1 (loop, &refs);
data_reference_p dr; data_reference_p dr;
unsigned int i; unsigned int i;
...@@ -1896,7 +1894,7 @@ predicate_all_scalar_phis (struct loop *loop) ...@@ -1896,7 +1894,7 @@ predicate_all_scalar_phis (struct loop *loop)
gimplification of the predicates. */ gimplification of the predicates. */
static void static void
insert_gimplified_predicates (loop_p loop, bool any_mask_load_store) insert_gimplified_predicates (loop_p loop)
{ {
unsigned int i; unsigned int i;
...@@ -1918,7 +1916,7 @@ insert_gimplified_predicates (loop_p loop, bool any_mask_load_store) ...@@ -1918,7 +1916,7 @@ insert_gimplified_predicates (loop_p loop, bool any_mask_load_store)
stmts = bb_predicate_gimplified_stmts (bb); stmts = bb_predicate_gimplified_stmts (bb);
if (stmts) if (stmts)
{ {
if (any_mask_load_store) if (any_pred_load_store)
{ {
/* Insert the predicate of the BB just after the label, /* Insert the predicate of the BB just after the label,
as the if-conversion of memory writes will use this as the if-conversion of memory writes will use this
...@@ -2228,7 +2226,7 @@ remove_conditions_and_labels (loop_p loop) ...@@ -2228,7 +2226,7 @@ remove_conditions_and_labels (loop_p loop)
blocks. Replace PHI nodes with conditional modify expressions. */ blocks. Replace PHI nodes with conditional modify expressions. */
static void static void
combine_blocks (struct loop *loop, bool any_mask_load_store) combine_blocks (struct loop *loop)
{ {
basic_block bb, exit_bb, merge_target_bb; basic_block bb, exit_bb, merge_target_bb;
unsigned int orig_loop_num_nodes = loop->num_nodes; unsigned int orig_loop_num_nodes = loop->num_nodes;
...@@ -2238,10 +2236,10 @@ combine_blocks (struct loop *loop, bool any_mask_load_store) ...@@ -2238,10 +2236,10 @@ combine_blocks (struct loop *loop, bool any_mask_load_store)
predicate_bbs (loop); predicate_bbs (loop);
remove_conditions_and_labels (loop); remove_conditions_and_labels (loop);
insert_gimplified_predicates (loop, any_mask_load_store); insert_gimplified_predicates (loop);
predicate_all_scalar_phis (loop); predicate_all_scalar_phis (loop);
if (any_mask_load_store) if (any_pred_load_store)
predicate_mem_writes (loop); predicate_mem_writes (loop);
/* Merge basic blocks: first remove all the edges in the loop, /* Merge basic blocks: first remove all the edges in the loop,
...@@ -2716,7 +2714,7 @@ tree_if_conversion (struct loop *loop) ...@@ -2716,7 +2714,7 @@ tree_if_conversion (struct loop *loop)
{ {
unsigned int todo = 0; unsigned int todo = 0;
ifc_bbs = NULL; ifc_bbs = NULL;
bool any_mask_load_store = false; any_pred_load_store = false;
/* Set up aggressive if-conversion for loops marked with simd pragma. */ /* Set up aggressive if-conversion for loops marked with simd pragma. */
aggressive_if_conv = loop->force_vectorize; aggressive_if_conv = loop->force_vectorize;
...@@ -2732,22 +2730,22 @@ tree_if_conversion (struct loop *loop) ...@@ -2732,22 +2730,22 @@ tree_if_conversion (struct loop *loop)
if (!ifcvt_split_critical_edges (loop)) if (!ifcvt_split_critical_edges (loop))
goto cleanup; goto cleanup;
if (!if_convertible_loop_p (loop, &any_mask_load_store) if (!if_convertible_loop_p (loop)
|| !dbg_cnt (if_conversion_tree)) || !dbg_cnt (if_conversion_tree))
goto cleanup; goto cleanup;
if (any_mask_load_store if (any_pred_load_store
&& ((!flag_tree_loop_vectorize && !loop->force_vectorize) && ((!flag_tree_loop_vectorize && !loop->force_vectorize)
|| loop->dont_vectorize)) || loop->dont_vectorize))
goto cleanup; goto cleanup;
if (any_mask_load_store && !version_loop_for_if_conversion (loop)) if (any_pred_load_store && !version_loop_for_if_conversion (loop))
goto cleanup; goto cleanup;
/* Now all statements are if-convertible. Combine all the basic /* Now all statements are if-convertible. Combine all the basic
blocks into one huge basic block doing the if-conversion blocks into one huge basic block doing the if-conversion
on-the-fly. */ on-the-fly. */
combine_blocks (loop, any_mask_load_store); combine_blocks (loop);
/* Delete dead predicate computations and repair tree correspondent /* Delete dead predicate computations and repair tree correspondent
to bool pattern to delete multiple uses of predicates. */ to bool pattern to delete multiple uses of predicates. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment