re PR tree-optimization/37421 (ICE in vn_reference_insert_pieces at tree-ssa-sccvn.c:1131)

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.

From-SVN: r140111
This commit is contained in:
Richard Guenther 2008-09-08 16:31:43 +00:00 committed by Richard Biener
parent 94c8a0cca5
commit 7220ca2b38
4 changed files with 57 additions and 3 deletions

View file

@ -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

View file

@ -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

View file

@ -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;
}

View file

@ -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);
}