diff options
author | sandra <sandra@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-06-08 18:15:53 +0000 |
---|---|---|
committer | sandra <sandra@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-06-08 18:15:53 +0000 |
commit | c82d157a5d6f77c0ae3b4f8e1eadad16ed60df27 (patch) | |
tree | 4a855d962c105784a8cbaa9f50b09a09cba934e6 /gcc/tree-ssa-ifcombine.c | |
parent | eecb925d941ac59fcd938380f5c466d59e0755ab (diff) | |
download | gcc-c82d157a5d6f77c0ae3b4f8e1eadad16ed60df27.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160445 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-ifcombine.c')
-rw-r--r-- | gcc/tree-ssa-ifcombine.c | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/gcc/tree-ssa-ifcombine.c b/gcc/tree-ssa-ifcombine.c index a20f7040403..bc551b2231c 100644 --- a/gcc/tree-ssa-ifcombine.c +++ b/gcc/tree-ssa-ifcombine.c @@ -366,21 +366,16 @@ ifcombine_ifandif (basic_block inner_cond_bb, basic_block outer_cond_bb) /* See if we have two comparisons that we can merge into one. */ else if (TREE_CODE_CLASS (gimple_cond_code (inner_cond)) == tcc_comparison - && TREE_CODE_CLASS (gimple_cond_code (outer_cond)) == tcc_comparison - && operand_equal_p (gimple_cond_lhs (inner_cond), - gimple_cond_lhs (outer_cond), 0) - && operand_equal_p (gimple_cond_rhs (inner_cond), - gimple_cond_rhs (outer_cond), 0)) + && TREE_CODE_CLASS (gimple_cond_code (outer_cond)) == tcc_comparison) { - enum tree_code code1 = gimple_cond_code (inner_cond); - enum tree_code code2 = gimple_cond_code (outer_cond); tree t; - if (!(t = combine_comparisons (UNKNOWN_LOCATION, - TRUTH_ANDIF_EXPR, code1, code2, - boolean_type_node, - gimple_cond_lhs (outer_cond), - gimple_cond_rhs (outer_cond)))) + if (!(t = maybe_fold_and_comparisons (gimple_cond_code (inner_cond), + gimple_cond_lhs (inner_cond), + gimple_cond_rhs (inner_cond), + gimple_cond_code (outer_cond), + gimple_cond_lhs (outer_cond), + gimple_cond_rhs (outer_cond)))) return false; t = canonicalize_cond_expr_cond (t); if (!t) @@ -518,22 +513,17 @@ ifcombine_iforif (basic_block inner_cond_bb, basic_block outer_cond_bb) /* See if we have two comparisons that we can merge into one. This happens for C++ operator overloading where for example GE_EXPR is implemented as GT_EXPR || EQ_EXPR. */ - else if (TREE_CODE_CLASS (gimple_cond_code (inner_cond)) == tcc_comparison - && TREE_CODE_CLASS (gimple_cond_code (outer_cond)) == tcc_comparison - && operand_equal_p (gimple_cond_lhs (inner_cond), - gimple_cond_lhs (outer_cond), 0) - && operand_equal_p (gimple_cond_rhs (inner_cond), - gimple_cond_rhs (outer_cond), 0)) + else if (TREE_CODE_CLASS (gimple_cond_code (inner_cond)) == tcc_comparison + && TREE_CODE_CLASS (gimple_cond_code (outer_cond)) == tcc_comparison) { - enum tree_code code1 = gimple_cond_code (inner_cond); - enum tree_code code2 = gimple_cond_code (outer_cond); tree t; - if (!(t = combine_comparisons (UNKNOWN_LOCATION, - TRUTH_ORIF_EXPR, code1, code2, - boolean_type_node, - gimple_cond_lhs (outer_cond), - gimple_cond_rhs (outer_cond)))) + if (!(t = maybe_fold_or_comparisons (gimple_cond_code (inner_cond), + gimple_cond_lhs (inner_cond), + gimple_cond_rhs (inner_cond), + gimple_cond_code (outer_cond), + gimple_cond_lhs (outer_cond), + gimple_cond_rhs (outer_cond)))) return false; t = canonicalize_cond_expr_cond (t); if (!t) |