diff options
author | kazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-20 00:45:43 +0000 |
---|---|---|
committer | kazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-20 00:45:43 +0000 |
commit | caac37c241c47fe1c95a28c8824bf863cc947260 (patch) | |
tree | 4d50396db16e6979ac1ada58ebf3ea3bf12ff65c /gcc/tree-ssa-phiopt.c | |
parent | 7d0da8df197e28d6b7d70db27e17b44627371db1 (diff) | |
download | gcc-caac37c241c47fe1c95a28c8824bf863cc947260.tar.gz |
* tree-ssa-phiopt.c: Update a comment about the pass.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98428 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-phiopt.c')
-rw-r--r-- | gcc/tree-ssa-phiopt.c | 85 |
1 files changed, 48 insertions, 37 deletions
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index 5f5857bf21a..b9354071993 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -49,80 +49,91 @@ static void replace_phi_edge_with_variable (basic_block, basic_block, edge, tree, tree); static basic_block *blocks_in_phiopt_order (void); -/* This pass eliminates PHI nodes which can be trivially implemented as - an assignment from a conditional expression. i.e. if we have something - like: +/* This pass tries to replaces an if-then-else block with an + assignment. We have four kinds of transformations. Some of these + transformations are also performed by the ifcvt RTL optimizer. + + Conditional Replacement + ----------------------- + + This transformation, implmented in conditional_replacement, + replaces bb0: if (cond) goto bb2; else goto bb1; bb1: bb2: - x = PHI (0 (bb1), 1 (bb0) + x = PHI <0 (bb1), 1 (bb0), ...>; - We can rewrite that as: + with bb0: - bb1: + x' = cond; + goto bb2; bb2: - x = cond; + x = PHI <x' (bb0), ...>; - bb1 will become unreachable and bb0 and bb2 will almost always - be merged into a single block. This occurs often due to gimplification - of conditionals. + We remove bb1 as it becomes unreachable. This occurs often due to + gimplification of conditionals. - Also done is the following optimization: + Value Replacement + ----------------- + + This transformation, implemented in value_replacement, replaces bb0: - if (a != b) goto bb2; else goto bb1; + if (a != b) goto bb2; else goto bb1; bb1: bb2: - x = PHI (a (bb1), b (bb0)) + x = PHI <a (bb1), b (bb0), ...>; - We can rewrite that as: + with bb0: - bb1: 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 - similar transformation is done by the ifcvt RTL optimizer. + ABS Replacement + --------------- - This pass also eliminates PHI nodes which are really absolute - values. i.e. if we have something like: + This transformation, implemented in abs_replacement, replaces bb0: - if (a >= 0) goto bb2; else goto bb1; + if (a >= 0) goto bb2; else goto bb1; bb1: - x = -a; + x = -a; bb2: - x = PHI (x (bb1), a (bb0)); + x = PHI <x (bb1), a (bb0), ...>; - We can rewrite that as: + with bb0: - bb1: + x' = ABS_EXPR< a >; bb2: - x = ABS_EXPR< a >; + x = PHI <x' (bb0), ...>; + + MIN/MAX Replacement + ------------------- - Similarly, + This transformation, minmax_replacement replaces bb0: - if (a <= b) goto bb2; else goto bb1; + if (a <= b) goto bb2; else goto bb1; bb1: - goto bb2; bb2: - x = PHI (b (bb1), a (bb0)); + x = PHI <b (bb1), a (bb0), ...>; - Becomes + with - x = MIN_EXPR (a, b) - - And the same transformation for MAX_EXPR. + bb0: + x' = MIN_EXPR (a, b) + bb2: + x = PHI <x' (bb0), ...>; - bb1 will become unreachable and bb0 and bb2 will almost always be merged - into a single block. Similar transformations are done by the ifcvt - RTL optimizer. */ + A similar transformtion is done for MAX_EXPR. */ static void tree_ssa_phiopt (void) |