1 /* Operations with affine combinations of trees.
2 Copyright (C) 2005-2013 Free Software Foundation, Inc.
4 This file is part of GCC.
6 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 Free Software Foundation; either version 3, or (at your option) any
11 GCC is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
22 #include "coretypes.h"
25 #include "tree-pretty-print.h"
26 #include "pointer-set.h"
27 #include "tree-affine.h"
32 #include "cfgexpand.h"
34 /* Extends CST as appropriate for the affine combinations COMB. */
37 double_int_ext_for_comb (double_int cst
, aff_tree
*comb
)
39 return cst
.sext (TYPE_PRECISION (comb
->type
));
42 /* Initializes affine combination COMB so that its value is zero in TYPE. */
45 aff_combination_zero (aff_tree
*comb
, tree type
)
48 comb
->offset
= double_int_zero
;
50 comb
->rest
= NULL_TREE
;
53 /* Sets COMB to CST. */
56 aff_combination_const (aff_tree
*comb
, tree type
, double_int cst
)
58 aff_combination_zero (comb
, type
);
59 comb
->offset
= double_int_ext_for_comb (cst
, comb
);
62 /* Sets COMB to single element ELT. */
65 aff_combination_elt (aff_tree
*comb
, tree type
, tree elt
)
67 aff_combination_zero (comb
, type
);
70 comb
->elts
[0].val
= elt
;
71 comb
->elts
[0].coef
= double_int_one
;
74 /* Scales COMB by SCALE. */
77 aff_combination_scale (aff_tree
*comb
, double_int scale
)
81 scale
= double_int_ext_for_comb (scale
, comb
);
87 aff_combination_zero (comb
, comb
->type
);
92 = double_int_ext_for_comb (scale
* comb
->offset
, comb
);
93 for (i
= 0, j
= 0; i
< comb
->n
; i
++)
98 = double_int_ext_for_comb (scale
* comb
->elts
[i
].coef
, comb
);
99 /* A coefficient may become zero due to overflow. Remove the zero
101 if (new_coef
.is_zero ())
103 comb
->elts
[j
].coef
= new_coef
;
104 comb
->elts
[j
].val
= comb
->elts
[i
].val
;
111 tree type
= comb
->type
;
112 if (POINTER_TYPE_P (type
))
114 if (comb
->n
< MAX_AFF_ELTS
)
116 comb
->elts
[comb
->n
].coef
= scale
;
117 comb
->elts
[comb
->n
].val
= comb
->rest
;
118 comb
->rest
= NULL_TREE
;
122 comb
->rest
= fold_build2 (MULT_EXPR
, type
, comb
->rest
,
123 double_int_to_tree (type
, scale
));
127 /* Adds ELT * SCALE to COMB. */
130 aff_combination_add_elt (aff_tree
*comb
, tree elt
, double_int scale
)
135 scale
= double_int_ext_for_comb (scale
, comb
);
136 if (scale
.is_zero ())
139 for (i
= 0; i
< comb
->n
; i
++)
140 if (operand_equal_p (comb
->elts
[i
].val
, elt
, 0))
144 new_coef
= comb
->elts
[i
].coef
+ scale
;
145 new_coef
= double_int_ext_for_comb (new_coef
, comb
);
146 if (!new_coef
.is_zero ())
148 comb
->elts
[i
].coef
= new_coef
;
153 comb
->elts
[i
] = comb
->elts
[comb
->n
];
157 gcc_assert (comb
->n
== MAX_AFF_ELTS
- 1);
158 comb
->elts
[comb
->n
].coef
= double_int_one
;
159 comb
->elts
[comb
->n
].val
= comb
->rest
;
160 comb
->rest
= NULL_TREE
;
165 if (comb
->n
< MAX_AFF_ELTS
)
167 comb
->elts
[comb
->n
].coef
= scale
;
168 comb
->elts
[comb
->n
].val
= elt
;
174 if (POINTER_TYPE_P (type
))
178 elt
= fold_convert (type
, elt
);
180 elt
= fold_build2 (MULT_EXPR
, type
,
181 fold_convert (type
, elt
),
182 double_int_to_tree (type
, scale
));
185 comb
->rest
= fold_build2 (PLUS_EXPR
, type
, comb
->rest
,
194 aff_combination_add_cst (aff_tree
*c
, double_int cst
)
196 c
->offset
= double_int_ext_for_comb (c
->offset
+ cst
, c
);
199 /* Adds COMB2 to COMB1. */
202 aff_combination_add (aff_tree
*comb1
, aff_tree
*comb2
)
206 aff_combination_add_cst (comb1
, comb2
->offset
);
207 for (i
= 0; i
< comb2
->n
; i
++)
208 aff_combination_add_elt (comb1
, comb2
->elts
[i
].val
, comb2
->elts
[i
].coef
);
210 aff_combination_add_elt (comb1
, comb2
->rest
, double_int_one
);
213 /* Converts affine combination COMB to TYPE. */
216 aff_combination_convert (aff_tree
*comb
, tree type
)
219 tree comb_type
= comb
->type
;
221 if (TYPE_PRECISION (type
) > TYPE_PRECISION (comb_type
))
223 tree val
= fold_convert (type
, aff_combination_to_tree (comb
));
224 tree_to_aff_combination (val
, type
, comb
);
229 if (comb
->rest
&& !POINTER_TYPE_P (type
))
230 comb
->rest
= fold_convert (type
, comb
->rest
);
232 if (TYPE_PRECISION (type
) == TYPE_PRECISION (comb_type
))
235 comb
->offset
= double_int_ext_for_comb (comb
->offset
, comb
);
236 for (i
= j
= 0; i
< comb
->n
; i
++)
238 double_int new_coef
= double_int_ext_for_comb (comb
->elts
[i
].coef
, comb
);
239 if (new_coef
.is_zero ())
241 comb
->elts
[j
].coef
= new_coef
;
242 comb
->elts
[j
].val
= fold_convert (type
, comb
->elts
[i
].val
);
247 if (comb
->n
< MAX_AFF_ELTS
&& comb
->rest
)
249 comb
->elts
[comb
->n
].coef
= double_int_one
;
250 comb
->elts
[comb
->n
].val
= comb
->rest
;
251 comb
->rest
= NULL_TREE
;
256 /* Splits EXPR into an affine combination of parts. */
259 tree_to_aff_combination (tree expr
, tree type
, aff_tree
*comb
)
263 tree cst
, core
, toffset
;
264 HOST_WIDE_INT bitpos
, bitsize
;
265 enum machine_mode mode
;
266 int unsignedp
, volatilep
;
270 code
= TREE_CODE (expr
);
274 aff_combination_const (comb
, type
, tree_to_double_int (expr
));
277 case POINTER_PLUS_EXPR
:
278 tree_to_aff_combination (TREE_OPERAND (expr
, 0), type
, comb
);
279 tree_to_aff_combination (TREE_OPERAND (expr
, 1), sizetype
, &tmp
);
280 aff_combination_add (comb
, &tmp
);
285 tree_to_aff_combination (TREE_OPERAND (expr
, 0), type
, comb
);
286 tree_to_aff_combination (TREE_OPERAND (expr
, 1), type
, &tmp
);
287 if (code
== MINUS_EXPR
)
288 aff_combination_scale (&tmp
, double_int_minus_one
);
289 aff_combination_add (comb
, &tmp
);
293 cst
= TREE_OPERAND (expr
, 1);
294 if (TREE_CODE (cst
) != INTEGER_CST
)
296 tree_to_aff_combination (TREE_OPERAND (expr
, 0), type
, comb
);
297 aff_combination_scale (comb
, tree_to_double_int (cst
));
301 tree_to_aff_combination (TREE_OPERAND (expr
, 0), type
, comb
);
302 aff_combination_scale (comb
, double_int_minus_one
);
307 tree_to_aff_combination (TREE_OPERAND (expr
, 0), type
, comb
);
308 aff_combination_scale (comb
, double_int_minus_one
);
309 aff_combination_add_cst (comb
, double_int_minus_one
);
313 /* Handle &MEM[ptr + CST] which is equivalent to POINTER_PLUS_EXPR. */
314 if (TREE_CODE (TREE_OPERAND (expr
, 0)) == MEM_REF
)
316 expr
= TREE_OPERAND (expr
, 0);
317 tree_to_aff_combination (TREE_OPERAND (expr
, 0), type
, comb
);
318 tree_to_aff_combination (TREE_OPERAND (expr
, 1), sizetype
, &tmp
);
319 aff_combination_add (comb
, &tmp
);
322 core
= get_inner_reference (TREE_OPERAND (expr
, 0), &bitsize
, &bitpos
,
323 &toffset
, &mode
, &unsignedp
, &volatilep
,
325 if (bitpos
% BITS_PER_UNIT
!= 0)
327 aff_combination_const (comb
, type
,
328 double_int::from_uhwi (bitpos
/ BITS_PER_UNIT
));
329 core
= build_fold_addr_expr (core
);
330 if (TREE_CODE (core
) == ADDR_EXPR
)
331 aff_combination_add_elt (comb
, core
, double_int_one
);
334 tree_to_aff_combination (core
, type
, &tmp
);
335 aff_combination_add (comb
, &tmp
);
339 tree_to_aff_combination (toffset
, type
, &tmp
);
340 aff_combination_add (comb
, &tmp
);
345 if (TREE_CODE (TREE_OPERAND (expr
, 0)) == ADDR_EXPR
)
346 tree_to_aff_combination (TREE_OPERAND (TREE_OPERAND (expr
, 0), 0),
348 else if (integer_zerop (TREE_OPERAND (expr
, 1)))
350 aff_combination_elt (comb
, type
, expr
);
354 aff_combination_elt (comb
, type
,
355 build2 (MEM_REF
, TREE_TYPE (expr
),
356 TREE_OPERAND (expr
, 0),
358 (TREE_TYPE (TREE_OPERAND (expr
, 1)), 0)));
359 tree_to_aff_combination (TREE_OPERAND (expr
, 1), sizetype
, &tmp
);
360 aff_combination_add (comb
, &tmp
);
367 aff_combination_elt (comb
, type
, expr
);
370 /* Creates EXPR + ELT * SCALE in TYPE. EXPR is taken from affine
374 add_elt_to_tree (tree expr
, tree type
, tree elt
, double_int scale
,
379 if (POINTER_TYPE_P (type
))
382 scale
= double_int_ext_for_comb (scale
, comb
);
384 if (scale
.is_minus_one ()
385 && POINTER_TYPE_P (TREE_TYPE (elt
)))
387 elt
= convert_to_ptrofftype (elt
);
388 elt
= fold_build1 (NEGATE_EXPR
, TREE_TYPE (elt
), elt
);
389 scale
= double_int_one
;
396 if (POINTER_TYPE_P (TREE_TYPE (elt
)))
399 return fold_convert (type1
, elt
);
402 if (POINTER_TYPE_P (TREE_TYPE (expr
)))
403 return fold_build_pointer_plus (expr
, elt
);
404 if (POINTER_TYPE_P (TREE_TYPE (elt
)))
405 return fold_build_pointer_plus (elt
, expr
);
406 return fold_build2 (PLUS_EXPR
, type1
,
407 expr
, fold_convert (type1
, elt
));
410 if (scale
.is_minus_one ())
413 return fold_build1 (NEGATE_EXPR
, type1
,
414 fold_convert (type1
, elt
));
416 if (POINTER_TYPE_P (TREE_TYPE (expr
)))
418 elt
= convert_to_ptrofftype (elt
);
419 elt
= fold_build1 (NEGATE_EXPR
, TREE_TYPE (elt
), elt
);
420 return fold_build_pointer_plus (expr
, elt
);
422 return fold_build2 (MINUS_EXPR
, type1
,
423 expr
, fold_convert (type1
, elt
));
426 elt
= fold_convert (type1
, elt
);
428 return fold_build2 (MULT_EXPR
, type1
, elt
,
429 double_int_to_tree (type1
, scale
));
431 if (scale
.is_negative ())
439 elt
= fold_build2 (MULT_EXPR
, type1
, elt
,
440 double_int_to_tree (type1
, scale
));
441 if (POINTER_TYPE_P (TREE_TYPE (expr
)))
443 if (code
== MINUS_EXPR
)
444 elt
= fold_build1 (NEGATE_EXPR
, type1
, elt
);
445 return fold_build_pointer_plus (expr
, elt
);
447 return fold_build2 (code
, type1
, expr
, elt
);
450 /* Makes tree from the affine combination COMB. */
453 aff_combination_to_tree (aff_tree
*comb
)
455 tree type
= comb
->type
;
456 tree expr
= NULL_TREE
;
460 if (POINTER_TYPE_P (type
))
463 gcc_assert (comb
->n
== MAX_AFF_ELTS
|| comb
->rest
== NULL_TREE
);
465 for (i
= 0; i
< comb
->n
; i
++)
466 expr
= add_elt_to_tree (expr
, type
, comb
->elts
[i
].val
, comb
->elts
[i
].coef
,
470 expr
= add_elt_to_tree (expr
, type
, comb
->rest
, double_int_one
, comb
);
472 /* Ensure that we get x - 1, not x + (-1) or x + 0xff..f if x is
474 if (comb
->offset
.is_negative ())
477 sgn
= double_int_minus_one
;
482 sgn
= double_int_one
;
484 return add_elt_to_tree (expr
, type
, double_int_to_tree (type1
, off
), sgn
,
488 /* Copies the tree elements of COMB to ensure that they are not shared. */
491 unshare_aff_combination (aff_tree
*comb
)
495 for (i
= 0; i
< comb
->n
; i
++)
496 comb
->elts
[i
].val
= unshare_expr (comb
->elts
[i
].val
);
498 comb
->rest
= unshare_expr (comb
->rest
);
501 /* Remove M-th element from COMB. */
504 aff_combination_remove_elt (aff_tree
*comb
, unsigned m
)
508 comb
->elts
[m
] = comb
->elts
[comb
->n
];
511 comb
->elts
[comb
->n
].coef
= double_int_one
;
512 comb
->elts
[comb
->n
].val
= comb
->rest
;
513 comb
->rest
= NULL_TREE
;
518 /* Adds C * COEF * VAL to R. VAL may be NULL, in that case only
519 C * COEF is added to R. */
523 aff_combination_add_product (aff_tree
*c
, double_int coef
, tree val
,
529 for (i
= 0; i
< c
->n
; i
++)
531 aval
= c
->elts
[i
].val
;
534 type
= TREE_TYPE (aval
);
535 aval
= fold_build2 (MULT_EXPR
, type
, aval
,
536 fold_convert (type
, val
));
539 aff_combination_add_elt (r
, aval
, coef
* c
->elts
[i
].coef
);
547 type
= TREE_TYPE (aval
);
548 aval
= fold_build2 (MULT_EXPR
, type
, aval
,
549 fold_convert (type
, val
));
552 aff_combination_add_elt (r
, aval
, coef
);
556 aff_combination_add_elt (r
, val
, coef
* c
->offset
);
558 aff_combination_add_cst (r
, coef
* c
->offset
);
561 /* Multiplies C1 by C2, storing the result to R */
564 aff_combination_mult (aff_tree
*c1
, aff_tree
*c2
, aff_tree
*r
)
567 gcc_assert (TYPE_PRECISION (c1
->type
) == TYPE_PRECISION (c2
->type
));
569 aff_combination_zero (r
, c1
->type
);
571 for (i
= 0; i
< c2
->n
; i
++)
572 aff_combination_add_product (c1
, c2
->elts
[i
].coef
, c2
->elts
[i
].val
, r
);
574 aff_combination_add_product (c1
, double_int_one
, c2
->rest
, r
);
575 aff_combination_add_product (c1
, c2
->offset
, NULL
, r
);
578 /* Returns the element of COMB whose value is VAL, or NULL if no such
579 element exists. If IDX is not NULL, it is set to the index of VAL in
582 static struct aff_comb_elt
*
583 aff_combination_find_elt (aff_tree
*comb
, tree val
, unsigned *idx
)
587 for (i
= 0; i
< comb
->n
; i
++)
588 if (operand_equal_p (comb
->elts
[i
].val
, val
, 0))
593 return &comb
->elts
[i
];
599 /* Element of the cache that maps ssa name NAME to its expanded form
600 as an affine expression EXPANSION. */
602 struct name_expansion
606 /* True if the expansion for the name is just being generated. */
607 unsigned in_progress
: 1;
610 /* Expands SSA names in COMB recursively. CACHE is used to cache the
614 aff_combination_expand (aff_tree
*comb ATTRIBUTE_UNUSED
,
615 struct pointer_map_t
**cache ATTRIBUTE_UNUSED
)
618 aff_tree to_add
, current
, curre
;
623 struct name_expansion
*exp
;
625 aff_combination_zero (&to_add
, comb
->type
);
626 for (i
= 0; i
< comb
->n
; i
++)
631 e
= comb
->elts
[i
].val
;
632 type
= TREE_TYPE (e
);
634 /* Look through some conversions. */
635 if (TREE_CODE (e
) == NOP_EXPR
636 && (TYPE_PRECISION (type
)
637 >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (e
, 0)))))
638 name
= TREE_OPERAND (e
, 0);
639 if (TREE_CODE (name
) != SSA_NAME
)
641 def
= SSA_NAME_DEF_STMT (name
);
642 if (!is_gimple_assign (def
) || gimple_assign_lhs (def
) != name
)
645 code
= gimple_assign_rhs_code (def
);
647 && !IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code
))
648 && (get_gimple_rhs_class (code
) != GIMPLE_SINGLE_RHS
649 || !is_gimple_min_invariant (gimple_assign_rhs1 (def
))))
652 /* We do not know whether the reference retains its value at the
653 place where the expansion is used. */
654 if (TREE_CODE_CLASS (code
) == tcc_reference
)
658 *cache
= pointer_map_create ();
659 slot
= pointer_map_insert (*cache
, e
);
660 exp
= (struct name_expansion
*) *slot
;
664 exp
= XNEW (struct name_expansion
);
665 exp
->in_progress
= 1;
667 /* In principle this is a generally valid folding, but
668 it is not unconditionally an optimization, so do it
669 here and not in fold_unary. */
670 /* Convert (T1)(X *+- CST) into (T1)X *+- (T1)CST if T1 is wider
671 than the type of X and overflow for the type of X is
674 && INTEGRAL_TYPE_P (type
)
675 && INTEGRAL_TYPE_P (TREE_TYPE (name
))
676 && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (name
))
677 && TYPE_PRECISION (type
) > TYPE_PRECISION (TREE_TYPE (name
))
678 && (code
== PLUS_EXPR
|| code
== MINUS_EXPR
|| code
== MULT_EXPR
)
679 && TREE_CODE (gimple_assign_rhs2 (def
)) == INTEGER_CST
)
680 rhs
= fold_build2 (code
, type
,
681 fold_convert (type
, gimple_assign_rhs1 (def
)),
682 fold_convert (type
, gimple_assign_rhs2 (def
)));
685 rhs
= gimple_assign_rhs_to_tree (def
);
687 rhs
= fold_convert (type
, rhs
);
689 tree_to_aff_combination_expand (rhs
, comb
->type
, ¤t
, cache
);
690 exp
->expansion
= current
;
691 exp
->in_progress
= 0;
695 /* Since we follow the definitions in the SSA form, we should not
696 enter a cycle unless we pass through a phi node. */
697 gcc_assert (!exp
->in_progress
);
698 current
= exp
->expansion
;
701 /* Accumulate the new terms to TO_ADD, so that we do not modify
702 COMB while traversing it; include the term -coef * E, to remove
704 scale
= comb
->elts
[i
].coef
;
705 aff_combination_zero (&curre
, comb
->type
);
706 aff_combination_add_elt (&curre
, e
, -scale
);
707 aff_combination_scale (¤t
, scale
);
708 aff_combination_add (&to_add
, ¤t
);
709 aff_combination_add (&to_add
, &curre
);
711 aff_combination_add (comb
, &to_add
);
714 /* Similar to tree_to_aff_combination, but follows SSA name definitions
715 and expands them recursively. CACHE is used to cache the expansions
716 of the ssa names, to avoid exponential time complexity for cases
725 tree_to_aff_combination_expand (tree expr
, tree type
, aff_tree
*comb
,
726 struct pointer_map_t
**cache
)
728 tree_to_aff_combination (expr
, type
, comb
);
729 aff_combination_expand (comb
, cache
);
732 /* Frees memory occupied by struct name_expansion in *VALUE. Callback for
733 pointer_map_traverse. */
736 free_name_expansion (const void *key ATTRIBUTE_UNUSED
, void **value
,
737 void *data ATTRIBUTE_UNUSED
)
739 struct name_expansion
*const exp
= (struct name_expansion
*) *value
;
745 /* Frees memory allocated for the CACHE used by
746 tree_to_aff_combination_expand. */
749 free_affine_expand_cache (struct pointer_map_t
**cache
)
754 pointer_map_traverse (*cache
, free_name_expansion
, NULL
);
755 pointer_map_destroy (*cache
);
759 /* If VAL != CST * DIV for any constant CST, returns false.
760 Otherwise, if *MULT_SET is true, additionally compares CST and MULT,
761 and if they are different, returns false. Finally, if neither of these
762 two cases occur, true is returned, and CST is stored to MULT and MULT_SET
766 double_int_constant_multiple_p (double_int val
, double_int div
,
767 bool *mult_set
, double_int
*mult
)
773 if (*mult_set
&& !mult
->is_zero ())
776 *mult
= double_int_zero
;
783 cst
= val
.sdivmod (div
, FLOOR_DIV_EXPR
, &rem
);
787 if (*mult_set
&& *mult
!= cst
)
795 /* Returns true if VAL = X * DIV for some constant X. If this is the case,
796 X is stored to MULT. */
799 aff_combination_constant_multiple_p (aff_tree
*val
, aff_tree
*div
,
802 bool mult_set
= false;
805 if (val
->n
== 0 && val
->offset
.is_zero ())
807 *mult
= double_int_zero
;
810 if (val
->n
!= div
->n
)
813 if (val
->rest
|| div
->rest
)
816 if (!double_int_constant_multiple_p (val
->offset
, div
->offset
,
820 for (i
= 0; i
< div
->n
; i
++)
822 struct aff_comb_elt
*elt
823 = aff_combination_find_elt (val
, div
->elts
[i
].val
, NULL
);
826 if (!double_int_constant_multiple_p (elt
->coef
, div
->elts
[i
].coef
,
831 gcc_assert (mult_set
);
835 /* Prints the affine VAL to the FILE. */
838 print_aff (FILE *file
, aff_tree
*val
)
841 bool uns
= TYPE_UNSIGNED (val
->type
);
842 if (POINTER_TYPE_P (val
->type
))
844 fprintf (file
, "{\n type = ");
845 print_generic_expr (file
, val
->type
, TDF_VOPS
|TDF_MEMSYMS
);
846 fprintf (file
, "\n offset = ");
847 dump_double_int (file
, val
->offset
, uns
);
850 fprintf (file
, "\n elements = {\n");
851 for (i
= 0; i
< val
->n
; i
++)
853 fprintf (file
, " [%d] = ", i
);
854 print_generic_expr (file
, val
->elts
[i
].val
, TDF_VOPS
|TDF_MEMSYMS
);
856 fprintf (file
, " * ");
857 dump_double_int (file
, val
->elts
[i
].coef
, uns
);
859 fprintf (file
, ", \n");
861 fprintf (file
, "\n }");
865 fprintf (file
, "\n rest = ");
866 print_generic_expr (file
, val
->rest
, TDF_VOPS
|TDF_MEMSYMS
);
868 fprintf (file
, "\n}");
871 /* Prints the affine VAL to the standard error, used for debugging. */
874 debug_aff (aff_tree
*val
)
876 print_aff (stderr
, val
);
877 fprintf (stderr
, "\n");
880 /* Computes address of the reference REF in ADDR. The size of the accessed
881 location is stored to SIZE. Returns the ultimate containing object to
885 get_inner_reference_aff (tree ref
, aff_tree
*addr
, double_int
*size
)
887 HOST_WIDE_INT bitsize
, bitpos
;
889 enum machine_mode mode
;
892 tree base
= get_inner_reference (ref
, &bitsize
, &bitpos
, &toff
, &mode
,
894 tree base_addr
= build_fold_addr_expr (base
);
896 /* ADDR = &BASE + TOFF + BITPOS / BITS_PER_UNIT. */
898 tree_to_aff_combination (base_addr
, sizetype
, addr
);
902 tree_to_aff_combination (toff
, sizetype
, &tmp
);
903 aff_combination_add (addr
, &tmp
);
906 aff_combination_const (&tmp
, sizetype
,
907 double_int::from_shwi (bitpos
/ BITS_PER_UNIT
));
908 aff_combination_add (addr
, &tmp
);
910 *size
= double_int::from_shwi ((bitsize
+ BITS_PER_UNIT
- 1) / BITS_PER_UNIT
);
915 /* Returns true if a region of size SIZE1 at position 0 and a region of
916 size SIZE2 at position DIFF cannot overlap. */
919 aff_comb_cannot_overlap_p (aff_tree
*diff
, double_int size1
, double_int size2
)
923 /* Unless the difference is a constant, we fail. */
928 if (d
.is_negative ())
930 /* The second object is before the first one, we succeed if the last
931 element of the second object is before the start of the first one. */
932 bound
= d
+ size2
+ double_int_minus_one
;
933 return bound
.is_negative ();
937 /* We succeed if the second object starts after the first one ends. */
938 return size1
.sle (d
);