This fixes PR55111.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2012-10-30  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/55111
        * tree-ssa-pre.c (eliminate_insert): Properly fold the built
        stmt.

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

Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c  (revision 192983)
--- gcc/tree-ssa-pre.c  (working copy)
*************** eliminate_insert (gimple_stmt_iterator *
*** 3996,4003 ****
  
    tree res = make_temp_ssa_name (TREE_TYPE (val), NULL, "pretmp");
    gimple tem = gimple_build_assign (res,
!                                   build1 (TREE_CODE (expr),
!                                           TREE_TYPE (expr), leader));
    gsi_insert_before (gsi, tem, GSI_SAME_STMT);
    VN_INFO_GET (res)->valnum = val;
  
--- 3996,4003 ----
  
    tree res = make_temp_ssa_name (TREE_TYPE (val), NULL, "pretmp");
    gimple tem = gimple_build_assign (res,
!                                   fold_build1 (TREE_CODE (expr),
!                                                TREE_TYPE (expr), leader));
    gsi_insert_before (gsi, tem, GSI_SAME_STMT);
    VN_INFO_GET (res)->valnum = val;
  
Index: gcc/testsuite/gcc.dg/torture/pr55111.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr55111.c      (revision 0)
--- gcc/testsuite/gcc.dg/torture/pr55111.c      (working copy)
***************
*** 0 ****
--- 1,24 ----
+ /* { dg-do compile } */
+ 
+ int a, b, c;
+ long d;
+ unsigned long *e;
+ 
+ int f(void)
+ {
+   for(;; a++)
+     {
+       if(c)
+       {
+         for(b = d = 0; b < 1; b++)
+           e = &d;
+ 
+         --*e;
+ 
+         if(d > 0)
+           a = 0;
+ 
+         return d;
+       }
+     }
+ }

Reply via email to