comparison gcc/tree-ssa-loop-manip.c @ 63:b7f97abdc517 gcc-4.6-20100522

update gcc from gcc-4.5.0 to gcc-4.6
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Mon, 24 May 2010 12:47:05 +0900
parents 77e2b8dfacca
children f6334be47118
comparison
equal deleted inserted replaced
56:3c8a44c06a95 63:b7f97abdc517
1 /* High-level loop manipulation functions. 1 /* High-level loop manipulation functions.
2 Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. 2 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010
3 Free Software Foundation, Inc.
3 4
4 This file is part of GCC. 5 This file is part of GCC.
5 6
6 GCC is free software; you can redistribute it and/or modify it 7 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the 8 under the terms of the GNU General Public License as published by the
20 #include "config.h" 21 #include "config.h"
21 #include "system.h" 22 #include "system.h"
22 #include "coretypes.h" 23 #include "coretypes.h"
23 #include "tm.h" 24 #include "tm.h"
24 #include "tree.h" 25 #include "tree.h"
25 #include "rtl.h"
26 #include "tm_p.h" 26 #include "tm_p.h"
27 #include "hard-reg-set.h"
28 #include "basic-block.h" 27 #include "basic-block.h"
29 #include "output.h" 28 #include "output.h"
30 #include "diagnostic.h" 29 #include "diagnostic.h"
31 #include "tree-flow.h" 30 #include "tree-flow.h"
32 #include "tree-dump.h" 31 #include "tree-dump.h"
437 436
438 FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, SSA_OP_ALL_USES) 437 FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, SSA_OP_ALL_USES)
439 check_loop_closed_ssa_use (bb, var); 438 check_loop_closed_ssa_use (bb, var);
440 } 439 }
441 440
442 /* Checks that invariants of the loop closed ssa form are preserved. */ 441 /* Checks that invariants of the loop closed ssa form are preserved.
442 Call verify_ssa when VERIFY_SSA_P is true. */
443 443
444 void 444 void
445 verify_loop_closed_ssa (void) 445 verify_loop_closed_ssa (bool verify_ssa_p)
446 { 446 {
447 basic_block bb; 447 basic_block bb;
448 gimple_stmt_iterator bsi; 448 gimple_stmt_iterator bsi;
449 gimple phi; 449 gimple phi;
450 edge e; 450 edge e;
451 edge_iterator ei; 451 edge_iterator ei;
452 452
453 if (number_of_loops () <= 1) 453 if (number_of_loops () <= 1)
454 return; 454 return;
455 455
456 verify_ssa (false); 456 if (verify_ssa_p)
457 verify_ssa (false);
457 458
458 FOR_EACH_BB (bb) 459 FOR_EACH_BB (bb)
459 { 460 {
460 for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi)) 461 for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi))
461 { 462 {
613 if (!loops_state_satisfies_p (LOOPS_HAVE_PREHEADERS)) 614 if (!loops_state_satisfies_p (LOOPS_HAVE_PREHEADERS))
614 return false; 615 return false;
615 616
616 #ifdef ENABLE_CHECKING 617 #ifdef ENABLE_CHECKING
617 if (loops_state_satisfies_p (LOOP_CLOSED_SSA)) 618 if (loops_state_satisfies_p (LOOP_CLOSED_SSA))
618 verify_loop_closed_ssa (); 619 verify_loop_closed_ssa (true);
619 #endif 620 #endif
620 621
621 first_new_block = last_basic_block; 622 first_new_block = last_basic_block;
622 if (!duplicate_loop_to_header_edge (loop, e, ndupl, wont_exit, 623 if (!duplicate_loop_to_header_edge (loop, e, ndupl, wont_exit,
623 orig, to_remove, flags)) 624 orig, to_remove, flags))
1092 1093
1093 #ifdef ENABLE_CHECKING 1094 #ifdef ENABLE_CHECKING
1094 verify_flow_info (); 1095 verify_flow_info ();
1095 verify_dominators (CDI_DOMINATORS); 1096 verify_dominators (CDI_DOMINATORS);
1096 verify_loop_structure (); 1097 verify_loop_structure ();
1097 verify_loop_closed_ssa (); 1098 verify_loop_closed_ssa (true);
1098 #endif 1099 #endif
1099 } 1100 }
1100 1101
1101 /* Wrapper over tree_transform_and_unroll_loop for case we do not 1102 /* Wrapper over tree_transform_and_unroll_loop for case we do not
1102 want to transform the loop before unrolling. The meaning 1103 want to transform the loop before unrolling. The meaning
1179 /* Bases all the induction variables in LOOP on a single induction 1180 /* Bases all the induction variables in LOOP on a single induction
1180 variable (unsigned with base 0 and step 1), whose final value is 1181 variable (unsigned with base 0 and step 1), whose final value is
1181 compared with *NIT. When the IV type precision has to be larger 1182 compared with *NIT. When the IV type precision has to be larger
1182 than *NIT type precision, *NIT is converted to the larger type, the 1183 than *NIT type precision, *NIT is converted to the larger type, the
1183 conversion code is inserted before the loop, and *NIT is updated to 1184 conversion code is inserted before the loop, and *NIT is updated to
1184 the new definition. The induction variable is incremented in the 1185 the new definition. When BUMP_IN_LATCH is true, the induction
1185 loop latch. Return the induction variable that was created. */ 1186 variable is incremented in the loop latch, otherwise it is
1187 incremented in the loop header. Return the induction variable that
1188 was created. */
1186 1189
1187 tree 1190 tree
1188 canonicalize_loop_ivs (struct loop *loop, tree *nit) 1191 canonicalize_loop_ivs (struct loop *loop, tree *nit, bool bump_in_latch)
1189 { 1192 {
1190 unsigned precision = TYPE_PRECISION (TREE_TYPE (*nit)); 1193 unsigned precision = TYPE_PRECISION (TREE_TYPE (*nit));
1191 unsigned original_precision = precision; 1194 unsigned original_precision = precision;
1192 tree type, var_before; 1195 tree type, var_before;
1193 gimple_stmt_iterator gsi, psi; 1196 gimple_stmt_iterator gsi, psi;
1213 *nit = force_gimple_operand (*nit, &stmts, true, NULL_TREE); 1216 *nit = force_gimple_operand (*nit, &stmts, true, NULL_TREE);
1214 if (stmts) 1217 if (stmts)
1215 gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts); 1218 gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
1216 } 1219 }
1217 1220
1218 gsi = gsi_last_bb (loop->latch); 1221 gsi = gsi_last_bb (bump_in_latch ? loop->latch : loop->header);
1219 create_iv (build_int_cst_type (type, 0), build_int_cst (type, 1), NULL_TREE, 1222 create_iv (build_int_cst_type (type, 0), build_int_cst (type, 1), NULL_TREE,
1220 loop, &gsi, true, &var_before, NULL); 1223 loop, &gsi, bump_in_latch, &var_before, NULL);
1221 1224
1222 rewrite_all_phi_nodes_with_iv (loop, var_before); 1225 rewrite_all_phi_nodes_with_iv (loop, var_before);
1223 1226
1224 stmt = last_stmt (exit->src); 1227 stmt = last_stmt (exit->src);
1225 /* Make the loop exit if the control condition is not satisfied. */ 1228 /* Make the loop exit if the control condition is not satisfied. */