X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=isl_ast_codegen.c;h=dfd634e44afe8ec0099470353ba8b37aef5ce9c6;hb=19596bc4e5cd282b2e75d17077b1aaaeacbfd6f9;hp=5ea377fd00aefb60a1c258355eb200abb464be92;hpb=7e0cf790a114e12e0560ff4e33f86bb4f7abeeaa;p=platform%2Fupstream%2Fisl.git diff --git a/isl_ast_codegen.c b/isl_ast_codegen.c index 5ea377f..dfd634e 100644 --- a/isl_ast_codegen.c +++ b/isl_ast_codegen.c @@ -2801,6 +2801,22 @@ static __isl_give isl_ast_graft_list *generate_shifted_component_from_list( return generate_shifted_component(executed, build); } +/* Does set dimension "pos" of "set" have an obviously fixed value? + */ +static int dim_is_fixed(__isl_keep isl_set *set, int pos) +{ + int fixed; + isl_val *v; + + v = isl_set_plain_get_val_if_fixed(set, isl_dim_set, pos); + if (!v) + return -1; + fixed = !isl_val_is_nan(v); + isl_val_free(v); + + return fixed; +} + /* Given an array "domain" of isl_set_map_pairs and an array "order" * of indices into the "domain" array, * do all (except for at most one) of the "set" field of the elements @@ -2816,8 +2832,7 @@ static int at_most_one_non_fixed(struct isl_set_map_pair *domain, for (i = 0; i < n; ++i) { int f; - f = isl_set_plain_is_fixed(domain[order[i]].set, - isl_dim_set, depth, NULL); + f = dim_is_fixed(domain[order[i]].set, depth); if (f < 0) return -1; if (f) @@ -2847,8 +2862,7 @@ static int eliminate_non_fixed(struct isl_set_map_pair *domain, for (i = n - 1; i >= 0; --i) { int f; - f = isl_set_plain_is_fixed(domain[order[i]].set, - isl_dim_set, depth, NULL); + f = dim_is_fixed(domain[order[i]].set, depth); if (f < 0) return -1; if (f) @@ -2998,11 +3012,11 @@ static int first_offset(struct isl_set_map_pair *domain, int *order, int n, * in all cases. */ static __isl_give isl_union_map *contruct_shifted_executed( - struct isl_set_map_pair *domain, int *order, int n, isl_int stride, - __isl_keep isl_vec *offset, __isl_keep isl_ast_build *build) + struct isl_set_map_pair *domain, int *order, int n, + __isl_keep isl_val *stride, __isl_keep isl_multi_val *offset, + __isl_take isl_ast_build *build) { int i; - isl_int v; isl_union_map *executed; isl_space *space; isl_map *map; @@ -3022,17 +3036,18 @@ static __isl_give isl_union_map *contruct_shifted_executed( c = isl_constraint_set_coefficient_si(c, isl_dim_in, depth, 1); c = isl_constraint_set_coefficient_si(c, isl_dim_out, depth, -1); - isl_int_init(v); - for (i = 0; i < n; ++i) { isl_map *map_i; + isl_val *v; - if (isl_vec_get_element(offset, i, &v) < 0) + v = isl_multi_val_get_val(offset, i); + if (!v) break; map_i = isl_map_copy(map); - map_i = isl_map_fix(map_i, isl_dim_out, depth + 1, v); - isl_int_neg(v, v); - c = isl_constraint_set_constant(c, v); + map_i = isl_map_fix_val(map_i, isl_dim_out, depth + 1, + isl_val_copy(v)); + v = isl_val_neg(v); + c = isl_constraint_set_constant_val(c, v); map_i = isl_map_add_constraint(map_i, isl_constraint_copy(c)); map_i = isl_map_apply_domain(isl_map_copy(domain[order[i]].map), @@ -3043,8 +3058,6 @@ static __isl_give isl_union_map *contruct_shifted_executed( isl_constraint_free(c); isl_map_free(map); - isl_int_clear(v); - if (i < n) executed = isl_union_map_free(executed); @@ -3078,15 +3091,16 @@ static __isl_give isl_union_map *contruct_shifted_executed( * old schedule domain. */ static __isl_give isl_ast_graft_list *generate_shift_component( - struct isl_set_map_pair *domain, int *order, int n, isl_int stride, - __isl_keep isl_vec *offset, __isl_take isl_ast_build *build) + struct isl_set_map_pair *domain, int *order, int n, + __isl_keep isl_val *stride, __isl_keep isl_multi_val *offset, + __isl_take isl_ast_build *build) { isl_ast_graft_list *list; int first; int depth; isl_ctx *ctx; - isl_int val; - isl_vec *v; + isl_val *val; + isl_multi_val *mv; isl_space *space; isl_multi_aff *ma, *zero; isl_union_map *executed; @@ -3098,16 +3112,13 @@ static __isl_give isl_ast_graft_list *generate_shift_component( if (first < 0) return isl_ast_build_free(build); - isl_int_init(val); - v = isl_vec_alloc(ctx, n); - if (isl_vec_get_element(offset, first, &val) < 0) - v = isl_vec_free(v); - isl_int_neg(val, val); - v = isl_vec_set(v, val); - v = isl_vec_add(v, isl_vec_copy(offset)); - v = isl_vec_fdiv_r(v, stride); + mv = isl_multi_val_copy(offset); + val = isl_multi_val_get_val(offset, first); + val = isl_val_neg(val); + mv = isl_multi_val_add_val(mv, val); + mv = isl_multi_val_mod_val(mv, isl_val_copy(stride)); - executed = contruct_shifted_executed(domain, order, n, stride, v, + executed = contruct_shifted_executed(domain, order, n, stride, mv, build); space = isl_ast_build_get_space(build, 1); space = isl_space_map_from_set(space); @@ -3121,8 +3132,7 @@ static __isl_give isl_ast_graft_list *generate_shift_component( list = isl_ast_graft_list_preimage_multi_aff(list, ma); - isl_vec_free(v); - isl_int_clear(val); + isl_multi_val_free(mv); return list; } @@ -3200,8 +3210,8 @@ static __isl_give isl_ast_graft_list *generate_component( isl_ctx *ctx; isl_map *map; isl_set *deltas; - isl_int m, r, gcd; - isl_vec *v; + isl_val *gcd = NULL; + isl_multi_val *mv; int fixed, skip; int base; isl_ast_graft_list *list; @@ -3226,13 +3236,12 @@ static __isl_give isl_ast_graft_list *generate_component( ctx = isl_ast_build_get_ctx(build); - isl_int_init(m); - isl_int_init(r); - isl_int_init(gcd); - v = isl_vec_alloc(ctx, n); + mv = isl_multi_val_zero(isl_space_set_alloc(ctx, 0, n)); fixed = 1; for (i = 0; i < n; ++i) { + isl_val *r, *m; + map = isl_map_from_domain_and_range( isl_set_copy(domain[order[base]].set), isl_set_copy(domain[order[i]].set)); @@ -3240,48 +3249,51 @@ static __isl_give isl_ast_graft_list *generate_component( map = isl_map_equate(map, isl_dim_in, d, isl_dim_out, d); deltas = isl_map_deltas(map); - res = isl_set_dim_residue_class(deltas, depth, &m, &r); + res = isl_set_dim_residue_class_val(deltas, depth, &m, &r); isl_set_free(deltas); if (res < 0) break; if (i == 0) - isl_int_set(gcd, m); + gcd = m; else - isl_int_gcd(gcd, gcd, m); - if (isl_int_is_one(gcd)) + gcd = isl_val_gcd(gcd, m); + if (isl_val_is_one(gcd)) { + isl_val_free(r); break; - v = isl_vec_set_element(v, i, r); + } + mv = isl_multi_val_set_val(mv, i, r); - res = isl_set_plain_is_fixed(domain[order[i]].set, - isl_dim_set, depth, NULL); + res = dim_is_fixed(domain[order[i]].set, depth); if (res < 0) break; if (res) continue; if (fixed && i > base) { - isl_vec_get_element(v, base, &m); - if (isl_int_ne(m, r)) + isl_val *a, *b; + a = isl_multi_val_get_val(mv, i); + b = isl_multi_val_get_val(mv, base); + if (isl_val_ne(a, b)) fixed = 0; + isl_val_free(a); + isl_val_free(b); } } - if (res < 0) { + if (res < 0 || !gcd) { isl_ast_build_free(build); list = NULL; } else if (i < n || fixed) { list = generate_shifted_component_from_list(domain, order, n, build); } else { - list = generate_shift_component(domain, order, n, gcd, v, + list = generate_shift_component(domain, order, n, gcd, mv, build); } - isl_vec_free(v); - isl_int_clear(gcd); - isl_int_clear(r); - isl_int_clear(m); + isl_val_free(gcd); + isl_multi_val_free(mv); return list; }