static bool graphite_can_represent_scev (tree scev) { if (chrec_contains_undetermined (scev)) return false; /* We disable the handling of pointer types, because it’s currently not supported by Graphite with the ISL AST generator. SSA_NAME nodes are the only nodes, which are disabled in case they are pointers to object types, but this can be changed. */ if (POINTER_TYPE_P (TREE_TYPE (scev)) && TREE_CODE (scev) == SSA_NAME) return false; switch (TREE_CODE (scev)) { case NEGATE_EXPR: case BIT_NOT_EXPR: CASE_CONVERT: case NON_LVALUE_EXPR: return graphite_can_represent_scev (TREE_OPERAND (scev, 0)); case PLUS_EXPR: case POINTER_PLUS_EXPR: case MINUS_EXPR: return graphite_can_represent_scev (TREE_OPERAND (scev, 0)) && graphite_can_represent_scev (TREE_OPERAND (scev, 1)); case MULT_EXPR: return !CONVERT_EXPR_CODE_P (TREE_CODE (TREE_OPERAND (scev, 0))) && !CONVERT_EXPR_CODE_P (TREE_CODE (TREE_OPERAND (scev, 1))) && !(chrec_contains_symbols (TREE_OPERAND (scev, 0)) && chrec_contains_symbols (TREE_OPERAND (scev, 1))) && graphite_can_represent_init (scev) && graphite_can_represent_scev (TREE_OPERAND (scev, 0)) && graphite_can_represent_scev (TREE_OPERAND (scev, 1)); case POLYNOMIAL_CHREC: /* Check for constant strides. With a non constant stride of 'n' we would have a value of 'iv * n'. Also check that the initial value can represented: for example 'n * m' cannot be represented. */ if (!evolution_function_right_is_integer_cst (scev) || !graphite_can_represent_init (scev)) return false; return graphite_can_represent_scev (CHREC_LEFT (scev)); default: break; } /* Only affine functions can be represented. */ if (tree_contains_chrecs (scev, NULL) || !scev_is_linear_expression (scev)) return false; return true; }
static bool graphite_can_represent_scev (tree scev) { if (chrec_contains_undetermined (scev)) return false; switch (TREE_CODE (scev)) { case NEGATE_EXPR: case BIT_NOT_EXPR: CASE_CONVERT: case NON_LVALUE_EXPR: return graphite_can_represent_scev (TREE_OPERAND (scev, 0)); case PLUS_EXPR: case POINTER_PLUS_EXPR: case MINUS_EXPR: return graphite_can_represent_scev (TREE_OPERAND (scev, 0)) && graphite_can_represent_scev (TREE_OPERAND (scev, 1)); case MULT_EXPR: return !CONVERT_EXPR_CODE_P (TREE_CODE (TREE_OPERAND (scev, 0))) && !CONVERT_EXPR_CODE_P (TREE_CODE (TREE_OPERAND (scev, 1))) && !(chrec_contains_symbols (TREE_OPERAND (scev, 0)) && chrec_contains_symbols (TREE_OPERAND (scev, 1))) && graphite_can_represent_init (scev) && graphite_can_represent_scev (TREE_OPERAND (scev, 0)) && graphite_can_represent_scev (TREE_OPERAND (scev, 1)); case POLYNOMIAL_CHREC: /* Check for constant strides. With a non constant stride of 'n' we would have a value of 'iv * n'. Also check that the initial value can represented: for example 'n * m' cannot be represented. */ if (!evolution_function_right_is_integer_cst (scev) || !graphite_can_represent_init (scev)) return false; return graphite_can_represent_scev (CHREC_LEFT (scev)); default: break; } /* Only affine functions can be represented. */ if (tree_contains_chrecs (scev, NULL) || !scev_is_linear_expression (scev)) return false; return true; }
static bool graphite_can_represent_init (tree e) { switch (TREE_CODE (e)) { case POLYNOMIAL_CHREC: return graphite_can_represent_init (CHREC_LEFT (e)) && graphite_can_represent_init (CHREC_RIGHT (e)); case MULT_EXPR: if (chrec_contains_symbols (TREE_OPERAND (e, 0))) return graphite_can_represent_init (TREE_OPERAND (e, 0)) && tree_fits_shwi_p (TREE_OPERAND (e, 1)); else return graphite_can_represent_init (TREE_OPERAND (e, 1)) && tree_fits_shwi_p (TREE_OPERAND (e, 0)); case PLUS_EXPR: case POINTER_PLUS_EXPR: case MINUS_EXPR: return graphite_can_represent_init (TREE_OPERAND (e, 0)) && graphite_can_represent_init (TREE_OPERAND (e, 1)); case NEGATE_EXPR: case BIT_NOT_EXPR: CASE_CONVERT: case NON_LVALUE_EXPR: return graphite_can_represent_init (TREE_OPERAND (e, 0)); default: break; } return true; }