comparison gcc/graphite.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 /* Gimple Represented as Polyhedra. 1 /* Gimple Represented as Polyhedra.
2 Copyright (C) 2006-2017 Free Software Foundation, Inc. 2 Copyright (C) 2006-2018 Free Software Foundation, Inc.
3 Contributed by Sebastian Pop <sebastian.pop@inria.fr>. 3 Contributed by Sebastian Pop <sebastian.pop@inria.fr>.
4 4
5 This file is part of GCC. 5 This file is part of GCC.
6 6
7 GCC is free software; you can redistribute it and/or modify 7 GCC is free software; you can redistribute it and/or modify
36 #include "diagnostic-core.h" 36 #include "diagnostic-core.h"
37 #include "cfgloop.h" 37 #include "cfgloop.h"
38 #include "tree-pass.h" 38 #include "tree-pass.h"
39 #include "params.h" 39 #include "params.h"
40 #include "pretty-print.h" 40 #include "pretty-print.h"
41 #include "cfganal.h"
41 42
42 #ifdef HAVE_isl 43 #ifdef HAVE_isl
43 #include "cfghooks.h" 44 #include "cfghooks.h"
44 #include "tree.h" 45 #include "tree.h"
45 #include "gimple.h" 46 #include "gimple.h"
224 } 225 }
225 226
226 /* Transforms LOOP to the canonical loop closed SSA form. */ 227 /* Transforms LOOP to the canonical loop closed SSA form. */
227 228
228 static void 229 static void
229 canonicalize_loop_closed_ssa (loop_p loop) 230 canonicalize_loop_closed_ssa (loop_p loop, edge e)
230 { 231 {
231 edge e = single_exit (loop);
232 basic_block bb; 232 basic_block bb;
233 gphi_iterator psi; 233 gphi_iterator psi;
234
235 if (!e || (e->flags & EDGE_COMPLEX))
236 return;
237 234
238 bb = e->dest; 235 bb = e->dest;
239 236
240 /* Make the loop-close PHI node BB contain only PHIs and have a 237 /* Make the loop-close PHI node BB contain only PHIs and have a
241 single predecessor. */ 238 single predecessor. */
311 308
312 - the basic block containing the close phi nodes does not contain 309 - the basic block containing the close phi nodes does not contain
313 other statements. 310 other statements.
314 311
315 - there exist only one phi node per definition in the loop. 312 - there exist only one phi node per definition in the loop.
313
314 In addition to that we also make sure that loop exit edges are
315 first in the successor edge vector. This is to make RPO order
316 as computed by pre_and_rev_post_order_compute be consistent with
317 what initial schedule generation expects.
316 */ 318 */
317 319
318 static void 320 static void
319 canonicalize_loop_closed_ssa_form (void) 321 canonicalize_loop_form (void)
320 { 322 {
321 loop_p loop; 323 loop_p loop;
322 FOR_EACH_LOOP (loop, LI_FROM_INNERMOST) 324 FOR_EACH_LOOP (loop, LI_FROM_INNERMOST)
323 canonicalize_loop_closed_ssa (loop); 325 {
326 edge e = single_exit (loop);
327 if (!e || (e->flags & (EDGE_COMPLEX|EDGE_FAKE)))
328 continue;
329
330 canonicalize_loop_closed_ssa (loop, e);
331
332 /* If the exit is not first in the edge vector make it so. */
333 if (e != EDGE_SUCC (e->src, 0))
334 {
335 unsigned ei;
336 for (ei = 0; EDGE_SUCC (e->src, ei) != e; ++ei)
337 ;
338 std::swap (EDGE_SUCC (e->src, ei), EDGE_SUCC (e->src, 0));
339 }
340 }
341
342 /* We can end up releasing duplicate exit PHIs and also introduce
343 additional copies so the cached information isn't correct anymore. */
344 scev_reset ();
324 345
325 checking_verify_loop_closed_ssa (true); 346 checking_verify_loop_closed_ssa (true);
326 } 347 }
327 348
328 isl_ctx *the_isl_ctx; 349 isl_ctx *the_isl_ctx;
344 if (parallelized_function_p (cfun->decl)) 365 if (parallelized_function_p (cfun->decl))
345 return; 366 return;
346 367
347 calculate_dominance_info (CDI_DOMINATORS); 368 calculate_dominance_info (CDI_DOMINATORS);
348 369
370 /* We rely on post-dominators during merging of SESE regions so those
371 have to be meaningful. */
372 connect_infinite_loops_to_exit ();
373
349 ctx = isl_ctx_alloc (); 374 ctx = isl_ctx_alloc ();
350 isl_options_set_on_error (ctx, ISL_ON_ERROR_ABORT); 375 isl_options_set_on_error (ctx, ISL_ON_ERROR_ABORT);
351 the_isl_ctx = ctx; 376 the_isl_ctx = ctx;
352 377
353 sort_sibling_loops (cfun); 378 sort_sibling_loops (cfun);
354 canonicalize_loop_closed_ssa_form (); 379 canonicalize_loop_form ();
355 380
356 /* Print the loop structure. */ 381 /* Print the loop structure. */
357 if (dump_file && (dump_flags & TDF_DETAILS)) 382 if (dump_file && (dump_flags & TDF_DETAILS))
358 { 383 {
359 print_loops (dump_file, 2); 384 print_loops (dump_file, 2);
361 } 386 }
362 387
363 calculate_dominance_info (CDI_POST_DOMINATORS); 388 calculate_dominance_info (CDI_POST_DOMINATORS);
364 build_scops (&scops); 389 build_scops (&scops);
365 free_dominance_info (CDI_POST_DOMINATORS); 390 free_dominance_info (CDI_POST_DOMINATORS);
391
392 /* Remove the fake exits before transform given they are not reflected
393 in loop structures we end up verifying. */
394 remove_fake_exit_edges ();
366 395
367 if (dump_file && (dump_flags & TDF_DETAILS)) 396 if (dump_file && (dump_flags & TDF_DETAILS))
368 { 397 {
369 print_graphite_statistics (dump_file, scops); 398 print_graphite_statistics (dump_file, scops);
370 print_global_statistics (dump_file); 399 print_global_statistics (dump_file);
381 continue; 410 continue;
382 411
383 changed = true; 412 changed = true;
384 if (graphite_regenerate_ast_isl (scop)) 413 if (graphite_regenerate_ast_isl (scop))
385 { 414 {
386 location_t loc = find_loop_location 415 dump_user_location_t loc = find_loop_location
387 (scops[i]->scop_info->region.entry->dest->loop_father); 416 (scops[i]->scop_info->region.entry->dest->loop_father);
388 dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, 417 dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
389 "loop nest optimized\n"); 418 "loop nest optimized\n");
390 } 419 }
391 } 420 }
422 cleanup_tree_cfg (); 451 cleanup_tree_cfg ();
423 profile_status_for_fn (cfun) = PROFILE_ABSENT; 452 profile_status_for_fn (cfun) = PROFILE_ABSENT;
424 release_recorded_exits (cfun); 453 release_recorded_exits (cfun);
425 tree_estimate_probability (false); 454 tree_estimate_probability (false);
426 } 455 }
427
428 } 456 }
429 457
430 #else /* If isl is not available: #ifndef HAVE_isl. */ 458 #else /* If isl is not available: #ifndef HAVE_isl. */
431 459
432 static void 460 static void