return NULL_TREE;
}
-static tree instantiate_scev_1 (basic_block, struct loop *, tree, bool,
+static tree instantiate_scev_r (basic_block, struct loop *, tree, bool,
htab_t, int);
/* Analyze all the parameters of the chrec, between INSTANTIATE_BELOW
}
else if (res != chrec_dont_know)
- res = instantiate_scev_1 (instantiate_below, evolution_loop, res,
+ res = instantiate_scev_r (instantiate_below, evolution_loop, res,
fold_conversions, cache, size_expr);
/* Store the correct value to the cache. */
bool fold_conversions, htab_t cache, int size_expr)
{
tree op1;
- tree op0 = instantiate_scev_1 (instantiate_below, evolution_loop,
+ tree op0 = instantiate_scev_r (instantiate_below, evolution_loop,
CHREC_LEFT (chrec), fold_conversions, cache,
size_expr);
if (op0 == chrec_dont_know)
return chrec_dont_know;
- op1 = instantiate_scev_1 (instantiate_below, evolution_loop,
+ op1 = instantiate_scev_r (instantiate_below, evolution_loop,
CHREC_RIGHT (chrec), fold_conversions, cache,
size_expr);
if (op1 == chrec_dont_know)
bool fold_conversions, htab_t cache, int size_expr)
{
tree op1;
- tree op0 = instantiate_scev_1 (instantiate_below, evolution_loop,
+ 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_1 (instantiate_below, evolution_loop,
+ op1 = instantiate_scev_r (instantiate_below, evolution_loop,
TREE_OPERAND (chrec, 1), fold_conversions, cache,
size_expr);
if (op1 == chrec_dont_know)
tree type, tree op,
bool fold_conversions, htab_t cache, int size_expr)
{
- tree op0 = instantiate_scev_1 (instantiate_below, evolution_loop, op,
+ tree op0 = instantiate_scev_r (instantiate_below, evolution_loop, op,
fold_conversions, cache, size_expr);
if (op0 == chrec_dont_know)
bool fold_conversions, htab_t cache, int size_expr)
{
tree type = chrec_type (chrec);
- tree op0 = instantiate_scev_1 (instantiate_below, evolution_loop,
+ tree op0 = instantiate_scev_r (instantiate_below, evolution_loop,
TREE_OPERAND (chrec, 0),
fold_conversions, cache, size_expr);
if (op0 == chrec_dont_know)
bool fold_conversions, htab_t cache, int size_expr)
{
tree op1, op2;
- tree op0 = instantiate_scev_1 (instantiate_below, evolution_loop,
+ 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_1 (instantiate_below, evolution_loop,
+ 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;
- op2 = instantiate_scev_1 (instantiate_below, evolution_loop,
+ op2 = instantiate_scev_r (instantiate_below, evolution_loop,
TREE_OPERAND (chrec, 2),
fold_conversions, cache, size_expr);
if (op2 == chrec_dont_know)
/* 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.
+ 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_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.
struct loop *evolution_loop, tree chrec,
bool fold_conversions, htab_t cache, int size_expr)
{
- tree op0, 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;
+
+ 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;
fold_conversions, cache, size_expr);
case 2:
- op0 = instantiate_scev_1 (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_1 (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);
+ return instantiate_scev_2 (instantiate_below, evolution_loop, chrec,
+ fold_conversions, cache, size_expr);
case 1:
- op0 = instantiate_scev_1 (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);
+ return instantiate_scev_1 (instantiate_below, evolution_loop, chrec,
+ fold_conversions, cache, size_expr);
case 0:
return chrec;
fprintf (dump_file, ")\n");
}
- res = instantiate_scev_1 (instantiate_below, evolution_loop, chrec, false,
+ res = instantiate_scev_r (instantiate_below, evolution_loop, chrec, false,
cache, 0);
if (dump_file && (dump_flags & TDF_DETAILS))
resolve_mixers (struct loop *loop, tree chrec)
{
htab_t cache = htab_create (10, hash_scev_info, eq_scev_info, del_scev_info);
- tree ret = instantiate_scev_1 (block_before_loop (loop), loop, chrec, true,
+ tree ret = instantiate_scev_r (block_before_loop (loop), loop, chrec, true,
cache, 0);
htab_delete (cache);
return ret;