Commit 5635785a by Jeff Law Committed by Jeff Law

ssa-dse-1.c: New test.

	* gcc.dg/tree-ssa/ssa-dse-1.c: New test.
	* gcc.dg/tree-ssa/ssa-dse-2.c: New test.
	* gcc.dg/tree-ssa/ssa-dse-3.c: New test.
	* gcc.dg/tree-ssa/ssa-dse-4.c: New test.
	* gcc.dg/tree-ssa/ssa-dse-5.c: New test.
	* gcc.dg/tree-ssa/ssa-dse-6.c: New test.
	* gcc.dg/tree-ssa/ssa-dse-7.c: New test.

From-SVN: r98779
parent b1ca239f
2005-04-26 Jeff Law <law@redhat.com>
* gcc.gc/tree-ssa/ssa-dce-1.c: New test.
* gcc.gc/tree-ssa/ssa-dce-2.c: New test.
* gcc.gc/tree-ssa/ssa-dce-3.c: New test.
* gcc.gc/tree-ssa/ssa-dce-4.c: New test.
* gcc.gc/tree-ssa/ssa-dce-5.c: New test.
* gcc.gc/tree-ssa/ssa-dce-6.c: New test.
* gcc.gc/tree-ssa/ssa-dce-7.c: New test.
2004-04-26 Richard Guenther <rguenth@gcc.gnu.org>
PR tree-optimization/17598
......
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-dse1" } */
int
foo (int a, int b, int c)
{
int *p;
if (c)
p = &a;
else
p = &b;
*p = 3;
*p = 4;
return *p;
}
/* We should eliminate both assignments to *p. */
/* { dg-final { scan-tree-dump-times " = 3" 0 "dse1"} } */
/* { dg-final { scan-tree-dump-times " = 4" 0 "dse1"} } */
/* The return *p should be turned into return 4. */
/* { dg-final { scan-tree-dump-times " return 4" 1 "dse1"} } */
/* { dg-final { cleanup-tree-dump "dse1" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-dse1" } */
int a, b, c;
int
foo ()
{
int *p;
if (c)
p = &a;
else
p = &b;
*p = 3;
*p = 4;
return *p;
}
/* We should eliminate the first assignment to *p, but not the second. */
/* { dg-final { scan-tree-dump-times " = 3" 0 "dse1"} } */
/* { dg-final { scan-tree-dump-times " = 4" 1 "dse1"} } */
/* { dg-final { cleanup-tree-dump "dse1" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-dse1" } */
char Bool_Glob;
void f(void)
{
Bool_Glob = 0;
Bool_Glob = 1;
}
/* We should eliminate the first assignment to *p, but not the second. */
/* { dg-final { scan-tree-dump-times "Bool_Glob = 0" 0 "dse1"} } */
/* { dg-final { scan-tree-dump-times "Bool_Glob = 1" 1 "dse1"} } */
/* { dg-final { cleanup-tree-dump "dse1" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-dse1" } */
foo( int *a)
{
*a = 5;
*a = 3;
}
/* We should eliminate the first assignment to *p, but not the second. */
/* { dg-final { scan-tree-dump-times "= 5" 0 "dse1"} } */
/* { dg-final { scan-tree-dump-times "= 3" 1 "dse1"} } */
/* { dg-final { cleanup-tree-dump "dse1" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
int x;
int
f1 (int i, int j, int k)
{
int *p = k ? &i : &j;
i = 3;
*p = 5;
x = j;
}
/* The assignment "i = 3" is partialy dead. Our DSE pass doesn't handle
detection of partially dead assignments.
There's two outputs which would indicate that the optimization was
performed.
If we used block copying to detect and eliminate the partially dead
store, then we should see an assignment "i = 5" somewhere in the
dump file.
Another approach would be to redirect the path from the true arm
of the first conditional so that it reaches the statement *p = 5
rather than i = 3. */
/* { dg-final { scan-tree-dump-times "i = 5" 1 "optimized" { xfail *-*-* }} } */
/* { dg-final { scan-tree-dump-times "<L.*>:;\[\n\t \]*\\*p = 5" 1 "optimized" { xfail *-*-*}} } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-dse1" } */
int foo11 (int c)
{
static int local1, local2;
local1 = 0;
local2 += c;
local1 = 2;
local2++;
return local1 + local2;
}
/* There should only be one assignment to local1 and local2. */
/* { dg-final { scan-tree-dump-times "local1 = " 1 "dse1"} } */
/* { dg-final { scan-tree-dump-times "local2 = " 1 "dse1"} } */
/* { dg-final { cleanup-tree-dump "dse1" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-dse1" } */
int glob1, glob2;
int foo1 (void)
{
glob1 = 0;
glob2 = 1;
glob1 = 2;
glob2 = 3;
return glob1 + glob2;
}
/* There should only be one assignment to glob1 and glob2, the final
return statement should just return a constant. */
/* { dg-final { scan-tree-dump-times "glob1 = " 1 "dse1"} } */
/* { dg-final { scan-tree-dump-times "glob2 = " 1 "dse1"} } */
/* { dg-final { scan-tree-dump-times "return 5" 1 "dse1"} } */
/* { dg-final { cleanup-tree-dump "dse1" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment