aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-reassoc.c
diff options
context:
space:
mode:
authorSandra Loosemore <sandra@codesourcery.com>2010-06-08 14:15:53 -0400
committerSandra Loosemore <sandra@gcc.gnu.org>2010-06-08 14:15:53 -0400
commite89065a17202234f50185ce3bf2a80efb2fef938 (patch)
tree4a855d962c105784a8cbaa9f50b09a09cba934e6 /gcc/tree-ssa-reassoc.c
parentc547eb0db1e58bbe7346705cc35ac36891fee425 (diff)
downloadgcc-e89065a17202234f50185ce3bf2a80efb2fef938.zip
gcc-e89065a17202234f50185ce3bf2a80efb2fef938.tar.gz
gcc-e89065a17202234f50185ce3bf2a80efb2fef938.tar.bz2
re PR tree-optimization/39874 (missing VRP (submission))
2010-06-08 Sandra Loosemore <sandra@codesourcery.com> PR tree-optimization/39874 PR middle-end/28685 gcc/ * gimple.h (maybe_fold_and_comparisons, maybe_fold_or_comparisons): Declare. * gimple-fold.c (canonicalize_bool, same_bool_comparison_p, same_bool_result_p): New. (and_var_with_comparison, and_var_with_comparison_1, and_comparisons_1, and_comparisons, maybe_fold_and_comparisons): New. (or_var_with_comparison, or_var_with_comparison_1, or_comparisons_1, or_comparisons, maybe_fold_or_comparisons): New. * tree-ssa-reassoc.c (eliminate_redundant_comparison): Use maybe_fold_and_comparisons or maybe_fold_or_comparisons instead of combine_comparisons. * tree-ssa-ifcombine.c (ifcombine_ifandif, ifcombine_iforif): Likewise. gcc/testsuite/ * gcc.dg/pr39874.c: New file. From-SVN: r160445
Diffstat (limited to 'gcc/tree-ssa-reassoc.c')
-rw-r--r--gcc/tree-ssa-reassoc.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index 0911c56..caad9081 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -1261,23 +1261,27 @@ eliminate_redundant_comparison (enum tree_code opcode,
rcode = gimple_assign_rhs_code (def2);
if (TREE_CODE_CLASS (rcode) != tcc_comparison)
continue;
- if (operand_equal_p (op1, gimple_assign_rhs1 (def2), 0)
- && operand_equal_p (op2, gimple_assign_rhs2 (def2), 0))
- ;
- else if (operand_equal_p (op1, gimple_assign_rhs2 (def2), 0)
- && operand_equal_p (op2, gimple_assign_rhs1 (def2), 0))
- rcode = swap_tree_comparison (rcode);
- else
- continue;
/* If we got here, we have a match. See if we can combine the
two comparisons. */
- t = combine_comparisons (UNKNOWN_LOCATION,
- (opcode == BIT_IOR_EXPR
- ? TRUTH_OR_EXPR : TRUTH_AND_EXPR),
- lcode, rcode, TREE_TYPE (curr->op), op1, op2);
+ if (opcode == BIT_IOR_EXPR)
+ t = maybe_fold_or_comparisons (lcode, op1, op2,
+ rcode, gimple_assign_rhs1 (def2),
+ gimple_assign_rhs2 (def2));
+ else
+ t = maybe_fold_and_comparisons (lcode, op1, op2,
+ rcode, gimple_assign_rhs1 (def2),
+ gimple_assign_rhs2 (def2));
if (!t)
continue;
+
+ /* maybe_fold_and_comparisons and maybe_fold_or_comparisons
+ always give us a boolean_type_node value back. If the original
+ BIT_AND_EXPR or BIT_IOR_EXPR was of a wider integer type,
+ we need to convert. */
+ if (!useless_type_conversion_p (TREE_TYPE (curr->op), TREE_TYPE (t)))
+ t = fold_convert (TREE_TYPE (curr->op), t);
+
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Equivalence: ");
@@ -1303,7 +1307,7 @@ eliminate_redundant_comparison (enum tree_code opcode,
VEC_ordered_remove (operand_entry_t, *ops, currindex);
add_to_ops_vec (ops, t);
}
- else if (TREE_CODE (t) != lcode)
+ else if (!operand_equal_p (t, curr->op, 0))
{
tree tmpvar;
gimple sum;