diff options
author | Jeff Law <law@redhat.com> | 2004-06-15 23:09:41 -0600 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2004-06-15 23:09:41 -0600 |
commit | fd660b1bee7af09cd69d1125cf35e6aa5826234c (patch) | |
tree | 2d5c137139fce6357a14c09e7a739e3529131431 /gcc/fold-const.c | |
parent | 3e97fe67e31070b78a333dba397ab4ddde2e7311 (diff) | |
download | gcc-fd660b1bee7af09cd69d1125cf35e6aa5826234c.zip gcc-fd660b1bee7af09cd69d1125cf35e6aa5826234c.tar.gz gcc-fd660b1bee7af09cd69d1125cf35e6aa5826234c.tar.bz2 |
fold-const.c (swap_tree_comparison): No longer static.
* fold-const.c (swap_tree_comparison): No longer static.
(tree_swap_operands_p): Similarly. Return true if both operands
are SSA_NAMEs and the first operand has a higher version number than
the second operand.
* tree.h (swap_tree_comparison): Prototype.
(tree_swap_operands_p): Prototype.
* tree-ssa-operands.c (get_expr_operands): For commutative
operators and relational comparisons, canonicalize the
order of the operands.
* gcc.dg/tree-ssa/20040615-1.c: New test.
* gcc.dg/tree-ssa/20030824-1.c: Update expected output to
be less sensitive to operand ordering.
* gcc.dg/tree-ssa/20030824-2.c: Likewise.
From-SVN: r83224
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 72974d6..91f4054 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -92,7 +92,6 @@ static hashval_t size_htab_hash (const void *); static int size_htab_eq (const void *, const void *); static tree fold_convert_const (enum tree_code, tree, tree); static enum tree_code invert_tree_comparison (enum tree_code, bool); -static enum tree_code swap_tree_comparison (enum tree_code); static enum comparison_code comparison_to_compcode (enum tree_code); static enum tree_code compcode_to_comparison (enum comparison_code); static tree combine_comparisons (enum tree_code, enum tree_code, @@ -132,8 +131,6 @@ static tree fold_mathfn_compare (enum built_in_function, enum tree_code, static tree fold_inf_compare (enum tree_code, tree, tree, tree); static tree fold_div_compare (enum tree_code, tree, tree, tree); static bool reorder_operands_p (tree, tree); -static bool tree_swap_operands_p (tree, tree, bool); - static tree fold_negate_const (tree, tree); static tree fold_not_const (tree, tree); static tree fold_relational_const (enum tree_code, tree, tree, tree); @@ -2119,7 +2116,7 @@ invert_tree_comparison (enum tree_code code, bool honor_nans) /* Similar, but return the comparison that results if the operands are swapped. This is safe for floating-point. */ -static enum tree_code +enum tree_code swap_tree_comparison (enum tree_code code) { switch (code) @@ -5527,7 +5524,7 @@ reorder_operands_p (tree arg0, tree arg1) isn't. If REORDER is true, only recommend swapping if we can evaluate the operands in reverse order. */ -static bool +bool tree_swap_operands_p (tree arg0, tree arg1, bool reorder) { STRIP_SIGN_NOPS (arg0); @@ -5574,6 +5571,15 @@ tree_swap_operands_p (tree arg0, tree arg1, bool reorder) if (DECL_P (arg0)) return 1; + /* It is preferable to swap two SSA_NAME to ensure a canonical form + for commutative and comparison operators. Ensuring a canonical + form allows the optimizers to find additional redundancies without + having to explicitly check for both orderings. */ + if (TREE_CODE (arg0) == SSA_NAME + && TREE_CODE (arg1) == SSA_NAME + && SSA_NAME_VERSION (arg0) > SSA_NAME_VERSION (arg1)) + return 1; + return 0; } |