This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR34241, ICE in forwprop
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 27 Nov 2007 16:05:40 +0100 (CET)
- Subject: [PATCH] Fix PR34241, ICE in forwprop
With propagating (T)&x we now may recognize that as part of a copy-/
conversion chain. Fixed by strengthening the check.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to mainline.
Richard.
2007-11-27 Richard Guenther <rguenther@suse.de>
PR tree-optimization/34241
* tree-ssa-forwprop.c (forward_propagate_addr_expr): Make sure
to only delete real conversion chains.
* g++.dg/torture/pr34241.C: New testcase.
Index: tree-ssa-forwprop.c
===================================================================
*** tree-ssa-forwprop.c (revision 130464)
--- tree-ssa-forwprop.c (working copy)
*************** forward_propagate_addr_expr (tree name,
*** 685,690 ****
--- 685,691 ----
FOR_EACH_IMM_USE_STMT (use_stmt, iter, name)
{
bool result;
+ tree use_rhs;
/* If the use is not in a simple assignment statement, then
there is nothing we can do. */
*************** forward_propagate_addr_expr (tree name,
*** 712,722 ****
pop_stmt_changes (&use_stmt);
/* Remove intermediate now unused copy and conversion chains. */
if (result
&& TREE_CODE (GIMPLE_STMT_OPERAND (use_stmt, 0)) == SSA_NAME
! && (TREE_CODE (GIMPLE_STMT_OPERAND (use_stmt, 1)) == SSA_NAME
! || TREE_CODE (GIMPLE_STMT_OPERAND (use_stmt, 1)) == NOP_EXPR
! || TREE_CODE (GIMPLE_STMT_OPERAND (use_stmt, 1)) == CONVERT_EXPR))
{
block_stmt_iterator bsi = bsi_for_stmt (use_stmt);
release_defs (use_stmt);
--- 713,725 ----
pop_stmt_changes (&use_stmt);
/* Remove intermediate now unused copy and conversion chains. */
+ use_rhs = GIMPLE_STMT_OPERAND (use_stmt, 1);
if (result
&& TREE_CODE (GIMPLE_STMT_OPERAND (use_stmt, 0)) == SSA_NAME
! && (TREE_CODE (use_rhs) == SSA_NAME
! || ((TREE_CODE (use_rhs) == NOP_EXPR
! || TREE_CODE (use_rhs) == CONVERT_EXPR)
! && TREE_CODE (TREE_OPERAND (use_rhs, 0)) == SSA_NAME)))
{
block_stmt_iterator bsi = bsi_for_stmt (use_stmt);
release_defs (use_stmt);
Index: testsuite/g++.dg/torture/pr34241.C
===================================================================
*** testsuite/g++.dg/torture/pr34241.C (revision 0)
--- testsuite/g++.dg/torture/pr34241.C (revision 0)
***************
*** 0 ****
--- 1,18 ----
+ /* { dg-do compile } */
+
+ inline void *operator new (__SIZE_TYPE__, void *__p) throw ()
+ {
+ return __p;
+ }
+ struct A
+ {
+ A(int, double);
+ inline explicit A (int pattern, bool cs)
+ {
+ new (this) A (pattern, double(cs));
+ }
+ };
+ A test ()
+ {
+ const A a (42, true);
+ }