tree-ssa-loop.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Header file for SSA loop optimizations.
  2. Copyright (C) 2013-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 under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. 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. #ifndef GCC_TREE_SSA_LOOP_H
  16. #define GCC_TREE_SSA_LOOP_H
  17. #include "wide-int.h"
  18. /* Affine iv. */
  19. struct affine_iv
  20. {
  21. /* Iv = BASE + STEP * i. */
  22. tree base, step;
  23. /* True if this iv does not overflow. */
  24. bool no_overflow;
  25. };
  26. /* Description of number of iterations of a loop. All the expressions inside
  27. the structure can be evaluated at the end of the loop's preheader
  28. (and due to ssa form, also anywhere inside the body of the loop). */
  29. struct tree_niter_desc
  30. {
  31. tree assumptions; /* The boolean expression. If this expression evaluates
  32. to false, then the other fields in this structure
  33. should not be used; there is no guarantee that they
  34. will be correct. */
  35. tree may_be_zero; /* The boolean expression. If it evaluates to true,
  36. the loop will exit in the first iteration (i.e.
  37. its latch will not be executed), even if the niter
  38. field says otherwise. */
  39. tree niter; /* The expression giving the number of iterations of
  40. a loop (provided that assumptions == true and
  41. may_be_zero == false), more precisely the number
  42. of executions of the latch of the loop. */
  43. widest_int max; /* The upper bound on the number of iterations of
  44. the loop. */
  45. /* The simplified shape of the exit condition. The loop exits if
  46. CONTROL CMP BOUND is false, where CMP is one of NE_EXPR,
  47. LT_EXPR, or GT_EXPR, and step of CONTROL is positive if CMP is
  48. LE_EXPR and negative if CMP is GE_EXPR. This information is used
  49. by loop unrolling. */
  50. affine_iv control;
  51. tree bound;
  52. enum tree_code cmp;
  53. };
  54. extern bool for_each_index (tree *, bool (*) (tree, tree *, void *), void *);
  55. extern char *get_lsm_tmp_name (tree ref, unsigned n, const char *suffix = NULL);
  56. extern unsigned tree_num_loop_insns (struct loop *, struct eni_weights_d *);
  57. /* Returns the loop of the statement STMT. */
  58. static inline struct loop *
  59. loop_containing_stmt (gimple stmt)
  60. {
  61. basic_block bb = gimple_bb (stmt);
  62. if (!bb)
  63. return NULL;
  64. return bb->loop_father;
  65. }
  66. #endif /* GCC_TREE_SSA_LOOP_H */