Polly 19.0.0git
isl_pw_opt_templ.c
Go to the documentation of this file.
1/*
2 * Copyright 2010 INRIA Saclay
3 *
4 * Use of this software is governed by the MIT license
5 *
6 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
7 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
8 * 91893 Orsay, France
9 */
10
11/* Compute the maximal value attained by the piecewise quasipolynomial
12 * on its domain or zero if the domain is empty.
13 * In the worst case, the domain is scanned completely,
14 * so the domain is assumed to be bounded.
15 */
16__isl_give isl_val *FN(PW,opt)(__isl_take PW *pw, int max)
17{
18 int i;
19 isl_val *opt;
20
21 if (!pw)
22 return NULL;
23
24 if (pw->n == 0) {
25 opt = isl_val_zero(FN(PW,get_ctx)(pw));
26 FN(PW,free)(pw);
27 return opt;
28 }
29
30 opt = FN(EL,opt_on_domain)(FN(EL,copy)(pw->p[0].FIELD),
31 isl_set_copy(pw->p[0].set), max);
32 for (i = 1; i < pw->n; ++i) {
33 isl_val *opt_i;
34 opt_i = FN(EL,opt_on_domain)(FN(EL,copy)(pw->p[i].FIELD),
35 isl_set_copy(pw->p[i].set), max);
36 if (max)
37 opt = isl_val_max(opt, opt_i);
38 else
39 opt = isl_val_min(opt, opt_i);
40 }
41
42 FN(PW,free)(pw);
43 return opt;
44}
45
47{
48 return FN(PW,opt)(pw, 1);
49}
50
52{
53 return FN(PW,opt)(pw, 0);
54}
#define FN(TYPE, NAME)
#define __isl_take
Definition: ctx.h:22
#define __isl_give
Definition: ctx.h:19
#define PW
Definition: isl_aff.c:4582
#define EL
__isl_give isl_set * isl_set_copy(__isl_keep isl_set *set)
Definition: isl_map.c:1470
__isl_export __isl_give isl_val * isl_val_max(__isl_take isl_val *v1, __isl_take isl_val *v2)
Definition: isl_val.c:598
__isl_export __isl_give isl_val * isl_val_zero(isl_ctx *ctx)
Definition: isl_val.c:41
__isl_export __isl_give isl_val * isl_val_min(__isl_take isl_val *v1, __isl_take isl_val *v2)
Definition: isl_val.c:570