mirror of git://gcc.gnu.org/git/gcc.git
re PR tree-optimization/71947 (x ^ y not folded to 0 if x == y by DOM)
PR tree-optimization/71947 * tree-ssa-dom.c (cprop_into_stmt): Avoid replacing A with B, then B with A within a single statement. 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. From-SVN: r240947
This commit is contained in:
parent
db62593447
commit
d30078b8e7
|
|
@ -1,3 +1,9 @@
|
||||||
|
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>
|
2016-10-10 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
|
||||||
|
|
||||||
PR tree-optimization/77824
|
PR tree-optimization/77824
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,13 @@
|
||||||
|
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>
|
2016-10-10 Thomas Koenig <tkoenig@gcc.gnu.org>
|
||||||
|
|
||||||
PR fortran/77915
|
PR fortran/77915
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
/* { 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" } } */
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
/* { 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" } } */
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
/* { 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" } } */
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
/* { 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" } } */
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
/* { 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" } } */
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
/* { 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 *-*-* } } } */
|
||||||
|
|
@ -1731,9 +1731,26 @@ cprop_into_stmt (gimple *stmt)
|
||||||
{
|
{
|
||||||
use_operand_p op_p;
|
use_operand_p op_p;
|
||||||
ssa_op_iter iter;
|
ssa_op_iter iter;
|
||||||
|
tree last_copy_propagated_op = NULL;
|
||||||
|
|
||||||
FOR_EACH_SSA_USE_OPERAND (op_p, stmt, iter, SSA_OP_USE)
|
FOR_EACH_SSA_USE_OPERAND (op_p, stmt, iter, SSA_OP_USE)
|
||||||
|
{
|
||||||
|
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);
|
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
|
/* Optimize the statement in block BB pointed to by iterator SI
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue