tree-data-ref.h 21 KB

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