re PR tree-optimization/82672 ([GRAPHITE] ICE in verify_gimple_in_cfg)
authorRichard Biener <rguenth@gcc.gnu.org>
Tue, 24 Oct 2017 07:02:48 +0000 (07:02 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 24 Oct 2017 07:02:48 +0000 (07:02 +0000)
2017-10-23  Richard Biener  <rguenther@suse.de>

PR tree-optimization/82672
* graphite-isl-ast-to-gimple.c (graphite_copy_stmts_from_block):
Fold the stmt if we propagated into it.

* gfortran.dg/graphite/pr82672.f90: New testcase.

From-SVN: r254036

gcc/graphite-isl-ast-to-gimple.c

index b39ac5441c3cccb89e652c3cf1f4dbb266f9cfed..16570e16855725f0b0280fa6a730997e0f10f75a 100644 (file)
@@ -1175,22 +1175,28 @@ graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb,
       ssa_op_iter iter;
       use_operand_p use_p;
       if (!is_gimple_debug (copy))
-       FOR_EACH_SSA_USE_OPERAND (use_p, copy, iter, SSA_OP_USE)
-         {
-           tree old_name = USE_FROM_PTR (use_p);
-
-           if (TREE_CODE (old_name) != SSA_NAME
-               || SSA_NAME_IS_DEFAULT_DEF (old_name)
-               || ! scev_analyzable_p (old_name, region->region))
-             continue;
-
-           gimple_seq stmts = NULL;
-           tree new_name = get_rename_from_scev (old_name, &stmts,
-                                                 bb->loop_father, iv_map);
-           if (! codegen_error_p ())
-             gsi_insert_earliest (stmts);
-           replace_exp (use_p, new_name);
-         }
+       {
+         bool changed = false;
+         FOR_EACH_SSA_USE_OPERAND (use_p, copy, iter, SSA_OP_USE)
+           {
+             tree old_name = USE_FROM_PTR (use_p);
+
+             if (TREE_CODE (old_name) != SSA_NAME
+                 || SSA_NAME_IS_DEFAULT_DEF (old_name)
+                 || ! scev_analyzable_p (old_name, region->region))
+               continue;
+
+             gimple_seq stmts = NULL;
+             tree new_name = get_rename_from_scev (old_name, &stmts,
+                                                   bb->loop_father, iv_map);
+             if (! codegen_error_p ())
+               gsi_insert_earliest (stmts);
+             replace_exp (use_p, new_name);
+             changed = true;
+           }
+         if (changed)
+           fold_stmt_inplace (&gsi_tgt);
+       }
 
       update_stmt (copy);
     }