diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-08-29 08:36:10 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-08-29 08:36:10 +0000 |
commit | eb8b313af81929e569d7729872ebb95db543c480 (patch) | |
tree | 81dde4fb09ba070d53dbbe9adb6f6574611ea46a /gcc | |
parent | c0d40c29c39fe97e86b9cc59598dc4ece3487c63 (diff) | |
download | gcc-eb8b313af81929e569d7729872ebb95db543c480.tar.gz |
2008-08-29 Richard Guenther <rguenther@suse.de>
PR tree-optimization/37207
* tree-vrp.c (extract_range_from_binary_expr): Also try
to constant fold if only one of the operands is a constant.
* gcc.dg/tree-ssa/vrp46.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139754 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/vrp46.c | 28 | ||||
-rw-r--r-- | gcc/tree-vrp.c | 9 |
4 files changed, 45 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d9907a60701..24ce3a6c532 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-08-29 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/37207 + * tree-vrp.c (extract_range_from_binary_expr): Also try + to constant fold if only one of the operands is a constant. + 2008-08-29 Nick Clifton <nickc@redhat.com> * config/m32r/m32r.h (LEGITIMATE_CONSTANT_P): Treat LABEL_REFs in diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 23ea3b5c12d..14b4299da7f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-08-29 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/37207 + * gcc.dg/tree-ssa/vrp46.c: New testcase. + 2008-08-28 Adam Nemet <anemet@caviumnetworks.com> * gcc.target/mips/octeon-bbit-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp46.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp46.c new file mode 100644 index 00000000000..a67e839ded5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp46.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-vrp1" } */ + +void +func_18 ( int t ) +{ + unsigned l_889; + int l_895 = 1; + for (0; 1; ++l_889) + { + int t1 = 0; + if (func_81 (1)) + { + int rhs = l_895; + if (rhs == 0) + rhs = 1; + if (1 & (t % rhs)) + t1 = 1; + } + func_98 (t1); + l_895 = 0; + } +} + +/* There should be a single if left. */ + +/* { dg-final { scan-tree-dump-times "if" 1 "vrp1" } } */ +/* { dg-final { cleanup-tree-dump "vrp1" } } */ diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 17fbcdbb770..7579ee1330b 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -2058,10 +2058,13 @@ extract_range_from_binary_expr (value_range_t *vr, && code != TRUTH_OR_EXPR) { /* We can still do constant propagation here. */ - if ((op0 = op_with_constant_singleton_value_range (op0)) != NULL_TREE - && (op1 = op_with_constant_singleton_value_range (op1)) != NULL_TREE) + tree const_op0 = op_with_constant_singleton_value_range (op0); + tree const_op1 = op_with_constant_singleton_value_range (op1); + if (const_op0 || const_op1) { - tree tem = fold_binary (code, expr_type, op0, op1); + tree tem = fold_binary (code, expr_type, + const_op0 ? const_op0 : op0, + const_op1 ? const_op1 : op1); if (tem && is_gimple_min_invariant (tem) && !is_overflow_infinity (tem)) |