+2014-11-16 Patrick Palka <ppalka@gcc.gnu.org>
+
+ PR middle-end/63790
+ * tree-ssa-forwprop.c (forward_propagate_into_comparison_1):
+ Always combine comparisons or conversions from booleans.
+
2014-11-16 Jan Hubicka <hubicka@ucw.cz>
* ipa-polymorphic-call.c
+2014-11-16 Patrick Palka <ppalka@gcc.gnu.org>
+
+ PR middle-end/63790
+ * gcc.dg/tree-ssa/pr21031.c: Drop XFAIL.
+ * gcc.dg/tree-ssa/forwprop-29.c: New test.
+
2014-11-16 Andrew Pinski <apinski@cavium.com>
* gcc.c-torture/execute/memset-4.c: New test.
--- /dev/null
+/* { dg-options "-O2" } */
+
+void runtime_error (void) __attribute__ ((noreturn));
+void compiletime_error (void) __attribute__ ((noreturn, error ("")));
+
+static void
+compiletime_check_equals_1 (int *x, int y)
+{
+ int __p = *x != y;
+ if (__builtin_constant_p (__p) && __p)
+ compiletime_error ();
+ if (__p)
+ runtime_error ();
+}
+
+static void
+compiletime_check_equals_2 (int *x, int y)
+{
+ int __p = *x != y;
+ if (__builtin_constant_p (__p) && __p)
+ compiletime_error (); /* { dg-error "call to" } */
+ if (__p)
+ runtime_error ();
+}
+
+void
+foo (int *x)
+{
+ compiletime_check_equals_1 (x, 5);
+ compiletime_check_equals_2 (x, 10);
+}
return 0;
}
-/* { dg-final { scan-tree-dump-times "Replaced" 2 "forwprop1" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "Replaced" 2 "forwprop1" } } */
/* { dg-final { cleanup-tree-dump "forwprop1" } } */
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;
}