tree-ssa-loop.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. /* Loop optimizations over tree-ssa.
  2. Copyright (C) 2003-2015 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by the
  6. Free Software Foundation; either version 3, or (at your option) any
  7. later version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. #include "config.h"
  16. #include "system.h"
  17. #include "coretypes.h"
  18. #include "tm.h"
  19. #include "hash-set.h"
  20. #include "machmode.h"
  21. #include "vec.h"
  22. #include "double-int.h"
  23. #include "input.h"
  24. #include "alias.h"
  25. #include "symtab.h"
  26. #include "wide-int.h"
  27. #include "inchash.h"
  28. #include "tree.h"
  29. #include "fold-const.h"
  30. #include "tm_p.h"
  31. #include "predict.h"
  32. #include "hard-reg-set.h"
  33. #include "input.h"
  34. #include "function.h"
  35. #include "dominance.h"
  36. #include "cfg.h"
  37. #include "basic-block.h"
  38. #include "tree-ssa-alias.h"
  39. #include "internal-fn.h"
  40. #include "gimple-expr.h"
  41. #include "is-a.h"
  42. #include "gimple.h"
  43. #include "gimple-iterator.h"
  44. #include "tree-ssa-loop-ivopts.h"
  45. #include "tree-ssa-loop-manip.h"
  46. #include "tree-ssa-loop-niter.h"
  47. #include "tree-ssa-loop.h"
  48. #include "tree-pass.h"
  49. #include "cfgloop.h"
  50. #include "flags.h"
  51. #include "tree-inline.h"
  52. #include "tree-scalar-evolution.h"
  53. #include "diagnostic-core.h"
  54. #include "tree-vectorizer.h"
  55. /* A pass making sure loops are fixed up. */
  56. namespace {
  57. const pass_data pass_data_fix_loops =
  58. {
  59. GIMPLE_PASS, /* type */
  60. "fix_loops", /* name */
  61. OPTGROUP_LOOP, /* optinfo_flags */
  62. TV_TREE_LOOP, /* tv_id */
  63. PROP_cfg, /* properties_required */
  64. 0, /* properties_provided */
  65. 0, /* properties_destroyed */
  66. 0, /* todo_flags_start */
  67. 0, /* todo_flags_finish */
  68. };
  69. class pass_fix_loops : public gimple_opt_pass
  70. {
  71. public:
  72. pass_fix_loops (gcc::context *ctxt)
  73. : gimple_opt_pass (pass_data_fix_loops, ctxt)
  74. {}
  75. /* opt_pass methods: */
  76. virtual bool gate (function *) { return flag_tree_loop_optimize; }
  77. virtual unsigned int execute (function *fn);
  78. }; // class pass_fix_loops
  79. unsigned int
  80. pass_fix_loops::execute (function *)
  81. {
  82. if (loops_state_satisfies_p (LOOPS_NEED_FIXUP))
  83. {
  84. calculate_dominance_info (CDI_DOMINATORS);
  85. fix_loop_structure (NULL);
  86. }
  87. return 0;
  88. }
  89. } // anon namespace
  90. gimple_opt_pass *
  91. make_pass_fix_loops (gcc::context *ctxt)
  92. {
  93. return new pass_fix_loops (ctxt);
  94. }
  95. /* Gate for loop pass group. The group is controlled by -ftree-loop-optimize
  96. but we also avoid running it when the IL doesn't contain any loop. */
  97. static bool
  98. gate_loop (function *fn)
  99. {
  100. if (!flag_tree_loop_optimize)
  101. return false;
  102. /* For -fdump-passes which runs before loop discovery print the
  103. state of -ftree-loop-optimize. */
  104. if (!loops_for_fn (fn))
  105. return true;
  106. return number_of_loops (fn) > 1;
  107. }
  108. /* The loop superpass. */
  109. namespace {
  110. const pass_data pass_data_tree_loop =
  111. {
  112. GIMPLE_PASS, /* type */
  113. "loop", /* name */
  114. OPTGROUP_LOOP, /* optinfo_flags */
  115. TV_TREE_LOOP, /* tv_id */
  116. PROP_cfg, /* properties_required */
  117. 0, /* properties_provided */
  118. 0, /* properties_destroyed */
  119. 0, /* todo_flags_start */
  120. 0, /* todo_flags_finish */
  121. };
  122. class pass_tree_loop : public gimple_opt_pass
  123. {
  124. public:
  125. pass_tree_loop (gcc::context *ctxt)
  126. : gimple_opt_pass (pass_data_tree_loop, ctxt)
  127. {}
  128. /* opt_pass methods: */
  129. virtual bool gate (function *fn) { return gate_loop (fn); }
  130. }; // class pass_tree_loop
  131. } // anon namespace
  132. gimple_opt_pass *
  133. make_pass_tree_loop (gcc::context *ctxt)
  134. {
  135. return new pass_tree_loop (ctxt);
  136. }
  137. /* The no-loop superpass. */
  138. namespace {
  139. const pass_data pass_data_tree_no_loop =
  140. {
  141. GIMPLE_PASS, /* type */
  142. "no_loop", /* name */
  143. OPTGROUP_NONE, /* optinfo_flags */
  144. TV_TREE_NOLOOP, /* tv_id */
  145. PROP_cfg, /* properties_required */
  146. 0, /* properties_provided */
  147. 0, /* properties_destroyed */
  148. 0, /* todo_flags_start */
  149. 0, /* todo_flags_finish */
  150. };
  151. class pass_tree_no_loop : public gimple_opt_pass
  152. {
  153. public:
  154. pass_tree_no_loop (gcc::context *ctxt)
  155. : gimple_opt_pass (pass_data_tree_no_loop, ctxt)
  156. {}
  157. /* opt_pass methods: */
  158. virtual bool gate (function *fn) { return !gate_loop (fn); }
  159. }; // class pass_tree_no_loop
  160. } // anon namespace
  161. gimple_opt_pass *
  162. make_pass_tree_no_loop (gcc::context *ctxt)
  163. {
  164. return new pass_tree_no_loop (ctxt);
  165. }
  166. /* Loop optimizer initialization. */
  167. namespace {
  168. const pass_data pass_data_tree_loop_init =
  169. {
  170. GIMPLE_PASS, /* type */
  171. "loopinit", /* name */
  172. OPTGROUP_LOOP, /* optinfo_flags */
  173. TV_NONE, /* tv_id */
  174. PROP_cfg, /* properties_required */
  175. 0, /* properties_provided */
  176. 0, /* properties_destroyed */
  177. 0, /* todo_flags_start */
  178. 0, /* todo_flags_finish */
  179. };
  180. class pass_tree_loop_init : public gimple_opt_pass
  181. {
  182. public:
  183. pass_tree_loop_init (gcc::context *ctxt)
  184. : gimple_opt_pass (pass_data_tree_loop_init, ctxt)
  185. {}
  186. /* opt_pass methods: */
  187. virtual unsigned int execute (function *);
  188. }; // class pass_tree_loop_init
  189. unsigned int
  190. pass_tree_loop_init::execute (function *fun ATTRIBUTE_UNUSED)
  191. {
  192. loop_optimizer_init (LOOPS_NORMAL
  193. | LOOPS_HAVE_RECORDED_EXITS);
  194. rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
  195. /* We might discover new loops, e.g. when turning irreducible
  196. regions into reducible. */
  197. scev_initialize ();
  198. return 0;
  199. }
  200. } // anon namespace
  201. gimple_opt_pass *
  202. make_pass_tree_loop_init (gcc::context *ctxt)
  203. {
  204. return new pass_tree_loop_init (ctxt);
  205. }
  206. /* Loop autovectorization. */
  207. namespace {
  208. const pass_data pass_data_vectorize =
  209. {
  210. GIMPLE_PASS, /* type */
  211. "vect", /* name */
  212. OPTGROUP_LOOP | OPTGROUP_VEC, /* optinfo_flags */
  213. TV_TREE_VECTORIZATION, /* tv_id */
  214. ( PROP_cfg | PROP_ssa ), /* properties_required */
  215. 0, /* properties_provided */
  216. 0, /* properties_destroyed */
  217. 0, /* todo_flags_start */
  218. 0, /* todo_flags_finish */
  219. };
  220. class pass_vectorize : public gimple_opt_pass
  221. {
  222. public:
  223. pass_vectorize (gcc::context *ctxt)
  224. : gimple_opt_pass (pass_data_vectorize, ctxt)
  225. {}
  226. /* opt_pass methods: */
  227. virtual bool gate (function *fun)
  228. {
  229. return flag_tree_loop_vectorize || fun->has_force_vectorize_loops;
  230. }
  231. virtual unsigned int execute (function *);
  232. }; // class pass_vectorize
  233. unsigned int
  234. pass_vectorize::execute (function *fun)
  235. {
  236. if (number_of_loops (fun) <= 1)
  237. return 0;
  238. return vectorize_loops ();
  239. }
  240. } // anon namespace
  241. gimple_opt_pass *
  242. make_pass_vectorize (gcc::context *ctxt)
  243. {
  244. return new pass_vectorize (ctxt);
  245. }
  246. /* Check the correctness of the data dependence analyzers. */
  247. namespace {
  248. const pass_data pass_data_check_data_deps =
  249. {
  250. GIMPLE_PASS, /* type */
  251. "ckdd", /* name */
  252. OPTGROUP_LOOP, /* optinfo_flags */
  253. TV_CHECK_DATA_DEPS, /* tv_id */
  254. ( PROP_cfg | PROP_ssa ), /* properties_required */
  255. 0, /* properties_provided */
  256. 0, /* properties_destroyed */
  257. 0, /* todo_flags_start */
  258. 0, /* todo_flags_finish */
  259. };
  260. class pass_check_data_deps : public gimple_opt_pass
  261. {
  262. public:
  263. pass_check_data_deps (gcc::context *ctxt)
  264. : gimple_opt_pass (pass_data_check_data_deps, ctxt)
  265. {}
  266. /* opt_pass methods: */
  267. virtual bool gate (function *) { return flag_check_data_deps != 0; }
  268. virtual unsigned int execute (function *);
  269. }; // class pass_check_data_deps
  270. unsigned int
  271. pass_check_data_deps::execute (function *fun)
  272. {
  273. if (number_of_loops (fun) <= 1)
  274. return 0;
  275. tree_check_data_deps ();
  276. return 0;
  277. }
  278. } // anon namespace
  279. gimple_opt_pass *
  280. make_pass_check_data_deps (gcc::context *ctxt)
  281. {
  282. return new pass_check_data_deps (ctxt);
  283. }
  284. /* Propagation of constants using scev. */
  285. namespace {
  286. const pass_data pass_data_scev_cprop =
  287. {
  288. GIMPLE_PASS, /* type */
  289. "sccp", /* name */
  290. OPTGROUP_LOOP, /* optinfo_flags */
  291. TV_SCEV_CONST, /* tv_id */
  292. ( PROP_cfg | PROP_ssa ), /* properties_required */
  293. 0, /* properties_provided */
  294. 0, /* properties_destroyed */
  295. 0, /* todo_flags_start */
  296. ( TODO_cleanup_cfg
  297. | TODO_update_ssa_only_virtuals ), /* todo_flags_finish */
  298. };
  299. class pass_scev_cprop : public gimple_opt_pass
  300. {
  301. public:
  302. pass_scev_cprop (gcc::context *ctxt)
  303. : gimple_opt_pass (pass_data_scev_cprop, ctxt)
  304. {}
  305. /* opt_pass methods: */
  306. virtual bool gate (function *) { return flag_tree_scev_cprop; }
  307. virtual unsigned int execute (function *) { return scev_const_prop (); }
  308. }; // class pass_scev_cprop
  309. } // anon namespace
  310. gimple_opt_pass *
  311. make_pass_scev_cprop (gcc::context *ctxt)
  312. {
  313. return new pass_scev_cprop (ctxt);
  314. }
  315. /* Record bounds on numbers of iterations of loops. */
  316. namespace {
  317. const pass_data pass_data_record_bounds =
  318. {
  319. GIMPLE_PASS, /* type */
  320. "*record_bounds", /* name */
  321. OPTGROUP_NONE, /* optinfo_flags */
  322. TV_TREE_LOOP_BOUNDS, /* tv_id */
  323. ( PROP_cfg | PROP_ssa ), /* properties_required */
  324. 0, /* properties_provided */
  325. 0, /* properties_destroyed */
  326. 0, /* todo_flags_start */
  327. 0, /* todo_flags_finish */
  328. };
  329. class pass_record_bounds : public gimple_opt_pass
  330. {
  331. public:
  332. pass_record_bounds (gcc::context *ctxt)
  333. : gimple_opt_pass (pass_data_record_bounds, ctxt)
  334. {}
  335. /* opt_pass methods: */
  336. virtual unsigned int execute (function *);
  337. }; // class pass_record_bounds
  338. unsigned int
  339. pass_record_bounds::execute (function *fun)
  340. {
  341. if (number_of_loops (fun) <= 1)
  342. return 0;
  343. estimate_numbers_of_iterations ();
  344. scev_reset ();
  345. return 0;
  346. }
  347. } // anon namespace
  348. gimple_opt_pass *
  349. make_pass_record_bounds (gcc::context *ctxt)
  350. {
  351. return new pass_record_bounds (ctxt);
  352. }
  353. /* Induction variable optimizations. */
  354. namespace {
  355. const pass_data pass_data_iv_optimize =
  356. {
  357. GIMPLE_PASS, /* type */
  358. "ivopts", /* name */
  359. OPTGROUP_LOOP, /* optinfo_flags */
  360. TV_TREE_LOOP_IVOPTS, /* tv_id */
  361. ( PROP_cfg | PROP_ssa ), /* properties_required */
  362. 0, /* properties_provided */
  363. 0, /* properties_destroyed */
  364. 0, /* todo_flags_start */
  365. TODO_update_ssa, /* todo_flags_finish */
  366. };
  367. class pass_iv_optimize : public gimple_opt_pass
  368. {
  369. public:
  370. pass_iv_optimize (gcc::context *ctxt)
  371. : gimple_opt_pass (pass_data_iv_optimize, ctxt)
  372. {}
  373. /* opt_pass methods: */
  374. virtual bool gate (function *) { return flag_ivopts != 0; }
  375. virtual unsigned int execute (function *);
  376. }; // class pass_iv_optimize
  377. unsigned int
  378. pass_iv_optimize::execute (function *fun)
  379. {
  380. if (number_of_loops (fun) <= 1)
  381. return 0;
  382. tree_ssa_iv_optimize ();
  383. return 0;
  384. }
  385. } // anon namespace
  386. gimple_opt_pass *
  387. make_pass_iv_optimize (gcc::context *ctxt)
  388. {
  389. return new pass_iv_optimize (ctxt);
  390. }
  391. /* Loop optimizer finalization. */
  392. static unsigned int
  393. tree_ssa_loop_done (void)
  394. {
  395. free_numbers_of_iterations_estimates ();
  396. scev_finalize ();
  397. loop_optimizer_finalize ();
  398. return 0;
  399. }
  400. namespace {
  401. const pass_data pass_data_tree_loop_done =
  402. {
  403. GIMPLE_PASS, /* type */
  404. "loopdone", /* name */
  405. OPTGROUP_LOOP, /* optinfo_flags */
  406. TV_NONE, /* tv_id */
  407. PROP_cfg, /* properties_required */
  408. 0, /* properties_provided */
  409. 0, /* properties_destroyed */
  410. 0, /* todo_flags_start */
  411. TODO_cleanup_cfg, /* todo_flags_finish */
  412. };
  413. class pass_tree_loop_done : public gimple_opt_pass
  414. {
  415. public:
  416. pass_tree_loop_done (gcc::context *ctxt)
  417. : gimple_opt_pass (pass_data_tree_loop_done, ctxt)
  418. {}
  419. /* opt_pass methods: */
  420. virtual unsigned int execute (function *) { return tree_ssa_loop_done (); }
  421. }; // class pass_tree_loop_done
  422. } // anon namespace
  423. gimple_opt_pass *
  424. make_pass_tree_loop_done (gcc::context *ctxt)
  425. {
  426. return new pass_tree_loop_done (ctxt);
  427. }
  428. /* Calls CBCK for each index in memory reference ADDR_P. There are two
  429. kinds situations handled; in each of these cases, the memory reference
  430. and DATA are passed to the callback:
  431. Access to an array: ARRAY_{RANGE_}REF (base, index). In this case we also
  432. pass the pointer to the index to the callback.
  433. Pointer dereference: INDIRECT_REF (addr). In this case we also pass the
  434. pointer to addr to the callback.
  435. If the callback returns false, the whole search stops and false is returned.
  436. Otherwise the function returns true after traversing through the whole
  437. reference *ADDR_P. */
  438. bool
  439. for_each_index (tree *addr_p, bool (*cbck) (tree, tree *, void *), void *data)
  440. {
  441. tree *nxt, *idx;
  442. for (; ; addr_p = nxt)
  443. {
  444. switch (TREE_CODE (*addr_p))
  445. {
  446. case SSA_NAME:
  447. return cbck (*addr_p, addr_p, data);
  448. case MEM_REF:
  449. nxt = &TREE_OPERAND (*addr_p, 0);
  450. return cbck (*addr_p, nxt, data);
  451. case BIT_FIELD_REF:
  452. case VIEW_CONVERT_EXPR:
  453. case REALPART_EXPR:
  454. case IMAGPART_EXPR:
  455. nxt = &TREE_OPERAND (*addr_p, 0);
  456. break;
  457. case COMPONENT_REF:
  458. /* If the component has varying offset, it behaves like index
  459. as well. */
  460. idx = &TREE_OPERAND (*addr_p, 2);
  461. if (*idx
  462. && !cbck (*addr_p, idx, data))
  463. return false;
  464. nxt = &TREE_OPERAND (*addr_p, 0);
  465. break;
  466. case ARRAY_REF:
  467. case ARRAY_RANGE_REF:
  468. nxt = &TREE_OPERAND (*addr_p, 0);
  469. if (!cbck (*addr_p, &TREE_OPERAND (*addr_p, 1), data))
  470. return false;
  471. break;
  472. case VAR_DECL:
  473. case PARM_DECL:
  474. case CONST_DECL:
  475. case STRING_CST:
  476. case RESULT_DECL:
  477. case VECTOR_CST:
  478. case COMPLEX_CST:
  479. case INTEGER_CST:
  480. case REAL_CST:
  481. case FIXED_CST:
  482. case CONSTRUCTOR:
  483. return true;
  484. case ADDR_EXPR:
  485. gcc_assert (is_gimple_min_invariant (*addr_p));
  486. return true;
  487. case TARGET_MEM_REF:
  488. idx = &TMR_BASE (*addr_p);
  489. if (*idx
  490. && !cbck (*addr_p, idx, data))
  491. return false;
  492. idx = &TMR_INDEX (*addr_p);
  493. if (*idx
  494. && !cbck (*addr_p, idx, data))
  495. return false;
  496. idx = &TMR_INDEX2 (*addr_p);
  497. if (*idx
  498. && !cbck (*addr_p, idx, data))
  499. return false;
  500. return true;
  501. default:
  502. gcc_unreachable ();
  503. }
  504. }
  505. }
  506. /* The name and the length of the currently generated variable
  507. for lsm. */
  508. #define MAX_LSM_NAME_LENGTH 40
  509. static char lsm_tmp_name[MAX_LSM_NAME_LENGTH + 1];
  510. static int lsm_tmp_name_length;
  511. /* Adds S to lsm_tmp_name. */
  512. static void
  513. lsm_tmp_name_add (const char *s)
  514. {
  515. int l = strlen (s) + lsm_tmp_name_length;
  516. if (l > MAX_LSM_NAME_LENGTH)
  517. return;
  518. strcpy (lsm_tmp_name + lsm_tmp_name_length, s);
  519. lsm_tmp_name_length = l;
  520. }
  521. /* Stores the name for temporary variable that replaces REF to
  522. lsm_tmp_name. */
  523. static void
  524. gen_lsm_tmp_name (tree ref)
  525. {
  526. const char *name;
  527. switch (TREE_CODE (ref))
  528. {
  529. case MEM_REF:
  530. case TARGET_MEM_REF:
  531. gen_lsm_tmp_name (TREE_OPERAND (ref, 0));
  532. lsm_tmp_name_add ("_");
  533. break;
  534. case ADDR_EXPR:
  535. gen_lsm_tmp_name (TREE_OPERAND (ref, 0));
  536. break;
  537. case BIT_FIELD_REF:
  538. case VIEW_CONVERT_EXPR:
  539. case ARRAY_RANGE_REF:
  540. gen_lsm_tmp_name (TREE_OPERAND (ref, 0));
  541. break;
  542. case REALPART_EXPR:
  543. gen_lsm_tmp_name (TREE_OPERAND (ref, 0));
  544. lsm_tmp_name_add ("_RE");
  545. break;
  546. case IMAGPART_EXPR:
  547. gen_lsm_tmp_name (TREE_OPERAND (ref, 0));
  548. lsm_tmp_name_add ("_IM");
  549. break;
  550. case COMPONENT_REF:
  551. gen_lsm_tmp_name (TREE_OPERAND (ref, 0));
  552. lsm_tmp_name_add ("_");
  553. name = get_name (TREE_OPERAND (ref, 1));
  554. if (!name)
  555. name = "F";
  556. lsm_tmp_name_add (name);
  557. break;
  558. case ARRAY_REF:
  559. gen_lsm_tmp_name (TREE_OPERAND (ref, 0));
  560. lsm_tmp_name_add ("_I");
  561. break;
  562. case SSA_NAME:
  563. case VAR_DECL:
  564. case PARM_DECL:
  565. name = get_name (ref);
  566. if (!name)
  567. name = "D";
  568. lsm_tmp_name_add (name);
  569. break;
  570. case STRING_CST:
  571. lsm_tmp_name_add ("S");
  572. break;
  573. case RESULT_DECL:
  574. lsm_tmp_name_add ("R");
  575. break;
  576. case INTEGER_CST:
  577. /* Nothing. */
  578. break;
  579. default:
  580. gcc_unreachable ();
  581. }
  582. }
  583. /* Determines name for temporary variable that replaces REF.
  584. The name is accumulated into the lsm_tmp_name variable.
  585. N is added to the name of the temporary. */
  586. char *
  587. get_lsm_tmp_name (tree ref, unsigned n, const char *suffix)
  588. {
  589. char ns[2];
  590. lsm_tmp_name_length = 0;
  591. gen_lsm_tmp_name (ref);
  592. lsm_tmp_name_add ("_lsm");
  593. if (n < 10)
  594. {
  595. ns[0] = '0' + n;
  596. ns[1] = 0;
  597. lsm_tmp_name_add (ns);
  598. }
  599. return lsm_tmp_name;
  600. if (suffix != NULL)
  601. lsm_tmp_name_add (suffix);
  602. }
  603. /* Computes an estimated number of insns in LOOP, weighted by WEIGHTS. */
  604. unsigned
  605. tree_num_loop_insns (struct loop *loop, eni_weights *weights)
  606. {
  607. basic_block *body = get_loop_body (loop);
  608. gimple_stmt_iterator gsi;
  609. unsigned size = 0, i;
  610. for (i = 0; i < loop->num_nodes; i++)
  611. for (gsi = gsi_start_bb (body[i]); !gsi_end_p (gsi); gsi_next (&gsi))
  612. size += estimate_num_insns (gsi_stmt (gsi), weights);
  613. free (body);
  614. return size;
  615. }