return chrec_dont_know;
}
-/* Determine whether the CHREC is always positive/negative. If the expression
- cannot be statically analyzed, return false, otherwise set the answer into
- VALUE. */
-
-bool
-chrec_is_positive (tree chrec, bool *value)
-{
- bool value0, value1, value2;
- tree end_value, nb_iter;
-
- switch (TREE_CODE (chrec))
- {
- case POLYNOMIAL_CHREC:
- if (!chrec_is_positive (CHREC_LEFT (chrec), &value0)
- || !chrec_is_positive (CHREC_RIGHT (chrec), &value1))
- return false;
-
- /* FIXME -- overflows. */
- if (value0 == value1)
- {
- *value = value0;
- return true;
- }
-
- /* Otherwise the chrec is under the form: "{-197, +, 2}_1",
- and the proof consists in showing that the sign never
- changes during the execution of the loop, from 0 to
- loop->nb_iterations. */
- if (!evolution_function_is_affine_p (chrec))
- return false;
-
- nb_iter = number_of_latch_executions (get_chrec_loop (chrec));
- if (chrec_contains_undetermined (nb_iter))
- return false;
-
-#if 0
- /* TODO -- If the test is after the exit, we may decrease the number of
- iterations by one. */
- if (after_exit)
- nb_iter = chrec_fold_minus (type, nb_iter, build_int_cst (type, 1));
-#endif
-
- end_value = chrec_apply (CHREC_VARIABLE (chrec), chrec, nb_iter);
-
- if (!chrec_is_positive (end_value, &value2))
- return false;
-
- *value = value0;
- return value0 == value1;
-
- case INTEGER_CST:
- *value = (tree_int_cst_sgn (chrec) == 1);
- return true;
-
- default:
- return false;
- }
-}
-
/* Associate CHREC to SCALAR. */
static void
else if (TREE_CODE (res) == POLYNOMIAL_CHREC)
new_init = CHREC_LEFT (res);
STRIP_USELESS_TYPE_CONVERSION (new_init);
- gcc_assert (TREE_CODE (new_init) != POLYNOMIAL_CHREC);
- if (!operand_equal_p (init_cond, new_init, 0))
+ if (TREE_CODE (new_init) == POLYNOMIAL_CHREC
+ || !operand_equal_p (init_cond, new_init, 0))
return chrec_dont_know;
}
chrec1 = analyze_scalar_evolution (loop, rhs1);
chrec2 = analyze_scalar_evolution (loop, rhs2);
chrec1 = chrec_convert (type, chrec1, at_stmt);
- chrec2 = chrec_convert (sizetype, chrec2, at_stmt);
+ chrec2 = chrec_convert (TREE_TYPE (rhs2), chrec2, at_stmt);
res = chrec_fold_plus (type, chrec1, chrec2);
break;
if (automatically_generated_chrec_p (expr))
return expr;
- if (TREE_CODE (expr) == POLYNOMIAL_CHREC)
+ if (TREE_CODE (expr) == POLYNOMIAL_CHREC
+ || get_gimple_rhs_class (TREE_CODE (expr)) == GIMPLE_TERNARY_RHS)
return chrec_dont_know;
extract_ops_from_tree (expr, &code, &op0, &op1);
TREE_OPERAND (chrec, 0),
fold_conversions, cache, size_expr);
+ case ADDR_EXPR:
case SCEV_NOT_KNOWN:
return chrec_dont_know;
iv->no_overflow = false;
type = TREE_TYPE (op);
- if (TREE_CODE (type) != INTEGER_TYPE
- && TREE_CODE (type) != POINTER_TYPE)
+ if (!POINTER_TYPE_P (type)
+ && !INTEGRAL_TYPE_P (type))
return false;
ev = analyze_scalar_evolution_in_loop (wrto_loop, use_loop, op,