+2016-10-10 Jeff Law <law@redhat.com>
+
+ PR tree-optimization/71947
+ * tree-ssa-dom.c (cprop_into_stmt): Avoid replacing A with B, then
+ B with A within a single statement.
+
2016-10-10 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
PR tree-optimization/77824
+2016-10-10 Jeff Law <law@redhat.com>
+
+ PR tree-optimization/71947
+ * gcc.dg/tree-ssa/pr71947-1.c: New test.
+ * gcc.dg/tree-ssa/pr71947-2.c: New test.
+ * gcc.dg/tree-ssa/pr71947-3.c: New test.
+ * gcc.dg/tree-ssa/pr71947-4.c: New test.
+ * gcc.dg/tree-ssa/pr71947-5.c: New test.
+ * gcc.dg/tree-ssa/pr71947-6.c: New test.
+
2016-10-10 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/77915
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-vrp -fdump-tree-dom-details" } */
+
+
+int f(int x, int y)
+{
+ int ret;
+
+ if (x == y)
+ ret = x ^ y;
+ else
+ ret = 1;
+
+ return ret;
+}
+
+/* { dg-final { scan-tree-dump "Folded to: ret_\[0-9\]+ = 0;" "dom2" } } */
+
+
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-vrp -fdump-tree-dom-details" } */
+
+
+int f(int x, int y)
+{
+ int ret;
+ if (x == y)
+ ret = x - y;
+ else
+ ret = 1;
+
+ return ret;
+}
+
+/* { dg-final { scan-tree-dump "Folded to: ret_\[0-9\]+ = 0;" "dom2" } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-vrp -fdump-tree-dom-details" } */
+
+int f(int x, int y)
+{
+ int ret = 10;
+ if (x == y)
+ ret = x - y;
+ return ret;
+}
+
+/* { dg-final { scan-tree-dump "Folded to: ret_\[0-9\]+ = 0;" "dom2" } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-vrp -fdump-tree-dom-details" } */
+
+
+
+static inline long load(long *p)
+{
+ long ret;
+ asm ("movq %1,%0\n\t" : "=r" (ret) : "m" (*p));
+ if (ret != *p)
+ __builtin_unreachable();
+ return ret;
+}
+
+long foo(long *mem)
+{
+ long ret;
+ ret = load(mem);
+ return ret + *mem;
+}
+
+/* { dg-final { scan-tree-dump "Folded to: _\[0-9\]+ = _\[0-9\]+ \\* 2" "dom2" } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-vrp -fdump-tree-dom-details" } */
+
+
+static inline long load(long *p)
+{
+ long ret;
+ asm ("movq %1,%0\n\t" : "=r" (ret) : "m" (*p));
+ if (ret != *p)
+ __builtin_unreachable();
+ return ret;
+}
+
+long foo(long *mem)
+{
+ long ret;
+ ret = load(mem);
+ return ret - *mem;
+}
+
+/* { dg-final { scan-tree-dump "Folded to: _\[0-9\]+ = 0;" "dom2" } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-vrp -fdump-tree-dom-details" } */
+
+
+int f(int x, int y, int a, int b)
+{
+ int ret = 10;
+ if (a == x
+ && b == y
+ && a == b)
+ ret = x - y;
+
+ return ret;
+}
+
+/* { dg-final { scan-tree-dump "Folded to: ret_\[0-9\]+ = 0;" "dom2" { xfail *-*-* } } } */
{
use_operand_p op_p;
ssa_op_iter iter;
+ tree last_copy_propagated_op = NULL;
FOR_EACH_SSA_USE_OPERAND (op_p, stmt, iter, SSA_OP_USE)
- cprop_operand (stmt, op_p);
+ {
+ tree old_op = USE_FROM_PTR (op_p);
+
+ /* If we have A = B and B = A in the copy propagation tables
+ (due to an equality comparison), avoid substituting B for A
+ then A for B in the trivially discovered cases. This allows
+ optimization of statements were A and B appear as input
+ operands. */
+ if (old_op != last_copy_propagated_op)
+ {
+ cprop_operand (stmt, op_p);
+
+ tree new_op = USE_FROM_PTR (op_p);
+ if (new_op != old_op && TREE_CODE (new_op) == SSA_NAME)
+ last_copy_propagated_op = new_op;
+ }
+ }
}
/* Optimize the statement in block BB pointed to by iterator SI