From a68f286ccc36bc6d5e483383e490e2531307466b Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 13 Oct 2017 07:02:55 +0000 Subject: re PR tree-optimization/82451 ([GRAPHITE] codegen error in get_rename_from_scev) 2017-10-13 Richard Biener PR tree-optimization/82451 Revert 2017-10-02 Richard Biener PR tree-optimization/82355 * graphite-isl-ast-to-gimple.c (build_iv_mapping): Also build a mapping for the enclosing loop but avoid generating one for the loop tree root. (copy_bb_and_scalar_dependences): Remove premature codegen error on PHIs in blocks duplicated into multiple places. * graphite-scop-detection.c (scop_detection::stmt_has_simple_data_refs_p): For a loop not in the region use it as loop and nest to analyze the DR in. (try_generate_gimple_bb): Likewise. * graphite-sese-to-poly.c (extract_affine_chrec): Adjust. (add_loop_constraints): For blocks in a loop not in the region create a dimension with a single iteration. * sese.h (gbb_loop_at_index): Remove assert. * cfgloop.c (loop_preheader_edge): For the loop tree root return the single successor of the entry block. * graphite-isl-ast-to-gimple.c (graphite_regenerate_ast_isl): Reset the SCEV hashtable and niters. * graphite-scop-detection.c (scop_detection::graphite_can_represent_scev): Add SCOP parameter, assert that we only have POLYNOMIAL_CHREC that vary in loops contained in the region. (scop_detection::graphite_can_represent_expr): Adjust. (scop_detection::stmt_has_simple_data_refs_p): For loops not in the region set loop to NULL. The nest is now the entry edge to the region. (try_generate_gimple_bb): Likewise. * sese.c (scalar_evolution_in_region): Adjust for instantiate_scev change. * tree-data-ref.h (graphite_find_data_references_in_stmt): Make nest parameter the edge into the region. (create_data_ref): Likewise. * tree-data-ref.c (dr_analyze_indices): Make nest parameter an entry edge into a region and adjust instantiate_scev calls. (create_data_ref): Likewise. (graphite_find_data_references_in_stmt): Likewise. (find_data_references_in_stmt): Pass the loop preheader edge from the nest argument. * tree-scalar-evolution.h (instantiate_scev): Make instantiate_below parameter the edge into the region. (instantiate_parameters): Use the loop preheader edge as entry. * tree-scalar-evolution.c (analyze_scalar_evolution): Handle NULL loop. (get_instantiated_value_entry): Make instantiate_below parameter the edge into the region. (instantiate_scev_name): Likewise. Adjust dominance checks, when we cannot use loop-based instantiation instantiate by walking use-def chains. (instantiate_scev_poly): Adjust. (instantiate_scev_binary): Likewise. (instantiate_scev_convert): Likewise. (instantiate_scev_not): Likewise. (instantiate_array_ref): Remove. (instantiate_scev_3): Likewise. (instantiate_scev_2): Likewise. (instantiate_scev_1): Likewise. (instantiate_scev_r): Do not blindly handle N-operand trees. Do not instantiate array-refs. Handle all constants and invariants. (instantiate_scev): Make instantiate_below parameter the edge into the region. (resolve_mixers): Use the loop preheader edge for the region parameter to instantiate_scev_r. * tree-ssa-loop-prefetch.c (determine_loop_nest_reuse): Adjust. * gcc.dg/graphite/pr82451.c: New testcase. * gfortran.dg/graphite/id-27.f90: Likewise. * gfortran.dg/graphite/pr82451.f: Likewise. From-SVN: r253707 --- gcc/graphite-sese-to-poly.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'gcc/graphite-sese-to-poly.c') diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index 50b6fe8d..ed6cbec 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -86,7 +86,7 @@ extract_affine_chrec (scop_p s, tree e, __isl_take isl_space *space) isl_pw_aff *lhs = extract_affine (s, CHREC_LEFT (e), isl_space_copy (space)); isl_pw_aff *rhs = extract_affine (s, CHREC_RIGHT (e), isl_space_copy (space)); isl_local_space *ls = isl_local_space_from_space (space); - unsigned pos = sese_loop_depth (s->scop_info->region, get_chrec_loop (e)); + unsigned pos = sese_loop_depth (s->scop_info->region, get_chrec_loop (e)) - 1; isl_aff *loop = isl_aff_set_coefficient_si (isl_aff_zero_on_domain (ls), isl_dim_in, pos, 1); isl_pw_aff *l = isl_pw_aff_from_aff (loop); @@ -763,10 +763,10 @@ add_loop_constraints (scop_p scop, __isl_take isl_set *domain, loop_p loop, return domain; const sese_l ®ion = scop->scop_info->region; if (!loop_in_sese_p (loop, region)) - ; - else - /* Recursion all the way up to the context loop. */ - domain = add_loop_constraints (scop, domain, loop_outer (loop), context); + return domain; + + /* Recursion all the way up to the context loop. */ + domain = add_loop_constraints (scop, domain, loop_outer (loop), context); /* Then, build constraints over the loop in post-order: outer to inner. */ @@ -777,21 +777,6 @@ add_loop_constraints (scop_p scop, __isl_take isl_set *domain, loop_p loop, domain = add_iter_domain_dimension (domain, loop, scop); isl_space *space = isl_set_get_space (domain); - if (!loop_in_sese_p (loop, region)) - { - /* 0 == loop_i */ - isl_local_space *ls = isl_local_space_from_space (space); - isl_constraint *c = isl_equality_alloc (ls); - c = isl_constraint_set_coefficient_si (c, isl_dim_set, loop_index, 1); - if (dump_file) - { - fprintf (dump_file, "[sese-to-poly] adding constraint to the domain: "); - print_isl_constraint (dump_file, c); - } - domain = isl_set_add_constraint (domain, c); - return domain; - } - /* 0 <= loop_i */ isl_local_space *ls = isl_local_space_from_space (isl_space_copy (space)); isl_constraint *c = isl_inequality_alloc (ls); -- cgit v1.1