diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-09-08 16:31:43 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-09-08 16:31:43 +0000 |
commit | 0cce97a638ada18d399567b3f500827d9ae19d0e (patch) | |
tree | aee1d6b6b943eaad16bcc7f6620c5cb7275d2694 /gcc | |
parent | 1a51554b2fb99c743d635cee3bdcb36e1fe12c9f (diff) | |
download | gcc-0cce97a638ada18d399567b3f500827d9ae19d0e.tar.gz |
2008-09-08 Richard Guenther <rguenther@suse.de>
PR tree-optimization/37421
* tree-ssa-sccvn.c (visit_copy): Make sure to fully
valueize the RHS.
* g++.dg/torture/pr37421.C: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@140111 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/g++.dg/torture/pr37421.C | 39 | ||||
-rw-r--r-- | gcc/tree-ssa-sccvn.c | 10 |
4 files changed, 57 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 15848c2d0e4..e8d4c0303f8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-09-08 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/37421 + * tree-ssa-sccvn.c (visit_copy): Make sure to fully + valueize the RHS. + 2008-09-08 Jakub Jelinek <jakub@redhat.com> PR middle-end/37415 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 219fa164975..e136c69091e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-09-08 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/37421 + * g++.dg/torture/pr37421.C: New testcase. + 2008-09-08 Daniel Kraft <d@domob.eu> PR fortran/36167 diff --git a/gcc/testsuite/g++.dg/torture/pr37421.C b/gcc/testsuite/g++.dg/torture/pr37421.C new file mode 100644 index 00000000000..4b8447eac49 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr37421.C @@ -0,0 +1,39 @@ +/* { dg-do compile } */ + +#include <stdio.h> +#include <string.h> + +inline int +bci (const float &source) +{ + int dest; + memcpy (&dest, &source, sizeof (dest)); + return dest; +} + +inline float +bcf (const int &source) +{ + float dest; + memcpy (&dest, &source, sizeof (dest)); + return dest; +} + +float +Foo () +{ + const int foo = bci (0.0f); + int bar = foo; + const int baz = foo & 1; + if (!baz && (foo & 2)) + bar = 0; + return bcf (bar); +} + +int +main () +{ + printf ("Foo() = %f\n", Foo()); + return 0; +} + diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 0b995d6837d..09b2ee8fffd 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -1607,13 +1607,17 @@ static bool visit_copy (tree lhs, tree rhs) { /* Follow chains of copies to their destination. */ - while (SSA_VAL (rhs) != rhs && TREE_CODE (SSA_VAL (rhs)) == SSA_NAME) + while (TREE_CODE (rhs) == SSA_NAME + && SSA_VAL (rhs) != rhs) rhs = SSA_VAL (rhs); /* The copy may have a more interesting constant filled expression (we don't, since we know our RHS is just an SSA name). */ - VN_INFO (lhs)->has_constants = VN_INFO (rhs)->has_constants; - VN_INFO (lhs)->expr = VN_INFO (rhs)->expr; + if (TREE_CODE (rhs) == SSA_NAME) + { + VN_INFO (lhs)->has_constants = VN_INFO (rhs)->has_constants; + VN_INFO (lhs)->expr = VN_INFO (rhs)->expr; + } return set_ssa_val_to (lhs, rhs); } |