tree-data-ref.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. /* Data references and dependences detectors.
  2. Copyright (C) 2003-2018 Free Software Foundation, Inc.
  3. Contributed by Sebastian Pop <pop@cri.ensmp.fr>
  4. This file is part of GCC.
  5. GCC is free software; you can redistribute it and/or modify it under
  6. the terms of the GNU General Public License as published by the Free
  7. Software Foundation; either version 3, or (at your option) any later
  8. version.
  9. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GCC; see the file COPYING3. If not see
  15. <http://www.gnu.org/licenses/>. */
  16. #ifndef GCC_TREE_DATA_REF_H
  17. #define GCC_TREE_DATA_REF_H
  18. #include "graphds.h"
  19. #include "tree-chrec.h"
  20. /*
  21. innermost_loop_behavior describes the evolution of the address of the memory
  22. reference in the innermost enclosing loop. The address is expressed as
  23. BASE + STEP * # of iteration, and base is further decomposed as the base
  24. pointer (BASE_ADDRESS), loop invariant offset (OFFSET) and
  25. constant offset (INIT). Examples, in loop nest
  26. for (i = 0; i < 100; i++)
  27. for (j = 3; j < 100; j++)
  28. Example 1 Example 2
  29. data-ref a[j].b[i][j] *(p + x + 16B + 4B * j)
  30. innermost_loop_behavior
  31. base_address &a p
  32. offset i * D_i x
  33. init 3 * D_j + offsetof (b) 28
  34. step D_j 4
  35. */
  36. struct innermost_loop_behavior
  37. {
  38. tree base_address;
  39. tree offset;
  40. tree init;
  41. tree step;
  42. /* BASE_ADDRESS is known to be misaligned by BASE_MISALIGNMENT bytes
  43. from an alignment boundary of BASE_ALIGNMENT bytes. For example,
  44. if we had:
  45. struct S __attribute__((aligned(16))) { ... };
  46. char *ptr;
  47. ... *(struct S *) (ptr - 4) ...;
  48. the information would be:
  49. base_address: ptr
  50. base_aligment: 16
  51. base_misalignment: 4
  52. init: -4
  53. where init cancels the base misalignment. If instead we had a
  54. reference to a particular field:
  55. struct S __attribute__((aligned(16))) { ... int f; ... };
  56. char *ptr;
  57. ... ((struct S *) (ptr - 4))->f ...;
  58. the information would be:
  59. base_address: ptr
  60. base_aligment: 16
  61. base_misalignment: 4
  62. init: -4 + offsetof (S, f)
  63. where base_address + init might also be misaligned, and by a different
  64. amount from base_address. */
  65. unsigned int base_alignment;
  66. unsigned int base_misalignment;
  67. /* The largest power of two that divides OFFSET, capped to a suitably
  68. high value if the offset is zero. This is a byte rather than a bit
  69. quantity. */
  70. unsigned int offset_alignment;
  71. /* Likewise for STEP. */
  72. unsigned int step_alignment;
  73. };
  74. /* Describes the evolutions of indices of the memory reference. The indices
  75. are indices of the ARRAY_REFs, indexes in artificial dimensions
  76. added for member selection of records and the operands of MEM_REFs.
  77. BASE_OBJECT is the part of the reference that is loop-invariant
  78. (note that this reference does not have to cover the whole object
  79. being accessed, in which case UNCONSTRAINED_BASE is set; hence it is
  80. not recommended to use BASE_OBJECT in any code generation).
  81. For the examples above,
  82. base_object: a *(p + x + 4B * j_0)
  83. indices: {j_0, +, 1}_2 {16, +, 4}_2
  84. 4
  85. {i_0, +, 1}_1
  86. {j_0, +, 1}_2
  87. */
  88. struct indices
  89. {
  90. /* The object. */
  91. tree base_object;
  92. /* A list of chrecs. Access functions of the indices. */
  93. vec<tree> access_fns;
  94. /* Whether BASE_OBJECT is an access representing the whole object
  95. or whether the access could not be constrained. */
  96. bool unconstrained_base;
  97. };
  98. struct dr_alias
  99. {
  100. /* The alias information that should be used for new pointers to this
  101. location. */
  102. struct ptr_info_def *ptr_info;
  103. };
  104. /* An integer vector. A vector formally consists of an element of a vector
  105. space. A vector space is a set that is closed under vector addition
  106. and scalar multiplication. In this vector space, an element is a list of
  107. integers. */
  108. typedef int *lambda_vector;
  109. /* An integer matrix. A matrix consists of m vectors of length n (IE
  110. all vectors are the same length). */
  111. typedef lambda_vector *lambda_matrix;
  112. struct data_reference
  113. {
  114. /* A pointer to the statement that contains this DR. */
  115. gimple *stmt;
  116. /* A pointer to the memory reference. */
  117. tree ref;
  118. /* Auxiliary info specific to a pass. */
  119. void *aux;
  120. /* True when the data reference is in RHS of a stmt. */
  121. bool is_read;
  122. /* True when the data reference is conditional within STMT,
  123. i.e. if it might not occur even when the statement is executed
  124. and runs to completion. */
  125. bool is_conditional_in_stmt;
  126. /* Behavior of the memory reference in the innermost loop. */
  127. struct innermost_loop_behavior innermost;
  128. /* Subscripts of this data reference. */
  129. struct indices indices;
  130. /* Alias information for the data reference. */
  131. struct dr_alias alias;
  132. };
  133. #define DR_STMT(DR) (DR)->stmt
  134. #define DR_REF(DR) (DR)->ref
  135. #define DR_BASE_OBJECT(DR) (DR)->indices.base_object
  136. #define DR_UNCONSTRAINED_BASE(DR) (DR)->indices.unconstrained_base
  137. #define DR_ACCESS_FNS(DR) (DR)->indices.access_fns
  138. #define DR_ACCESS_FN(DR, I) DR_ACCESS_FNS (DR)[I]
  139. #define DR_NUM_DIMENSIONS(DR) DR_ACCESS_FNS (DR).length ()
  140. #define DR_IS_READ(DR) (DR)->is_read
  141. #define DR_IS_WRITE(DR) (!DR_IS_READ (DR))
  142. #define DR_IS_CONDITIONAL_IN_STMT(DR) (DR)->is_conditional_in_stmt
  143. #define DR_BASE_ADDRESS(DR) (DR)->innermost.base_address
  144. #define DR_OFFSET(DR) (DR)->innermost.offset
  145. #define DR_INIT(DR) (DR)->innermost.init
  146. #define DR_STEP(DR) (DR)->innermost.step
  147. #define DR_PTR_INFO(DR) (DR)->alias.ptr_info
  148. #define DR_BASE_ALIGNMENT(DR) (DR)->innermost.base_alignment
  149. #define DR_BASE_MISALIGNMENT(DR) (DR)->innermost.base_misalignment
  150. #define DR_OFFSET_ALIGNMENT(DR) (DR)->innermost.offset_alignment
  151. #define DR_STEP_ALIGNMENT(DR) (DR)->innermost.step_alignment
  152. #define DR_INNERMOST(DR) (DR)->innermost
  153. typedef struct data_reference *data_reference_p;
  154. /* This struct is used to store the information of a data reference,
  155. including the data ref itself and the segment length for aliasing
  156. checks. This is used to merge alias checks. */
  157. struct dr_with_seg_len
  158. {
  159. dr_with_seg_len (data_reference_p d, tree len, unsigned HOST_WIDE_INT size,
  160. unsigned int a)
  161. : dr (d), seg_len (len), access_size (size), align (a) {}
  162. data_reference_p dr;
  163. /* The offset of the last access that needs to be checked minus
  164. the offset of the first. */
  165. tree seg_len;
  166. /* A value that, when added to abs (SEG_LEN), gives the total number of
  167. bytes in the segment. */
  168. poly_uint64 access_size;
  169. /* The minimum common alignment of DR's start address, SEG_LEN and
  170. ACCESS_SIZE. */
  171. unsigned int align;
  172. };
  173. /* This struct contains two dr_with_seg_len objects with aliasing data
  174. refs. Two comparisons are generated from them. */
  175. struct dr_with_seg_len_pair_t
  176. {
  177. dr_with_seg_len_pair_t (const dr_with_seg_len& d1,
  178. const dr_with_seg_len& d2)
  179. : first (d1), second (d2) {}
  180. dr_with_seg_len first;
  181. dr_with_seg_len second;
  182. };
  183. enum data_dependence_direction {
  184. dir_positive,
  185. dir_negative,
  186. dir_equal,
  187. dir_positive_or_negative,
  188. dir_positive_or_equal,
  189. dir_negative_or_equal,
  190. dir_star,
  191. dir_independent
  192. };
  193. /* The description of the grid of iterations that overlap. At most
  194. two loops are considered at the same time just now, hence at most
  195. two functions are needed. For each of the functions, we store
  196. the vector of coefficients, f[0] + x * f[1] + y * f[2] + ...,
  197. where x, y, ... are variables. */
  198. #define MAX_DIM 2
  199. /* Special values of N. */
  200. #define NO_DEPENDENCE 0
  201. #define NOT_KNOWN (MAX_DIM + 1)
  202. #define CF_NONTRIVIAL_P(CF) ((CF)->n != NO_DEPENDENCE && (CF)->n != NOT_KNOWN)
  203. #define CF_NOT_KNOWN_P(CF) ((CF)->n == NOT_KNOWN)
  204. #define CF_NO_DEPENDENCE_P(CF) ((CF)->n == NO_DEPENDENCE)
  205. typedef vec<tree> affine_fn;
  206. struct conflict_function
  207. {
  208. unsigned n;
  209. affine_fn fns[MAX_DIM];
  210. };
  211. /* What is a subscript? Given two array accesses a subscript is the
  212. tuple composed of the access functions for a given dimension.
  213. Example: Given A[f1][f2][f3] and B[g1][g2][g3], there are three
  214. subscripts: (f1, g1), (f2, g2), (f3, g3). These three subscripts
  215. are stored in the data_dependence_relation structure under the form
  216. of an array of subscripts. */
  217. struct subscript
  218. {
  219. /* The access functions of the two references. */
  220. tree access_fn[2];
  221. /* A description of the iterations for which the elements are
  222. accessed twice. */
  223. conflict_function *conflicting_iterations_in_a;
  224. conflict_function *conflicting_iterations_in_b;
  225. /* This field stores the information about the iteration domain
  226. validity of the dependence relation. */
  227. tree last_conflict;
  228. /* Distance from the iteration that access a conflicting element in
  229. A to the iteration that access this same conflicting element in
  230. B. The distance is a tree scalar expression, i.e. a constant or a
  231. symbolic expression, but certainly not a chrec function. */
  232. tree distance;
  233. };
  234. typedef struct subscript *subscript_p;
  235. #define SUB_ACCESS_FN(SUB, I) (SUB)->access_fn[I]
  236. #define SUB_CONFLICTS_IN_A(SUB) (SUB)->conflicting_iterations_in_a
  237. #define SUB_CONFLICTS_IN_B(SUB) (SUB)->conflicting_iterations_in_b
  238. #define SUB_LAST_CONFLICT(SUB) (SUB)->last_conflict
  239. #define SUB_DISTANCE(SUB) (SUB)->distance
  240. /* A data_dependence_relation represents a relation between two
  241. data_references A and B. */
  242. struct data_dependence_relation
  243. {
  244. struct data_reference *a;
  245. struct data_reference *b;
  246. /* A "yes/no/maybe" field for the dependence relation:
  247. - when "ARE_DEPENDENT == NULL_TREE", there exist a dependence
  248. relation between A and B, and the description of this relation
  249. is given in the SUBSCRIPTS array,
  250. - when "ARE_DEPENDENT == chrec_known", there is no dependence and
  251. SUBSCRIPTS is empty,
  252. - when "ARE_DEPENDENT == chrec_dont_know", there may be a dependence,
  253. but the analyzer cannot be more specific. */
  254. tree are_dependent;
  255. /* If nonnull, COULD_BE_INDEPENDENT_P is true and the accesses are
  256. independent when the runtime addresses of OBJECT_A and OBJECT_B
  257. are different. The addresses of both objects are invariant in the
  258. loop nest. */
  259. tree object_a;
  260. tree object_b;
  261. /* For each subscript in the dependence test, there is an element in
  262. this array. This is the attribute that labels the edge A->B of
  263. the data_dependence_relation. */
  264. vec<subscript_p> subscripts;
  265. /* The analyzed loop nest. */
  266. vec<loop_p> loop_nest;
  267. /* The classic direction vector. */
  268. vec<lambda_vector> dir_vects;
  269. /* The classic distance vector. */
  270. vec<lambda_vector> dist_vects;
  271. /* An index in loop_nest for the innermost loop that varies for
  272. this data dependence relation. */
  273. unsigned inner_loop;
  274. /* Is the dependence reversed with respect to the lexicographic order? */
  275. bool reversed_p;
  276. /* When the dependence relation is affine, it can be represented by
  277. a distance vector. */
  278. bool affine_p;
  279. /* Set to true when the dependence relation is on the same data
  280. access. */
  281. bool self_reference_p;
  282. /* True if the dependence described is conservatively correct rather
  283. than exact, and if it is still possible for the accesses to be
  284. conditionally independent. For example, the a and b references in:
  285. struct s *a, *b;
  286. for (int i = 0; i < n; ++i)
  287. a->f[i] += b->f[i];
  288. conservatively have a distance vector of (0), for the case in which
  289. a == b, but the accesses are independent if a != b. Similarly,
  290. the a and b references in:
  291. struct s *a, *b;
  292. for (int i = 0; i < n; ++i)
  293. a[0].f[i] += b[i].f[i];
  294. conservatively have a distance vector of (0), but they are indepenent
  295. when a != b + i. In contrast, the references in:
  296. struct s *a;
  297. for (int i = 0; i < n; ++i)
  298. a->f[i] += a->f[i];
  299. have the same distance vector of (0), but the accesses can never be
  300. independent. */
  301. bool could_be_independent_p;
  302. };
  303. typedef struct data_dependence_relation *ddr_p;
  304. #define DDR_A(DDR) (DDR)->a
  305. #define DDR_B(DDR) (DDR)->b
  306. #define DDR_AFFINE_P(DDR) (DDR)->affine_p
  307. #define DDR_ARE_DEPENDENT(DDR) (DDR)->are_dependent
  308. #define DDR_OBJECT_A(DDR) (DDR)->object_a
  309. #define DDR_OBJECT_B(DDR) (DDR)->object_b
  310. #define DDR_SUBSCRIPTS(DDR) (DDR)->subscripts
  311. #define DDR_SUBSCRIPT(DDR, I) DDR_SUBSCRIPTS (DDR)[I]
  312. #define DDR_NUM_SUBSCRIPTS(DDR) DDR_SUBSCRIPTS (DDR).length ()
  313. #define DDR_LOOP_NEST(DDR) (DDR)->loop_nest
  314. /* The size of the direction/distance vectors: the number of loops in
  315. the loop nest. */
  316. #define DDR_NB_LOOPS(DDR) (DDR_LOOP_NEST (DDR).length ())
  317. #define DDR_INNER_LOOP(DDR) (DDR)->inner_loop
  318. #define DDR_SELF_REFERENCE(DDR) (DDR)->self_reference_p
  319. #define DDR_DIST_VECTS(DDR) ((DDR)->dist_vects)
  320. #define DDR_DIR_VECTS(DDR) ((DDR)->dir_vects)
  321. #define DDR_NUM_DIST_VECTS(DDR) \
  322. (DDR_DIST_VECTS (DDR).length ())
  323. #define DDR_NUM_DIR_VECTS(DDR) \
  324. (DDR_DIR_VECTS (DDR).length ())
  325. #define DDR_DIR_VECT(DDR, I) \
  326. DDR_DIR_VECTS (DDR)[I]
  327. #define DDR_DIST_VECT(DDR, I) \
  328. DDR_DIST_VECTS (DDR)[I]
  329. #define DDR_REVERSED_P(DDR) (DDR)->reversed_p
  330. #define DDR_COULD_BE_INDEPENDENT_P(DDR) (DDR)->could_be_independent_p
  331. bool dr_analyze_innermost (innermost_loop_behavior *, tree, struct loop *);
  332. extern bool compute_data_dependences_for_loop (struct loop *, bool,
  333. vec<loop_p> *,
  334. vec<data_reference_p> *,
  335. vec<ddr_p> *);
  336. extern void debug_ddrs (vec<ddr_p> );
  337. extern void dump_data_reference (FILE *, struct data_reference *);
  338. extern void debug (data_reference &ref);
  339. extern void debug (data_reference *ptr);
  340. extern void debug_data_reference (struct data_reference *);
  341. extern void debug_data_references (vec<data_reference_p> );
  342. extern void debug (vec<data_reference_p> &ref);
  343. extern void debug (vec<data_reference_p> *ptr);
  344. extern void debug_data_dependence_relation (struct data_dependence_relation *);
  345. extern void dump_data_dependence_relations (FILE *, vec<ddr_p> );
  346. extern void debug (vec<ddr_p> &ref);
  347. extern void debug (vec<ddr_p> *ptr);
  348. extern void debug_data_dependence_relations (vec<ddr_p> );
  349. extern void free_dependence_relation (struct data_dependence_relation *);
  350. extern void free_dependence_relations (vec<ddr_p> );
  351. extern void free_data_ref (data_reference_p);
  352. extern void free_data_refs (vec<data_reference_p> );
  353. extern bool find_data_references_in_stmt (struct loop *, gimple *,
  354. vec<data_reference_p> *);
  355. extern bool graphite_find_data_references_in_stmt (edge, loop_p, gimple *,
  356. vec<data_reference_p> *);
  357. tree find_data_references_in_loop (struct loop *, vec<data_reference_p> *);
  358. bool loop_nest_has_data_refs (loop_p loop);
  359. struct data_reference *create_data_ref (edge, loop_p, tree, gimple *, bool,
  360. bool);
  361. extern bool find_loop_nest (struct loop *, vec<loop_p> *);
  362. extern struct data_dependence_relation *initialize_data_dependence_relation
  363. (struct data_reference *, struct data_reference *, vec<loop_p>);
  364. extern void compute_affine_dependence (struct data_dependence_relation *,
  365. loop_p);
  366. extern void compute_self_dependence (struct data_dependence_relation *);
  367. extern bool compute_all_dependences (vec<data_reference_p> ,
  368. vec<ddr_p> *,
  369. vec<loop_p>, bool);
  370. extern tree find_data_references_in_bb (struct loop *, basic_block,
  371. vec<data_reference_p> *);
  372. extern unsigned int dr_alignment (innermost_loop_behavior *);
  373. extern tree get_base_for_alignment (tree, unsigned int *);
  374. /* Return the alignment in bytes that DR is guaranteed to have at all
  375. times. */
  376. inline unsigned int
  377. dr_alignment (data_reference *dr)
  378. {
  379. return dr_alignment (&DR_INNERMOST (dr));
  380. }
  381. extern bool dr_may_alias_p (const struct data_reference *,
  382. const struct data_reference *, bool);
  383. extern bool dr_equal_offsets_p (struct data_reference *,
  384. struct data_reference *);
  385. extern bool runtime_alias_check_p (ddr_p, struct loop *, bool);
  386. extern int data_ref_compare_tree (tree, tree);
  387. extern void prune_runtime_alias_test_list (vec<dr_with_seg_len_pair_t> *,
  388. poly_uint64);
  389. extern void create_runtime_alias_checks (struct loop *,
  390. vec<dr_with_seg_len_pair_t> *, tree*);
  391. extern tree dr_direction_indicator (struct data_reference *);
  392. extern tree dr_zero_step_indicator (struct data_reference *);
  393. extern bool dr_known_forward_stride_p (struct data_reference *);
  394. /* Return true when the base objects of data references A and B are
  395. the same memory object. */
  396. static inline bool
  397. same_data_refs_base_objects (data_reference_p a, data_reference_p b)
  398. {
  399. return DR_NUM_DIMENSIONS (a) == DR_NUM_DIMENSIONS (b)
  400. && operand_equal_p (DR_BASE_OBJECT (a), DR_BASE_OBJECT (b), 0);
  401. }
  402. /* Return true when the data references A and B are accessing the same
  403. memory object with the same access functions. */
  404. static inline bool
  405. same_data_refs (data_reference_p a, data_reference_p b)
  406. {
  407. unsigned int i;
  408. /* The references are exactly the same. */
  409. if (operand_equal_p (DR_REF (a), DR_REF (b), 0))
  410. return true;
  411. if (!same_data_refs_base_objects (a, b))
  412. return false;
  413. for (i = 0; i < DR_NUM_DIMENSIONS (a); i++)
  414. if (!eq_evolutions_p (DR_ACCESS_FN (a, i), DR_ACCESS_FN (b, i)))
  415. return false;
  416. return true;
  417. }
  418. /* Returns true when all the dependences are computable. */
  419. inline bool
  420. known_dependences_p (vec<ddr_p> dependence_relations)
  421. {
  422. ddr_p ddr;
  423. unsigned int i;
  424. FOR_EACH_VEC_ELT (dependence_relations, i, ddr)
  425. if (DDR_ARE_DEPENDENT (ddr) == chrec_dont_know)
  426. return false;
  427. return true;
  428. }
  429. /* Returns the dependence level for a vector DIST of size LENGTH.
  430. LEVEL = 0 means a lexicographic dependence, i.e. a dependence due
  431. to the sequence of statements, not carried by any loop. */
  432. static inline unsigned
  433. dependence_level (lambda_vector dist_vect, int length)
  434. {
  435. int i;
  436. for (i = 0; i < length; i++)
  437. if (dist_vect[i] != 0)
  438. return i + 1;
  439. return 0;
  440. }
  441. /* Return the dependence level for the DDR relation. */
  442. static inline unsigned
  443. ddr_dependence_level (ddr_p ddr)
  444. {
  445. unsigned vector;
  446. unsigned level = 0;
  447. if (DDR_DIST_VECTS (ddr).exists ())
  448. level = dependence_level (DDR_DIST_VECT (ddr, 0), DDR_NB_LOOPS (ddr));
  449. for (vector = 1; vector < DDR_NUM_DIST_VECTS (ddr); vector++)
  450. level = MIN (level, dependence_level (DDR_DIST_VECT (ddr, vector),
  451. DDR_NB_LOOPS (ddr)));
  452. return level;
  453. }
  454. /* Return the index of the variable VAR in the LOOP_NEST array. */
  455. static inline int
  456. index_in_loop_nest (int var, vec<loop_p> loop_nest)
  457. {
  458. struct loop *loopi;
  459. int var_index;
  460. for (var_index = 0; loop_nest.iterate (var_index, &loopi);
  461. var_index++)
  462. if (loopi->num == var)
  463. break;
  464. return var_index;
  465. }
  466. /* Returns true when the data reference DR the form "A[i] = ..."
  467. with a stride equal to its unit type size. */
  468. static inline bool
  469. adjacent_dr_p (struct data_reference *dr)
  470. {
  471. /* If this is a bitfield store bail out. */
  472. if (TREE_CODE (DR_REF (dr)) == COMPONENT_REF
  473. && DECL_BIT_FIELD (TREE_OPERAND (DR_REF (dr), 1)))
  474. return false;
  475. if (!DR_STEP (dr)
  476. || TREE_CODE (DR_STEP (dr)) != INTEGER_CST)
  477. return false;
  478. return tree_int_cst_equal (fold_unary (ABS_EXPR, TREE_TYPE (DR_STEP (dr)),
  479. DR_STEP (dr)),
  480. TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr))));
  481. }
  482. void split_constant_offset (tree , tree *, tree *);
  483. /* Compute the greatest common divisor of a VECTOR of SIZE numbers. */
  484. static inline int
  485. lambda_vector_gcd (lambda_vector vector, int size)
  486. {
  487. int i;
  488. int gcd1 = 0;
  489. if (size > 0)
  490. {
  491. gcd1 = vector[0];
  492. for (i = 1; i < size; i++)
  493. gcd1 = gcd (gcd1, vector[i]);
  494. }
  495. return gcd1;
  496. }
  497. /* Allocate a new vector of given SIZE. */
  498. static inline lambda_vector
  499. lambda_vector_new (int size)
  500. {
  501. /* ??? We shouldn't abuse the GC allocator here. */
  502. return ggc_cleared_vec_alloc<int> (size);
  503. }
  504. /* Clear out vector VEC1 of length SIZE. */
  505. static inline void
  506. lambda_vector_clear (lambda_vector vec1, int size)
  507. {
  508. memset (vec1, 0, size * sizeof (*vec1));
  509. }
  510. /* Returns true when the vector V is lexicographically positive, in
  511. other words, when the first nonzero element is positive. */
  512. static inline bool
  513. lambda_vector_lexico_pos (lambda_vector v,
  514. unsigned n)
  515. {
  516. unsigned i;
  517. for (i = 0; i < n; i++)
  518. {
  519. if (v[i] == 0)
  520. continue;
  521. if (v[i] < 0)
  522. return false;
  523. if (v[i] > 0)
  524. return true;
  525. }
  526. return true;
  527. }
  528. /* Return true if vector VEC1 of length SIZE is the zero vector. */
  529. static inline bool
  530. lambda_vector_zerop (lambda_vector vec1, int size)
  531. {
  532. int i;
  533. for (i = 0; i < size; i++)
  534. if (vec1[i] != 0)
  535. return false;
  536. return true;
  537. }
  538. /* Allocate a matrix of M rows x N cols. */
  539. static inline lambda_matrix
  540. lambda_matrix_new (int m, int n, struct obstack *lambda_obstack)
  541. {
  542. lambda_matrix mat;
  543. int i;
  544. mat = XOBNEWVEC (lambda_obstack, lambda_vector, m);
  545. for (i = 0; i < m; i++)
  546. mat[i] = XOBNEWVEC (lambda_obstack, int, n);
  547. return mat;
  548. }
  549. #endif /* GCC_TREE_DATA_REF_H */