+ CACHE is the cache of already instantiated values.
+
+ FOLD_CONVERSIONS should be set to true when the conversions that
+ may wrap in signed/pointer type are folded, as long as the value of
+ the chrec is preserved.
+
+ SIZE_EXPR is used for computing the size of the expression to be
+ instantiated, and to stop if it exceeds some limit. */
+
+static tree
+instantiate_scev_2 (basic_block instantiate_below,
+ struct loop *evolution_loop, tree chrec,
+ bool fold_conversions, htab_t cache, int size_expr)
+{
+ tree op1;
+ tree op0 = instantiate_scev_r (instantiate_below, evolution_loop,
+ TREE_OPERAND (chrec, 0),
+ fold_conversions, cache, size_expr);
+ if (op0 == chrec_dont_know)
+ return chrec_dont_know;
+
+ op1 = instantiate_scev_r (instantiate_below, evolution_loop,
+ TREE_OPERAND (chrec, 1),
+ fold_conversions, cache, size_expr);
+ if (op1 == chrec_dont_know)
+ return chrec_dont_know;
+
+ if (op0 == TREE_OPERAND (chrec, 0)
+ && op1 == TREE_OPERAND (chrec, 1))
+ return chrec;
+
+ return fold_build2 (TREE_CODE (chrec), TREE_TYPE (chrec), op0, op1);
+}
+
+/* Analyze all the parameters of the chrec, between INSTANTIATE_BELOW
+ and EVOLUTION_LOOP, that were left under a symbolic form.
+
+ CHREC is an expression with 2 operands to be instantiated.
+
+ CACHE is the cache of already instantiated values.
+
+ FOLD_CONVERSIONS should be set to true when the conversions that
+ may wrap in signed/pointer type are folded, as long as the value of
+ the chrec is preserved.
+
+ SIZE_EXPR is used for computing the size of the expression to be
+ instantiated, and to stop if it exceeds some limit. */
+
+static tree
+instantiate_scev_1 (basic_block instantiate_below,
+ struct loop *evolution_loop, tree chrec,
+ bool fold_conversions, htab_t cache, int size_expr)
+{
+ tree op0 = instantiate_scev_r (instantiate_below, evolution_loop,
+ TREE_OPERAND (chrec, 0),
+ fold_conversions, cache, size_expr);
+
+ if (op0 == chrec_dont_know)
+ return chrec_dont_know;
+
+ if (op0 == TREE_OPERAND (chrec, 0))
+ return chrec;
+
+ return fold_build1 (TREE_CODE (chrec), TREE_TYPE (chrec), op0);
+}
+
+/* Analyze all the parameters of the chrec, between INSTANTIATE_BELOW
+ and EVOLUTION_LOOP, that were left under a symbolic form.
+
+ CHREC is the scalar evolution to instantiate.
+
+ CACHE is the cache of already instantiated values.
+
+ FOLD_CONVERSIONS should be set to true when the conversions that
+ may wrap in signed/pointer type are folded, as long as the value of
+ the chrec is preserved.
+
+ SIZE_EXPR is used for computing the size of the expression to be
+ instantiated, and to stop if it exceeds some limit. */
+
+static tree
+instantiate_scev_r (basic_block instantiate_below,
+ struct loop *evolution_loop, tree chrec,
+ bool fold_conversions, htab_t cache, int size_expr)
+{
+ /* Give up if the expression is larger than the MAX that we allow. */
+ if (size_expr++ > PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE))
+ return chrec_dont_know;
+
+ if (automatically_generated_chrec_p (chrec)
+ || is_gimple_min_invariant (chrec))
+ return chrec;
+
+ switch (TREE_CODE (chrec))
+ {
+ case SSA_NAME:
+ return instantiate_scev_name (instantiate_below, evolution_loop, chrec,
+ fold_conversions, cache, size_expr);
+
+ case POLYNOMIAL_CHREC:
+ return instantiate_scev_poly (instantiate_below, evolution_loop, chrec,
+ fold_conversions, cache, size_expr);
+
+ case POINTER_PLUS_EXPR:
+ case PLUS_EXPR:
+ case MINUS_EXPR:
+ case MULT_EXPR:
+ return instantiate_scev_binary (instantiate_below, evolution_loop, chrec,
+ TREE_CODE (chrec), chrec_type (chrec),
+ TREE_OPERAND (chrec, 0),
+ TREE_OPERAND (chrec, 1),
+ fold_conversions, cache, size_expr);
+
+ CASE_CONVERT:
+ return instantiate_scev_convert (instantiate_below, evolution_loop, chrec,
+ TREE_TYPE (chrec), TREE_OPERAND (chrec, 0),
+ fold_conversions, cache, size_expr);
+
+ case NEGATE_EXPR:
+ case BIT_NOT_EXPR:
+ return instantiate_scev_not (instantiate_below, evolution_loop, chrec,
+ TREE_CODE (chrec), TREE_TYPE (chrec),
+ TREE_OPERAND (chrec, 0),
+ fold_conversions, cache, size_expr);