aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorKazu Hirata <kazu@cs.umass.edu>2005-04-20 00:45:43 +0000
committerKazu Hirata <kazu@gcc.gnu.org>2005-04-20 00:45:43 +0000
commit7195b4148a916bab2451894b84e1298b5c42b8fe (patch)
tree4d50396db16e6979ac1ada58ebf3ea3bf12ff65c /gcc
parentacf55c29fcb72aefb55c3420c1a13447ddd4df32 (diff)
downloadgcc-7195b4148a916bab2451894b84e1298b5c42b8fe.zip
gcc-7195b4148a916bab2451894b84e1298b5c42b8fe.tar.gz
gcc-7195b4148a916bab2451894b84e1298b5c42b8fe.tar.bz2
* tree-ssa-phiopt.c: Update a comment about the pass.
From-SVN: r98428
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/tree-ssa-phiopt.c85
2 files changed, 52 insertions, 37 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 29fcc2f..42cea0a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+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>
* tree-ssa-phiopt.c, config/arm/arm.c, config/fr30/fr30.md,
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 5f5857b..b935407 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)