This fixes an oversight of my patch folding the added stmt in PRE - 
failing to update it.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2011-10-18  Richard Guenther  <rguent...@suse.de>

        PR tree-optimization/50767
        * tree-ssa-pre.c (create_expression_by_pieces): Update the
        folded statement.

        * gcc.dg/torture/pr50767.c: New testcase.

Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c  (revision 180127)
--- gcc/tree-ssa-pre.c  (working copy)
*************** create_expression_by_pieces (basic_block
*** 3188,3194 ****
  
    /* Fold the last statement.  */
    gsi = gsi_last (*stmts);
!   fold_stmt_inplace (&gsi);
  
    /* Add a value number to the temporary.
       The value may already exist in either NEW_SETS, or AVAIL_OUT, because
--- 3188,3195 ----
  
    /* Fold the last statement.  */
    gsi = gsi_last (*stmts);
!   if (fold_stmt_inplace (&gsi))
!     update_stmt (gsi_stmt (gsi));
  
    /* Add a value number to the temporary.
       The value may already exist in either NEW_SETS, or AVAIL_OUT, because
Index: gcc/testsuite/gcc.dg/torture/pr50767.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr50767.c      (revision 0)
--- gcc/testsuite/gcc.dg/torture/pr50767.c      (revision 0)
***************
*** 0 ****
--- 1,21 ----
+ /* { dg-do compile } */
+ /* { dg-options "-fno-tree-copy-prop -fno-tree-dominator-opts" } */
+ 
+ struct S
+ {
+   struct S *s;
+ };
+ 
+ static struct S *ss;
+ struct S *s;
+ 
+ void bar(void);
+ 
+ void foo(void)
+ {
+   for (;;)
+     {
+       s->s = ss;
+       bar ();
+     }
+ }

Reply via email to