Commit 0b4b14ac by Richard Guenther Committed by Richard Biener

tree-ssa-ccp.c (struct prop_value_d): Add mask member.

2010-08-06  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-ccp.c (struct prop_value_d): Add mask member.
	(dump_lattice_value): Dump it.
	(get_default_value): Adjust.
	(get_constant_value): Likewise.
	(set_value_varying): Likewise.
	(set_lattice_value): Make sure to not go up the lattice
	with bitwise constant values.
	(get_value_for_expr): Handle ADDR_EXPRs.
	(value_to_double_int): New function.
	(get_value_from_alignment): Likewise.
	(do_dbg_cnt): Adjust.
	(ccp_lattice_meet): Handle partially constant values.
	(bit_value_unop_1): New function.
	(bit_value_binop_1): Likewise.
	(bit_value_unop): Likewise.
	(bit_value_binop): Likewise.
	(evaluate_stmt): Track partially constant values if
	flag_tree_bit_ccp is set.
	(ccp_fold_stmt): Dump if we folded a predicate.
	(ccp_visit_stmt): Adjust.
	* common.opt (ftree-bit-ccp): New flag.
	* doc/invoke.texi (ftree-bit-ccp): Document.
	* opts.c (decode_options): Enable bit-CCP at -O1.

	* gcc.dg/tree-ssa/ssa-dce-3.c: XFAIL.
	* gcc.dg/tree-ssa/pr23744.c: Disable CCP.
	* gcc.dg/tree-ssa/pr25382.c: Likewise.
	* gcc.dg/tree-ssa/ssa-ccp-30.c: New testcase.
	* gcc.dg/tree-ssa/ssa-ccp-31.c: Likewise.
	* gcc.dg/tree-ssa/ssa-ccp-32.c: Likewise.
	* gcc.dg/tree-ssa/ssa-ccp-33.c: Likewise.
	* gcc.c-torture/execute/20100805-1.c: Likewise.

