+2019-04-23 Bin Cheng <bin.cheng@linux.alibaba.com>
+
+ PR tree-optimization/92001
+ * tree-chrec.c (evolution_function_is_univariate_p): New parameter
+ and check univariate against it.
+ * tree-chrec.h (evolution_function_is_univariate_p): New parameter.
+ * tree-data-ref.c (add_other_self_distances): Pass new argument.
+
2019-04-21 H.J. Lu <hongjiu.lu@intel.com>
PR target/90178
}
/* Determine whether the given tree is a function in zero or one
- variables. */
+ variables with respect to loop specified by LOOPNUM. Note only positive
+ LOOPNUM stands for a real loop. */
bool
-evolution_function_is_univariate_p (const_tree chrec)
+evolution_function_is_univariate_p (const_tree chrec, int loopnum)
{
if (chrec == NULL_TREE)
return true;
+ tree sub_chrec;
switch (TREE_CODE (chrec))
{
case POLYNOMIAL_CHREC:
switch (TREE_CODE (CHREC_LEFT (chrec)))
{
case POLYNOMIAL_CHREC:
- if (CHREC_VARIABLE (chrec) != CHREC_VARIABLE (CHREC_LEFT (chrec)))
+ sub_chrec = CHREC_LEFT (chrec);
+ if (CHREC_VARIABLE (chrec) != CHREC_VARIABLE (sub_chrec)
+ && (loopnum <= 0
+ || CHREC_VARIABLE (sub_chrec) == (unsigned) loopnum
+ || flow_loop_nested_p (get_loop (cfun, loopnum),
+ get_chrec_loop (sub_chrec))))
return false;
- if (!evolution_function_is_univariate_p (CHREC_LEFT (chrec)))
+ if (!evolution_function_is_univariate_p (sub_chrec, loopnum))
return false;
break;
switch (TREE_CODE (CHREC_RIGHT (chrec)))
{
case POLYNOMIAL_CHREC:
- if (CHREC_VARIABLE (chrec) != CHREC_VARIABLE (CHREC_RIGHT (chrec)))
+ sub_chrec = CHREC_RIGHT (chrec);
+ if (CHREC_VARIABLE (chrec) != CHREC_VARIABLE (sub_chrec)
+ && (loopnum <= 0
+ || CHREC_VARIABLE (sub_chrec) == (unsigned) loopnum
+ || flow_loop_nested_p (get_loop (cfun, loopnum),
+ get_chrec_loop (sub_chrec))))
return false;
- if (!evolution_function_is_univariate_p (CHREC_RIGHT (chrec)))
+ if (!evolution_function_is_univariate_p (sub_chrec, loopnum))
return false;
break;
extern bool chrec_contains_undetermined (const_tree);
extern bool tree_contains_chrecs (const_tree, int *);
extern bool evolution_function_is_affine_multivariate_p (const_tree, int);
-extern bool evolution_function_is_univariate_p (const_tree);
+extern bool evolution_function_is_univariate_p (const_tree, int = 0);
extern unsigned nb_vars_in_chrec (tree);
extern bool evolution_function_is_invariant_p (tree, int);
extern bool scev_is_linear_expression (tree);