Mercurial > hg > CbC > CbC_gcc
diff gcc/tree-ssa-ifcombine.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | 855418dad1a3 |
children | b7f97abdc517 |
line wrap: on
line diff
--- a/gcc/tree-ssa-ifcombine.c Sun Feb 07 18:28:00 2010 +0900 +++ b/gcc/tree-ssa-ifcombine.c Fri Feb 12 23:39:51 2010 +0900 @@ -108,7 +108,7 @@ gimple stmt = gsi_stmt (gsi); if (gimple_has_volatile_ops (stmt) - || !ZERO_SSA_OPERANDS (stmt, SSA_OP_ALL_VIRTUALS)) + || gimple_vuse (stmt)) return false; } @@ -340,6 +340,9 @@ t2 = force_gimple_operand_gsi (&gsi, t2, true, NULL_TREE, true, GSI_SAME_STMT); t = fold_build2 (EQ_EXPR, boolean_type_node, t2, t); + t = canonicalize_cond_expr_cond (t); + if (!t) + return false; gimple_cond_set_condition_from_tree (inner_cond, t); update_stmt (inner_cond); @@ -361,6 +364,44 @@ return true; } + /* 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)) + { + 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)))) + return false; + t = canonicalize_cond_expr_cond (t); + if (!t) + return false; + gimple_cond_set_condition_from_tree (inner_cond, t); + update_stmt (inner_cond); + + /* Leave CFG optimization to cfg_cleanup. */ + gimple_cond_set_condition_from_tree (outer_cond, boolean_true_node); + update_stmt (outer_cond); + + if (dump_file) + { + fprintf (dump_file, "optimizing two comparisons to "); + print_generic_expr (dump_file, t, 0); + fprintf (dump_file, "\n"); + } + + return true; + } + return false; } @@ -450,6 +491,9 @@ true, GSI_SAME_STMT); t = fold_build2 (NE_EXPR, boolean_type_node, t, build_int_cst (TREE_TYPE (t), 0)); + t = canonicalize_cond_expr_cond (t); + if (!t) + return false; gimple_cond_set_condition_from_tree (inner_cond, t); update_stmt (inner_cond); @@ -483,42 +527,14 @@ { enum tree_code code1 = gimple_cond_code (inner_cond); enum tree_code code2 = gimple_cond_code (outer_cond); - enum tree_code code; tree t; -#define CHK(a,b) ((code1 == a ## _EXPR && code2 == b ## _EXPR) \ - || (code2 == a ## _EXPR && code1 == b ## _EXPR)) - /* Merge the two condition codes if possible. */ - if (code1 == code2) - code = code1; - else if (CHK (EQ, LT)) - code = LE_EXPR; - else if (CHK (EQ, GT)) - code = GE_EXPR; - else if (CHK (LT, LE)) - code = LE_EXPR; - else if (CHK (GT, GE)) - code = GE_EXPR; - else if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_lhs (inner_cond))) - || flag_unsafe_math_optimizations) - { - if (CHK (LT, GT)) - code = NE_EXPR; - else if (CHK (LT, NE)) - code = NE_EXPR; - else if (CHK (GT, NE)) - code = NE_EXPR; - else - return false; - } - /* We could check for combinations leading to trivial true/false. */ - else + if (!(t = combine_comparisons (UNKNOWN_LOCATION, + TRUTH_ORIF_EXPR, code1, code2, + boolean_type_node, + gimple_cond_lhs (outer_cond), + gimple_cond_rhs (outer_cond)))) return false; -#undef CHK - - /* Do it. */ - t = fold_build2 (code, boolean_type_node, gimple_cond_lhs (outer_cond), - gimple_cond_rhs (outer_cond)); t = canonicalize_cond_expr_cond (t); if (!t) return false; @@ -641,7 +657,7 @@ return 1; } -struct gimple_opt_pass pass_tree_ifcombine = +struct gimple_opt_pass pass_tree_ifcombine = { { GIMPLE_PASS,