aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-forwprop.c
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@gcc.gnu.org>2014-11-17 02:01:36 +0000
committerPatrick Palka <ppalka@gcc.gnu.org>2014-11-17 02:01:36 +0000
commitc1c7f1fc21ff3b3ebbb8bf7eb91f68b2fec64d60 (patch)
tree3ba9abd59af95a71bcd793ab1693a17da7c20e53 /gcc/tree-ssa-forwprop.c
parent6e2826178d775918fd0be177bdb8ae876f21965c (diff)
downloadgcc-c1c7f1fc21ff3b3ebbb8bf7eb91f68b2fec64d60.zip
gcc-c1c7f1fc21ff3b3ebbb8bf7eb91f68b2fec64d60.tar.gz
gcc-c1c7f1fc21ff3b3ebbb8bf7eb91f68b2fec64d60.tar.bz2
Always combine comparisons or conversions from booleans.
2014-11-16 Patrick Palka <ppalka@gcc.gnu.org> gcc/ PR middle-end/63790 * tree-ssa-forwprop.c (forward_propagate_into_comparison_1): Always combine comparisons or conversions from booleans. gcc/testsuite/ PR middle-end/63790 * gcc.dg/tree-ssa/pr21031.c: Drop XFAIL. * gcc.dg/tree-ssa/forwprop-29.c: New test. From-SVN: r217638
Diffstat (limited to 'gcc/tree-ssa-forwprop.c')
-rw-r--r--gcc/tree-ssa-forwprop.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index d42dcf8..5b8c10e 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -442,9 +442,21 @@ forward_propagate_into_comparison_1 (gimple stmt,
gimple def_stmt = get_prop_source_stmt (op0, false, &single_use0_p);
if (def_stmt && can_propagate_from (def_stmt))
{
+ enum tree_code def_code = gimple_assign_rhs_code (def_stmt);
+ bool invariant_only_p = !single_use0_p;
+
rhs0 = rhs_to_tree (TREE_TYPE (op1), def_stmt);
+
+ /* Always combine comparisons or conversions from booleans. */
+ if (TREE_CODE (op1) == INTEGER_CST
+ && ((CONVERT_EXPR_CODE_P (def_code)
+ && TREE_CODE (TREE_TYPE (TREE_OPERAND (rhs0, 0)))
+ == BOOLEAN_TYPE)
+ || TREE_CODE_CLASS (def_code) == tcc_comparison))
+ invariant_only_p = false;
+
tmp = combine_cond_expr_cond (stmt, code, type,
- rhs0, op1, !single_use0_p);
+ rhs0, op1, invariant_only_p);
if (tmp)
return tmp;
}