Commit b6779d81 by Sebastian Pop Committed by Sebastian Pop

Fix comments in ifconvert.

2010-04-07  Sebastian Pop  <sebastian.pop@amd.com>

	* tree-if-conv.c: Fix indentation and comments.

From-SVN: r158039
parent bdd277f3
2010-04-07 Sebastian Pop <sebastian.pop@amd.com>
* tree-if-conv.c: Fix indentation and comments.
2010-04-06 Sebastian Pop <sebastian.pop@amd.com> 2010-04-06 Sebastian Pop <sebastian.pop@amd.com>
PR middle-end/43519 PR middle-end/43519
......
...@@ -134,12 +134,12 @@ static bool bb_with_exit_edge_p (struct loop *, basic_block); ...@@ -134,12 +134,12 @@ static bool bb_with_exit_edge_p (struct loop *, basic_block);
/* List of basic blocks in if-conversion-suitable order. */ /* List of basic blocks in if-conversion-suitable order. */
static basic_block *ifc_bbs; static basic_block *ifc_bbs;
/* Main entry point. /* Main entry point. Apply if-conversion to the LOOP. Return true if
Apply if-conversion to the LOOP. Return true if successful otherwise return successful otherwise return false. If false is returned then loop
false. If false is returned then loop remains unchanged. remains unchanged. FOR_VECTORIZER is a boolean flag. It indicates
FOR_VECTORIZER is a boolean flag. It indicates whether if-conversion is used whether if-conversion is used for vectorizer or not. If it is used
for vectorizer or not. If it is used for vectorizer, additional checks are for vectorizer, additional checks are used. (Vectorization checks
used. (Vectorization checks are not yet implemented). */ are not yet implemented). */
static bool static bool
tree_if_conversion (struct loop *loop, bool for_vectorizer) tree_if_conversion (struct loop *loop, bool for_vectorizer)
...@@ -150,8 +150,8 @@ tree_if_conversion (struct loop *loop, bool for_vectorizer) ...@@ -150,8 +150,8 @@ tree_if_conversion (struct loop *loop, bool for_vectorizer)
ifc_bbs = NULL; ifc_bbs = NULL;
/* if-conversion is not appropriate for all loops. First, check if loop is /* If-conversion is not appropriate for all loops. First, check if
if-convertible or not. */ loop is if-convertible or not. */
if (!if_convertible_loop_p (loop, for_vectorizer)) if (!if_convertible_loop_p (loop, for_vectorizer))
{ {
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
...@@ -215,7 +215,7 @@ tree_if_conversion (struct loop *loop, bool for_vectorizer) ...@@ -215,7 +215,7 @@ tree_if_conversion (struct loop *loop, bool for_vectorizer)
return true; return true;
} }
/* if-convert stmt T which is part of LOOP. /* If-convert stmt T which is part of LOOP.
If T is a GIMPLE_ASSIGN then it is converted into conditional modify If T is a GIMPLE_ASSIGN then it is converted into conditional modify
expression using COND. For conditional expressions, add condition in the expression using COND. For conditional expressions, add condition in the
destination basic block's predicate list and remove conditional destination basic block's predicate list and remove conditional
...@@ -253,7 +253,7 @@ tree_if_convert_stmt (struct loop * loop, gimple t, tree cond, ...@@ -253,7 +253,7 @@ tree_if_convert_stmt (struct loop * loop, gimple t, tree cond,
value will be selected by PHI node based on condition. It is possible value will be selected by PHI node based on condition. It is possible
that before this transformation, PHI nodes was selecting default that before this transformation, PHI nodes was selecting default
value and now it will use this new value. This is OK because it does value and now it will use this new value. This is OK because it does
not change validity the program. */ not change the validity of the program. */
break; break;
case GIMPLE_COND: case GIMPLE_COND:
...@@ -292,10 +292,10 @@ tree_if_convert_cond_stmt (struct loop *loop, gimple stmt, tree cond, ...@@ -292,10 +292,10 @@ tree_if_convert_cond_stmt (struct loop *loop, gimple stmt, tree cond,
/* Add new condition into destination's predicate list. */ /* Add new condition into destination's predicate list. */
/* If C is true then TRUE_EDGE is taken. */ /* If C is true, then TRUE_EDGE is taken. */
add_to_dst_predicate_list (loop, true_edge, cond, c, gsi); add_to_dst_predicate_list (loop, true_edge, cond, c, gsi);
/* If 'c' is false then FALSE_EDGE is taken. */ /* If C is false, then FALSE_EDGE is taken. */
c2 = invert_truthvalue_loc (loc, unshare_expr (c)); c2 = invert_truthvalue_loc (loc, unshare_expr (c));
add_to_dst_predicate_list (loop, false_edge, cond, c2, gsi); add_to_dst_predicate_list (loop, false_edge, cond, c2, gsi);
...@@ -313,9 +313,9 @@ tree_if_convert_cond_stmt (struct loop *loop, gimple stmt, tree cond, ...@@ -313,9 +313,9 @@ tree_if_convert_cond_stmt (struct loop *loop, gimple stmt, tree cond,
/* Return true, iff PHI is if-convertible. PHI is part of loop LOOP /* Return true, iff PHI is if-convertible. PHI is part of loop LOOP
and it belongs to basic block BB. and it belongs to basic block BB.
PHI is not if-convertible PHI is not if-convertible
- if it has more than 2 arguments. - if it has more than 2 arguments,
- Virtual PHI is immediately used in another PHI node. - virtual PHI is immediately used in another PHI node,
- Virtual PHI on BB other than header. */ - virtual PHI on BB other than header. */
static bool static bool
if_convertible_phi_p (struct loop *loop, basic_block bb, gimple phi) if_convertible_phi_p (struct loop *loop, basic_block bb, gimple phi)
...@@ -360,8 +360,8 @@ if_convertible_phi_p (struct loop *loop, basic_block bb, gimple phi) ...@@ -360,8 +360,8 @@ if_convertible_phi_p (struct loop *loop, basic_block bb, gimple phi)
/* Return true, if STMT is if-convertible. /* Return true, if STMT is if-convertible.
GIMPLE_ASSIGN statement is not if-convertible if, GIMPLE_ASSIGN statement is not if-convertible if,
- It is not movable. - it is not movable,
- It could trap. - it could trap,
- LHS is not var decl. - LHS is not var decl.
GIMPLE_ASSIGN is part of block BB, which is inside loop LOOP. */ GIMPLE_ASSIGN is part of block BB, which is inside loop LOOP. */
...@@ -420,8 +420,8 @@ if_convertible_gimple_assign_stmt_p (struct loop *loop, basic_block bb, ...@@ -420,8 +420,8 @@ if_convertible_gimple_assign_stmt_p (struct loop *loop, basic_block bb,
/* Return true, iff STMT is if-convertible. /* Return true, iff STMT is if-convertible.
Statement is if-convertible if, Statement is if-convertible if,
- It is if-convertible GIMPLE_ASSGIN - it is if-convertible GIMPLE_ASSGIN,
- It is GIMPLE_LABEL or GIMPLE_COND. - it is GIMPLE_LABEL or GIMPLE_COND.
STMT is inside block BB, which is inside loop LOOP. */ STMT is inside block BB, which is inside loop LOOP. */
static bool static bool
...@@ -459,10 +459,10 @@ if_convertible_stmt_p (struct loop *loop, basic_block bb, gimple stmt) ...@@ -459,10 +459,10 @@ if_convertible_stmt_p (struct loop *loop, basic_block bb, gimple stmt)
/* Return true, iff BB is if-convertible. /* Return true, iff BB is if-convertible.
Note: This routine does _not_ check basic block statements and phis. Note: This routine does _not_ check basic block statements and phis.
Basic block is not if-convertible if, Basic block is not if-convertible if:
- Basic block is non-empty and it is after exit block (in BFS order). - basic block is non-empty and it is after exit block (in BFS order),
- Basic block is after exit block but before latch. - basic block is after exit block but before latch,
- Basic block edge(s) is not normal. - basic block edge(s) is not normal.
EXIT_BB_SEEN is true if basic block with exit edge is already seen. EXIT_BB_SEEN is true if basic block with exit edge is already seen.
BB is inside loop LOOP. */ BB is inside loop LOOP. */
...@@ -513,15 +513,16 @@ if_convertible_bb_p (struct loop *loop, basic_block bb, basic_block exit_bb) ...@@ -513,15 +513,16 @@ if_convertible_bb_p (struct loop *loop, basic_block bb, basic_block exit_bb)
} }
/* Return true, iff LOOP is if-convertible. /* Return true, iff LOOP is if-convertible.
LOOP is if-convertible if, LOOP is if-convertible if:
- It is innermost. - it is innermost,
- It has two or more basic blocks. - it has two or more basic blocks,
- It has only one exit. - it has only one exit,
- Loop header is not the exit edge. - loop header is not the exit edge,
- If its basic blocks and phi nodes are if convertible. See above for - if its basic blocks and phi nodes are if convertible. See above for
more info. more info.
FOR_VECTORIZER enables vectorizer specific checks. For example, support FOR_VECTORIZER enables vectorizer specific checks, for example, support
for vector conditions, data dependency checks etc.. (Not implemented yet). */ for vector conditions, data dependency checks, etc.
(Not implemented yet). */
static bool static bool
if_convertible_loop_p (struct loop *loop, bool for_vectorizer ATTRIBUTE_UNUSED) if_convertible_loop_p (struct loop *loop, bool for_vectorizer ATTRIBUTE_UNUSED)
...@@ -587,21 +588,16 @@ if_convertible_loop_p (struct loop *loop, bool for_vectorizer ATTRIBUTE_UNUSED) ...@@ -587,21 +588,16 @@ if_convertible_loop_p (struct loop *loop, bool for_vectorizer ATTRIBUTE_UNUSED)
if (!if_convertible_bb_p (loop, bb, exit_bb)) if (!if_convertible_bb_p (loop, bb, exit_bb))
return false; return false;
/* Check statements. */
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 (loop, bb, gsi_stmt (itr))) if (!if_convertible_stmt_p (loop, bb, gsi_stmt (itr)))
return false; return false;
/* ??? Check data dependency for vectorizer. */
/* What about phi nodes ? */
itr = gsi_start_phis (bb); itr = gsi_start_phis (bb);
/* Clear aux field of incoming edges to a bb with a phi node. */
if (!gsi_end_p (itr)) if (!gsi_end_p (itr))
FOR_EACH_EDGE (e, ei, bb->preds) FOR_EACH_EDGE (e, ei, bb->preds)
e->aux = NULL; e->aux = NULL;
/* Check statements. */
for (; !gsi_end_p (itr); gsi_next (&itr)) for (; !gsi_end_p (itr); gsi_next (&itr))
if (!if_convertible_phi_p (loop, bb, gsi_stmt (itr))) if (!if_convertible_phi_p (loop, bb, gsi_stmt (itr)))
return false; return false;
...@@ -610,8 +606,6 @@ if_convertible_loop_p (struct loop *loop, bool for_vectorizer ATTRIBUTE_UNUSED) ...@@ -610,8 +606,6 @@ if_convertible_loop_p (struct loop *loop, bool for_vectorizer ATTRIBUTE_UNUSED)
exit_bb = bb; exit_bb = bb;
} }
/* OK. Did not find any potential issues so go ahead in if-convert
this loop. Now there is no looking back. */
if (dump_file) if (dump_file)
fprintf (dump_file,"Applying if-conversion\n"); fprintf (dump_file,"Applying if-conversion\n");
...@@ -1064,11 +1058,11 @@ pred_blocks_visited_p (basic_block bb, bitmap *visited) ...@@ -1064,11 +1058,11 @@ pred_blocks_visited_p (basic_block bb, bitmap *visited)
return true; return true;
} }
/* Get body of a LOOP in suitable order for if-conversion. /* Get body of a LOOP in suitable order for if-conversion. It is
It is caller's responsibility to deallocate basic block caller's responsibility to deallocate basic block list.
list. If-conversion suitable order is, BFS order with one If-conversion suitable order is, breadth first sort (BFS) order
additional constraint. Select block in BFS block, if all with an additional constraint: select a block only if all its
pred are already selected. */ predecessors are already selected. */
static basic_block * static basic_block *
get_loop_body_in_if_conv_order (const struct loop *loop) get_loop_body_in_if_conv_order (const struct loop *loop)
...@@ -1099,6 +1093,7 @@ get_loop_body_in_if_conv_order (const struct loop *loop) ...@@ -1099,6 +1093,7 @@ get_loop_body_in_if_conv_order (const struct loop *loop)
free (blocks); free (blocks);
return NULL; return NULL;
} }
if (!bitmap_bit_p (visited, bb->index)) if (!bitmap_bit_p (visited, bb->index))
{ {
if (pred_blocks_visited_p (bb, &visited) if (pred_blocks_visited_p (bb, &visited)
...@@ -1109,14 +1104,14 @@ get_loop_body_in_if_conv_order (const struct loop *loop) ...@@ -1109,14 +1104,14 @@ get_loop_body_in_if_conv_order (const struct loop *loop)
blocks[visited_count++] = bb; blocks[visited_count++] = bb;
} }
} }
index++; index++;
if (index == loop->num_nodes if (index == loop->num_nodes
&& visited_count != loop->num_nodes) && visited_count != loop->num_nodes)
{
/* Not done yet. */ /* Not done yet. */
index = 0; index = 0;
} }
}
free (blocks_in_bfs_order); free (blocks_in_bfs_order);
BITMAP_FREE (visited); BITMAP_FREE (visited);
return blocks; return blocks;
......
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