+2014-06-30 Jeff Law <law@redhat.com>
+
+ PR tree-optimization/61607
+ * tree-ssa-threadedge.c (simplify_control_stmt_condition): Look
+ deeper into the SSA_NAME_VALUE chain.
+
2014-06-30 Marek Polacek <polacek@redhat.com>
* convert.c (convert_to_integer): Don't instrument conversions if the
+2014-06-30 Jeff Law <law@redhat.com>
+
+ PR tree-optimization/61607
+ * gcc.dg/tree-ssa/pr61607.c: New test.
+
2014-06-30 Marek Polacek <polacek@redhat.com>
* c-c++-common/ubsan/attrib-2.c: New test.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-Os -fno-tree-fre -fdump-tree-dom1" } */
+
+void foo(int *);
+void f2(int dst[3], int R)
+{
+ int i, inter[2];
+ _Bool inter0p = 0;
+ _Bool inter1p = 0;
+ for (i = 1; i < R; i++)
+ {
+ inter0p = 1;
+ inter1p = 1;
+ }
+ if (inter0p)
+ inter[0] = 1;
+ if (inter1p)
+ inter[1] = 1;
+ foo(inter);
+}
+
+
+/* There should be precisely two conditionals. One for the loop condition
+ and one for the test after the loop. Previously we failed to eliminate
+ the second conditional after the loop. */
+/* { dg-final { scan-tree-dump-times "if" 2 "dom1"} } */
+
+/* { dg-final { cleanup-tree-dump "dom1" } } */
+
/* Get the current value of both operands. */
if (TREE_CODE (op0) == SSA_NAME)
{
- tree tmp = SSA_NAME_VALUE (op0);
- if (tmp)
- op0 = tmp;
+ for (int i = 0; i < 2; i++)
+ {
+ if (TREE_CODE (op0) == SSA_NAME
+ && SSA_NAME_VALUE (op0))
+ op0 = SSA_NAME_VALUE (op0);
+ else
+ break;
+ }
}
if (TREE_CODE (op1) == SSA_NAME)
{
- tree tmp = SSA_NAME_VALUE (op1);
- if (tmp)
- op1 = tmp;
+ for (int i = 0; i < 2; i++)
+ {
+ if (TREE_CODE (op1) == SSA_NAME
+ && SSA_NAME_VALUE (op1))
+ op1 = SSA_NAME_VALUE (op1);
+ else
+ break;
+ }
}
if (handle_dominating_asserts)
It is possible to get loops in the SSA_NAME_VALUE chains
(consider threading the backedge of a loop where we have
a loop invariant SSA_NAME used in the condition. */
- if (cached_lhs
- && TREE_CODE (cached_lhs) == SSA_NAME
- && SSA_NAME_VALUE (cached_lhs))
- cached_lhs = SSA_NAME_VALUE (cached_lhs);
+ if (cached_lhs)
+ {
+ for (int i = 0; i < 2; i++)
+ {
+ if (TREE_CODE (cached_lhs) == SSA_NAME
+ && SSA_NAME_VALUE (cached_lhs))
+ cached_lhs = SSA_NAME_VALUE (cached_lhs);
+ else
+ break;
+ }
+ }
/* If we're dominated by a suitable ASSERT_EXPR, then
update CACHED_LHS appropriately. */