2 * Copyright 2012 Ecole Normale Superieure
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege,
7 * Ecole Normale Superieure, 45 rue d’Ulm, 75230 Paris, France
11 #include <isl_ast_build_expr.h>
12 #include <isl_ast_private.h>
13 #include <isl_ast_build_private.h>
15 /* Compute the minimum of the integer affine expression "obj" over the points
16 * in build->domain and put the result in *opt.
18 enum isl_lp_result isl_ast_build_min(__isl_keep isl_ast_build *build,
19 __isl_keep isl_aff *obj, isl_int *opt)
24 return isl_set_min(build->domain, obj, opt);
27 /* Compute the maximum of the integer affine expression "obj" over the points
28 * in build->domain and put the result in *opt.
30 enum isl_lp_result isl_ast_build_max(__isl_keep isl_ast_build *build,
31 __isl_keep isl_aff *obj, isl_int *opt)
36 return isl_set_max(build->domain, obj, opt);
39 /* Create an isl_ast_expr evaluating the div at position "pos" in "ls".
40 * The result is simplified in terms of build->domain.
42 * "ls" is known to be non-NULL.
44 * Let the div be of the form floor(e/d).
45 * If the ast_build_prefer_pdiv option is set then we check if "e"
46 * is non-negative, so that we can generate
48 * (pdiv_q, expr(e), expr(d))
52 * (fdiv_q, expr(e), expr(d))
55 static __isl_give isl_ast_expr *var_div(__isl_keep isl_local_space *ls,
56 int pos, __isl_keep isl_ast_build *build)
58 isl_ctx *ctx = isl_local_space_get_ctx(ls);
60 isl_ast_expr *num, *den;
62 enum isl_ast_op_type type;
64 aff = isl_local_space_get_div(ls, pos);
66 isl_aff_get_denominator(aff, &d);
67 aff = isl_aff_scale(aff, d);
68 den = isl_ast_expr_alloc_int(ctx, d);
71 type = isl_ast_op_fdiv_q;
72 if (isl_options_get_ast_build_prefer_pdiv(ctx)) {
73 int non_neg = isl_ast_build_aff_is_nonneg(build, aff);
75 aff = isl_aff_free(aff);
77 type = isl_ast_op_pdiv_q;
80 num = isl_ast_expr_from_aff(aff, build);
81 return isl_ast_expr_alloc_binary(type, num, den);
84 /* Create an isl_ast_expr evaluating the specified dimension of "ls".
85 * The result is simplified in terms of build->domain.
87 * The isl_ast_expr is constructed based on the type of the dimension.
88 * - divs are constructed by var_div
89 * - set variables are constructed from the iterator isl_ids in "build"
90 * - parameters are constructed from the isl_ids in "ls"
92 static __isl_give isl_ast_expr *var(__isl_keep isl_local_space *ls,
93 enum isl_dim_type type, int pos, __isl_keep isl_ast_build *build)
95 isl_ctx *ctx = isl_local_space_get_ctx(ls);
98 if (type == isl_dim_div)
99 return var_div(ls, pos, build);
101 if (type == isl_dim_set) {
102 id = isl_ast_build_get_iterator_id(build, pos);
103 return isl_ast_expr_from_id(id);
106 if (!isl_local_space_has_dim_id(ls, type, pos))
107 isl_die(ctx, isl_error_internal, "unnamed dimension",
109 id = isl_local_space_get_dim_id(ls, type, pos);
110 return isl_ast_expr_from_id(id);
113 /* Does "expr" represent the zero integer?
115 static int ast_expr_is_zero(__isl_keep isl_ast_expr *expr)
119 if (expr->type != isl_ast_expr_int)
121 return isl_int_is_zero(expr->u.i);
124 /* Create an expression representing the sum of "expr1" and "expr2",
125 * provided neither of the two expressions is identically zero.
127 static __isl_give isl_ast_expr *ast_expr_add(__isl_take isl_ast_expr *expr1,
128 __isl_take isl_ast_expr *expr2)
130 if (!expr1 || !expr2)
133 if (ast_expr_is_zero(expr1)) {
134 isl_ast_expr_free(expr1);
138 if (ast_expr_is_zero(expr2)) {
139 isl_ast_expr_free(expr2);
143 return isl_ast_expr_add(expr1, expr2);
145 isl_ast_expr_free(expr1);
146 isl_ast_expr_free(expr2);
150 /* Subtract expr2 from expr1.
152 * If expr2 is zero, we simply return expr1.
153 * If expr1 is zero, we return
155 * (isl_ast_op_minus, expr2)
157 * Otherwise, we return
159 * (isl_ast_op_sub, expr1, expr2)
161 static __isl_give isl_ast_expr *ast_expr_sub(__isl_take isl_ast_expr *expr1,
162 __isl_take isl_ast_expr *expr2)
164 if (!expr1 || !expr2)
167 if (ast_expr_is_zero(expr2)) {
168 isl_ast_expr_free(expr2);
172 if (ast_expr_is_zero(expr1)) {
173 isl_ast_expr_free(expr1);
174 return isl_ast_expr_neg(expr2);
177 return isl_ast_expr_sub(expr1, expr2);
179 isl_ast_expr_free(expr1);
180 isl_ast_expr_free(expr2);
184 /* Return an isl_ast_expr that represents
188 * v is assumed to be non-negative.
189 * The result is simplified in terms of build->domain.
191 static __isl_give isl_ast_expr *isl_ast_expr_mod(isl_int v,
192 __isl_keep isl_aff *aff, isl_int d, __isl_keep isl_ast_build *build)
201 ctx = isl_aff_get_ctx(aff);
202 expr = isl_ast_expr_from_aff(isl_aff_copy(aff), build);
204 c = isl_ast_expr_alloc_int(ctx, d);
205 expr = isl_ast_expr_alloc_binary(isl_ast_op_pdiv_r, expr, c);
207 if (!isl_int_is_one(v)) {
208 c = isl_ast_expr_alloc_int(ctx, v);
209 expr = isl_ast_expr_mul(c, expr);
215 /* Create an isl_ast_expr evaluating "v" times the specified dimension of "ls".
216 * The result is simplified in terms of build->domain.
218 * Let e be the expression for the specified dimension.
219 * If v is 1, we simply return e.
220 * If v is -1, we return
222 * (isl_ast_op_minus, e)
224 * Otherwise, we return
226 * (isl_ast_op_mul, expr(v), e)
228 static __isl_give isl_ast_expr *isl_ast_expr_term(
229 __isl_keep isl_local_space *ls, enum isl_dim_type type, int pos,
230 isl_int v, __isl_keep isl_ast_build *build)
239 ctx = isl_local_space_get_ctx(ls);
240 expr = var(ls, type, pos, build);
242 if (!isl_int_is_one(v)) {
243 if (isl_int_is_negone(v)) {
244 expr = isl_ast_expr_neg(expr);
246 c = isl_ast_expr_alloc_int(ctx, v);
247 expr = isl_ast_expr_mul(c, expr);
254 /* Add an expression for "v" times the specified dimension of "ls"
257 * Let e be the expression for the specified dimension.
258 * If "v" is negative, we create
260 * (isl_ast_op_sub, expr, e)
262 * except when expr is trivially zero, in which case we create
264 * (isl_ast_op_minus, e)
268 * If "v" is positive, we simply create
270 * (isl_ast_op_add, expr, e)
273 static __isl_give isl_ast_expr *isl_ast_expr_add_term(
274 __isl_take isl_ast_expr *expr,
275 __isl_keep isl_local_space *ls, enum isl_dim_type type, int pos,
276 isl_int v, __isl_keep isl_ast_build *build)
283 if (isl_int_is_neg(v) && !ast_expr_is_zero(expr)) {
285 term = isl_ast_expr_term(ls, type, pos, v, build);
286 return ast_expr_sub(expr, term);
288 term = isl_ast_expr_term(ls, type, pos, v, build);
289 return ast_expr_add(expr, term);
293 /* Add an expression for "v" to expr.
295 static __isl_give isl_ast_expr *isl_ast_expr_add_int(
296 __isl_take isl_ast_expr *expr, isl_int v)
299 isl_ast_expr *expr_int;
304 if (isl_int_is_zero(v))
307 ctx = isl_ast_expr_get_ctx(expr);
308 if (isl_int_is_neg(v) && !ast_expr_is_zero(expr)) {
310 expr_int = isl_ast_expr_alloc_int(ctx, v);
311 return ast_expr_sub(expr, expr_int);
313 expr_int = isl_ast_expr_alloc_int(ctx, v);
314 return ast_expr_add(expr, expr_int);
318 /* Check if "aff" involves any (implicit) modulo computations.
319 * If so, remove them from aff and add expressions corresponding
320 * to those modulo computations to *pos and/or *neg.
321 * We only do this if the option ast_build_prefer_pdiv is set.
323 * A modulo expression is of the form
325 * a mod m = a - m * floor(a / m)
327 * To detect them in aff, we look for terms of the form
329 * (f * m * floor(a / m)) / d
333 * (f * (a - (a mod m))) / d = (f * a) / d - (f * (a mod m)) / d
335 * and extract out -f * (a mod m).
336 * In particular, if f > 0, we add (f * (a mod m)) to *neg.
337 * If f < 0, we add ((-f) * (a mod m)) to *pos.
339 * The caller is responsible for dividing *neg and/or *pos by d.
341 static __isl_give isl_aff *extract_modulos(__isl_take isl_aff *aff,
342 __isl_keep isl_ast_expr **pos, __isl_keep isl_ast_expr **neg,
343 __isl_keep isl_ast_build *build)
353 ctx = isl_aff_get_ctx(aff);
354 if (!isl_options_get_ast_build_prefer_pdiv(ctx))
359 ls = isl_aff_get_domain_local_space(aff);
361 n = isl_aff_dim(aff, isl_dim_div);
362 for (j = 0; j < n; ++j) {
368 isl_aff_get_coefficient(aff, isl_dim_div, j, &v);
369 if (isl_int_is_zero(v))
371 div = isl_local_space_get_div(ls, j);
372 isl_aff_get_denominator(div, &d);
373 mod = isl_int_is_divisible_by(v, d);
375 mod = isl_ast_build_aff_is_nonneg(build, div);
377 aff = isl_aff_free(aff);
384 div = isl_aff_scale(div, d);
385 isl_int_divexact(v, v, d);
388 expr = isl_ast_expr_mod(v, div, d, build);
390 *neg = ast_expr_add(*neg, expr);
392 *pos = ast_expr_add(*pos, expr);
393 aff = isl_aff_set_coefficient_si(aff, isl_dim_div, j, 0);
396 div = isl_aff_scale(div, v);
397 isl_aff_get_denominator(aff, &d);
398 div = isl_aff_scale_down(div, d);
399 aff = isl_aff_add(aff, div);
402 isl_local_space_free(ls);
409 /* Construct an isl_ast_expr that evaluates the affine expression "aff",
410 * The result is simplified in terms of build->domain.
412 * We first extract hidden modulo computations from the affine expression
413 * and then add terms for each variable with a non-zero coefficient.
414 * Finally, if the affine expression has a non-trivial denominator,
415 * we divide the resulting isl_ast_expr by this denominator.
417 __isl_give isl_ast_expr *isl_ast_expr_from_aff(__isl_take isl_aff *aff,
418 __isl_keep isl_ast_build *build)
423 isl_ctx *ctx = isl_aff_get_ctx(aff);
424 isl_ast_expr *expr, *expr_neg;
425 enum isl_dim_type t[] = { isl_dim_param, isl_dim_in, isl_dim_div };
426 enum isl_dim_type l[] = { isl_dim_param, isl_dim_set, isl_dim_div };
432 expr = isl_ast_expr_alloc_int_si(ctx, 0);
433 expr_neg = isl_ast_expr_alloc_int_si(ctx, 0);
435 aff = extract_modulos(aff, &expr, &expr_neg, build);
436 expr = ast_expr_sub(expr, expr_neg);
439 ls = isl_aff_get_domain_local_space(aff);
441 for (i = 0; i < 3; ++i) {
442 n = isl_aff_dim(aff, t[i]);
443 for (j = 0; j < n; ++j) {
444 isl_aff_get_coefficient(aff, t[i], j, &v);
445 if (isl_int_is_zero(v))
447 expr = isl_ast_expr_add_term(expr,
448 ls, l[i], j, v, build);
452 isl_aff_get_constant(aff, &v);
453 expr = isl_ast_expr_add_int(expr, v);
455 isl_aff_get_denominator(aff, &v);
456 if (!isl_int_is_one(v)) {
458 d = isl_ast_expr_alloc_int(ctx, v);
459 expr = isl_ast_expr_div(expr, d);
462 isl_local_space_free(ls);
468 /* Add terms to "expr" for each variable in "aff" with a coefficient
469 * with sign equal to "sign".
470 * The result is simplified in terms of build->domain.
472 static __isl_give isl_ast_expr *add_signed_terms(__isl_take isl_ast_expr *expr,
473 __isl_keep isl_aff *aff, int sign, __isl_keep isl_ast_build *build)
477 enum isl_dim_type t[] = { isl_dim_param, isl_dim_in, isl_dim_div };
478 enum isl_dim_type l[] = { isl_dim_param, isl_dim_set, isl_dim_div };
482 ls = isl_aff_get_domain_local_space(aff);
484 for (i = 0; i < 3; ++i) {
485 int n = isl_aff_dim(aff, t[i]);
486 for (j = 0; j < n; ++j) {
487 isl_aff_get_coefficient(aff, t[i], j, &v);
488 if (sign * isl_int_sgn(v) <= 0)
491 expr = isl_ast_expr_add_term(expr,
492 ls, l[i], j, v, build);
496 isl_aff_get_constant(aff, &v);
497 if (sign * isl_int_sgn(v) > 0) {
499 expr = isl_ast_expr_add_int(expr, v);
502 isl_local_space_free(ls);
508 /* Construct an isl_ast_expr that evaluates the condition "constraint",
509 * The result is simplified in terms of build->domain.
511 * Let the constraint by either "a >= 0" or "a == 0".
512 * We first extract hidden modulo computations from "a"
513 * and then collect all the terms with a positive coefficient in cons_pos
514 * and the terms with a negative coefficient in cons_neg.
516 * The result is then of the form
518 * (isl_ast_op_ge, expr(pos), expr(-neg)))
522 * (isl_ast_op_eq, expr(pos), expr(-neg)))
524 * However, if the first expression is an integer constant (and the second
525 * is not), then we swap the two expressions. This ensures that we construct,
526 * e.g., "i <= 5" rather than "5 >= i".
528 static __isl_give isl_ast_expr *isl_ast_expr_from_constraint(
529 __isl_take isl_constraint *constraint, __isl_keep isl_ast_build *build)
532 isl_ast_expr *expr_pos;
533 isl_ast_expr *expr_neg;
537 enum isl_ast_op_type type;
542 aff = isl_constraint_get_aff(constraint);
544 ctx = isl_constraint_get_ctx(constraint);
545 expr_pos = isl_ast_expr_alloc_int_si(ctx, 0);
546 expr_neg = isl_ast_expr_alloc_int_si(ctx, 0);
548 aff = extract_modulos(aff, &expr_pos, &expr_neg, build);
550 expr_pos = add_signed_terms(expr_pos, aff, 1, build);
551 expr_neg = add_signed_terms(expr_neg, aff, -1, build);
553 eq = isl_constraint_is_equality(constraint);
555 if (isl_ast_expr_get_type(expr_pos) == isl_ast_expr_int &&
556 isl_ast_expr_get_type(expr_neg) != isl_ast_expr_int) {
557 type = eq ? isl_ast_op_eq : isl_ast_op_le;
558 expr = isl_ast_expr_alloc_binary(type, expr_neg, expr_pos);
560 type = eq ? isl_ast_op_eq : isl_ast_op_ge;
561 expr = isl_ast_expr_alloc_binary(type, expr_pos, expr_neg);
564 isl_constraint_free(constraint);
569 struct isl_expr_from_basic_data {
570 isl_ast_build *build;
575 /* Construct an isl_ast_expr that evaluates the condition "c",
576 * except if it is a div constraint, and add it to the data->res.
577 * The result is simplified in terms of data->build->domain.
579 static int expr_from_basic_set(__isl_take isl_constraint *c, void *user)
581 struct isl_expr_from_basic_data *data = user;
584 if (isl_constraint_is_div_constraint(c)) {
585 isl_constraint_free(c);
589 expr = isl_ast_expr_from_constraint(c, data->build);
593 data->res = isl_ast_expr_and(data->res, expr);
602 /* Construct an isl_ast_expr that evaluates the conditions defining "bset".
603 * The result is simplified in terms of build->domain.
605 * We filter out the div constraints during printing, so we do not know
606 * in advance how many constraints are going to be printed.
608 * If it turns out that there was no constraint, then we contruct
609 * the expression "1", i.e., "true".
611 __isl_give isl_ast_expr *isl_ast_build_expr_from_basic_set(
612 __isl_keep isl_ast_build *build, __isl_take isl_basic_set *bset)
614 struct isl_expr_from_basic_data data = { build, 1, NULL };
616 if (isl_basic_set_foreach_constraint(bset,
617 &expr_from_basic_set, &data) < 0) {
618 data.res = isl_ast_expr_free(data.res);
619 } else if (data.res == NULL) {
620 isl_ctx *ctx = isl_basic_set_get_ctx(bset);
621 data.res = isl_ast_expr_alloc_int_si(ctx, 1);
624 isl_basic_set_free(bset);
628 struct isl_expr_from_set_data {
629 isl_ast_build *build;
634 /* Construct an isl_ast_expr that evaluates the conditions defining "bset"
635 * and add it to data->res.
636 * The result is simplified in terms of data->build->domain.
638 static int expr_from_set(__isl_take isl_basic_set *bset, void *user)
640 struct isl_expr_from_set_data *data = user;
643 expr = isl_ast_build_expr_from_basic_set(data->build, bset);
647 data->res = isl_ast_expr_or(data->res, expr);
656 /* Construct an isl_ast_expr that evaluates the conditions defining "set".
657 * The result is simplified in terms of build->domain.
659 __isl_give isl_ast_expr *isl_ast_build_expr_from_set(
660 __isl_keep isl_ast_build *build, __isl_take isl_set *set)
662 struct isl_expr_from_set_data data = { build, 1, NULL };
664 if (isl_set_foreach_basic_set(set, &expr_from_set, &data) < 0)
665 data.res = isl_ast_expr_free(data.res);
671 struct isl_from_pw_aff_data {
672 isl_ast_build *build;
678 /* This function is called during the construction of an isl_ast_expr
679 * that evaluates an isl_pw_aff.
680 * Adjust data->next to take into account this piece.
682 * data->n is the number of pairs of set and aff to go.
683 * data->dom is the domain of the entire isl_pw_aff.
685 * If this is the last pair, then data->next is set to evaluate aff
686 * and the domain is ignored.
687 * Otherwise, data->next is set to a select operation that selects
688 * an isl_ast_expr correponding to "aff" on "set" and to an expression
689 * that will be filled in by later calls otherwise.
691 static int ast_expr_from_pw_aff(__isl_take isl_set *set,
692 __isl_take isl_aff *aff, void *user)
694 struct isl_from_pw_aff_data *data = user;
697 ctx = isl_set_get_ctx(set);
700 *data->next = isl_ast_expr_from_aff(aff, data->build);
705 isl_ast_expr *ternary, *arg;
707 ternary = isl_ast_expr_alloc_op(ctx, isl_ast_op_select, 3);
708 set = isl_set_gist(set, isl_set_copy(data->dom));
709 arg = isl_ast_build_expr_from_set(data->build, set);
710 ternary = isl_ast_expr_set_op_arg(ternary, 0, arg);
711 arg = isl_ast_expr_from_aff(aff, data->build);
712 ternary = isl_ast_expr_set_op_arg(ternary, 1, arg);
716 *data->next = ternary;
717 data->next = &ternary->u.op.args[2];
723 /* Construct an isl_ast_expr that evaluates "pa".
724 * The result is simplified in terms of build->domain.
726 * The domain of "pa" lives in the internal schedule space.
728 __isl_give isl_ast_expr *isl_ast_build_expr_from_pw_aff_internal(
729 __isl_keep isl_ast_build *build, __isl_take isl_pw_aff *pa)
731 struct isl_from_pw_aff_data data;
732 isl_ast_expr *res = NULL;
738 data.n = isl_pw_aff_n_piece(pa);
740 data.dom = isl_pw_aff_domain(isl_pw_aff_copy(pa));
742 if (isl_pw_aff_foreach_piece(pa, &ast_expr_from_pw_aff, &data) < 0)
743 res = isl_ast_expr_free(res);
745 isl_die(isl_pw_aff_get_ctx(pa), isl_error_invalid,
746 "cannot handle void expression", res = NULL);
749 isl_set_free(data.dom);
753 /* Construct an isl_ast_expr that evaluates "pa".
754 * The result is simplified in terms of build->domain.
756 * The domain of "pa" lives in the external schedule space.
758 __isl_give isl_ast_expr *isl_ast_build_expr_from_pw_aff(
759 __isl_keep isl_ast_build *build, __isl_take isl_pw_aff *pa)
763 if (isl_ast_build_need_schedule_map(build)) {
765 ma = isl_ast_build_get_schedule_map_multi_aff(build);
766 pa = isl_pw_aff_pullback_multi_aff(pa, ma);
768 expr = isl_ast_build_expr_from_pw_aff_internal(build, pa);
772 /* Set the ids of the input dimensions of "pma" to the iterator ids
775 * The domain of "pma" is assumed to live in the internal schedule domain.
777 static __isl_give isl_pw_multi_aff *set_iterator_names(
778 __isl_keep isl_ast_build *build, __isl_take isl_pw_multi_aff *pma)
782 n = isl_pw_multi_aff_dim(pma, isl_dim_in);
783 for (i = 0; i < n; ++i) {
786 id = isl_ast_build_get_iterator_id(build, i);
787 pma = isl_pw_multi_aff_set_dim_id(pma, isl_dim_in, i, id);
793 /* Construct an isl_ast_expr that calls the domain element specified by "pma".
794 * The name of the function is obtained from the output tuple name.
795 * The arguments are given by the piecewise affine expressions.
797 * The domain of "pma" is assumed to live in the internal schedule domain.
799 static __isl_give isl_ast_expr *isl_ast_build_call_from_pw_multi_aff_internal(
800 __isl_keep isl_ast_build *build, __isl_take isl_pw_multi_aff *pma)
807 pma = set_iterator_names(build, pma);
809 return isl_pw_multi_aff_free(pma);
811 ctx = isl_ast_build_get_ctx(build);
812 n = isl_pw_multi_aff_dim(pma, isl_dim_out);
813 expr = isl_ast_expr_alloc_op(ctx, isl_ast_op_call, 1 + n);
815 if (isl_pw_multi_aff_has_tuple_id(pma, isl_dim_out))
816 id = isl_pw_multi_aff_get_tuple_id(pma, isl_dim_out);
818 id = isl_id_alloc(ctx, "", NULL);
820 expr = isl_ast_expr_set_op_arg(expr, 0, isl_ast_expr_from_id(id));
821 for (i = 0; i < n; ++i) {
825 pa = isl_pw_multi_aff_get_pw_aff(pma, i);
826 arg = isl_ast_build_expr_from_pw_aff_internal(build, pa);
827 expr = isl_ast_expr_set_op_arg(expr, 1 + i, arg);
830 isl_pw_multi_aff_free(pma);
834 /* Construct an isl_ast_expr that calls the domain element specified by "pma".
835 * The name of the function is obtained from the output tuple name.
836 * The arguments are given by the piecewise affine expressions.
838 * The domain of "pma" is assumed to live in the external schedule domain.
840 __isl_give isl_ast_expr *isl_ast_build_call_from_pw_multi_aff(
841 __isl_keep isl_ast_build *build, __isl_take isl_pw_multi_aff *pma)
845 isl_space *space_build, *space_pma;
847 space_build = isl_ast_build_get_space(build, 0);
848 space_pma = isl_pw_multi_aff_get_space(pma);
849 is_domain = isl_space_tuple_match(space_build, isl_dim_set,
850 space_pma, isl_dim_in);
851 isl_space_free(space_build);
852 isl_space_free(space_pma);
854 return isl_pw_multi_aff_free(pma);
856 isl_die(isl_ast_build_get_ctx(build), isl_error_invalid,
857 "spaces don't match",
858 return isl_pw_multi_aff_free(pma));
860 if (isl_ast_build_need_schedule_map(build)) {
862 ma = isl_ast_build_get_schedule_map_multi_aff(build);
863 pma = isl_pw_multi_aff_pullback_multi_aff(pma, ma);
866 expr = isl_ast_build_call_from_pw_multi_aff_internal(build, pma);
870 /* Construct an isl_ast_expr that calls the domain element
871 * specified by "executed".
873 * "executed" is assumed to be single-valued, with a domain that lives
874 * in the internal schedule space.
876 __isl_give isl_ast_node *isl_ast_build_call_from_executed(
877 __isl_keep isl_ast_build *build, __isl_take isl_map *executed)
879 isl_pw_multi_aff *iteration;
882 iteration = isl_pw_multi_aff_from_map(executed);
883 iteration = isl_ast_build_compute_gist_pw_multi_aff(build, iteration);
884 iteration = isl_pw_multi_aff_intersect_domain(iteration,
885 isl_ast_build_get_domain(build));
886 expr = isl_ast_build_call_from_pw_multi_aff_internal(build, iteration);
887 return isl_ast_node_alloc_user(expr);