Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard.
2017-10-23 Richard Biener <rguent...@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. Index: gcc/graphite-isl-ast-to-gimple.c =================================================================== --- gcc/graphite-isl-ast-to-gimple.c (revision 253998) +++ gcc/graphite-isl-ast-to-gimple.c (working copy) @@ -1175,22 +1194,28 @@ graphite_copy_stmts_from_block (basic_bl 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); } Index: gcc/testsuite/gfortran.dg/graphite/pr82672.f90 =================================================================== --- gcc/testsuite/gfortran.dg/graphite/pr82672.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/graphite/pr82672.f90 (working copy) @@ -0,0 +1,33 @@ +! { dg-do compile } +! { dg-options "-O2 -floop-nest-optimize" } + + character(len=20,kind=4) :: s4 + character(len=20,kind=1) :: s1 + + s1 = "foo\u0000" + s1 = "foo\u00ff" + s1 = "foo\u0100" + s1 = "foo\u0101" + s1 = "foo\U00000101" + + s1 = 4_"foo bar" + s1 = 4_"foo\u00ff" + s1 = 4_"foo\u0101" + s1 = 4_"foo\u1101" + s1 = 4_"foo\UFFFFFFFF" + + s4 = "foo\u0000" + s4 = "foo\u00ff" + s4 = "foo\u0100" + s4 = "foo\U00000100" + + s4 = 4_"foo bar" + s4 = 4_"\xFF\x96" + s4 = 4_"\x00\x96" + s4 = 4_"foo\u00ff" + s4 = 4_"foo\u0101" + s4 = 4_"foo\u1101" + s4 = 4_"foo\Uab98EF56" + s4 = 4_"foo\UFFFFFFFF" + +end