From-SVN: r162943
parent c2653d8f
2010-08-06 Richard Guenther <rguenther@suse.de>
* tree-ssa-ccp.c (struct prop_value_d): Add mask member.
(dump_lattice_value): Dump it.
(get_default_value): Adjust.
(get_constant_value): Likewise.
(set_value_varying): Likewise.
(set_lattice_value): Make sure to not go up the lattice
with bitwise constant values.
(get_value_for_expr): Handle ADDR_EXPRs.
(value_to_double_int): New function.
(get_value_from_alignment): Likewise.
(do_dbg_cnt): Adjust.
(ccp_lattice_meet): Handle partially constant values.
(bit_value_unop_1): New function.
(bit_value_binop_1): Likewise.
(bit_value_unop): Likewise.
(bit_value_binop): Likewise.
(evaluate_stmt): Track partially constant values if
flag_tree_bit_ccp is set.
(ccp_fold_stmt): Dump if we folded a predicate.
(ccp_visit_stmt): Adjust.
* common.opt (ftree-bit-ccp): New flag.
* doc/invoke.texi (ftree-bit-ccp): Document.
* opts.c (decode_options): Enable bit-CCP at -O1.
2010-08-06 Alan Modra <amodra@gmail.com>
* doc/invoke.texi (RS/6000 and PowerPC Options): Rewrite -mrelocatable
......
......@@ -1281,6 +1281,10 @@ ftree-ccp
Common Report Var(flag_tree_ccp) Optimization
Enable SSA-CCP optimization on trees
ftree-bit-ccp
Common Report Var(flag_tree_bit_ccp) Optimization
Enable SSA-BIT-CCP optimization on trees
ftree-store-ccp
Common
Does nothing. Preserved for backward compatibility.
......
......@@ -380,7 +380,7 @@ Objective-C and Objective-C++ Dialects}.
-fsel-sched-pipelining -fsel-sched-pipelining-outer-loops @gol
-fsignaling-nans -fsingle-precision-constant -fsplit-ivs-in-unroller @gol
-fsplit-wide-types -fstack-protector -fstack-protector-all @gol
-fstrict-aliasing -fstrict-overflow -fthread-jumps -ftracer @gol
-fstrict-aliasing -fstrict-overflow -fthread-jumps -ftracer -ftree-bit-ccp @gol
-ftree-builtin-call-dce -ftree-ccp -ftree-ch -ftree-copy-prop @gol
-ftree-copyrename -ftree-dce -ftree-dominator-opts -ftree-dse @gol
-ftree-forwprop -ftree-fre -ftree-loop-if-convert -ftree-loop-im @gol
......@@ -5848,6 +5848,7 @@ compilation time.
-fipa-reference @gol
-fmerge-constants
-fsplit-wide-types @gol
-ftree-bit-ccp @gol
-ftree-builtin-call-dce @gol
-ftree-ccp @gol
-ftree-ch @gol
......@@ -6737,6 +6738,13 @@ Transposing is enabled only if profiling information is available.
Perform forward store motion on trees. This flag is
enabled by default at @option{-O} and higher.
@item -ftree-bit-ccp
@opindex ftree-bit-ccp
Perform sparse conditional bit constant propagation on trees and propagate
pointer alignment information.
This pass only operates on local scalar variables and is enabled by default
at @option{-O} and higher. It requires that @option{-ftree-ccp} is enabled.
@item -ftree-ccp
@opindex ftree-ccp
Perform sparse conditional constant propagation (CCP) on trees. This
......
......@@ -767,6 +767,7 @@ decode_options (unsigned int argc, const char **argv,
flag_merge_constants = opt1;
flag_split_wide_types = opt1;
flag_tree_ccp = opt1;
flag_tree_bit_ccp = opt1;
flag_tree_dce = opt1;
flag_tree_dom = opt1;
flag_tree_dse = opt1;
......
2010-08-06 Richard Guenther <rguenther@suse.de>
* gcc.dg/tree-ssa/ssa-dce-3.c: XFAIL.
* gcc.dg/tree-ssa/pr23744.c: Disable CCP.
* gcc.dg/tree-ssa/pr25382.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-30.c: New testcase.
* gcc.dg/tree-ssa/ssa-ccp-31.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-32.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-33.c: Likewise.
* gcc.c-torture/execute/20100805-1.c: Likewise.
2010-08-05 Martin Jambor <mjambor@suse.cz>
PR testsuite/42855
......
unsigned int foo (unsigned int a, unsigned int b)
{
unsigned i;
a = a & 1;
for (i = 0; i < b; ++i)
a = a << 1 | a >> (sizeof (unsigned int) * 8 - 1);
return a;
}
extern void abort (void);
int main()
{
if (foo (1, sizeof (unsigned int) * 8 + 1) != 2)
abort ();
return 0;
}
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-vrp1" } */
/* { dg-options "-O2 -fno-tree-ccp -fdump-tree-vrp1" } */
int g (int i, int j)
{
......
......@@ -3,7 +3,7 @@
Check that VRP now gets ranges from BIT_AND_EXPRs. */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-vrp1" } */
/* { dg-options "-O2 -fno-tree-ccp -fdump-tree-vrp1" } */
int
foo (int a)
......
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-ccp1" } */
int
foo (int a)
{
int b = a & 0xff;
if (b > 300)
return 2;
else
return 1;
}
/* { dg-final { scan-tree-dump-times "Folding predicate b_.* > 300 to 0" 1 "ccp1" } } */
/* { dg-final { cleanup-tree-dump "ccp1" } } */
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-ccp1" } */
int g (int i, int j)
{
int t = 0;
int i1;
if (i == j)
t = 3;
for (i1 = 0; i1 < 10000; i1++) h();
if (t != 5)
return 0;
else
return 1;
}
/* { dg-final { scan-tree-dump-times "Folding predicate.*to 1" 1 "ccp1" } } */
/* { dg-final { cleanup-tree-dump "ccp1" } } */
/* { dg-do run } */
/* { dg-options "-O" } */
extern void link_error (void);
unsigned int __attribute__((noinline,noclone))
test0 (unsigned int a)
{
a = a & 1;
a = a << 1 | a >> (sizeof (unsigned int) * 8 - 1);
if (a & 1)
{
a = a | 4;
link_error ();
}
if (a & 4)
link_error ();
return a;
}
int __attribute__((noinline,noclone))
test1 (int a)
{
a |= 1;
a = a << (sizeof (int) * 8 - 1);
if (a >= 0)
link_error ();
a = a * 4;
if (a & ~3)
link_error ();
if (a == -1)
link_error ();
return a;
}
int __attribute__((noinline,noclone))
test2 (int a)
{
a = a | 0xff;
a = a + 1;
if (a & 0xff)
link_error ();
a = -a;
if (a & 0xff)
link_error ();
a = a - 1;
if (a & 0xff != 0xff)
link_error ();
return a;
}
extern void abort (void);
int main()
{
if (test0 (1) != 2)
abort ();
if (test1 (0) != 0)
abort ();
if (test2 (-1) != -1)
abort ();
return 0;
}
/* { dg-do link } */
/* { dg-options "-O" } */
extern void link_error ();
int a[256];
void foo(int n)
{
int *p;
for (p = a; n != 0; --n, ++p)
;
if ((__SIZE_TYPE__)p & (sizeof (int) - 1))
link_error ();
}
int main()
{
return 0;
}
......@@ -21,11 +21,15 @@ int main(void)
return 0;
}
/* We now can prove the infiniteness of the loop during CCP and fail
to eliminate the code inside the infinite loop because we start
by marking the j % 7 condition as useful. See PR45178. */
/* We should eliminate the inner condition, but the loop must be preserved
as it is infinite. Therefore there should be just one phi node (for i): */
/* { dg-final { scan-tree-dump-times "PHI " 1 "cddce1"} } */
/* { dg-final { scan-tree-dump-times "PHI " 1 "cddce1" { xfail *-*-* } } } */
/* And one if (for the exit condition of the loop): */
/* { dg-final { scan-tree-dump-times "if " 1 "cddce1"} } */
/* { dg-final { scan-tree-dump-times "if " 1 "cddce1" } } */
/* { dg-final { cleanup-tree-dump "cddce1" } } */
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