Commit 7195b414 by Kazu Hirata Committed by Kazu Hirata

* tree-ssa-phiopt.c: Update a comment about the pass.

From-SVN: r98428
parent acf55c29
2005-04-20 Kazu Hirata <kazu@cs.umass.edu>
* tree-ssa-phiopt.c: Update a comment about the pass.
2005-04-19 Kazu Hirata <kazu@cs.umass.edu> 2005-04-19 Kazu Hirata <kazu@cs.umass.edu>
* tree-ssa-phiopt.c, config/arm/arm.c, config/fr30/fr30.md, * tree-ssa-phiopt.c, config/arm/arm.c, config/fr30/fr30.md,
......
...@@ -49,80 +49,91 @@ static void replace_phi_edge_with_variable (basic_block, basic_block, edge, ...@@ -49,80 +49,91 @@ static void replace_phi_edge_with_variable (basic_block, basic_block, edge,
tree, tree); tree, tree);
static basic_block *blocks_in_phiopt_order (void); static basic_block *blocks_in_phiopt_order (void);
/* This pass eliminates PHI nodes which can be trivially implemented as /* This pass tries to replaces an if-then-else block with an
an assignment from a conditional expression. i.e. if we have something assignment. We have four kinds of transformations. Some of these
like: transformations are also performed by the ifcvt RTL optimizer.
Conditional Replacement
-----------------------
This transformation, implmented in conditional_replacement,
replaces
bb0: bb0:
if (cond) goto bb2; else goto bb1; if (cond) goto bb2; else goto bb1;
bb1: bb1:
bb2: bb2:
x = PHI (0 (bb1), 1 (bb0) x = PHI <0 (bb1), 1 (bb0), ...>;
We can rewrite that as: with
bb0: bb0:
bb1: x' = cond;
goto bb2;
bb2: bb2:
x = cond; x = PHI <x' (bb0), ...>;
bb1 will become unreachable and bb0 and bb2 will almost always We remove bb1 as it becomes unreachable. This occurs often due to
be merged into a single block. This occurs often due to gimplification gimplification of conditionals.
of conditionals.
Also done is the following optimization: Value Replacement
-----------------
This transformation, implemented in value_replacement, replaces
bb0: bb0:
if (a != b) goto bb2; else goto bb1; if (a != b) goto bb2; else goto bb1;
bb1: bb1:
bb2: bb2:
x = PHI (a (bb1), b (bb0)) x = PHI <a (bb1), b (bb0), ...>;
We can rewrite that as: with
bb0: bb0:
bb1:
bb2: bb2:
x = b; x = PHI <b (bb0), ...>;
This opportunity can sometimes occur as a result of other
optimizations.
This can sometimes occur as a result of other optimizations. A ABS Replacement
similar transformation is done by the ifcvt RTL optimizer. ---------------
This pass also eliminates PHI nodes which are really absolute This transformation, implemented in abs_replacement, replaces
values. i.e. if we have something like:
bb0: bb0:
if (a >= 0) goto bb2; else goto bb1; if (a >= 0) goto bb2; else goto bb1;
bb1: bb1:
x = -a; x = -a;
bb2: bb2:
x = PHI (x (bb1), a (bb0)); x = PHI <x (bb1), a (bb0), ...>;
We can rewrite that as: with
bb0: bb0:
bb1: x' = ABS_EXPR< a >;
bb2: bb2:
x = ABS_EXPR< a >; x = PHI <x' (bb0), ...>;
MIN/MAX Replacement
-------------------
Similarly, This transformation, minmax_replacement replaces
bb0: bb0:
if (a <= b) goto bb2; else goto bb1; if (a <= b) goto bb2; else goto bb1;
bb1: bb1:
goto bb2;
bb2: bb2:
x = PHI (b (bb1), a (bb0)); x = PHI <b (bb1), a (bb0), ...>;
Becomes with
x = MIN_EXPR (a, b) bb0:
x' = MIN_EXPR (a, b)
And the same transformation for MAX_EXPR. bb2:
x = PHI <x' (bb0), ...>;
bb1 will become unreachable and bb0 and bb2 will almost always be merged A similar transformtion is done for MAX_EXPR. */
into a single block. Similar transformations are done by the ifcvt
RTL optimizer. */
static void static void
tree_ssa_phiopt (void) tree_ssa_phiopt (void)
......
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