]> git.pld-linux.org Git - packages/cloog-isl.git/blob - cloog-isl-git.patch
Merge branch 'master' of git://git.pld-linux.org/packages/cloog-isl
[packages/cloog-isl.git] / cloog-isl-git.patch
1 From b561f860f2fefa84459750d576807d214e4aad97 Mon Sep 17 00:00:00 2001
2 From: Sven Verdoolaege <skimo@kotnet.org>
3 Date: Sun, 12 Jan 2014 14:35:00 +0100
4 Subject: [PATCH] cloog_domain_cube: reimplement using documented functions
5
6 The original implementation used the undocumented
7 isl_basic_set_interval function, which will be removed
8 in the next release of isl.
9
10 Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
11 Signed-off-by: Cedric Bastoul <cedric.bastoul@unistra.fr>
12 ---
13  source/isl/domain.c |   20 ++++++++++----------
14  1 files changed, 10 insertions(+), 10 deletions(-)
15
16 diff --git a/source/isl/domain.c b/source/isl/domain.c
17 index d11da7b..620584d 100644
18 --- a/source/isl/domain.c
19 +++ b/source/isl/domain.c
20 @@ -1389,20 +1389,20 @@ CloogDomain *cloog_domain_cube(CloogState *state,
21                                 int dim, cloog_int_t min, cloog_int_t max)
22  {
23         int i;
24 -       struct isl_basic_set *cube;
25 -       struct isl_basic_set *interval;
26 -       struct isl_basic_set_list *list;
27 +       isl_space *space;
28 +       isl_set *cube;
29  
30         if (dim == 0)
31                 return cloog_domain_universe(state, dim);
32  
33 -       interval = isl_basic_set_interval(state->backend->ctx, min, max);
34 -       list = isl_basic_set_list_alloc(state->backend->ctx, dim);
35 -       for (i = 0; i < dim; ++i)
36 -               list = isl_basic_set_list_add(list, isl_basic_set_copy(interval));
37 -       isl_basic_set_free(interval);
38 -       cube = isl_basic_set_list_product(list);
39 -       return cloog_domain_from_isl_set(isl_set_from_basic_set(cube));
40 +       space = isl_space_set_alloc(state->backend->ctx, 0, dim);
41 +       cube = isl_set_universe(space);
42 +       for (i = 0; i < dim; ++i) {
43 +               cube = isl_set_lower_bound(cube, isl_dim_set, i, min);
44 +               cube = isl_set_upper_bound(cube, isl_dim_set, i, max);
45 +       }
46 +
47 +       return cloog_domain_from_isl_set(cube);
48  }
49  
50  
51 -- 
52 1.7.6.6.GIT
53
54 From 2d8b7c6b43ee46fee978a57fa6877de49675f357 Mon Sep 17 00:00:00 2001
55 From: Taj Muhammad Khan <taj.khan@lri.fr>
56 Date: Thu, 5 Dec 2013 07:55:16 +0530
57 Subject: [PATCH] Use isl_val instead of isl_int
58
59 isl is moving from the macro-based isl_int to a more generic
60 integer type isl_val, so CLooG does with this patch.
61 Authors are Uday Bondhugula, Taj Muhammad Khan and Cedric Bastoul.
62 ---
63  include/cloog/isl/constraintset.h |    6 +
64  source/isl/constraints.c          |  247 +++++++++++++++++++---------
65  source/isl/domain.c               |  329 ++++++++++++++++++++++++-------------
66  3 files changed, 389 insertions(+), 193 deletions(-)
67
68 diff --git a/include/cloog/isl/constraintset.h b/include/cloog/isl/constraintset.h
69 index c3c2eed..5d48cdb 100644
70 --- a/include/cloog/isl/constraintset.h
71 +++ b/include/cloog/isl/constraintset.h
72 @@ -27,6 +27,12 @@ CloogConstraintSet *cloog_constraint_set_from_isl_basic_set(struct isl_basic_set
73  CloogConstraint *cloog_constraint_from_isl_constraint(struct isl_constraint *constraint);
74  isl_constraint *cloog_constraint_to_isl(CloogConstraint *constraint);
75  
76 +__isl_give isl_val *cloog_int_to_isl_val(isl_ctx* ctx, cloog_int_t c);
77 +void isl_val_to_cloog_int(__isl_keep isl_val *val, cloog_int_t *cint);
78 +
79 +__isl_give isl_val *cloog_constraint_coefficient_get_val(CloogConstraint *constraint,
80 +                       int var);
81 +
82  #if defined(__cplusplus)
83    }
84  #endif 
85 diff --git a/source/isl/constraints.c b/source/isl/constraints.c
86 index e860000..73d72df 100644
87 --- a/source/isl/constraints.c
88 +++ b/source/isl/constraints.c
89 @@ -5,11 +5,51 @@
90  #include <cloog/isl/backend.h>
91  #include <isl/aff.h>
92  #include <isl/set.h>
93 +#include <isl/val.h>
94 +#include <isl/val_gmp.h>
95  
96  
97  #define ALLOC(type) (type*)malloc(sizeof(type))
98  #define ALLOCN(type,n) (type*)malloc((n)*sizeof(type))
99  
100 +__isl_give isl_val *cloog_int_to_isl_val(isl_ctx* ctx, cloog_int_t c)
101 +{
102 +       isl_val *v;
103 +#if defined(CLOOG_INT_INT)
104 +       v = isl_val_int_from_si(ctx, c);
105 +#elif defined(CLOOG_INT_LONG)
106 +       v = isl_val_int_from_si(ctx, c);
107 +#elif defined(CLOOG_INT_LONG_LONG)
108 +       v = isl_val_int_from_si(ctx, c);
109 +#elif defined(CLOOG_INT_GMP)
110 +       v = isl_val_int_from_gmp(ctx, c);
111 +#else
112 +#error "No integer type defined"
113 +#endif
114 +       return v;
115 +}
116 +
117 +/*
118 + * CLooG'll be dealing in integers so we expect numerator/1 form
119 + * from isl_val. Thus get numerator to assign to cloog_int
120 + */
121 +void isl_val_to_cloog_int(__isl_keep isl_val *val, cloog_int_t *cint)
122 +{
123 +       assert(isl_val_is_int(val));
124 +#if defined(CLOOG_INT_INT)
125 +       *cint = isl_val_get_num_si(val);
126 +#elif defined(CLOOG_INT_LONG)
127 +       *cint = isl_val_get_num_si(val);
128 +#elif defined(CLOOG_INT_LONG_LONG)
129 +       *cint = isl_val_get_num_si(val);
130 +#elif defined(CLOOG_INT_GMP)
131 +       isl_val_get_num_gmp(val, *cint);
132 +#else
133 +#error "No integer type defined"
134 +#endif
135 +}
136 +
137 +
138  CloogConstraintSet *cloog_constraint_set_from_isl_basic_set(struct isl_basic_set *bset)
139  {
140         return (CloogConstraintSet *)bset;
141 @@ -266,53 +306,65 @@ int cloog_equal_count(CloogEqualities *equal)
142  static int cloog_constraint_equal_type(CloogConstraint *cc, int level)
143  { 
144         int i;
145 -       isl_int c;
146 +       isl_val *c;
147         int type = EQTYPE_NONE;
148         struct isl_constraint *constraint = cloog_constraint_to_isl(cc);
149      
150 -       isl_int_init(c);
151 -       isl_constraint_get_constant(constraint, &c);
152 -       if (!isl_int_is_zero(c))
153 +       c = isl_constraint_get_constant_val(constraint);
154 +       if (!isl_val_is_zero(c))
155                 type = EQTYPE_CONSTANT;
156 -       isl_constraint_get_coefficient(constraint, isl_dim_set, level - 1, &c);
157 -       if (!isl_int_is_one(c) && !isl_int_is_negone(c))
158 +       isl_val_free(c);
159 +       c = isl_constraint_get_coefficient_val(constraint, isl_dim_set, level - 1);
160 +       if (!isl_val_is_one(c) && !isl_val_is_negone(c))
161                 type = EQTYPE_EXAFFINE;
162 +       isl_val_free(c);
163         for (i = 0; i < isl_constraint_dim(constraint, isl_dim_param); ++i) {
164 -               isl_constraint_get_coefficient(constraint, isl_dim_param, i, &c);
165 -               if (isl_int_is_zero(c))
166 +               c = isl_constraint_get_coefficient_val(constraint, isl_dim_param, i);
167 +               if (isl_val_is_zero(c)){
168 +                       isl_val_free(c);
169                         continue;
170 -               if ((!isl_int_is_one(c) && !isl_int_is_negone(c)) ||
171 +               }
172 +               if ((!isl_val_is_one(c) && !isl_val_is_negone(c)) ||
173                     type != EQTYPE_NONE) {
174                         type = EQTYPE_EXAFFINE;
175 +                       isl_val_free(c);
176                         break;
177                 }
178                 type = EQTYPE_PUREITEM;
179 +               isl_val_free(c);
180         }
181         for (i = 0; i < isl_constraint_dim(constraint, isl_dim_set); ++i) {
182                 if (i == level - 1)
183                         continue;
184 -               isl_constraint_get_coefficient(constraint, isl_dim_set, i, &c);
185 -               if (isl_int_is_zero(c))
186 +               c = isl_constraint_get_coefficient_val(constraint, isl_dim_set, i);
187 +               if (isl_val_is_zero(c)){
188 +                       isl_val_free(c);
189                         continue;
190 -               if ((!isl_int_is_one(c) && !isl_int_is_negone(c)) ||
191 +               }
192 +               if ((!isl_val_is_one(c) && !isl_val_is_negone(c)) ||
193                     type != EQTYPE_NONE) {
194                         type = EQTYPE_EXAFFINE;
195 +                       isl_val_free(c);
196                         break;
197                 }
198                 type = EQTYPE_PUREITEM;
199 +               isl_val_free(c);
200         }
201         for (i = 0; i < isl_constraint_dim(constraint, isl_dim_div); ++i) {
202 -               isl_constraint_get_coefficient(constraint, isl_dim_div, i, &c);
203 -               if (isl_int_is_zero(c))
204 +               c = isl_constraint_get_coefficient_val(constraint, isl_dim_div, i);
205 +               if (isl_val_is_zero(c)){
206 +                       isl_val_free(c);
207                         continue;
208 -               if ((!isl_int_is_one(c) && !isl_int_is_negone(c)) ||
209 +               }
210 +               if ((!isl_val_is_one(c) && !isl_val_is_negone(c)) ||
211                     type != EQTYPE_NONE) {
212                         type = EQTYPE_EXAFFINE;
213 +                       isl_val_free(c);
214                         break;
215                 }
216                 type = EQTYPE_PUREITEM;
217 +               isl_val_free(c);
218         }
219 -       isl_int_clear(c);
220  
221         if (type == EQTYPE_NONE)
222                 type = EQTYPE_CONSTANT;
223 @@ -447,27 +499,31 @@ static struct clast_expr *div_expr(CloogConstraint *constraint, int pos,
224  {
225         int i, nb_elts;
226         unsigned dim = cloog_constraint_total_dimension(constraint);
227 -       cloog_int_t c;
228 +       isl_val *c;
229         struct clast_reduction *r;
230         struct clast_expr *e = NULL;
231         isl_aff *div;
232 +       cloog_int_t cint;
233  
234 +       cloog_int_init(cint);
235         div = isl_constraint_get_div(cloog_constraint_to_isl(constraint), pos);
236  
237 -       cloog_int_init(c);
238         for (i = 0, nb_elts = 0; i < dim; ++i) {
239                 struct cloog_isl_dim dim;
240  
241                 dim = constraint_cloog_dim_to_isl_dim(constraint, i);
242                 if (dim.type == isl_dim_set)
243                         dim.type = isl_dim_in;
244 -               isl_aff_get_coefficient(div, dim.type, dim.pos, &c);
245 -               if (!cloog_int_is_zero(c))
246 +               c = isl_aff_get_coefficient_val(div, dim.type, dim.pos);
247 +               if (!isl_val_is_zero(c))
248                         ++nb_elts;
249 +
250 +               isl_val_free(c);
251         }
252 -       isl_aff_get_constant(div, &c);
253 -       if (!cloog_int_is_zero(c))
254 +       c = isl_aff_get_constant_val(div);
255 +       if (!isl_val_is_zero(c))
256                 ++nb_elts;
257 +       isl_val_free(c);
258  
259         r = new_clast_reduction(clast_red_sum, nb_elts);
260         for (i = 0, nb_elts = 0; i < dim; ++i) {
261 @@ -477,22 +533,35 @@ static struct clast_expr *div_expr(CloogConstraint *constraint, int pos,
262                 dim = constraint_cloog_dim_to_isl_dim(constraint, i);
263                 if (dim.type == isl_dim_set)
264                         dim.type = isl_dim_in;
265 -               isl_aff_get_coefficient(div, dim.type, dim.pos, &c);
266 -               if (cloog_int_is_zero(c))
267 +               c = isl_aff_get_coefficient_val(div, dim.type, dim.pos);
268 +               if (isl_val_is_zero(c)){
269 +                       isl_val_free(c);
270                         continue;
271 +               }
272  
273                 v = cloog_constraint_variable_expr(constraint, 1 + i, names);
274  
275 -               r->elts[nb_elts++] = &new_clast_term(c, v)->expr;
276 +               /* We are interested only in the numerator */
277 +               cloog_int_set_si(cint, isl_val_get_num_si(c));
278 +               r->elts[nb_elts++] = &new_clast_term(cint, v)->expr;
279 +
280 +               isl_val_free(c);
281 +       }
282 +
283 +       c = isl_aff_get_constant_val(div);
284 +       if (!isl_val_is_zero(c)) {
285 +               /* We are interested only in the numerator */
286 +               cloog_int_set_si(cint, isl_val_get_num_si(c));
287 +               r->elts[nb_elts++] = &new_clast_term(cint, NULL)->expr;
288         }
289 -       isl_aff_get_constant(div, &c);
290 -       if (!cloog_int_is_zero(c))
291 -               r->elts[nb_elts++] = &new_clast_term(c, NULL)->expr;
292 +       isl_val_free(c);
293  
294 -       isl_aff_get_denominator(div, &c);
295 -       e = &new_clast_binary(clast_bin_fdiv, &r->expr, c)->expr;
296 +       c = isl_aff_get_denominator_val(div);
297 +       isl_val_to_cloog_int(c, &cint);
298 +       isl_val_free(c);
299 +       e = &new_clast_binary(clast_bin_fdiv, &r->expr, cint)->expr;
300  
301 -       cloog_int_clear(c);
302 +       cloog_int_clear(cint);
303  
304         isl_aff_free(div);
305  
306 @@ -529,37 +598,34 @@ struct clast_expr *cloog_constraint_variable_expr(CloogConstraint *constraint,
307   */
308  int cloog_constraint_involves(CloogConstraint *constraint, int v)
309  {
310 -       isl_int c;
311 +       isl_val *c;
312         int res;
313  
314 -       isl_int_init(c);
315 -       cloog_constraint_coefficient_get(constraint, v, &c);
316 -       res = !isl_int_is_zero(c);
317 -       isl_int_clear(c);
318 +       c = cloog_constraint_coefficient_get_val(constraint, v);
319 +       res = !isl_val_is_zero(c);
320 +       isl_val_free(c);
321         return res;
322  }
323  
324  int cloog_constraint_is_lower_bound(CloogConstraint *constraint, int v)
325  {
326 -       isl_int c;
327 +       isl_val *c;
328         int res;
329  
330 -       isl_int_init(c);
331 -       cloog_constraint_coefficient_get(constraint, v, &c);
332 -       res = isl_int_is_pos(c);
333 -       isl_int_clear(c);
334 +       c = cloog_constraint_coefficient_get_val(constraint, v);
335 +       res = isl_val_is_pos(c);
336 +       isl_val_free(c);
337         return res;
338  }
339  
340  int cloog_constraint_is_upper_bound(CloogConstraint *constraint, int v)
341  {
342 -       isl_int c;
343 +       isl_val *c;
344         int res;
345  
346 -       isl_int_init(c);
347 -       cloog_constraint_coefficient_get(constraint, v, &c);
348 -       res = isl_int_is_neg(c);
349 -       isl_int_clear(c);
350 +       c = cloog_constraint_coefficient_get_val(constraint, v);
351 +       res = isl_val_is_neg(c);
352 +       isl_val_free(c);
353         return res;
354  }
355  
356 @@ -585,15 +651,37 @@ void cloog_constraint_coefficient_get(CloogConstraint *constraint,
357  {
358         struct cloog_isl_dim dim;
359         isl_constraint *c;
360 +       isl_val *ival;
361 +
362 +       if (!constraint)
363 +               val = NULL;
364 +
365 +       dim = constraint_cloog_dim_to_isl_dim(constraint, var);
366 +       c = cloog_constraint_to_isl(constraint);
367 +       ival = isl_constraint_get_coefficient_val(c, dim.type, dim.pos);
368 +
369 +       isl_val_to_cloog_int(ival, val);
370 +       isl_val_free(ival);
371 +}
372 +
373 +isl_val *cloog_constraint_coefficient_get_val(CloogConstraint *constraint,
374 +                       int var)
375 +{
376 +       struct cloog_isl_dim dim;
377 +       isl_constraint *c;
378 +       isl_val *val;
379  
380         if (!constraint)
381 -               return;
382 +               return NULL;
383  
384         dim = constraint_cloog_dim_to_isl_dim(constraint, var);
385         c = cloog_constraint_to_isl(constraint);
386 -       isl_constraint_get_coefficient(c, dim.type, dim.pos, val);
387 +       val = isl_constraint_get_coefficient_val(c, dim.type, dim.pos);
388 +       return val;
389  }
390  
391 +
392 +
393  void cloog_constraint_coefficient_set(CloogConstraint *constraint,
394                         int var, cloog_int_t val)
395  {
396 @@ -604,14 +692,26 @@ void cloog_constraint_coefficient_set(CloogConstraint *constraint,
397  
398         dim = constraint_cloog_dim_to_isl_dim(constraint, var);
399         c = cloog_constraint_to_isl(constraint);
400 -       isl_constraint_set_coefficient(c, dim.type, dim.pos, val);
401 +       isl_constraint_set_coefficient_val(c, dim.type, dim.pos,
402 +               cloog_int_to_isl_val(isl_constraint_get_ctx(c), val));
403  }
404  
405  void cloog_constraint_constant_get(CloogConstraint *constraint, cloog_int_t *val)
406  {
407 -       isl_constraint_get_constant(cloog_constraint_to_isl(constraint), val);
408 +       isl_val *ival;
409 +       ival = isl_constraint_get_constant_val(cloog_constraint_to_isl(constraint));
410 +       isl_val_to_cloog_int(ival, val);
411 +       isl_val_free(ival);
412  }
413  
414 +
415 +__isl_give isl_val *cloog_constraint_constant_get_val(CloogConstraint *constraint)
416 +{
417 +       return isl_constraint_get_constant_val(cloog_constraint_to_isl(constraint));
418 +}
419 +
420 +
421 +
422  /**
423   * Copy the coefficient of constraint c into dst in PolyLib order,
424   * i.e., first the coefficients of the variables, then the coefficients
425 @@ -700,15 +800,11 @@ CloogConstraintSet *cloog_constraint_set_for_reduction(CloogConstraint *upper,
426  
427  static int add_constant_term(CloogConstraint *c, void *user)
428  {
429 -       isl_int *bound = (isl_int *)user;
430 -       isl_int v;
431 -
432 -       isl_int_init(v);
433 -
434 -       cloog_constraint_constant_get(c, &v);
435 -       isl_int_add(*bound, *bound, v);
436 +       isl_val **bound = (isl_val **)user;
437 +       isl_val *v;
438  
439 -       isl_int_clear(v);
440 +       v = cloog_constraint_constant_get_val(c);
441 +       *bound = isl_val_add(*bound, v);
442  
443         return 0;
444  }
445 @@ -822,11 +918,14 @@ CloogConstraintSet *cloog_constraint_set_reduce(CloogConstraintSet *constraints,
446         c = isl_constraint_set_coefficient_si(c, isl_dim_set, dim.pos, -1);
447         bset = isl_basic_set_add_constraint(bset, c);
448  
449 -       isl_int_set_si(*bound, 0);
450 +       cloog_int_set_si(*bound, 0);
451 +       isl_val *v = cloog_int_to_isl_val(isl_basic_set_get_ctx(bset), *bound);
452         constraints = cloog_constraint_set_from_isl_basic_set(bset);
453         cloog_constraint_set_foreach_constraint(constraints,
454 -                                               add_constant_term, bound);
455 +                       add_constant_term, &v);
456 +       isl_val_to_cloog_int(v, bound); //return the value to bound
457  
458 +       isl_val_free(v);
459         isl_basic_set_free(orig);
460         return cloog_constraint_set_from_isl_basic_set(bset);
461  }
462 @@ -896,31 +995,27 @@ static isl_aff *extract_stride_offset(__isl_keep isl_constraint *c,
463         isl_space *dim = isl_constraint_get_space(c);
464         isl_local_space *ls = isl_local_space_from_space(dim);
465         isl_aff *offset = isl_aff_zero_on_domain(ls);
466 -       isl_int u;
467 +       isl_val *u;
468         unsigned nparam, nvar;
469  
470 -       isl_int_init(u);
471 -
472         nparam = isl_constraint_dim(c, isl_dim_param);
473         nvar = isl_constraint_dim(c, isl_dim_set);
474  
475         for (i = 0; i < nparam; ++i) {
476 -               isl_constraint_get_coefficient(c, isl_dim_param, i, &u);
477 -               isl_int_mul(u, u, stride->factor);
478 -               offset = isl_aff_set_coefficient(offset, isl_dim_param, i, u);
479 +               u = isl_constraint_get_coefficient_val(c, isl_dim_param, i);
480 +               u = isl_val_mul(u, cloog_int_to_isl_val(isl_constraint_get_ctx(c), stride->factor));
481 +               offset = isl_aff_set_coefficient_val(offset, isl_dim_param, i, u);
482         }
483         for (i = 0; i < nvar; ++i) {
484                 if (i == level - 1)
485                         continue;
486 -               isl_constraint_get_coefficient(c, isl_dim_set, i, &u);
487 -               isl_int_mul(u, u, stride->factor);
488 -               offset = isl_aff_set_coefficient(offset, isl_dim_in, i, u);
489 +               u = isl_constraint_get_coefficient_val(c, isl_dim_set, i);
490 +               u = isl_val_mul(u, cloog_int_to_isl_val(isl_constraint_get_ctx(c), stride->factor));
491 +               offset = isl_aff_set_coefficient_val(offset, isl_dim_in, i, u);
492         }
493 -       isl_constraint_get_constant(c, &u);
494 -       isl_int_mul(u, u, stride->factor);
495 -       offset = isl_aff_set_constant(offset, u);
496 -
497 -       isl_int_clear(u);
498 +       u = isl_constraint_get_constant_val(c);
499 +       u = isl_val_mul(u, cloog_int_to_isl_val(isl_constraint_get_ctx(c), stride->factor));
500 +       offset = isl_aff_set_constant_val(offset, u);
501  
502         return offset;
503  }
504 @@ -953,9 +1048,9 @@ CloogConstraint *cloog_constraint_stride_lower_bound(CloogConstraint *c,
505         offset = extract_stride_offset(stride_c, level, stride);
506  
507         lower = isl_aff_sub(lower, isl_aff_copy(offset));
508 -       lower = isl_aff_scale_down(lower, stride->stride);
509 +       lower = isl_aff_scale_down_val(lower, cloog_int_to_isl_val(isl_constraint_get_ctx(stride_c), stride->stride));
510         lower = isl_aff_ceil(lower);
511 -       lower = isl_aff_scale(lower, stride->stride);
512 +       lower = isl_aff_scale_val(lower, cloog_int_to_isl_val(isl_constraint_get_ctx(stride_c), stride->stride));
513         lower = isl_aff_add(lower, offset);
514         lower = isl_aff_neg(lower);
515         lower = isl_aff_add_coefficient_si(lower, isl_dim_in, level - 1, 1);
516 diff --git a/source/isl/domain.c b/source/isl/domain.c
517 index 620584d..dc81a96 100644
518 --- a/source/isl/domain.c
519 +++ b/source/isl/domain.c
520 @@ -7,7 +7,11 @@
521  #include <isl/list.h>
522  #include <isl/constraint.h>
523  #include <isl/ilp.h>
524 +#include <isl/lp.h>
525  #include <isl/aff.h>
526 +#include <isl/map.h>
527 +#include <isl/val.h>
528 +#include <isl/val_gmp.h>
529  
530  #ifdef OSL_SUPPORT
531  #include <osl/macros.h>
532 @@ -510,15 +514,18 @@ static struct isl_constraint *isl_constraint_read_from_matrix(
533         else
534                 constraint = isl_inequality_alloc(ls);
535  
536 -       for (j = 0; j < nvariables; ++j)
537 -               isl_constraint_set_coefficient(constraint, isl_dim_out, j,
538 -                                              row[1 + j]);
539 +       for (j = 0; j < nvariables; ++j) {
540 +               isl_val *val = cloog_int_to_isl_val(isl_constraint_get_ctx(constraint), row[1 + j]);
541 +               isl_constraint_set_coefficient_val(constraint, isl_dim_out, j, val);
542 +       }
543  
544 -       for (j = 0; j < nparam; ++j)
545 -               isl_constraint_set_coefficient(constraint, isl_dim_param, j,
546 -                                              row[1 + nvariables + j]);
547 +       for (j = 0; j < nparam; ++j) {
548 +               isl_val *val = cloog_int_to_isl_val(isl_constraint_get_ctx(constraint), row[1 + nvariables + j]);
549 +               isl_constraint_set_coefficient_val(constraint, isl_dim_param, j, val);
550 +       }
551  
552 -       isl_constraint_set_constant(constraint, row[1 + nvariables + nparam]);
553 +       isl_val *val = cloog_int_to_isl_val(isl_constraint_get_ctx(constraint), row[1 + nvariables + nparam]);
554 +       isl_constraint_set_constant_val(constraint, val);
555  
556         return constraint;
557  }
558 @@ -631,7 +638,6 @@ CloogDomain *cloog_domain_from_osl_relation(CloogState *state,
559    return domain;
560  }
561  
562 -
563  /**
564   * Converts an openscop scattering relation to a CLooG scattering.
565   * \param[in,out] state    CLooG state.
566 @@ -779,10 +785,22 @@ int cloog_domain_is_otl(CloogDomain *domain, int level)
567  void cloog_domain_stride(CloogDomain *domain, int strided_level,
568         cloog_int_t *stride, cloog_int_t *offset)
569  {
570 +       int ret = -1;
571         isl_set *set = isl_set_from_cloog_domain(domain);
572 -       isl_set_dim_residue_class(set, strided_level - 1, stride, offset);
573 -       if (!isl_int_is_zero(*offset))
574 -               isl_int_sub(*offset, *stride, *offset);
575 +       isl_val *stride_val = NULL;
576 +       isl_val *offset_val = NULL;
577 +       ret = isl_set_dim_residue_class_val(set, strided_level - 1, &stride_val, &offset_val);
578 +       if (ret != 0)
579 +               cloog_die("failure to compute stride.\n");
580 +       isl_val_to_cloog_int(stride_val, stride);
581 +       isl_val_to_cloog_int(offset_val, offset);
582 +
583 +       if (!cloog_int_is_zero(*offset))
584 +               cloog_int_sub(*offset, *stride, *offset);
585 +
586 +       isl_val_free(stride_val);
587 +       isl_val_free(offset_val);
588 +
589         return;
590  }
591  
592 @@ -796,7 +814,7 @@ static int constraint_can_stride(__isl_take isl_constraint *c, void *user)
593  {
594         struct cloog_can_stride *ccs = (struct cloog_can_stride *)user;
595         int i;
596 -       isl_int v;
597 +       isl_val *v;
598         unsigned n_div;
599  
600         if (isl_constraint_is_equality(c)) {
601 @@ -804,21 +822,22 @@ static int constraint_can_stride(__isl_take isl_constraint *c, void *user)
602                 return 0;
603         }
604  
605 -       isl_int_init(v);
606 -       isl_constraint_get_coefficient(c, isl_dim_set, ccs->level - 1, &v);
607 -       if (isl_int_is_pos(v)) {
608 +       v = isl_constraint_get_coefficient_val(c, isl_dim_set, ccs->level - 1);
609 +       if (isl_val_is_pos(v)) {
610                 n_div = isl_constraint_dim(c, isl_dim_div);
611 +
612                 for (i = 0; i < n_div; ++i) {
613 -                       isl_constraint_get_coefficient(c, isl_dim_div, i, &v);
614 -                       if (!isl_int_is_zero(v))
615 +                       isl_val_free(v);
616 +                       v = isl_constraint_get_coefficient_val(c, isl_dim_div, i);
617 +                       if (!isl_val_is_zero(v))
618                                 break;
619                 }
620                 if (i < n_div)
621                         ccs->can_stride = 0;
622         }
623 -       isl_int_clear(v);
624 -       isl_constraint_free(c);
625 +       isl_val_free(v);
626  
627 +       isl_constraint_free(c);
628         return 0;
629  }
630  
631 @@ -903,7 +922,7 @@ struct cloog_stride_lower {
632  static int constraint_stride_lower(__isl_take isl_constraint *c, void *user)
633  {
634         struct cloog_stride_lower *csl = (struct cloog_stride_lower *)user;
635 -       isl_int v;
636 +       isl_val *v;
637         isl_constraint *bound;
638         isl_aff *b;
639  
640 @@ -912,31 +931,31 @@ static int constraint_stride_lower(__isl_take isl_constraint *c, void *user)
641                 return 0;
642         }
643  
644 -       isl_int_init(v);
645 -       isl_constraint_get_coefficient(c, isl_dim_set, csl->level - 1, &v);
646 -       if (!isl_int_is_pos(v)) {
647 -               isl_int_clear(v);
648 +       v = isl_constraint_get_coefficient_val(c, isl_dim_set, csl->level - 1);
649 +       if (!isl_val_is_pos(v)) {
650 +               isl_val_free(v);
651                 isl_constraint_free(c);
652  
653                 return 0;
654         }
655 +       isl_val_free(v);
656  
657         b = isl_constraint_get_bound(c, isl_dim_set, csl->level - 1);
658  
659         b = isl_aff_neg(b);
660 -       b = isl_aff_add_constant(b, csl->stride->offset);
661 -       b = isl_aff_scale_down(b, csl->stride->stride);
662 +       b = isl_aff_add_constant_val(b, cloog_int_to_isl_val(isl_constraint_get_ctx(c), csl->stride->offset));
663 +       b = isl_aff_scale_down_val(b, cloog_int_to_isl_val(isl_constraint_get_ctx(c), csl->stride->stride));
664         b = isl_aff_floor(b);
665 -       b = isl_aff_scale(b, csl->stride->stride);
666 -       isl_int_neg(v, csl->stride->offset);
667 -       b = isl_aff_add_constant(b, v);
668 +       b = isl_aff_scale_val(b, cloog_int_to_isl_val(isl_constraint_get_ctx(c), csl->stride->stride));
669 +       v = cloog_int_to_isl_val(isl_constraint_get_ctx(c), csl->stride->offset);
670 +       v = isl_val_neg(v);
671 +       b = isl_aff_add_constant_val(b, v);
672         b = isl_aff_add_coefficient_si(b, isl_dim_in, csl->level - 1, 1);
673  
674         bound = isl_inequality_from_aff(b);
675  
676         csl->bounds = isl_basic_set_add_constraint(csl->bounds, bound);
677  
678 -       isl_int_clear(v);
679         isl_constraint_free(c);
680  
681         return 0;
682 @@ -960,7 +979,7 @@ static int constraint_stride_lower(__isl_take isl_constraint *c, void *user)
683  static int constraint_stride_lower_c(__isl_take isl_constraint *c, void *user)
684  {
685         struct cloog_stride_lower *csl = (struct cloog_stride_lower *)user;
686 -       isl_int v;
687 +       isl_val *v;
688         isl_constraint *bound;
689         isl_constraint *csl_c;
690         isl_aff *d, *b;
691 @@ -970,10 +989,9 @@ static int constraint_stride_lower_c(__isl_take isl_constraint *c, void *user)
692                 return 0;
693         }
694  
695 -       isl_int_init(v);
696 -       isl_constraint_get_coefficient(c, isl_dim_set, csl->level - 1, &v);
697 -       if (!isl_int_is_pos(v)) {
698 -               isl_int_clear(v);
699 +       v = isl_constraint_get_coefficient_val(c, isl_dim_set, csl->level - 1);
700 +       if (!isl_val_is_pos(v)) {
701 +               isl_val_free(v);
702                 isl_constraint_free(c);
703  
704                 return 0;
705 @@ -984,15 +1002,15 @@ static int constraint_stride_lower_c(__isl_take isl_constraint *c, void *user)
706         d = isl_constraint_get_aff(csl_c);
707         d = isl_aff_drop_dims(d, isl_dim_div, 0, isl_aff_dim(d, isl_dim_div));
708         d = isl_aff_set_coefficient_si(d, isl_dim_in, csl->level - 1, 0);
709 -       d = isl_aff_scale(d, csl->stride->factor);
710 +       d = isl_aff_scale_val(d, cloog_int_to_isl_val(isl_constraint_get_ctx(csl_c), csl->stride->factor));
711  
712         b = isl_constraint_get_bound(c, isl_dim_set, csl->level - 1);
713  
714         b = isl_aff_neg(b);
715         b = isl_aff_add(b, isl_aff_copy(d));
716 -       b = isl_aff_scale_down(b, csl->stride->stride);
717 +       b = isl_aff_scale_down_val(b, cloog_int_to_isl_val(isl_constraint_get_ctx(csl_c), csl->stride->stride));
718         b = isl_aff_floor(b);
719 -       b = isl_aff_scale(b, csl->stride->stride);
720 +       b = isl_aff_scale_val(b, cloog_int_to_isl_val(isl_constraint_get_ctx(csl_c), csl->stride->stride));
721         b = isl_aff_sub(b, d);
722         b = isl_aff_add_coefficient_si(b, isl_dim_in, csl->level - 1, 1);
723  
724 @@ -1000,7 +1018,7 @@ static int constraint_stride_lower_c(__isl_take isl_constraint *c, void *user)
725  
726         csl->bounds = isl_basic_set_add_constraint(csl->bounds, bound);
727  
728 -       isl_int_clear(v);
729 +       isl_val_free(v);
730         isl_constraint_free(c);
731  
732         return 0;
733 @@ -1090,28 +1108,30 @@ struct cloog_bound_split {
734  static int constraint_bound_split(__isl_take isl_constraint *c, void *user)
735  {
736         struct cloog_bound_split *cbs = (struct cloog_bound_split *)user;
737 -       isl_int v;
738 +       isl_val *v;
739         int i;
740         int handle = 0;
741  
742 -       isl_int_init(v);
743 -       isl_constraint_get_coefficient(c, isl_dim_set, cbs->level - 1, &v);
744 -       if (!cbs->lower && isl_int_is_pos(v))
745 +       v = isl_constraint_get_coefficient_val(c, isl_dim_set, cbs->level - 1);
746 +       if (!cbs->lower && isl_val_is_pos(v))
747                 cbs->lower = handle = 1;
748 -       else if (!cbs->upper && isl_int_is_neg(v))
749 +       else if (!cbs->upper && isl_val_is_neg(v))
750                 cbs->upper = handle = 1;
751 +
752         if (handle) {
753                 for (i = 0; i < isl_set_dim(cbs->set, isl_dim_param); ++i) {
754 -                       isl_constraint_get_coefficient(c, isl_dim_param, i, &v);
755 -                       if (isl_int_is_zero(v))
756 +                       isl_val_free(v);
757 +                       v = isl_constraint_get_coefficient_val(c, isl_dim_param, i);
758 +                       if (isl_val_is_zero(v))
759                                 continue;
760 +
761                         cbs->set = isl_set_split_dims(cbs->set,
762                                                         isl_dim_param, i, 1);
763                 }
764         }
765 -       isl_int_clear(v);
766 -       isl_constraint_free(c);
767 +       isl_val_free(v);
768  
769 +       isl_constraint_free(c);
770         return (cbs->lower && cbs->upper) ? -1 : 0;
771  }
772  
773 @@ -1203,7 +1223,7 @@ static int injective_scattering(CloogScatteringList *list)
774   * - scattdims is the total number of scattering dimentions.
775   */
776  int cloog_scattering_lazy_block(CloogScattering *s1, CloogScattering *s2,
777 -                           CloogScatteringList *scattering, int scattdims)
778 +                       CloogScatteringList *scattering, int scattdims)
779  {
780         int i;
781         struct isl_space *dim;
782 @@ -1211,8 +1231,8 @@ int cloog_scattering_lazy_block(CloogScattering *s1, CloogScattering *s2,
783         struct isl_set *delta;
784         isl_map *map1 = isl_map_from_cloog_scattering(s1);
785         isl_map *map2 = isl_map_from_cloog_scattering(s2);
786 -       int fixed, block;
787 -       isl_int cst;
788 +       int block;
789 +       isl_val *cst;
790         unsigned n_scat;
791  
792         n_scat = isl_map_dim(map1, isl_dim_out);
793 @@ -1225,22 +1245,33 @@ int cloog_scattering_lazy_block(CloogScattering *s1, CloogScattering *s2,
794         rel = isl_map_apply_domain(rel, isl_map_copy(map1));
795         rel = isl_map_apply_range(rel, isl_map_copy(map2));
796         delta = isl_map_deltas(rel);
797 -       isl_int_init(cst);
798 +       cst = NULL;
799         for (i = 0; i < n_scat; ++i) {
800 -               fixed = isl_set_fast_dim_is_fixed(delta, i, &cst);
801 -               if (fixed != 1)
802 +               cst = isl_set_plain_get_val_if_fixed(delta, isl_dim_set, i);
803 +               if (!cst){
804 +                       isl_val_free(cst);
805                         break;
806 -               if (isl_int_is_zero(cst))
807 +               }
808 +               if (isl_val_is_zero(cst)){
809 +                       isl_val_free(cst);
810                         continue;
811 -               if (i + 1 < n_scat)
812 +               }
813 +               if (i + 1 < n_scat){
814 +                       isl_val_free(cst);
815                         break;
816 -               if (!isl_int_is_one(cst))
817 +               }
818 +               if (!isl_val_is_one(cst)){
819 +                       isl_val_free(cst);
820                         break;
821 -               if (!injective_scattering(scattering))
822 +               }
823 +               if (!injective_scattering(scattering)){
824 +                       isl_val_free(cst);
825                         break;
826 +               }
827 +
828 +               isl_val_free(cst);
829         }
830         block = i >= n_scat;
831 -       isl_int_clear(cst);
832         isl_set_free(delta);
833         return block;
834  }
835 @@ -1345,10 +1376,25 @@ CloogDomain *cloog_domain_simplify_union(CloogDomain *domain)
836   * If value is not NULL, then it is set to the constant value of dimension.
837   */
838  int cloog_scattering_lazy_isscalar(CloogScattering *scatt, int dimension,
839 -                                       cloog_int_t *value)
840 +       cloog_int_t *value)
841  {
842         isl_map *map = isl_map_from_cloog_scattering(scatt);
843 -       return isl_map_fast_is_fixed(map, isl_dim_out, dimension, value);
844 +       isl_val *v = isl_map_plain_get_val_if_fixed(map, isl_dim_out, dimension);
845 +       if (v != NULL) {
846 +               if (!isl_val_is_nan(v)){
847 +                       if (value != NULL)
848 +                               isl_val_to_cloog_int(v, value);
849 +
850 +                       isl_val_free(v);
851 +                       return 1;
852 +               }
853 +               else {
854 +                       isl_val_free(v);
855 +                       return 0;
856 +               }
857 +       }
858 +
859 +       return 0;
860  }
861  
862  
863 @@ -1362,7 +1408,22 @@ int cloog_domain_lazy_isconstant(CloogDomain *domain, int dimension,
864         cloog_int_t *value)
865  {
866         isl_set *set = isl_set_from_cloog_domain(domain);
867 -       return isl_set_fast_dim_is_fixed(set, dimension, value);
868 +       isl_val *cst = isl_set_plain_get_val_if_fixed(set, isl_dim_set, dimension);
869 +       if (cst != NULL) {
870 +               if (!isl_val_is_nan(cst)){
871 +                       if (value != NULL)
872 +                               isl_val_to_cloog_int(cst, value);
873 +
874 +                       isl_val_free(cst);
875 +                       return 1;
876 +               }
877 +               else {
878 +                       isl_val_free(cst);
879 +                       return 0;
880 +               }
881 +       }
882 +
883 +       return 0;
884  }
885  
886  
887 @@ -1391,6 +1452,8 @@ CloogDomain *cloog_domain_cube(CloogState *state,
888         int i;
889         isl_space *space;
890         isl_set *cube;
891 +       isl_val *min_v;
892 +       isl_val *max_v;
893  
894         if (dim == 0)
895                 return cloog_domain_universe(state, dim);
896 @@ -1398,8 +1461,10 @@ CloogDomain *cloog_domain_cube(CloogState *state,
897         space = isl_space_set_alloc(state->backend->ctx, 0, dim);
898         cube = isl_set_universe(space);
899         for (i = 0; i < dim; ++i) {
900 -               cube = isl_set_lower_bound(cube, isl_dim_set, i, min);
901 -               cube = isl_set_upper_bound(cube, isl_dim_set, i, max);
902 +               min_v = cloog_int_to_isl_val(isl_set_get_ctx(cube), min);
903 +               max_v = cloog_int_to_isl_val(isl_set_get_ctx(cube), max);
904 +               cube = isl_set_lower_bound_val(cube, isl_dim_set, i, min_v);
905 +               cube = isl_set_upper_bound_val(cube, isl_dim_set, i, max_v);
906         }
907  
908         return cloog_domain_from_isl_set(cube);
909 @@ -1595,7 +1660,7 @@ static void Euclid(cloog_int_t a, cloog_int_t b,
910                 cloog_int_mul(tmp, tmp, d);
911                 cloog_int_sub(c, c, tmp);
912                 cloog_int_swap(c, d);
913 -           cloog_int_swap(e, f);
914 +               cloog_int_swap(e, f);
915         }
916         cloog_int_set(*g, c);
917         if (cloog_int_is_zero(a))
918 @@ -1631,49 +1696,70 @@ static void Euclid(cloog_int_t a, cloog_int_t b,
919  static CloogStride *construct_stride(isl_constraint *c, int level)
920  {
921         int i, n, sign;
922 -       isl_int v, m, gcd, stride, factor;
923 +       isl_val *v, *m, *gcd, *stride;
924 +       isl_val *v_copy, *m_copy, *gcd_copy;
925 +       cloog_int_t c_v, c_m, c_gcd, c_stride, c_factor;
926         CloogStride *s;
927 +       isl_ctx *ctx = isl_constraint_get_ctx(c);;
928  
929         if (!c)
930                 return NULL;
931  
932 -       isl_int_init(v);
933 -       isl_int_init(m);
934 -       isl_int_init(gcd);
935 -       isl_int_init(factor);
936 -       isl_int_init(stride);
937 +       v = isl_constraint_get_coefficient_val(c, isl_dim_set, level - 1);
938  
939 -       isl_constraint_get_coefficient(c, isl_dim_set, level - 1, &v);
940 -       sign = isl_int_sgn(v);
941 -       isl_int_abs(m, v);
942 +       sign = isl_val_sgn(v);
943 +       m = isl_val_abs(v); /* *takes* v. */
944  
945 -       isl_int_set_si(gcd, 0);
946 +       gcd = isl_val_int_from_si(ctx, 0);
947         n = isl_constraint_dim(c, isl_dim_div);
948         for (i = 0; i < n; ++i) {
949 -               isl_constraint_get_coefficient(c, isl_dim_div, i, &v);
950 -               isl_int_gcd(gcd, gcd, v);
951 +               v = isl_constraint_get_coefficient_val(c, isl_dim_div, i);
952 +               gcd = isl_val_gcd(gcd, v);
953         }
954  
955 -       isl_int_gcd(v, m, gcd);
956 -       isl_int_divexact(stride, gcd, v);
957 +       m_copy = isl_val_copy(m);
958 +       gcd_copy = isl_val_copy(gcd);
959  
960 -       if (isl_int_is_zero(stride) || isl_int_is_one(stride))
961 +       v = isl_val_gcd(m, gcd);
962 +
963 +       v_copy = isl_val_copy(v);
964 +       gcd = isl_val_copy(gcd_copy);
965 +       stride = isl_val_div(gcd, v);
966 +
967 +       if (isl_val_is_zero(stride) || isl_val_is_one(stride))
968                 s = NULL;
969         else {
970 -               Euclid(m, stride, &factor, &v, &gcd);
971 +               cloog_int_init(c_m);
972 +               cloog_int_init(c_stride);
973 +               cloog_int_init(c_v);
974 +               cloog_int_init(c_gcd);
975 +               cloog_int_init(c_factor);
976 +
977 +               isl_val_to_cloog_int(m_copy, &c_m);
978 +               isl_val_to_cloog_int(stride, &c_stride);
979 +               isl_val_to_cloog_int(v_copy, &c_v);
980 +               isl_val_to_cloog_int(gcd_copy, &c_gcd);
981 +
982 +               Euclid(c_m, c_stride, &c_factor, &c_v, &c_gcd);
983                 if (sign > 0)
984 -                       isl_int_neg(factor, factor);
985 +                       cloog_int_neg(c_factor, c_factor);
986  
987                 c = isl_constraint_copy(c);
988 -               s = cloog_stride_alloc_from_constraint(stride,
989 -                           cloog_constraint_from_isl_constraint(c), factor);
990 +               s = cloog_stride_alloc_from_constraint(c_stride,
991 +                                       cloog_constraint_from_isl_constraint(c), c_factor);
992 +
993 +
994 +               cloog_int_clear(c_m);
995 +               cloog_int_clear(c_stride);
996 +               cloog_int_clear(c_v);
997 +               cloog_int_clear(c_gcd);
998 +               cloog_int_clear(c_factor);
999         }
1000  
1001 -       isl_int_clear(stride);
1002 -       isl_int_clear(factor);
1003 -       isl_int_clear(gcd);
1004 -       isl_int_clear(m);
1005 -       isl_int_clear(v);
1006 +       isl_val_free(stride);
1007 +       isl_val_free(gcd_copy);
1008 +       isl_val_free(m_copy);
1009 +       isl_val_free(v_copy);
1010  
1011         return s;
1012  }
1013 @@ -1694,7 +1780,7 @@ static int find_stride(__isl_take isl_constraint *c, void *user)
1014  {
1015         struct cloog_isl_find_stride_data *data;
1016         int n;
1017 -       isl_int v;
1018 +       isl_val *v;
1019  
1020         if (!isl_constraint_is_equality(c)) {
1021                 isl_constraint_free(c);
1022 @@ -1714,13 +1800,11 @@ static int find_stride(__isl_take isl_constraint *c, void *user)
1023                 return 0;
1024         }
1025  
1026 -       isl_int_init(v);
1027 -
1028 -       isl_constraint_get_coefficient(c, isl_dim_set, data->level - 1, &v);
1029 -       if (!isl_int_is_zero(v))
1030 +       v = isl_constraint_get_coefficient_val(c, isl_dim_set, data->level - 1);
1031 +       if (!isl_val_is_zero(v))
1032                 data->stride = construct_stride(c, data->level);
1033  
1034 -       isl_int_clear(v);
1035 +       isl_val_free(v);
1036  
1037         isl_constraint_free(c);
1038  
1039 @@ -1769,7 +1853,7 @@ struct cloog_can_unroll {
1040         int level;
1041         isl_constraint *c;
1042         isl_set *set;
1043 -       isl_int *n;
1044 +       isl_val *n;
1045  };
1046  
1047  
1048 @@ -1782,11 +1866,11 @@ struct cloog_can_unroll {
1049   * with l the given lower bound and i the iterator identified by level.
1050   */
1051  static int is_valid_unrolling_lower_bound(struct cloog_can_unroll *ccu,
1052 -       __isl_keep isl_constraint *c, isl_int *v)
1053 +       __isl_keep isl_constraint *c, isl_val **v)
1054  {
1055         unsigned n_div;
1056         isl_aff *aff;
1057 -       enum isl_lp_result res;
1058 +       enum isl_lp_result;
1059  
1060         n_div = isl_constraint_dim(c, isl_dim_div);
1061         if (isl_constraint_involves_dims(c, isl_dim_div, 0, n_div))
1062 @@ -1796,15 +1880,19 @@ static int is_valid_unrolling_lower_bound(struct cloog_can_unroll *ccu,
1063         aff = isl_aff_ceil(aff);
1064         aff = isl_aff_neg(aff);
1065         aff = isl_aff_add_coefficient_si(aff, isl_dim_in, ccu->level - 1, 1);
1066 -       res = isl_set_max(ccu->set, aff, v);
1067 +       *v = isl_set_max_val(ccu->set, aff);
1068         isl_aff_free(aff);
1069  
1070 -       if (res == isl_lp_unbounded)
1071 -               return 0;
1072 +       if (!*v || isl_val_is_nan(*v))
1073 +               cloog_die("Fail to decide about unrolling (cannot find max)");
1074  
1075 -       assert(res == isl_lp_ok);
1076 +       if (isl_val_is_infty(*v) || isl_val_is_neginfty(*v)){
1077 +               isl_val_free(*v);
1078 +               *v = NULL;
1079 +               return 0;
1080 +       }
1081  
1082 -       cloog_int_add_ui(*v, *v, 1);
1083 +       *v = isl_val_add_ui(*v, 1);
1084  
1085         return 1;
1086  }
1087 @@ -1818,21 +1906,21 @@ static int is_valid_unrolling_lower_bound(struct cloog_can_unroll *ccu,
1088  static int constraint_can_unroll(__isl_take isl_constraint *c, void *user)
1089  {
1090         struct cloog_can_unroll *ccu = (struct cloog_can_unroll *)user;
1091 -       isl_int v;
1092 -       isl_int count;
1093 -
1094 -       isl_int_init(v);
1095 -       isl_int_init(count);
1096 -       isl_constraint_get_coefficient(c, isl_dim_set, ccu->level - 1, &v);
1097 -       if (isl_int_is_pos(v) &&
1098 -           is_valid_unrolling_lower_bound(ccu, c, &count) &&
1099 -           (!ccu->c || isl_int_lt(count, *ccu->n))) {
1100 +       isl_val *v;
1101 +       isl_val *count = NULL;
1102 +
1103 +       v = isl_constraint_get_coefficient_val(c, isl_dim_set, ccu->level - 1);
1104 +       if (isl_val_is_pos(v) &&
1105 +                       is_valid_unrolling_lower_bound(ccu, c, &count) &&
1106 +                       (!ccu->c || (isl_val_lt(count, ccu->n))) ) {
1107                 isl_constraint_free(ccu->c);
1108                 ccu->c = isl_constraint_copy(c);
1109 -               isl_int_set(*ccu->n, count);
1110 +               if (ccu->n)
1111 +                       isl_val_free(ccu->n);
1112 +               ccu->n = isl_val_copy(count);
1113         }
1114 -       isl_int_clear(count);
1115 -       isl_int_clear(v);
1116 +       isl_val_free(count);
1117 +       isl_val_free(v);
1118         isl_constraint_free(c);
1119  
1120         return 0;
1121 @@ -1872,7 +1960,8 @@ int cloog_domain_can_unroll(CloogDomain *domain, int level, cloog_int_t *n,
1122         CloogConstraint **lb)
1123  {
1124         isl_set *set = isl_set_from_cloog_domain(domain);
1125 -       struct cloog_can_unroll ccu = { 1, level, NULL, set, n };
1126 +       isl_val *v = cloog_int_to_isl_val(isl_set_get_ctx(set), *n);
1127 +       struct cloog_can_unroll ccu = { 1, level, NULL, set, v };
1128         int r;
1129  
1130         *lb = NULL;
1131 @@ -1887,6 +1976,11 @@ int cloog_domain_can_unroll(CloogDomain *domain, int level, cloog_int_t *n,
1132  
1133         *lb = cloog_constraint_from_isl_constraint(ccu.c);
1134  
1135 +       isl_val_to_cloog_int(ccu.n, n);
1136 +       /* Note: we have to free ccu.n and not v because v has been
1137 +        * freed and replaced in ccu during isl_set_foreach_basic_set
1138 +        */
1139 +       isl_val_free(ccu.n);
1140         return ccu.can_unroll;
1141  }
1142  
1143 @@ -1904,6 +1998,7 @@ CloogDomain *cloog_domain_fixed_offset(CloogDomain *domain,
1144  {
1145         isl_aff *aff;
1146         isl_set *set = isl_set_from_cloog_domain(domain);
1147 +       isl_ctx *ctx = isl_set_get_ctx(set);
1148         isl_constraint *c;
1149         isl_constraint *eq;
1150  
1151 @@ -1911,7 +2006,7 @@ CloogDomain *cloog_domain_fixed_offset(CloogDomain *domain,
1152         aff = isl_constraint_get_bound(c, isl_dim_set, level - 1);
1153         aff = isl_aff_ceil(aff);
1154         aff = isl_aff_add_coefficient_si(aff, isl_dim_in, level - 1, -1);
1155 -       aff = isl_aff_add_constant(aff, offset);
1156 +       aff = isl_aff_add_constant_val(aff, cloog_int_to_isl_val(ctx, offset));
1157         eq = isl_equality_from_aff(aff);
1158         set = isl_set_add_constraint(set, eq);
1159  
1160 -- 
1161 1.7.6.6.GIT
1162
This page took 0.198609 seconds and 3 git commands to generate.