1 /* Chains of recurrences.
2 Copyright (C) 2003-2013 Free Software Foundation, Inc.
3 Contributed by Sebastian Pop <pop@cri.ensmp.fr>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 /* This file implements operations on chains of recurrences. Chains
22 of recurrences are used for modeling evolution functions of scalar
28 #include "coretypes.h"
30 #include "tree-pretty-print.h"
33 #include "tree-ssa-loop-ivopts.h"
34 #include "tree-ssa-loop-niter.h"
35 #include "tree-chrec.h"
38 #include "tree-scalar-evolution.h"
40 /* Extended folder for chrecs. */
42 /* Determines whether CST is not a constant evolution. */
45 is_not_constant_evolution (const_tree cst
)
47 return (TREE_CODE (cst
) == POLYNOMIAL_CHREC
);
50 /* Fold CODE for a polynomial function and a constant. */
53 chrec_fold_poly_cst (enum tree_code code
,
60 gcc_assert (TREE_CODE (poly
) == POLYNOMIAL_CHREC
);
61 gcc_assert (!is_not_constant_evolution (cst
));
62 gcc_assert (type
== chrec_type (poly
));
67 return build_polynomial_chrec
68 (CHREC_VARIABLE (poly
),
69 chrec_fold_plus (type
, CHREC_LEFT (poly
), cst
),
73 return build_polynomial_chrec
74 (CHREC_VARIABLE (poly
),
75 chrec_fold_minus (type
, CHREC_LEFT (poly
), cst
),
79 return build_polynomial_chrec
80 (CHREC_VARIABLE (poly
),
81 chrec_fold_multiply (type
, CHREC_LEFT (poly
), cst
),
82 chrec_fold_multiply (type
, CHREC_RIGHT (poly
), cst
));
85 return chrec_dont_know
;
89 /* Fold the addition of two polynomial functions. */
92 chrec_fold_plus_poly_poly (enum tree_code code
,
98 struct loop
*loop0
= get_chrec_loop (poly0
);
99 struct loop
*loop1
= get_chrec_loop (poly1
);
100 tree rtype
= code
== POINTER_PLUS_EXPR
? chrec_type (poly1
) : type
;
104 gcc_assert (TREE_CODE (poly0
) == POLYNOMIAL_CHREC
);
105 gcc_assert (TREE_CODE (poly1
) == POLYNOMIAL_CHREC
);
106 if (POINTER_TYPE_P (chrec_type (poly0
)))
107 gcc_assert (ptrofftype_p (chrec_type (poly1
)));
109 gcc_assert (chrec_type (poly0
) == chrec_type (poly1
));
110 gcc_assert (type
== chrec_type (poly0
));
113 {a, +, b}_1 + {c, +, d}_2 -> {{a, +, b}_1 + c, +, d}_2,
114 {a, +, b}_2 + {c, +, d}_1 -> {{c, +, d}_1 + a, +, b}_2,
115 {a, +, b}_x + {c, +, d}_x -> {a+c, +, b+d}_x. */
116 if (flow_loop_nested_p (loop0
, loop1
))
118 if (code
== PLUS_EXPR
|| code
== POINTER_PLUS_EXPR
)
119 return build_polynomial_chrec
120 (CHREC_VARIABLE (poly1
),
121 chrec_fold_plus (type
, poly0
, CHREC_LEFT (poly1
)),
122 CHREC_RIGHT (poly1
));
124 return build_polynomial_chrec
125 (CHREC_VARIABLE (poly1
),
126 chrec_fold_minus (type
, poly0
, CHREC_LEFT (poly1
)),
127 chrec_fold_multiply (type
, CHREC_RIGHT (poly1
),
128 SCALAR_FLOAT_TYPE_P (type
)
129 ? build_real (type
, dconstm1
)
130 : build_int_cst_type (type
, -1)));
133 if (flow_loop_nested_p (loop1
, loop0
))
135 if (code
== PLUS_EXPR
|| code
== POINTER_PLUS_EXPR
)
136 return build_polynomial_chrec
137 (CHREC_VARIABLE (poly0
),
138 chrec_fold_plus (type
, CHREC_LEFT (poly0
), poly1
),
139 CHREC_RIGHT (poly0
));
141 return build_polynomial_chrec
142 (CHREC_VARIABLE (poly0
),
143 chrec_fold_minus (type
, CHREC_LEFT (poly0
), poly1
),
144 CHREC_RIGHT (poly0
));
147 /* This function should never be called for chrecs of loops that
148 do not belong to the same loop nest. */
149 gcc_assert (loop0
== loop1
);
151 if (code
== PLUS_EXPR
|| code
== POINTER_PLUS_EXPR
)
153 left
= chrec_fold_plus
154 (type
, CHREC_LEFT (poly0
), CHREC_LEFT (poly1
));
155 right
= chrec_fold_plus
156 (rtype
, CHREC_RIGHT (poly0
), CHREC_RIGHT (poly1
));
160 left
= chrec_fold_minus
161 (type
, CHREC_LEFT (poly0
), CHREC_LEFT (poly1
));
162 right
= chrec_fold_minus
163 (type
, CHREC_RIGHT (poly0
), CHREC_RIGHT (poly1
));
166 if (chrec_zerop (right
))
169 return build_polynomial_chrec
170 (CHREC_VARIABLE (poly0
), left
, right
);
175 /* Fold the multiplication of two polynomial functions. */
178 chrec_fold_multiply_poly_poly (tree type
,
184 struct loop
*loop0
= get_chrec_loop (poly0
);
185 struct loop
*loop1
= get_chrec_loop (poly1
);
189 gcc_assert (TREE_CODE (poly0
) == POLYNOMIAL_CHREC
);
190 gcc_assert (TREE_CODE (poly1
) == POLYNOMIAL_CHREC
);
191 gcc_assert (chrec_type (poly0
) == chrec_type (poly1
));
192 gcc_assert (type
== chrec_type (poly0
));
194 /* {a, +, b}_1 * {c, +, d}_2 -> {c*{a, +, b}_1, +, d}_2,
195 {a, +, b}_2 * {c, +, d}_1 -> {a*{c, +, d}_1, +, b}_2,
196 {a, +, b}_x * {c, +, d}_x -> {a*c, +, a*d + b*c + b*d, +, 2*b*d}_x. */
197 if (flow_loop_nested_p (loop0
, loop1
))
198 /* poly0 is a constant wrt. poly1. */
199 return build_polynomial_chrec
200 (CHREC_VARIABLE (poly1
),
201 chrec_fold_multiply (type
, CHREC_LEFT (poly1
), poly0
),
202 CHREC_RIGHT (poly1
));
204 if (flow_loop_nested_p (loop1
, loop0
))
205 /* poly1 is a constant wrt. poly0. */
206 return build_polynomial_chrec
207 (CHREC_VARIABLE (poly0
),
208 chrec_fold_multiply (type
, CHREC_LEFT (poly0
), poly1
),
209 CHREC_RIGHT (poly0
));
211 gcc_assert (loop0
== loop1
);
213 /* poly0 and poly1 are two polynomials in the same variable,
214 {a, +, b}_x * {c, +, d}_x -> {a*c, +, a*d + b*c + b*d, +, 2*b*d}_x. */
217 t0
= chrec_fold_multiply (type
, CHREC_LEFT (poly0
), CHREC_LEFT (poly1
));
220 t1
= chrec_fold_multiply (type
, CHREC_LEFT (poly0
), CHREC_RIGHT (poly1
));
221 t1
= chrec_fold_plus (type
, t1
, chrec_fold_multiply (type
,
223 CHREC_LEFT (poly1
)));
225 t2
= chrec_fold_multiply (type
, CHREC_RIGHT (poly0
), CHREC_RIGHT (poly1
));
226 /* "a*d + b*c + b*d". */
227 t1
= chrec_fold_plus (type
, t1
, t2
);
229 t2
= chrec_fold_multiply (type
, SCALAR_FLOAT_TYPE_P (type
)
230 ? build_real (type
, dconst2
)
231 : build_int_cst (type
, 2), t2
);
233 var
= CHREC_VARIABLE (poly0
);
234 return build_polynomial_chrec (var
, t0
,
235 build_polynomial_chrec (var
, t1
, t2
));
238 /* When the operands are automatically_generated_chrec_p, the fold has
239 to respect the semantics of the operands. */
242 chrec_fold_automatically_generated_operands (tree op0
,
245 if (op0
== chrec_dont_know
246 || op1
== chrec_dont_know
)
247 return chrec_dont_know
;
249 if (op0
== chrec_known
250 || op1
== chrec_known
)
253 if (op0
== chrec_not_analyzed_yet
254 || op1
== chrec_not_analyzed_yet
)
255 return chrec_not_analyzed_yet
;
257 /* The default case produces a safe result. */
258 return chrec_dont_know
;
261 /* Fold the addition of two chrecs. */
264 chrec_fold_plus_1 (enum tree_code code
, tree type
,
267 if (automatically_generated_chrec_p (op0
)
268 || automatically_generated_chrec_p (op1
))
269 return chrec_fold_automatically_generated_operands (op0
, op1
);
271 switch (TREE_CODE (op0
))
273 case POLYNOMIAL_CHREC
:
275 (!chrec_contains_symbols_defined_in_loop (op0
, CHREC_VARIABLE (op0
)));
276 switch (TREE_CODE (op1
))
278 case POLYNOMIAL_CHREC
:
280 (!chrec_contains_symbols_defined_in_loop (op1
,
281 CHREC_VARIABLE (op1
)));
282 return chrec_fold_plus_poly_poly (code
, type
, op0
, op1
);
285 if (tree_contains_chrecs (op1
, NULL
))
286 return chrec_dont_know
;
289 if (code
== PLUS_EXPR
|| code
== POINTER_PLUS_EXPR
)
290 return build_polynomial_chrec
291 (CHREC_VARIABLE (op0
),
292 chrec_fold_plus (type
, CHREC_LEFT (op0
), op1
),
295 return build_polynomial_chrec
296 (CHREC_VARIABLE (op0
),
297 chrec_fold_minus (type
, CHREC_LEFT (op0
), op1
),
302 if (tree_contains_chrecs (op0
, NULL
))
303 return chrec_dont_know
;
306 switch (TREE_CODE (op1
))
308 case POLYNOMIAL_CHREC
:
310 (!chrec_contains_symbols_defined_in_loop (op1
,
311 CHREC_VARIABLE (op1
)));
312 if (code
== PLUS_EXPR
|| code
== POINTER_PLUS_EXPR
)
313 return build_polynomial_chrec
314 (CHREC_VARIABLE (op1
),
315 chrec_fold_plus (type
, op0
, CHREC_LEFT (op1
)),
318 return build_polynomial_chrec
319 (CHREC_VARIABLE (op1
),
320 chrec_fold_minus (type
, op0
, CHREC_LEFT (op1
)),
321 chrec_fold_multiply (type
, CHREC_RIGHT (op1
),
322 SCALAR_FLOAT_TYPE_P (type
)
323 ? build_real (type
, dconstm1
)
324 : build_int_cst_type (type
, -1)));
327 if (tree_contains_chrecs (op1
, NULL
))
328 return chrec_dont_know
;
333 if ((tree_contains_chrecs (op0
, &size
)
334 || tree_contains_chrecs (op1
, &size
))
335 && size
< PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE
))
336 return build2 (code
, type
, op0
, op1
);
337 else if (size
< PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE
))
339 if (code
== POINTER_PLUS_EXPR
)
340 return fold_build_pointer_plus (fold_convert (type
, op0
),
343 return fold_build2 (code
, type
,
344 fold_convert (type
, op0
),
345 fold_convert (type
, op1
));
348 return chrec_dont_know
;
354 /* Fold the addition of two chrecs. */
357 chrec_fold_plus (tree type
,
362 if (automatically_generated_chrec_p (op0
)
363 || automatically_generated_chrec_p (op1
))
364 return chrec_fold_automatically_generated_operands (op0
, op1
);
366 if (integer_zerop (op0
))
367 return chrec_convert (type
, op1
, NULL
);
368 if (integer_zerop (op1
))
369 return chrec_convert (type
, op0
, NULL
);
371 if (POINTER_TYPE_P (type
))
372 code
= POINTER_PLUS_EXPR
;
376 return chrec_fold_plus_1 (code
, type
, op0
, op1
);
379 /* Fold the subtraction of two chrecs. */
382 chrec_fold_minus (tree type
,
386 if (automatically_generated_chrec_p (op0
)
387 || automatically_generated_chrec_p (op1
))
388 return chrec_fold_automatically_generated_operands (op0
, op1
);
390 if (integer_zerop (op1
))
393 return chrec_fold_plus_1 (MINUS_EXPR
, type
, op0
, op1
);
396 /* Fold the multiplication of two chrecs. */
399 chrec_fold_multiply (tree type
,
403 if (automatically_generated_chrec_p (op0
)
404 || automatically_generated_chrec_p (op1
))
405 return chrec_fold_automatically_generated_operands (op0
, op1
);
407 switch (TREE_CODE (op0
))
409 case POLYNOMIAL_CHREC
:
411 (!chrec_contains_symbols_defined_in_loop (op0
, CHREC_VARIABLE (op0
)));
412 switch (TREE_CODE (op1
))
414 case POLYNOMIAL_CHREC
:
416 (!chrec_contains_symbols_defined_in_loop (op1
,
417 CHREC_VARIABLE (op1
)));
418 return chrec_fold_multiply_poly_poly (type
, op0
, op1
);
421 if (tree_contains_chrecs (op1
, NULL
))
422 return chrec_dont_know
;
425 if (integer_onep (op1
))
427 if (integer_zerop (op1
))
428 return build_int_cst (type
, 0);
430 return build_polynomial_chrec
431 (CHREC_VARIABLE (op0
),
432 chrec_fold_multiply (type
, CHREC_LEFT (op0
), op1
),
433 chrec_fold_multiply (type
, CHREC_RIGHT (op0
), op1
));
437 if (tree_contains_chrecs (op0
, NULL
))
438 return chrec_dont_know
;
441 if (integer_onep (op0
))
444 if (integer_zerop (op0
))
445 return build_int_cst (type
, 0);
447 switch (TREE_CODE (op1
))
449 case POLYNOMIAL_CHREC
:
451 (!chrec_contains_symbols_defined_in_loop (op1
,
452 CHREC_VARIABLE (op1
)));
453 return build_polynomial_chrec
454 (CHREC_VARIABLE (op1
),
455 chrec_fold_multiply (type
, CHREC_LEFT (op1
), op0
),
456 chrec_fold_multiply (type
, CHREC_RIGHT (op1
), op0
));
459 if (tree_contains_chrecs (op1
, NULL
))
460 return chrec_dont_know
;
463 if (integer_onep (op1
))
465 if (integer_zerop (op1
))
466 return build_int_cst (type
, 0);
467 return fold_build2 (MULT_EXPR
, type
, op0
, op1
);
476 /* Evaluate the binomial coefficient. Return NULL_TREE if the intermediate
477 calculation overflows, otherwise return C(n,k) with type TYPE. */
480 tree_fold_binomial (tree type
, tree n
, unsigned int k
)
482 double_int num
, denom
, idx
, di_res
;
487 /* Handle the most frequent cases. */
489 return build_int_cst (type
, 1);
491 return fold_convert (type
, n
);
494 num
= TREE_INT_CST (n
);
496 /* Check that k <= n. */
497 if (num
.ult (double_int::from_uhwi (k
)))
500 /* Denominator = 2. */
501 denom
= double_int::from_uhwi (2);
503 /* Index = Numerator-1. */
504 idx
= num
- double_int_one
;
506 /* Numerator = Numerator*Index = n*(n-1). */
507 num
= num
.mul_with_sign (idx
, false, &overflow
);
511 for (i
= 3; i
<= k
; i
++)
516 /* Numerator *= Index. */
517 num
= num
.mul_with_sign (idx
, false, &overflow
);
521 /* Denominator *= i. */
522 denom
*= double_int::from_uhwi (i
);
525 /* Result = Numerator / Denominator. */
526 di_res
= num
.div (denom
, true, EXACT_DIV_EXPR
);
527 res
= build_int_cst_wide (type
, di_res
.low
, di_res
.high
);
528 return int_fits_type_p (res
, type
) ? res
: NULL_TREE
;
531 /* Helper function. Use the Newton's interpolating formula for
532 evaluating the value of the evolution function. */
535 chrec_evaluate (unsigned var
, tree chrec
, tree n
, unsigned int k
)
537 tree arg0
, arg1
, binomial_n_k
;
538 tree type
= TREE_TYPE (chrec
);
539 struct loop
*var_loop
= get_loop (cfun
, var
);
541 while (TREE_CODE (chrec
) == POLYNOMIAL_CHREC
542 && flow_loop_nested_p (var_loop
, get_chrec_loop (chrec
)))
543 chrec
= CHREC_LEFT (chrec
);
545 if (TREE_CODE (chrec
) == POLYNOMIAL_CHREC
546 && CHREC_VARIABLE (chrec
) == var
)
548 arg1
= chrec_evaluate (var
, CHREC_RIGHT (chrec
), n
, k
+ 1);
549 if (arg1
== chrec_dont_know
)
550 return chrec_dont_know
;
551 binomial_n_k
= tree_fold_binomial (type
, n
, k
);
553 return chrec_dont_know
;
554 arg0
= fold_build2 (MULT_EXPR
, type
,
555 CHREC_LEFT (chrec
), binomial_n_k
);
556 return chrec_fold_plus (type
, arg0
, arg1
);
559 binomial_n_k
= tree_fold_binomial (type
, n
, k
);
561 return chrec_dont_know
;
563 return fold_build2 (MULT_EXPR
, type
, chrec
, binomial_n_k
);
566 /* Evaluates "CHREC (X)" when the varying variable is VAR.
567 Example: Given the following parameters,
573 The result is given by the Newton's interpolating formula:
574 3 * \binom{10}{0} + 4 * \binom{10}{1}.
578 chrec_apply (unsigned var
,
582 tree type
= chrec_type (chrec
);
583 tree res
= chrec_dont_know
;
585 if (automatically_generated_chrec_p (chrec
)
586 || automatically_generated_chrec_p (x
)
588 /* When the symbols are defined in an outer loop, it is possible
589 to symbolically compute the apply, since the symbols are
590 constants with respect to the varying loop. */
591 || chrec_contains_symbols_defined_in_loop (chrec
, var
))
592 return chrec_dont_know
;
594 if (dump_file
&& (dump_flags
& TDF_SCEV
))
595 fprintf (dump_file
, "(chrec_apply \n");
597 if (TREE_CODE (x
) == INTEGER_CST
&& SCALAR_FLOAT_TYPE_P (type
))
598 x
= build_real_from_int_cst (type
, x
);
600 switch (TREE_CODE (chrec
))
602 case POLYNOMIAL_CHREC
:
603 if (evolution_function_is_affine_p (chrec
))
605 if (CHREC_VARIABLE (chrec
) != var
)
606 return build_polynomial_chrec
607 (CHREC_VARIABLE (chrec
),
608 chrec_apply (var
, CHREC_LEFT (chrec
), x
),
609 chrec_apply (var
, CHREC_RIGHT (chrec
), x
));
611 /* "{a, +, b} (x)" -> "a + b*x". */
612 x
= chrec_convert_rhs (type
, x
, NULL
);
613 res
= chrec_fold_multiply (TREE_TYPE (x
), CHREC_RIGHT (chrec
), x
);
614 res
= chrec_fold_plus (type
, CHREC_LEFT (chrec
), res
);
616 else if (TREE_CODE (x
) == INTEGER_CST
617 && tree_int_cst_sgn (x
) == 1)
618 /* testsuite/.../ssa-chrec-38.c. */
619 res
= chrec_evaluate (var
, chrec
, x
, 0);
621 res
= chrec_dont_know
;
625 res
= chrec_convert (TREE_TYPE (chrec
),
626 chrec_apply (var
, TREE_OPERAND (chrec
, 0), x
),
635 if (dump_file
&& (dump_flags
& TDF_SCEV
))
637 fprintf (dump_file
, " (varying_loop = %d\n", var
);
638 fprintf (dump_file
, ")\n (chrec = ");
639 print_generic_expr (dump_file
, chrec
, 0);
640 fprintf (dump_file
, ")\n (x = ");
641 print_generic_expr (dump_file
, x
, 0);
642 fprintf (dump_file
, ")\n (res = ");
643 print_generic_expr (dump_file
, res
, 0);
644 fprintf (dump_file
, "))\n");
650 /* For a given CHREC and an induction variable map IV_MAP that maps
651 (loop->num, expr) for every loop number of the current_loops an
652 expression, calls chrec_apply when the expression is not NULL. */
655 chrec_apply_map (tree chrec
, vec
<tree
> iv_map
)
660 FOR_EACH_VEC_ELT (iv_map
, i
, expr
)
662 chrec
= chrec_apply (i
, chrec
, expr
);
667 /* Replaces the initial condition in CHREC with INIT_COND. */
670 chrec_replace_initial_condition (tree chrec
,
673 if (automatically_generated_chrec_p (chrec
))
676 gcc_assert (chrec_type (chrec
) == chrec_type (init_cond
));
678 switch (TREE_CODE (chrec
))
680 case POLYNOMIAL_CHREC
:
681 return build_polynomial_chrec
682 (CHREC_VARIABLE (chrec
),
683 chrec_replace_initial_condition (CHREC_LEFT (chrec
), init_cond
),
684 CHREC_RIGHT (chrec
));
691 /* Returns the initial condition of a given CHREC. */
694 initial_condition (tree chrec
)
696 if (automatically_generated_chrec_p (chrec
))
699 if (TREE_CODE (chrec
) == POLYNOMIAL_CHREC
)
700 return initial_condition (CHREC_LEFT (chrec
));
705 /* Returns a univariate function that represents the evolution in
706 LOOP_NUM. Mask the evolution of any other loop. */
709 hide_evolution_in_other_loops_than_loop (tree chrec
,
712 struct loop
*loop
= get_loop (cfun
, loop_num
), *chloop
;
713 if (automatically_generated_chrec_p (chrec
))
716 switch (TREE_CODE (chrec
))
718 case POLYNOMIAL_CHREC
:
719 chloop
= get_chrec_loop (chrec
);
722 return build_polynomial_chrec
724 hide_evolution_in_other_loops_than_loop (CHREC_LEFT (chrec
),
726 CHREC_RIGHT (chrec
));
728 else if (flow_loop_nested_p (chloop
, loop
))
729 /* There is no evolution in this loop. */
730 return initial_condition (chrec
);
734 gcc_assert (flow_loop_nested_p (loop
, chloop
));
735 return hide_evolution_in_other_loops_than_loop (CHREC_LEFT (chrec
),
744 /* Returns the evolution part of CHREC in LOOP_NUM when RIGHT is
745 true, otherwise returns the initial condition in LOOP_NUM. */
748 chrec_component_in_loop_num (tree chrec
,
753 struct loop
*loop
= get_loop (cfun
, loop_num
), *chloop
;
755 if (automatically_generated_chrec_p (chrec
))
758 switch (TREE_CODE (chrec
))
760 case POLYNOMIAL_CHREC
:
761 chloop
= get_chrec_loop (chrec
);
766 component
= CHREC_RIGHT (chrec
);
768 component
= CHREC_LEFT (chrec
);
770 if (TREE_CODE (CHREC_LEFT (chrec
)) != POLYNOMIAL_CHREC
771 || CHREC_VARIABLE (CHREC_LEFT (chrec
)) != CHREC_VARIABLE (chrec
))
775 return build_polynomial_chrec
777 chrec_component_in_loop_num (CHREC_LEFT (chrec
),
783 else if (flow_loop_nested_p (chloop
, loop
))
784 /* There is no evolution part in this loop. */
789 gcc_assert (flow_loop_nested_p (loop
, chloop
));
790 return chrec_component_in_loop_num (CHREC_LEFT (chrec
),
803 /* Returns the evolution part in LOOP_NUM. Example: the call
804 evolution_part_in_loop_num ({{0, +, 1}_1, +, 2}_1, 1) returns
808 evolution_part_in_loop_num (tree chrec
,
811 return chrec_component_in_loop_num (chrec
, loop_num
, true);
814 /* Returns the initial condition in LOOP_NUM. Example: the call
815 initial_condition_in_loop_num ({{0, +, 1}_1, +, 2}_2, 2) returns
819 initial_condition_in_loop_num (tree chrec
,
822 return chrec_component_in_loop_num (chrec
, loop_num
, false);
825 /* Set or reset the evolution of CHREC to NEW_EVOL in loop LOOP_NUM.
826 This function is essentially used for setting the evolution to
827 chrec_dont_know, for example after having determined that it is
828 impossible to say how many times a loop will execute. */
831 reset_evolution_in_loop (unsigned loop_num
,
835 struct loop
*loop
= get_loop (cfun
, loop_num
);
837 if (POINTER_TYPE_P (chrec_type (chrec
)))
838 gcc_assert (ptrofftype_p (chrec_type (new_evol
)));
840 gcc_assert (chrec_type (chrec
) == chrec_type (new_evol
));
842 if (TREE_CODE (chrec
) == POLYNOMIAL_CHREC
843 && flow_loop_nested_p (loop
, get_chrec_loop (chrec
)))
845 tree left
= reset_evolution_in_loop (loop_num
, CHREC_LEFT (chrec
),
847 tree right
= reset_evolution_in_loop (loop_num
, CHREC_RIGHT (chrec
),
849 return build3 (POLYNOMIAL_CHREC
, TREE_TYPE (left
),
850 CHREC_VAR (chrec
), left
, right
);
853 while (TREE_CODE (chrec
) == POLYNOMIAL_CHREC
854 && CHREC_VARIABLE (chrec
) == loop_num
)
855 chrec
= CHREC_LEFT (chrec
);
857 return build_polynomial_chrec (loop_num
, chrec
, new_evol
);
860 /* Merges two evolution functions that were found by following two
861 alternate paths of a conditional expression. */
864 chrec_merge (tree chrec1
,
867 if (chrec1
== chrec_dont_know
868 || chrec2
== chrec_dont_know
)
869 return chrec_dont_know
;
871 if (chrec1
== chrec_known
872 || chrec2
== chrec_known
)
875 if (chrec1
== chrec_not_analyzed_yet
)
877 if (chrec2
== chrec_not_analyzed_yet
)
880 if (eq_evolutions_p (chrec1
, chrec2
))
883 return chrec_dont_know
;
890 /* Helper function for is_multivariate_chrec. */
893 is_multivariate_chrec_rec (const_tree chrec
, unsigned int rec_var
)
895 if (chrec
== NULL_TREE
)
898 if (TREE_CODE (chrec
) == POLYNOMIAL_CHREC
)
900 if (CHREC_VARIABLE (chrec
) != rec_var
)
903 return (is_multivariate_chrec_rec (CHREC_LEFT (chrec
), rec_var
)
904 || is_multivariate_chrec_rec (CHREC_RIGHT (chrec
), rec_var
));
910 /* Determine whether the given chrec is multivariate or not. */
913 is_multivariate_chrec (const_tree chrec
)
915 if (chrec
== NULL_TREE
)
918 if (TREE_CODE (chrec
) == POLYNOMIAL_CHREC
)
919 return (is_multivariate_chrec_rec (CHREC_LEFT (chrec
),
920 CHREC_VARIABLE (chrec
))
921 || is_multivariate_chrec_rec (CHREC_RIGHT (chrec
),
922 CHREC_VARIABLE (chrec
)));
927 /* Determines whether the chrec contains symbolic names or not. */
930 chrec_contains_symbols (const_tree chrec
)
934 if (chrec
== NULL_TREE
)
937 if (TREE_CODE (chrec
) == SSA_NAME
938 || TREE_CODE (chrec
) == VAR_DECL
939 || TREE_CODE (chrec
) == PARM_DECL
940 || TREE_CODE (chrec
) == FUNCTION_DECL
941 || TREE_CODE (chrec
) == LABEL_DECL
942 || TREE_CODE (chrec
) == RESULT_DECL
943 || TREE_CODE (chrec
) == FIELD_DECL
)
946 n
= TREE_OPERAND_LENGTH (chrec
);
947 for (i
= 0; i
< n
; i
++)
948 if (chrec_contains_symbols (TREE_OPERAND (chrec
, i
)))
953 /* Determines whether the chrec contains undetermined coefficients. */
956 chrec_contains_undetermined (const_tree chrec
)
960 if (chrec
== chrec_dont_know
)
963 if (chrec
== NULL_TREE
)
966 n
= TREE_OPERAND_LENGTH (chrec
);
967 for (i
= 0; i
< n
; i
++)
968 if (chrec_contains_undetermined (TREE_OPERAND (chrec
, i
)))
973 /* Determines whether the tree EXPR contains chrecs, and increment
974 SIZE if it is not a NULL pointer by an estimation of the depth of
978 tree_contains_chrecs (const_tree expr
, int *size
)
982 if (expr
== NULL_TREE
)
988 if (tree_is_chrec (expr
))
991 n
= TREE_OPERAND_LENGTH (expr
);
992 for (i
= 0; i
< n
; i
++)
993 if (tree_contains_chrecs (TREE_OPERAND (expr
, i
), size
))
998 /* Recursive helper function. */
1001 evolution_function_is_invariant_rec_p (tree chrec
, int loopnum
)
1003 if (evolution_function_is_constant_p (chrec
))
1006 if (TREE_CODE (chrec
) == SSA_NAME
1008 || expr_invariant_in_loop_p (get_loop (cfun
, loopnum
), chrec
)))
1011 if (TREE_CODE (chrec
) == POLYNOMIAL_CHREC
)
1013 if (CHREC_VARIABLE (chrec
) == (unsigned) loopnum
1014 || flow_loop_nested_p (get_loop (cfun
, loopnum
),
1015 get_chrec_loop (chrec
))
1016 || !evolution_function_is_invariant_rec_p (CHREC_RIGHT (chrec
),
1018 || !evolution_function_is_invariant_rec_p (CHREC_LEFT (chrec
),
1024 switch (TREE_OPERAND_LENGTH (chrec
))
1027 if (!evolution_function_is_invariant_rec_p (TREE_OPERAND (chrec
, 1),
1032 if (!evolution_function_is_invariant_rec_p (TREE_OPERAND (chrec
, 0),
1044 /* Return true if CHREC is invariant in loop LOOPNUM, false otherwise. */
1047 evolution_function_is_invariant_p (tree chrec
, int loopnum
)
1049 return evolution_function_is_invariant_rec_p (chrec
, loopnum
);
1052 /* Determine whether the given tree is an affine multivariate
1056 evolution_function_is_affine_multivariate_p (const_tree chrec
, int loopnum
)
1058 if (chrec
== NULL_TREE
)
1061 switch (TREE_CODE (chrec
))
1063 case POLYNOMIAL_CHREC
:
1064 if (evolution_function_is_invariant_rec_p (CHREC_LEFT (chrec
), loopnum
))
1066 if (evolution_function_is_invariant_rec_p (CHREC_RIGHT (chrec
), loopnum
))
1070 if (TREE_CODE (CHREC_RIGHT (chrec
)) == POLYNOMIAL_CHREC
1071 && CHREC_VARIABLE (CHREC_RIGHT (chrec
))
1072 != CHREC_VARIABLE (chrec
)
1073 && evolution_function_is_affine_multivariate_p
1074 (CHREC_RIGHT (chrec
), loopnum
))
1082 if (evolution_function_is_invariant_rec_p (CHREC_RIGHT (chrec
), loopnum
)
1083 && TREE_CODE (CHREC_LEFT (chrec
)) == POLYNOMIAL_CHREC
1084 && CHREC_VARIABLE (CHREC_LEFT (chrec
)) != CHREC_VARIABLE (chrec
)
1085 && evolution_function_is_affine_multivariate_p
1086 (CHREC_LEFT (chrec
), loopnum
))
1097 /* Determine whether the given tree is a function in zero or one
1101 evolution_function_is_univariate_p (const_tree chrec
)
1103 if (chrec
== NULL_TREE
)
1106 switch (TREE_CODE (chrec
))
1108 case POLYNOMIAL_CHREC
:
1109 switch (TREE_CODE (CHREC_LEFT (chrec
)))
1111 case POLYNOMIAL_CHREC
:
1112 if (CHREC_VARIABLE (chrec
) != CHREC_VARIABLE (CHREC_LEFT (chrec
)))
1114 if (!evolution_function_is_univariate_p (CHREC_LEFT (chrec
)))
1119 if (tree_contains_chrecs (CHREC_LEFT (chrec
), NULL
))
1124 switch (TREE_CODE (CHREC_RIGHT (chrec
)))
1126 case POLYNOMIAL_CHREC
:
1127 if (CHREC_VARIABLE (chrec
) != CHREC_VARIABLE (CHREC_RIGHT (chrec
)))
1129 if (!evolution_function_is_univariate_p (CHREC_RIGHT (chrec
)))
1134 if (tree_contains_chrecs (CHREC_RIGHT (chrec
), NULL
))
1144 /* Returns the number of variables of CHREC. Example: the call
1145 nb_vars_in_chrec ({{0, +, 1}_5, +, 2}_6) returns 2. */
1148 nb_vars_in_chrec (tree chrec
)
1150 if (chrec
== NULL_TREE
)
1153 switch (TREE_CODE (chrec
))
1155 case POLYNOMIAL_CHREC
:
1156 return 1 + nb_vars_in_chrec
1157 (initial_condition_in_loop_num (chrec
, CHREC_VARIABLE (chrec
)));
1164 static tree
chrec_convert_1 (tree
, tree
, gimple
, bool);
1166 /* Converts BASE and STEP of affine scev to TYPE. LOOP is the loop whose iv
1167 the scev corresponds to. AT_STMT is the statement at that the scev is
1168 evaluated. USE_OVERFLOW_SEMANTICS is true if this function should assume that
1169 the rules for overflow of the given language apply (e.g., that signed
1170 arithmetics in C does not overflow) -- i.e., to use them to avoid unnecessary
1171 tests, but also to enforce that the result follows them. Returns true if the
1172 conversion succeeded, false otherwise. */
1175 convert_affine_scev (struct loop
*loop
, tree type
,
1176 tree
*base
, tree
*step
, gimple at_stmt
,
1177 bool use_overflow_semantics
)
1179 tree ct
= TREE_TYPE (*step
);
1180 bool enforce_overflow_semantics
;
1181 bool must_check_src_overflow
, must_check_rslt_overflow
;
1182 tree new_base
, new_step
;
1183 tree step_type
= POINTER_TYPE_P (type
) ? sizetype
: type
;
1186 (TYPE) (BASE + STEP * i) = (TYPE) BASE + (TYPE -- sign extend) STEP * i,
1187 but we must check some assumptions.
1189 1) If [BASE, +, STEP] wraps, the equation is not valid when precision
1190 of CT is smaller than the precision of TYPE. For example, when we
1191 cast unsigned char [254, +, 1] to unsigned, the values on left side
1192 are 254, 255, 0, 1, ..., but those on the right side are
1193 254, 255, 256, 257, ...
1194 2) In case that we must also preserve the fact that signed ivs do not
1195 overflow, we must additionally check that the new iv does not wrap.
1196 For example, unsigned char [125, +, 1] casted to signed char could
1197 become a wrapping variable with values 125, 126, 127, -128, -127, ...,
1198 which would confuse optimizers that assume that this does not
1200 must_check_src_overflow
= TYPE_PRECISION (ct
) < TYPE_PRECISION (type
);
1202 enforce_overflow_semantics
= (use_overflow_semantics
1203 && nowrap_type_p (type
));
1204 if (enforce_overflow_semantics
)
1206 /* We can avoid checking whether the result overflows in the following
1209 -- must_check_src_overflow is true, and the range of TYPE is superset
1210 of the range of CT -- i.e., in all cases except if CT signed and
1212 -- both CT and TYPE have the same precision and signedness, and we
1213 verify instead that the source does not overflow (this may be
1214 easier than verifying it for the result, as we may use the
1215 information about the semantics of overflow in CT). */
1216 if (must_check_src_overflow
)
1218 if (TYPE_UNSIGNED (type
) && !TYPE_UNSIGNED (ct
))
1219 must_check_rslt_overflow
= true;
1221 must_check_rslt_overflow
= false;
1223 else if (TYPE_UNSIGNED (ct
) == TYPE_UNSIGNED (type
)
1224 && TYPE_PRECISION (ct
) == TYPE_PRECISION (type
))
1226 must_check_rslt_overflow
= false;
1227 must_check_src_overflow
= true;
1230 must_check_rslt_overflow
= true;
1233 must_check_rslt_overflow
= false;
1235 if (must_check_src_overflow
1236 && scev_probably_wraps_p (*base
, *step
, at_stmt
, loop
,
1237 use_overflow_semantics
))
1240 new_base
= chrec_convert_1 (type
, *base
, at_stmt
,
1241 use_overflow_semantics
);
1242 /* The step must be sign extended, regardless of the signedness
1243 of CT and TYPE. This only needs to be handled specially when
1244 CT is unsigned -- to avoid e.g. unsigned char [100, +, 255]
1245 (with values 100, 99, 98, ...) from becoming signed or unsigned
1246 [100, +, 255] with values 100, 355, ...; the sign-extension is
1247 performed by default when CT is signed. */
1249 if (TYPE_PRECISION (step_type
) > TYPE_PRECISION (ct
) && TYPE_UNSIGNED (ct
))
1251 tree signed_ct
= build_nonstandard_integer_type (TYPE_PRECISION (ct
), 0);
1252 new_step
= chrec_convert_1 (signed_ct
, new_step
, at_stmt
,
1253 use_overflow_semantics
);
1255 new_step
= chrec_convert_1 (step_type
, new_step
, at_stmt
, use_overflow_semantics
);
1257 if (automatically_generated_chrec_p (new_base
)
1258 || automatically_generated_chrec_p (new_step
))
1261 if (must_check_rslt_overflow
1262 /* Note that in this case we cannot use the fact that signed variables
1263 do not overflow, as this is what we are verifying for the new iv. */
1264 && scev_probably_wraps_p (new_base
, new_step
, at_stmt
, loop
, false))
1273 /* Convert CHREC for the right hand side of a CHREC.
1274 The increment for a pointer type is always sizetype. */
1277 chrec_convert_rhs (tree type
, tree chrec
, gimple at_stmt
)
1279 if (POINTER_TYPE_P (type
))
1282 return chrec_convert (type
, chrec
, at_stmt
);
1285 /* Convert CHREC to TYPE. When the analyzer knows the context in
1286 which the CHREC is built, it sets AT_STMT to the statement that
1287 contains the definition of the analyzed variable, otherwise the
1288 conversion is less accurate: the information is used for
1289 determining a more accurate estimation of the number of iterations.
1290 By default AT_STMT could be safely set to NULL_TREE.
1292 The following rule is always true: TREE_TYPE (chrec) ==
1293 TREE_TYPE (CHREC_LEFT (chrec)) == TREE_TYPE (CHREC_RIGHT (chrec)).
1294 An example of what could happen when adding two chrecs and the type
1295 of the CHREC_RIGHT is different than CHREC_LEFT is:
1297 {(uint) 0, +, (uchar) 10} +
1298 {(uint) 0, +, (uchar) 250}
1300 that would produce a wrong result if CHREC_RIGHT is not (uint):
1302 {(uint) 0, +, (uchar) 4}
1306 {(uint) 0, +, (uint) 260}
1310 chrec_convert (tree type
, tree chrec
, gimple at_stmt
)
1312 return chrec_convert_1 (type
, chrec
, at_stmt
, true);
1315 /* Convert CHREC to TYPE. When the analyzer knows the context in
1316 which the CHREC is built, it sets AT_STMT to the statement that
1317 contains the definition of the analyzed variable, otherwise the
1318 conversion is less accurate: the information is used for
1319 determining a more accurate estimation of the number of iterations.
1320 By default AT_STMT could be safely set to NULL_TREE.
1322 USE_OVERFLOW_SEMANTICS is true if this function should assume that
1323 the rules for overflow of the given language apply (e.g., that signed
1324 arithmetics in C does not overflow) -- i.e., to use them to avoid unnecessary
1325 tests, but also to enforce that the result follows them. */
1328 chrec_convert_1 (tree type
, tree chrec
, gimple at_stmt
,
1329 bool use_overflow_semantics
)
1335 if (automatically_generated_chrec_p (chrec
))
1338 ct
= chrec_type (chrec
);
1342 if (!evolution_function_is_affine_p (chrec
))
1345 loop
= get_chrec_loop (chrec
);
1346 base
= CHREC_LEFT (chrec
);
1347 step
= CHREC_RIGHT (chrec
);
1349 if (convert_affine_scev (loop
, type
, &base
, &step
, at_stmt
,
1350 use_overflow_semantics
))
1351 return build_polynomial_chrec (loop
->num
, base
, step
);
1353 /* If we cannot propagate the cast inside the chrec, just keep the cast. */
1355 /* Fold will not canonicalize (long)(i - 1) to (long)i - 1 because that
1356 may be more expensive. We do want to perform this optimization here
1357 though for canonicalization reasons. */
1358 if (use_overflow_semantics
1359 && (TREE_CODE (chrec
) == PLUS_EXPR
1360 || TREE_CODE (chrec
) == MINUS_EXPR
)
1361 && TREE_CODE (type
) == INTEGER_TYPE
1362 && TREE_CODE (ct
) == INTEGER_TYPE
1363 && TYPE_PRECISION (type
) > TYPE_PRECISION (ct
)
1364 && TYPE_OVERFLOW_UNDEFINED (ct
))
1365 res
= fold_build2 (TREE_CODE (chrec
), type
,
1366 fold_convert (type
, TREE_OPERAND (chrec
, 0)),
1367 fold_convert (type
, TREE_OPERAND (chrec
, 1)));
1368 /* Similar perform the trick that (signed char)((int)x + 2) can be
1369 narrowed to (signed char)((unsigned char)x + 2). */
1370 else if (use_overflow_semantics
1371 && TREE_CODE (chrec
) == POLYNOMIAL_CHREC
1372 && TREE_CODE (ct
) == INTEGER_TYPE
1373 && TREE_CODE (type
) == INTEGER_TYPE
1374 && TYPE_OVERFLOW_UNDEFINED (type
)
1375 && TYPE_PRECISION (type
) < TYPE_PRECISION (ct
))
1377 tree utype
= unsigned_type_for (type
);
1378 res
= build_polynomial_chrec (CHREC_VARIABLE (chrec
),
1379 fold_convert (utype
,
1380 CHREC_LEFT (chrec
)),
1381 fold_convert (utype
,
1382 CHREC_RIGHT (chrec
)));
1383 res
= chrec_convert_1 (type
, res
, at_stmt
, use_overflow_semantics
);
1386 res
= fold_convert (type
, chrec
);
1388 /* Don't propagate overflows. */
1389 if (CONSTANT_CLASS_P (res
))
1390 TREE_OVERFLOW (res
) = 0;
1392 /* But reject constants that don't fit in their type after conversion.
1393 This can happen if TYPE_MIN_VALUE or TYPE_MAX_VALUE are not the
1394 natural values associated with TYPE_PRECISION and TYPE_UNSIGNED,
1395 and can cause problems later when computing niters of loops. Note
1396 that we don't do the check before converting because we don't want
1397 to reject conversions of negative chrecs to unsigned types. */
1398 if (TREE_CODE (res
) == INTEGER_CST
1399 && TREE_CODE (type
) == INTEGER_TYPE
1400 && !int_fits_type_p (res
, type
))
1401 res
= chrec_dont_know
;
1406 /* Convert CHREC to TYPE, without regard to signed overflows. Returns the new
1407 chrec if something else than what chrec_convert would do happens, NULL_TREE
1411 chrec_convert_aggressive (tree type
, tree chrec
)
1413 tree inner_type
, left
, right
, lc
, rc
, rtype
;
1415 if (automatically_generated_chrec_p (chrec
)
1416 || TREE_CODE (chrec
) != POLYNOMIAL_CHREC
)
1419 inner_type
= TREE_TYPE (chrec
);
1420 if (TYPE_PRECISION (type
) > TYPE_PRECISION (inner_type
))
1423 rtype
= POINTER_TYPE_P (type
) ? sizetype
: type
;
1425 left
= CHREC_LEFT (chrec
);
1426 right
= CHREC_RIGHT (chrec
);
1427 lc
= chrec_convert_aggressive (type
, left
);
1429 lc
= chrec_convert (type
, left
, NULL
);
1430 rc
= chrec_convert_aggressive (rtype
, right
);
1432 rc
= chrec_convert (rtype
, right
, NULL
);
1434 return build_polynomial_chrec (CHREC_VARIABLE (chrec
), lc
, rc
);
1437 /* Returns true when CHREC0 == CHREC1. */
1440 eq_evolutions_p (const_tree chrec0
, const_tree chrec1
)
1442 if (chrec0
== NULL_TREE
1443 || chrec1
== NULL_TREE
1444 || TREE_CODE (chrec0
) != TREE_CODE (chrec1
))
1447 if (chrec0
== chrec1
)
1450 switch (TREE_CODE (chrec0
))
1453 return operand_equal_p (chrec0
, chrec1
, 0);
1455 case POLYNOMIAL_CHREC
:
1456 return (CHREC_VARIABLE (chrec0
) == CHREC_VARIABLE (chrec1
)
1457 && eq_evolutions_p (CHREC_LEFT (chrec0
), CHREC_LEFT (chrec1
))
1458 && eq_evolutions_p (CHREC_RIGHT (chrec0
), CHREC_RIGHT (chrec1
)));
1463 case POINTER_PLUS_EXPR
:
1464 return eq_evolutions_p (TREE_OPERAND (chrec0
, 0),
1465 TREE_OPERAND (chrec1
, 0))
1466 && eq_evolutions_p (TREE_OPERAND (chrec0
, 1),
1467 TREE_OPERAND (chrec1
, 1));
1474 /* Returns EV_GROWS if CHREC grows (assuming that it does not overflow),
1475 EV_DECREASES if it decreases, and EV_UNKNOWN if we cannot determine
1476 which of these cases happens. */
1479 scev_direction (const_tree chrec
)
1483 if (!evolution_function_is_affine_p (chrec
))
1484 return EV_DIR_UNKNOWN
;
1486 step
= CHREC_RIGHT (chrec
);
1487 if (TREE_CODE (step
) != INTEGER_CST
)
1488 return EV_DIR_UNKNOWN
;
1490 if (tree_int_cst_sign_bit (step
))
1491 return EV_DIR_DECREASES
;
1493 return EV_DIR_GROWS
;
1496 /* Iterates over all the components of SCEV, and calls CBCK. */
1499 for_each_scev_op (tree
*scev
, bool (*cbck
) (tree
*, void *), void *data
)
1501 switch (TREE_CODE_LENGTH (TREE_CODE (*scev
)))
1504 for_each_scev_op (&TREE_OPERAND (*scev
, 2), cbck
, data
);
1507 for_each_scev_op (&TREE_OPERAND (*scev
, 1), cbck
, data
);
1510 for_each_scev_op (&TREE_OPERAND (*scev
, 0), cbck
, data
);
1518 /* Returns true when the operation can be part of a linear
1522 operator_is_linear (tree scev
)
1524 switch (TREE_CODE (scev
))
1527 case POLYNOMIAL_CHREC
:
1529 case POINTER_PLUS_EXPR
:
1534 case NON_LVALUE_EXPR
:
1544 /* Return true when SCEV is a linear expression. Linear expressions
1545 can contain additions, substractions and multiplications.
1546 Multiplications are restricted to constant scaling: "cst * x". */
1549 scev_is_linear_expression (tree scev
)
1552 || !operator_is_linear (scev
))
1555 if (TREE_CODE (scev
) == MULT_EXPR
)
1556 return !(tree_contains_chrecs (TREE_OPERAND (scev
, 0), NULL
)
1557 && tree_contains_chrecs (TREE_OPERAND (scev
, 1), NULL
));
1559 if (TREE_CODE (scev
) == POLYNOMIAL_CHREC
1560 && !evolution_function_is_affine_multivariate_p (scev
, CHREC_VARIABLE (scev
)))
1563 switch (TREE_CODE_LENGTH (TREE_CODE (scev
)))
1566 return scev_is_linear_expression (TREE_OPERAND (scev
, 0))
1567 && scev_is_linear_expression (TREE_OPERAND (scev
, 1))
1568 && scev_is_linear_expression (TREE_OPERAND (scev
, 2));
1571 return scev_is_linear_expression (TREE_OPERAND (scev
, 0))
1572 && scev_is_linear_expression (TREE_OPERAND (scev
, 1));
1575 return scev_is_linear_expression (TREE_OPERAND (scev
, 0));
1585 /* Determines whether the expression CHREC contains only interger consts
1586 in the right parts. */
1589 evolution_function_right_is_integer_cst (const_tree chrec
)
1591 if (chrec
== NULL_TREE
)
1594 switch (TREE_CODE (chrec
))
1599 case POLYNOMIAL_CHREC
:
1600 return TREE_CODE (CHREC_RIGHT (chrec
)) == INTEGER_CST
1601 && (TREE_CODE (CHREC_LEFT (chrec
)) != POLYNOMIAL_CHREC
1602 || evolution_function_right_is_integer_cst (CHREC_LEFT (chrec
)));
1605 return evolution_function_right_is_integer_cst (TREE_OPERAND (chrec
, 0));