Polly 23.0.0git
isl_test.c
Go to the documentation of this file.
1/*
2 * Copyright 2008-2009 Katholieke Universiteit Leuven
3 * Copyright 2010 INRIA Saclay
4 * Copyright 2012-2013 Ecole Normale Superieure
5 * Copyright 2014 INRIA Rocquencourt
6 * Copyright 2022 Cerebras Systems
7 *
8 * Use of this software is governed by the MIT license
9 *
10 * Written by Sven Verdoolaege, K.U.Leuven, Departement
11 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
12 * and INRIA Saclay - Ile-de-France, Parc Club Orsay Universite,
13 * ZAC des vignes, 4 rue Jacques Monod, 91893 Orsay, France
14 * and Ecole Normale Superieure, 45 rue d’Ulm, 75230 Paris, France
15 * and Inria Paris - Rocquencourt, Domaine de Voluceau - Rocquencourt,
16 * B.P. 105 - 78153 Le Chesnay, France
17 * and Cerebras Systems, 1237 E Arques Ave, Sunnyvale, CA, USA
18 */
19
20#include <assert.h>
21#include <stdio.h>
22#include <limits.h>
23#include <isl_ctx_private.h>
24#include <isl_map_private.h>
25#include <isl_aff_private.h>
26#include <isl_space_private.h>
27#include <isl/id.h>
28#include <isl/set.h>
29#include <isl/flow.h>
31#include <isl/polynomial.h>
32#include <isl/union_set.h>
33#include <isl/union_map.h>
34#include <isl_factorization.h>
35#include <isl/schedule.h>
36#include <isl/schedule_node.h>
37#include <isl_options_private.h>
39#include <isl/ast_build.h>
40#include <isl/val.h>
41#include <isl/ilp.h>
42#include <isl_ast_build_expr.h>
43#include <isl/options.h>
44
45#include "isl_srcdir.c"
46
47#define ARRAY_SIZE(array) (sizeof(array)/sizeof(*array))
48
49static char *get_filename(isl_ctx *ctx, const char *name, const char *suffix) {
50 char *filename;
51 int length;
52 char *pattern = "%s/test_inputs/%s.%s";
53
54 length = strlen(pattern) - 6 + strlen(srcdir) + strlen(name)
55 + strlen(suffix) + 1;
56 filename = isl_alloc_array(ctx, char, length);
57
58 if (!filename)
59 return NULL;
60
61 sprintf(filename, pattern, srcdir, name, suffix);
62
63 return filename;
64}
65
66void test_parse_map(isl_ctx *ctx, const char *str)
67{
68 isl_map *map;
69
71 assert(map);
73}
74
75int test_parse_map_equal(isl_ctx *ctx, const char *str, const char *str2)
76{
77 isl_map *map, *map2;
78 int equal;
79
81 map2 = isl_map_read_from_str(ctx, str2);
85
86 if (equal < 0)
87 return -1;
88 if (!equal)
89 isl_die(ctx, isl_error_unknown, "maps not equal",
90 return -1);
91
92 return 0;
93}
94
103
104static void test_parse_pwaff(isl_ctx *ctx, const char *str)
105{
106 isl_pw_aff *pwaff;
107
108 pwaff = isl_pw_aff_read_from_str(ctx, str);
109 assert(pwaff);
110 isl_pw_aff_free(pwaff);
111}
112
113/* Check that we can read an isl_multi_val from "str" without errors.
114 */
115static int test_parse_multi_val(isl_ctx *ctx, const char *str)
116{
117 isl_multi_val *mv;
118
120 isl_multi_val_free(mv);
121
122 return mv ? 0 : -1;
123}
124
125/* String descriptions of multi piecewise affine expressions
126 * that are used for testing printing and parsing.
127 */
128static const char *reparse_multi_pw_aff_tests[] = {
129 "{ A[x, y] -> [] : x + y >= 0 }",
130 "{ A[x, y] -> B[] : x + y >= 0 }",
131 "{ A[x, y] -> [x] : x + y >= 0 }",
132 "[N] -> { A[x, y] -> [x] : x + y <= N }",
133 "{ A[x, y] -> [x, y] : x + y >= 0 }",
134 "{ A[x, y] -> [(x : x >= 0), (y : y >= 0)] : x + y >= 0 }",
135 "[N] -> { [] : N >= 0 }",
136 "[N] -> { [] : N >= 0 }",
137 "[N] -> { [N] : N >= 0 }",
138 "[N] -> { [N, N + 1] : N >= 0 }",
139 "[N, M] -> { [(N : N >= 0), (M : M >= 0)] : N + M >= 0 }",
140 "{ [a] -> [b = a] }",
141 "{ [a] -> [b = a] : a >= 0 }",
142};
143
144#undef BASE
145#define BASE multi_pw_aff
146
147#include "check_reparse_templ.c"
149
150/* String descriptions that cannot be parsed
151 * as multi piecewise affine expressions.
152 */
153static const char *parse_multi_pw_aff_fail_tests[] = {
154 "{ [a] -> [b] : b = a }",
155 "{ [a] -> [b = a] : b >= 0 }",
156};
157
159
160/* String descriptions of piecewise multi affine expressions
161 * that are used for testing printing and parsing.
162 */
163static const char *reparse_pw_multi_aff_tests[] = {
164 "{ [x] -> [x] }",
165 "{ [x] -> [x % 4] }",
166 "{ [x] -> [x % 4] : x mod 3 = 1 }",
167 "{ [x, x] -> [x % 4] }",
168 "{ [x, x + 1] -> [x % 4] : x mod 3 = 1 }",
169 "{ [x, x mod 2] -> [x % 4] }",
170 "{ [a] -> [a//2] : exists (e0: 8*floor((-a + e0)/8) <= -8 - a + 8e0) }",
171 "{ [a, b] -> [(2*floor((a)/8) + floor((b)/6))] }",
172 "{ [] : false }",
173 "{ A[*,*] -> B[0,0] : false }",
174};
175
176#undef BASE
177#define BASE pw_multi_aff
178
179#include "check_reparse_templ.c"
181
182/* Test parsing of piecewise multi affine expressions by printing
183 * the expressions and checking that parsing the output results
184 * in the same expression.
185 * Do this for an expression converted from a map with an output
186 * dimension name that is equal to an automatically generated name, and
187 * a set of expressions parsed from strings.
188 */
190{
191 isl_map *map;
193
194 map = isl_map_read_from_str(ctx, "{ [a, a] -> [i1 = a + 1] }");
196 if (check_reparse_pw_multi_aff(ctx, pma) < 0)
197 return isl_stat_error;
198
199 if (check_reparse_pw_multi_aff_tests(ctx) < 0)
200 return isl_stat_error;
201
202 return isl_stat_ok;
203}
204
205/* String descriptions that cannot be parsed
206 * as union piecewise multi affine expressions.
207 */
209 "{ [a] -> [b] : b = a }",
210 "{ [a] -> [b = a] : b >= 0 }",
211};
212
213#undef BASE
214#define BASE union_pw_multi_aff
215
217
218/* Test parsing of union piecewise multi affine expressions.
219 *
220 * In particular, check some cases where parsing is supposed to fail.
221 */
223{
224 if (check_parse_union_pw_multi_aff_fail_tests(ctx) < 0)
225 return isl_stat_error;
226
227 return isl_stat_ok;
228}
229
230/* Test parsing of multi piecewise affine expressions by printing
231 * the expressions and checking that parsing the output results
232 * in the same expression.
233 * Do this for a couple of manually constructed expressions,
234 * an expression converted from a map with an output dimension name
235 * that is equal to an automatically generated name, and
236 * a set of expressions parsed from strings.
237 *
238 * Additionally, check some cases where parsing is supposed to fail.
239 */
240static int test_parse_mpa(isl_ctx *ctx)
241{
242 isl_space *space;
243 isl_set *dom;
244 isl_map *map;
246 isl_multi_pw_aff *mpa;
247 isl_stat r;
248
249 space = isl_space_set_alloc(ctx, 0, 0);
250 space = isl_space_set_tuple_name(space, isl_dim_set, "A");
251 mpa = isl_multi_pw_aff_zero(space);
252 r = check_reparse_multi_pw_aff(ctx, mpa);
253 if (r < 0)
254 return -1;
255
256 space = isl_space_set_alloc(ctx, 1, 0);
257 space = isl_space_set_dim_name(space, isl_dim_param, 0, "N");
258 space = isl_space_set_tuple_name(space, isl_dim_set, "A");
260 dom = isl_set_lower_bound_si(dom, isl_dim_param, 0, 5);
261 mpa = isl_multi_pw_aff_zero(space);
262 mpa = isl_multi_pw_aff_intersect_domain(mpa, dom);
263 r = check_reparse_multi_pw_aff(ctx, mpa);
264 if (r < 0)
265 return -1;
266
267 map = isl_map_read_from_str(ctx, "{ [a, a] -> [i1 = a + 1] }");
270 if (check_reparse_multi_pw_aff(ctx, mpa) < 0)
271 return -1;
272
273 if (check_reparse_multi_pw_aff_tests(ctx) < 0)
274 return -1;
275 if (check_parse_multi_pw_aff_fail_tests(ctx) < 0)
276 return -1;
277
278 return 0;
279}
280
281/* String descriptions of multi union piecewise affine expressions
282 * that are used for testing printing and parsing.
283 */
284static const char *reparse_multi_union_pw_aff_tests[] = {
285 "[]",
286 "A[]",
287 "A[B[] -> C[]]",
288 "(A[] : { S[x] : x > 0; T[y] : y >= 0 })",
289 "(A[] : { })",
290 "[N] -> (A[] : { })",
291 "[N] -> (A[] : { : N >= 0 })",
292 "[N] -> (A[] : { S[x] : x > N; T[y] : y >= 0 })",
293 "(A[] : [N] -> { S[x] : x > N; T[y] : y >= 0 })",
294 "A[{ S[x] -> [x + 1]; T[x] -> [x] }]",
295 "(A[{ S[x] -> [x + 1]; T[x] -> [x] }] : "
296 "{ S[x] : x > 0; T[y] : y >= 0 })",
297 "A[{ }]",
298 "A[{ }, { S[x] -> [x + 1]; T[x] -> [x] }]",
299};
300
301#undef BASE
302#define BASE multi_union_pw_aff
303
304#include "check_reparse_templ.c"
306
307/* Test parsing of multi union piecewise affine expressions by printing
308 * the expressions and checking that parsing the output results
309 * in the same expression.
310 * Do this for a couple of manually constructed expressions and
311 * a set of expressions parsed from strings.
312 */
313static int test_parse_mupa(isl_ctx *ctx)
314{
315 isl_space *space;
317 isl_set *dom;
318 isl_union_set *uset;
319 isl_stat r;
320
321 space = isl_space_set_alloc(ctx, 0, 0);
322 space = isl_space_set_tuple_name(space, isl_dim_set, "A");
324 r = check_reparse_multi_union_pw_aff(ctx, mupa);
325 if (r < 0)
326 return -1;
327
328 space = isl_space_set_alloc(ctx, 1, 0);
329 space = isl_space_set_dim_name(space, isl_dim_param, 0, "N");
330 space = isl_space_set_tuple_name(space, isl_dim_set, "A");
331 dom = isl_set_universe(space);
332 dom = isl_set_lower_bound_si(dom, isl_dim_param, 0, 5);
333 uset = isl_union_set_from_set(dom);
334 space = isl_space_set_alloc(ctx, 1, 0);
335 space = isl_space_set_dim_name(space, isl_dim_param, 0, "N");
336 space = isl_space_set_tuple_name(space, isl_dim_set, "B");
339 r = check_reparse_multi_union_pw_aff(ctx, mupa);
340 if (r < 0)
341 return -1;
342
343 if (check_reparse_multi_union_pw_aff_tests(ctx) < 0)
344 return -1;
345
346 return 0;
347}
348
349/* Test parsing of multi expressions.
350 */
351static int test_parse_multi(isl_ctx *ctx)
352{
353 if (test_parse_mpa(ctx) < 0)
354 return -1;
355 if (test_parse_mupa(ctx) < 0)
356 return -1;
357
358 return 0;
359}
360
361/* Pairs of binary relation representations that should represent
362 * the same binary relations.
363 */
364struct {
365 const char *map1;
366 const char *map2;
368 { "{ [x,y] : [([x/2]+y)/3] >= 1 }",
369 "{ [x, y] : 2y >= 6 - x }" },
370 { "{ [x,y] : x <= min(y, 2*y+3) }",
371 "{ [x,y] : x <= y, 2*y + 3 }" },
372 { "{ [x,y] : x >= min(y, 2*y+3) }",
373 "{ [x, y] : (y <= x and y >= -3) or (2y <= -3 + x and y <= -4) }" },
374 { "[n] -> { [c1] : c1>=0 and c1<=floord(n-4,3) }",
375 "[n] -> { [c1] : c1 >= 0 and 3c1 <= -4 + n }" },
376 { "{ [i,j] -> [i] : i < j; [i,j] -> [j] : j <= i }",
377 "{ [i,j] -> [min(i,j)] }" },
378 { "{ [i,j] : i != j }",
379 "{ [i,j] : i < j or i > j }" },
380 { "{ [i,j] : (i+1)*2 >= j }",
381 "{ [i, j] : j <= 2 + 2i }" },
382 { "{ [i] -> [i > 0 ? 4 : 5] }",
383 "{ [i] -> [5] : i <= 0; [i] -> [4] : i >= 1 }" },
384 { "[N=2,M] -> { [i=[(M+N)/4]] }",
385 "[N, M] -> { [i] : N = 2 and 4i <= 2 + M and 4i >= -1 + M }" },
386 { "{ [x] : x >= 0 }",
387 "{ [x] : x-0 >= 0 }" },
388 { "{ [i] : ((i > 10)) }",
389 "{ [i] : i >= 11 }" },
390 { "{ [i] -> [0] }",
391 "{ [i] -> [0 * i] }" },
392 { "{ [a] -> [b] : (not false) }",
393 "{ [a] -> [b] : true }" },
394 { "{ [i] : i/2 <= 5 }",
395 "{ [i] : i <= 10 }" },
396 { "{Sym=[n] [i] : i <= n }",
397 "[n] -> { [i] : i <= n }" },
398 { "{ [*] }",
399 "{ [a] }" },
400 { "{ [i] : 2*floor(i/2) = i }",
401 "{ [i] : exists a : i = 2 a }" },
402 { "{ [a] -> [b] : a = 5 implies b = 5 }",
403 "{ [a] -> [b] : a != 5 or b = 5 }" },
404 { "{ [a] -> [a - 1 : a > 0] }",
405 "{ [a] -> [a - 1] : a > 0 }" },
406 { "{ [a] -> [a - 1 : a > 0; a : a <= 0] }",
407 "{ [a] -> [a - 1] : a > 0; [a] -> [a] : a <= 0 }" },
408 { "{ [a] -> [(a) * 2 : a >= 0; 0 : a < 0] }",
409 "{ [a] -> [2a] : a >= 0; [a] -> [0] : a < 0 }" },
410 { "{ [a] -> [(a * 2) : a >= 0; 0 : a < 0] }",
411 "{ [a] -> [2a] : a >= 0; [a] -> [0] : a < 0 }" },
412 { "{ [a] -> [(a * 2 : a >= 0); 0 : a < 0] }",
413 "{ [a] -> [2a] : a >= 0; [a] -> [0] : a < 0 }" },
414 { "{ [a] -> [(a * 2 : a >= 0; 0 : a < 0)] }",
415 "{ [a] -> [2a] : a >= 0; [a] -> [0] : a < 0 }" },
416 { "{ [a,b] -> [i,j] : a,b << i,j }",
417 "{ [a,b] -> [i,j] : a < i or (a = i and b < j) }" },
418 { "{ [a,b] -> [i,j] : a,b <<= i,j }",
419 "{ [a,b] -> [i,j] : a < i or (a = i and b <= j) }" },
420 { "{ [a,b] -> [i,j] : a,b >> i,j }",
421 "{ [a,b] -> [i,j] : a > i or (a = i and b > j) }" },
422 { "{ [a,b] -> [i,j] : a,b >>= i,j }",
423 "{ [a,b] -> [i,j] : a > i or (a = i and b >= j) }" },
424 { "{ [n] -> [i] : exists (a, b, c: 8b <= i - 32a and "
425 "8b >= -7 + i - 32 a and b >= 0 and b <= 3 and "
426 "8c < n - 32a and i < n and c >= 0 and "
427 "c <= 3 and c >= -4a) }",
428 "{ [n] -> [i] : 0 <= i < n }" },
429 { "{ [x] -> [] : exists (a, b: 0 <= a <= 1 and 0 <= b <= 3 and "
430 "2b <= x - 8a and 2b >= -1 + x - 8a) }",
431 "{ [x] -> [] : 0 <= x <= 15 }" },
432 { "{ [x] -> [x] : }",
433 "{ [x] -> [x] }" },
434 { "{ [x=4:5] -> [x + 1] }",
435 "{ [x] -> [x + 1] : 4 <= x <= 5 }" },
436 { "{ [x=4:5] -> [x + 1 : x + 1] }",
437 "{ [x=4:5] -> [x + 1] }" },
438 { "{ [x] -> [x - 1 : x + 1] }",
439 "{ [x] -> [y] : x - 1 <= y <= x + 1 }" },
440 { "{ [x=4:] -> [x + 1] }",
441 "{ [x] -> [x + 1] : 4 <= x }" },
442 { "{ [x=:5] -> [x + 1] }",
443 "{ [x] -> [x + 1] : x <= 5 }" },
444 { "{ [x=:] -> [x + 1] }",
445 "{ [x] -> [x + 1] }" },
446 { "{ [:] -> [:] }",
447 "{ [x] -> [y] }" },
448 { "{ [x, x//4] }",
449 "{ [x, floor(x/4)] }" },
450 { "{ [10//4] }",
451 "{ [2] }" },
452 { "{ [-1//4] }",
453 "{ [-1] }" },
454 { "{ [0-1//4] }",
455 "{ [0] }" },
456 { "{ [- 1//4] }",
457 "{ [-1] }" },
458 { "{ [0 - 1//4] }",
459 "{ [0] }" },
460 { "{ [0--1//4] }",
461 "{ [1] }" },
462 { "{ [0 - -1//4] }",
463 "{ [1] }" },
464 { "{ [-2^2:2^2-1] }",
465 "{ [-4:3] }" },
466 { "{ [2*-2] }",
467 "{ [-4] }" },
468 { "{ [i,i*-2] }",
469 "{ [i,-2i] }" },
470 { "{ [a = 0:3, b = 0:15, c = 0:15, d] : "
471 "256*floor((-1 - (256a + 16b + c))/256) >= d }",
472 "{ [a = 0:3, b = 0:15, c = 0:15, d] : 256a <= -256 - d }" },
473 { "[a, b, c, d] -> { [max(a,b,c,d)] }",
474 "[a, b, c, d] -> { [a] : b < a and c < a and d < a; "
475 "[b] : b >= a and c < b and d < b; "
476 "[c] : c >= a and c >= b and d < c; "
477 "[d] : d >= a and d >= b and d >= c }" },
478 { "[a, b, c, d] -> { [min(a,b,c,d)] }",
479 "[a, b, c, d] -> { [a] : b >= a and c >= a and d >= a; "
480 "[b] : b < a and c >= b and d >= b; "
481 "[c] : c < b and c < a and d >= c; "
482 "[d] : d < c and d < b and d < a }" },
484
485int test_parse(struct isl_ctx *ctx)
486{
487 int i;
488 isl_map *map, *map2;
489 const char *str, *str2;
490
491 if (test_parse_multi_val(ctx, "{ A[B[2] -> C[5, 7]] }") < 0)
492 return -1;
493 if (test_parse_multi_val(ctx, "[n] -> { [2] }") < 0)
494 return -1;
495 if (test_parse_multi_val(ctx, "{ A[4, infty, NaN, -1/2, 2/3] }") < 0)
496 return -1;
497 if (test_parse_multi(ctx) < 0)
498 return -1;
499 if (test_parse_pma(ctx) < 0)
500 return -1;
501 if (test_parse_upma(ctx) < 0)
502 return -1;
503
504 str = "{ [i] -> [-i] }";
506 assert(map);
508
509 str = "{ A[i] -> L[([i/3])] }";
511 assert(map);
513
514 test_parse_map(ctx, "{[[s] -> A[i]] -> [[s+1] -> A[i]]}");
515 test_parse_map(ctx, "{ [p1, y1, y2] -> [2, y1, y2] : "
516 "p1 = 1 && (y1 <= y2 || y2 = 0) }");
517
518 for (i = 0; i < ARRAY_SIZE(parse_map_equal_tests); ++i) {
519 str = parse_map_equal_tests[i].map1;
520 str2 = parse_map_equal_tests[i].map2;
521 if (test_parse_map_equal(ctx, str, str2) < 0)
522 return -1;
523 }
524
525 str = "{[new,old] -> [new+1-2*[(new+1)/2],old+1-2*[(old+1)/2]]}";
527 str = "{ [new, old] -> [o0, o1] : "
528 "exists (e0 = [(-1 - new + o0)/2], e1 = [(-1 - old + o1)/2]: "
529 "2e0 = -1 - new + o0 and 2e1 = -1 - old + o1 and o0 >= 0 and "
530 "o0 <= 1 and o1 >= 0 and o1 <= 1) }";
535
536 str = "{[new,old] -> [new+1-2*[(new+1)/2],old+1-2*[(old+1)/2]]}";
538 str = "{[new,old] -> [(new+1)%2,(old+1)%2]}";
543
544 test_parse_pwqp(ctx, "{ [i] -> i + [ (i + [i/3])/2 ] }");
545 test_parse_map(ctx, "{ S1[i] -> [([i/10]),i%10] : 0 <= i <= 45 }");
546 test_parse_pwaff(ctx, "{ [i] -> [i + 1] : i > 0; [a] -> [a] : a < 0 }");
547 test_parse_pwqp(ctx, "{ [x] -> ([(x)/2] * [(x)/3]) }");
548 test_parse_pwaff(ctx, "{ [] -> [(100)] }");
549
550 return 0;
551}
552
553static int test_read(isl_ctx *ctx)
554{
555 char *filename;
556 FILE *input;
557 isl_basic_set *bset1, *bset2;
558 const char *str = "{[y]: Exists ( alpha : 2alpha = y)}";
559 int equal;
560
561 filename = get_filename(ctx, "set", "omega");
562 assert(filename);
563 input = fopen(filename, "r");
564 assert(input);
565
566 bset1 = isl_basic_set_read_from_file(ctx, input);
567 bset2 = isl_basic_set_read_from_str(ctx, str);
568
569 equal = isl_basic_set_is_equal(bset1, bset2);
570
571 isl_basic_set_free(bset1);
572 isl_basic_set_free(bset2);
573 free(filename);
574
575 fclose(input);
576
577 if (equal < 0)
578 return -1;
579 if (!equal)
581 "read sets not equal", return -1);
582
583 return 0;
584}
585
586static int test_bounded(isl_ctx *ctx)
587{
588 isl_set *set;
589 isl_bool bounded;
590
591 set = isl_set_read_from_str(ctx, "[n] -> {[i] : 0 <= i <= n }");
592 bounded = isl_set_is_bounded(set);
594
595 if (bounded < 0)
596 return -1;
597 if (!bounded)
599 "set not considered bounded", return -1);
600
601 set = isl_set_read_from_str(ctx, "{[n, i] : 0 <= i <= n }");
602 bounded = isl_set_is_bounded(set);
603 assert(!bounded);
605
606 if (bounded < 0)
607 return -1;
608 if (bounded)
610 "set considered bounded", return -1);
611
612 set = isl_set_read_from_str(ctx, "[n] -> {[i] : i <= n }");
613 bounded = isl_set_is_bounded(set);
615
616 if (bounded < 0)
617 return -1;
618 if (bounded)
620 "set considered bounded", return -1);
621
622 return 0;
623}
624
625/* Construct the basic set { [i] : 5 <= i <= N } */
627{
628 isl_space *space;
629 isl_local_space *ls;
630 isl_basic_set *bset;
632
633 space = isl_space_set_alloc(ctx, 1, 1);
635 ls = isl_local_space_from_space(space);
636
640 bset = isl_basic_set_add_constraint(bset, c);
641
645 bset = isl_basic_set_add_constraint(bset, c);
646
648 isl_basic_set_free(bset);
649
650 return 0;
651}
652
653/* Construct the basic set { [x] : -100 <= x <= 100 }
654 * using isl_basic_set_{lower,upper}_bound_val and
655 * check that it is equal the same basic set parsed from a string.
656 */
658{
660 isl_val *v;
661 isl_space *space;
662 isl_basic_set *bset1, *bset2;
663
664 v = isl_val_int_from_si(ctx, 100);
665 space = isl_space_set_alloc(ctx, 0, 1);
666 bset1 = isl_basic_set_universe(space);
668 isl_val_copy(v));
670 isl_val_neg(v));
671 bset2 = isl_basic_set_read_from_str(ctx, "{ [x] : -100 <= x <= 100 }");
672 equal = isl_basic_set_is_equal(bset1, bset2);
673 isl_basic_set_free(bset1);
674 isl_basic_set_free(bset2);
675
676 if (equal < 0)
677 return -1;
678 if (!equal)
680 "failed construction", return -1);
681
682 return 0;
683}
684
685/* Basic tests for constructing basic sets.
686 */
688{
689 if (test_construction_1(ctx) < 0)
690 return -1;
691 if (test_construction_2(ctx) < 0)
692 return -1;
693 return 0;
694}
695
696static int test_dim(isl_ctx *ctx)
697{
698 const char *str;
699 isl_map *map1, *map2;
700 int equal;
701
703 "[n] -> { [i] -> [j] : exists (a = [i/10] : i - 10a <= n ) }");
706 "[n] -> { [i,k] -> [j] : exists (a = [i/10] : i - 10a <= n ) }");
709
711 map2 = isl_map_read_from_str(ctx, "[n] -> { [i] -> [j] : n >= 0 }");
712 if (equal >= 0 && equal)
714
717
718 if (equal < 0)
719 return -1;
720 if (!equal)
722 "unexpected result", return -1);
723
724 str = "[n] -> { [i] -> [] : exists a : 0 <= i <= n and i = 2 a }";
726 str = "{ [i] -> [j] : exists a : 0 <= i <= j and i = 2 a }";
732
733 if (equal < 0)
734 return -1;
735 if (!equal)
737 "unexpected result", return -1);
738
739 return 0;
740}
741
742#undef BASE
743#define BASE multi_val
745
746#undef BASE
747#define BASE multi_aff
749
750/* Check that "val" is equal to the value described by "str".
751 * If "str" is "NaN", then check for a NaN value explicitly.
752 */
754{
755 isl_bool ok, is_nan;
756 isl_ctx *ctx;
757 isl_val *res;
758
759 if (!val)
760 return isl_stat_error;
761
762 ctx = isl_val_get_ctx(val);
764 is_nan = isl_val_is_nan(res);
765 if (is_nan < 0)
766 ok = isl_bool_error;
767 else if (is_nan)
768 ok = isl_val_is_nan(val);
769 else
770 ok = isl_val_eq(val, res);
772 if (ok < 0)
773 return isl_stat_error;
774 if (!ok)
776 "unexpected result", return isl_stat_error);
777 return isl_stat_ok;
778}
779
780struct {
782 const char *arg;
783 const char *res;
784} val_un_tests[] = {
785 { &isl_val_neg, "0", "0" },
786 { &isl_val_abs, "0", "0" },
787 { &isl_val_pow2, "0", "1" },
788 { &isl_val_floor, "0", "0" },
789 { &isl_val_ceil, "0", "0" },
790 { &isl_val_neg, "1", "-1" },
791 { &isl_val_neg, "-1", "1" },
792 { &isl_val_neg, "1/2", "-1/2" },
793 { &isl_val_neg, "-1/2", "1/2" },
794 { &isl_val_neg, "infty", "-infty" },
795 { &isl_val_neg, "-infty", "infty" },
796 { &isl_val_neg, "NaN", "NaN" },
797 { &isl_val_abs, "1", "1" },
798 { &isl_val_abs, "-1", "1" },
799 { &isl_val_abs, "1/2", "1/2" },
800 { &isl_val_abs, "-1/2", "1/2" },
801 { &isl_val_abs, "infty", "infty" },
802 { &isl_val_abs, "-infty", "infty" },
803 { &isl_val_abs, "NaN", "NaN" },
804 { &isl_val_floor, "1", "1" },
805 { &isl_val_floor, "-1", "-1" },
806 { &isl_val_floor, "1/2", "0" },
807 { &isl_val_floor, "-1/2", "-1" },
808 { &isl_val_floor, "infty", "infty" },
809 { &isl_val_floor, "-infty", "-infty" },
810 { &isl_val_floor, "NaN", "NaN" },
811 { &isl_val_ceil, "1", "1" },
812 { &isl_val_ceil, "-1", "-1" },
813 { &isl_val_ceil, "1/2", "1" },
814 { &isl_val_ceil, "-1/2", "0" },
815 { &isl_val_ceil, "infty", "infty" },
816 { &isl_val_ceil, "-infty", "-infty" },
817 { &isl_val_ceil, "NaN", "NaN" },
818 { &isl_val_pow2, "-3", "1/8" },
819 { &isl_val_pow2, "-1", "1/2" },
820 { &isl_val_pow2, "1", "2" },
821 { &isl_val_pow2, "2", "4" },
822 { &isl_val_pow2, "3", "8" },
823 { &isl_val_inv, "1", "1" },
824 { &isl_val_inv, "2", "1/2" },
825 { &isl_val_inv, "1/2", "2" },
826 { &isl_val_inv, "-2", "-1/2" },
827 { &isl_val_inv, "-1/2", "-2" },
828 { &isl_val_inv, "0", "NaN" },
829 { &isl_val_inv, "NaN", "NaN" },
830 { &isl_val_inv, "infty", "0" },
831 { &isl_val_inv, "-infty", "0" },
833
834/* Perform some basic tests of unary operations on isl_val objects.
835 */
836static int test_un_val(isl_ctx *ctx)
837{
838 int i;
839 isl_val *v;
841
842 for (i = 0; i < ARRAY_SIZE(val_un_tests); ++i) {
843 isl_stat r;
844
846 fn = val_un_tests[i].op;
847 v = fn(v);
849 isl_val_free(v);
850 if (r < 0)
851 return -1;
852 }
853
854 return 0;
855}
856
857struct {
859 __isl_take isl_val *v2);
860} val_bin_op[] = {
861 ['+'] = { &isl_val_add },
862 ['-'] = { &isl_val_sub },
863 ['*'] = { &isl_val_mul },
864 ['/'] = { &isl_val_div },
865 ['g'] = { &isl_val_gcd },
866 ['m'] = { &isl_val_min },
867 ['M'] = { &isl_val_max },
869
870struct {
871 const char *arg1;
872 unsigned char op;
873 const char *arg2;
874 const char *res;
875} val_bin_tests[] = {
876 { "0", '+', "0", "0" },
877 { "1", '+', "0", "1" },
878 { "1", '+', "1", "2" },
879 { "1", '-', "1", "0" },
880 { "1", '*', "1", "1" },
881 { "1", '/', "1", "1" },
882 { "2", '*', "3", "6" },
883 { "2", '*', "1/2", "1" },
884 { "2", '*', "1/3", "2/3" },
885 { "2/3", '*', "3/5", "2/5" },
886 { "2/3", '*', "7/5", "14/15" },
887 { "2", '/', "1/2", "4" },
888 { "-2", '/', "-1/2", "4" },
889 { "-2", '/', "1/2", "-4" },
890 { "2", '/', "-1/2", "-4" },
891 { "2", '/', "2", "1" },
892 { "2", '/', "3", "2/3" },
893 { "2/3", '/', "5/3", "2/5" },
894 { "2/3", '/', "5/7", "14/15" },
895 { "0", '/', "0", "NaN" },
896 { "42", '/', "0", "NaN" },
897 { "-42", '/', "0", "NaN" },
898 { "infty", '/', "0", "NaN" },
899 { "-infty", '/', "0", "NaN" },
900 { "NaN", '/', "0", "NaN" },
901 { "0", '/', "NaN", "NaN" },
902 { "42", '/', "NaN", "NaN" },
903 { "-42", '/', "NaN", "NaN" },
904 { "infty", '/', "NaN", "NaN" },
905 { "-infty", '/', "NaN", "NaN" },
906 { "NaN", '/', "NaN", "NaN" },
907 { "0", '/', "infty", "0" },
908 { "42", '/', "infty", "0" },
909 { "-42", '/', "infty", "0" },
910 { "infty", '/', "infty", "NaN" },
911 { "-infty", '/', "infty", "NaN" },
912 { "NaN", '/', "infty", "NaN" },
913 { "0", '/', "-infty", "0" },
914 { "42", '/', "-infty", "0" },
915 { "-42", '/', "-infty", "0" },
916 { "infty", '/', "-infty", "NaN" },
917 { "-infty", '/', "-infty", "NaN" },
918 { "NaN", '/', "-infty", "NaN" },
919 { "1", '-', "1/3", "2/3" },
920 { "1/3", '+', "1/2", "5/6" },
921 { "1/2", '+', "1/2", "1" },
922 { "3/4", '-', "1/4", "1/2" },
923 { "1/2", '-', "1/3", "1/6" },
924 { "infty", '+', "42", "infty" },
925 { "infty", '+', "infty", "infty" },
926 { "42", '+', "infty", "infty" },
927 { "infty", '-', "infty", "NaN" },
928 { "infty", '*', "infty", "infty" },
929 { "infty", '*', "-infty", "-infty" },
930 { "-infty", '*', "infty", "-infty" },
931 { "-infty", '*', "-infty", "infty" },
932 { "0", '*', "infty", "NaN" },
933 { "1", '*', "infty", "infty" },
934 { "infty", '*', "0", "NaN" },
935 { "infty", '*', "42", "infty" },
936 { "42", '-', "infty", "-infty" },
937 { "infty", '+', "-infty", "NaN" },
938 { "4", 'g', "6", "2" },
939 { "5", 'g', "6", "1" },
940 { "42", 'm', "3", "3" },
941 { "42", 'M', "3", "42" },
942 { "3", 'm', "42", "3" },
943 { "3", 'M', "42", "42" },
944 { "42", 'm', "infty", "42" },
945 { "42", 'M', "infty", "infty" },
946 { "42", 'm', "-infty", "-infty" },
947 { "42", 'M', "-infty", "42" },
948 { "42", 'm', "NaN", "NaN" },
949 { "42", 'M', "NaN", "NaN" },
950 { "infty", 'm', "-infty", "-infty" },
951 { "infty", 'M', "-infty", "infty" },
953
954/* Perform some basic tests of binary operations on isl_val objects.
955 */
956static int test_bin_val(isl_ctx *ctx)
957{
958 int i;
959 isl_val *v1, *v2, *res;
961 __isl_take isl_val *v2);
962 int ok;
963
964 for (i = 0; i < ARRAY_SIZE(val_bin_tests); ++i) {
968 fn = val_bin_op[val_bin_tests[i].op].fn;
969 v1 = fn(v1, v2);
970 if (isl_val_is_nan(res))
971 ok = isl_val_is_nan(v1);
972 else
973 ok = isl_val_eq(v1, res);
974 isl_val_free(v1);
976 if (ok < 0)
977 return -1;
978 if (!ok)
980 "unexpected result", return -1);
981 }
982
983 return 0;
984}
985
986/* Perform some basic tests on isl_val objects.
987 */
988static int test_val(isl_ctx *ctx)
989{
990 if (test_un_val(ctx) < 0)
991 return -1;
992 if (test_bin_val(ctx) < 0)
993 return -1;
994 return 0;
995}
996
997/* Sets described using existentially quantified variables that
998 * can also be described without.
999 */
1000static const char *elimination_tests[] = {
1001 "{ [i,j] : 2 * [i/2] + 3 * [j/4] <= 10 and 2 i = j }",
1002 "{ [m, w] : exists a : w - 2m - 5 <= 3a <= m - 2w }",
1003 "{ [m, w] : exists a : w >= 0 and a < m and -1 + w <= a <= 2m - w }",
1004};
1005
1006/* Check that redundant existentially quantified variables are
1007 * getting removed.
1008 */
1010{
1011 int i;
1012 isl_size n;
1013 isl_basic_set *bset;
1014
1015 for (i = 0; i < ARRAY_SIZE(elimination_tests); ++i) {
1018 isl_basic_set_free(bset);
1019 if (n < 0)
1020 return -1;
1021 if (n != 0)
1023 "expecting no existentials", return -1);
1024 }
1025
1026 return 0;
1027}
1028
1029static int test_div(isl_ctx *ctx)
1030{
1031 const char *str;
1032 int empty;
1033 isl_space *space;
1034 isl_set *set;
1035 isl_local_space *ls;
1036 struct isl_basic_set *bset;
1037 struct isl_constraint *c;
1038
1039 /* test 1 */
1040 space = isl_space_set_alloc(ctx, 0, 3);
1043
1048 bset = isl_basic_set_add_constraint(bset, c);
1049
1054 bset = isl_basic_set_add_constraint(bset, c);
1055
1056 bset = isl_basic_set_project_out(bset, isl_dim_set, 1, 2);
1057
1058 assert(bset && bset->n_div == 1);
1060 isl_basic_set_free(bset);
1061
1062 /* test 2 */
1063 space = isl_space_set_alloc(ctx, 0, 3);
1066
1071 bset = isl_basic_set_add_constraint(bset, c);
1072
1077 bset = isl_basic_set_add_constraint(bset, c);
1078
1079 bset = isl_basic_set_project_out(bset, isl_dim_set, 1, 2);
1080
1081 assert(bset && bset->n_div == 1);
1083 isl_basic_set_free(bset);
1084
1085 /* test 3 */
1086 space = isl_space_set_alloc(ctx, 0, 3);
1089
1094 bset = isl_basic_set_add_constraint(bset, c);
1095
1100 bset = isl_basic_set_add_constraint(bset, c);
1101
1102 bset = isl_basic_set_project_out(bset, isl_dim_set, 1, 2);
1103
1104 assert(bset && bset->n_div == 1);
1106 isl_basic_set_free(bset);
1107
1108 /* test 4 */
1109 space = isl_space_set_alloc(ctx, 0, 3);
1112
1117 bset = isl_basic_set_add_constraint(bset, c);
1118
1123 bset = isl_basic_set_add_constraint(bset, c);
1124
1125 bset = isl_basic_set_project_out(bset, isl_dim_set, 1, 2);
1126
1129 isl_basic_set_free(bset);
1130
1131 /* test 5 */
1132 space = isl_space_set_alloc(ctx, 0, 3);
1135
1139 bset = isl_basic_set_add_constraint(bset, c);
1140
1144 bset = isl_basic_set_add_constraint(bset, c);
1145
1146 bset = isl_basic_set_project_out(bset, isl_dim_set, 2, 1);
1147
1148 assert(bset && bset->n_div == 0);
1149 isl_basic_set_free(bset);
1151
1152 /* test 6 */
1153 space = isl_space_set_alloc(ctx, 0, 3);
1156
1160 bset = isl_basic_set_add_constraint(bset, c);
1161
1165 bset = isl_basic_set_add_constraint(bset, c);
1166
1167 bset = isl_basic_set_project_out(bset, isl_dim_set, 2, 1);
1168
1169 assert(bset && bset->n_div == 1);
1170 isl_basic_set_free(bset);
1172
1173 /* test 7 */
1174 /* This test is a bit tricky. We set up an equality
1175 * a + 3b + 3c = 6 e0
1176 * Normalization of divs creates _two_ divs
1177 * a = 3 e0
1178 * c - b - e0 = 2 e1
1179 * Afterwards e0 is removed again because it has coefficient -1
1180 * and we end up with the original equality and div again.
1181 * Perhaps we can avoid the introduction of this temporary div.
1182 */
1183 space = isl_space_set_alloc(ctx, 0, 4);
1186
1192 bset = isl_basic_set_add_constraint(bset, c);
1193
1194 bset = isl_basic_set_project_out(bset, isl_dim_set, 3, 1);
1195
1196 /* Test disabled for now */
1197 /*
1198 assert(bset && bset->n_div == 1);
1199 */
1201 isl_basic_set_free(bset);
1202
1203 /* test 8 */
1204 space = isl_space_set_alloc(ctx, 0, 5);
1207
1213 bset = isl_basic_set_add_constraint(bset, c);
1214
1219 bset = isl_basic_set_add_constraint(bset, c);
1220
1221 bset = isl_basic_set_project_out(bset, isl_dim_set, 4, 1);
1222
1223 /* Test disabled for now */
1224 /*
1225 assert(bset && bset->n_div == 1);
1226 */
1228 isl_basic_set_free(bset);
1229
1230 /* test 9 */
1231 space = isl_space_set_alloc(ctx, 0, 4);
1234
1239 bset = isl_basic_set_add_constraint(bset, c);
1240
1245 bset = isl_basic_set_add_constraint(bset, c);
1246
1247 bset = isl_basic_set_project_out(bset, isl_dim_set, 2, 2);
1248
1249 bset = isl_basic_set_fix_si(bset, isl_dim_set, 0, 2);
1250
1252
1254 isl_basic_set_free(bset);
1255
1256 /* test 10 */
1257 space = isl_space_set_alloc(ctx, 0, 3);
1260
1264 bset = isl_basic_set_add_constraint(bset, c);
1265
1266 bset = isl_basic_set_project_out(bset, isl_dim_set, 2, 1);
1267
1268 bset = isl_basic_set_fix_si(bset, isl_dim_set, 0, 2);
1269
1271 isl_basic_set_free(bset);
1272
1273 str = "{ [i] : exists (e0, e1: 3e1 >= 1 + 2e0 and "
1274 "8e1 <= -1 + 5i - 5e0 and 2e1 >= 1 + 2i - 5e0) }";
1278 if (!set)
1279 return -1;
1280
1281 if (test_elimination(ctx) < 0)
1282 return -1;
1283
1284 str = "{ [i,j,k] : 3 + i + 2j >= 0 and 2 * [(i+2j)/4] <= k }";
1287 set = isl_set_fix_si(set, isl_dim_set, 2, -3);
1288 empty = isl_set_is_empty(set);
1290 if (empty < 0)
1291 return -1;
1292 if (!empty)
1294 "result not as accurate as expected", return -1);
1295
1296 return 0;
1297}
1298
1299void test_application_case(struct isl_ctx *ctx, const char *name)
1300{
1301 char *filename;
1302 FILE *input;
1303 struct isl_basic_set *bset1, *bset2;
1304 struct isl_basic_map *bmap;
1305
1306 filename = get_filename(ctx, name, "omega");
1307 assert(filename);
1308 input = fopen(filename, "r");
1309 assert(input);
1310
1311 bset1 = isl_basic_set_read_from_file(ctx, input);
1312 bmap = isl_basic_map_read_from_file(ctx, input);
1313
1314 bset1 = isl_basic_set_apply(bset1, bmap);
1315
1316 bset2 = isl_basic_set_read_from_file(ctx, input);
1317
1318 assert(isl_basic_set_is_equal(bset1, bset2) == 1);
1319
1320 isl_basic_set_free(bset1);
1321 isl_basic_set_free(bset2);
1322 free(filename);
1323
1324 fclose(input);
1325}
1326
1328{
1329 test_application_case(ctx, "application");
1330 test_application_case(ctx, "application2");
1331
1332 return 0;
1333}
1334
1335void test_affine_hull_case(struct isl_ctx *ctx, const char *name)
1336{
1337 char *filename;
1338 FILE *input;
1339 struct isl_basic_set *bset1, *bset2;
1340
1341 filename = get_filename(ctx, name, "polylib");
1342 assert(filename);
1343 input = fopen(filename, "r");
1344 assert(input);
1345
1346 bset1 = isl_basic_set_read_from_file(ctx, input);
1347 bset2 = isl_basic_set_read_from_file(ctx, input);
1348
1349 bset1 = isl_basic_set_affine_hull(bset1);
1350
1351 assert(isl_basic_set_is_equal(bset1, bset2) == 1);
1352
1353 isl_basic_set_free(bset1);
1354 isl_basic_set_free(bset2);
1355 free(filename);
1356
1357 fclose(input);
1358}
1359
1360/* Pairs of sets and the corresponding expected results of
1361 * isl_basic_set_recession_cone.
1362 */
1363struct {
1364 const char *set;
1365 const char *cone;
1367 { "{ [i] : 0 <= i <= 10 }", "{ [0] }" },
1368 { "{ [i] : 0 <= i }", "{ [i] : 0 <= i }" },
1369 { "{ [i] : i <= 10 }", "{ [i] : i <= 0 }" },
1370 { "{ [i] : false }", "{ [i] : false }" },
1372
1373/* Perform some basic isl_basic_set_recession_cone tests.
1374 */
1375static int test_recession_cone(struct isl_ctx *ctx)
1376{
1377 int i;
1378
1379 for (i = 0; i < ARRAY_SIZE(recession_cone_tests); ++i) {
1380 const char *str;
1381 isl_basic_set *bset;
1384
1385 str = recession_cone_tests[i].set;
1386 bset = isl_basic_set_read_from_str(ctx, str);
1387 str = recession_cone_tests[i].cone;
1393 if (equal < 0)
1394 return -1;
1395 if (!equal)
1396 isl_die(ctx, isl_error_unknown, "unexpected cone",
1397 return -1);
1398 }
1399
1400 return 0;
1401}
1402
1404{
1405 const char *str;
1406 isl_set *set;
1407 isl_basic_set *bset, *bset2;
1408 isl_size n;
1410
1411 test_affine_hull_case(ctx, "affine2");
1412 test_affine_hull_case(ctx, "affine");
1413 test_affine_hull_case(ctx, "affine3");
1414
1415 str = "[m] -> { [i0] : exists (e0, e1: e1 <= 1 + i0 and "
1416 "m >= 3 and 4i0 <= 2 + m and e1 >= i0 and "
1417 "e1 >= 0 and e1 <= 2 and e1 >= 1 + 2e0 and "
1418 "2e1 <= 1 + m + 4e0 and 2e1 >= 2 - m + 4i0 - 4e0) }";
1420 bset = isl_set_affine_hull(set);
1422 isl_basic_set_free(bset);
1423 if (n < 0)
1424 return -1;
1425 if (n != 0)
1426 isl_die(ctx, isl_error_unknown, "not expecting any divs",
1427 return -1);
1428
1429 /* Check that isl_map_affine_hull is not confused by
1430 * the reordering of divs in isl_map_align_divs.
1431 */
1432 str = "{ [a, b, c, 0] : exists (e0 = [(b)/32], e1 = [(c)/32]: "
1433 "32e0 = b and 32e1 = c); "
1434 "[a, 0, c, 0] : exists (e0 = [(c)/32]: 32e0 = c) }";
1436 bset = isl_set_affine_hull(set);
1437 isl_basic_set_free(bset);
1438 if (!bset)
1439 return -1;
1440
1441 str = "{ [a] : exists e0, e1, e2: 32e1 = 31 + 31a + 31e0 and "
1442 "32e2 = 31 + 31e0 }";
1444 bset = isl_set_affine_hull(set);
1445 str = "{ [a] : exists e : a = 32 e }";
1446 bset2 = isl_basic_set_read_from_str(ctx, str);
1447 subset = isl_basic_set_is_subset(bset, bset2);
1448 isl_basic_set_free(bset);
1449 isl_basic_set_free(bset2);
1450 if (subset < 0)
1451 return -1;
1452 if (!subset)
1453 isl_die(ctx, isl_error_unknown, "not as accurate as expected",
1454 return -1);
1455
1456 return 0;
1457}
1458
1459/* Test a special case of isl_set_plain_unshifted_simple_hull
1460 * where older versions of isl would include a redundant constraint
1461 * in the result.
1462 * Check that the result does not have any constraints.
1463 */
1465{
1466 const char *str;
1467 isl_bool is_universe;
1468 isl_set *set;
1469 isl_basic_set *bset;
1470
1471 str = "{[x, y] : x = 0 or 2*((x+y)//2) <= y + 2 }";
1474 is_universe = isl_basic_set_plain_is_universe(bset);
1475 isl_basic_set_free(bset);
1476
1477 if (is_universe < 0)
1478 return isl_stat_error;
1479 if (!is_universe)
1481 "hull should not have any constraints",
1482 return isl_stat_error);
1483
1484 return isl_stat_ok;
1485}
1486
1487/* Inputs for simple hull tests, consisting of
1488 * the specific simple hull function, the input set and the expected result.
1489 */
1490struct {
1492 const char *set;
1493 const char *hull;
1494} simple_hull_tests[] = {
1496 "{ [i,j] : i >= 1 and j >= 1 or i >= 2 and j <= 10 }",
1497 "{ [i,j] : i >= 1 }" },
1499 "{ [n,i,j,k] : (i mod 3 = 2 and j mod 4 = 2) or "
1500 "(j mod 4 = 2 and k mod 6 = n) }",
1501 "{ [n,i,j,k] : j mod 4 = 2 }" },
1503 "{ [0,x,y] : x <= -1; [1,x,y] : x <= y <= -x; [2,x,y] : x <= 1 }",
1504 "{ [t,x,y] : 0 <= t <= 2 and x <= 1 }" },
1506 "{ [a, b] : b <= 0 and "
1507 "2*floor((-2*floor((b)/2))/5) >= a - floor((b)/2); "
1508 "[a, b] : a mod 2 = 0 }",
1509 "{ [a, b] }" },
1511
1512/* Basic tests for various simple hull functions.
1513 */
1515{
1516 int i;
1517 isl_set *set;
1520
1521 for (i = 0; i < ARRAY_SIZE(simple_hull_tests); ++i) {
1522 const char *str;
1523 str = simple_hull_tests[i].set;
1525 str = simple_hull_tests[i].hull;
1527 hull = simple_hull_tests[i].fn(set);
1531 if (equal < 0)
1532 return -1;
1533 if (!equal)
1534 isl_die(ctx, isl_error_unknown, "unexpected hull",
1535 return -1);
1536 }
1537
1538 return 0;
1539}
1540
1541static int test_simple_hull(struct isl_ctx *ctx)
1542{
1543 const char *str;
1544 isl_set *set;
1545 isl_basic_set *bset;
1546 isl_bool is_empty;
1547
1548 str = "{ [x, y] : 3y <= 2x and y >= -2 + 2x and 2y >= 2 - x;"
1549 "[y, x] : 3y <= 2x and y >= -2 + 2x and 2y >= 2 - x }";
1551 bset = isl_set_simple_hull(set);
1552 is_empty = isl_basic_set_is_empty(bset);
1553 isl_basic_set_free(bset);
1554
1555 if (is_empty == isl_bool_error)
1556 return -1;
1557
1558 if (is_empty == isl_bool_false)
1559 isl_die(ctx, isl_error_unknown, "Empty set should be detected",
1560 return -1);
1561
1563 return -1;
1564 if (test_various_simple_hull(ctx) < 0)
1565 return -1;
1566
1567 return 0;
1568}
1569
1570/* Inputs for isl_set_get_simple_fixed_box_hull tests.
1571 * "set" is the input set.
1572 * "offset" is the expected box offset.
1573 * "size" is the expected box size.
1574 */
1575static struct {
1576 const char *set;
1577 const char *offset;
1578 const char *size;
1579} box_hull_tests[] = {
1580 { "{ S[x, y] : 0 <= x, y < 10 }", "{ S[0, 0] }", "{ S[10, 10] }" },
1581 { "[N] -> { S[x, y] : N <= x, y < N + 10 }",
1582 "[N] -> { S[N, N] }", "{ S[10, 10] }" },
1583 { "{ S[x, y] : 0 <= x + y, x - y < 10 }",
1584 "{ S[0, -4] }", "{ S[10, 9] }" },
1585 { "{ [i=0:10] : exists (e0, e1: 3e1 >= 1 + 2e0 and "
1586 "8e1 <= -1 + 5i - 5e0 and 2e1 >= 1 + 2i - 5e0) }",
1587 "{ [3] }", "{ [8] }" },
1588 { "[N] -> { [w = 0:17] : exists (e0: w < 2N and "
1589 "-1 + w <= e0 <= w and 2e0 >= N + w and w <= 2e0 <= 15 + w) }",
1590 "[N] -> { [N] }", "{ [9] }" },
1592
1593/* Perform basic isl_set_get_simple_fixed_box_hull tests.
1594 */
1595static int test_box_hull(struct isl_ctx *ctx)
1596{
1597 int i;
1598
1599 for (i = 0; i < ARRAY_SIZE(box_hull_tests); ++i) {
1600 const char *str;
1601 isl_stat r;
1602 isl_set *set;
1605 isl_fixed_box *box;
1606
1611 str = box_hull_tests[i].offset;
1612 r = multi_aff_check_plain_equal(offset, str);
1613 str = box_hull_tests[i].size;
1614 if (r >= 0)
1615 r = multi_val_check_plain_equal(size, str);
1616 isl_multi_aff_free(offset);
1617 isl_multi_val_free(size);
1618 isl_fixed_box_free(box);
1620 if (r < 0)
1621 return -1;
1622 }
1623
1624 return 0;
1625}
1626
1627void test_convex_hull_case(struct isl_ctx *ctx, const char *name)
1628{
1629 char *filename;
1630 FILE *input;
1631 struct isl_basic_set *bset1, *bset2;
1632 struct isl_set *set;
1633
1634 filename = get_filename(ctx, name, "polylib");
1635 assert(filename);
1636 input = fopen(filename, "r");
1637 assert(input);
1638
1639 bset1 = isl_basic_set_read_from_file(ctx, input);
1640 bset2 = isl_basic_set_read_from_file(ctx, input);
1641
1642 set = isl_basic_set_union(bset1, bset2);
1643 bset1 = isl_set_convex_hull(set);
1644
1645 bset2 = isl_basic_set_read_from_file(ctx, input);
1646
1647 assert(isl_basic_set_is_equal(bset1, bset2) == 1);
1648
1649 isl_basic_set_free(bset1);
1650 isl_basic_set_free(bset2);
1651 free(filename);
1652
1653 fclose(input);
1654}
1655
1656struct {
1657 const char *set;
1658 const char *hull;
1659} convex_hull_tests[] = {
1660 { "{ [i0, i1, i2] : (i2 = 1 and i0 = 0 and i1 >= 0) or "
1661 "(i0 = 1 and i1 = 0 and i2 = 1) or "
1662 "(i0 = 0 and i1 = 0 and i2 = 0) }",
1663 "{ [i0, i1, i2] : i0 >= 0 and i2 >= i0 and i2 <= 1 and i1 >= 0 }" },
1664 { "[n] -> { [i0, i1, i0] : i0 <= -4 + n; "
1665 "[i0, i0, i2] : n = 6 and i0 >= 0 and i2 <= 7 - i0 and "
1666 "i2 <= 5 and i2 >= 4; "
1667 "[3, i1, 3] : n = 5 and i1 <= 2 and i1 >= 0 }",
1668 "[n] -> { [i0, i1, i2] : i2 <= -1 + n and 2i2 <= -6 + 3n - i0 and "
1669 "i2 <= 5 + i0 and i2 >= i0 }" },
1670 { "{ [x, y] : 3y <= 2x and y >= -2 + 2x and 2y >= 2 - x }",
1671 "{ [x, y] : 1 = 0 }" },
1672 { "{ [x, y, z] : 0 <= x, y, z <= 10; [x, y, 0] : x >= 0 and y > 0; "
1673 "[x, y, 0] : x >= 0 and y < 0 }",
1674 "{ [x, y, z] : x >= 0 and 0 <= z <= 10 }" },
1675 { "{ [a, b, c] : a <= 1 and -a < b <= 1 and 0 <= c <= 2 - a - b and "
1676 "c <= a; "
1677 "[0, 2, 0]; [3, 1, 0] }",
1678 "{ [a, b, c] : b > -a and 2b >= -1 + a and 0 <= c <= a and "
1679 "5c <= 6 - a - 3b }" },
1681
1683{
1684 int i;
1685 int orig_convex = ctx->opt->convex;
1686 ctx->opt->convex = convex;
1687
1688 test_convex_hull_case(ctx, "convex0");
1689 test_convex_hull_case(ctx, "convex1");
1690 test_convex_hull_case(ctx, "convex2");
1691 test_convex_hull_case(ctx, "convex3");
1692 test_convex_hull_case(ctx, "convex4");
1693 test_convex_hull_case(ctx, "convex5");
1694 test_convex_hull_case(ctx, "convex6");
1695 test_convex_hull_case(ctx, "convex7");
1696 test_convex_hull_case(ctx, "convex8");
1697 test_convex_hull_case(ctx, "convex9");
1698 test_convex_hull_case(ctx, "convex10");
1699 test_convex_hull_case(ctx, "convex11");
1700 test_convex_hull_case(ctx, "convex12");
1701 test_convex_hull_case(ctx, "convex13");
1702 test_convex_hull_case(ctx, "convex14");
1703 test_convex_hull_case(ctx, "convex15");
1704
1705 for (i = 0; i < ARRAY_SIZE(convex_hull_tests); ++i) {
1706 isl_set *set1, *set2;
1707 int equal;
1708
1715
1716 if (equal < 0)
1717 return -1;
1718 if (!equal)
1720 "unexpected convex hull", return -1);
1721 }
1722
1723 ctx->opt->convex = orig_convex;
1724
1725 return 0;
1726}
1727
1729{
1731 return -1;
1733 return -1;
1734 return 0;
1735}
1736
1737/* Check that computing the gist of "map" with respect to "context"
1738 * does not make any copy of "map" get marked empty.
1739 * Earlier versions of isl would end up doing that.
1740 */
1741static isl_stat test_gist_empty_pair(isl_ctx *ctx, const char *map,
1742 const char *context)
1743{
1744 isl_map *m1, *m2, *m3;
1745 isl_bool empty_before, empty_after;
1746
1747 m1 = isl_map_read_from_str(ctx, map);
1748 m2 = isl_map_read_from_str(ctx, context);
1749 m3 = isl_map_copy(m1);
1750 empty_before = isl_map_is_empty(m3);
1751 m1 = isl_map_gist(m1, m2);
1752 empty_after = isl_map_is_empty(m3);
1753 isl_map_free(m1);
1754 isl_map_free(m3);
1755
1756 if (empty_before < 0 || empty_after < 0)
1757 return isl_stat_error;
1758 if (empty_before)
1759 isl_die(ctx, isl_error_unknown, "map should not be empty",
1760 return isl_stat_error);
1761 if (empty_after)
1762 isl_die(ctx, isl_error_unknown, "map should still not be empty",
1763 return isl_stat_error);
1764
1765 return isl_stat_ok;
1766}
1767
1768/* Check that computing a gist does not make any copy of the input
1769 * get marked empty.
1770 * Earlier versions of isl would end up doing that on some pairs of inputs.
1771 */
1773{
1774 const char *map, *context;
1775
1776 map = "{ [] -> [a, b, c] : 2b = 1 + a }";
1777 context = "{ [] -> [a, b, c] : 2c = 2 + a }";
1778 if (test_gist_empty_pair(ctx, map, context) < 0)
1779 return isl_stat_error;
1780 map = "{ [] -> [0, 0] }";
1781 context = "{ [] -> [a, b] : a > b }";
1782 if (test_gist_empty_pair(ctx, map, context) < 0)
1783 return isl_stat_error;
1784
1785 return isl_stat_ok;
1786}
1787
1788/* Inputs to isl_map_plain_gist_basic_map, along with the expected output.
1789 */
1790struct {
1791 const char *map;
1792 const char *context;
1793 const char *gist;
1794} plain_gist_tests[] = {
1795 { "{ [i] -> [j] : i >= 1 and j >= 1 or i >= 2 and j <= 10 }",
1796 "{ [i] -> [j] : i >= 1 }",
1797 "{ [i] -> [j] : j >= 1 or i >= 2 and j <= 10 }" },
1798 { "{ [n] -> [i,j,k] : (i mod 3 = 2 and j mod 4 = 2) or "
1799 "(j mod 4 = 2 and k mod 6 = n) }",
1800 "{ [n] -> [i,j,k] : j mod 4 = 2 }",
1801 "{ [n] -> [i,j,k] : (i mod 3 = 2) or (k mod 6 = n) }" },
1802 { "{ [i] -> [j] : i > j and (exists a,b : i <= 2a + 5b <= 2) }",
1803 "{ [i] -> [j] : i > j }",
1804 "{ [i] -> [j] : exists a,b : i <= 2a + 5b <= 2 }" },
1806
1807/* Basic tests for isl_map_plain_gist_basic_map.
1808 */
1809static int test_plain_gist(isl_ctx *ctx)
1810{
1811 int i;
1812
1813 for (i = 0; i < ARRAY_SIZE(plain_gist_tests); ++i) {
1814 const char *str;
1815 int equal;
1816 isl_map *map, *gist;
1818
1820 str = plain_gist_tests[i].context;
1827 if (equal < 0)
1828 return -1;
1829 if (!equal)
1831 "incorrect gist result", return -1);
1832 }
1833
1834 return 0;
1835}
1836
1837/* Check that isl_set_gist behaves as expected.
1838 */
1839static int test_gist(struct isl_ctx *ctx)
1840{
1841 const char *str;
1842 isl_basic_set *bset1, *bset2;
1843 isl_map *map1, *map2;
1844 isl_size n_div;
1845
1846 str = "[p0, p2, p3, p5, p6, p10] -> { [] : "
1847 "exists (e0 = [(15 + p0 + 15p6 + 15p10)/16], e1 = [(p5)/8], "
1848 "e2 = [(p6)/128], e3 = [(8p2 - p5)/128], "
1849 "e4 = [(128p3 - p6)/4096]: 8e1 = p5 and 128e2 = p6 and "
1850 "128e3 = 8p2 - p5 and 4096e4 = 128p3 - p6 and p2 >= 0 and "
1851 "16e0 >= 16 + 16p6 + 15p10 and p2 <= 15 and p3 >= 0 and "
1852 "p3 <= 31 and p6 >= 128p3 and p5 >= 8p2 and p10 >= 0 and "
1853 "16e0 <= 15 + p0 + 15p6 + 15p10 and 16e0 >= p0 + 15p6 + 15p10 and "
1854 "p10 <= 15 and p10 <= -1 + p0 - p6) }";
1855 bset1 = isl_basic_set_read_from_str(ctx, str);
1856 str = "[p0, p2, p3, p5, p6, p10] -> { [] : exists (e0 = [(p5)/8], "
1857 "e1 = [(p6)/128], e2 = [(8p2 - p5)/128], "
1858 "e3 = [(128p3 - p6)/4096]: 8e0 = p5 and 128e1 = p6 and "
1859 "128e2 = 8p2 - p5 and 4096e3 = 128p3 - p6 and p5 >= -7 and "
1860 "p2 >= 0 and 8p2 <= -1 + p0 and p2 <= 15 and p3 >= 0 and "
1861 "p3 <= 31 and 128p3 <= -1 + p0 and p6 >= -127 and "
1862 "p5 <= -1 + p0 and p6 <= -1 + p0 and p6 >= 128p3 and "
1863 "p0 >= 1 and p5 >= 8p2 and p10 >= 0 and p10 <= 15 ) }";
1864 bset2 = isl_basic_set_read_from_str(ctx, str);
1865 bset1 = isl_basic_set_gist(bset1, bset2);
1866 assert(bset1 && bset1->n_div == 0);
1867 isl_basic_set_free(bset1);
1868
1869 /* Check that the integer divisions of the second disjunct
1870 * do not spread to the first disjunct.
1871 */
1872 str = "[t1] -> { S_0[] -> A[o0] : (exists (e0 = [(-t1 + o0)/16]: "
1873 "16e0 = -t1 + o0 and o0 >= 0 and o0 <= 15 and t1 >= 0)) or "
1874 "(exists (e0 = [(-1 + t1)/16], "
1875 "e1 = [(-16 + t1 - 16e0)/4294967296]: "
1876 "4294967296e1 = -16 + t1 - o0 - 16e0 and "
1877 "16e0 <= -1 + t1 and 16e0 >= -16 + t1 and o0 >= 0 and "
1878 "o0 <= 4294967295 and t1 <= -1)) }";
1880 str = "[t1] -> { S_0[] -> A[o0] : t1 >= 0 and t1 <= 4294967295 }";
1883 if (!map1)
1884 return -1;
1885 if (map1->n != 1)
1886 isl_die(ctx, isl_error_unknown, "expecting single disjunct",
1887 isl_map_free(map1); return -1);
1888 n_div = isl_basic_map_dim(map1->p[0], isl_dim_div);
1890 if (n_div < 0)
1891 return -1;
1892 if (n_div != 1)
1893 isl_die(ctx, isl_error_unknown, "expecting single div",
1894 return -1);
1895
1896 if (test_gist_empty(ctx) < 0)
1897 return -1;
1898 if (test_plain_gist(ctx) < 0)
1899 return -1;
1900
1901 return 0;
1902}
1903
1904int test_coalesce_set(isl_ctx *ctx, const char *str, int check_one)
1905{
1906 isl_set *set, *set2;
1907 int equal;
1908 int one;
1909
1914 one = set && set->n == 1;
1917
1918 if (equal < 0)
1919 return -1;
1920 if (!equal)
1922 "coalesced set not equal to input", return -1);
1923 if (check_one && !one)
1925 "coalesced set should not be a union", return -1);
1926
1927 return 0;
1928}
1929
1930/* Inputs for coalescing tests with unbounded wrapping.
1931 * "str" is a string representation of the input set.
1932 * "single_disjunct" is set if we expect the result to consist of
1933 * a single disjunct.
1934 */
1935struct {
1937 const char *str;
1939 { 1, "{ [x,y,z] : y + 2 >= 0 and x - y + 1 >= 0 and "
1940 "-x - y + 1 >= 0 and -3 <= z <= 3;"
1941 "[x,y,z] : -x+z + 20 >= 0 and -x-z + 20 >= 0 and "
1942 "x-z + 20 >= 0 and x+z + 20 >= 0 and "
1943 "-10 <= y <= 0}" },
1944 { 1, "{ [x,y] : 0 <= x,y <= 10; [5,y]: 4 <= y <= 11 }" },
1945 { 1, "{ [x,0,0] : -5 <= x <= 5; [0,y,1] : -5 <= y <= 5 }" },
1946 { 1, "{ [x,y] : 0 <= x <= 10 and 0 >= y >= -1 and x+y >= 0; [0,1] }" },
1947 { 1, "{ [x,y] : (0 <= x,y <= 4) or (2 <= x,y <= 5 and x + y <= 9) }" },
1948 { 0, "{ [x, y, z] : 0 <= x,y,z <= 100 and 0 < z <= 2 + 2x + 2y; "
1949 "[x, y, 0] : x,y <= 100 and y <= 9 + 11x and x <= 9 + 11y }" },
1950 { 1, "{ [0:1, 0:1]; [0, 2:3] }" },
1951 { 1, "{ [0:1, 0:1]; [0, 2:3]; [1, -2:-1] }" },
1952 { 1, "{ [0:3, 0:1]; [1:2, 2:5] }" },
1953 { 1, "{ [0:3, 0:1]; [0:2, 2:5] }" },
1954 { 1, "{ [0:3, 0:1]; [1:3, 2:5] }" },
1955 { 0, "{ [0:3, 0:1]; [1:4, 2:5] }" },
1956 { 0, "{ [0:3, 0:1]; [1:5, 2:5] }" },
1958
1959/* Test the functionality of isl_set_coalesce with the bounded wrapping
1960 * option turned off.
1961 */
1963{
1964 int i;
1965 int r = 0;
1966 int bounded;
1967
1970
1971 for (i = 0; i < ARRAY_SIZE(coalesce_unbounded_tests); ++i) {
1972 const char *str = coalesce_unbounded_tests[i].str;
1973 int check_one = coalesce_unbounded_tests[i].single_disjunct;
1974 if (test_coalesce_set(ctx, str, check_one) >= 0)
1975 continue;
1976 r = -1;
1977 break;
1978 }
1979
1981
1982 return r;
1983}
1984
1985/* Inputs for coalescing tests.
1986 * "str" is a string representation of the input set.
1987 * "single_disjunct" is set if we expect the result to consist of
1988 * a single disjunct.
1989 */
1990struct {
1991 int single_disjunct;
1992 const char *str;
1993} coalesce_tests[] = {
1994 { 1, "{[x,y]: x >= 0 & x <= 10 & y >= 0 & y <= 10 or "
1995 "y >= x & x >= 2 & 5 >= y }" },
1996 { 1, "{[x,y]: y >= 0 & 2x + y <= 30 & y <= 10 & x >= 0 or "
1997 "x + y >= 10 & y <= x & x + y <= 20 & y >= 0}" },
1998 { 0, "{[x,y]: y >= 0 & 2x + y <= 30 & y <= 10 & x >= 0 or "
1999 "x + y >= 10 & y <= x & x + y <= 19 & y >= 0}" },
2000 { 1, "{[x,y]: y >= 0 & x <= 5 & y <= x or "
2001 "y >= 0 & x >= 6 & x <= 10 & y <= x}" },
2002 { 0, "{[x,y]: y >= 0 & x <= 5 & y <= x or "
2003 "y >= 0 & x >= 7 & x <= 10 & y <= x}" },
2004 { 0, "{[x,y]: y >= 0 & x <= 5 & y <= x or "
2005 "y >= 0 & x >= 6 & x <= 10 & y + 1 <= x}" },
2006 { 1, "{[x,y]: y >= 0 & x <= 5 & y <= x or y >= 0 & x = 6 & y <= 6}" },
2007 { 0, "{[x,y]: y >= 0 & x <= 5 & y <= x or y >= 0 & x = 7 & y <= 6}" },
2008 { 1, "{[x,y]: y >= 0 & x <= 5 & y <= x or y >= 0 & x = 6 & y <= 5}" },
2009 { 0, "{[x,y]: y >= 0 & x <= 5 & y <= x or y >= 0 & x = 6 & y <= 7}" },
2010 { 1, "[n] -> { [i] : i = 1 and n >= 2 or 2 <= i and i <= n }" },
2011 { 0, "{[x,y] : x >= 0 and y >= 0 or 0 <= y and y <= 5 and x = -1}" },
2012 { 1, "[n] -> { [i] : 1 <= i and i <= n - 1 or 2 <= i and i <= n }" },
2013 { 0, "[n] -> { [[i0] -> [o0]] : exists (e0 = [(i0)/4], e1 = [(o0)/4], "
2014 "e2 = [(n)/2], e3 = [(-2 + i0)/4], e4 = [(-2 + o0)/4], "
2015 "e5 = [(-2n + i0)/4]: 2e2 = n and 4e3 = -2 + i0 and "
2016 "4e4 = -2 + o0 and i0 >= 8 + 2n and o0 >= 2 + i0 and "
2017 "o0 <= 56 + 2n and o0 <= -12 + 4n and i0 <= 57 + 2n and "
2018 "i0 <= -11 + 4n and o0 >= 6 + 2n and 4e0 <= i0 and "
2019 "4e0 >= -3 + i0 and 4e1 <= o0 and 4e1 >= -3 + o0 and "
2020 "4e5 <= -2n + i0 and 4e5 >= -3 - 2n + i0);"
2021 "[[i0] -> [o0]] : exists (e0 = [(i0)/4], e1 = [(o0)/4], "
2022 "e2 = [(n)/2], e3 = [(-2 + i0)/4], e4 = [(-2 + o0)/4], "
2023 "e5 = [(-2n + i0)/4]: 2e2 = n and 4e3 = -2 + i0 and "
2024 "4e4 = -2 + o0 and 2e0 >= 3 + n and e0 <= -4 + n and "
2025 "2e0 <= 27 + n and e1 <= -4 + n and 2e1 <= 27 + n and "
2026 "2e1 >= 2 + n and e1 >= 1 + e0 and i0 >= 7 + 2n and "
2027 "i0 <= -11 + 4n and i0 <= 57 + 2n and 4e0 <= -2 + i0 and "
2028 "4e0 >= -3 + i0 and o0 >= 6 + 2n and o0 <= -11 + 4n and "
2029 "o0 <= 57 + 2n and 4e1 <= -2 + o0 and 4e1 >= -3 + o0 and "
2030 "4e5 <= -2n + i0 and 4e5 >= -3 - 2n + i0 ) }" },
2031 { 0, "[n, m] -> { [o0, o2, o3] : (o3 = 1 and o0 >= 1 + m and "
2032 "o0 <= n + m and o2 <= m and o0 >= 2 + n and o2 >= 3) or "
2033 "(o0 >= 2 + n and o0 >= 1 + m and o0 <= n + m and n >= 1 and "
2034 "o3 <= -1 + o2 and o3 >= 1 - m + o2 and o3 >= 2 and o3 <= n) }" },
2035 { 0, "[M, N] -> { [[i0, i1, i2, i3, i4, i5, i6] -> "
2036 "[o0, o1, o2, o3, o4, o5, o6]] : "
2037 "(o6 <= -4 + 2M - 2N + i0 + i1 - i2 + i6 - o0 - o1 + o2 and "
2038 "o3 <= -2 + i3 and o6 >= 2 + i0 + i3 + i6 - o0 - o3 and "
2039 "o6 >= 2 - M + N + i3 + i4 + i6 - o3 - o4 and o0 <= -1 + i0 and "
2040 "o4 >= 4 - 3M + 3N - i0 - i1 + i2 + 2i3 + i4 + o0 + o1 - o2 - 2o3 "
2041 "and o6 <= -3 + 2M - 2N + i3 + i4 - i5 + i6 - o3 - o4 + o5 and "
2042 "2o6 <= -5 + 5M - 5N + 2i0 + i1 - i2 - i5 + 2i6 - 2o0 - o1 + o2 + o5 "
2043 "and o6 >= 2i0 + i1 + i6 - 2o0 - o1 and "
2044 "3o6 <= -5 + 4M - 4N + 2i0 + i1 - i2 + 2i3 + i4 - i5 + 3i6 "
2045 "- 2o0 - o1 + o2 - 2o3 - o4 + o5) or "
2046 "(N >= 2 and o3 <= -1 + i3 and o0 <= -1 + i0 and "
2047 "o6 >= i3 + i6 - o3 and M >= 0 and "
2048 "2o6 >= 1 + i0 + i3 + 2i6 - o0 - o3 and "
2049 "o6 >= 1 - M + i0 + i6 - o0 and N >= 2M and o6 >= i0 + i6 - o0) }" },
2050 { 0, "[M, N] -> { [o0] : (o0 = 0 and M >= 1 and N >= 2) or "
2051 "(o0 = 0 and M >= 1 and N >= 2M and N >= 2 + M) or "
2052 "(o0 = 0 and M >= 2 and N >= 3) or "
2053 "(M = 0 and o0 = 0 and N >= 3) }" },
2054 { 0, "{ [i0, i1, i2, i3] : (i1 = 10i0 and i0 >= 1 and 10i0 <= 100 and "
2055 "i3 <= 9 + 10 i2 and i3 >= 1 + 10i2 and i3 >= 0) or "
2056 "(i1 <= 9 + 10i0 and i1 >= 1 + 10i0 and i2 >= 0 and "
2057 "i0 >= 0 and i1 <= 100 and i3 <= 9 + 10i2 and i3 >= 1 + 10i2) }" },
2058 { 0, "[M] -> { [i1] : (i1 >= 2 and i1 <= M) or (i1 = M and M >= 1) }" },
2059 { 0, "{[x,y] : x,y >= 0; [x,y] : 10 <= x <= 20 and y >= -1 }" },
2060 { 1, "{ [x, y] : (x >= 1 and y >= 1 and x <= 2 and y <= 2) or "
2061 "(y = 3 and x = 1) }" },
2062 { 1, "[M] -> { [i0, i1, i2, i3, i4] : (i1 >= 3 and i4 >= 2 + i2 and "
2063 "i2 >= 2 and i0 >= 2 and i3 >= 1 + i2 and i0 <= M and "
2064 "i1 <= M and i3 <= M and i4 <= M) or "
2065 "(i1 >= 2 and i4 >= 1 + i2 and i2 >= 2 and i0 >= 2 and "
2066 "i3 >= 1 + i2 and i0 <= M and i1 <= -1 + M and i3 <= M and "
2067 "i4 <= -1 + M) }" },
2068 { 1, "{ [x, y] : (x >= 0 and y >= 0 and x <= 10 and y <= 10) or "
2069 "(x >= 1 and y >= 1 and x <= 11 and y <= 11) }" },
2070 { 0, "{[x,0] : x >= 0; [x,1] : x <= 20}" },
2071 { 1, "{ [x, 1 - x] : 0 <= x <= 1; [0,0] }" },
2072 { 1, "{ [0,0]; [i,i] : 1 <= i <= 10 }" },
2073 { 0, "{ [0,0]; [i,j] : 1 <= i,j <= 10 }" },
2074 { 1, "{ [0,0]; [i,2i] : 1 <= i <= 10 }" },
2075 { 0, "{ [0,0]; [i,2i] : 2 <= i <= 10 }" },
2076 { 0, "{ [1,0]; [i,2i] : 1 <= i <= 10 }" },
2077 { 0, "{ [0,1]; [i,2i] : 1 <= i <= 10 }" },
2078 { 0, "{ [a, b] : exists e : 2e = a and "
2079 "a >= 0 and (a <= 3 or (b <= 0 and b >= -4 + a)) }" },
2080 { 0, "{ [i, j, i', j'] : i <= 2 and j <= 2 and "
2081 "j' >= -1 + 2i + j - 2i' and i' <= -1 + i and "
2082 "j >= 1 and j' <= i + j - i' and i >= 1; "
2083 "[1, 1, 1, 1] }" },
2084 { 1, "{ [i,j] : exists a,b : i = 2a and j = 3b; "
2085 "[i,j] : exists a : j = 3a }" },
2086 { 1, "{ [a, b, c] : (c <= 7 - b and b <= 1 and b >= 0 and "
2087 "c >= 3 + b and b <= 3 + 8a and b >= -26 + 8a and "
2088 "a >= 3) or "
2089 "(b <= 1 and c <= 7 and b >= 0 and c >= 4 + b and "
2090 "b <= 3 + 8a and b >= -26 + 8a and a >= 3) }" },
2091 { 1, "{ [a, 0, c] : c >= 1 and c <= 29 and c >= -1 + 8a and "
2092 "c <= 6 + 8a and a >= 3; "
2093 "[a, -1, c] : c >= 1 and c <= 30 and c >= 8a and "
2094 "c <= 7 + 8a and a >= 3 and a <= 4 }" },
2095 { 1, "{ [x,y] : 0 <= x <= 2 and y >= 0 and x + 2y <= 4; "
2096 "[x,0] : 3 <= x <= 4 }" },
2097 { 1, "{ [x,y] : 0 <= x <= 3 and y >= 0 and x + 3y <= 6; "
2098 "[x,0] : 4 <= x <= 5 }" },
2099 { 0, "{ [x,y] : 0 <= x <= 2 and y >= 0 and x + 2y <= 4; "
2100 "[x,0] : 3 <= x <= 5 }" },
2101 { 0, "{ [x,y] : 0 <= x <= 2 and y >= 0 and x + y <= 4; "
2102 "[x,0] : 3 <= x <= 4 }" },
2103 { 1, "{ [i0, i1] : i0 <= 122 and i0 >= 1 and 128i1 >= -249 + i0 and "
2104 "i1 <= 0; "
2105 "[i0, 0] : i0 >= 123 and i0 <= 124 }" },
2106 { 1, "{ [0,0]; [1,1] }" },
2107 { 1, "[n] -> { [k] : 16k <= -1 + n and k >= 1; [0] : n >= 2 }" },
2108 { 1, "{ [k, ii, k - ii] : ii >= -6 + k and ii <= 6 and ii >= 1 and "
2109 "ii <= k;"
2110 "[k, 0, k] : k <= 6 and k >= 1 }" },
2111 { 1, "{ [i,j] : i = 4 j and 0 <= i <= 100;"
2112 "[i,j] : 1 <= i <= 100 and i >= 4j + 1 and i <= 4j + 2 }" },
2113 { 1, "{ [x,y] : x % 2 = 0 and y % 2 = 0; [x,x] : x % 2 = 0 }" },
2114 { 1, "[n] -> { [1] : n >= 0;"
2115 "[x] : exists (e0 = floor((x)/2): x >= 2 and "
2116 "2e0 >= -1 + x and 2e0 <= x and 2e0 <= n) }" },
2117 { 1, "[n] -> { [x, y] : exists (e0 = floor((x)/2), e1 = floor((y)/3): "
2118 "3e1 = y and x >= 2 and 2e0 >= -1 + x and "
2119 "2e0 <= x and 2e0 <= n);"
2120 "[1, y] : exists (e0 = floor((y)/3): 3e0 = y and "
2121 "n >= 0) }" },
2122 { 1, "[t1] -> { [i0] : (exists (e0 = floor((63t1)/64): "
2123 "128e0 >= -134 + 127t1 and t1 >= 2 and "
2124 "64e0 <= 63t1 and 64e0 >= -63 + 63t1)) or "
2125 "t1 = 1 }" },
2126 { 1, "{ [i, i] : exists (e0 = floor((1 + 2i)/3): 3e0 <= 2i and "
2127 "3e0 >= -1 + 2i and i <= 9 and i >= 1);"
2128 "[0, 0] }" },
2129 { 1, "{ [t1] : exists (e0 = floor((-11 + t1)/2): 2e0 = -11 + t1 and "
2130 "t1 >= 13 and t1 <= 16);"
2131 "[t1] : t1 <= 15 and t1 >= 12 }" },
2132 { 1, "{ [x,y] : x = 3y and 0 <= y <= 2; [-3,-1] }" },
2133 { 1, "{ [x,y] : 2x = 3y and 0 <= y <= 4; [-3,-2] }" },
2134 { 0, "{ [x,y] : 2x = 3y and 0 <= y <= 4; [-2,-2] }" },
2135 { 0, "{ [x,y] : 2x = 3y and 0 <= y <= 4; [-3,-1] }" },
2136 { 1, "{ [i] : exists j : i = 4 j and 0 <= i <= 100;"
2137 "[i] : exists j : 1 <= i <= 100 and i >= 4j + 1 and "
2138 "i <= 4j + 2 }" },
2139 { 1, "{ [c0] : (exists (e0 : c0 - 1 <= 3e0 <= c0)) or "
2140 "(exists (e0 : 3e0 = -2 + c0)) }" },
2141 { 0, "[n, b0, t0] -> "
2142 "{ [i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12] : "
2143 "(exists (e0 = floor((-32b0 + i4)/1048576), "
2144 "e1 = floor((i8)/32): 1048576e0 = -32b0 + i4 and 32e1 = i8 and "
2145 "n <= 2147483647 and b0 <= 32767 and b0 >= 0 and "
2146 "32b0 <= -2 + n and t0 <= 31 and t0 >= 0 and i0 >= 8 + n and "
2147 "3i4 <= -96 + 3t0 + i0 and 3i4 >= -95 - n + 3t0 + i0 and "
2148 "i8 >= -157 + i0 - 4i4 and i8 >= 0 and "
2149 "i8 <= -33 + i0 - 4i4 and 3i8 <= -91 + 4n - i0)) or "
2150 "(exists (e0 = floor((-32b0 + i4)/1048576), "
2151 "e1 = floor((i8)/32): 1048576e0 = -32b0 + i4 and 32e1 = i8 and "
2152 "n <= 2147483647 and b0 <= 32767 and b0 >= 0 and "
2153 "32b0 <= -2 + n and t0 <= 31 and t0 >= 0 and i0 <= 7 + n and "
2154 "4i4 <= -3 + i0 and 3i4 <= -96 + 3t0 + i0 and "
2155 "3i4 >= -95 - n + 3t0 + i0 and i8 >= -157 + i0 - 4i4 and "
2156 "i8 >= 0 and i8 <= -4 + i0 - 3i4 and i8 <= -41 + i0));"
2157 "[i0, i1, i2, i3, 0, i5, i6, i7, i8, i9, i10, i11, i12] : "
2158 "(exists (e0 = floor((i8)/32): b0 = 0 and 32e0 = i8 and "
2159 "n <= 2147483647 and t0 <= 31 and t0 >= 0 and i0 >= 11 and "
2160 "i0 >= 96 - 3t0 and i0 <= 95 + n - 3t0 and i0 <= 7 + n and "
2161 "i8 >= -40 + i0 and i8 <= -10 + i0)) }" },
2162 { 0, "{ [i0, i1, i2] : "
2163 "(exists (e0, e1 = floor((i0)/32), e2 = floor((i1)/32): "
2164 "32e1 = i0 and 32e2 = i1 and i1 >= -31 + i0 and "
2165 "i1 <= 31 + i0 and i2 >= -30 + i0 and i2 >= -30 + i1 and "
2166 "32e0 >= -30 + i0 and 32e0 >= -30 + i1 and "
2167 "32e0 >= -31 + i2 and 32e0 <= 30 + i2 and 32e0 <= 31 + i1 and "
2168 "32e0 <= 31 + i0)) or "
2169 "i0 >= 0 }" },
2170 { 1, "{ [a, b, c] : 2b = 1 + a and 2c = 2 + a; [0, 0, 0] }" },
2171 { 1, "{ [a, a, b, c] : 32*floor((a)/32) = a and 2*floor((b)/2) = b and "
2172 "2*floor((c)/2) = c and 0 <= a <= 192;"
2173 "[224, 224, b, c] : 2*floor((b)/2) = b and 2*floor((c)/2) = c }"
2174 },
2175 { 1, "[n] -> { [a,b] : (exists e : 1 <= a <= 7e and 9e <= b <= n) or "
2176 "(0 <= a <= b <= n) }" },
2177 { 1, "{ [a, b] : 0 <= a <= 2 and b >= 0 and "
2178 "((0 < b <= 13) or (2*floor((a + b)/2) >= -5 + a + 2b)) }" },
2179 { 1, "{ [a] : (2 <= a <= 5) or (a mod 2 = 1 and 1 <= a <= 5) }" },
2180 { 1, "{ [a, b, c] : (b = -1 + a and 0 < a <= 3 and "
2181 "9*floor((-4a + 2c)/9) <= -3 - 4a + 2c) or "
2182 "(exists (e0 = floor((-16 + 2c)/9): a = 4 and "
2183 "b = 3 and 9e0 <= -19 + 2c)) }" },
2184 { 1, "{ [a, b, c] : (b = -1 + a and 0 < a <= 3 and "
2185 "9*floor((-4a + 2c)/9) <= -3 - 4a + 2c) or "
2186 "(a = 4 and b = 3 and "
2187 "9*floor((-16 + 2c)/9) <= -19 + 2c) }" },
2188 { 0, "{ [a, b, c] : (b <= 2 and b <= -2 + a) or "
2189 "(b = -1 + a and 0 < a <= 3 and "
2190 "9*floor((-4a + 2c)/9) <= -3 - 4a + 2c) or "
2191 "(exists (e0 = floor((-16 + 2c)/9): a = 4 and "
2192 "b = 3 and 9e0 <= -19 + 2c)) }" },
2193 { 1, "{ [y, x] : (x - y) mod 3 = 2 and 2 <= y <= 200 and 0 <= x <= 2;"
2194 "[1, 0] }" },
2195 { 1, "{ [x, y] : (x - y) mod 3 = 2 and 2 <= y <= 200 and 0 <= x <= 2;"
2196 "[0, 1] }" },
2197 { 1, "{ [1, y] : -1 <= y <= 1; [x, -x] : 0 <= x <= 1 }" },
2198 { 1, "{ [1, y] : 0 <= y <= 1; [x, -x] : 0 <= x <= 1 }" },
2199 { 1, "{ [x, y] : 0 <= x <= 10 and x - 4*floor(x/4) <= 1 and y <= 0; "
2200 "[x, y] : 0 <= x <= 10 and x - 4*floor(x/4) > 1 and y <= 0; "
2201 "[x, y] : 0 <= x <= 10 and x - 5*floor(x/5) <= 1 and 0 < y; "
2202 "[x, y] : 0 <= x <= 10 and x - 5*floor(x/5) > 1 and 0 < y }" },
2203 { 1, "{ [x, 0] : 0 <= x <= 10 and x mod 2 = 0; "
2204 "[x, 0] : 0 <= x <= 10 and x mod 2 = 1; "
2205 "[x, y] : 0 <= x <= 10 and 1 <= y <= 10 }" },
2206 { 1, "{ [a] : a <= 8 and "
2207 "(a mod 10 = 7 or a mod 10 = 8 or a mod 10 = 9) }" },
2208 { 1, "{ [x, y] : 2y = -x and x <= 0 or "
2209 "x <= -1 and 2y <= -x - 1 and 2y >= x - 1 }" },
2210 { 0, "{ [x, y] : 2y = -x and x <= 0 or "
2211 "x <= -2 and 2y <= -x - 1 and 2y >= x - 1 }" },
2212 { 1, "{ [a] : (a <= 0 and 3*floor((a)/3) = a) or "
2213 "(a < 0 and 3*floor((a)/3) < a) }" },
2214 { 1, "{ [a] : (a <= 0 and 3*floor((a)/3) = a) or "
2215 "(a < -1 and 3*floor((a)/3) < a) }" },
2216 { 1, "{ [a, b] : a <= 1024 and b >= 0 and "
2217 "((-31 - a + b <= 32*floor((-1 - a)/32) <= -33 + b and "
2218 "32*floor((-1 - a)/32) <= -16 + b + 16*floor((-1 - a)/16))"
2219 "or (2 <= a <= 15 and b < a)) }" },
2220 { 1, "{ [a] : a > 0 and ((16*floor((a)/16) < a and "
2221 "32*floor((a)/32) < a) or a <= 15) }" },
2222 { 1, "{ [a, b, c, d] : (-a + d) mod 64 = 0 and a <= 8 and b <= 1 and "
2223 "10 - a <= c <= 3 and d >= 5 and 9 - 64b <= d <= 70;"
2224 "[a, b = 1, c, d] : (-a + d) mod 64 = 0 and a <= 8 and c >= 4 and "
2225 "10 - a <= c <= 5 and 5 <= d <= 73 - c }" },
2226 { 1, "[n, m] -> { S_0[i] : (-n + i) mod 3 = 0 and m >= 3 + n and "
2227 "i >= n and 3*floor((2 + n + 2m)/3) <= n + 3m - i; "
2228 "S_0[n] : n <= m <= 2 + n }" },
2229 { 1, "{ [a, b] : exists (e0: 0 <= a <= 1 and b >= 0 and "
2230 "2e0 >= -5 + a + 2b and 2e0 >= -1 + a + b and "
2231 "2e0 <= a + b); "
2232 "[a, b] : exists (e0: 0 <= a <= 1 and 2e0 >= -5 + a + 2b and "
2233 "2e0 >= -1 - a + b and 2e0 <= -a + b and "
2234 "2e0 < -a + 2b) }" },
2235 { 1, "{ [i, j, i - 8j] : 8 <= i <= 63 and -7 + i <= 8j <= i; "
2236 "[i, 0, i] : 0 <= i <= 7 }" },
2237 { 1, "{ [a, b] : a >= 0 and 0 <= b <= 1 - a; [1, 1] }" },
2238 { 0, "{ [a, b] : a >= 0 and 0 <= b <= 1 - a; [0, 2] }" },
2239 { 0, "{ [a, b] : a >= 0 and 0 <= b <= 1 - a; [-1, 3] }" },
2240 { 1, "{ [a, b] : a, b >= 0 and a + 2b <= 2; [1, 1] }" },
2241 { 0, "{ [a, b] : a, b >= 0 and a + 2b <= 2; [2, 1] }" },
2242 { 0, "{ [a, c] : (2 + a) mod 4 = 0 or "
2243 "(c = 4 + a and 4 * floor((a)/4) = a and a >= 0 and a <= 4) or "
2244 "(c = 3 + a and 4 * floor((-1 + a)/4) = -1 + a and "
2245 "a > 0 and a <= 5) }" },
2246 { 1, "{ [1, 0, 0]; [a, b, c] : -1 <= -a < b <= 0 and 2c > b }" },
2247 { 0, "{ [j, a, l] : a mod 2 = 0 and j <= 29 and a >= 2 and "
2248 "2a <= -5 + j and 32j + 2a + 2 <= 4l < 33j; "
2249 "[j, 0, l] : 4 <= j <= 29 and -3 + 33j <= 4l <= 33j }" },
2250 { 0, "{ [0:1, 0:1]; [0, 2:3] }" },
2251 { 1, "{ [a] : (a = 0 or ((1 + a) mod 2 = 0 and 0 < a <= 15) or "
2252 "((a) mod 2 = 0 and 0 < a <= 15)) }" },
2253 { 1, "{ rat: [0:2]; rat: [1:3] }" },
2254 { 1, "{ [a = 1:14] : a mod 4 = 0 and 4*floor((1 + a)/4) <= a; [0] }" },
2255 { 0, "{ [a = 4:6, b = 1:7, 8] : a mod 2 = 1 and b mod 2 = 1;"
2256 "[a = 1:7, 1:7, a] }" },
2257 { 1, "{ [a] : a mod 2 = 0 and (a <= 3 or a >= 12 or 4 <= a <= 11) }" },
2258 { 1, "{ [a] : 0 < a <= 341 or "
2259 "(0 < a <= 700 and 360*floor(a/360) >= -340 + a) }" },
2260 { 0, "{ [a] : 0 < a <= 341 or "
2261 "(0 < a <= 701 and 360*floor(a/360) >= -340 + a) }" },
2263
2264/* A specialized coalescing test case that would result
2265 * in a segmentation fault or a failed assertion in earlier versions of isl.
2266 */
2267static int test_coalesce_special(struct isl_ctx *ctx)
2268{
2269 const char *str;
2270 isl_map *map1, *map2;
2271
2272 str = "[y] -> { [S_L220_OUT[] -> T7[]] -> "
2273 "[[S_L309_IN[] -> T11[]] -> ce_imag2[1, o1]] : "
2274 "(y = 201 and o1 <= 239 and o1 >= 212) or "
2275 "(exists (e0 = [(y)/3]: 3e0 = y and y <= 198 and y >= 3 and "
2276 "o1 <= 239 and o1 >= 212)) or "
2277 "(exists (e0 = [(y)/3]: 3e0 = y and y <= 201 and y >= 3 and "
2278 "o1 <= 241 and o1 >= 240));"
2279 "[S_L220_OUT[] -> T7[]] -> "
2280 "[[S_L309_IN[] -> T11[]] -> ce_imag2[0, o1]] : "
2281 "(y = 2 and o1 <= 241 and o1 >= 212) or "
2282 "(exists (e0 = [(-2 + y)/3]: 3e0 = -2 + y and y <= 200 and "
2283 "y >= 5 and o1 <= 241 and o1 >= 212)) }";
2287 str = "[y] -> { [S_L220_OUT[] -> T7[]] -> "
2288 "[[S_L309_IN[] -> T11[]] -> ce_imag2[o0, o1]] : "
2289 "exists (e0 = [(-1 - y + o0)/3]: 3e0 = -1 - y + o0 and "
2290 "y <= 201 and o0 <= 2 and o1 >= 212 and o1 <= 241 and "
2291 "o0 >= 3 - y and o0 <= -2 + y and o0 >= 0) }";
2297 if (!map2)
2298 return -1;
2299
2300 return 0;
2301}
2302
2303/* Check that the union of the basic sets described by "str1" and "str2"
2304 * can be coalesced and that the result is equal to the union.
2305 * The explicit call to isl_basic_set_union prevents the implicit
2306 * equality constraints in the basic maps from being detected prior
2307 * to the call to isl_set_coalesce, at least at the point
2308 * where this function was introduced.
2309 */
2310static isl_stat test_coalesce_union(isl_ctx *ctx, const char *str1,
2311 const char *str2)
2312{
2313 isl_basic_set *bset1, *bset2;
2314 isl_set *set, *set2;
2316
2317 bset1 = isl_basic_set_read_from_str(ctx, str1);
2318 bset2 = isl_basic_set_read_from_str(ctx, str2);
2319 set = isl_basic_set_union(bset1, bset2);
2321
2322 bset1 = isl_basic_set_read_from_str(ctx, str1);
2323 bset2 = isl_basic_set_read_from_str(ctx, str2);
2324 set2 = isl_basic_set_union(bset1, bset2);
2325
2329
2330 if (equal < 0)
2331 return isl_stat_error;
2332 if (!equal)
2334 "coalesced set not equal to input",
2335 return isl_stat_error);
2336
2337 return isl_stat_non_null(set);
2338}
2339
2340/* A specialized coalescing test case that would result in an assertion
2341 * in an earlier version of isl. Use test_coalesce_union with
2342 * an explicit call to isl_basic_set_union to prevent the implicit
2343 * equality constraints in the first basic map from being detected prior
2344 * to the call to isl_set_coalesce, at least at the point
2345 * where this test case was introduced.
2346 */
2348{
2349 const char *str1;
2350 const char *str2;
2351
2352 str1 = "{ [x, y] : x, y >= 0 and x + 2y <= 1 and 2x + y <= 1 }";
2353 str2 = "{ [x,0] : -1 <= x <= 1 and x mod 2 = 1 }";
2354 return test_coalesce_union(ctx, str1, str2);
2355}
2356
2357/* Check that calling isl_set_coalesce does not leave other sets
2358 * that may share some information with the input to isl_set_coalesce
2359 * in an inconsistent state.
2360 * In particular, older versions of isl would modify all copies
2361 * of the basic sets in the isl_set_coalesce input in a way
2362 * that could leave them in an inconsistent state.
2363 * The result of printing any other set containing one of these
2364 * basic sets would then result in an invalid set description.
2365 */
2367{
2368 const char *str;
2369 char *s;
2370 isl_set *set1, *set2;
2371 isl_printer *p;
2372
2373 set1 = isl_set_read_from_str(ctx, "{ [0, 0, 0] }");
2374 str = "{ [a, b, a + b] : a >= 0 and b >= 0 and 0 < a + b }";
2379
2380 p = isl_printer_to_str(ctx);
2385 set1 = isl_set_read_from_str(ctx, s);
2386 free(s);
2388
2389 if (!set1)
2390 return -1;
2391
2392 return 0;
2393}
2394
2395/* Check that calling isl_set_coalesce on the intersection of
2396 * the sets described by "s1" and "s2" does not leave other sets
2397 * that may share some information with the input to isl_set_coalesce
2398 * in an inconsistent state.
2399 * In particular, when isl_set_coalesce detects equality constraints,
2400 * it does not immediately perform Gaussian elimination on them,
2401 * but then it needs to ensure that it is performed at some point.
2402 * The input set has implicit equality constraints in the first disjunct.
2403 * It is constructed as an intersection, because otherwise
2404 * those equality constraints would already be detected during parsing.
2405 */
2407 const char *s1, const char *s2)
2408{
2409 isl_set *set1, *set2;
2410
2411 set1 = isl_set_read_from_str(ctx, s1);
2412 set2 = isl_set_read_from_str(ctx, s2);
2417
2418 if (!set1)
2419 return isl_stat_error;
2420
2421 return isl_stat_ok;
2422}
2423
2424/* Check that calling isl_set_coalesce does not leave other sets
2425 * that may share some information with the input to isl_set_coalesce
2426 * in an inconsistent state, for the case where one disjunct
2427 * is a subset of the other.
2428 */
2430{
2431 const char *s1, *s2;
2432
2433 s1 = "{ [a, b] : b <= 0 or a <= 1 }";
2434 s2 = "{ [a, b] : -1 <= -a < b }";
2435 return test_coalesce_intersection(ctx, s1, s2);
2436}
2437
2438/* Check that calling isl_set_coalesce does not leave other sets
2439 * that may share some information with the input to isl_set_coalesce
2440 * in an inconsistent state, for the case where two disjuncts
2441 * can be fused.
2442 */
2444{
2445 const char *s1, *s2;
2446
2447 s1 = "{ [a, b, c] : b <= 0 }";
2448 s2 = "{ [a, b, c] : -1 <= -a < b and (c >= 0 or c < 0) }";
2449 return test_coalesce_intersection(ctx, s1, s2);
2450}
2451
2452/* Check that calling isl_set_coalesce does not leave other sets
2453 * that may share some information with the input to isl_set_coalesce
2454 * in an inconsistent state, for the case where two disjuncts
2455 * can be fused and where both disjuncts have implicit equality constraints.
2456 */
2458{
2459 const char *s1, *s2;
2460
2461 s1 = "{ [a, b, c] : c <= 0 }";
2462 s2 = "{ [a, b, c] : 0 <= a <= b <= c or (0 <= b <= c and a > 0) }";
2463 return test_coalesce_intersection(ctx, s1, s2);
2464}
2465
2466/* A specialized coalescing test case that would result in an assertion failure
2467 * in an earlier version of isl. Use test_coalesce_union with
2468 * an explicit call to isl_basic_set_union to prevent the implicit
2469 * equality constraints in the basic maps from being detected prior
2470 * to the call to isl_set_coalesce, at least at the point
2471 * where this test case was introduced.
2472 */
2474{
2475 const char *str1;
2476 const char *str2;
2477
2478 str1 = "{ [a, b, c=0:17] : a <= 7 and 2b <= 11 - a and "
2479 "c <= -7 + 2a and 2c >= - 3 + 3a - 2b }";
2480 str2 = "{ [a, b, c] : c > -15a and c >= -7 + 2a and c < 0 and "
2481 "3c <= -5 + 5a - 3b and 2b >= 11 - a }";
2482 return test_coalesce_union(ctx, str1, str2);
2483}
2484
2485/* A specialized coalescing test case that would result in a disjunct
2486 * getting dropped in an earlier version of isl. Use test_coalesce_union with
2487 * an explicit call to isl_basic_set_union to prevent the implicit
2488 * equality constraints in the basic maps from being detected prior
2489 * to the call to isl_set_coalesce, at least at the point
2490 * where this test case was introduced.
2491 */
2493{
2494 const char *str1;
2495 const char *str2;
2496
2497 str1 = "{ [a, b, c] : 2c <= -a and b >= -a and b <= 5 and "
2498 "6c > -7a and 11c >= -5a - b and a <= 3 }";
2499 str2 = "{ [a, b, c] : 6c > -7a and b >= -a and b <= 5 and "
2500 "11c >= -5a - b and a >= 4 and 2b <= a and 2c <= -a }";
2501 return test_coalesce_union(ctx, str1, str2);
2502}
2503
2504/* Test the functionality of isl_set_coalesce.
2505 * That is, check that the output is always equal to the input
2506 * and in some cases that the result consists of a single disjunct.
2507 */
2508static int test_coalesce(struct isl_ctx *ctx)
2509{
2510 int i;
2511
2512 for (i = 0; i < ARRAY_SIZE(coalesce_tests); ++i) {
2513 const char *str = coalesce_tests[i].str;
2514 int check_one = coalesce_tests[i].single_disjunct;
2515 if (test_coalesce_set(ctx, str, check_one) < 0)
2516 return -1;
2517 }
2518
2520 return -1;
2521 if (test_coalesce_special(ctx) < 0)
2522 return -1;
2523 if (test_coalesce_special2(ctx) < 0)
2524 return -1;
2525 if (test_coalesce_special3(ctx) < 0)
2526 return -1;
2527 if (test_coalesce_special4(ctx) < 0)
2528 return -1;
2529 if (test_coalesce_special5(ctx) < 0)
2530 return -1;
2531 if (test_coalesce_special6(ctx) < 0)
2532 return -1;
2533 if (test_coalesce_special7(ctx) < 0)
2534 return -1;
2535 if (test_coalesce_special8(ctx) < 0)
2536 return -1;
2537
2538 return 0;
2539}
2540
2541/* Construct a representation of the graph on the right of Figure 1
2542 * in "Computing the Transitive Closure of a Union of
2543 * Affine Integer Tuple Relations".
2544 */
2546{
2547 isl_set *dom;
2548 isl_map *up, *right;
2549
2550 dom = isl_set_read_from_str(ctx,
2551 "{ [x,y] : x >= 0 and -2 x + 3 y >= 0 and x <= 3 and "
2552 "2 x - 3 y + 3 >= 0 }");
2553 right = isl_map_read_from_str(ctx,
2554 "{ [x,y] -> [x2,y2] : x2 = x + 1 and y2 = y }");
2555 up = isl_map_read_from_str(ctx,
2556 "{ [x,y] -> [x2,y2] : x2 = x and y2 = y + 1 }");
2557 right = isl_map_intersect_domain(right, isl_set_copy(dom));
2558 right = isl_map_intersect_range(right, isl_set_copy(dom));
2560 up = isl_map_intersect_range(up, dom);
2561 return isl_map_union(up, right);
2562}
2563
2564/* Construct a representation of the power of the graph
2565 * on the right of Figure 1 in "Computing the Transitive Closure of
2566 * a Union of Affine Integer Tuple Relations".
2567 */
2569{
2570 return isl_map_read_from_str(ctx,
2571 "{ [1] -> [[0,0] -> [0,1]]; [2] -> [[0,0] -> [1,1]]; "
2572 " [1] -> [[0,1] -> [1,1]]; [1] -> [[2,2] -> [3,2]]; "
2573 " [2] -> [[2,2] -> [3,3]]; [1] -> [[3,2] -> [3,3]] }");
2574}
2575
2576/* Construct a representation of the transitive closure of the graph
2577 * on the right of Figure 1 in "Computing the Transitive Closure of
2578 * a Union of Affine Integer Tuple Relations".
2579 */
2584
2585static int test_closure(isl_ctx *ctx)
2586{
2587 const char *str;
2588 isl_map *map, *map2;
2589 isl_bool exact, equal;
2590
2591 /* COCOA example 1 */
2593 "[n] -> { [i,j] -> [i2,j2] : i2 = i + 1 and j2 = j + 1 and "
2594 "1 <= i and i < n and 1 <= j and j < n or "
2595 "i2 = i + 1 and j2 = j - 1 and "
2596 "1 <= i and i < n and 2 <= j and j <= n }");
2597 map = isl_map_power(map, &exact);
2598 assert(exact);
2600
2601 /* COCOA example 1 */
2603 "[n] -> { [i,j] -> [i2,j2] : i2 = i + 1 and j2 = j + 1 and "
2604 "1 <= i and i < n and 1 <= j and j < n or "
2605 "i2 = i + 1 and j2 = j - 1 and "
2606 "1 <= i and i < n and 2 <= j and j <= n }");
2608 assert(exact);
2610 "[n] -> { [i,j] -> [i2,j2] : exists (k1,k2,k : "
2611 "1 <= i and i < n and 1 <= j and j <= n and "
2612 "2 <= i2 and i2 <= n and 1 <= j2 and j2 <= n and "
2613 "i2 = i + k1 + k2 and j2 = j + k1 - k2 and "
2614 "k1 >= 0 and k2 >= 0 and k1 + k2 = k and k >= 1 )}");
2618
2620 "[n] -> { [x] -> [y] : y = x + 1 and 0 <= x and x <= n and "
2621 " 0 <= y and y <= n }");
2624 "[n] -> { [x] -> [y] : y > x and 0 <= x and x <= n and "
2625 " 0 <= y and y <= n }");
2629
2630 /* COCOA example 2 */
2632 "[n] -> { [i,j] -> [i2,j2] : i2 = i + 2 and j2 = j + 2 and "
2633 "1 <= i and i < n - 1 and 1 <= j and j < n - 1 or "
2634 "i2 = i + 2 and j2 = j - 2 and "
2635 "1 <= i and i < n - 1 and 3 <= j and j <= n }");
2637 assert(exact);
2639 "[n] -> { [i,j] -> [i2,j2] : exists (k1,k2,k : "
2640 "1 <= i and i < n - 1 and 1 <= j and j <= n and "
2641 "3 <= i2 and i2 <= n and 1 <= j2 and j2 <= n and "
2642 "i2 = i + 2 k1 + 2 k2 and j2 = j + 2 k1 - 2 k2 and "
2643 "k1 >= 0 and k2 >= 0 and k1 + k2 = k and k >= 1) }");
2647
2648 /* COCOA Fig.2 left */
2650 "[n] -> { [i,j] -> [i2,j2] : i2 = i + 2 and j2 = j and "
2651 "i <= 2 j - 3 and i <= n - 2 and j <= 2 i - 1 and "
2652 "j <= n or "
2653 "i2 = i and j2 = j + 2 and i <= 2 j - 1 and i <= n and "
2654 "j <= 2 i - 3 and j <= n - 2 or "
2655 "i2 = i + 1 and j2 = j + 1 and i <= 2 j - 1 and "
2656 "i <= n - 1 and j <= 2 i - 1 and j <= n - 1 }");
2658 assert(exact);
2660
2661 /* COCOA Fig.2 right */
2663 "[n] -> { [i,j] -> [i2,j2] : i2 = i + 3 and j2 = j and "
2664 "i <= 2 j - 4 and i <= n - 3 and j <= 2 i - 1 and "
2665 "j <= n or "
2666 "i2 = i and j2 = j + 3 and i <= 2 j - 1 and i <= n and "
2667 "j <= 2 i - 4 and j <= n - 3 or "
2668 "i2 = i + 1 and j2 = j + 1 and i <= 2 j - 1 and "
2669 "i <= n - 1 and j <= 2 i - 1 and j <= n - 1 }");
2670 map = isl_map_power(map, &exact);
2671 assert(exact);
2673
2674 /* COCOA Fig.2 right */
2676 "[n] -> { [i,j] -> [i2,j2] : i2 = i + 3 and j2 = j and "
2677 "i <= 2 j - 4 and i <= n - 3 and j <= 2 i - 1 and "
2678 "j <= n or "
2679 "i2 = i and j2 = j + 3 and i <= 2 j - 1 and i <= n and "
2680 "j <= 2 i - 4 and j <= n - 3 or "
2681 "i2 = i + 1 and j2 = j + 1 and i <= 2 j - 1 and "
2682 "i <= n - 1 and j <= 2 i - 1 and j <= n - 1 }");
2684 assert(exact);
2686 "[n] -> { [i,j] -> [i2,j2] : exists (k1,k2,k3,k : "
2687 "i <= 2 j - 1 and i <= n and j <= 2 i - 1 and "
2688 "j <= n and 3 + i + 2 j <= 3 n and "
2689 "3 + 2 i + j <= 3n and i2 <= 2 j2 -1 and i2 <= n and "
2690 "i2 <= 3 j2 - 4 and j2 <= 2 i2 -1 and j2 <= n and "
2691 "13 + 4 j2 <= 11 i2 and i2 = i + 3 k1 + k3 and "
2692 "j2 = j + 3 k2 + k3 and k1 >= 0 and k2 >= 0 and "
2693 "k3 >= 0 and k1 + k2 + k3 = k and k > 0) }");
2697
2700 assert(exact);
2705
2707 map = isl_map_power(map, &exact);
2712 if (equal < 0)
2713 return -1;
2714 if (!exact)
2715 isl_die(ctx, isl_error_unknown, "power not exact", return -1);
2716 if (!equal)
2717 isl_die(ctx, isl_error_unknown, "unexpected power", return -1);
2718
2719 /* COCOA Theorem 1 counter example */
2721 "{ [i,j] -> [i2,j2] : i = 0 and 0 <= j and j <= 1 and "
2722 "i2 = 1 and j2 = j or "
2723 "i = 0 and j = 0 and i2 = 0 and j2 = 1 }");
2725 assert(exact);
2727
2729 "[m,n] -> { [i,j] -> [i2,j2] : i2 = i and j2 = j + 2 and "
2730 "1 <= i,i2 <= n and 1 <= j,j2 <= m or "
2731 "i2 = i + 1 and 3 <= j2 - j <= 4 and "
2732 "1 <= i,i2 <= n and 1 <= j,j2 <= m }");
2734 assert(exact);
2736
2737 /* Kelly et al 1996, fig 12 */
2739 "[n] -> { [i,j] -> [i2,j2] : i2 = i and j2 = j + 1 and "
2740 "1 <= i,j,j+1 <= n or "
2741 "j = n and j2 = 1 and i2 = i + 1 and "
2742 "1 <= i,i+1 <= n }");
2744 assert(exact);
2746 "[n] -> { [i,j] -> [i2,j2] : 1 <= j < j2 <= n and "
2747 "1 <= i <= n and i = i2 or "
2748 "1 <= i < i2 <= n and 1 <= j <= n and "
2749 "1 <= j2 <= n }");
2753
2754 /* Omega's closure4 */
2756 "[m,n] -> { [x,y] -> [x2,y2] : x2 = x and y2 = y + 1 and "
2757 "1 <= x,y <= 10 or "
2758 "x2 = x + 1 and y2 = y and "
2759 "1 <= x <= 20 && 5 <= y <= 15 }");
2761 assert(exact);
2763
2765 "[n] -> { [x] -> [y]: 1 <= n <= y - x <= 10 }");
2767 assert(!exact);
2769 "[n] -> { [x] -> [y] : 1 <= n <= 10 and y >= n + x }");
2773
2774 str = "[n, m] -> { [i0, i1, i2, i3] -> [o0, o1, o2, o3] : "
2775 "i3 = 1 and o0 = i0 and o1 = -1 + i1 and o2 = -1 + i2 and "
2776 "o3 = -2 + i2 and i1 <= -1 + i0 and i1 >= 1 - m + i0 and "
2777 "i1 >= 2 and i1 <= n and i2 >= 3 and i2 <= 1 + n and i2 <= m }";
2780 assert(exact);
2785
2786 str = "{[0] -> [1]; [2] -> [3]}";
2789 assert(exact);
2794
2795 str = "[n] -> { [[i0, i1, 1, 0, i0] -> [i5, 1]] -> "
2796 "[[i0, -1 + i1, 2, 0, i0] -> [-1 + i5, 2]] : "
2797 "exists (e0 = [(3 - n)/3]: i5 >= 2 and i1 >= 2 and "
2798 "3i0 <= -1 + n and i1 <= -1 + n and i5 <= -1 + n and "
2799 "3e0 >= 1 - n and 3e0 <= 2 - n and 3i0 >= -2 + n); "
2800 "[[i0, i1, 2, 0, i0] -> [i5, 1]] -> "
2801 "[[i0, i1, 1, 0, i0] -> [-1 + i5, 2]] : "
2802 "exists (e0 = [(3 - n)/3]: i5 >= 2 and i1 >= 1 and "
2803 "3i0 <= -1 + n and i1 <= -1 + n and i5 <= -1 + n and "
2804 "3e0 >= 1 - n and 3e0 <= 2 - n and 3i0 >= -2 + n); "
2805 "[[i0, i1, 1, 0, i0] -> [i5, 2]] -> "
2806 "[[i0, -1 + i1, 2, 0, i0] -> [i5, 1]] : "
2807 "exists (e0 = [(3 - n)/3]: i1 >= 2 and i5 >= 1 and "
2808 "3i0 <= -1 + n and i1 <= -1 + n and i5 <= -1 + n and "
2809 "3e0 >= 1 - n and 3e0 <= 2 - n and 3i0 >= -2 + n); "
2810 "[[i0, i1, 2, 0, i0] -> [i5, 2]] -> "
2811 "[[i0, i1, 1, 0, i0] -> [i5, 1]] : "
2812 "exists (e0 = [(3 - n)/3]: i5 >= 1 and i1 >= 1 and "
2813 "3i0 <= -1 + n and i1 <= -1 + n and i5 <= -1 + n and "
2814 "3e0 >= 1 - n and 3e0 <= 2 - n and 3i0 >= -2 + n) }";
2817 assert(map);
2819
2820 return 0;
2821}
2822
2823/* Check that the actual result of a boolean operation is equal
2824 * to the expected result.
2825 */
2827{
2828 if (actual != expected)
2830 "incorrect boolean operation", return isl_stat_error);
2831 return isl_stat_ok;
2832}
2833
2834/* Test operations on isl_bool values.
2835 *
2836 * This tests:
2837 *
2838 * isl_bool_not
2839 * isl_bool_ok
2840 */
2841static int test_isl_bool(isl_ctx *ctx)
2842{
2844 return -1;
2846 return -1;
2848 return -1;
2849 if (check_bool(ctx, isl_bool_ok(0), isl_bool_false) < 0)
2850 return -1;
2851 if (check_bool(ctx, isl_bool_ok(1), isl_bool_true) < 0)
2852 return -1;
2853 if (check_bool(ctx, isl_bool_ok(-1), isl_bool_true) < 0)
2854 return -1;
2855 if (check_bool(ctx, isl_bool_ok(2), isl_bool_true) < 0)
2856 return -1;
2857 if (check_bool(ctx, isl_bool_ok(-2), isl_bool_true) < 0)
2858 return -1;
2859
2860 return 0;
2861}
2862
2863static int test_lex(struct isl_ctx *ctx)
2864{
2865 isl_space *space;
2866 isl_map *map;
2867 int empty;
2868
2869 space = isl_space_set_alloc(ctx, 0, 0);
2870 map = isl_map_lex_le(space);
2871 empty = isl_map_is_empty(map);
2873
2874 if (empty < 0)
2875 return -1;
2876 if (empty)
2878 "expecting non-empty result", return -1);
2879
2880 return 0;
2881}
2882
2883/* Inputs for isl_map_lexmin tests.
2884 * "map" is the input and "lexmin" is the expected result.
2885 */
2886struct {
2887 const char *map;
2888 const char *lexmin;
2889} lexmin_tests [] = {
2890 { "{ [x] -> [y] : x <= y <= 10; [x] -> [5] : -8 <= x <= 8 }",
2891 "{ [x] -> [5] : 6 <= x <= 8; "
2892 "[x] -> [x] : x <= 5 or (9 <= x <= 10) }" },
2893 { "{ [x] -> [y] : 4y = x or 4y = -1 + x or 4y = -2 + x }",
2894 "{ [x] -> [y] : 4y = x or 4y = -1 + x or 4y = -2 + x }" },
2895 { "{ [x] -> [y] : x = 4y; [x] -> [y] : x = 2y }",
2896 "{ [x] -> [y] : (4y = x and x >= 0) or "
2897 "(exists (e0 = [(x)/4], e1 = [(-2 + x)/4]: 2y = x and "
2898 "4e1 = -2 + x and 4e0 <= -1 + x and 4e0 >= -3 + x)) or "
2899 "(exists (e0 = [(x)/4]: 2y = x and 4e0 = x and x <= -4)) }" },
2900 { "{ T[a] -> S[b, c] : a = 4b-2c and c >= b }",
2901 "{ T[a] -> S[b, c] : 2b = a and 2c = a }" },
2902 /* Check that empty pieces are properly combined. */
2903 { "[K, N] -> { [x, y] -> [a, b] : K+2<=N<=K+4 and x>=4 and "
2904 "2N-6<=x<K+N and N-1<=a<=K+N-1 and N+b-6<=a<=2N-4 and "
2905 "b<=2N-3K+a and 3b<=4N-K+1 and b>=N and a>=x+1 }",
2906 "[K, N] -> { [x, y] -> [1 + x, N] : x >= -6 + 2N and "
2907 "x <= -5 + 2N and x >= -1 + 3K - N and x <= -2 + K + N and "
2908 "x >= 4 }" },
2909 { "{ [i, k, j] -> [a, b, c, d] : 8*floor((b)/8) = b and k <= 255 and "
2910 "a <= 255 and c <= 255 and d <= 255 - j and "
2911 "255 - j <= 7d <= 7 - i and 240d <= 239 + a and "
2912 "247d <= 247 + k - j and 247d <= 247 + k - b and "
2913 "247d <= 247 + i and 248 - b <= 248d <= c and "
2914 "254d >= i - a + b and 254d >= -a + b and "
2915 "255d >= -i + a - b and 1792d >= -63736 + 257b }",
2916 "{ [i, k, j] -> "
2917 "[-127762 + i + 502j, -62992 + 248j, 63240 - 248j, 255 - j] : "
2918 "k <= 255 and 7j >= 1778 + i and 246j >= 62738 - k and "
2919 "247j >= 62738 - i and 509j <= 129795 + i and "
2920 "742j >= 188724 - i; "
2921 "[0, k, j] -> [1, 0, 248, 1] : k <= 255 and 248 <= j <= 254, k }" },
2922 { "{ [a] -> [b] : 0 <= b <= 255 and -509 + a <= 512b < a and "
2923 "16*floor((8 + b)/16) <= 7 + b; "
2924 "[a] -> [1] }",
2925 "{ [a] -> [b = 1] : a >= 510 or a <= 0; "
2926 "[a] -> [b = 0] : 0 < a <= 509 }" },
2927 { "{ rat: [i] : 1 <= 2i <= 9 }", "{ rat: [i] : 2i = 1 }" },
2928 { "{ rat: [i] : 1 <= 2i <= 9 or i >= 10 }", "{ rat: [i] : 2i = 1 }" },
2929 { "{ rat: [i] : 21 <= 2i <= 29 or i = 5 }", "{ rat: [5] }" },
2931
2932static int test_lexmin(struct isl_ctx *ctx)
2933{
2934 int i;
2935 int equal;
2936 const char *str;
2937 isl_basic_map *bmap;
2938 isl_map *map, *map2;
2939 isl_set *set;
2940 isl_set *set2;
2942
2943 str = "[p0, p1] -> { [] -> [] : "
2944 "exists (e0 = [(2p1)/3], e1, e2, e3 = [(3 - p1 + 3e0)/3], "
2945 "e4 = [(p1)/3], e5 = [(p1 + 3e4)/3]: "
2946 "3e0 >= -2 + 2p1 and 3e0 >= p1 and 3e3 >= 1 - p1 + 3e0 and "
2947 "3e0 <= 2p1 and 3e3 >= -2 + p1 and 3e3 <= -1 + p1 and p1 >= 3 and "
2948 "3e5 >= -2 + 2p1 and 3e5 >= p1 and 3e5 <= -1 + p1 + 3e4 and "
2949 "3e4 <= p1 and 3e4 >= -2 + p1 and e3 <= -1 + e0 and "
2950 "3e4 >= 6 - p1 + 3e1 and 3e1 >= p1 and 3e5 >= -2 + p1 + 3e4 and "
2951 "2e4 >= 3 - p1 + 2e1 and e4 <= e1 and 3e3 <= 2 - p1 + 3e0 and "
2952 "e5 >= 1 + e1 and 3e4 >= 6 - 2p1 + 3e1 and "
2953 "p0 >= 2 and p1 >= p0 and 3e2 >= p1 and 3e4 >= 6 - p1 + 3e2 and "
2954 "e2 <= e1 and e3 >= 1 and e4 <= e2) }";
2958 if (!map)
2959 return -1;
2960
2961 str = "[C] -> { [obj,a,b,c] : obj <= 38 a + 7 b + 10 c and "
2962 "a + b <= 1 and c <= 10 b and c <= C and a,b,c,C >= 0 }";
2965 str = "[C] -> { [obj,a,b,c] : C = 8 }";
2970
2971 for (i = 0; i < ARRAY_SIZE(lexmin_tests); ++i) {
2978
2979 if (equal < 0)
2980 return -1;
2981 if (!equal)
2983 "unexpected result", return -1);
2984 }
2985
2986 str = "{ [i] -> [i', j] : j = i - 8i' and i' >= 0 and i' <= 7 and "
2987 " 8i' <= i and 8i' >= -7 + i }";
2988 bmap = isl_basic_map_read_from_str(ctx, str);
2995
2996 str = "[i] -> { [i', j] : j = i - 8i' and i' >= 0 and i' <= 7 and "
2997 " 8i' <= i and 8i' >= -7 + i }";
3004 if (equal < 0)
3005 return -1;
3006 if (!equal)
3008 "unexpected difference between set and "
3009 "piecewise affine expression", return -1);
3010
3011 return 0;
3012}
3013
3014/* Inputs for isl_pw_multi_aff_max_multi_val tests.
3015 * "pma" is the input.
3016 * "res" is the expected result.
3017 */
3018static struct {
3019 const char *pma;
3020 const char *res;
3021} opt_pw_tests[] = {
3022 { "{ [-1] -> [-1]; [1] -> [1] }", "{ [1] }" },
3023 { "{ [a, b] -> [floor((b - 2*floor((-a)/4))/5)] : "
3024 "0 <= a, b <= 100 and b mod 2 = 0}", "{ [30] }" },
3025 { "[N] -> { [i,j] -> A[i, -i, i + j] : 0 <= i,j <= N <= 10 }",
3026 "{ A[10, 0, 20] }" },
3027 { "[N] -> {A[N, -N, 2N] : 0 <= N }", "{ A[infty, 0, infty] }" },
3029
3030/* Perform basic isl_pw_multi_aff_max_multi_val tests.
3031 */
3032static isl_stat test_pw_max(struct isl_ctx *ctx)
3033{
3034 int i;
3036 isl_multi_val *mv;
3037 isl_stat r;
3038
3039 for (i = 0; i < ARRAY_SIZE(opt_pw_tests); ++i) {
3042 r = multi_val_check_plain_equal(mv, opt_pw_tests[i].res);
3043 isl_multi_val_free(mv);
3044
3045 if (r < 0)
3046 return isl_stat_error;
3047 }
3048
3049 return isl_stat_ok;
3050}
3051
3052/* A specialized isl_set_min_val test case that would return the wrong result
3053 * in earlier versions of isl.
3054 * The explicit call to isl_basic_set_union prevents the second basic set
3055 * from being determined to be empty prior to the call to isl_set_min_val,
3056 * at least at the point where this test case was introduced.
3057 */
3059{
3060 const char *str;
3061 isl_basic_set *bset1, *bset2;
3062 isl_set *set;
3063 isl_aff *obj;
3064 isl_val *res;
3065 int ok;
3066
3067 str = "{ [a, b] : a >= 2 and b >= 0 and 14 - a <= b <= 9 }";
3068 bset1 = isl_basic_set_read_from_str(ctx, str);
3069 str = "{ [a, b] : 1 <= a, b and a + b <= 1 }";
3070 bset2 = isl_basic_set_read_from_str(ctx, str);
3071 set = isl_basic_set_union(bset1, bset2);
3072 obj = isl_aff_read_from_str(ctx, "{ [a, b] -> [a] }");
3073
3075 ok = isl_val_cmp_si(res, 5) == 0;
3076
3080
3081 if (!res)
3082 return -1;
3083 if (!ok)
3084 isl_die(ctx, isl_error_unknown, "unexpected minimum",
3085 return -1);
3086
3087 return 0;
3088}
3089
3090/* A specialized isl_set_min_val test case that would return an error
3091 * in earlier versions of isl.
3092 */
3094{
3095 const char *str;
3096 isl_basic_set *bset;
3097 isl_aff *obj;
3098 isl_val *res;
3099
3100 str = "{ [i, j, k] : 2j = i and 2k = i + 1 and i >= 2 }";
3101 bset = isl_basic_set_read_from_str(ctx, str);
3102
3103 obj = isl_aff_read_from_str(ctx, "{ [i, j, k] -> [i] }");
3104
3105 res = isl_basic_set_max_val(bset, obj);
3106
3107 isl_basic_set_free(bset);
3110
3111 if (!res)
3112 return -1;
3113
3114 return 0;
3115}
3116
3117/* Check that the result of isl_set_min_multi_pw_aff
3118 * on the union of the sets with string descriptions "s1" and "s2"
3119 * consists of a single expression (on a single cell).
3120 */
3121static isl_stat check_single_expr_min(isl_ctx *ctx, const char *s1,
3122 const char *s2)
3123{
3124 isl_size n;
3125 isl_set *set1, *set2;
3126 isl_multi_pw_aff *mpa;
3128
3129 set1 = isl_set_read_from_str(ctx, s1);
3130 set2 = isl_set_read_from_str(ctx, s2);
3136
3137 if (n < 0)
3138 return isl_stat_error;
3139 if (n != 1)
3140 isl_die(ctx, isl_error_unknown, "expecting single expression",
3141 return isl_stat_error);
3142 return isl_stat_ok;
3143}
3144
3145/* A specialized isl_set_min_multi_pw_aff test that checks
3146 * that the minimum of 2N and 3N for N >= 0 is represented
3147 * by a single expression, without splitting off the special case N = 0.
3148 * Do this for both orderings.
3149 */
3150static int test_min_mpa(isl_ctx *ctx)
3151{
3152 const char *s1, *s2;
3153
3154 s1 = "[N=0:] -> { [1, 3N:] }";
3155 s2 = "[N=0:] -> { [10, 2N:] }";
3156 if (check_single_expr_min(ctx, s1, s2) < 0)
3157 return -1;
3158 if (check_single_expr_min(ctx, s2, s1) < 0)
3159 return -1;
3160
3161 return 0;
3162}
3163
3164struct {
3165 const char *set;
3166 const char *obj;
3169 const char *res;
3170} opt_tests[] = {
3171 { "{ [-1]; [1] }", "{ [x] -> [x] }", &isl_set_min_val, "-1" },
3172 { "{ [-1]; [1] }", "{ [x] -> [x] }", &isl_set_max_val, "1" },
3173 { "{ [a, b] : 0 <= a, b <= 100 and b mod 2 = 0}",
3174 "{ [a, b] -> [floor((b - 2*floor((-a)/4))/5)] }",
3175 &isl_set_max_val, "30" },
3176
3178
3179/* Perform basic isl_set_min_val and isl_set_max_val tests.
3180 * In particular, check the results on non-convex inputs.
3181 */
3182static int test_min(struct isl_ctx *ctx)
3183{
3184 int i;
3185 isl_set *set;
3186 isl_aff *obj;
3187 isl_val *val, *res;
3188 isl_bool ok;
3189
3190 for (i = 0; i < ARRAY_SIZE(opt_tests); ++i) {
3194 val = opt_tests[i].fn(set, obj);
3195 ok = isl_val_eq(res, val);
3200
3201 if (ok < 0)
3202 return -1;
3203 if (!ok)
3205 "unexpected optimum", return -1);
3206 }
3207
3208 if (test_pw_max(ctx) < 0)
3209 return -1;
3210 if (test_min_special(ctx) < 0)
3211 return -1;
3212 if (test_min_special2(ctx) < 0)
3213 return -1;
3214
3215 return 0;
3216}
3217
3222
3224 void *dep_user, void *user)
3225{
3226 struct must_may *mm = (struct must_may *)user;
3227
3228 if (must)
3229 mm->must = isl_map_union(mm->must, dep);
3230 else
3231 mm->may = isl_map_union(mm->may, dep);
3232
3233 return isl_stat_ok;
3234}
3235
3236static int common_space(void *first, void *second)
3237{
3238 int depth = *(int *)first;
3239 return 2 * depth;
3240}
3241
3242static int map_is_equal(__isl_keep isl_map *map, const char *str)
3243{
3244 isl_map *map2;
3245 int equal;
3246
3247 if (!map)
3248 return -1;
3249
3253
3254 return equal;
3255}
3256
3257static int map_check_equal(__isl_keep isl_map *map, const char *str)
3258{
3259 int equal;
3260
3262 if (equal < 0)
3263 return -1;
3264 if (!equal)
3266 "result not as expected", return -1);
3267 return 0;
3268}
3269
3270/* Is "set" equal to the set described by "str"?
3271 */
3273{
3274 isl_set *set2;
3276
3277 if (!set)
3278 return isl_bool_error;
3279
3283
3284 return equal;
3285}
3286
3287/* Check that "set" is equal to the set described by "str".
3288 */
3290{
3292
3294 if (equal < 0)
3295 return isl_stat_error;
3296 if (!equal)
3298 "result not as expected", return isl_stat_error);
3299 return isl_stat_ok;
3300}
3301
3302/* Is "uset" equal to the union set described by "str"?
3303 */
3305{
3306 isl_union_set *uset2;
3308
3309 if (!uset)
3310 return isl_bool_error;
3311
3313 equal = isl_union_set_is_equal(uset, uset2);
3314 isl_union_set_free(uset2);
3315
3316 return equal;
3317}
3318
3319/* Check that "uset" is equal to the union set described by "str".
3320 */
3322 const char *str)
3323{
3325
3326 equal = uset_is_equal(uset, str);
3327 if (equal < 0)
3328 return isl_stat_error;
3329 if (!equal)
3331 "result not as expected", return isl_stat_error);
3332 return isl_stat_ok;
3333}
3334
3335static int test_dep(struct isl_ctx *ctx)
3336{
3337 const char *str;
3338 isl_space *space;
3339 isl_map *map;
3340 isl_access_info *ai;
3341 isl_flow *flow;
3342 int depth;
3343 struct must_may mm;
3344
3345 depth = 3;
3346
3347 str = "{ [2,i,0] -> [i] : 0 <= i <= 10 }";
3349 ai = isl_access_info_alloc(map, &depth, &common_space, 2);
3350
3351 str = "{ [0,i,0] -> [i] : 0 <= i <= 10 }";
3353 ai = isl_access_info_add_source(ai, map, 1, &depth);
3354
3355 str = "{ [1,i,0] -> [5] : 0 <= i <= 10 }";
3357 ai = isl_access_info_add_source(ai, map, 1, &depth);
3358
3360 space = isl_space_alloc(ctx, 0, 3, 3);
3361 mm.must = isl_map_empty(isl_space_copy(space));
3362 mm.may = isl_map_empty(space);
3363
3365
3366 str = "{ [0,i,0] -> [2,i,0] : (0 <= i <= 4) or (6 <= i <= 10); "
3367 " [1,10,0] -> [2,5,0] }";
3369 str = "{ [i,j,k] -> [l,m,n] : 1 = 0 }";
3370 assert(map_is_equal(mm.may, str));
3371
3372 isl_map_free(mm.must);
3373 isl_map_free(mm.may);
3375
3376
3377 str = "{ [2,i,0] -> [i] : 0 <= i <= 10 }";
3379 ai = isl_access_info_alloc(map, &depth, &common_space, 2);
3380
3381 str = "{ [0,i,0] -> [i] : 0 <= i <= 10 }";
3383 ai = isl_access_info_add_source(ai, map, 1, &depth);
3384
3385 str = "{ [1,i,0] -> [5] : 0 <= i <= 10 }";
3387 ai = isl_access_info_add_source(ai, map, 0, &depth);
3388
3390 space = isl_space_alloc(ctx, 0, 3, 3);
3391 mm.must = isl_map_empty(isl_space_copy(space));
3392 mm.may = isl_map_empty(space);
3393
3395
3396 str = "{ [0,i,0] -> [2,i,0] : (0 <= i <= 4) or (6 <= i <= 10) }";
3398 str = "{ [0,5,0] -> [2,5,0]; [1,i,0] -> [2,5,0] : 0 <= i <= 10 }";
3399 assert(map_is_equal(mm.may, str));
3400
3401 isl_map_free(mm.must);
3402 isl_map_free(mm.may);
3404
3405
3406 str = "{ [2,i,0] -> [i] : 0 <= i <= 10 }";
3408 ai = isl_access_info_alloc(map, &depth, &common_space, 2);
3409
3410 str = "{ [0,i,0] -> [i] : 0 <= i <= 10 }";
3412 ai = isl_access_info_add_source(ai, map, 0, &depth);
3413
3414 str = "{ [1,i,0] -> [5] : 0 <= i <= 10 }";
3416 ai = isl_access_info_add_source(ai, map, 0, &depth);
3417
3419 space = isl_space_alloc(ctx, 0, 3, 3);
3420 mm.must = isl_map_empty(isl_space_copy(space));
3421 mm.may = isl_map_empty(space);
3422
3424
3425 str = "{ [0,i,0] -> [2,i,0] : 0 <= i <= 10; "
3426 " [1,i,0] -> [2,5,0] : 0 <= i <= 10 }";
3427 assert(map_is_equal(mm.may, str));
3428 str = "{ [i,j,k] -> [l,m,n] : 1 = 0 }";
3430
3431 isl_map_free(mm.must);
3432 isl_map_free(mm.may);
3434
3435
3436 str = "{ [0,i,2] -> [i] : 0 <= i <= 10 }";
3438 ai = isl_access_info_alloc(map, &depth, &common_space, 2);
3439
3440 str = "{ [0,i,0] -> [i] : 0 <= i <= 10 }";
3442 ai = isl_access_info_add_source(ai, map, 0, &depth);
3443
3444 str = "{ [0,i,1] -> [5] : 0 <= i <= 10 }";
3446 ai = isl_access_info_add_source(ai, map, 0, &depth);
3447
3449 space = isl_space_alloc(ctx, 0, 3, 3);
3450 mm.must = isl_map_empty(isl_space_copy(space));
3451 mm.may = isl_map_empty(space);
3452
3454
3455 str = "{ [0,i,0] -> [0,i,2] : 0 <= i <= 10; "
3456 " [0,i,1] -> [0,5,2] : 0 <= i <= 5 }";
3457 assert(map_is_equal(mm.may, str));
3458 str = "{ [i,j,k] -> [l,m,n] : 1 = 0 }";
3460
3461 isl_map_free(mm.must);
3462 isl_map_free(mm.may);
3464
3465
3466 str = "{ [0,i,1] -> [i] : 0 <= i <= 10 }";
3468 ai = isl_access_info_alloc(map, &depth, &common_space, 2);
3469
3470 str = "{ [0,i,0] -> [i] : 0 <= i <= 10 }";
3472 ai = isl_access_info_add_source(ai, map, 0, &depth);
3473
3474 str = "{ [0,i,2] -> [5] : 0 <= i <= 10 }";
3476 ai = isl_access_info_add_source(ai, map, 0, &depth);
3477
3479 space = isl_space_alloc(ctx, 0, 3, 3);
3480 mm.must = isl_map_empty(isl_space_copy(space));
3481 mm.may = isl_map_empty(space);
3482
3484
3485 str = "{ [0,i,0] -> [0,i,1] : 0 <= i <= 10; "
3486 " [0,i,2] -> [0,5,1] : 0 <= i <= 4 }";
3487 assert(map_is_equal(mm.may, str));
3488 str = "{ [i,j,k] -> [l,m,n] : 1 = 0 }";
3490
3491 isl_map_free(mm.must);
3492 isl_map_free(mm.may);
3494
3495
3496 depth = 5;
3497
3498 str = "{ [1,i,0,0,0] -> [i,j] : 0 <= i <= 10 and 0 <= j <= 10 }";
3500 ai = isl_access_info_alloc(map, &depth, &common_space, 1);
3501
3502 str = "{ [0,i,0,j,0] -> [i,j] : 0 <= i <= 10 and 0 <= j <= 10 }";
3504 ai = isl_access_info_add_source(ai, map, 1, &depth);
3505
3507 space = isl_space_alloc(ctx, 0, 5, 5);
3508 mm.must = isl_map_empty(isl_space_copy(space));
3509 mm.may = isl_map_empty(space);
3510
3512
3513 str = "{ [0,i,0,j,0] -> [1,i,0,0,0] : 0 <= i,j <= 10 }";
3515 str = "{ [0,0,0,0,0] -> [0,0,0,0,0] : 1 = 0 }";
3516 assert(map_is_equal(mm.may, str));
3517
3518 isl_map_free(mm.must);
3519 isl_map_free(mm.may);
3521
3522 return 0;
3523}
3524
3525/* Check that the dependence analysis proceeds without errors.
3526 * Earlier versions of isl would break down during the analysis
3527 * due to the use of the wrong spaces.
3528 */
3529static int test_flow(isl_ctx *ctx)
3530{
3531 const char *str;
3532 isl_union_map *access, *schedule;
3533 isl_union_map *must_dep, *may_dep;
3534 int r;
3535
3536 str = "{ S0[j] -> i[]; S1[j,i] -> i[]; S2[] -> i[]; S3[] -> i[] }";
3537 access = isl_union_map_read_from_str(ctx, str);
3538 str = "{ S0[j] -> [0,j,0,0] : 0 <= j < 10; "
3539 "S1[j,i] -> [0,j,1,i] : 0 <= j < i < 10; "
3540 "S2[] -> [1,0,0,0]; "
3541 "S3[] -> [-1,0,0,0] }";
3545 &must_dep, &may_dep, NULL, NULL);
3546 isl_union_map_free(may_dep);
3547 isl_union_map_free(must_dep);
3548
3549 return r;
3550}
3551
3552struct {
3553 const char *map;
3554 int sv;
3555} sv_tests[] = {
3556 { "[N] -> { [i] -> [f] : 0 <= i <= N and 0 <= i - 10 f <= 9 }", 1 },
3557 { "[N] -> { [i] -> [f] : 0 <= i <= N and 0 <= i - 10 f <= 10 }", 0 },
3558 { "{ [i] -> [3*floor(i/2) + 5*floor(i/3)] }", 1 },
3559 { "{ S1[i] -> [i] : 0 <= i <= 9; S2[i] -> [i] : 0 <= i <= 9 }", 1 },
3560 { "{ [i] -> S1[i] : 0 <= i <= 9; [i] -> S2[i] : 0 <= i <= 9 }", 0 },
3561 { "{ A[i] -> [i]; B[i] -> [i]; B[i] -> [i + 1] }", 0 },
3562 { "{ A[i] -> [i]; B[i] -> [i] : i < 0; B[i] -> [i + 1] : i > 0 }", 1 },
3563 { "{ A[i] -> [i]; B[i] -> A[i] : i < 0; B[i] -> [i + 1] : i > 0 }", 1 },
3564 { "{ A[i] -> [i]; B[i] -> [j] : i - 1 <= j <= i }", 0 },
3566
3568{
3569 isl_union_map *umap;
3570 int i;
3571 int sv;
3572
3573 for (i = 0; i < ARRAY_SIZE(sv_tests); ++i) {
3576 isl_union_map_free(umap);
3577 if (sv < 0)
3578 return -1;
3579 if (sv_tests[i].sv && !sv)
3581 "map not detected as single valued", return -1);
3582 if (!sv_tests[i].sv && sv)
3584 "map detected as single valued", return -1);
3585 }
3586
3587 return 0;
3588}
3589
3590struct {
3591 const char *str;
3593} bijective_tests[] = {
3594 { "[N,M]->{[i,j] -> [i]}", 0 },
3595 { "[N,M]->{[i,j] -> [i] : j=i}", 1 },
3596 { "[N,M]->{[i,j] -> [i] : j=0}", 1 },
3597 { "[N,M]->{[i,j] -> [i] : j=N}", 1 },
3598 { "[N,M]->{[i,j] -> [j,i]}", 1 },
3599 { "[N,M]->{[i,j] -> [i+j]}", 0 },
3600 { "[N,M]->{[i,j] -> []}", 0 },
3601 { "[N,M]->{[i,j] -> [i,j,N]}", 1 },
3602 { "[N,M]->{[i,j] -> [2i]}", 0 },
3603 { "[N,M]->{[i,j] -> [i,i]}", 0 },
3604 { "[N,M]->{[i,j] -> [2i,i]}", 0 },
3605 { "[N,M]->{[i,j] -> [2i,j]}", 1 },
3606 { "[N,M]->{[i,j] -> [x,y] : 2x=i & y =j}", 1 },
3608
3609static int test_bijective(struct isl_ctx *ctx)
3610{
3611 isl_map *map;
3612 int i;
3613 int bijective;
3614
3615 for (i = 0; i < ARRAY_SIZE(bijective_tests); ++i) {
3619 if (bijective < 0)
3620 return -1;
3623 "map not detected as bijective", return -1);
3626 "map detected as bijective", return -1);
3627 }
3628
3629 return 0;
3630}
3631
3632/* Inputs for isl_pw_qpolynomial_gist tests.
3633 * "pwqp" is the input, "set" is the context and "gist" is the expected result.
3634 */
3635struct {
3636 const char *pwqp;
3637 const char *set;
3638 const char *gist;
3639} pwqp_gist_tests[] = {
3640 { "{ [i] -> i }", "{ [k] : exists a : k = 2a }", "{ [i] -> i }" },
3641 { "{ [i] -> i + [ (i + [i/3])/2 ] }", "{ [10] }", "{ [i] -> 16 }" },
3642 { "{ [i] -> ([(i)/2]) }", "{ [k] : exists a : k = 2a+1 }",
3643 "{ [i] -> -1/2 + 1/2 * i }" },
3644 { "{ [i] -> i^2 : i != 0 }", "{ [i] : i != 0 }", "{ [i] -> i^2 }" },
3645 { "{ [i] -> i^2 : i > 0; [i] -> i^2 : i < 0 }", "{ [i] : i != 0 }",
3646 "{ [i] -> i^2 }" },
3648
3649/* Perform some basic isl_pw_qpolynomial_gist tests.
3650 */
3652{
3653 int i;
3654 const char *str;
3655 isl_set *set;
3656 isl_pw_qpolynomial *pwqp1, *pwqp2;
3658
3659 for (i = 0; i < ARRAY_SIZE(pwqp_gist_tests); ++i) {
3660 str = pwqp_gist_tests[i].pwqp;
3662 str = pwqp_gist_tests[i].set;
3664 pwqp1 = isl_pw_qpolynomial_gist(pwqp1, set);
3665 str = pwqp_gist_tests[i].gist;
3667 pwqp1 = isl_pw_qpolynomial_sub(pwqp1, pwqp2);
3670
3671 if (equal < 0)
3672 return isl_stat_error;
3673 if (!equal)
3675 "unexpected result", return isl_stat_error);
3676 }
3677
3678 return isl_stat_ok;
3679}
3680
3681/* Perform a basic isl_pw_qpolynomial_max test.
3682 */
3684{
3685 const char *str;
3687 isl_val *v;
3688 int ok;
3689
3690 str = "{ [x=2:9, y] -> floor((x + 1)/4)^3 - floor((2x)/3)^2 }";
3693 ok = isl_val_cmp_si(v, -1) == 0;
3694 isl_val_free(v);
3695
3696 if (!v)
3697 return isl_stat_error;
3698 if (!ok)
3699 isl_die(ctx, isl_error_unknown, "unexpected maximum",
3700 return isl_stat_error);
3701
3702 return isl_stat_ok;
3703}
3704
3705static int test_pwqp(struct isl_ctx *ctx)
3706{
3707 const char *str;
3708 isl_set *set;
3709 isl_pw_qpolynomial *pwqp1, *pwqp2;
3710 int equal;
3711
3712 str = "{ [i,j,k] -> 1 + 9 * [i/5] + 7 * [j/11] + 4 * [k/13] }";
3714
3716 isl_dim_in, 1, 1);
3717
3718 str = "[j] -> { [i,k] -> 1 + 9 * [i/5] + 7 * [j/11] + 4 * [k/13] }";
3720
3721 pwqp1 = isl_pw_qpolynomial_sub(pwqp1, pwqp2);
3722
3724
3726
3727 if (test_pwqp_gist(ctx) < 0)
3728 return -1;
3729
3730 str = "{ [i] -> ([([i/2] + [i/2])/5]) }";
3732 str = "{ [i] -> ([(2 * [i/2])/5]) }";
3734
3735 pwqp1 = isl_pw_qpolynomial_sub(pwqp1, pwqp2);
3736
3738
3740
3741 str = "{ [x] -> ([x/2] + [(x+1)/2]) }";
3743 str = "{ [x] -> x }";
3745
3746 pwqp1 = isl_pw_qpolynomial_sub(pwqp1, pwqp2);
3747
3749
3751
3752 str = "{ [i] -> ([i/2]) : i >= 0; [i] -> ([i/3]) : i < 0 }";
3755 pwqp1 = isl_pw_qpolynomial_coalesce(pwqp1);
3756 pwqp1 = isl_pw_qpolynomial_sub(pwqp1, pwqp2);
3759
3760 str = "{ [a,b,a] -> (([(2*[a/3]+b)/5]) * ([(2*[a/3]+b)/5])) }";
3762 str = "{ [a,b,c] -> (([(2*[a/3]+b)/5]) * ([(2*[c/3]+b)/5])) }";
3764 set = isl_set_read_from_str(ctx, "{ [a,b,a] }");
3769 if (equal < 0)
3770 return -1;
3771 if (!equal)
3772 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
3773
3774 str = "{ [a,b,c] -> (([(2*[a/3]+1)/5]) * ([(2*[c/3]+1)/5])) : b = 1 }";
3776 str = "{ [a,b,c] -> (([(2*[a/3]+b)/5]) * ([(2*[c/3]+b)/5])) }";
3778 pwqp1 = isl_pw_qpolynomial_fix_val(pwqp1, isl_dim_set, 1,
3779 isl_val_one(ctx));
3783 if (equal < 0)
3784 return -1;
3785 if (!equal)
3786 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
3787
3788 if (test_pwqp_max(ctx) < 0)
3789 return -1;
3790
3791 return 0;
3792}
3793
3795{
3796 const char *str;
3798
3799 str = "{ [U,V] -> 1/3 * U + 2/3 * V - [(U + 2V)/3] + [U/2] : "
3800 "U + 2V + 3 >= 0 and - U -2V >= 0 and - U + 10 >= 0 and "
3801 "U >= 0; [U,V] -> U^2 : U >= 100 }";
3803
3805
3807
3808 if (!pwqp)
3809 return -1;
3810
3811 return 0;
3812}
3813
3814static int test_union(isl_ctx *ctx)
3815{
3816 const char *str;
3817 isl_union_set *uset1, *uset2;
3818 isl_union_map *umap1, *umap2;
3819 int equal;
3820
3821 str = "{ [i] : 0 <= i <= 1 }";
3822 uset1 = isl_union_set_read_from_str(ctx, str);
3823 str = "{ [1] -> [0] }";
3824 umap1 = isl_union_map_read_from_str(ctx, str);
3825
3827 equal = isl_union_map_is_equal(umap1, umap2);
3828
3829 isl_union_map_free(umap1);
3830 isl_union_map_free(umap2);
3831
3832 if (equal < 0)
3833 return -1;
3834 if (!equal)
3835 isl_die(ctx, isl_error_unknown, "union maps not equal",
3836 return -1);
3837
3838 str = "{ A[i] -> B[i]; B[i] -> C[i]; A[0] -> C[1] }";
3839 umap1 = isl_union_map_read_from_str(ctx, str);
3840 str = "{ A[i]; B[i] }";
3841 uset1 = isl_union_set_read_from_str(ctx, str);
3842
3843 uset2 = isl_union_map_domain(umap1);
3844
3845 equal = isl_union_set_is_equal(uset1, uset2);
3846
3847 isl_union_set_free(uset1);
3848 isl_union_set_free(uset2);
3849
3850 if (equal < 0)
3851 return -1;
3852 if (!equal)
3853 isl_die(ctx, isl_error_unknown, "union sets not equal",
3854 return -1);
3855
3856 return 0;
3857}
3858
3859/* Inputs for basic isl_pw_qpolynomial_bound tests.
3860 * "type" is the type of bound that should be computed.
3861 * "poly" is a string representation of the input.
3862 * "bound" is a string representation of the expected result.
3863 * "tight" is set if the result is expected to be tight.
3864 */
3865static struct {
3868 const char *poly;
3869 const char *bound;
3870} bound_tests[] = {
3871 /* Check that computing a bound of a non-zero polynomial
3872 * over an unbounded domain does not produce a rational value.
3873 * In particular, check that the upper bound is infinity.
3874 */
3875 { 0, isl_fold_max, "{ [m, n] -> -m * n }", "{ max(infty) }" },
3876 { 1, isl_fold_max, "{ [[a, b, c, d] -> [e]] -> 0 }",
3877 "{ [a, b, c, d] -> max(0) }" },
3878 { 1, isl_fold_max, "{ [[x] -> [x]] -> 1 : exists a : x = 2 a }",
3879 "{ [x] -> max(1) : x mod 2 = 0 }" },
3880 { 1, isl_fold_min, "{ [x=5:10] -> (x + 2)^2 }", "{ min(49) }" },
3881 { 1, isl_fold_max, "{ [0:10] -> 1 }", "{ max(1) }" },
3882 { 1, isl_fold_max, "{ [[m] -> [0:m]] -> m^2 }",
3883 "{ [m] -> max(m^2) : m >= 0 }" },
3884 { 1, isl_fold_max, "{ [[a=0:1] -> [b=0:1]] -> (floor((a + b)/2)) }",
3885 "{ [a=0:1] -> max(a) }" },
3887
3888/* Check that the bound computation can handle differences
3889 * in domain dimension names of the input polynomial and its domain.
3890 */
3892{
3893 const char *str;
3894 isl_set *set;
3897
3898 str = "{ [[c] -> [c]] }";
3900 str = "{ [[a] -> [b]] -> 1 }";
3905
3906 return isl_stat_non_null(pwf);
3907}
3908
3909/* Perform basic isl_pw_qpolynomial_bound tests.
3910 */
3911static int test_bound(isl_ctx *ctx)
3912{
3913 int i;
3914
3915 if (test_bound_space(ctx) < 0)
3916 return -1;
3917
3918 for (i = 0; i < ARRAY_SIZE(bound_tests); ++i) {
3919 const char *str;
3920 enum isl_fold type;
3923 isl_pw_qpolynomial_fold *pwf1, *pwf2;
3924
3925 str = bound_tests[i].poly;
3927 type = bound_tests[i].type;
3929 str = bound_tests[i].bound;
3934 if (equal < 0)
3935 return -1;
3936 if (!equal)
3938 "incorrect bound result", return -1);
3939 if (bound_tests[i].tight && !tight)
3941 "bound unexpectedly not tight", return -1);
3942 }
3943
3944 return 0;
3945}
3946
3947/* isl_set is defined to isl_map internally, so the corresponding elements
3948 * are isl_basic_map objects.
3949 */
3950#undef EL_BASE
3951#undef SET_BASE
3952#define EL_BASE basic_map
3953#define SET_BASE set
3954#include "isl_test_list_templ.c"
3955
3956#undef EL_BASE
3957#undef SET_BASE
3958#define EL_BASE basic_set
3959#define SET_BASE union_set
3960#include "isl_test_list_templ.c"
3961
3962#undef EL_BASE
3963#undef SET_BASE
3964#define EL_BASE set
3965#define SET_BASE union_set
3966#include "isl_test_list_templ.c"
3967
3968#undef EL_BASE
3969#undef SET_BASE
3970#define EL_BASE basic_map
3971#define SET_BASE map
3972#include "isl_test_list_templ.c"
3973
3974#undef EL_BASE
3975#undef SET_BASE
3976#define EL_BASE map
3977#define SET_BASE union_map
3978#include "isl_test_list_templ.c"
3979
3980/* Check that the conversion from isl objects to lists works as expected.
3981 */
3982static int test_get_list(isl_ctx *ctx)
3983{
3984 if (test_get_list_basic_map_from_set(ctx, "{ [0]; [2]; [3] }"))
3985 return -1;
3986 if (test_get_list_basic_set_from_union_set(ctx, "{ A[0]; B[2]; B[3] }"))
3987 return -1;
3988 if (test_get_list_set_from_union_set(ctx, "{ A[0]; A[2]; B[3] }"))
3989 return -1;
3990 if (test_get_list_basic_map_from_map(ctx,
3991 "{ [0] -> [0]; [2] -> [0]; [3] -> [0] }"))
3992 return -1;
3993 if (test_get_list_map_from_union_map(ctx,
3994 "{ A[0] -> [0]; A[2] -> [0]; B[3] -> [0] }"))
3995 return -1;
3996
3997 return 0;
3998}
3999
4000static int test_lift(isl_ctx *ctx)
4001{
4002 const char *str;
4003 isl_basic_map *bmap;
4004 isl_basic_set *bset;
4005
4006 str = "{ [i0] : exists e0 : i0 = 4e0 }";
4007 bset = isl_basic_set_read_from_str(ctx, str);
4008 bset = isl_basic_set_lift(bset);
4009 bmap = isl_basic_map_from_range(bset);
4010 bset = isl_basic_map_domain(bmap);
4011 isl_basic_set_free(bset);
4012
4013 return 0;
4014}
4015
4016/* Check that isl_set_is_subset is not confused by identical
4017 * integer divisions.
4018 * The call to isl_set_normalize ensures that the equality constraints
4019 * a = b = 0 are discovered, turning e0 and e1 into identical
4020 * integer divisions. Any further simplification would remove
4021 * the duplicate integer divisions.
4022 */
4024{
4025 const char *str;
4026 isl_bool is_subset;
4027 isl_set *set1, *set2;
4028
4029 str = "{ [a, b, c, d] : "
4030 "exists (e0 = floor((a + d)/4), e1 = floor((d)/4), "
4031 "e2 = floor((-a - d + 4 *floor((a + d)/4))/10), "
4032 "e3 = floor((-d + 4*floor((d)/4))/10): "
4033 "10e2 = -a - 2c - d + 4e0 and 10e3 = -2c - d + 4e1 and "
4034 "b >= 0 and a <= 0 and b <= a) }";
4038
4039 is_subset = isl_set_is_subset(set1, set2);
4040
4043
4044 if (is_subset < 0)
4045 return isl_stat_error;
4046 if (!is_subset)
4048 "set is not considered to be a subset of itself",
4049 return isl_stat_error);
4050
4051 return isl_stat_ok;
4052}
4053
4054struct {
4055 const char *set1;
4056 const char *set2;
4058} subset_tests[] = {
4059 { "{ [112, 0] }",
4060 "{ [i0, i1] : exists (e0 = [(i0 - i1)/16], e1: "
4061 "16e0 <= i0 - i1 and 16e0 >= -15 + i0 - i1 and "
4062 "16e1 <= i1 and 16e0 >= -i1 and 16e1 >= -i0 + i1) }", 1 },
4063 { "{ [65] }",
4064 "{ [i] : exists (e0 = [(255i)/256], e1 = [(127i + 65e0)/191], "
4065 "e2 = [(3i + 61e1)/65], e3 = [(52i + 12e2)/61], "
4066 "e4 = [(2i + e3)/3], e5 = [(4i + e3)/4], e6 = [(8i + e3)/12]: "
4067 "3e4 = 2i + e3 and 4e5 = 4i + e3 and 12e6 = 8i + e3 and "
4068 "i <= 255 and 64e3 >= -45 + 67i and i >= 0 and "
4069 "256e0 <= 255i and 256e0 >= -255 + 255i and "
4070 "191e1 <= 127i + 65e0 and 191e1 >= -190 + 127i + 65e0 and "
4071 "65e2 <= 3i + 61e1 and 65e2 >= -64 + 3i + 61e1 and "
4072 "61e3 <= 52i + 12e2 and 61e3 >= -60 + 52i + 12e2) }", 1 },
4073 { "{ [i] : 0 <= i <= 10 }", "{ rat: [i] : 0 <= i <= 10 }", 1 },
4074 { "{ rat: [i] : 0 <= i <= 10 }", "{ [i] : 0 <= i <= 10 }", 0 },
4075 { "{ rat: [0] }", "{ [i] : 0 <= i <= 10 }", 1 },
4076 { "{ rat: [(1)/2] }", "{ [i] : 0 <= i <= 10 }", 0 },
4077 { "{ [t, i] : (exists (e0 = [(2 + t)/4]: 4e0 <= 2 + t and "
4078 "4e0 >= -1 + t and i >= 57 and i <= 62 and "
4079 "4e0 <= 62 + t - i and 4e0 >= -61 + t + i and "
4080 "t >= 0 and t <= 511 and 4e0 <= -57 + t + i and "
4081 "4e0 >= 58 + t - i and i >= 58 + t and i >= 62 - t)) }",
4082 "{ [i0, i1] : (exists (e0 = [(4 + i0)/4]: 4e0 <= 62 + i0 - i1 and "
4083 "4e0 >= 1 + i0 and i0 >= 0 and i0 <= 511 and "
4084 "4e0 <= -57 + i0 + i1)) or "
4085 "(exists (e0 = [(2 + i0)/4]: 4e0 <= i0 and "
4086 "4e0 >= 58 + i0 - i1 and i0 >= 2 and i0 <= 511 and "
4087 "4e0 >= -61 + i0 + i1)) or "
4088 "(i1 <= 66 - i0 and i0 >= 2 and i1 >= 59 + i0) }", 1 },
4089 { "[a, b] -> { : a = 0 and b = -1 }", "[b, a] -> { : b >= -10 }", 1 },
4091
4092static int test_subset(isl_ctx *ctx)
4093{
4094 int i;
4095 isl_set *set1, *set2;
4096 int subset;
4097
4099 return -1;
4100
4101 for (i = 0; i < ARRAY_SIZE(subset_tests); ++i) {
4107 if (subset < 0)
4108 return -1;
4109 if (subset != subset_tests[i].subset)
4111 "incorrect subset result", return -1);
4112 }
4113
4114 return 0;
4115}
4116
4117/* Perform a set subtraction with a set that has a non-obviously empty disjunct.
4118 * Older versions of isl would fail on such cases.
4119 */
4121{
4122 const char *str;
4123 isl_set *s1, *s2;
4124
4125 s1 = isl_set_read_from_str(ctx, "{ [0] }");
4126 str = "{ [a] : (exists (e0, e1, e2: 1056e1 <= 32 + a - 33e0 and "
4127 "1089e1 >= a - 33e0 and 1089e1 <= 1 + a - 33e0 and "
4128 "33e2 >= -a + 33e0 + 1056e1 and "
4129 "33e2 < -2a + 66e0 + 2112e1)) or a = 0 }";
4130 s2 = isl_set_read_from_str(ctx, str);
4131 s1 = isl_set_subtract(s1, s2);
4132 isl_set_free(s1);
4133
4134 return isl_stat_non_null(s1);
4135}
4136
4137struct {
4138 const char *minuend;
4139 const char *subtrahend;
4140 const char *difference;
4142 { "{ A[i] -> B[i] }", "{ A[i] }", "{ }" },
4143 { "{ A[i] -> B[i] }", "{ B[i] }", "{ A[i] -> B[i] }" },
4144 { "{ A[i] -> B[i] }", "{ A[i] : i > 0 }", "{ A[i] -> B[i] : i <= 0 }" },
4146
4147static int test_subtract(isl_ctx *ctx)
4148{
4149 int i;
4150 isl_union_map *umap1, *umap2;
4151 isl_union_pw_multi_aff *upma1, *upma2;
4152 isl_union_set *uset;
4153 int equal;
4154
4155 if (test_subtract_empty(ctx) < 0)
4156 return -1;
4157
4158 for (i = 0; i < ARRAY_SIZE(subtract_domain_tests); ++i) {
4159 umap1 = isl_union_map_read_from_str(ctx,
4161 uset = isl_union_set_read_from_str(ctx,
4163 umap2 = isl_union_map_read_from_str(ctx,
4165 umap1 = isl_union_map_subtract_domain(umap1, uset);
4166 equal = isl_union_map_is_equal(umap1, umap2);
4167 isl_union_map_free(umap1);
4168 isl_union_map_free(umap2);
4169 if (equal < 0)
4170 return -1;
4171 if (!equal)
4173 "incorrect subtract domain result", return -1);
4174 }
4175
4176 for (i = 0; i < ARRAY_SIZE(subtract_domain_tests); ++i) {
4179 uset = isl_union_set_read_from_str(ctx,
4183 upma1 = isl_union_pw_multi_aff_subtract_domain(upma1, uset);
4187 if (equal < 0)
4188 return -1;
4189 if (!equal)
4191 "incorrect subtract domain result", return -1);
4192 }
4193
4194 return 0;
4195}
4196
4197/* Check that intersecting the empty basic set with another basic set
4198 * does not increase the number of constraints. In particular,
4199 * the empty basic set should maintain its canonical representation.
4200 */
4202{
4203 isl_size n1, n2;
4204 isl_basic_set *bset1, *bset2;
4205
4206 bset1 = isl_basic_set_read_from_str(ctx, "{ [a,b,c] : 1 = 0 }");
4207 bset2 = isl_basic_set_read_from_str(ctx, "{ [1,2,3] }");
4208 n1 = isl_basic_set_n_constraint(bset1);
4209 bset1 = isl_basic_set_intersect(bset1, bset2);
4210 n2 = isl_basic_set_n_constraint(bset1);
4211 isl_basic_set_free(bset1);
4212 if (n1 < 0 || n2 < 0)
4213 return -1;
4214 if (n1 != n2)
4216 "number of constraints of empty set changed",
4217 return -1);
4218
4219 return 0;
4220}
4221
4222/* Check that intersecting a set with itself does not cause
4223 * an explosion in the number of disjuncts.
4224 */
4226{
4227 int i;
4228 isl_set *set;
4229
4230 set = isl_set_read_from_str(ctx, "{ [x,y] : x >= 0 or y >= 0 }");
4231 for (i = 0; i < 100; ++i)
4234 if (!set)
4235 return isl_stat_error;
4236 return isl_stat_ok;
4237}
4238
4239/* Perform some intersection tests.
4240 */
4241static int test_intersect(isl_ctx *ctx)
4242{
4243 if (test_intersect_1(ctx) < 0)
4244 return -1;
4245 if (test_intersect_2(ctx) < 0)
4246 return -1;
4247
4248 return 0;
4249}
4250
4252{
4253 const char *str;
4254 isl_basic_set *bset;
4256
4257 str = "{ [i0, i1, i2, i3, i4, i5, i6, i7] : 3i5 <= 2 - 2i0 and "
4258 "i0 >= -2 and i6 >= 1 + i3 and i7 >= 0 and 3i5 >= -2i0 and "
4259 "2i4 <= i2 and i6 >= 1 + 2i0 + 3i1 and i4 <= -1 and "
4260 "i6 >= 1 + 2i0 + 3i5 and i6 <= 2 + 2i0 + 3i5 and "
4261 "3i5 <= 2 - 2i0 - i2 + 3i4 and i6 <= 2 + 2i0 + 3i1 and "
4262 "i0 <= -1 and i7 <= i2 + i3 - 3i4 - i6 and "
4263 "3i5 >= -2i0 - i2 + 3i4 }";
4264 bset = isl_basic_set_read_from_str(ctx, str);
4266 isl_basic_set_free(bset);
4268 if (!f)
4270 "failed to construct factorizer", return -1);
4271
4272 str = "{ [i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12] : "
4273 "i12 <= 2 + i0 - i11 and 2i8 >= -i4 and i11 >= i1 and "
4274 "3i5 <= -i2 and 2i11 >= -i4 - 2i7 and i11 <= 3 + i0 + 3i9 and "
4275 "i11 <= -i4 - 2i7 and i12 >= -i10 and i2 >= -2 and "
4276 "i11 >= i1 + 3i10 and i11 >= 1 + i0 + 3i9 and "
4277 "i11 <= 1 - i4 - 2i8 and 6i6 <= 6 - i2 and 3i6 >= 1 - i2 and "
4278 "i11 <= 2 + i1 and i12 <= i4 + i11 and i12 >= i0 - i11 and "
4279 "3i5 >= -2 - i2 and i12 >= -1 + i4 + i11 and 3i3 <= 3 - i2 and "
4280 "9i6 <= 11 - i2 + 6i5 and 3i3 >= 1 - i2 and "
4281 "9i6 <= 5 - i2 + 6i3 and i12 <= -1 and i2 <= 0 }";
4282 bset = isl_basic_set_read_from_str(ctx, str);
4284 isl_basic_set_free(bset);
4286 if (!f)
4288 "failed to construct factorizer", return -1);
4289
4290 return 0;
4291}
4292
4294{
4295 int *injective = user;
4296
4297 *injective = isl_map_is_injective(map);
4299
4300 if (*injective < 0 || !*injective)
4301 return isl_stat_error;
4302
4303 return isl_stat_ok;
4304}
4305
4306int test_one_schedule(isl_ctx *ctx, const char *d, const char *w,
4307 const char *r, const char *s, int tilable, int parallel)
4308{
4309 int i;
4310 isl_union_set *D;
4311 isl_union_map *W, *R, *S;
4312 isl_union_map *empty;
4313 isl_union_map *dep_raw, *dep_war, *dep_waw, *dep;
4314 isl_union_map *validity, *proximity, *coincidence;
4317 isl_union_set *delta;
4319 isl_set *delta_set;
4320 isl_set *slice;
4321 isl_set *origin;
4323 isl_schedule *sched;
4324 int is_nonneg, is_parallel, is_tilable, is_injection, is_complete;
4325 isl_size n;
4326
4327 D = isl_union_set_read_from_str(ctx, d);
4328 W = isl_union_map_read_from_str(ctx, w);
4329 R = isl_union_map_read_from_str(ctx, r);
4331
4334
4337 isl_union_map_copy(W), empty,
4339 &dep_raw, NULL, NULL, NULL);
4344 &dep_waw, &dep_war, NULL, NULL);
4345
4346 dep = isl_union_map_union(dep_waw, dep_war);
4347 dep = isl_union_map_union(dep, dep_raw);
4348 validity = isl_union_map_copy(dep);
4349 coincidence = isl_union_map_copy(dep);
4350 proximity = isl_union_map_copy(dep);
4351
4353 sc = isl_schedule_constraints_set_validity(sc, validity);
4354 sc = isl_schedule_constraints_set_coincidence(sc, coincidence);
4355 sc = isl_schedule_constraints_set_proximity(sc, proximity);
4358 isl_schedule_free(sched);
4362
4363 is_injection = 1;
4365
4367 is_complete = isl_union_set_is_subset(D, domain);
4370
4374
4375 delta = isl_union_map_deltas(test);
4376 n = isl_union_set_n_set(delta);
4377 if (n < 0) {
4378 isl_union_set_free(delta);
4379 return -1;
4380 }
4381 if (n == 0) {
4382 is_tilable = 1;
4383 is_parallel = 1;
4384 is_nonneg = 1;
4385 isl_union_set_free(delta);
4386 } else {
4387 isl_size dim;
4388
4389 delta_set = isl_set_from_union_set(delta);
4390
4391 slice = isl_set_universe(isl_set_get_space(delta_set));
4392 for (i = 0; i < tilable; ++i)
4393 slice = isl_set_lower_bound_si(slice, isl_dim_set, i, 0);
4394 is_tilable = isl_set_is_subset(delta_set, slice);
4395 isl_set_free(slice);
4396
4397 slice = isl_set_universe(isl_set_get_space(delta_set));
4398 for (i = 0; i < parallel; ++i)
4399 slice = isl_set_fix_si(slice, isl_dim_set, i, 0);
4400 is_parallel = isl_set_is_subset(delta_set, slice);
4401 isl_set_free(slice);
4402
4403 origin = isl_set_universe(isl_set_get_space(delta_set));
4404 dim = isl_set_dim(origin, isl_dim_set);
4405 if (dim < 0)
4406 origin = isl_set_free(origin);
4407 for (i = 0; i < dim; ++i)
4408 origin = isl_set_fix_si(origin, isl_dim_set, i, 0);
4409
4410 delta_set = isl_set_union(delta_set, isl_set_copy(origin));
4411 delta_set = isl_set_lexmin(delta_set);
4412
4413 is_nonneg = isl_set_is_equal(delta_set, origin);
4414
4415 isl_set_free(origin);
4416 isl_set_free(delta_set);
4417 }
4418
4419 if (is_nonneg < 0 || is_parallel < 0 || is_tilable < 0 ||
4420 is_injection < 0 || is_complete < 0)
4421 return -1;
4422 if (!is_complete)
4424 "generated schedule incomplete", return -1);
4425 if (!is_injection)
4427 "generated schedule not injective on each statement",
4428 return -1);
4429 if (!is_nonneg)
4431 "negative dependences in generated schedule",
4432 return -1);
4433 if (!is_tilable)
4435 "generated schedule not as tilable as expected",
4436 return -1);
4437 if (!is_parallel)
4439 "generated schedule not as parallel as expected",
4440 return -1);
4441
4442 return 0;
4443}
4444
4445/* Compute a schedule for the given instance set, validity constraints,
4446 * proximity constraints and context and return a corresponding union map
4447 * representation.
4448 */
4450 const char *domain, const char *validity, const char *proximity,
4451 const char *context)
4452{
4453 isl_set *con;
4454 isl_union_set *dom;
4455 isl_union_map *dep;
4456 isl_union_map *prox;
4459 isl_union_map *sched;
4460
4461 con = isl_set_read_from_str(ctx, context);
4463 dep = isl_union_map_read_from_str(ctx, validity);
4464 prox = isl_union_map_read_from_str(ctx, proximity);
4472
4473 return sched;
4474}
4475
4476/* Compute a schedule for the given instance set, validity constraints and
4477 * proximity constraints and return a corresponding union map representation.
4478 */
4480 const char *domain, const char *validity, const char *proximity)
4481{
4482 return compute_schedule_with_context(ctx, domain, validity, proximity,
4483 "{ : }");
4484}
4485
4486/* Check that a schedule can be constructed on the given domain
4487 * with the given validity and proximity constraints.
4488 */
4489static int test_has_schedule(isl_ctx *ctx, const char *domain,
4490 const char *validity, const char *proximity)
4491{
4492 isl_union_map *sched;
4493
4494 sched = compute_schedule(ctx, domain, validity, proximity);
4495 if (!sched)
4496 return -1;
4497
4498 isl_union_map_free(sched);
4499 return 0;
4500}
4501
4503 const char *validity, const char *proximity, const char *expected_sched)
4504{
4505 isl_union_map *sched1, *sched2;
4506 int equal;
4507
4508 sched1 = compute_schedule(ctx, domain, validity, proximity);
4509 sched2 = isl_union_map_read_from_str(ctx, expected_sched);
4510
4511 equal = isl_union_map_is_equal(sched1, sched2);
4512 isl_union_map_free(sched1);
4513 isl_union_map_free(sched2);
4514
4515 if (equal < 0)
4516 return -1;
4517 if (!equal)
4518 isl_die(ctx, isl_error_unknown, "unexpected schedule",
4519 return -1);
4520
4521 return 0;
4522}
4523
4524/* Check that the schedule map is properly padded, i.e., that the range
4525 * lives in a single space.
4526 */
4528{
4529 const char *str;
4530 isl_union_set *D;
4531 isl_union_map *validity, *proximity;
4533 isl_schedule *sched;
4534 isl_union_map *umap;
4536 isl_set *set;
4537
4538 str = "[N] -> { S0[i] : 0 <= i <= N; S1[i, j] : 0 <= i, j <= N }";
4541 proximity = isl_union_map_copy(validity);
4543 sc = isl_schedule_constraints_set_validity(sc, validity);
4544 sc = isl_schedule_constraints_set_proximity(sc, proximity);
4546 umap = isl_schedule_get_map(sched);
4547 isl_schedule_free(sched);
4548 range = isl_union_map_range(umap);
4551
4552 if (!set)
4553 return -1;
4554
4555 return 0;
4556}
4557
4558/* Check that conditional validity constraints are also taken into
4559 * account across bands.
4560 * In particular, try to make sure that live ranges D[1,0]->C[2,1] and
4561 * D[2,0]->C[3,0] are not local in the outer band of the generated schedule
4562 * and then check that the adjacent order constraint C[2,1]->D[2,0]
4563 * is enforced by the rest of the schedule.
4564 */
4566{
4567 const char *str;
4569 isl_union_map *validity, *proximity, *condition;
4570 isl_union_map *sink, *source, *dep;
4573 isl_union_access_info *access;
4575 int empty;
4576
4577 str = "[n] -> { C[k, i] : k <= -1 + n and i >= 0 and i <= -1 + k; "
4578 "A[k] : k >= 1 and k <= -1 + n; "
4579 "B[k, i] : k <= -1 + n and i >= 0 and i <= -1 + k; "
4580 "D[k, i] : k <= -1 + n and i >= 0 and i <= -1 + k }";
4583 str = "[n] -> { D[k, i] -> C[1 + k, k - i] : "
4584 "k <= -2 + n and i >= 1 and i <= -1 + k; "
4585 "D[k, i] -> C[1 + k, i] : "
4586 "k <= -2 + n and i >= 1 and i <= -1 + k; "
4587 "D[k, 0] -> C[1 + k, k] : k >= 1 and k <= -2 + n; "
4588 "D[k, 0] -> C[1 + k, 0] : k >= 1 and k <= -2 + n }";
4589 validity = isl_union_map_read_from_str(ctx, str);
4590 sc = isl_schedule_constraints_set_validity(sc, validity);
4591 str = "[n] -> { C[k, i] -> D[k, i] : "
4592 "0 <= i <= -1 + k and k <= -1 + n }";
4593 proximity = isl_union_map_read_from_str(ctx, str);
4594 sc = isl_schedule_constraints_set_proximity(sc, proximity);
4595 str = "[n] -> { [D[k, i] -> a[]] -> [C[1 + k, k - i] -> b[]] : "
4596 "i <= -1 + k and i >= 1 and k <= -2 + n; "
4597 "[B[k, i] -> c[]] -> [B[k, 1 + i] -> c[]] : "
4598 "k <= -1 + n and i >= 0 and i <= -2 + k }";
4600 str = "[n] -> { [B[k, i] -> e[]] -> [D[k, i] -> a[]] : "
4601 "i >= 0 and i <= -1 + k and k <= -1 + n; "
4602 "[C[k, i] -> b[]] -> [D[k', -1 + k - i] -> a[]] : "
4603 "i >= 0 and i <= -1 + k and k <= -1 + n and "
4604 "k' <= -1 + n and k' >= k - i and k' >= 1 + k; "
4605 "[C[k, i] -> b[]] -> [D[k, -1 + k - i] -> a[]] : "
4606 "i >= 0 and i <= -1 + k and k <= -1 + n; "
4607 "[B[k, i] -> c[]] -> [A[k'] -> d[]] : "
4608 "k <= -1 + n and i >= 0 and i <= -1 + k and "
4609 "k' >= 1 and k' <= -1 + n and k' >= 1 + k }";
4610 validity = isl_union_map_read_from_str(ctx, str);
4612 validity);
4614 str = "{ D[2,0] -> [] }";
4615 sink = isl_union_map_read_from_str(ctx, str);
4616 access = isl_union_access_info_from_sink(sink);
4617 str = "{ C[2,1] -> [] }";
4618 source = isl_union_map_read_from_str(ctx, str);
4619 access = isl_union_access_info_set_must_source(access, source);
4624 empty = isl_union_map_is_empty(dep);
4625 isl_union_map_free(dep);
4626
4627 if (empty < 0)
4628 return -1;
4629 if (empty)
4631 "conditional validity not respected", return -1);
4632
4633 return 0;
4634}
4635
4636/* Check that the test for violated conditional validity constraints
4637 * is not confused by domain compression.
4638 * In particular, earlier versions of isl would apply
4639 * a schedule on the compressed domains to the original domains,
4640 * resulting in a failure to detect that the default schedule
4641 * violates the conditional validity constraints.
4642 */
4644{
4645 const char *str;
4646 isl_bool empty;
4648 isl_union_map *validity, *condition;
4651 isl_union_map *umap;
4652 isl_map *map, *ge;
4653
4654 str = "{ A[0, i] : 0 <= i <= 10; B[1, i] : 0 <= i <= 10 }";
4657 str = "{ B[1, i] -> A[0, i + 1] }";
4659 str = "{ A[0, i] -> B[1, i - 1] }";
4660 validity = isl_union_map_read_from_str(ctx, str);
4662 isl_union_map_copy(validity));
4666 validity = isl_union_map_apply_domain(validity,
4667 isl_union_map_copy(umap));
4668 validity = isl_union_map_apply_range(validity, umap);
4669 map = isl_map_from_union_map(validity);
4671 map = isl_map_intersect(map, ge);
4672 empty = isl_map_is_empty(map);
4674
4675 if (empty < 0)
4676 return -1;
4677 if (!empty)
4679 "conditional validity constraints not satisfied",
4680 return -1);
4681
4682 return 0;
4683}
4684
4685/* Input for testing of schedule construction based on
4686 * conditional constraints.
4687 *
4688 * domain is the iteration domain
4689 * flow are the flow dependences, which determine the validity and
4690 * proximity constraints
4691 * condition are the conditions on the conditional validity constraints
4692 * conditional_validity are the conditional validity constraints
4693 * outer_band_n is the expected number of members in the outer band
4694 */
4695struct {
4696 const char *domain;
4697 const char *flow;
4698 const char *condition;
4701} live_range_tests[] = {
4702 /* Contrived example that illustrates that we need to keep
4703 * track of tagged condition dependences and
4704 * tagged conditional validity dependences
4705 * in isl_sched_edge separately.
4706 * In particular, the conditional validity constraints on A
4707 * cannot be satisfied,
4708 * but they can be ignored because there are no corresponding
4709 * condition constraints. However, we do have an additional
4710 * conditional validity constraint that maps to the same
4711 * dependence relation
4712 * as the condition constraint on B. If we did not make a distinction
4713 * between tagged condition and tagged conditional validity
4714 * dependences, then we
4715 * could end up treating this shared dependence as an condition
4716 * constraint on A, forcing a localization of the conditions,
4717 * which is impossible.
4718 */
4719 { "{ S[i] : 0 <= 1 < 100; T[i] : 0 <= 1 < 100 }",
4720 "{ S[i] -> S[i+1] : 0 <= i < 99 }",
4721 "{ [S[i] -> B[]] -> [S[i+1] -> B[]] : 0 <= i < 99 }",
4722 "{ [S[i] -> A[]] -> [T[i'] -> A[]] : 0 <= i', i < 100 and i != i';"
4723 "[T[i] -> A[]] -> [S[i'] -> A[]] : 0 <= i', i < 100 and i != i';"
4724 "[S[i] -> A[]] -> [S[i+1] -> A[]] : 0 <= i < 99 }",
4725 1
4726 },
4727 /* TACO 2013 Fig. 7 */
4728 { "[n] -> { S1[i,j] : 0 <= i,j < n; S2[i,j] : 0 <= i,j < n }",
4729 "[n] -> { S1[i,j] -> S2[i,j] : 0 <= i,j < n;"
4730 "S2[i,j] -> S2[i,j+1] : 0 <= i < n and 0 <= j < n - 1 }",
4731 "[n] -> { [S1[i,j] -> t[]] -> [S2[i,j] -> t[]] : 0 <= i,j < n;"
4732 "[S2[i,j] -> x1[]] -> [S2[i,j+1] -> x1[]] : "
4733 "0 <= i < n and 0 <= j < n - 1 }",
4734 "[n] -> { [S2[i,j] -> t[]] -> [S1[i,j'] -> t[]] : "
4735 "0 <= i < n and 0 <= j < j' < n;"
4736 "[S2[i,j] -> t[]] -> [S1[i',j'] -> t[]] : "
4737 "0 <= i < i' < n and 0 <= j,j' < n;"
4738 "[S2[i,j] -> x1[]] -> [S2[i,j'] -> x1[]] : "
4739 "0 <= i,j,j' < n and j < j' }",
4740 2
4741 },
4742 /* TACO 2013 Fig. 7, without tags */
4743 { "[n] -> { S1[i,j] : 0 <= i,j < n; S2[i,j] : 0 <= i,j < n }",
4744 "[n] -> { S1[i,j] -> S2[i,j] : 0 <= i,j < n;"
4745 "S2[i,j] -> S2[i,j+1] : 0 <= i < n and 0 <= j < n - 1 }",
4746 "[n] -> { S1[i,j] -> S2[i,j] : 0 <= i,j < n;"
4747 "S2[i,j] -> S2[i,j+1] : 0 <= i < n and 0 <= j < n - 1 }",
4748 "[n] -> { S2[i,j] -> S1[i,j'] : 0 <= i < n and 0 <= j < j' < n;"
4749 "S2[i,j] -> S1[i',j'] : 0 <= i < i' < n and 0 <= j,j' < n;"
4750 "S2[i,j] -> S2[i,j'] : 0 <= i,j,j' < n and j < j' }",
4751 1
4752 },
4753 /* TACO 2013 Fig. 12 */
4754 { "{ S1[i,0] : 0 <= i <= 1; S2[i,j] : 0 <= i <= 1 and 1 <= j <= 2;"
4755 "S3[i,3] : 0 <= i <= 1 }",
4756 "{ S1[i,0] -> S2[i,1] : 0 <= i <= 1;"
4757 "S2[i,1] -> S2[i,2] : 0 <= i <= 1;"
4758 "S2[i,2] -> S3[i,3] : 0 <= i <= 1 }",
4759 "{ [S1[i,0]->t[]] -> [S2[i,1]->t[]] : 0 <= i <= 1;"
4760 "[S2[i,1]->t[]] -> [S2[i,2]->t[]] : 0 <= i <= 1;"
4761 "[S2[i,2]->t[]] -> [S3[i,3]->t[]] : 0 <= i <= 1 }",
4762 "{ [S2[i,1]->t[]] -> [S2[i,2]->t[]] : 0 <= i <= 1;"
4763 "[S2[0,j]->t[]] -> [S2[1,j']->t[]] : 1 <= j,j' <= 2;"
4764 "[S2[0,j]->t[]] -> [S1[1,0]->t[]] : 1 <= j <= 2;"
4765 "[S3[0,3]->t[]] -> [S2[1,j]->t[]] : 1 <= j <= 2;"
4766 "[S3[0,3]->t[]] -> [S1[1,0]->t[]] }",
4767 1
4768 }
4770
4771/* Test schedule construction based on conditional constraints.
4772 * In particular, check the number of members in the outer band node
4773 * as an indication of whether tiling is possible or not.
4774 */
4776{
4777 int i;
4781 isl_union_map *validity;
4784 isl_schedule_node *node;
4785 isl_size n_member;
4786
4788 return -1;
4790 return -1;
4791
4792 for (i = 0; i < ARRAY_SIZE(live_range_tests); ++i) {
4799 validity = isl_union_map_read_from_str(ctx,
4806 condition, validity);
4809 while (node &&
4811 node = isl_schedule_node_first_child(node);
4812 n_member = isl_schedule_node_band_n_member(node);
4815
4816 if (!schedule || n_member < 0)
4817 return -1;
4818 if (n_member != live_range_tests[i].outer_band_n)
4820 "unexpected number of members in outer band",
4821 return -1);
4822 }
4823 return 0;
4824}
4825
4826/* Check that the schedule computed for the given instance set and
4827 * dependence relation strongly satisfies the dependences.
4828 * In particular, check that no instance is scheduled before
4829 * or together with an instance on which it depends.
4830 * Earlier versions of isl would produce a schedule that
4831 * only weakly satisfies the dependences.
4832 */
4834{
4835 const char *domain, *dep;
4837 isl_map *map, *ge;
4838 int empty;
4839
4840 domain = "{ B[i0, i1] : 0 <= i0 <= 1 and 0 <= i1 <= 11; "
4841 "A[i0] : 0 <= i0 <= 1 }";
4842 dep = "{ B[i0, i1] -> B[i0, 1 + i1] : 0 <= i0 <= 1 and 0 <= i1 <= 10; "
4843 "B[0, 11] -> A[1]; A[i0] -> B[i0, 0] : 0 <= i0 <= 1 }";
4844 schedule = compute_schedule(ctx, domain, dep, dep);
4845 D = isl_union_map_read_from_str(ctx, dep);
4850 map = isl_map_intersect(map, ge);
4851 empty = isl_map_is_empty(map);
4853
4854 if (empty < 0)
4855 return -1;
4856 if (!empty)
4858 "dependences not strongly satisfied", return -1);
4859
4860 return 0;
4861}
4862
4863/* Compute a schedule for input where the instance set constraints
4864 * conflict with the context constraints.
4865 * Earlier versions of isl did not properly handle this situation.
4866 */
4868{
4870 const char *domain, *context;
4871
4872 domain = "[n] -> { A[] : n >= 0 }";
4873 context = "[n] -> { : n < 0 }";
4875 domain, "{}", "{}", context);
4877
4878 if (!schedule)
4879 return -1;
4880
4881 return 0;
4882}
4883
4884/* Check that a set of schedule constraints that only allow for
4885 * a coalescing schedule still produces a schedule even if the user
4886 * request a non-coalescing schedule. Earlier versions of isl
4887 * would not handle this case correctly.
4888 */
4890{
4891 const char *domain, *dep;
4892 isl_union_set *I;
4893 isl_union_map *D;
4896 int treat_coalescing;
4897
4898 domain = "{ S[a, b] : 0 <= a <= 1 and 0 <= b <= 1 }";
4899 dep = "{ S[a, b] -> S[a + b, 1 - b] }";
4901 D = isl_union_map_read_from_str(ctx, dep);
4904 treat_coalescing = isl_options_get_schedule_treat_coalescing(ctx);
4907 isl_options_set_schedule_treat_coalescing(ctx, treat_coalescing);
4909 if (!schedule)
4910 return -1;
4911 return 0;
4912}
4913
4914/* Check that the scheduler does not perform any needless
4915 * compound skewing. Earlier versions of isl would compute
4916 * schedules in terms of transformed schedule coefficients and
4917 * would not accurately keep track of the sum of the original
4918 * schedule coefficients. It could then produce the schedule
4919 * S[t,i,j,k] -> [t, 2t + i, 2t + i + j, 2t + i + j + k]
4920 * for the input below instead of the schedule below.
4921 */
4923{
4924 const char *D, *V, *P, *S;
4925
4926 D = "[n] -> { S[t,i,j,k] : 0 <= t,i,j,k < n }";
4927 V = "[n] -> { S[t,i,j,k] -> S[t+1,a,b,c] : 0 <= t,i,j,k,a,b,c < n and "
4928 "-2 <= a-i <= 2 and -1 <= a-i + b-j <= 1 and "
4929 "-1 <= a-i + b-j + c-k <= 1 }";
4930 P = "{ }";
4931 S = "{ S[t,i,j,k] -> [t, 2t + i, t + i + j, 2t + k] }";
4932
4933 return test_special_schedule(ctx, D, V, P, S);
4934}
4935
4937{
4938 const char *D, *W, *R, *V, *P, *S;
4939 int max_coincidence;
4940 int treat_coalescing;
4941
4942 /* Handle resulting schedule with zero bands. */
4943 if (test_one_schedule(ctx, "{[]}", "{}", "{}", "{[] -> []}", 0, 0) < 0)
4944 return -1;
4945
4946 /* Jacobi */
4947 D = "[T,N] -> { S1[t,i] : 1 <= t <= T and 2 <= i <= N - 1 }";
4948 W = "{ S1[t,i] -> a[t,i] }";
4949 R = "{ S1[t,i] -> a[t-1,i]; S1[t,i] -> a[t-1,i-1]; "
4950 "S1[t,i] -> a[t-1,i+1] }";
4951 S = "{ S1[t,i] -> [t,i] }";
4952 if (test_one_schedule(ctx, D, W, R, S, 2, 0) < 0)
4953 return -1;
4954
4955 /* Fig. 5 of CC2008 */
4956 D = "[N] -> { S_0[i, j] : i >= 0 and i <= -1 + N and j >= 2 and "
4957 "j <= -1 + N }";
4958 W = "[N] -> { S_0[i, j] -> a[i, j] : i >= 0 and i <= -1 + N and "
4959 "j >= 2 and j <= -1 + N }";
4960 R = "[N] -> { S_0[i, j] -> a[j, i] : i >= 0 and i <= -1 + N and "
4961 "j >= 2 and j <= -1 + N; "
4962 "S_0[i, j] -> a[i, -1 + j] : i >= 0 and i <= -1 + N and "
4963 "j >= 2 and j <= -1 + N }";
4964 S = "[N] -> { S_0[i, j] -> [0, i, 0, j, 0] }";
4965 if (test_one_schedule(ctx, D, W, R, S, 2, 0) < 0)
4966 return -1;
4967
4968 D = "{ S1[i] : 0 <= i <= 10; S2[i] : 0 <= i <= 9 }";
4969 W = "{ S1[i] -> a[i] }";
4970 R = "{ S2[i] -> a[i+1] }";
4971 S = "{ S1[i] -> [0,i]; S2[i] -> [1,i] }";
4972 if (test_one_schedule(ctx, D, W, R, S, 1, 1) < 0)
4973 return -1;
4974
4975 D = "{ S1[i] : 0 <= i < 10; S2[i] : 0 <= i < 10 }";
4976 W = "{ S1[i] -> a[i] }";
4977 R = "{ S2[i] -> a[9-i] }";
4978 S = "{ S1[i] -> [0,i]; S2[i] -> [1,i] }";
4979 if (test_one_schedule(ctx, D, W, R, S, 1, 1) < 0)
4980 return -1;
4981
4982 D = "[N] -> { S1[i] : 0 <= i < N; S2[i] : 0 <= i < N }";
4983 W = "{ S1[i] -> a[i] }";
4984 R = "[N] -> { S2[i] -> a[N-1-i] }";
4985 S = "{ S1[i] -> [0,i]; S2[i] -> [1,i] }";
4986 if (test_one_schedule(ctx, D, W, R, S, 1, 1) < 0)
4987 return -1;
4988
4989 D = "{ S1[i] : 0 < i < 10; S2[i] : 0 <= i < 10 }";
4990 W = "{ S1[i] -> a[i]; S2[i] -> b[i] }";
4991 R = "{ S2[i] -> a[i]; S1[i] -> b[i-1] }";
4992 S = "{ S1[i] -> [i,0]; S2[i] -> [i,1] }";
4993 if (test_one_schedule(ctx, D, W, R, S, 0, 0) < 0)
4994 return -1;
4995
4996 D = "[N] -> { S1[i] : 1 <= i <= N; S2[i,j] : 1 <= i,j <= N }";
4997 W = "{ S1[i] -> a[0,i]; S2[i,j] -> a[i,j] }";
4998 R = "{ S2[i,j] -> a[i-1,j] }";
4999 S = "{ S1[i] -> [0,i,0]; S2[i,j] -> [1,i,j] }";
5000 if (test_one_schedule(ctx, D, W, R, S, 2, 1) < 0)
5001 return -1;
5002
5003 D = "[N] -> { S1[i] : 1 <= i <= N; S2[i,j] : 1 <= i,j <= N }";
5004 W = "{ S1[i] -> a[i,0]; S2[i,j] -> a[i,j] }";
5005 R = "{ S2[i,j] -> a[i,j-1] }";
5006 S = "{ S1[i] -> [0,i,0]; S2[i,j] -> [1,i,j] }";
5007 if (test_one_schedule(ctx, D, W, R, S, 2, 1) < 0)
5008 return -1;
5009
5010 D = "[N] -> { S_0[]; S_1[i] : i >= 0 and i <= -1 + N; S_2[] }";
5011 W = "[N] -> { S_0[] -> a[0]; S_2[] -> b[0]; "
5012 "S_1[i] -> a[1 + i] : i >= 0 and i <= -1 + N }";
5013 R = "[N] -> { S_2[] -> a[N]; S_1[i] -> a[i] : i >= 0 and i <= -1 + N }";
5014 S = "[N] -> { S_1[i] -> [1, i, 0]; S_2[] -> [2, 0, 1]; "
5015 "S_0[] -> [0, 0, 0] }";
5016 if (test_one_schedule(ctx, D, W, R, S, 1, 0) < 0)
5017 return -1;
5018 ctx->opt->schedule_parametric = 0;
5019 if (test_one_schedule(ctx, D, W, R, S, 0, 0) < 0)
5020 return -1;
5021 ctx->opt->schedule_parametric = 1;
5022
5023 D = "[N] -> { S1[i] : 1 <= i <= N; S2[i] : 1 <= i <= N; "
5024 "S3[i,j] : 1 <= i,j <= N; S4[i] : 1 <= i <= N }";
5025 W = "{ S1[i] -> a[i,0]; S2[i] -> a[0,i]; S3[i,j] -> a[i,j] }";
5026 R = "[N] -> { S3[i,j] -> a[i-1,j]; S3[i,j] -> a[i,j-1]; "
5027 "S4[i] -> a[i,N] }";
5028 S = "{ S1[i] -> [0,i,0]; S2[i] -> [1,i,0]; S3[i,j] -> [2,i,j]; "
5029 "S4[i] -> [4,i,0] }";
5030 max_coincidence = isl_options_get_schedule_maximize_coincidence(ctx);
5032 if (test_one_schedule(ctx, D, W, R, S, 2, 0) < 0)
5033 return -1;
5035
5036 D = "[N] -> { S_0[i, j] : i >= 1 and i <= N and j >= 1 and j <= N }";
5037 W = "[N] -> { S_0[i, j] -> s[0] : i >= 1 and i <= N and j >= 1 and "
5038 "j <= N }";
5039 R = "[N] -> { S_0[i, j] -> s[0] : i >= 1 and i <= N and j >= 1 and "
5040 "j <= N; "
5041 "S_0[i, j] -> a[i, j] : i >= 1 and i <= N and j >= 1 and "
5042 "j <= N }";
5043 S = "[N] -> { S_0[i, j] -> [0, i, 0, j, 0] }";
5044 if (test_one_schedule(ctx, D, W, R, S, 0, 0) < 0)
5045 return -1;
5046
5047 D = "[N] -> { S_0[t] : t >= 0 and t <= -1 + N; "
5048 " S_2[t] : t >= 0 and t <= -1 + N; "
5049 " S_1[t, i] : t >= 0 and t <= -1 + N and i >= 0 and "
5050 "i <= -1 + N }";
5051 W = "[N] -> { S_0[t] -> a[t, 0] : t >= 0 and t <= -1 + N; "
5052 " S_2[t] -> b[t] : t >= 0 and t <= -1 + N; "
5053 " S_1[t, i] -> a[t, 1 + i] : t >= 0 and t <= -1 + N and "
5054 "i >= 0 and i <= -1 + N }";
5055 R = "[N] -> { S_1[t, i] -> a[t, i] : t >= 0 and t <= -1 + N and "
5056 "i >= 0 and i <= -1 + N; "
5057 " S_2[t] -> a[t, N] : t >= 0 and t <= -1 + N }";
5058 S = "[N] -> { S_2[t] -> [0, t, 2]; S_1[t, i] -> [0, t, 1, i, 0]; "
5059 " S_0[t] -> [0, t, 0] }";
5060
5061 if (test_one_schedule(ctx, D, W, R, S, 2, 1) < 0)
5062 return -1;
5063 ctx->opt->schedule_parametric = 0;
5064 if (test_one_schedule(ctx, D, W, R, S, 0, 0) < 0)
5065 return -1;
5066 ctx->opt->schedule_parametric = 1;
5067
5068 D = "[N] -> { S1[i,j] : 0 <= i,j < N; S2[i,j] : 0 <= i,j < N }";
5069 S = "{ S1[i,j] -> [0,i,j]; S2[i,j] -> [1,i,j] }";
5070 if (test_one_schedule(ctx, D, "{}", "{}", S, 2, 2) < 0)
5071 return -1;
5072
5073 D = "[M, N] -> { S_1[i] : i >= 0 and i <= -1 + M; "
5074 "S_0[i, j] : i >= 0 and i <= -1 + M and j >= 0 and j <= -1 + N }";
5075 W = "[M, N] -> { S_0[i, j] -> a[j] : i >= 0 and i <= -1 + M and "
5076 "j >= 0 and j <= -1 + N; "
5077 "S_1[i] -> b[0] : i >= 0 and i <= -1 + M }";
5078 R = "[M, N] -> { S_0[i, j] -> a[0] : i >= 0 and i <= -1 + M and "
5079 "j >= 0 and j <= -1 + N; "
5080 "S_1[i] -> b[0] : i >= 0 and i <= -1 + M }";
5081 S = "[M, N] -> { S_1[i] -> [1, i, 0]; S_0[i, j] -> [0, i, 0, j, 0] }";
5082 if (test_one_schedule(ctx, D, W, R, S, 0, 0) < 0)
5083 return -1;
5084
5085 D = "{ S_0[i] : i >= 0 }";
5086 W = "{ S_0[i] -> a[i] : i >= 0 }";
5087 R = "{ S_0[i] -> a[0] : i >= 0 }";
5088 S = "{ S_0[i] -> [0, i, 0] }";
5089 if (test_one_schedule(ctx, D, W, R, S, 0, 0) < 0)
5090 return -1;
5091
5092 D = "{ S_0[i] : i >= 0; S_1[i] : i >= 0 }";
5093 W = "{ S_0[i] -> a[i] : i >= 0; S_1[i] -> b[i] : i >= 0 }";
5094 R = "{ S_0[i] -> b[0] : i >= 0; S_1[i] -> a[i] : i >= 0 }";
5095 S = "{ S_1[i] -> [0, i, 1]; S_0[i] -> [0, i, 0] }";
5096 if (test_one_schedule(ctx, D, W, R, S, 0, 0) < 0)
5097 return -1;
5098
5099 D = "[n] -> { S_0[j, k] : j <= -1 + n and j >= 0 and "
5100 "k <= -1 + n and k >= 0 }";
5101 W = "[n] -> { S_0[j, k] -> B[j] : j <= -1 + n and j >= 0 and " "k <= -1 + n and k >= 0 }";
5102 R = "[n] -> { S_0[j, k] -> B[j] : j <= -1 + n and j >= 0 and "
5103 "k <= -1 + n and k >= 0; "
5104 "S_0[j, k] -> B[k] : j <= -1 + n and j >= 0 and "
5105 "k <= -1 + n and k >= 0; "
5106 "S_0[j, k] -> A[k] : j <= -1 + n and j >= 0 and "
5107 "k <= -1 + n and k >= 0 }";
5108 S = "[n] -> { S_0[j, k] -> [2, j, k] }";
5110 if (test_one_schedule(ctx, D, W, R, S, 0, 0) < 0)
5111 return -1;
5113
5114 D = "{Stmt_for_body24[i0, i1, i2, i3]:"
5115 "i0 >= 0 and i0 <= 1 and i1 >= 0 and i1 <= 6 and i2 >= 2 and "
5116 "i2 <= 6 - i1 and i3 >= 0 and i3 <= -1 + i2;"
5117 "Stmt_for_body24[i0, i1, 1, 0]:"
5118 "i0 >= 0 and i0 <= 1 and i1 >= 0 and i1 <= 5;"
5119 "Stmt_for_body7[i0, i1, i2]:"
5120 "i0 >= 0 and i0 <= 1 and i1 >= 0 and i1 <= 7 and i2 >= 0 and "
5121 "i2 <= 7 }";
5122
5123 V = "{Stmt_for_body24[0, i1, i2, i3] -> "
5124 "Stmt_for_body24[1, i1, i2, i3]:"
5125 "i3 >= 0 and i3 <= -1 + i2 and i1 >= 0 and i2 <= 6 - i1 and "
5126 "i2 >= 1;"
5127 "Stmt_for_body24[0, i1, i2, i3] -> "
5128 "Stmt_for_body7[1, 1 + i1 + i3, 1 + i1 + i2]:"
5129 "i3 <= -1 + i2 and i2 <= 6 - i1 and i2 >= 1 and i1 >= 0 and "
5130 "i3 >= 0;"
5131 "Stmt_for_body24[0, i1, i2, i3] ->"
5132 "Stmt_for_body7[1, i1, 1 + i1 + i3]:"
5133 "i3 >= 0 and i2 <= 6 - i1 and i1 >= 0 and i3 <= -1 + i2;"
5134 "Stmt_for_body7[0, i1, i2] -> Stmt_for_body7[1, i1, i2]:"
5135 "(i2 >= 1 + i1 and i2 <= 6 and i1 >= 0 and i1 <= 4) or "
5136 "(i2 >= 3 and i2 <= 7 and i1 >= 1 and i2 >= 1 + i1) or "
5137 "(i2 >= 0 and i2 <= i1 and i2 >= -7 + i1 and i1 <= 7);"
5138 "Stmt_for_body7[0, i1, 1 + i1] -> Stmt_for_body7[1, i1, 1 + i1]:"
5139 "i1 <= 6 and i1 >= 0;"
5140 "Stmt_for_body7[0, 0, 7] -> Stmt_for_body7[1, 0, 7];"
5141 "Stmt_for_body7[i0, i1, i2] -> "
5142 "Stmt_for_body24[i0, o1, -1 + i2 - o1, -1 + i1 - o1]:"
5143 "i0 >= 0 and i0 <= 1 and o1 >= 0 and i2 >= 1 + i1 and "
5144 "o1 <= -2 + i2 and i2 <= 7 and o1 <= -1 + i1;"
5145 "Stmt_for_body7[i0, i1, i2] -> "
5146 "Stmt_for_body24[i0, i1, o2, -1 - i1 + i2]:"
5147 "i0 >= 0 and i0 <= 1 and i1 >= 0 and o2 >= -i1 + i2 and "
5148 "o2 >= 1 and o2 <= 6 - i1 and i2 >= 1 + i1 }";
5149 P = V;
5150
5151 treat_coalescing = isl_options_get_schedule_treat_coalescing(ctx);
5153 if (test_has_schedule(ctx, D, V, P) < 0)
5154 return -1;
5155 isl_options_set_schedule_treat_coalescing(ctx, treat_coalescing);
5156
5157 D = "{ S_0[i, j] : i >= 1 and i <= 10 and j >= 1 and j <= 8 }";
5158 V = "{ S_0[i, j] -> S_0[i, 1 + j] : i >= 1 and i <= 10 and "
5159 "j >= 1 and j <= 7;"
5160 "S_0[i, j] -> S_0[1 + i, j] : i >= 1 and i <= 9 and "
5161 "j >= 1 and j <= 8 }";
5162 P = "{ }";
5163 S = "{ S_0[i, j] -> [i + j, i] }";
5165 if (test_special_schedule(ctx, D, V, P, S) < 0)
5166 return -1;
5168
5169 /* Fig. 1 from Feautrier's "Some Efficient Solutions..." pt. 2, 1992 */
5170 D = "[N] -> { S_0[i, j] : i >= 0 and i <= -1 + N and "
5171 "j >= 0 and j <= -1 + i }";
5172 V = "[N] -> { S_0[i, j] -> S_0[i, 1 + j] : j <= -2 + i and "
5173 "i <= -1 + N and j >= 0;"
5174 "S_0[i, -1 + i] -> S_0[1 + i, 0] : i >= 1 and "
5175 "i <= -2 + N }";
5176 P = "{ }";
5177 S = "{ S_0[i, j] -> [i, j] }";
5179 if (test_special_schedule(ctx, D, V, P, S) < 0)
5180 return -1;
5182
5183 /* Test both algorithms on a case with only proximity dependences. */
5184 D = "{ S[i,j] : 0 <= i <= 10 }";
5185 V = "{ }";
5186 P = "{ S[i,j] -> S[i+1,j] : 0 <= i,j <= 10 }";
5187 S = "{ S[i, j] -> [j, i] }";
5189 if (test_special_schedule(ctx, D, V, P, S) < 0)
5190 return -1;
5192 if (test_special_schedule(ctx, D, V, P, S) < 0)
5193 return -1;
5194
5195 D = "{ A[a]; B[] }";
5196 V = "{}";
5197 P = "{ A[a] -> B[] }";
5198 if (test_has_schedule(ctx, D, V, P) < 0)
5199 return -1;
5200
5201 if (test_padded_schedule(ctx) < 0)
5202 return -1;
5203
5204 /* Check that check for progress is not confused by rational
5205 * solution.
5206 */
5207 D = "[N] -> { S0[i, j] : i >= 0 and i <= N and j >= 0 and j <= N }";
5208 V = "[N] -> { S0[i0, -1 + N] -> S0[2 + i0, 0] : i0 >= 0 and "
5209 "i0 <= -2 + N; "
5210 "S0[i0, i1] -> S0[i0, 1 + i1] : i0 >= 0 and "
5211 "i0 <= N and i1 >= 0 and i1 <= -1 + N }";
5212 P = "{}";
5214 if (test_has_schedule(ctx, D, V, P) < 0)
5215 return -1;
5217
5218 /* Check that we allow schedule rows that are only non-trivial
5219 * on some full-dimensional domains.
5220 */
5221 D = "{ S1[j] : 0 <= j <= 1; S0[]; S2[k] : 0 <= k <= 1 }";
5222 V = "{ S0[] -> S1[j] : 0 <= j <= 1; S2[0] -> S0[];"
5223 "S1[j] -> S2[1] : 0 <= j <= 1 }";
5224 P = "{}";
5226 if (test_has_schedule(ctx, D, V, P) < 0)
5227 return -1;
5229
5231 return -1;
5232
5234 return -1;
5235
5237 return -1;
5238
5239 if (test_coalescing_schedule(ctx) < 0)
5240 return -1;
5241 if (test_skewing_schedule(ctx) < 0)
5242 return -1;
5243
5244 return 0;
5245}
5246
5247/* Perform scheduling tests using the whole component scheduler.
5248 */
5250{
5251 int whole;
5252 int r;
5253
5256 r = test_schedule(ctx);
5258
5259 return r;
5260}
5261
5262/* Perform scheduling tests using the incremental scheduler.
5263 */
5265{
5266 int whole;
5267 int r;
5268
5271 r = test_schedule(ctx);
5273
5274 return r;
5275}
5276
5277int test_plain_injective(isl_ctx *ctx, const char *str, int injective)
5278{
5279 isl_union_map *umap;
5280 int test;
5281
5282 umap = isl_union_map_read_from_str(ctx, str);
5284 isl_union_map_free(umap);
5285 if (test < 0)
5286 return -1;
5287 if (test == injective)
5288 return 0;
5289 if (injective)
5291 "map not detected as injective", return -1);
5292 else
5294 "map detected as injective", return -1);
5295}
5296
5298{
5299 const char *str;
5300
5301 if (test_plain_injective(ctx, "{S[i,j] -> A[0]; T[i,j] -> B[1]}", 0))
5302 return -1;
5303 if (test_plain_injective(ctx, "{S[] -> A[0]; T[] -> B[0]}", 1))
5304 return -1;
5305 if (test_plain_injective(ctx, "{S[] -> A[0]; T[] -> A[1]}", 1))
5306 return -1;
5307 if (test_plain_injective(ctx, "{S[] -> A[0]; T[] -> A[0]}", 0))
5308 return -1;
5309 if (test_plain_injective(ctx, "{S[i] -> A[i,0]; T[i] -> A[i,1]}", 1))
5310 return -1;
5311 if (test_plain_injective(ctx, "{S[i] -> A[i]; T[i] -> A[i]}", 0))
5312 return -1;
5313 if (test_plain_injective(ctx, "{S[] -> A[0,0]; T[] -> A[0,1]}", 1))
5314 return -1;
5315 if (test_plain_injective(ctx, "{S[] -> A[0,0]; T[] -> A[1,0]}", 1))
5316 return -1;
5317
5318 str = "{S[] -> A[0,0]; T[] -> A[0,1]; U[] -> A[1,0]}";
5319 if (test_plain_injective(ctx, str, 1))
5320 return -1;
5321 str = "{S[] -> A[0,0]; T[] -> A[0,1]; U[] -> A[0,0]}";
5322 if (test_plain_injective(ctx, str, 0))
5323 return -1;
5324
5325 return 0;
5326}
5327
5328#undef BASE
5329#define BASE aff
5331
5332#undef BASE
5333#define BASE pw_multi_aff
5335
5336#undef BASE
5337#define BASE union_pw_aff
5339
5340/* Basic tests on isl_union_pw_aff.
5341 *
5342 * In particular, check that isl_union_pw_aff_aff_on_domain
5343 * aligns the parameters of the input objects and
5344 * that isl_union_pw_aff_param_on_domain_id properly
5345 * introduces the parameter.
5346 */
5347static int test_upa(isl_ctx *ctx)
5348{
5349 const char *str;
5350 isl_id *id;
5351 isl_aff *aff;
5353 isl_union_pw_aff *upa;
5354 isl_stat ok;
5355
5356 aff = isl_aff_read_from_str(ctx, "[N] -> { [N] }");
5357 str = "[M] -> { A[i] : 0 <= i < M; B[] }";
5360 str = "[N, M] -> { A[i] -> [N] : 0 <= i < M; B[] -> [N] }";
5361 ok = union_pw_aff_check_plain_equal(upa, str);
5363 if (ok < 0)
5364 return -1;
5365
5366 id = isl_id_alloc(ctx, "N", NULL);
5367 str = "[M] -> { A[i] : 0 <= i < M; B[] }";
5370 str = "[N, M] -> { A[i] -> [N] : 0 <= i < M; B[] -> [N] }";
5371 ok = union_pw_aff_check_plain_equal(upa, str);
5373 if (ok < 0)
5374 return -1;
5375
5376 return 0;
5377}
5378
5379struct {
5380 __isl_give isl_aff *(*fn)(__isl_take isl_aff *aff1,
5381 __isl_take isl_aff *aff2);
5382} aff_bin_op[] = {
5383 ['+'] = { &isl_aff_add },
5384 ['-'] = { &isl_aff_sub },
5385 ['*'] = { &isl_aff_mul },
5386 ['/'] = { &isl_aff_div },
5388
5389struct {
5390 const char *arg1;
5391 unsigned char op;
5392 const char *arg2;
5393 const char *res;
5394} aff_bin_tests[] = {
5395 { "{ [i] -> [i] }", '+', "{ [i] -> [i] }",
5396 "{ [i] -> [2i] }" },
5397 { "{ [i] -> [i] }", '-', "{ [i] -> [i] }",
5398 "{ [i] -> [0] }" },
5399 { "{ [i] -> [i] }", '*', "{ [i] -> [2] }",
5400 "{ [i] -> [2i] }" },
5401 { "{ [i] -> [2] }", '*', "{ [i] -> [i] }",
5402 "{ [i] -> [2i] }" },
5403 { "{ [i] -> [i] }", '/', "{ [i] -> [2] }",
5404 "{ [i] -> [i/2] }" },
5405 { "{ [i] -> [2i] }", '/', "{ [i] -> [2] }",
5406 "{ [i] -> [i] }" },
5407 { "{ [i] -> [i] }", '+', "{ [i] -> [NaN] }",
5408 "{ [i] -> [NaN] }" },
5409 { "{ [i] -> [i] }", '-', "{ [i] -> [NaN] }",
5410 "{ [i] -> [NaN] }" },
5411 { "{ [i] -> [i] }", '*', "{ [i] -> [NaN] }",
5412 "{ [i] -> [NaN] }" },
5413 { "{ [i] -> [2] }", '*', "{ [i] -> [NaN] }",
5414 "{ [i] -> [NaN] }" },
5415 { "{ [i] -> [i] }", '/', "{ [i] -> [NaN] }",
5416 "{ [i] -> [NaN] }" },
5417 { "{ [i] -> [2] }", '/', "{ [i] -> [NaN] }",
5418 "{ [i] -> [NaN] }" },
5419 { "{ [i] -> [NaN] }", '+', "{ [i] -> [i] }",
5420 "{ [i] -> [NaN] }" },
5421 { "{ [i] -> [NaN] }", '-', "{ [i] -> [i] }",
5422 "{ [i] -> [NaN] }" },
5423 { "{ [i] -> [NaN] }", '*', "{ [i] -> [2] }",
5424 "{ [i] -> [NaN] }" },
5425 { "{ [i] -> [NaN] }", '*', "{ [i] -> [i] }",
5426 "{ [i] -> [NaN] }" },
5427 { "{ [i] -> [NaN] }", '/', "{ [i] -> [2] }",
5428 "{ [i] -> [NaN] }" },
5429 { "{ [i] -> [NaN] }", '/', "{ [i] -> [i] }",
5430 "{ [i] -> [NaN] }" },
5431 { "{ [i] -> [i] }", '/', "{ [i] -> [0] }",
5432 "{ [i] -> [NaN] }" },
5434
5435/* Perform some basic tests of binary operations on isl_aff objects.
5436 */
5437static int test_bin_aff(isl_ctx *ctx)
5438{
5439 int i;
5440 isl_aff *aff1, *aff2, *res;
5441 __isl_give isl_aff *(*fn)(__isl_take isl_aff *aff1,
5442 __isl_take isl_aff *aff2);
5443 int ok;
5444
5445 for (i = 0; i < ARRAY_SIZE(aff_bin_tests); ++i) {
5449 fn = aff_bin_op[aff_bin_tests[i].op].fn;
5450 aff1 = fn(aff1, aff2);
5451 if (isl_aff_is_nan(res))
5452 ok = isl_aff_is_nan(aff1);
5453 else
5454 ok = isl_aff_plain_is_equal(aff1, res);
5455 isl_aff_free(aff1);
5457 if (ok < 0)
5458 return -1;
5459 if (!ok)
5461 "unexpected result", return -1);
5462 }
5463
5464 return 0;
5465}
5466
5467struct {
5469 __isl_take isl_pw_aff *pa2);
5470} pw_aff_bin_op[] = {
5471 ['m'] = { &isl_pw_aff_min },
5472 ['M'] = { &isl_pw_aff_max },
5474
5475/* Inputs for binary isl_pw_aff operation tests.
5476 * "arg1" and "arg2" are the two arguments, "op" identifies the operation
5477 * defined by pw_aff_bin_op, and "res" is the expected result.
5478 */
5479struct {
5480 const char *arg1;
5481 unsigned char op;
5482 const char *arg2;
5483 const char *res;
5484} pw_aff_bin_tests[] = {
5485 { "{ [i] -> [i] }", 'm', "{ [i] -> [i] }",
5486 "{ [i] -> [i] }" },
5487 { "{ [i] -> [i] }", 'M', "{ [i] -> [i] }",
5488 "{ [i] -> [i] }" },
5489 { "{ [i] -> [i] }", 'm', "{ [i] -> [0] }",
5490 "{ [i] -> [i] : i <= 0; [i] -> [0] : i > 0 }" },
5491 { "{ [i] -> [i] }", 'M', "{ [i] -> [0] }",
5492 "{ [i] -> [i] : i >= 0; [i] -> [0] : i < 0 }" },
5493 { "{ [i] -> [i] }", 'm', "{ [i] -> [NaN] }",
5494 "{ [i] -> [NaN] }" },
5495 { "{ [i] -> [NaN] }", 'm', "{ [i] -> [i] }",
5496 "{ [i] -> [NaN] }" },
5498
5499/* Perform some basic tests of binary operations on isl_pw_aff objects.
5500 */
5501static int test_bin_pw_aff(isl_ctx *ctx)
5502{
5503 int i;
5504 isl_bool ok;
5505 isl_pw_aff *pa1, *pa2, *res;
5506
5507 for (i = 0; i < ARRAY_SIZE(pw_aff_bin_tests); ++i) {
5511 pa1 = pw_aff_bin_op[pw_aff_bin_tests[i].op].fn(pa1, pa2);
5513 ok = isl_pw_aff_involves_nan(pa1);
5514 else
5515 ok = isl_pw_aff_plain_is_equal(pa1, res);
5516 isl_pw_aff_free(pa1);
5518 if (ok < 0)
5519 return -1;
5520 if (!ok)
5522 "unexpected result", return -1);
5523 }
5524
5525 return 0;
5526}
5527
5528/* Inputs for basic tests of test operations on
5529 * isl_union_pw_multi_aff objects.
5530 * "fn" is the function that is being tested.
5531 * "arg" is a string description of the input.
5532 * "res" is the expected result.
5533 */
5534static struct {
5536 const char *arg;
5537 isl_bool res;
5538} upma_test_tests[] = {
5539 { &isl_union_pw_multi_aff_involves_nan, "{ A[] -> [0]; B[0] -> [1] }",
5541 { &isl_union_pw_multi_aff_involves_nan, "{ A[] -> [NaN]; B[0] -> [1] }",
5542 isl_bool_true },
5543 { &isl_union_pw_multi_aff_involves_nan, "{ A[] -> [0]; B[0] -> [NaN] }",
5544 isl_bool_true },
5546 "{ A[] -> [0]; B[0] -> [1, NaN, 5] }",
5547 isl_bool_true },
5549 "{ A[] -> [0]; B[0] -> [1] }",
5552 "{ A[] -> [0]; B[x] -> [1] : x mod 2 = 0 }",
5553 isl_bool_true },
5555 "{ A[] -> [0]; B[x] -> [x // 2] }",
5556 isl_bool_true },
5558 "{ A[i] -> [i // 2]; B[0] -> [1] }",
5559 isl_bool_true },
5561
5562/* Perform some basic tests of test operations on
5563 * isl_union_pw_multi_aff objects.
5564 */
5566{
5567 int i;
5569 isl_bool res;
5570
5571 for (i = 0; i < ARRAY_SIZE(upma_test_tests); ++i) {
5572 const char *str;
5573
5574 str = upma_test_tests[i].arg;
5576 res = upma_test_tests[i].fn(upma);
5578 if (res < 0)
5579 return isl_stat_error;
5580 if (res != upma_test_tests[i].res)
5582 "unexpected result", return isl_stat_error);
5583 }
5584
5585 return isl_stat_ok;
5586}
5587
5588struct {
5592 const char *arg1;
5593 const char *arg2;
5594 const char *res;
5595} upma_bin_tests[] = {
5596 { &isl_union_pw_multi_aff_add, "{ A[] -> [0]; B[0] -> [1] }",
5597 "{ B[x] -> [2] : x >= 0 }", "{ B[0] -> [3] }" },
5598 { &isl_union_pw_multi_aff_union_add, "{ A[] -> [0]; B[0] -> [1] }",
5599 "{ B[x] -> [2] : x >= 0 }",
5600 "{ A[] -> [0]; B[0] -> [3]; B[x] -> [2] : x >= 1 }" },
5602 "{ A[] -> B[0]; C[x] -> B[1] : x < 10; C[y] -> B[2] : y >= 10 }",
5603 "{ D[i] -> A[] : i < 0; D[i] -> C[i + 5] : i >= 0 }",
5604 "{ D[i] -> B[0] : i < 0; D[i] -> B[1] : 0 <= i < 5; "
5605 "D[i] -> B[2] : i >= 5 }" },
5606 { &isl_union_pw_multi_aff_union_add, "{ B[x] -> A[1] : x <= 0 }",
5607 "{ B[x] -> C[2] : x > 0 }",
5608 "{ B[x] -> A[1] : x <= 0; B[x] -> C[2] : x > 0 }" },
5609 { &isl_union_pw_multi_aff_union_add, "{ B[x] -> A[1] : x <= 0 }",
5610 "{ B[x] -> A[2] : x >= 0 }",
5611 "{ B[x] -> A[1] : x < 0; B[x] -> A[2] : x > 0; B[0] -> A[3] }" },
5612 {
5614 "{ B[x] -> C[x + 2] }",
5615 "{ D[y] -> B[2y] }",
5616 "{ }" },
5617 {
5619 "{ [A[x] -> B[x + 1]] -> C[x + 2] }",
5620 "{ D[y] -> B[2y] }",
5621 "{ }" },
5622 {
5624 "{ [A[x] -> B[x + 1]] -> C[x + 2]; B[x] -> C[x + 2] }",
5625 "{ D[y] -> A[2y] }",
5626 "{ [D[y] -> B[2y + 1]] -> C[2y + 2] }" },
5627 {
5629 "{ T[A[x] -> B[x + 1]] -> C[x + 2]; B[x] -> C[x + 2] }",
5630 "{ D[y] -> A[2y] }",
5631 "{ T[D[y] -> B[2y + 1]] -> C[2y + 2] }" },
5633
5634/* Perform some basic tests of binary operations on
5635 * isl_union_pw_multi_aff objects.
5636 */
5637static int test_bin_upma(isl_ctx *ctx)
5638{
5639 int i;
5640 isl_union_pw_multi_aff *upma1, *upma2, *res;
5641 int ok;
5642
5643 for (i = 0; i < ARRAY_SIZE(upma_bin_tests); ++i) {
5645 upma_bin_tests[i].arg1);
5647 upma_bin_tests[i].arg2);
5649 upma_bin_tests[i].res);
5650 upma1 = upma_bin_tests[i].fn(upma1, upma2);
5654 if (ok < 0)
5655 return -1;
5656 if (!ok)
5658 "unexpected result", return -1);
5659 }
5660
5661 return 0;
5662}
5663
5664struct {
5668 const char *arg1;
5669 const char *arg2;
5670} upma_bin_fail_tests[] = {
5671 { &isl_union_pw_multi_aff_union_add, "{ B[x] -> A[1] : x <= 0 }",
5672 "{ B[x] -> C[2] : x >= 0 }" },
5674
5675/* Perform some basic tests of binary operations on
5676 * isl_union_pw_multi_aff objects that are expected to fail.
5677 */
5679{
5680 int i, n;
5681 isl_union_pw_multi_aff *upma1, *upma2;
5682 int on_error;
5683
5687 for (i = 0; i < n; ++i) {
5692 upma1 = upma_bin_fail_tests[i].fn(upma1, upma2);
5694 if (upma1)
5695 break;
5696 }
5698 if (i < n)
5700 "operation not expected to succeed", return -1);
5701
5702 return 0;
5703}
5704
5705/* Inputs for basic tests of binary operations on
5706 * pairs of isl_union_pw_multi_aff and isl_union_set objects.
5707 * "fn" is the function that is being tested.
5708 * "arg1" and "arg2" are string descriptions of the inputs.
5709 * "res" is a string description of the expected result.
5710 */
5711struct {
5715 const char *arg1;
5716 const char *arg2;
5717 const char *res;
5718} upma_uset_tests[] = {
5720 "{ A[i] -> B[i] }", "{ B[0] }",
5721 "{ }" },
5723 "{ [A[i] -> B[i]] -> C[i + 1] }", "{ A[1]; B[0] }",
5724 "{ [A[1] -> B[1]] -> C[2] }" },
5726 "{ [A[i] -> B[i]] -> C[i + 1] }", "{ A[1]; B[0] }",
5727 "{ [A[0] -> B[0]] -> C[1] }" },
5729 "{ [A[i] -> B[i]] -> C[i + 1] }", "[N] -> { B[N] }",
5730 "[N] -> { [A[N] -> B[N]] -> C[N + 1] }" },
5732 "[M] -> { [A[M] -> B[M]] -> C[M + 1] }", "[N] -> { B[N] }",
5733 "[N, M] -> { [A[N] -> B[N]] -> C[N + 1] : N = M }" },
5735 "{ [A[] -> B[]] -> C[]; N[A[] -> B[]] -> D[]; [B[] -> A[]] -> E[] }",
5736 "{ B[] }",
5737 "{ [A[] -> B[]] -> C[]; N[A[] -> B[]] -> D[] }" },
5739
5740/* Perform some basic tests of binary operations on
5741 * pairs of isl_union_pw_multi_aff and isl_union_set objects.
5742 */
5744{
5745 int i;
5746 isl_bool ok;
5748 isl_union_set *uset;
5749
5750 for (i = 0; i < ARRAY_SIZE(upma_uset_tests); ++i) {
5753 uset = isl_union_set_read_from_str(ctx,
5756 upma_uset_tests[i].res);
5757 upma = upma_uset_tests[i].fn(upma, uset);
5761 if (ok < 0)
5762 return isl_stat_error;
5763 if (!ok)
5765 "unexpected result", return isl_stat_error);
5766 }
5767
5768 return isl_stat_ok;
5769}
5770
5771/* Inputs for basic tests of unary operations on isl_multi_pw_aff objects.
5772 * "fn" is the function that is tested.
5773 * "arg" is a string description of the input.
5774 * "res" is a string description of the expected result.
5775 */
5776struct {
5778 const char *arg;
5779 const char *res;
5780} mpa_un_tests[] = {
5781 { &isl_multi_pw_aff_range_factor_domain,
5782 "{ A[x] -> [B[(1 : x >= 5)] -> C[(2 : x <= 10)]] }",
5783 "{ A[x] -> B[(1 : x >= 5)] }" },
5784 { &isl_multi_pw_aff_range_factor_range,
5785 "{ A[x] -> [B[(1 : x >= 5)] -> C[(2 : x <= 10)]] }",
5786 "{ A[y] -> C[(2 : y <= 10)] }" },
5787 { &isl_multi_pw_aff_range_factor_domain,
5788 "{ A[x] -> [B[(1 : x >= 5)] -> C[]] }",
5789 "{ A[x] -> B[(1 : x >= 5)] }" },
5790 { &isl_multi_pw_aff_range_factor_range,
5791 "{ A[x] -> [B[(1 : x >= 5)] -> C[]] }",
5792 "{ A[y] -> C[] }" },
5793 { &isl_multi_pw_aff_range_factor_domain,
5794 "{ A[x] -> [B[] -> C[(2 : x <= 10)]] }",
5795 "{ A[x] -> B[] }" },
5796 { &isl_multi_pw_aff_range_factor_range,
5797 "{ A[x] -> [B[] -> C[(2 : x <= 10)]] }",
5798 "{ A[y] -> C[(2 : y <= 10)] }" },
5799 { &isl_multi_pw_aff_range_factor_domain,
5800 "{ A[x] -> [B[] -> C[]] }",
5801 "{ A[x] -> B[] }" },
5802 { &isl_multi_pw_aff_range_factor_range,
5803 "{ A[x] -> [B[] -> C[]] }",
5804 "{ A[y] -> C[] }" },
5805 { &isl_multi_pw_aff_factor_range,
5806 "{ [B[] -> C[]] }",
5807 "{ C[] }" },
5808 { &isl_multi_pw_aff_range_factor_domain,
5809 "{ A[x] -> [B[] -> C[]] : x >= 0 }",
5810 "{ A[x] -> B[] : x >= 0 }" },
5811 { &isl_multi_pw_aff_range_factor_range,
5812 "{ A[x] -> [B[] -> C[]] : x >= 0 }",
5813 "{ A[y] -> C[] : y >= 0 }" },
5814 { &isl_multi_pw_aff_factor_range,
5815 "[N] -> { [B[] -> C[]] : N >= 0 }",
5816 "[N] -> { C[] : N >= 0 }" },
5818
5819/* Perform some basic tests of unary operations on isl_multi_pw_aff objects.
5820 */
5821static int test_un_mpa(isl_ctx *ctx)
5822{
5823 int i;
5824 isl_bool ok;
5825 isl_multi_pw_aff *mpa, *res;
5826
5827 for (i = 0; i < ARRAY_SIZE(mpa_un_tests); ++i) {
5830 mpa = mpa_un_tests[i].fn(mpa);
5831 ok = isl_multi_pw_aff_plain_is_equal(mpa, res);
5832 isl_multi_pw_aff_free(mpa);
5833 isl_multi_pw_aff_free(res);
5834 if (ok < 0)
5835 return -1;
5836 if (!ok)
5838 "unexpected result", return -1);
5839 }
5840
5841 return 0;
5842}
5843
5844/* Inputs for basic tests of binary operations on isl_multi_pw_aff objects.
5845 * "fn" is the function that is tested.
5846 * "arg1" and "arg2" are string descriptions of the inputs.
5847 * "res" is a string description of the expected result.
5848 */
5849struct {
5853 const char *arg1;
5854 const char *arg2;
5855 const char *res;
5856} mpa_bin_tests[] = {
5857 { &isl_multi_pw_aff_add, "{ A[] -> [1] }", "{ A[] -> [2] }",
5858 "{ A[] -> [3] }" },
5859 { &isl_multi_pw_aff_add, "{ A[x] -> [(1 : x >= 5)] }",
5860 "{ A[x] -> [(x : x <= 10)] }",
5861 "{ A[x] -> [(1 + x : 5 <= x <= 10)] }" },
5862 { &isl_multi_pw_aff_add, "{ A[x] -> [] : x >= 5 }",
5863 "{ A[x] -> [] : x <= 10 }",
5864 "{ A[x] -> [] : 5 <= x <= 10 }" },
5865 { &isl_multi_pw_aff_add, "{ A[x] -> [] : x >= 5 }",
5866 "[N] -> { A[x] -> [] : x <= N }",
5867 "[N] -> { A[x] -> [] : 5 <= x <= N }" },
5868 { &isl_multi_pw_aff_add,
5869 "[N] -> { A[x] -> [] : x <= N }",
5870 "{ A[x] -> [] : x >= 5 }",
5871 "[N] -> { A[x] -> [] : 5 <= x <= N }" },
5872 { &isl_multi_pw_aff_range_product, "{ A[x] -> B[(1 : x >= 5)] }",
5873 "{ A[y] -> C[(2 : y <= 10)] }",
5874 "{ A[x] -> [B[(1 : x >= 5)] -> C[(2 : x <= 10)]] }" },
5875 { &isl_multi_pw_aff_range_product, "{ A[x] -> B[1] : x >= 5 }",
5876 "{ A[y] -> C[2] : y <= 10 }",
5877 "{ A[x] -> [B[(1 : x >= 5)] -> C[(2 : x <= 10)]] }" },
5878 { &isl_multi_pw_aff_range_product, "{ A[x] -> B[1] : x >= 5 }",
5879 "[N] -> { A[y] -> C[2] : y <= N }",
5880 "[N] -> { A[x] -> [B[(1 : x >= 5)] -> C[(2 : x <= N)]] }" },
5881 { &isl_multi_pw_aff_range_product, "[N] -> { A[x] -> B[1] : x >= N }",
5882 "{ A[y] -> C[2] : y <= 10 }",
5883 "[N] -> { A[x] -> [B[(1 : x >= N)] -> C[(2 : x <= 10)]] }" },
5884 { &isl_multi_pw_aff_range_product, "{ A[] -> B[1] }", "{ A[] -> C[2] }",
5885 "{ A[] -> [B[1] -> C[2]] }" },
5886 { &isl_multi_pw_aff_range_product, "{ A[] -> B[] }", "{ A[] -> C[] }",
5887 "{ A[] -> [B[] -> C[]] }" },
5888 { &isl_multi_pw_aff_range_product, "{ A[x] -> B[(1 : x >= 5)] }",
5889 "{ A[y] -> C[] : y <= 10 }",
5890 "{ A[x] -> [B[(1 : x >= 5)] -> C[]] : x <= 10 }" },
5891 { &isl_multi_pw_aff_range_product, "{ A[y] -> C[] : y <= 10 }",
5892 "{ A[x] -> B[(1 : x >= 5)] }",
5893 "{ A[x] -> [C[] -> B[(1 : x >= 5)]] : x <= 10 }" },
5894 { &isl_multi_pw_aff_product, "{ A[x] -> B[(1 : x >= 5)] }",
5895 "{ A[y] -> C[(2 : y <= 10)] }",
5896 "{ [A[x] -> A[y]] -> [B[(1 : x >= 5)] -> C[(2 : y <= 10)]] }" },
5897 { &isl_multi_pw_aff_product, "{ A[x] -> B[(1 : x >= 5)] }",
5898 "{ A[y] -> C[] : y <= 10 }",
5899 "{ [A[x] -> A[y]] -> [B[(1 : x >= 5)] -> C[]] : y <= 10 }" },
5900 { &isl_multi_pw_aff_product, "{ A[y] -> C[] : y <= 10 }",
5901 "{ A[x] -> B[(1 : x >= 5)] }",
5902 "{ [A[y] -> A[x]] -> [C[] -> B[(1 : x >= 5)]] : y <= 10 }" },
5903 { &isl_multi_pw_aff_product, "{ A[x] -> B[(1 : x >= 5)] }",
5904 "[N] -> { A[y] -> C[] : y <= N }",
5905 "[N] -> { [A[x] -> A[y]] -> [B[(1 : x >= 5)] -> C[]] : y <= N }" },
5906 { &isl_multi_pw_aff_product, "[N] -> { A[y] -> C[] : y <= N }",
5907 "{ A[x] -> B[(1 : x >= 5)] }",
5908 "[N] -> { [A[y] -> A[x]] -> [C[] -> B[(1 : x >= 5)]] : y <= N }" },
5909 { &isl_multi_pw_aff_product, "{ A[x] -> B[] : x >= 5 }",
5910 "{ A[y] -> C[] : y <= 10 }",
5911 "{ [A[x] -> A[y]] -> [B[] -> C[]] : x >= 5 and y <= 10 }" },
5912 { &isl_multi_pw_aff_product, "{ A[] -> B[1] }", "{ A[] -> C[2] }",
5913 "{ [A[] -> A[]] -> [B[1] -> C[2]] }" },
5914 { &isl_multi_pw_aff_product, "{ A[] -> B[] }", "{ A[] -> C[] }",
5915 "{ [A[] -> A[]] -> [B[] -> C[]] }" },
5917 "{ B[i,j] -> C[i + 2j] }", "{ A[a,b] -> B[b,a] }",
5918 "{ A[a,b] -> C[b + 2a] }" },
5920 "{ B[i,j] -> C[i + 2j] }",
5921 "{ A[a,b] -> B[(b : b > a),(a : b > a)] }",
5922 "{ A[a,b] -> C[(b + 2a : b > a)] }" },
5924 "{ B[i,j] -> C[(i + 2j : j > 4)] }",
5925 "{ A[a,b] -> B[(b : b > a),(a : b > a)] }",
5926 "{ A[a,b] -> C[(b + 2a : b > a > 4)] }" },
5928 "{ B[i,j] -> C[] }",
5929 "{ A[a,b] -> B[(b : b > a),(a : b > a)] }",
5930 "{ A[a,b] -> C[] }" },
5932 "{ B[i,j] -> C[] : i > j }",
5933 "{ A[a,b] -> B[b,a] }",
5934 "{ A[a,b] -> C[] : b > a }" },
5936 "{ B[i,j] -> C[] : j > 5 }",
5937 "{ A[a,b] -> B[(b : b > a),(a : b > a)] }",
5938 "{ A[a,b] -> C[] : b > a > 5 }" },
5940 "[N] -> { B[i,j] -> C[] : j > N }",
5941 "{ A[a,b] -> B[(b : b > a),(a : b > a)] }",
5942 "[N] -> { A[a,b] -> C[] : b > a > N }" },
5944 "[M,N] -> { B[] -> C[] : N > 5 }",
5945 "[M,N] -> { A[] -> B[] : M > N }",
5946 "[M,N] -> { A[] -> C[] : M > N > 5 }" },
5948
5949/* Perform some basic tests of binary operations on isl_multi_pw_aff objects.
5950 */
5951static int test_bin_mpa(isl_ctx *ctx)
5952{
5953 int i;
5954 isl_bool ok;
5955 isl_multi_pw_aff *mpa1, *mpa2, *res;
5956
5957 for (i = 0; i < ARRAY_SIZE(mpa_bin_tests); ++i) {
5959 mpa_bin_tests[i].arg1);
5961 mpa_bin_tests[i].arg2);
5963 mpa_bin_tests[i].res);
5964 mpa1 = mpa_bin_tests[i].fn(mpa1, mpa2);
5965 ok = isl_multi_pw_aff_plain_is_equal(mpa1, res);
5966 isl_multi_pw_aff_free(mpa1);
5967 isl_multi_pw_aff_free(res);
5968 if (ok < 0)
5969 return -1;
5970 if (!ok)
5972 "unexpected result", return -1);
5973 }
5974
5975 return 0;
5976}
5977
5978/* Inputs for basic tests of unary operations on
5979 * isl_multi_union_pw_aff objects.
5980 * "fn" is the function that is tested.
5981 * "arg" is a string description of the input.
5982 * "res" is a string description of the expected result.
5983 */
5984struct {
5987 const char *arg;
5988 const char *res;
5989} mupa_un_tests[] = {
5990 { &isl_multi_union_pw_aff_factor_range,
5991 "[B[{ A[] -> [1] }] -> C[{ A[] -> [2] }]]",
5992 "C[{ A[] -> [2] }]" },
5993 { &isl_multi_union_pw_aff_factor_range,
5994 "[B[] -> C[{ A[] -> [2] }]]",
5995 "C[{ A[] -> [2] }]" },
5996 { &isl_multi_union_pw_aff_factor_range,
5997 "[B[{ A[] -> [1] }] -> C[]]",
5998 "C[]" },
5999 { &isl_multi_union_pw_aff_factor_range,
6000 "[B[] -> C[]]",
6001 "C[]" },
6002 { &isl_multi_union_pw_aff_factor_range,
6003 "([B[] -> C[]] : { A[x] : x >= 0 })",
6004 "(C[] : { A[x] : x >= 0 })" },
6005 { &isl_multi_union_pw_aff_factor_range,
6006 "[N] -> ([B[] -> C[]] : { A[x] : x <= N })",
6007 "[N] -> (C[] : { A[x] : x <= N })" },
6008 { &isl_multi_union_pw_aff_factor_range,
6009 "[N] -> ([B[] -> C[]] : { : N >= 0 })",
6010 "[N] -> (C[] : { : N >= 0 })" },
6012
6013/* Perform some basic tests of unary operations on
6014 * isl_multi_union_pw_aff objects.
6015 */
6016static int test_un_mupa(isl_ctx *ctx)
6017{
6018 int i;
6019 isl_bool ok;
6021
6022 for (i = 0; i < ARRAY_SIZE(mupa_un_tests); ++i) {
6024 mupa_un_tests[i].arg);
6026 mupa_un_tests[i].res);
6027 mupa = mupa_un_tests[i].fn(mupa);
6028 ok = isl_multi_union_pw_aff_plain_is_equal(mupa, res);
6029 isl_multi_union_pw_aff_free(mupa);
6030 isl_multi_union_pw_aff_free(res);
6031 if (ok < 0)
6032 return -1;
6033 if (!ok)
6035 "unexpected result", return -1);
6036 }
6037
6038 return 0;
6039}
6040
6041/* Inputs for basic tests of binary operations on
6042 * isl_multi_union_pw_aff objects.
6043 * "fn" is the function that is tested.
6044 * "arg1" and "arg2" are string descriptions of the inputs.
6045 * "res" is a string description of the expected result.
6046 */
6047struct {
6051 const char *arg1;
6052 const char *arg2;
6053 const char *res;
6054} mupa_bin_tests[] = {
6055 { &isl_multi_union_pw_aff_add, "[{ A[] -> [1] }]", "[{ A[] -> [2] }]",
6056 "[{ A[] -> [3] }]" },
6057 { &isl_multi_union_pw_aff_sub, "[{ A[] -> [1] }]", "[{ A[] -> [2] }]",
6058 "[{ A[] -> [-1] }]" },
6059 { &isl_multi_union_pw_aff_add,
6060 "[{ A[] -> [1]; B[] -> [4] }]",
6061 "[{ A[] -> [2]; C[] -> [5] }]",
6062 "[{ A[] -> [3] }]" },
6064 "[{ A[] -> [1]; B[] -> [4] }]",
6065 "[{ A[] -> [2]; C[] -> [5] }]",
6066 "[{ A[] -> [3]; B[] -> [4]; C[] -> [5] }]" },
6067 { &isl_multi_union_pw_aff_add, "[{ A[x] -> [(1)] : x >= 5 }]",
6068 "[{ A[x] -> [(x)] : x <= 10 }]",
6069 "[{ A[x] -> [(1 + x)] : 5 <= x <= 10 }]" },
6070 { &isl_multi_union_pw_aff_add, "([] : { A[x] : x >= 5 })",
6071 "([] : { A[x] : x <= 10 })",
6072 "([] : { A[x] : 5 <= x <= 10 })" },
6073 { &isl_multi_union_pw_aff_add, "([] : { A[x] : x >= 5 })",
6074 "[N] -> ([] : { A[x] : x <= N })",
6075 "[N] -> ([] : { A[x] : 5 <= x <= N })" },
6076 { &isl_multi_union_pw_aff_add, "[N] -> ([] : { A[x] : x >= N })",
6077 "([] : { A[x] : x <= 10 })",
6078 "[N] -> ([] : { A[x] : N <= x <= 10 })" },
6079 { &isl_multi_union_pw_aff_union_add, "[{ A[x] -> [(1)] : x >= 5 }]",
6080 "[{ A[x] -> [(x)] : x <= 10 }]",
6081 "[{ A[x] -> [(1 + x)] : 5 <= x <= 10; "
6082 "A[x] -> [(1)] : x > 10; A[x] -> [(x)] : x < 5 }]" },
6083 { &isl_multi_union_pw_aff_union_add, "([] : { A[x] : x >= 5 })",
6084 "([] : { A[x] : x <= 10 })",
6085 "([] : { A[x] })" },
6086 { &isl_multi_union_pw_aff_union_add, "([] : { A[x] : x >= 0 })",
6087 "[N] -> ([] : { A[x] : x >= N })",
6088 "[N] -> ([] : { A[x] : x >= 0 or x >= N })" },
6090 "[N] -> ([] : { A[] : N >= 0})",
6091 "[N] -> ([] : { A[] : N <= 0})",
6092 "[N] -> ([] : { A[] })" },
6094 "[N] -> ([] : { A[] })",
6095 "[N] -> ([] : { : })",
6096 "[N] -> ([] : { : })" },
6098 "[N] -> ([] : { : })",
6099 "[N] -> ([] : { A[] })",
6100 "[N] -> ([] : { : })" },
6102 "[N] -> ([] : { : N >= 0})",
6103 "[N] -> ([] : { : N <= 0})",
6104 "[N] -> ([] : { : })" },
6105 { &isl_multi_union_pw_aff_range_product,
6106 "B[{ A[] -> [1] }]",
6107 "C[{ A[] -> [2] }]",
6108 "[B[{ A[] -> [1] }] -> C[{ A[] -> [2] }]]" },
6109 { &isl_multi_union_pw_aff_range_product,
6110 "(B[] : { A[x] : x >= 5 })",
6111 "(C[] : { A[x] : x <= 10 })",
6112 "([B[] -> C[]] : { A[x] : 5 <= x <= 10 })" },
6113 { &isl_multi_union_pw_aff_range_product,
6114 "B[{ A[x] -> [x + 1] : x >= 5 }]",
6115 "(C[] : { A[x] : x <= 10 })",
6116 "[B[{ A[x] -> [x + 1] : 5 <= x <= 10 }] -> C[]]" },
6117 { &isl_multi_union_pw_aff_range_product,
6118 "(C[] : { A[x] : x <= 10 })",
6119 "B[{ A[x] -> [x + 1] : x >= 5 }]",
6120 "[C[] -> B[{ A[x] -> [x + 1] : 5 <= x <= 10 }]]" },
6121 { &isl_multi_union_pw_aff_range_product,
6122 "B[{ A[x] -> [x + 1] : x >= 5 }]",
6123 "[N] -> (C[] : { A[x] : x <= N })",
6124 "[N] -> [B[{ A[x] -> [x + 1] : 5 <= x <= N }] -> C[]]" },
6125 { &isl_multi_union_pw_aff_range_product,
6126 "[N] -> (C[] : { A[x] : x <= N })",
6127 "B[{ A[x] -> [x + 1] : x >= 5 }]",
6128 "[N] -> [C[] -> B[{ A[x] -> [x + 1] : 5 <= x <= N }]]" },
6129 { &isl_multi_union_pw_aff_range_product,
6130 "B[{ A[] -> [1]; D[] -> [3] }]",
6131 "C[{ A[] -> [2] }]",
6132 "[B[{ A[] -> [1]; D[] -> [3] }] -> C[{ A[] -> [2] }]]" },
6133 { &isl_multi_union_pw_aff_range_product,
6134 "B[] }]",
6135 "(C[] : { A[x] })",
6136 "([B[] -> C[]] : { A[x] })" },
6137 { &isl_multi_union_pw_aff_range_product,
6138 "(B[] : { A[x] })",
6139 "C[] }]",
6140 "([B[] -> C[]] : { A[x] })" },
6142
6143/* Perform some basic tests of binary operations on
6144 * isl_multi_union_pw_aff objects.
6145 */
6146static int test_bin_mupa(isl_ctx *ctx)
6147{
6148 int i;
6149 isl_bool ok;
6150 isl_multi_union_pw_aff *mupa1, *mupa2, *res;
6151
6152 for (i = 0; i < ARRAY_SIZE(mupa_bin_tests); ++i) {
6154 mupa_bin_tests[i].arg1);
6156 mupa_bin_tests[i].arg2);
6158 mupa_bin_tests[i].res);
6159 mupa1 = mupa_bin_tests[i].fn(mupa1, mupa2);
6160 ok = isl_multi_union_pw_aff_plain_is_equal(mupa1, res);
6161 isl_multi_union_pw_aff_free(mupa1);
6162 isl_multi_union_pw_aff_free(res);
6163 if (ok < 0)
6164 return -1;
6165 if (!ok)
6167 "unexpected result", return -1);
6168 }
6169
6170 return 0;
6171}
6172
6173/* Inputs for basic tests of binary operations on
6174 * pairs of isl_multi_union_pw_aff and isl_set objects.
6175 * "fn" is the function that is tested.
6176 * "arg1" and "arg2" are string descriptions of the inputs.
6177 * "res" is a string description of the expected result.
6178 */
6179struct {
6183 const char *arg1;
6184 const char *arg2;
6185 const char *res;
6186} mupa_set_tests[] = {
6188 "C[{ B[i,j] -> [i + 2j] }]", "{ C[1] }",
6189 "C[{ B[i,j] -> [i + 2j] : i + 2j = 1 }]" },
6191 "C[{ B[i,j] -> [i + 2j] }]", "[N] -> { C[N] }",
6192 "[N] -> C[{ B[i,j] -> [i + 2j] : i + 2j = N }]" },
6194 "[N] -> C[{ B[i,j] -> [i + 2j + N] }]", "{ C[1] }",
6195 "[N] -> C[{ B[i,j] -> [i + 2j + N] : i + 2j + N = 1 }]" },
6197 "C[{ B[i,j] -> [i + 2j] }]", "[N] -> { C[x] : N >= 0 }",
6198 "[N] -> C[{ B[i,j] -> [i + 2j] : N >= 0 }]" },
6200 "C[]", "{ C[] }", "C[]" },
6202 "[N] -> (C[] : { : N >= 0 })",
6203 "{ C[] }",
6204 "[N] -> (C[] : { : N >= 0 })" },
6206 "(C[] : { A[a,b] })",
6207 "{ C[] }",
6208 "(C[] : { A[a,b] })" },
6210 "[N] -> (C[] : { A[a,b] : a,b <= N })",
6211 "{ C[] }",
6212 "[N] -> (C[] : { A[a,b] : a,b <= N })" },
6214 "C[]",
6215 "[N] -> { C[] : N >= 0 }",
6216 "[N] -> (C[] : { : N >= 0 })" },
6218 "(C[] : { A[a,b] })",
6219 "[N] -> { C[] : N >= 0 }",
6220 "[N] -> (C[] : { A[a,b] : N >= 0 })" },
6222 "[N] -> (C[] : { : N >= 0 })",
6223 "[N] -> { C[] : N < 1024 }",
6224 "[N] -> (C[] : { : 0 <= N < 1024 })" },
6226 "C[{ B[i,j] -> [i + 2j] }]", "[N] -> { : N >= 0 }",
6227 "[N] -> C[{ B[i,j] -> [i + 2j] : N >= 0}]" },
6229 "[N] -> C[{ B[i,j] -> [i + 2j] : N <= 256 }]", "[N] -> { : N >= 0 }",
6230 "[N] -> C[{ B[i,j] -> [i + 2j] : 0 <= N <= 256 }]" },
6232 "[N] -> C[{ B[i,j] -> [i + 2j] : N <= 256 }]", "{ : }",
6233 "[N] -> C[{ B[i,j] -> [i + 2j] : N <= 256 }]" },
6235 "C[]", "[N] -> { : N >= 0 }",
6236 "[N] -> (C[] : { : N >= 0 })" },
6238 "(C[] : { A[a,b] })", "[N] -> { : N >= 0 }",
6239 "[N] -> (C[] : { A[a,b] : N >= 0 })" },
6241 "[N] -> (C[] : { A[a,N] })", "{ : }",
6242 "[N] -> (C[] : { A[a,N] })" },
6244 "[N] -> (C[] : { A[a,b] : N <= 256 })", "[N] -> { : N >= 0 }",
6245 "[N] -> (C[] : { A[a,b] : 0 <= N <= 256 })" },
6247
6248/* Perform some basic tests of binary operations on
6249 * pairs of isl_multi_union_pw_aff and isl_set objects.
6250 */
6251static int test_mupa_set(isl_ctx *ctx)
6252{
6253 int i;
6254 isl_bool ok;
6256 isl_set *set;
6257
6258 for (i = 0; i < ARRAY_SIZE(mupa_set_tests); ++i) {
6260 mupa_set_tests[i].arg1);
6263 mupa_set_tests[i].res);
6264 mupa = mupa_set_tests[i].fn(mupa, set);
6265 ok = isl_multi_union_pw_aff_plain_is_equal(mupa, res);
6266 isl_multi_union_pw_aff_free(mupa);
6267 isl_multi_union_pw_aff_free(res);
6268 if (ok < 0)
6269 return -1;
6270 if (!ok)
6272 "unexpected result", return -1);
6273 }
6274
6275 return 0;
6276}
6277
6278/* Inputs for basic tests of binary operations on
6279 * pairs of isl_multi_union_pw_aff and isl_union_set objects.
6280 * "fn" is the function that is tested.
6281 * "arg1" and "arg2" are string descriptions of the inputs.
6282 * "res" is a string description of the expected result.
6283 */
6284struct {
6288 const char *arg1;
6289 const char *arg2;
6290 const char *res;
6291} mupa_uset_tests[] = {
6293 "C[{ B[i,j] -> [i + 2j] }]", "{ B[i,i] }",
6294 "C[{ B[i,i] -> [3i] }]" },
6296 "(C[] : { B[i,j] })", "{ B[i,i] }",
6297 "(C[] : { B[i,i] })" },
6299 "(C[] : { B[i,j] })", "[N] -> { B[N,N] }",
6300 "[N] -> (C[] : { B[N,N] })" },
6302 "C[]", "{ B[i,i] }",
6303 "(C[] : { B[i,i] })" },
6305 "[N] -> (C[] : { : N >= 0 })", "{ B[i,i] }",
6306 "[N] -> (C[] : { B[i,i] : N >= 0 })" },
6308
6309/* Perform some basic tests of binary operations on
6310 * pairs of isl_multi_union_pw_aff and isl_union_set objects.
6311 */
6312static int test_mupa_uset(isl_ctx *ctx)
6313{
6314 int i;
6315 isl_bool ok;
6317 isl_union_set *uset;
6318
6319 for (i = 0; i < ARRAY_SIZE(mupa_uset_tests); ++i) {
6322 uset = isl_union_set_read_from_str(ctx,
6325 mupa_uset_tests[i].res);
6326 mupa = mupa_uset_tests[i].fn(mupa, uset);
6327 ok = isl_multi_union_pw_aff_plain_is_equal(mupa, res);
6328 isl_multi_union_pw_aff_free(mupa);
6329 isl_multi_union_pw_aff_free(res);
6330 if (ok < 0)
6331 return -1;
6332 if (!ok)
6334 "unexpected result", return -1);
6335 }
6336
6337 return 0;
6338}
6339
6340/* Inputs for basic tests of binary operations on
6341 * pairs of isl_multi_union_pw_aff and isl_multi_aff objects.
6342 * "fn" is the function that is tested.
6343 * "arg1" and "arg2" are string descriptions of the inputs.
6344 * "res" is a string description of the expected result.
6345 */
6346struct {
6350 const char *arg1;
6351 const char *arg2;
6352 const char *res;
6353} mupa_ma_tests[] = {
6355 "C[{ A[i,j] -> [i]; B[i,j] -> [j] }, "
6356 "{ A[i,j] -> [j]; B[i,j] -> [i] }]",
6357 "{ C[a,b] -> D[b,a] }",
6358 "D[{ A[i,j] -> [j]; B[i,j] -> [i] }, "
6359 "{ A[i,j] -> [i]; B[i,j] -> [j] }]" },
6361 "C[{ A[i,j] -> [i] : i >= 0; B[i,j] -> [j] }, "
6362 "{ A[i,j] -> [j]; B[i,j] -> [i] }]",
6363 "{ C[a,b] -> D[b,a] }",
6364 "D[{ A[i,j] -> [j] : i >= 0; B[i,j] -> [i] }, "
6365 "{ A[i,j] -> [i] : i >= 0; B[i,j] -> [j] }]" },
6367 "C[{ A[i,j] -> [i]; B[i,j] -> [j] }]",
6368 "[N] -> { C[a] -> D[a + N] }",
6369 "[N] -> D[{ A[i,j] -> [i + N]; B[i,j] -> [j + N] }] " },
6371 "C[]",
6372 "{ C[] -> D[] }",
6373 "D[]" },
6375 "[N] -> (C[] : { : N >= 0 })",
6376 "{ C[] -> D[] }",
6377 "[N] -> (D[] : { : N >= 0 })" },
6379 "C[]",
6380 "[N] -> { C[] -> D[N] }",
6381 "[N] -> D[{ [N] }]" },
6383 "(C[] : { A[i,j] : i >= j })",
6384 "{ C[] -> D[] }",
6385 "(D[] : { A[i,j] : i >= j })" },
6387 "[N] -> (C[] : { A[i,j] : N >= 0 })",
6388 "{ C[] -> D[] }",
6389 "[N] -> (D[] : { A[i,j] : N >= 0 })" },
6391 "(C[] : { A[i,j] : i >= j })",
6392 "[N] -> { C[] -> D[N] }",
6393 "[N] -> (D[{ A[i,j] -> [N] : i >= j }])" },
6395
6396/* Perform some basic tests of binary operations on
6397 * pairs of isl_multi_union_pw_aff and isl_multi_aff objects.
6398 */
6399static int test_mupa_ma(isl_ctx *ctx)
6400{
6401 int i;
6402 isl_bool ok;
6405
6406 for (i = 0; i < ARRAY_SIZE(mupa_ma_tests); ++i) {
6408 mupa_ma_tests[i].arg1);
6411 mupa_ma_tests[i].res);
6412 mupa = mupa_ma_tests[i].fn(mupa, ma);
6413 ok = isl_multi_union_pw_aff_plain_is_equal(mupa, res);
6414 isl_multi_union_pw_aff_free(mupa);
6415 isl_multi_union_pw_aff_free(res);
6416 if (ok < 0)
6417 return -1;
6418 if (!ok)
6420 "unexpected result", return -1);
6421 }
6422
6423 return 0;
6424}
6425
6426/* Inputs for basic tests of binary operations on
6427 * pairs of isl_multi_union_pw_aff and isl_pw_aff objects.
6428 * "fn" is the function that is tested.
6429 * "arg1" and "arg2" are string descriptions of the inputs.
6430 * "res" is a string description of the expected result.
6431 */
6432struct {
6436 const char *arg1;
6437 const char *arg2;
6438 const char *res;
6439} mupa_pa_tests[] = {
6441 "C[{ A[i,j] -> [i]; B[i,j] -> [j] }]",
6442 "[N] -> { C[a] -> [a + N] }",
6443 "[N] -> { A[i,j] -> [i + N]; B[i,j] -> [j + N] }" },
6445 "C[{ A[i,j] -> [i]; B[i,j] -> [j] }]",
6446 "{ C[a] -> [a] : a >= 0; C[a] -> [-a] : a < 0 }",
6447 "{ A[i,j] -> [i] : i >= 0; A[i,j] -> [-i] : i < 0; "
6448 "B[i,j] -> [j] : j >= 0; B[i,j] -> [-j] : j < 0 }" },
6450 "C[]",
6451 "[N] -> { C[] -> [N] }",
6452 "[N] -> { [N] }" },
6454 "C[]",
6455 "[N] -> { C[] -> [N] : N >= 0; C[] -> [-N] : N < 0 }",
6456 "[N] -> { [N] : N >= 0; [-N] : N < 0 }" },
6458 "[N] -> (C[] : { : N >= 0 })",
6459 "[N] -> { C[] -> [N] }",
6460 "[N] -> { [N] : N >= 0 }" },
6462 "[N] -> (C[] : { : N >= 0 })",
6463 "[N] -> { C[] -> [N] : N >= 0; C[] -> [-N] : N < 0 }",
6464 "[N] -> { [N] : N >= 0 }" },
6466 "[N] -> (C[] : { : N >= 0 })",
6467 "{ C[] -> [0] }",
6468 "[N] -> { [0] : N >= 0 }" },
6470 "(C[] : { A[i,j] : i >= j })",
6471 "[N] -> { C[] -> [N] }",
6472 "[N] -> { A[i,j] -> [N] : i >= j }" },
6474 "(C[] : { A[i,j] : i >= j })",
6475 "[N] -> { C[] -> [N] : N >= 0 }",
6476 "[N] -> { A[i,j] -> [N] : i >= j and N >= 0 }" },
6478
6479/* Perform some basic tests of binary operations on
6480 * pairs of isl_multi_union_pw_aff and isl_pw_aff objects.
6481 */
6482static int test_mupa_pa(isl_ctx *ctx)
6483{
6484 int i;
6485 isl_bool ok;
6487 isl_union_pw_aff *upa, *res;
6488 isl_pw_aff *pa;
6489
6490 for (i = 0; i < ARRAY_SIZE(mupa_pa_tests); ++i) {
6492 mupa_pa_tests[i].arg1);
6495 mupa_pa_tests[i].res);
6496 upa = mupa_pa_tests[i].fn(mupa, pa);
6500 if (ok < 0)
6501 return -1;
6502 if (!ok)
6504 "unexpected result", return -1);
6505 }
6506
6507 return 0;
6508}
6509
6510/* Inputs for basic tests of binary operations on
6511 * pairs of isl_multi_union_pw_aff and isl_pw_multi_aff objects.
6512 * "fn" is the function that is tested.
6513 * "arg1" and "arg2" are string descriptions of the inputs.
6514 * "res" is a string description of the expected result.
6515 */
6516struct {
6520 const char *arg1;
6521 const char *arg2;
6522 const char *res;
6523} mupa_pma_tests[] = {
6525 "C[{ A[i,j] -> [i]; B[i,j] -> [j] }, "
6526 "{ A[i,j] -> [j]; B[i,j] -> [i] }]",
6527 "{ C[a,b] -> D[b,a] }",
6528 "D[{ A[i,j] -> [j]; B[i,j] -> [i] }, "
6529 "{ A[i,j] -> [i]; B[i,j] -> [j] }]" },
6531 "C[{ A[i,j] -> [i] : i >= 0; B[i,j] -> [j] }, "
6532 "{ A[i,j] -> [j]; B[i,j] -> [i] }]",
6533 "{ C[a,b] -> D[b,a] }",
6534 "D[{ A[i,j] -> [j] : i >= 0; B[i,j] -> [i] }, "
6535 "{ A[i,j] -> [i] : i >= 0; B[i,j] -> [j] }]" },
6537 "C[{ A[i,j] -> [i]; B[i,j] -> [j] }]",
6538 "[N] -> { C[a] -> D[a + N] }",
6539 "[N] -> D[{ A[i,j] -> [i + N]; B[i,j] -> [j + N] }]" },
6541 "C[{ A[i,j] -> [i]; B[i,j] -> [j] }]",
6542 "{ C[a] -> D[a] : a >= 0; C[a] -> D[-a] : a < 0 }",
6543 "D[{ A[i,j] -> [i] : i >= 0; A[i,j] -> [-i] : i < 0; "
6544 "B[i,j] -> [j] : j >= 0; B[i,j] -> [-j] : j < 0 }]" },
6546 "C[{ A[i,j] -> [i]; B[i,j] -> [j] }, "
6547 "{ A[i,j] -> [j]; B[i,j] -> [i] }]",
6548 "{ C[a,b] -> D[a,b] : a >= b; C[a,b] -> D[b,a] : a < b }",
6549 "D[{ A[i,j] -> [i] : i >= j; A[i,j] -> [j] : i < j; "
6550 "B[i,j] -> [j] : i <= j; B[i,j] -> [i] : i > j }, "
6551 "{ A[i,j] -> [j] : i >= j; A[i,j] -> [i] : i < j; "
6552 "B[i,j] -> [i] : i <= j; B[i,j] -> [j] : i > j }]" },
6554 "C[]",
6555 "{ C[] -> D[] }",
6556 "D[]" },
6558 "[N] -> (C[] : { : N >= 0 })",
6559 "{ C[] -> D[] }",
6560 "[N] -> (D[] : { : N >= 0 })" },
6562 "C[]",
6563 "[N] -> { C[] -> D[N] }",
6564 "[N] -> D[{ [N] }]" },
6566 "(C[] : { A[i,j] : i >= j })",
6567 "{ C[] -> D[] }",
6568 "(D[] : { A[i,j] : i >= j })" },
6570 "[N] -> (C[] : { A[i,j] : N >= 0 })",
6571 "{ C[] -> D[] }",
6572 "[N] -> (D[] : { A[i,j] : N >= 0 })" },
6574 "(C[] : { A[i,j] : i >= j })",
6575 "[N] -> { C[] -> D[N] }",
6576 "[N] -> (D[{ A[i,j] -> [N] : i >= j }])" },
6578 "C[]",
6579 "[N] -> { C[] -> D[N] : N >= 0; C[] -> D[-N] : N < 0 }",
6580 "[N] -> D[{ [N] : N >= 0; [-N] : N < 0 }]" },
6582 "[N] -> (C[] : { : N >= 0 })",
6583 "[N] -> { C[] -> D[N] }",
6584 "[N] -> D[{ [N] : N >= 0 }]" },
6586 "[N] -> (C[] : { : N >= 0 })",
6587 "[N] -> { C[] -> D[N] : N >= 0; C[] -> D[-N] : N < 0 }",
6588 "[N] -> D[{ [N] : N >= 0 }]" },
6590 "[N] -> (C[] : { : N >= 0 })",
6591 "{ C[] -> D[0] }",
6592 "[N] -> D[{ [0] : N >= 0 }]" },
6594 "(C[] : { A[i,j] : i >= j })",
6595 "[N] -> { C[] -> D[N] : N >= 0 }",
6596 "[N] -> D[{ A[i,j] -> [N] : i >= j and N >= 0 }]" },
6598
6599/* Perform some basic tests of binary operations on
6600 * pairs of isl_multi_union_pw_aff and isl_pw_multi_aff objects.
6601 */
6602static int test_mupa_pma(isl_ctx *ctx)
6603{
6604 int i;
6605 isl_bool ok;
6608
6609 for (i = 0; i < ARRAY_SIZE(mupa_pma_tests); ++i) {
6611 mupa_pma_tests[i].arg1);
6613 mupa_pma_tests[i].arg2);
6615 mupa_pma_tests[i].res);
6616 mupa = mupa_pma_tests[i].fn(mupa, pma);
6617 ok = isl_multi_union_pw_aff_plain_is_equal(mupa, res);
6618 isl_multi_union_pw_aff_free(mupa);
6619 isl_multi_union_pw_aff_free(res);
6620 if (ok < 0)
6621 return -1;
6622 if (!ok)
6624 "unexpected result", return -1);
6625 }
6626
6627 return 0;
6628}
6629
6630/* Inputs for basic tests of binary operations on
6631 * pairs of isl_multi_union_pw_aff and isl_union_pw_multi_aff objects.
6632 * "fn" is the function that is tested.
6633 * "arg1" and "arg2" are string descriptions of the inputs.
6634 * "res" is a string description of the expected result.
6635 */
6636struct {
6640 const char *arg1;
6641 const char *arg2;
6642 const char *res;
6643} mupa_upma_tests[] = {
6645 "C[{ B[i,j] -> [i + 2j] }]", "{ A[a,b] -> B[b,a] }",
6646 "C[{ A[a,b] -> [b + 2a] }]" },
6648 "C[{ B[i,j] -> [i + 2j] }]",
6649 "{ A[a,b] -> B[b,a] : b > a }",
6650 "C[{ A[a,b] -> [b + 2a] : b > a }]" },
6652 "C[{ B[i,j] -> [i + 2j] : j > 4 }]",
6653 "{ A[a,b] -> B[b,a] : b > a }",
6654 "C[{ A[a,b] -> [b + 2a] : b > a > 4 }]" },
6656 "C[{ B[i,j] -> [i + 2j] }]",
6657 "{ A[a,b] -> B[b,a] : a > b; A[a,b] -> B[a,b] : a <= b }",
6658 "C[{ A[a,b] -> [b + 2a] : a > b; A[a,b] -> [a + 2b] : a <= b }]" },
6660 "(C[] : { B[a,b] })",
6661 "{ A[a,b] -> B[b,a] }",
6662 "(C[] : { A[a,b] })" },
6664 "(C[] : { B[a,b] })",
6665 "{ B[a,b] -> A[b,a] }",
6666 "(C[] : { })" },
6668 "(C[] : { B[a,b] })",
6669 "{ A[a,b] -> B[b,a] : a > b }",
6670 "(C[] : { A[a,b] : a > b })" },
6672 "(C[] : { B[a,b] : a > b })",
6673 "{ A[a,b] -> B[b,a] }",
6674 "(C[] : { A[a,b] : b > a })" },
6676 "[N] -> (C[] : { B[a,b] : a > N })",
6677 "{ A[a,b] -> B[b,a] : a > b }",
6678 "[N] -> (C[] : { A[a,b] : a > b > N })" },
6680 "(C[] : { B[a,b] : a > b })",
6681 "[N] -> { A[a,b] -> B[b,a] : a > N }",
6682 "[N] -> (C[] : { A[a,b] : b > a > N })" },
6684 "C[]",
6685 "{ A[a,b] -> B[b,a] }",
6686 "C[]" },
6688 "[N] -> (C[] : { : N >= 0 })",
6689 "{ A[a,b] -> B[b,a] }",
6690 "[N] -> (C[] : { : N >= 0 })" },
6692 "C[]",
6693 "[N] -> { A[a,b] -> B[b,a] : N >= 0 }",
6694 "[N] -> (C[] : { : N >= 0 })" },
6696
6697/* Perform some basic tests of binary operations on
6698 * pairs of isl_multi_union_pw_aff and isl_union_pw_multi_aff objects.
6699 */
6700static int test_mupa_upma(isl_ctx *ctx)
6701{
6702 int i;
6703 isl_bool ok;
6706
6707 for (i = 0; i < ARRAY_SIZE(mupa_upma_tests); ++i) {
6713 mupa_upma_tests[i].res);
6714 mupa = mupa_upma_tests[i].fn(mupa, upma);
6715 ok = isl_multi_union_pw_aff_plain_is_equal(mupa, res);
6716 isl_multi_union_pw_aff_free(mupa);
6717 isl_multi_union_pw_aff_free(res);
6718 if (ok < 0)
6719 return -1;
6720 if (!ok)
6722 "unexpected result", return -1);
6723 }
6724
6725 return 0;
6726}
6727
6728/* Check that the input tuple of an isl_aff can be set properly.
6729 */
6731{
6732 isl_id *id;
6733 isl_aff *aff;
6735
6736 aff = isl_aff_read_from_str(ctx, "{ [x] -> [x + 1] }");
6737 id = isl_id_alloc(ctx, "A", NULL);
6739 equal = aff_check_plain_equal(aff, "{ A[x] -> [x + 1] }");
6741 if (equal < 0)
6742 return isl_stat_error;
6743
6744 return isl_stat_ok;
6745}
6746
6747/* Check that affine expressions get normalized on addition/subtraction.
6748 * In particular, check that (final) unused integer divisions get removed
6749 * such that an expression derived from expressions with integer divisions
6750 * is found to be obviously equal to one that is created directly.
6751 */
6753{
6754 isl_aff *aff, *aff2;
6755 isl_stat ok;
6756
6757 aff = isl_aff_read_from_str(ctx, "{ [x] -> [x//2] }");
6758 aff2 = isl_aff_read_from_str(ctx, "{ [x] -> [1 + x//2] }");
6759 aff = isl_aff_sub(aff2, aff);
6760 ok = aff_check_plain_equal(aff, "{ [x] -> [1] }");
6762
6763 return ok;
6764}
6765
6767{
6768 const char *str;
6769 isl_set *set;
6770 isl_space *space;
6771 isl_local_space *ls;
6772 isl_aff *aff;
6773 int zero;
6775
6776 if (test_upa(ctx) < 0)
6777 return -1;
6778 if (test_bin_aff(ctx) < 0)
6779 return -1;
6780 if (test_bin_pw_aff(ctx) < 0)
6781 return -1;
6782 if (test_upma_test(ctx) < 0)
6783 return -1;
6784 if (test_bin_upma(ctx) < 0)
6785 return -1;
6786 if (test_bin_upma_fail(ctx) < 0)
6787 return -1;
6788 if (test_upma_uset(ctx) < 0)
6789 return -1;
6790 if (test_un_mpa(ctx) < 0)
6791 return -1;
6792 if (test_bin_mpa(ctx) < 0)
6793 return -1;
6794 if (test_un_mupa(ctx) < 0)
6795 return -1;
6796 if (test_bin_mupa(ctx) < 0)
6797 return -1;
6798 if (test_mupa_set(ctx) < 0)
6799 return -1;
6800 if (test_mupa_uset(ctx) < 0)
6801 return -1;
6802 if (test_mupa_ma(ctx) < 0)
6803 return -1;
6804 if (test_mupa_pa(ctx) < 0)
6805 return -1;
6806 if (test_mupa_pma(ctx) < 0)
6807 return -1;
6808 if (test_mupa_upma(ctx) < 0)
6809 return -1;
6810
6811 space = isl_space_set_alloc(ctx, 0, 1);
6812 ls = isl_local_space_from_space(space);
6814
6822
6823 str = "{ [10] }";
6825 aff = isl_aff_gist(aff, set);
6826
6828 zero = isl_aff_plain_is_zero(aff);
6830
6831 if (zero < 0)
6832 return -1;
6833 if (!zero)
6834 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
6835
6836 aff = isl_aff_read_from_str(ctx, "{ [-1] }");
6839 equal = aff_check_plain_equal(aff, "{ [-1] }");
6841 if (equal < 0)
6842 return -1;
6843
6844 if (test_aff_set_tuple_id(ctx) < 0)
6845 return -1;
6846 if (test_aff_normalize(ctx) < 0)
6847 return -1;
6848
6849 return 0;
6850}
6851
6852/* Inputs for isl_set_bind tests.
6853 * "set" is the input set.
6854 * "tuple" is the binding tuple.
6855 * "res" is the expected result.
6856 */
6857static
6858struct {
6859 const char *set;
6860 const char *tuple;
6861 const char *res;
6862} bind_set_tests[] = {
6863 { "{ A[M, N] : M mod 2 = 0 and N mod 8 = 3 }",
6864 "{ A[M, N] }",
6865 "[M, N] -> { : M mod 2 = 0 and N mod 8 = 3 }" },
6866 { "{ B[N, M] : M mod 2 = 0 and N mod 8 = 3 }",
6867 "{ B[N, M] }",
6868 "[M, N] -> { : M mod 2 = 0 and N mod 8 = 3 }" },
6869 { "[M] -> { C[N] : M mod 2 = 0 and N mod 8 = 3 }",
6870 "{ C[N] }",
6871 "[M, N] -> { : M mod 2 = 0 and N mod 8 = 3 }" },
6872 { "[M] -> { D[x, N] : x mod 2 = 0 and N mod 8 = 3 and M >= 0 }",
6873 "{ D[M, N] }",
6874 "[M, N] -> { : M mod 2 = 0 and N mod 8 = 3 and M >= 0 }" },
6876
6877/* Perform basic isl_set_bind tests.
6878 */
6880{
6881 int i;
6882
6883 for (i = 0; i < ARRAY_SIZE(bind_set_tests); ++i) {
6884 const char *str;
6885 isl_set *set;
6887 isl_stat r;
6888
6890 str = bind_set_tests[i].tuple;
6895 if (r < 0)
6896 return isl_stat_error;
6897 }
6898
6899 return isl_stat_ok;
6900}
6901
6902/* Inputs for isl_map_bind_domain tests.
6903 * "map" is the input map.
6904 * "tuple" is the binding tuple.
6905 * "res" is the expected result.
6906 */
6907struct {
6908 const char *map;
6909 const char *tuple;
6910 const char *res;
6912 { "{ A[M, N] -> [M + floor(N/2)] }",
6913 "{ A[M, N] }",
6914 "[M, N] -> { [M + floor(N/2)] }" },
6915 { "{ B[N, M] -> [M + floor(N/2)] }",
6916 "{ B[N, M] }",
6917 "[N, M] -> { [M + floor(N/2)] }" },
6918 { "[M] -> { C[N] -> [M + floor(N/2)] }",
6919 "{ C[N] }",
6920 "[M, N] -> { [M + floor(N/2)] }" },
6921 { "[M] -> { C[x, N] -> [x + floor(N/2)] }",
6922 "{ C[M, N] }",
6923 "[M, N] -> { [M + floor(N/2)] }" },
6924 { "[M] -> { C[x, N] -> [M + floor(N/2)] }",
6925 "{ C[M, N] }",
6926 "[M, N] -> { [M + floor(N/2)] }" },
6927 { "[A, M] -> { C[N, x] -> [x + floor(N/2)] }",
6928 "{ C[N, M] }",
6929 "[A, N, M] -> { [M + floor(N/2)] }" },
6931
6932/* Perform basic isl_map_bind_domain tests.
6933 */
6935{
6936 int i;
6937
6938 for (i = 0; i < ARRAY_SIZE(bind_map_domain_tests); ++i) {
6939 const char *str;
6940 isl_map *map;
6941 isl_set *set;
6943 isl_stat r;
6944
6945 str = bind_map_domain_tests[i].map;
6947 str = bind_map_domain_tests[i].tuple;
6950 str = bind_map_domain_tests[i].res;
6951 r = set_check_equal(set, str);
6953 if (r < 0)
6954 return isl_stat_error;
6955 }
6956
6957 return isl_stat_ok;
6958}
6959
6960/* Inputs for isl_union_map_bind_range tests.
6961 * "map" is the input union map.
6962 * "tuple" is the binding tuple.
6963 * "res" is the expected result.
6964 */
6965struct {
6966 const char *map;
6967 const char *tuple;
6968 const char *res;
6970 { "{ B[N, M] -> A[M, N] : M mod 2 = 0 and N mod 8 = 3 }",
6971 "{ A[M, N] }",
6972 "[M, N] -> { B[N, M] : M mod 2 = 0 and N mod 8 = 3 }" },
6973 { "{ B[N, M] -> A[M, N] : M mod 2 = 0 and N mod 8 = 3 }",
6974 "{ B[M, N] }",
6975 "{ }" },
6976 { "{ A[] -> B[]; C[] -> D[]; E[] -> B[] }",
6977 "{ B[] }",
6978 "{ A[]; E[] }" },
6980
6981/* Perform basic isl_union_map_bind_range tests.
6982 */
6984{
6985 int i;
6986
6987 for (i = 0; i < ARRAY_SIZE(bind_umap_range_tests); ++i) {
6988 const char *str;
6989 isl_union_map *umap;
6990 isl_union_set *uset;
6992 isl_stat r;
6993
6994 str = bind_umap_range_tests[i].map;
6995 umap = isl_union_map_read_from_str(ctx, str);
6996 str = bind_umap_range_tests[i].tuple;
6998 uset = isl_union_map_bind_range(umap, tuple);
6999 str = bind_umap_range_tests[i].res;
7000 r = uset_check_equal(uset, str);
7001 isl_union_set_free(uset);
7002 if (r < 0)
7003 return isl_stat_error;
7004 }
7005
7006 return isl_stat_ok;
7007}
7008
7009/* Inputs for isl_pw_multi_aff_bind_domain tests.
7010 * "pma" is the input expression.
7011 * "tuple" is the binding tuple.
7012 * "res" is the expected result.
7013 */
7014struct {
7015 const char *pma;
7016 const char *tuple;
7017 const char *res;
7019 { "{ A[M, N] -> [M + floor(N/2)] }",
7020 "{ A[M, N] }",
7021 "[M, N] -> { [M + floor(N/2)] }" },
7022 { "{ B[N, M] -> [M + floor(N/2)] }",
7023 "{ B[N, M] }",
7024 "[N, M] -> { [M + floor(N/2)] }" },
7025 { "[M] -> { C[N] -> [M + floor(N/2)] }",
7026 "{ C[N] }",
7027 "[M, N] -> { [M + floor(N/2)] }" },
7028 { "[M] -> { C[x, N] -> [x + floor(N/2)] }",
7029 "{ C[M, N] }",
7030 "[M, N] -> { [M + floor(N/2)] }" },
7031 { "[M] -> { C[x, N] -> [M + floor(N/2)] }",
7032 "{ C[M, N] }",
7033 "[M, N] -> { [M + floor(N/2)] }" },
7034 { "[A, M] -> { C[N, x] -> [x + floor(N/2)] }",
7035 "{ C[N, M] }",
7036 "[A, N, M] -> { [M + floor(N/2)] }" },
7038
7039/* Perform basic isl_pw_multi_aff_bind_domain tests.
7040 */
7042{
7043 int i;
7044
7045 for (i = 0; i < ARRAY_SIZE(bind_pma_domain_tests); ++i) {
7046 const char *str;
7049 isl_stat r;
7050
7051 str = bind_pma_domain_tests[i].pma;
7053 str = bind_pma_domain_tests[i].tuple;
7056 str = bind_pma_domain_tests[i].res;
7057 r = pw_multi_aff_check_plain_equal(pma, str);
7059 if (r < 0)
7060 return isl_stat_error;
7061 }
7062
7063 return isl_stat_ok;
7064}
7065
7066/* Inputs for isl_pw_multi_aff_bind_domain_wrapped_domain tests.
7067 * "pma" is the input expression.
7068 * "tuple" is the binding tuple.
7069 * "res" is the expected result.
7070 */
7071struct {
7072 const char *pma;
7073 const char *tuple;
7074 const char *res;
7076 { "{ [A[M, N] -> B[]] -> [M + floor(N/2)] }",
7077 "{ A[M, N] }",
7078 "[M, N] -> { B[] -> [M + floor(N/2)] }" },
7079 { "{ [B[N, M] -> D[]] -> [M + floor(N/2)] }",
7080 "{ B[N, M] }",
7081 "[N, M] -> { D[] -> [M + floor(N/2)] }" },
7082 { "[M] -> { [C[N] -> B[x]] -> [x + M + floor(N/2)] }",
7083 "{ C[N] }",
7084 "[M, N] -> { B[x] -> [x + M + floor(N/2)] }" },
7085 { "[M] -> { [C[x, N] -> B[]] -> [x + floor(N/2)] }",
7086 "{ C[M, N] }",
7087 "[M, N] -> { B[] -> [M + floor(N/2)] }" },
7088 { "[M] -> { [C[x, N] -> B[]] -> [M + floor(N/2)] }",
7089 "{ C[M, N] }",
7090 "[M, N] -> { B[] -> [M + floor(N/2)] }" },
7091 { "[A, M] -> { [C[N, x] -> B[]] -> [x + floor(N/2)] }",
7092 "{ C[N, M] }",
7093 "[A, N, M] -> { B[] -> [M + floor(N/2)] }" },
7095
7096/* Perform basic isl_pw_multi_aff_bind_domain_wrapped_domain tests.
7097 */
7099{
7100 int i;
7101
7102 for (i = 0; i < ARRAY_SIZE(bind_pma_domain_wrapped_tests); ++i) {
7103 const char *str;
7106 isl_stat r;
7107
7114 r = pw_multi_aff_check_plain_equal(pma, str);
7116 if (r < 0)
7117 return isl_stat_error;
7118 }
7119
7120 return isl_stat_ok;
7121}
7122
7123/* Inputs for isl_aff_bind_id tests.
7124 * "aff" is the input expression.
7125 * "id" is the binding id.
7126 * "res" is the expected result.
7127 */
7128static
7129struct {
7130 const char *aff;
7131 const char *id;
7132 const char *res;
7133} bind_aff_tests[] = {
7134 { "{ [4] }", "M", "[M = 4] -> { : }" },
7135 { "{ B[x] -> [floor(x/2)] }", "M", "[M] -> { B[x] : M = floor(x/2) }" },
7136 { "[M] -> { [4] }", "M", "[M = 4] -> { : }" },
7137 { "[M] -> { [floor(M/2)] }", "M", "[M] -> { : floor(M/2) = M }" },
7138 { "{ [NaN] }", "M", "{ : false }" },
7139 { "{ A[x] -> [NaN] }", "M", "{ A[x] : false }" },
7141
7142/* Perform basic isl_aff_bind_id tests.
7143 */
7145{
7146 int i;
7147
7148 for (i = 0; i < ARRAY_SIZE(bind_aff_tests); ++i) {
7149 isl_aff *aff;
7150 isl_set *res;
7151 isl_id *id;
7152 isl_stat r;
7153
7155 id = isl_id_read_from_str(ctx, bind_aff_tests[i].id);
7159 if (r < 0)
7160 return isl_stat_error;
7161 }
7162
7163 return isl_stat_ok;
7164}
7165
7166/* Inputs for isl_pw_aff_bind_id tests.
7167 * "pa" is the input expression.
7168 * "id" is the binding id.
7169 * "res" is the expected result.
7170 */
7171static
7172struct {
7173 const char *pa;
7174 const char *id;
7175 const char *res;
7176} bind_pa_tests[] = {
7177 { "{ [4] }", "M", "[M = 4] -> { : }" },
7178 { "{ B[x] -> [floor(x/2)] }", "M", "[M] -> { B[x] : M = floor(x/2) }" },
7179 { "[M] -> { [4] }", "M", "[M = 4] -> { : }" },
7180 { "[M] -> { [floor(M/2)] }", "M", "[M] -> { : floor(M/2) = M }" },
7181 { "[M] -> { [M] : M >= 0; [-M] : M < 0 }", "M", "[M] -> { : M >= 0 }" },
7182 { "{ [NaN] }", "M", "{ : false }" },
7183 { "{ A[x] -> [NaN] }", "M", "{ A[x] : false }" },
7185
7186/* Perform basic isl_pw_aff_bind_id tests.
7187 */
7189{
7190 int i;
7191
7192 for (i = 0; i < ARRAY_SIZE(bind_pa_tests); ++i) {
7193 isl_pw_aff *pa;
7194 isl_set *res;
7195 isl_id *id;
7196 isl_stat r;
7197
7199 id = isl_id_read_from_str(ctx, bind_pa_tests[i].id);
7200 res = isl_pw_aff_bind_id(pa, id);
7203 if (r < 0)
7204 return isl_stat_error;
7205 }
7206
7207 return isl_stat_ok;
7208}
7209
7210/* Inputs for isl_multi_union_pw_aff_bind tests.
7211 * "mupa" is the input expression.
7212 * "tuple" is the binding tuple.
7213 * "res" is the expected result.
7214 */
7215static
7216struct {
7217 const char *mupa;
7218 const char *tuple;
7219 const char *res;
7220} bind_mupa_tests[] = {
7221 { "A[{ [4] }, { [5] }]",
7222 "{ A[M, N] }",
7223 "[M = 4, N = 5] -> { : }" },
7224 { "A[{ B[x] -> [floor(x/2)] }, { B[y] -> [y + 5] }]",
7225 "{ A[M, N] }",
7226 "[M, N] -> { B[x] : M = floor(x/2) and N = x + 5 }" },
7227 { "[M] -> A[{ [4] }, { [M + 1] }]",
7228 "{ A[M, N] }",
7229 "[M = 4, N = 5] -> { : }" },
7231
7232/* Perform basic isl_multi_union_pw_aff_bind tests.
7233 */
7235{
7236 int i;
7237
7238 for (i = 0; i < ARRAY_SIZE(bind_mupa_tests); ++i) {
7239 const char *str;
7243 isl_stat r;
7244
7245 str = bind_mupa_tests[i].mupa;
7247 str = bind_mupa_tests[i].tuple;
7252 if (r < 0)
7253 return isl_stat_error;
7254 }
7255
7256 return isl_stat_ok;
7257}
7258
7259/* Perform tests that reinterpret dimensions as parameters.
7260 */
7261static int test_bind(isl_ctx *ctx)
7262{
7263 if (test_bind_set(ctx) < 0)
7264 return -1;
7265 if (test_bind_map_domain(ctx) < 0)
7266 return -1;
7267 if (test_bind_umap_range(ctx) < 0)
7268 return -1;
7269 if (test_bind_pma_domain(ctx) < 0)
7270 return -1;
7271 if (test_bind_pma_domain_wrapped(ctx) < 0)
7272 return -1;
7273 if (test_bind_aff(ctx) < 0)
7274 return -1;
7275 if (test_bind_pa(ctx) < 0)
7276 return -1;
7277 if (test_bind_mupa(ctx) < 0)
7278 return -1;
7279
7280 return 0;
7281}
7282
7283/* Inputs for isl_set_unbind_params tests.
7284 * "set" is the input parameter domain.
7285 * "tuple" is the tuple of the constructed set.
7286 * "res" is the expected result.
7287 */
7288struct {
7289 const char *set;
7290 const char *tuple;
7291 const char *res;
7292} unbind_set_tests[] = {
7293 { "[M, N] -> { : M mod 2 = 0 and N mod 8 = 3 }",
7294 "{ A[M, N] }",
7295 "{ A[M, N] : M mod 2 = 0 and N mod 8 = 3 }" },
7296 { "[M, N] -> { : M mod 2 = 0 and N mod 8 = 3 }",
7297 "{ B[N, M] }",
7298 "{ B[N, M] : M mod 2 = 0 and N mod 8 = 3 }" },
7299 { "[M, N] -> { : M mod 2 = 0 and N mod 8 = 3 }",
7300 "{ C[N] }",
7301 "[M] -> { C[N] : M mod 2 = 0 and N mod 8 = 3 }" },
7302 { "[M, N] -> { : M mod 2 = 0 and N mod 8 = 3 }",
7303 "{ D[T, N] }",
7304 "[M] -> { D[x, N] : M mod 2 = 0 and N mod 8 = 3 }" },
7306
7307/* Perform basic isl_set_unbind_params tests.
7308 */
7310{
7311 int i;
7312
7313 for (i = 0; i < ARRAY_SIZE(unbind_set_tests); ++i) {
7314 const char *str;
7315 isl_set *set;
7317 isl_stat r;
7318
7320 str = unbind_set_tests[i].tuple;
7325 if (r < 0)
7326 return isl_stat_error;
7327 }
7328
7329 return isl_stat_ok;
7330}
7331
7332/* Inputs for isl_aff_unbind_params_insert_domain tests.
7333 * "aff" is the input affine expression defined over a parameter domain.
7334 * "tuple" is the tuple of the domain that gets introduced.
7335 * "res" is the expected result.
7336 */
7337struct {
7338 const char *aff;
7339 const char *tuple;
7340 const char *res;
7341} unbind_aff_tests[] = {
7342 { "[M, N] -> { [M + floor(N/2)] }",
7343 "{ A[M, N] }",
7344 "{ A[M, N] -> [M + floor(N/2)] }" },
7345 { "[M, N] -> { [M + floor(N/2)] }",
7346 "{ B[N, M] }",
7347 "{ B[N, M] -> [M + floor(N/2)] }" },
7348 { "[M, N] -> { [M + floor(N/2)] }",
7349 "{ C[N] }",
7350 "[M] -> { C[N] -> [M + floor(N/2)] }" },
7351 { "[M, N] -> { [M + floor(N/2)] }",
7352 "{ D[A, B, C, N, Z] }",
7353 "[M] -> { D[A, B, C, N, Z] -> [M + floor(N/2)] }" },
7355
7356/* Perform basic isl_aff_unbind_params_insert_domain tests.
7357 */
7359{
7360 int i;
7361
7362 for (i = 0; i < ARRAY_SIZE(unbind_aff_tests); ++i) {
7363 const char *str;
7364 isl_aff *aff;
7366 isl_stat r;
7367
7369 str = unbind_aff_tests[i].tuple;
7372 r = aff_check_plain_equal(aff, unbind_aff_tests[i].res);
7374 if (r < 0)
7375 return isl_stat_error;
7376 }
7377
7378 return isl_stat_ok;
7379}
7380
7381/* Inputs for isl_multi_aff_unbind_params_insert_domain tests.
7382 * "ma" is the input multi affine expression defined over a parameter domain.
7383 * "tuple" is the tuple of the domain that gets introduced.
7384 * "res" is the expected result.
7385 */
7386static struct {
7387 const char *ma;
7388 const char *tuple;
7389 const char *res;
7391 { "[M, N] -> { T[M + floor(N/2)] }",
7392 "{ A[M, N] }",
7393 "{ A[M, N] -> T[M + floor(N/2)] }" },
7394 { "[M, N] -> { [M + floor(N/2)] }",
7395 "{ B[N, M] }",
7396 "{ B[N, M] -> [M + floor(N/2)] }" },
7397 { "[M, N] -> { [M + floor(N/2)] }",
7398 "{ C[N] }",
7399 "[M] -> { C[N] -> [M + floor(N/2)] }" },
7400 { "[M, N] -> { [M + floor(N/2)] }",
7401 "{ D[A, B, C, N, Z] }",
7402 "[M] -> { D[A, B, C, N, Z] -> [M + floor(N/2)] }" },
7403 { "[M, N] -> { T[M + floor(N/2), N + floor(M/3)] }",
7404 "{ A[M, N] }",
7405 "{ A[M, N] -> T[M + floor(N/2), N + floor(M/3)] }" },
7407
7408/* Perform basic isl_multi_aff_unbind_params_insert_domain tests.
7409 */
7411{
7412 int i;
7413
7414 for (i = 0; i < ARRAY_SIZE(unbind_multi_aff_tests); ++i) {
7415 const char *str;
7418 isl_stat r;
7419
7422 str = unbind_multi_aff_tests[i].tuple;
7424 ma = isl_multi_aff_unbind_params_insert_domain(ma, tuple);
7425 str = unbind_multi_aff_tests[i].res;
7426 r = multi_aff_check_plain_equal(ma, str);
7427 isl_multi_aff_free(ma);
7428 if (r < 0)
7429 return isl_stat_error;
7430 }
7431
7432 return isl_stat_ok;
7433}
7434
7435/* Perform tests that reinterpret parameters.
7436 */
7437static int test_unbind(isl_ctx *ctx)
7438{
7439 if (test_unbind_set(ctx) < 0)
7440 return -1;
7441 if (test_unbind_aff(ctx) < 0)
7442 return -1;
7443 if (test_unbind_multi_aff(ctx) < 0)
7444 return -1;
7445
7446 return 0;
7447}
7448
7449/* Check that "pa" consists of a single expression.
7450 */
7452{
7453 isl_size n;
7454
7457
7458 if (n < 0)
7459 return -1;
7460 if (n != 1)
7461 isl_die(ctx, isl_error_unknown, "expecting single expression",
7462 return -1);
7463
7464 return 0;
7465}
7466
7467/* Check that the computation below results in a single expression.
7468 * One or two expressions may result depending on which constraint
7469 * ends up being considered as redundant with respect to the other
7470 * constraints after the projection that is performed internally
7471 * by isl_set_dim_min.
7472 */
7473static int test_dim_max_1(isl_ctx *ctx)
7474{
7475 const char *str;
7476 isl_set *set;
7477 isl_pw_aff *pa;
7478
7479 str = "[n] -> { [a, b] : n >= 0 and 4a >= -4 + n and b >= 0 and "
7480 "-4a <= b <= 3 and b < n - 4a }";
7482 pa = isl_set_dim_min(set, 0);
7483 return check_single_piece(ctx, pa);
7484}
7485
7486/* Check that the computation below results in a single expression.
7487 * The PIP problem corresponding to these constraints has a row
7488 * that causes a split of the solution domain. The solver should
7489 * first pick rows that split off empty parts such that the actual
7490 * solution domain does not get split.
7491 * Note that the description contains some redundant constraints.
7492 * If these constraints get removed first, then the row mentioned
7493 * above does not appear in the PIP problem.
7494 */
7495static int test_dim_max_2(isl_ctx *ctx)
7496{
7497 const char *str;
7498 isl_set *set;
7499 isl_pw_aff *pa;
7500
7501 str = "[P, N] -> { [a] : a < N and a >= 0 and N > P and a <= P and "
7502 "N > 0 and P >= 0 }";
7504 pa = isl_set_dim_max(set, 0);
7505 return check_single_piece(ctx, pa);
7506}
7507
7509{
7510 int equal;
7511 const char *str;
7512 isl_set *set1, *set2;
7513 isl_set *set;
7514 isl_map *map;
7515 isl_pw_aff *pwaff;
7516
7517 if (test_dim_max_1(ctx) < 0)
7518 return -1;
7519 if (test_dim_max_2(ctx) < 0)
7520 return -1;
7521
7522 str = "[N] -> { [i] : 0 <= i <= min(N,10) }";
7524 pwaff = isl_set_dim_max(set, 0);
7525 set1 = isl_set_from_pw_aff(pwaff);
7526 str = "[N] -> { [10] : N >= 10; [N] : N <= 9 and N >= 0 }";
7531 if (equal < 0)
7532 return -1;
7533 if (!equal)
7534 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7535
7536 str = "[N] -> { [i] : 0 <= i <= max(2N,N+6) }";
7538 pwaff = isl_set_dim_max(set, 0);
7539 set1 = isl_set_from_pw_aff(pwaff);
7540 str = "[N] -> { [6 + N] : -6 <= N <= 5; [2N] : N >= 6 }";
7545 if (equal < 0)
7546 return -1;
7547 if (!equal)
7548 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7549
7550 str = "[N] -> { [i] : 0 <= i <= 2N or 0 <= i <= N+6 }";
7552 pwaff = isl_set_dim_max(set, 0);
7553 set1 = isl_set_from_pw_aff(pwaff);
7554 str = "[N] -> { [6 + N] : -6 <= N <= 5; [2N] : N >= 6 }";
7559 if (equal < 0)
7560 return -1;
7561 if (!equal)
7562 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7563
7564 str = "[N,M] -> { [i,j] -> [([i/16]), i%16, ([j/16]), j%16] : "
7565 "0 <= i < N and 0 <= j < M }";
7568
7569 pwaff = isl_set_dim_max(isl_set_copy(set), 0);
7570 set1 = isl_set_from_pw_aff(pwaff);
7571 str = "[N,M] -> { [([(N-1)/16])] : M,N > 0 }";
7576
7577 pwaff = isl_set_dim_max(isl_set_copy(set), 3);
7578 set1 = isl_set_from_pw_aff(pwaff);
7579 str = "[N,M] -> { [t] : t = min(M-1,15) and M,N > 0 }";
7581 if (equal >= 0 && equal)
7585
7587
7588 if (equal < 0)
7589 return -1;
7590 if (!equal)
7591 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7592
7593 /* Check that solutions are properly merged. */
7594 str = "[n] -> { [a, b, c] : c >= -4a - 2b and "
7595 "c <= -1 + n - 4a - 2b and c >= -2b and "
7596 "4a >= -4 + n and c >= 0 }";
7598 pwaff = isl_set_dim_min(set, 2);
7599 set1 = isl_set_from_pw_aff(pwaff);
7600 str = "[n] -> { [(0)] : n >= 1 }";
7605
7606 if (equal < 0)
7607 return -1;
7608 if (!equal)
7609 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7610
7611 /* Check that empty solution lie in the right space. */
7612 str = "[n] -> { [t,a] : 1 = 0 }";
7614 pwaff = isl_set_dim_max(set, 0);
7615 set1 = isl_set_from_pw_aff(pwaff);
7616 str = "[n] -> { [t] : 1 = 0 }";
7621
7622 if (equal < 0)
7623 return -1;
7624 if (!equal)
7625 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7626
7627 return 0;
7628}
7629
7630/* Basic test for isl_pw_multi_aff_product.
7631 *
7632 * Check that multiple pieces are properly handled.
7633 */
7635{
7637 const char *str;
7638 isl_pw_multi_aff *pma1, *pma2;
7639
7640 str = "{ A[i] -> B[1] : i < 0; A[i] -> B[2] : i >= 0 }";
7642 str = "{ C[] -> D[] }";
7644 pma1 = isl_pw_multi_aff_product(pma1, pma2);
7645 str = "{ [A[i] -> C[]] -> [B[(1)] -> D[]] : i < 0;"
7646 "[A[i] -> C[]] -> [B[(2)] -> D[]] : i >= 0 }";
7647 equal = pw_multi_aff_check_plain_equal(pma1, str);
7649 if (equal < 0)
7650 return -1;
7651
7652 return 0;
7653}
7654
7656{
7657 const char *str;
7658 isl_set *set;
7659 isl_union_set *uset1, *uset2;
7660 int ok;
7661
7662 str = "{ A[i] }";
7667 if (ok < 0)
7668 return -1;
7669 if (!ok)
7670 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7671
7672 str = "{ [] }";
7673 uset1 = isl_union_set_read_from_str(ctx, str);
7674 uset1 = isl_union_set_product(uset1, isl_union_set_copy(uset1));
7675 str = "{ [[] -> []] }";
7676 uset2 = isl_union_set_read_from_str(ctx, str);
7677 ok = isl_union_set_is_equal(uset1, uset2);
7678 isl_union_set_free(uset1);
7679 isl_union_set_free(uset2);
7680 if (ok < 0)
7681 return -1;
7682 if (!ok)
7683 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7684
7685 if (test_product_pma(ctx) < 0)
7686 return -1;
7687
7688 return 0;
7689}
7690
7691/* Check that two sets are not considered disjoint just because
7692 * they have a different set of (named) parameters.
7693 */
7694static int test_disjoint(isl_ctx *ctx)
7695{
7696 const char *str;
7697 isl_set *set, *set2;
7698 int disjoint;
7699
7700 str = "[n] -> { [[]->[]] }";
7702 str = "{ [[]->[]] }";
7704 disjoint = isl_set_is_disjoint(set, set2);
7707 if (disjoint < 0)
7708 return -1;
7709 if (disjoint)
7710 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7711
7712 return 0;
7713}
7714
7715/* Inputs for isl_pw_multi_aff_is_equal tests.
7716 * "f1" and "f2" are the two function that need to be compared.
7717 * "equal" is the expected result.
7718 */
7719struct {
7721 const char *f1;
7722 const char *f2;
7723} pma_equal_tests[] = {
7724 { 1, "[N] -> { [floor(N/2)] : 0 <= N <= 1 }",
7725 "[N] -> { [0] : 0 <= N <= 1 }" },
7726 { 1, "[N] -> { [floor(N/2)] : 0 <= N <= 2 }",
7727 "[N] -> { [0] : 0 <= N <= 1; [1] : N = 2 }" },
7728 { 0, "[N] -> { [floor(N/2)] : 0 <= N <= 2 }",
7729 "[N] -> { [0] : 0 <= N <= 1 }" },
7730 { 0, "{ [NaN] }", "{ [NaN] }" },
7732
7734{
7735 int i;
7736 const char *str;
7737 isl_set *set, *set2;
7738 int equal;
7739
7740 str = "{ S_6[i] }";
7742 str = "{ S_7[i] }";
7747 if (equal < 0)
7748 return -1;
7749 if (equal)
7750 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7751
7752 for (i = 0; i < ARRAY_SIZE(pma_equal_tests); ++i) {
7753 int expected = pma_equal_tests[i].equal;
7755
7761 if (equal < 0)
7762 return -1;
7763 if (equal != expected)
7765 "unexpected equality result", return -1);
7766 }
7767
7768 return 0;
7769}
7770
7772 enum isl_dim_type type, unsigned pos, int fixed)
7773{
7774 isl_bool test;
7775
7778 if (test < 0)
7779 return -1;
7780 if (test == fixed)
7781 return 0;
7782 if (fixed)
7784 "map not detected as fixed", return -1);
7785 else
7787 "map detected as fixed", return -1);
7788}
7789
7791{
7792 const char *str;
7793 isl_map *map;
7794
7795 str = "{ [i] -> [i] }";
7797 if (test_plain_fixed(ctx, map, isl_dim_out, 0, 0))
7798 return -1;
7799 str = "{ [i] -> [1] }";
7801 if (test_plain_fixed(ctx, map, isl_dim_out, 0, 1))
7802 return -1;
7803 str = "{ S_1[p1] -> [o0] : o0 = -2 and p1 >= 1 and p1 <= 7 }";
7805 if (test_plain_fixed(ctx, map, isl_dim_out, 0, 1))
7806 return -1;
7808 map = isl_map_neg(map);
7809 if (test_plain_fixed(ctx, map, isl_dim_out, 0, 1))
7810 return -1;
7811
7812 return 0;
7813}
7814
7816 const char *set;
7817 int n;
7818 const char *vertex[6];
7819} vertices_tests[] = {
7820 { "{ A[t, i] : t = 12 and i >= 4 and i <= 12 }",
7821 2, { "{ A[12, 4] }", "{ A[12, 12] }" } },
7822 { "{ A[t, i] : t = 14 and i = 1 }",
7823 1, { "{ A[14, 1] }" } },
7824 { "[n, m] -> { [a, b, c] : b <= a and a <= n and b > 0 and c >= b and "
7825 "c <= m and m <= n and m > 0 }",
7826 6, {
7827 "[n, m] -> { [n, m, m] : 0 < m <= n }",
7828 "[n, m] -> { [n, 1, m] : 0 < m <= n }",
7829 "[n, m] -> { [n, 1, 1] : 0 < m <= n }",
7830 "[n, m] -> { [m, m, m] : 0 < m <= n }",
7831 "[n, m] -> { [1, 1, m] : 0 < m <= n }",
7832 "[n, m] -> { [1, 1, 1] : 0 < m <= n }"
7833 } },
7834 /* An input with implicit equality constraints among the parameters. */
7835 { "[N, M] -> { [a, b] : M >= 3 and 9 + 3M <= a <= 29 + 2N + 11M and "
7836 "2b >= M + a and 5 - 2N - M + a <= 2b <= 3 + a and "
7837 "3b >= 15 + a }",
7838 2, {
7839 "[N, M] -> { [(21), (12)] : M = 3 and N >= 0 }",
7840 "[N, M] -> { [(61 + 2N), (32 + N)] : M = 3 and N >= 0 }",
7841 }
7842 },
7844
7845/* Check that "vertex" corresponds to one of the vertices in data->vertex.
7846 */
7848{
7849 struct isl_vertices_test_data *data = user;
7850 isl_ctx *ctx;
7852 isl_basic_set *bset;
7854 int i;
7856
7861
7862 for (i = 0; i < data->n; ++i) {
7863 isl_pw_multi_aff *pma_i;
7864
7865 pma_i = isl_pw_multi_aff_read_from_str(ctx, data->vertex[i]);
7867 isl_pw_multi_aff_free(pma_i);
7868
7869 if (equal < 0 || equal)
7870 break;
7871 }
7872
7875
7876 if (equal < 0)
7877 return isl_stat_error;
7878
7879 return equal ? isl_stat_ok : isl_stat_error;
7880}
7881
7883{
7884 int i;
7885
7886 for (i = 0; i < ARRAY_SIZE(vertices_tests); ++i) {
7887 isl_basic_set *bset;
7888 isl_vertices *vertices;
7889 int ok = 1;
7890 isl_size n;
7891
7893 vertices = isl_basic_set_compute_vertices(bset);
7894 n = isl_vertices_get_n_vertices(vertices);
7895 if (vertices_tests[i].n != n)
7896 ok = 0;
7898 &vertices_tests[i]) < 0)
7899 ok = 0;
7900 isl_vertices_free(vertices);
7901 isl_basic_set_free(bset);
7902
7903 if (n < 0)
7904 return -1;
7905 if (!ok)
7906 isl_die(ctx, isl_error_unknown, "unexpected vertices",
7907 return -1);
7908 }
7909
7910 return 0;
7911}
7912
7913/* Inputs for basic tests of binary operations on isl_union_map.
7914 * "fn" is the function that is being tested.
7915 * "arg1" and "arg2" are string descriptions of the inputs.
7916 * "res" is a string description of the expected result.
7917 */
7918static struct {
7920 __isl_take isl_union_map *umap2);
7921 const char *arg1;
7922 const char *arg2;
7923 const char *res;
7924} umap_bin_tests[] = {
7926 "[n] -> { A[i] -> [] : 0 <= i <= n; B[] -> [] }",
7927 "[m] -> { A[i] -> [] : 0 <= i <= m; C[] -> [] }",
7928 "[m, n] -> { A[i] -> [] : 0 <= i <= n and i <= m }" },
7930 "{ [A[i] -> B[i + 1]] -> C[i + 2] }",
7931 "[N] -> { B[i] -> C[N] }",
7932 "{ }" },
7934 "{ [A[i] -> B[i + 1]] -> C[i + 2] }",
7935 "[N] -> { A[i] -> C[N] }",
7936 "[N] -> { [A[N - 2] -> B[N - 1]] -> C[N] }" },
7938 "{ T[A[i] -> B[i + 1]] -> C[i + 2] }",
7939 "[N] -> { A[i] -> C[N] }",
7940 "[N] -> { T[A[N - 2] -> B[N - 1]] -> C[N] }" },
7942 "{ [A[i] -> B[i + 1]] -> C[i + 2] }",
7943 "[N] -> { B[i] -> C[N] }",
7944 "[N] -> { [A[N - 2] -> B[N - 1]] -> C[N] }" },
7946 "{ T[A[i] -> B[i + 1]] -> C[i + 2] }",
7947 "[N] -> { B[i] -> C[N] }",
7948 "[N] -> { T[A[N - 2] -> B[N - 1]] -> C[N] }" },
7950 "{ [A[i] -> B[i + 1]] -> C[i + 2] }",
7951 "[N] -> { A[i] -> C[N] }",
7952 "{ }" },
7954 "{ A[i] -> [B[i + 1] -> C[i + 2]] }",
7955 "[N] -> { A[i] -> B[N] }",
7956 "[N] -> { A[N - 1] -> [B[N] -> C[N + 1]] }" },
7958 "{ A[i] -> T[B[i + 1] -> C[i + 2]] }",
7959 "[N] -> { A[i] -> B[N] }",
7960 "[N] -> { A[N - 1] -> T[B[N] -> C[N + 1]] }" },
7962 "{ A[i] -> [B[i + 1] -> C[i + 2]] }",
7963 "[N] -> { A[i] -> C[N] }",
7964 "{ }" },
7966 "{ A[i] -> [B[i + 1] -> C[i + 2]] }",
7967 "[N] -> { A[i] -> C[N] }",
7968 "[N] -> { A[N - 2] -> [B[N - 1] -> C[N]] }" },
7970 "{ A[i] -> T[B[i + 1] -> C[i + 2]] }",
7971 "[N] -> { A[i] -> C[N] }",
7972 "[N] -> { A[N - 2] -> T[B[N - 1] -> C[N]] }" },
7974 "{ A[i] -> [B[i + 1] -> C[i + 2]] }",
7975 "[N] -> { A[i] -> B[N] }",
7976 "{ }" },
7978
7979/* Perform basic tests of binary operations on isl_union_map.
7980 */
7982{
7983 int i;
7984
7985 for (i = 0; i < ARRAY_SIZE(umap_bin_tests); ++i) {
7986 const char *str;
7987 isl_union_map *umap1, *umap2, *res;
7989
7990 str = umap_bin_tests[i].arg1;
7991 umap1 = isl_union_map_read_from_str(ctx, str);
7992 str = umap_bin_tests[i].arg2;
7993 umap2 = isl_union_map_read_from_str(ctx, str);
7994 str = umap_bin_tests[i].res;
7996 umap1 = umap_bin_tests[i].fn(umap1, umap2);
7998 isl_union_map_free(umap1);
8000 if (equal < 0)
8001 return isl_stat_error;
8002 if (!equal)
8004 "unexpected result", return isl_stat_error);
8005 }
8006
8007 return isl_stat_ok;
8008}
8009
8010/* Check that isl_union_set_contains finds space independently
8011 * of the parameters.
8012 */
8014{
8015 const char *str;
8016 isl_bool ok;
8017 isl_space *space;
8018 isl_id *id;
8019 isl_union_set *uset;
8020
8021 str = "[N] -> { A[0:N]; B[*,*] }";
8022 uset = isl_union_set_read_from_str(ctx, str);
8023 space = isl_space_unit(ctx);
8024 id = isl_id_alloc(ctx, "A", NULL);
8025 space = isl_space_add_named_tuple_id_ui(space, id, 1);
8026 ok = isl_union_set_contains(uset, space);
8027 isl_space_free(space);
8028 isl_union_set_free(uset);
8029
8030 if (ok < 0)
8031 return isl_stat_error;
8032 if (!ok)
8034 "unexpected result", return isl_stat_error);
8035
8036 return isl_stat_ok;
8037}
8038
8039/* Perform basic tests of operations on isl_union_map or isl_union_set.
8040 */
8041static int test_union_map(isl_ctx *ctx)
8042{
8043 if (test_bin_union_map(ctx) < 0)
8044 return -1;
8045 if (test_union_set_contains(ctx) < 0)
8046 return -1;
8047 return 0;
8048}
8049
8050#undef BASE
8051#define BASE union_pw_qpolynomial
8053
8054/* Check that the result of applying "fn" to "a" and "b"
8055 * in (obviously) equal to "res".
8056 */
8057static isl_stat test_union_pw_op(isl_ctx *ctx, const char *a, const char *b,
8061 const char *res)
8062{
8063 isl_stat r;
8064 isl_union_pw_qpolynomial *upwqp1, *upwqp2;
8065
8068 upwqp1 = fn(upwqp1, upwqp2);
8069 r = union_pw_qpolynomial_check_plain_equal(upwqp1, res);
8071
8072 return r;
8073}
8074
8076{
8077 int equal;
8078 isl_stat r;
8079 const char *str;
8080 isl_union_set *uset;
8081 isl_union_pw_qpolynomial *upwqp1, *upwqp2;
8082 const char *a, *b;
8083
8084 str = "{ [x] -> x^2 }";
8086 upwqp2 = isl_union_pw_qpolynomial_copy(upwqp1);
8087 uset = isl_union_pw_qpolynomial_domain(upwqp1);
8088 upwqp1 = isl_union_pw_qpolynomial_copy(upwqp2);
8089 upwqp1 = isl_union_pw_qpolynomial_intersect_domain(upwqp1, uset);
8093 if (equal < 0)
8094 return -1;
8095 if (!equal)
8096 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
8097
8098 a = "{ A[x] -> x^2 : x >= 0; B[x] -> x }";
8099 b = "{ A[x] -> x }";
8100 str = "{ A[x] -> x^2 + x : x >= 0; A[x] -> x : x < 0; B[x] -> x }";
8102 return -1;
8103 str = "{ A[x] -> x^2 - x : x >= 0; A[x] -> -x : x < 0; B[x] -> x }";
8105 return -1;
8106
8107 str = "{ A[x] -> 0 }";
8108 a = "{ A[x] -> 1 }";
8109 b = "{ A[x] -> -1 }";
8111 return -1;
8112 a = "{ A[x] -> 1 }";
8113 b = "{ A[x] -> 1 }";
8115 return -1;
8116
8117 str = "{ [A[x] -> B[y,z]] -> x^2 + y * floor(x/4) * floor(z/2); "
8118 "C[z] -> z^3 }";
8121 str = "{ [B[y,z] -> A[x]] -> x^2 + y * floor(x/4) * floor(z/2) }";
8122 r = union_pw_qpolynomial_check_plain_equal(upwqp1, str);
8124 if (r < 0)
8125 return -1;
8126
8127 return 0;
8128}
8129
8130/* Inputs for basic tests of functions that select
8131 * subparts of the domain of an isl_multi_union_pw_aff.
8132 * "fn" is the function that is tested.
8133 * "arg" is a string description of the input.
8134 * "res" is a string description of the expected result.
8135 */
8136struct {
8139 const char *arg;
8140 const char *res;
8141} un_locus_tests[] = {
8143 "F[{ A[i,j] -> [i]; B[i,j] -> [i] }]",
8144 "{ A[0,j]; B[0,j] }" },
8146 "F[{ A[i,j] -> [i-j]; B[i,j] -> [i-j] : i >= 0 }]",
8147 "{ A[i,i]; B[i,i] : i >= 0 }" },
8149 "(F[] : { A[i,j]; B[i,i] : i >= 0 })",
8150 "{ A[i,j]; B[i,i] : i >= 0 }" },
8152
8153/* Perform some basic tests of functions that select
8154 * subparts of the domain of an isl_multi_union_pw_aff.
8155 */
8156static int test_un_locus(isl_ctx *ctx)
8157{
8158 int i;
8159 isl_bool ok;
8160 isl_union_set *uset, *res;
8162
8163 for (i = 0; i < ARRAY_SIZE(un_locus_tests); ++i) {
8165 un_locus_tests[i].arg);
8167 uset = un_locus_tests[i].fn(mupa);
8168 ok = isl_union_set_is_equal(uset, res);
8169 isl_union_set_free(uset);
8171 if (ok < 0)
8172 return -1;
8173 if (!ok)
8175 "unexpected result", return -1);
8176 }
8177
8178 return 0;
8179}
8180
8181/* Inputs for basic tests of functions that select
8182 * subparts of an isl_union_map based on a relation
8183 * specified by an isl_multi_union_pw_aff.
8184 * "fn" is the function that is tested.
8185 * "arg1" and "arg2" are string descriptions of the inputs.
8186 * "res" is a string description of the expected result.
8187 */
8188struct {
8192 const char *arg1;
8193 const char *arg2;
8194 const char *res;
8195} bin_locus_tests[] = {
8197 "{ A[i,j] -> B[i',j'] }",
8198 "F[{ A[i,j] -> [i]; B[i,j] -> [i] }]",
8199 "{ A[i,j] -> B[i,j'] }" },
8201 "{ A[i,j] -> B[i',j'] }",
8202 "F[{ A[i,j] -> [i]; B[i,j] -> [i] }, "
8203 "{ A[i,j] -> [j]; B[i,j] -> [j] }]",
8204 "{ A[i,j] -> B[i,j] }" },
8206 "{ A[i,j] -> B[i',j']; A[i,j] -> C[i',j'] }",
8207 "F[{ A[i,j] -> [i]; B[i,j] -> [i] }]",
8208 "{ A[i,j] -> B[i,j'] }" },
8210 "{ A[i,j] -> B[i',j']; A[i,j] -> C[i',j'] }",
8211 "F[{ A[i,j] -> [i]; B[i,j] -> [i]; C[i,j] -> [0] }]",
8212 "{ A[i,j] -> B[i,j']; A[0,j] -> C[i',j'] }" },
8214 "{ A[i,j] -> B[i',j'] }",
8215 "F[{ A[i,j] -> [i] : i > j; B[i,j] -> [i] }]",
8216 "{ A[i,j] -> B[i,j'] : i > j }" },
8218 "{ A[i,j] -> B[i',j'] }",
8219 "F[{ A[i,j] -> [i]; B[i,j] -> [i] }, "
8220 "{ A[i,j] -> [j]; B[i,j] -> [j] }]",
8221 "{ A[i,j] -> B[i',j'] : i,j <<= i',j' }" },
8223 "{ A[i,j] -> B[i',j'] }",
8224 "F[{ A[i,j] -> [i]; B[i,j] -> [i] }, "
8225 "{ A[i,j] -> [j]; B[i,j] -> [j] }]",
8226 "{ A[i,j] -> B[i',j'] : i,j << i',j' }" },
8228 "{ A[i,j] -> B[i',j'] }",
8229 "F[{ A[i,j] -> [i]; B[i,j] -> [i] }, "
8230 "{ A[i,j] -> [j]; B[i,j] -> [j] }]",
8231 "{ A[i,j] -> B[i',j'] : i,j >>= i',j' }" },
8233 "{ A[i,j] -> B[i',j'] }",
8234 "F[{ A[i,j] -> [i]; B[i,j] -> [i] }, "
8235 "{ A[i,j] -> [j]; B[i,j] -> [j] }]",
8236 "{ A[i,j] -> B[i',j'] : i,j >> i',j' }" },
8238 "{ A[i,j] -> B[i',j']; A[i,j] -> C[i',j'] }",
8239 "(F[] : { A[i,j]; B[i,j] })",
8240 "{ A[i,j] -> B[i',j'] }" },
8242 "{ A[i,j] -> B[i',j'] }",
8243 "(F[] : { A[i,j] : i > j; B[i,j] : i < j })",
8244 "{ A[i,j] -> B[i',j'] : i > j and i' < j' }" },
8246 "[N] -> { A[i,j] -> B[i',j'] : i,i' <= N }",
8247 "(F[] : { A[i,j] : i > j; B[i,j] : i < j })",
8248 "[N] -> { A[i,j] -> B[i',j'] : i > j and i' < j' and i,i' <= N }" },
8250 "{ A[i,j] -> B[i',j'] }",
8251 "[N] -> (F[] : { A[i,j] : i < N; B[i,j] : i < N })",
8252 "[N] -> { A[i,j] -> B[i',j'] : i,i' < N }" },
8254 "{ A[i,j] -> B[i',j'] }",
8255 "[N] -> (F[] : { : N >= 0 })",
8256 "[N] -> { A[i,j] -> B[i',j'] : N >= 0 }" },
8258
8259/* Perform some basic tests of functions that select
8260 * subparts of an isl_union_map based on a relation
8261 * specified by an isl_multi_union_pw_aff.
8262 */
8263static int test_bin_locus(isl_ctx *ctx)
8264{
8265 int i;
8266 isl_bool ok;
8267 isl_union_map *umap, *res;
8269
8270 for (i = 0; i < ARRAY_SIZE(bin_locus_tests); ++i) {
8271 umap = isl_union_map_read_from_str(ctx,
8276 umap = bin_locus_tests[i].fn(umap, mupa);
8277 ok = isl_union_map_is_equal(umap, res);
8278 isl_union_map_free(umap);
8280 if (ok < 0)
8281 return -1;
8282 if (!ok)
8284 "unexpected result", return -1);
8285 }
8286
8287 return 0;
8288}
8289
8290/* Inputs for basic tests of functions that determine
8291 * the part of the domain where two isl_multi_aff objects
8292 * related to each other in a specific way.
8293 * "fn" is the function that is being tested.
8294 * "arg1" and "arg2" are string descriptions of the inputs.
8295 * "res" is a string description of the expected result.
8296 */
8297static struct {
8300 const char *arg1;
8301 const char *arg2;
8302 const char *res;
8303} bin_locus_ma_tests[] = {
8304 { &isl_multi_aff_lex_le_set, "{ [] }", "{ [] }", "{ : }" },
8305 { &isl_multi_aff_lex_lt_set, "{ [] }", "{ [] }", "{ : false }" },
8307 "{ A[i] -> [i] }", "{ A[i] -> [0] }",
8308 "{ A[i] : i <= 0 }" },
8310 "{ A[i] -> [i] }", "{ A[i] -> [0] }",
8311 "{ A[i] : i < 0 }" },
8313 "{ A[i] -> [i, i] }", "{ A[i] -> [0, 0] }",
8314 "{ A[i] : i <= 0 }" },
8316 "{ A[i] -> [i, 0] }", "{ A[i] -> [0, 0] }",
8317 "{ A[i] : i <= 0 }" },
8319 "{ A[i] -> [i, 1] }", "{ A[i] -> [0, 0] }",
8320 "{ A[i] : i < 0 }" },
8322
8323/* Perform some basic tests of functions that determine
8324 * the part of the domain where two isl_multi_aff objects
8325 * related to each other in a specific way.
8326 */
8328{
8329 int i;
8330
8331 for (i = 0; i < ARRAY_SIZE(bin_locus_ma_tests); ++i) {
8332 const char *str;
8333 isl_bool ok;
8334 isl_multi_aff *ma1, *ma2;
8335 isl_set *set, *res;
8336
8337 str = bin_locus_ma_tests[i].arg1;
8339 str = bin_locus_ma_tests[i].arg2;
8340 ma2 = isl_multi_aff_read_from_str(ctx, str);
8342 set = bin_locus_ma_tests[i].fn(ma1, ma2);
8343 ok = isl_set_is_equal(set, res);
8346 if (ok < 0)
8347 return isl_stat_error;
8348 if (!ok)
8350 "unexpected result", return isl_stat_error);
8351 }
8352
8353 return isl_stat_ok;
8354}
8355
8356/* Perform basic locus tests.
8357 */
8358static int test_locus(isl_ctx *ctx)
8359{
8360 if (test_un_locus(ctx) < 0)
8361 return -1;
8362 if (test_bin_locus(ctx) < 0)
8363 return -1;
8364 if (test_bin_locus_ma(ctx) < 0)
8365 return -1;
8366 return 0;
8367}
8368
8369/* Test that isl_union_pw_qpolynomial_eval picks up the function
8370 * defined over the correct domain space.
8371 */
8372static int test_eval_1(isl_ctx *ctx)
8373{
8374 const char *str;
8375 isl_point *pnt;
8376 isl_set *set;
8378 isl_val *v;
8379 int cmp;
8380
8381 str = "{ A[x] -> x^2; B[x] -> -x^2 }";
8383 str = "{ A[6] }";
8386 v = isl_union_pw_qpolynomial_eval(upwqp, pnt);
8387 cmp = isl_val_cmp_si(v, 36);
8388 isl_val_free(v);
8389
8390 if (!v)
8391 return -1;
8392 if (cmp != 0)
8393 isl_die(ctx, isl_error_unknown, "unexpected value", return -1);
8394
8395 return 0;
8396}
8397
8398/* Check that isl_qpolynomial_eval handles getting called on a void point.
8399 */
8400static int test_eval_2(isl_ctx *ctx)
8401{
8402 const char *str;
8403 isl_point *pnt;
8404 isl_set *set;
8405 isl_qpolynomial *qp;
8406 isl_val *v;
8407 isl_bool ok;
8408
8409 str = "{ A[x] -> [x] }";
8411 str = "{ A[x] : false }";
8414 v = isl_qpolynomial_eval(qp, pnt);
8415 ok = isl_val_is_nan(v);
8416 isl_val_free(v);
8417
8418 if (ok < 0)
8419 return -1;
8420 if (!ok)
8421 isl_die(ctx, isl_error_unknown, "expecting NaN", return -1);
8422
8423 return 0;
8424}
8425
8426/* Check that a polynomial (without local variables) can be evaluated
8427 * in a rational point.
8428 */
8430{
8432 isl_point *pnt;
8433 isl_val *v;
8434 isl_stat r;
8435
8436 pwqp = isl_pw_qpolynomial_read_from_str(ctx, "{ [x] -> x^2 }");
8438 v = isl_val_read_from_str(ctx, "1/2");
8439 pnt = isl_point_set_coordinate_val(pnt, isl_dim_set, 0, v);
8440 v = isl_pw_qpolynomial_eval(pwqp, pnt);
8441 r = val_check_equal(v, "1/4");
8442 isl_val_free(v);
8443
8444 return r;
8445}
8446
8447/* Inputs for isl_pw_aff_eval test.
8448 * "f" is the affine function.
8449 * "p" is the point where the function should be evaluated.
8450 * "res" is the expected result.
8451 */
8452struct {
8453 const char *f;
8454 const char *p;
8455 const char *res;
8456} aff_eval_tests[] = {
8457 { "{ [i] -> [2 * i] }", "{ [4] }", "8" },
8458 { "{ [i] -> [2 * i] }", "{ [x] : false }", "NaN" },
8459 { "{ [i] -> [i + floor(i/2) + floor(i/3)] }", "{ [0] }", "0" },
8460 { "{ [i] -> [i + floor(i/2) + floor(i/3)] }", "{ [1] }", "1" },
8461 { "{ [i] -> [i + floor(i/2) + floor(i/3)] }", "{ [2] }", "3" },
8462 { "{ [i] -> [i + floor(i/2) + floor(i/3)] }", "{ [3] }", "5" },
8463 { "{ [i] -> [i + floor(i/2) + floor(i/3)] }", "{ [4] }", "7" },
8464 { "{ [i] -> [floor((3 * floor(i/2))/5)] }", "{ [0] }", "0" },
8465 { "{ [i] -> [floor((3 * floor(i/2))/5)] }", "{ [1] }", "0" },
8466 { "{ [i] -> [floor((3 * floor(i/2))/5)] }", "{ [2] }", "0" },
8467 { "{ [i] -> [floor((3 * floor(i/2))/5)] }", "{ [3] }", "0" },
8468 { "{ [i] -> [floor((3 * floor(i/2))/5)] }", "{ [4] }", "1" },
8469 { "{ [i] -> [floor((3 * floor(i/2))/5)] }", "{ [6] }", "1" },
8470 { "{ [i] -> [floor((3 * floor(i/2))/5)] }", "{ [8] }", "2" },
8471 { "{ [i] -> [i] : i > 0; [i] -> [-i] : i < 0 }", "{ [4] }", "4" },
8472 { "{ [i] -> [i] : i > 0; [i] -> [-i] : i < 0 }", "{ [-2] }", "2" },
8473 { "{ [i] -> [i] : i > 0; [i] -> [-i] : i < 0 }", "{ [0] }", "NaN" },
8474 { "[N] -> { [2 * N] }", "[N] -> { : N = 4 }", "8" },
8475 { "{ [i, j] -> [(i + j)/2] }", "{ [1, 1] }", "1" },
8476 { "{ [i, j] -> [(i + j)/2] }", "{ [1, 2] }", "3/2" },
8477 { "{ [i] -> [i] : i mod 2 = 0 }", "{ [4] }", "4" },
8478 { "{ [i] -> [i] : i mod 2 = 0 }", "{ [3] }", "NaN" },
8479 { "{ [i] -> [i] : i mod 2 = 0 }", "{ [x] : false }", "NaN" },
8480 { "[m, n] -> { [2m + 3n] }", "[n=1, m=10] -> { : }", "23" },
8482
8483/* Perform basic isl_pw_aff_eval tests.
8484 */
8485static int test_eval_aff(isl_ctx *ctx)
8486{
8487 int i;
8488
8489 for (i = 0; i < ARRAY_SIZE(aff_eval_tests); ++i) {
8490 isl_stat r;
8491 isl_pw_aff *pa;
8492 isl_set *set;
8493 isl_point *pnt;
8494 isl_val *v;
8495
8499 v = isl_pw_aff_eval(pa, pnt);
8501 isl_val_free(v);
8502 if (r < 0)
8503 return -1;
8504 }
8505 return 0;
8506}
8507
8508/* Perform basic evaluation tests.
8509 */
8510static int test_eval(isl_ctx *ctx)
8511{
8512 if (test_eval_1(ctx) < 0)
8513 return -1;
8514 if (test_eval_2(ctx) < 0)
8515 return -1;
8516 if (test_eval_3(ctx) < 0)
8517 return -1;
8518 if (test_eval_aff(ctx) < 0)
8519 return -1;
8520 return 0;
8521}
8522
8523/* Descriptions of sets that are tested for reparsing after printing.
8524 */
8525const char *output_tests[] = {
8526 "{ [1, y] : 0 <= y <= 1; [x, -x] : 0 <= x <= 1 }",
8527 "{ [x] : 1 = 0 }",
8528 "{ [x] : false }",
8529 "{ [x] : x mod 2 = 0 }",
8530 "{ [x] : x mod 2 = 1 }",
8531 "{ [x, y] : x mod 2 = 0 and 3*floor(y/2) < x }",
8532 "{ [y, x] : x mod 2 = 0 and 3*floor(y/2) < x }",
8533 "{ [x, y] : x mod 2 = 0 and 3*floor(y/2) = x + y }",
8534 "{ [y, x] : x mod 2 = 0 and 3*floor(y/2) = x + y }",
8535 "[n] -> { [y, x] : 2*((x + 2y) mod 3) = n }",
8536 "{ [x, y] : (2*floor(x/3) + 3*floor(y/4)) mod 5 = x }",
8537};
8538
8539/* Check that printing a set and reparsing a set from the printed output
8540 * results in the same set.
8541 */
8542static int test_output_set(isl_ctx *ctx)
8543{
8544 int i;
8545 char *str;
8546 isl_set *set1, *set2;
8548
8549 for (i = 0; i < ARRAY_SIZE(output_tests); ++i) {
8553 free(str);
8557 if (equal < 0)
8558 return -1;
8559 if (!equal)
8561 "parsed output not the same", return -1);
8562 }
8563
8564 return 0;
8565}
8566
8567/* Check that an isl_multi_aff is printed using a consistent space.
8568 */
8570{
8571 char *str;
8573 isl_aff *aff;
8574 isl_multi_aff *ma, *ma2;
8575
8576 ma = isl_multi_aff_read_from_str(ctx, "{ [a, b] -> [a + b] }");
8577 aff = isl_aff_read_from_str(ctx, "{ [c, d] -> [c + d] }");
8578 ma = isl_multi_aff_set_aff(ma, 0, aff);
8580 ma2 = isl_multi_aff_read_from_str(ctx, str);
8581 free(str);
8582 equal = isl_multi_aff_plain_is_equal(ma, ma2);
8583 isl_multi_aff_free(ma2);
8584 isl_multi_aff_free(ma);
8585
8586 if (equal < 0)
8587 return isl_stat_error;
8588 if (!equal)
8589 isl_die(ctx, isl_error_unknown, "bad conversion",
8590 return isl_stat_error);
8591
8592 return isl_stat_ok;
8593}
8594
8595/* Check that an isl_multi_pw_aff is printed using a consistent space.
8596 */
8598{
8599 char *str;
8601 isl_pw_aff *pa;
8602 isl_multi_pw_aff *mpa, *mpa2;
8603
8604 mpa = isl_multi_pw_aff_read_from_str(ctx, "{ [a, b] -> [a + b] }");
8605 pa = isl_pw_aff_read_from_str(ctx, "{ [c, d] -> [c + d] }");
8606 mpa = isl_multi_pw_aff_set_pw_aff(mpa, 0, pa);
8609 free(str);
8610 equal = isl_multi_pw_aff_plain_is_equal(mpa, mpa2);
8611 isl_multi_pw_aff_free(mpa2);
8612 isl_multi_pw_aff_free(mpa);
8613
8614 if (equal < 0)
8615 return isl_stat_error;
8616 if (!equal)
8617 isl_die(ctx, isl_error_unknown, "bad conversion",
8618 return isl_stat_error);
8619
8620 return isl_stat_ok;
8621}
8622
8624{
8625 char *s;
8626 const char *str;
8627 isl_pw_aff *pa;
8628 isl_printer *p;
8629 int equal;
8630
8631 if (test_output_set(ctx) < 0)
8632 return -1;
8633 if (test_output_ma(ctx) < 0)
8634 return -1;
8635 if (test_output_mpa(ctx) < 0)
8636 return -1;
8637
8638 str = "[x] -> { [1] : x % 4 <= 2; [2] : x = 3 }";
8640
8641 p = isl_printer_to_str(ctx);
8647 if (!s)
8648 equal = -1;
8649 else
8650 equal = !strcmp(s, "4 * floord(x, 4) + 2 >= x ? 1 : 2");
8651 free(s);
8652 if (equal < 0)
8653 return -1;
8654 if (!equal)
8655 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
8656
8657 return 0;
8658}
8659
8661{
8662 const char *str;
8663 isl_basic_set *bset1, *bset2;
8664 int empty, subset;
8665
8666 str = "{ [a, b, c, d, e, f, g, h, i, j, k] : "
8667 "3i >= 1073741823b - c - 1073741823e + f and c >= 0 and "
8668 "3i >= -1 + 3221225466b + c + d - 3221225466e - f and "
8669 "2e >= a - b and 3e <= 2a and 3k <= -a and f <= -1 + a and "
8670 "3i <= 4 - a + 4b + 2c - e - 2f and 3k <= -a + c - f and "
8671 "3h >= -2 + a and 3g >= -3 - a and 3k >= -2 - a and "
8672 "3i >= -2 - a - 2c + 3e + 2f and 3h <= a + c - f and "
8673 "3h >= a + 2147483646b + 2c - 2147483646e - 2f and "
8674 "3g <= -1 - a and 3i <= 1 + c + d - f and a <= 1073741823 and "
8675 "f >= 1 - a + 1073741822b + c + d - 1073741822e and "
8676 "3i >= 1 + 2b - 2c + e + 2f + 3g and "
8677 "1073741822f <= 1073741822 - a + 1073741821b + 1073741822c +"
8678 "d - 1073741821e and "
8679 "3j <= 3 - a + 3b and 3g <= -2 - 2b + c + d - e - f and "
8680 "3j >= 1 - a + b + 2e and "
8681 "3f >= -3 + a + 3221225462b + 3c + d - 3221225465e and "
8682 "3i <= 4 - a + 4b - e and "
8683 "f <= 1073741822 + 1073741822b - 1073741822e and 3h <= a and "
8684 "f >= 0 and 2e <= 4 - a + 5b - d and 2e <= a - b + d and "
8685 "c <= -1 + a and 3i >= -2 - a + 3e and "
8686 "1073741822e <= 1073741823 - a + 1073741822b + c and "
8687 "3g >= -4 + 3221225464b + 3c + d - 3221225467e - 3f and "
8688 "3i >= -1 + 3221225466b + 3c + d - 3221225466e - 3f and "
8689 "1073741823e >= 1 + 1073741823b - d and "
8690 "3i >= 1073741823b + c - 1073741823e - f and "
8691 "3i >= 1 + 2b + e + 3g }";
8692 bset1 = isl_basic_set_read_from_str(ctx, str);
8694 empty = isl_basic_set_is_empty(bset2);
8695 subset = isl_basic_set_is_subset(bset2, bset1);
8696 isl_basic_set_free(bset1);
8697 isl_basic_set_free(bset2);
8698 if (empty < 0 || subset < 0)
8699 return -1;
8700 if (empty)
8701 isl_die(ctx, isl_error_unknown, "point not found", return -1);
8702 if (!subset)
8703 isl_die(ctx, isl_error_unknown, "bad point found", return -1);
8704
8705 return 0;
8706}
8707
8708/* Perform a projection on a basic set that is known to be empty
8709 * but that has not been assigned a canonical representation.
8710 * Earlier versions of isl would run into a stack overflow
8711 * on this example.
8712 */
8714{
8715 const char *str;
8716 isl_bool empty;
8717 isl_basic_set *bset;
8718
8719 str = "{ [a, b, c, d, e, f, g, h] : 5f = 1 + 4a - b + 5c - d - 2e and "
8720 "3h = 2 + b + c and 14c >= 9 - 3a + 25b and "
8721 "4c <= 50 - 3a + 23b and 6b <= -39 + a and "
8722 "9g >= -6 + 3a + b + c and e < a + b - 2d and "
8723 "7d >= -5 + 2a + 2b and 5g >= -14 + a - 4b + d + 2e and "
8724 "9g <= -28 - 5b - 2c + 3d + 6e }";
8725 bset = isl_basic_set_read_from_str(ctx, str);
8726 empty = isl_basic_set_is_empty(bset);
8727 bset = isl_basic_set_params(bset);
8728 isl_basic_set_free(bset);
8729
8730 if (empty < 0)
8731 return -1;
8732
8733 return 0;
8734}
8735
8737{
8738 const char *str;
8739 isl_map *map;
8740 int equal;
8741
8742 str = "{ [i] -> [j] }";
8745 equal = map_check_equal(map, "{ [i] -> [i] }");
8747 if (equal < 0)
8748 return -1;
8749
8750 str = "{ [i] -> [j] }";
8753 equal = map_check_equal(map, "{ [i] -> [j] }");
8755 if (equal < 0)
8756 return -1;
8757
8758 str = "{ [i] -> [j] }";
8761 equal = map_check_equal(map, "{ [i] -> [-i] }");
8763 if (equal < 0)
8764 return -1;
8765
8766 str = "{ [i] -> [j] }";
8769 equal = map_check_equal(map, "{ [0] -> [j] }");
8771 if (equal < 0)
8772 return -1;
8773
8774 str = "{ [i] -> [j] }";
8777 equal = map_check_equal(map, "{ [i] -> [j] : i > j }");
8779 if (equal < 0)
8780 return -1;
8781
8782 str = "{ [i] -> [j] }";
8785 equal = map_check_equal(map, "{ [i] -> [j] : false }");
8787 if (equal < 0)
8788 return -1;
8789
8790 return 0;
8791}
8792
8794{
8795 const char *str;
8796 isl_map *map;
8797 int equal;
8798
8799 str = "{ [i] -> [j] : i = 2j }";
8802 equal = map_check_equal(map, "{ [i] -> [j] : exists a : i = 2a }");
8804 if (equal < 0)
8805 return -1;
8806
8807 return 0;
8808}
8809
8810/* Check basic functionality of isl_map_deltas_map.
8811 */
8812static int test_deltas_map(isl_ctx *ctx)
8813{
8814 const char *str;
8815 isl_map *map;
8816 int equal;
8817
8818 str = "{ A[i] -> A[i + 1] }";
8821 equal = map_check_equal(map, "{ [A[i] -> A[i + 1]] -> A[1] }");
8823 if (equal < 0)
8824 return -1;
8825
8826 return 0;
8827}
8828
8829/* Check that isl_set_dim_residue_class detects that the values of j
8830 * in the set below are all odd and that it does not detect any spurious
8831 * strides.
8832 */
8834{
8835 const char *str;
8836 isl_set *set;
8837 isl_int m, r;
8838 isl_stat res;
8839
8840 str = "{ [i,j] : j = 4 i + 1 and 0 <= i <= 100; "
8841 "[i,j] : j = 4 i + 3 and 500 <= i <= 600 }";
8843 isl_int_init(m);
8844 isl_int_init(r);
8845 res = isl_set_dim_residue_class(set, 1, &m, &r);
8846 if (res >= 0 &&
8847 (isl_int_cmp_si(m, 2) != 0 || isl_int_cmp_si(r, 1) != 0))
8848 isl_die(ctx, isl_error_unknown, "incorrect residue class",
8850 isl_int_clear(r);
8853
8854 return res;
8855}
8856
8858{
8859 const char *str;
8860 isl_space *space;
8861 isl_multi_aff *ma1, *ma2;
8862 int equal;
8863
8864 str = "{ A[B[] -> C[]] -> D[E[] -> F[]] }";
8866
8867 space = isl_space_params_alloc(ctx, 1);
8868 space = isl_space_set_dim_name(space, isl_dim_param, 0, "N");
8869 ma1 = isl_multi_aff_align_params(ma1, space);
8870
8871 str = "[N] -> { A[B[] -> C[]] -> D[E[] -> F[]] }";
8872 ma2 = isl_multi_aff_read_from_str(ctx, str);
8873
8874 equal = isl_multi_aff_plain_is_equal(ma1, ma2);
8875
8876 isl_multi_aff_free(ma1);
8877 isl_multi_aff_free(ma2);
8878
8879 if (equal < 0)
8880 return -1;
8881 if (!equal)
8883 "result not as expected", return -1);
8884
8885 return 0;
8886}
8887
8888/* Check the isl_multi_*_from_*_list operation in case inputs
8889 * have unaligned parameters.
8890 * In particular, older versions of isl would simply fail
8891 * (without printing any error message).
8892 */
8894{
8895 isl_space *space;
8896 isl_map *map;
8897 isl_aff *aff;
8899
8900 map = isl_map_read_from_str(ctx, "{ A[] -> M[x] }");
8901 space = isl_map_get_space(map);
8903
8904 aff = isl_aff_read_from_str(ctx, "[N] -> { A[] -> [N] }");
8905 ma = isl_multi_aff_from_aff_list(space, isl_aff_list_from_aff(aff));
8906 isl_multi_aff_free(ma);
8907
8908 if (!ma)
8909 return isl_stat_error;
8910 return isl_stat_ok;
8911}
8912
8913/* Perform basic parameter alignment tests.
8914 */
8916{
8917 if (test_align_parameters_1(ctx) < 0)
8918 return -1;
8919 if (test_align_parameters_2(ctx) < 0)
8920 return -1;
8921
8922 return 0;
8923}
8924
8925/* Check that isl_*_drop_unused_params actually drops the unused parameters
8926 * by comparing the result using isl_*_plain_is_equal.
8927 * Note that this assumes that isl_*_plain_is_equal does not consider
8928 * objects that only differ by unused parameters to be equal.
8929 */
8931{
8932 const char *str_with, *str_without;
8933 isl_basic_set *bset1, *bset2;
8934 isl_set *set1, *set2;
8935 isl_pw_aff *pwa1, *pwa2;
8936 int equal;
8937
8938 str_with = "[n, m, o] -> { [m] }";
8939 str_without = "[m] -> { [m] }";
8940
8941 bset1 = isl_basic_set_read_from_str(ctx, str_with);
8942 bset2 = isl_basic_set_read_from_str(ctx, str_without);
8943 bset1 = isl_basic_set_drop_unused_params(bset1);
8944 equal = isl_basic_set_plain_is_equal(bset1, bset2);
8945 isl_basic_set_free(bset1);
8946 isl_basic_set_free(bset2);
8947
8948 if (equal < 0)
8949 return -1;
8950 if (!equal)
8952 "result not as expected", return -1);
8953
8954 set1 = isl_set_read_from_str(ctx, str_with);
8955 set2 = isl_set_read_from_str(ctx, str_without);
8960
8961 if (equal < 0)
8962 return -1;
8963 if (!equal)
8965 "result not as expected", return -1);
8966
8967 pwa1 = isl_pw_aff_read_from_str(ctx, str_with);
8968 pwa2 = isl_pw_aff_read_from_str(ctx, str_without);
8969 pwa1 = isl_pw_aff_drop_unused_params(pwa1);
8970 equal = isl_pw_aff_plain_is_equal(pwa1, pwa2);
8971 isl_pw_aff_free(pwa1);
8972 isl_pw_aff_free(pwa2);
8973
8974 if (equal < 0)
8975 return -1;
8976 if (!equal)
8978 "result not as expected", return -1);
8979
8980 return 0;
8981}
8982
8983static int test_list(isl_ctx *ctx)
8984{
8985 isl_id *a, *b, *c, *d, *id;
8986 isl_id_list *list;
8987 isl_size n;
8988 int ok;
8989
8990 a = isl_id_alloc(ctx, "a", NULL);
8991 b = isl_id_alloc(ctx, "b", NULL);
8992 c = isl_id_alloc(ctx, "c", NULL);
8993 d = isl_id_alloc(ctx, "d", NULL);
8994
8995 list = isl_id_list_alloc(ctx, 4);
8996 list = isl_id_list_add(list, b);
8997 list = isl_id_list_insert(list, 0, a);
8998 list = isl_id_list_add(list, c);
8999 list = isl_id_list_add(list, d);
9000 list = isl_id_list_drop(list, 1, 1);
9001
9002 n = isl_id_list_n_id(list);
9003 if (n < 0)
9004 return -1;
9005 if (n != 3) {
9006 isl_id_list_free(list);
9008 "unexpected number of elements in list", return -1);
9009 }
9010
9011 id = isl_id_list_get_id(list, 0);
9012 ok = id == a;
9013 isl_id_free(id);
9014 id = isl_id_list_get_id(list, 1);
9015 ok = ok && id == c;
9016 isl_id_free(id);
9017 id = isl_id_list_get_id(list, 2);
9018 ok = ok && id == d;
9019 isl_id_free(id);
9020
9021 isl_id_list_free(list);
9022
9023 if (!ok)
9025 "unexpected elements in list", return -1);
9026
9027 return 0;
9028}
9029
9030/* Check the conversion from an isl_multi_aff to an isl_basic_set.
9031 */
9033{
9034 const char *str;
9037 isl_basic_set *bset1, *bset2;
9038
9039 str = "[N] -> { A[0, N + 1] }";
9041 bset1 = isl_basic_set_read_from_str(ctx, str);
9043 equal = isl_basic_set_is_equal(bset1, bset2);
9044 isl_basic_set_free(bset1);
9045 isl_basic_set_free(bset2);
9046 if (equal < 0)
9047 return isl_stat_error;
9048 if (!equal)
9049 isl_die(ctx, isl_error_unknown, "bad conversion",
9050 return isl_stat_error);
9051 return isl_stat_ok;
9052}
9053
9054const char *set_conversion_tests[] = {
9055 "[N] -> { [i] : N - 1 <= 2 i <= N }",
9056 "[N] -> { [i] : exists a : i = 4 a and N - 1 <= i <= N }",
9057 "[N] -> { [i,j] : exists a : i = 4 a and N - 1 <= i, 2j <= N }",
9058 "[N] -> { [[i]->[j]] : exists a : i = 4 a and N - 1 <= i, 2j <= N }",
9059 "[N] -> { [3*floor(N/2) + 5*floor(N/3)] }",
9060 "[a, b] -> { [c, d] : (4*floor((-a + c)/4) = -a + c and "
9061 "32*floor((-b + d)/32) = -b + d and 5 <= c <= 8 and "
9062 "-3 + c <= d <= 28 + c) }",
9063};
9064
9065/* Check that converting from isl_set to isl_pw_multi_aff and back
9066 * to isl_set produces the original isl_set.
9067 */
9069{
9070 int i;
9071 const char *str;
9072 isl_set *set1, *set2;
9074 int equal;
9075
9076 for (i = 0; i < ARRAY_SIZE(set_conversion_tests); ++i) {
9084
9085 if (equal < 0)
9086 return -1;
9087 if (!equal)
9088 isl_die(ctx, isl_error_unknown, "bad conversion",
9089 return -1);
9090 }
9091
9092 return 0;
9093}
9094
9095const char *conversion_tests[] = {
9096 "{ [a, b, c, d] -> s0[a, b, e, f] : "
9097 "exists (e0 = [(a - 2c)/3], e1 = [(-4 + b - 5d)/9], "
9098 "e2 = [(-d + f)/9]: 3e0 = a - 2c and 9e1 = -4 + b - 5d and "
9099 "9e2 = -d + f and f >= 0 and f <= 8 and 9e >= -5 - 2a and "
9100 "9e <= -2 - 2a) }",
9101 "{ [a, b] -> [c] : exists (e0 = floor((-a - b + c)/5): "
9102 "5e0 = -a - b + c and c >= -a and c <= 4 - a) }",
9103 "{ [a, b] -> [c] : exists d : 18 * d = -3 - a + 2c and 1 <= c <= 3 }",
9104};
9105
9106/* Check that converting from isl_map to isl_pw_multi_aff and back
9107 * to isl_map produces the original isl_map.
9108 */
9110{
9111 int i;
9112 isl_map *map1, *map2;
9114 int equal;
9115
9116 for (i = 0; i < ARRAY_SIZE(conversion_tests); ++i) {
9123
9124 if (equal < 0)
9125 return -1;
9126 if (!equal)
9127 isl_die(ctx, isl_error_unknown, "bad conversion",
9128 return -1);
9129 }
9130
9131 return 0;
9132}
9133
9134/* Descriptions of isl_pw_multi_aff objects for testing conversion
9135 * to isl_multi_pw_aff and back.
9136 */
9137const char *mpa_conversion_tests[] = {
9138 "{ [x] -> A[x] }",
9139 "{ [x] -> A[x] : x >= 0 }",
9140 "{ [x] -> A[x] : x >= 0; [x] -> A[-x] : x < 0 }",
9141 "{ [x] -> A[x, x + 1] }",
9142 "{ [x] -> A[] }",
9143 "{ [x] -> A[] : x >= 0 }",
9144};
9145
9146/* Check that conversion from isl_pw_multi_aff to isl_multi_pw_aff and
9147 * back to isl_pw_multi_aff preserves the original meaning.
9148 */
9150{
9151 int i;
9152 isl_pw_multi_aff *pma1, *pma2;
9153 isl_multi_pw_aff *mpa;
9154 int equal;
9155
9156 for (i = 0; i < ARRAY_SIZE(mpa_conversion_tests); ++i) {
9157 const char *str;
9160 pma2 = isl_pw_multi_aff_copy(pma1);
9166
9167 if (equal < 0)
9168 return -1;
9169 if (!equal)
9170 isl_die(ctx, isl_error_unknown, "bad conversion",
9171 return -1);
9172 }
9173
9174 return 0;
9175}
9176
9177/* Descriptions of union maps that should be convertible
9178 * to an isl_multi_union_pw_aff.
9179 */
9181 "{ [a, b, c, d] -> s0[a, b, e, f] : "
9182 "exists (e0 = [(a - 2c)/3], e1 = [(-4 + b - 5d)/9], "
9183 "e2 = [(-d + f)/9]: 3e0 = a - 2c and 9e1 = -4 + b - 5d and "
9184 "9e2 = -d + f and f >= 0 and f <= 8 and 9e >= -5 - 2a and "
9185 "9e <= -2 - 2a) }",
9186 "{ [a, b] -> [c] : exists (e0 = floor((-a - b + c)/5): "
9187 "5e0 = -a - b + c and c >= -a and c <= 4 - a) }",
9188 "{ [a, b] -> [c] : exists d : 18 * d = -3 - a + 2c and 1 <= c <= 3 }",
9189 "{ A[] -> B[0]; C[] -> B[1] }",
9190 "{ A[] -> B[]; C[] -> B[] }",
9191};
9192
9193/* Check that converting from isl_union_map to isl_multi_union_pw_aff and back
9194 * to isl_union_map produces the original isl_union_map.
9195 */
9197{
9198 int i;
9199 isl_union_map *umap1, *umap2;
9201 int equal;
9202
9203 for (i = 0; i < ARRAY_SIZE(umap_mupa_conversion_tests); ++i) {
9204 const char *str;
9206 umap1 = isl_union_map_read_from_str(ctx, str);
9207 umap2 = isl_union_map_copy(umap1);
9210 equal = isl_union_map_is_equal(umap1, umap2);
9211 isl_union_map_free(umap1);
9212 isl_union_map_free(umap2);
9213
9214 if (equal < 0)
9215 return -1;
9216 if (!equal)
9217 isl_die(ctx, isl_error_unknown, "bad conversion",
9218 return -1);
9219 }
9220
9221 return 0;
9222}
9223
9224static int test_conversion(isl_ctx *ctx)
9225{
9226 if (test_ma_conversion(ctx) < 0)
9227 return -1;
9228 if (test_set_conversion(ctx) < 0)
9229 return -1;
9230 if (test_map_conversion(ctx) < 0)
9231 return -1;
9232 if (test_mpa_conversion(ctx) < 0)
9233 return -1;
9234 if (test_union_map_mupa_conversion(ctx) < 0)
9235 return -1;
9236 return 0;
9237}
9238
9239/* Check that isl_basic_map_curry does not modify input.
9240 */
9241static int test_curry(isl_ctx *ctx)
9242{
9243 const char *str;
9244 isl_basic_map *bmap1, *bmap2;
9245 int equal;
9246
9247 str = "{ [A[] -> B[]] -> C[] }";
9248 bmap1 = isl_basic_map_read_from_str(ctx, str);
9250 equal = isl_basic_map_is_equal(bmap1, bmap2);
9251 isl_basic_map_free(bmap1);
9252 isl_basic_map_free(bmap2);
9253
9254 if (equal < 0)
9255 return -1;
9256 if (equal)
9258 "curried map should not be equal to original",
9259 return -1);
9260
9261 return 0;
9262}
9263
9264struct {
9265 const char *ma1;
9266 const char *ma;
9267 const char *res;
9268} pullback_tests[] = {
9269 { "{ B[i,j] -> C[i + 2j] }" , "{ A[a,b] -> B[b,a] }",
9270 "{ A[a,b] -> C[b + 2a] }" },
9271 { "{ B[i] -> C[2i] }", "{ A[a] -> B[(a)/2] }", "{ A[a] -> C[a] }" },
9272 { "{ B[i] -> C[(i)/2] }", "{ A[a] -> B[2a] }", "{ A[a] -> C[a] }" },
9273 { "{ B[i] -> C[(i)/2] }", "{ A[a] -> B[(a)/3] }",
9274 "{ A[a] -> C[(a)/6] }" },
9275 { "{ B[i] -> C[2i] }", "{ A[a] -> B[5a] }", "{ A[a] -> C[10a] }" },
9276 { "{ B[i] -> C[2i] }", "{ A[a] -> B[(a)/3] }",
9277 "{ A[a] -> C[(2a)/3] }" },
9278 { "{ B[i,j] -> C[i + j] }", "{ A[a] -> B[a,a] }", "{ A[a] -> C[2a] }"},
9279 { "{ B[a] -> C[a,a] }", "{ A[i,j] -> B[i + j] }",
9280 "{ A[i,j] -> C[i + j, i + j] }"},
9281 { "{ B[i] -> C[([i/2])] }", "{ B[5] }", "{ C[2] }" },
9282 { "[n] -> { B[i,j] -> C[([i/2]) + 2j] }",
9283 "[n] -> { B[n,[n/3]] }", "[n] -> { C[([n/2]) + 2*[n/3]] }", },
9284 { "{ [i, j] -> [floor((i)/4) + floor((2*i+j)/5)] }",
9285 "{ [i, j] -> [floor((i)/3), j] }",
9286 "{ [i, j] -> [(floor((i)/12) + floor((j + 2*floor((i)/3))/5))] }" },
9288
9289static int test_pullback(isl_ctx *ctx)
9290{
9291 int i;
9292 isl_multi_aff *ma1, *ma2;
9294 int equal;
9295
9296 for (i = 0; i < ARRAY_SIZE(pullback_tests); ++i) {
9301 equal = isl_multi_aff_plain_is_equal(ma1, ma2);
9302 isl_multi_aff_free(ma1);
9303 isl_multi_aff_free(ma2);
9304 if (equal < 0)
9305 return -1;
9306 if (!equal)
9307 isl_die(ctx, isl_error_unknown, "bad pullback",
9308 return -1);
9309 }
9310
9311 return 0;
9312}
9313
9314/* Check that negation is printed correctly and that equal expressions
9315 * are correctly identified.
9316 */
9317static int test_ast(isl_ctx *ctx)
9318{
9319 isl_ast_expr *expr, *expr1, *expr2, *expr3;
9320 char *str;
9321 int ok, equal;
9322
9323 expr1 = isl_ast_expr_from_id(isl_id_alloc(ctx, "A", NULL));
9324 expr2 = isl_ast_expr_from_id(isl_id_alloc(ctx, "B", NULL));
9325 expr = isl_ast_expr_add(expr1, expr2);
9326 expr2 = isl_ast_expr_copy(expr);
9327 expr = isl_ast_expr_neg(expr);
9328 expr2 = isl_ast_expr_neg(expr2);
9329 equal = isl_ast_expr_is_equal(expr, expr2);
9330 str = isl_ast_expr_to_C_str(expr);
9331 ok = str ? !strcmp(str, "-(A + B)") : -1;
9332 free(str);
9333 isl_ast_expr_free(expr);
9334 isl_ast_expr_free(expr2);
9335
9336 if (ok < 0 || equal < 0)
9337 return -1;
9338 if (!equal)
9340 "equal expressions not considered equal", return -1);
9341 if (!ok)
9343 "isl_ast_expr printed incorrectly", return -1);
9344
9345 expr1 = isl_ast_expr_from_id(isl_id_alloc(ctx, "A", NULL));
9346 expr2 = isl_ast_expr_from_id(isl_id_alloc(ctx, "B", NULL));
9347 expr = isl_ast_expr_add(expr1, expr2);
9348 expr3 = isl_ast_expr_from_id(isl_id_alloc(ctx, "C", NULL));
9349 expr = isl_ast_expr_sub(expr3, expr);
9350 str = isl_ast_expr_to_C_str(expr);
9351 ok = str ? !strcmp(str, "C - (A + B)") : -1;
9352 free(str);
9353 isl_ast_expr_free(expr);
9354
9355 if (ok < 0)
9356 return -1;
9357 if (!ok)
9359 "isl_ast_expr printed incorrectly", return -1);
9360
9361 return 0;
9362}
9363
9364/* Check that isl_ast_build_expr_from_set returns a valid expression
9365 * for an empty set. Note that isl_ast_build_expr_from_set getting
9366 * called on an empty set probably indicates a bug in the caller.
9367 */
9368static int test_ast_build(isl_ctx *ctx)
9369{
9370 isl_set *set;
9371 isl_ast_build *build;
9372 isl_ast_expr *expr;
9373
9376
9378 expr = isl_ast_build_expr_from_set(build, set);
9379
9380 isl_ast_expr_free(expr);
9381 isl_ast_build_free(build);
9382
9383 if (!expr)
9384 return -1;
9385
9386 return 0;
9387}
9388
9389/* Internal data structure for before_for and after_for callbacks.
9390 *
9391 * depth is the current depth
9392 * before is the number of times before_for has been called
9393 * after is the number of times after_for has been called
9394 */
9400
9401/* This function is called before each for loop in the AST generated
9402 * from test_ast_gen1.
9403 *
9404 * Increment the number of calls and the depth.
9405 * Check that the space returned by isl_ast_build_get_schedule_space
9406 * matches the target space of the schedule returned by
9407 * isl_ast_build_get_schedule.
9408 * Return an isl_id that is checked by the corresponding call
9409 * to after_for.
9410 */
9412 void *user)
9413{
9414 struct isl_test_codegen_data *data = user;
9415 isl_ctx *ctx;
9416 isl_space *space;
9418 isl_union_set *uset;
9419 isl_set *set;
9420 isl_bool empty;
9421 isl_size n;
9422 char name[] = "d0";
9423
9424 ctx = isl_ast_build_get_ctx(build);
9425
9426 if (data->before >= 3)
9428 "unexpected number of for nodes", return NULL);
9429 if (data->depth < 0 || data->depth >= 2)
9431 "unexpected depth", return NULL);
9432
9433 snprintf(name, sizeof(name), "d%d", data->depth);
9434 data->before++;
9435 data->depth++;
9436
9439 n = isl_union_set_n_set(uset);
9440 if (n != 1) {
9441 isl_union_set_free(uset);
9442 if (n < 0)
9443 return NULL;
9445 "expecting single range space", return NULL);
9446 }
9447
9448 space = isl_ast_build_get_schedule_space(build);
9449 set = isl_union_set_extract_set(uset, space);
9450 isl_union_set_free(uset);
9451 empty = isl_set_is_empty(set);
9453
9454 if (empty < 0)
9455 return NULL;
9456 if (empty)
9458 "spaces don't match", return NULL);
9459
9460 return isl_id_alloc(ctx, name, NULL);
9461}
9462
9463/* This function is called after each for loop in the AST generated
9464 * from test_ast_gen1.
9465 *
9466 * Increment the number of calls and decrement the depth.
9467 * Check that the annotation attached to the node matches
9468 * the isl_id returned by the corresponding call to before_for.
9469 */
9471 __isl_keep isl_ast_build *build, void *user)
9472{
9473 struct isl_test_codegen_data *data = user;
9474 isl_id *id;
9475 const char *name;
9476 int valid;
9477
9478 data->after++;
9479 data->depth--;
9480
9481 if (data->after > data->before)
9483 "mismatch in number of for nodes",
9484 return isl_ast_node_free(node));
9485
9486 id = isl_ast_node_get_annotation(node);
9487 if (!id)
9489 "missing annotation", return isl_ast_node_free(node));
9490
9491 name = isl_id_get_name(id);
9492 valid = name && atoi(name + 1) == data->depth;
9493 isl_id_free(id);
9494
9495 if (!valid)
9497 "wrong annotation", return isl_ast_node_free(node));
9498
9499 return node;
9500}
9501
9502/* This function is called after node in the AST generated
9503 * from test_ast_gen1.
9504 *
9505 * Increment the count in "user" if this is a for node and
9506 * return true to indicate that descendant should also be visited.
9507 */
9509{
9510 int *count = user;
9511
9513 ++*count;
9514
9515 return isl_bool_true;
9516}
9517
9518/* If "node" is a block node, then replace it by its first child.
9519 */
9521 void *user)
9522{
9523 isl_ast_node_list *children;
9524 isl_ast_node *child;
9525
9527 return node;
9528
9529 children = isl_ast_node_block_get_children(node);
9530 child = isl_ast_node_list_get_at(children, 0);
9531 isl_ast_node_list_free(children);
9532 isl_ast_node_free(node);
9533
9534 return child;
9535}
9536
9537/* Check that the before_each_for and after_each_for callbacks
9538 * are called for each for loop in the generated code,
9539 * that they are called in the right order and that the isl_id
9540 * returned from the before_each_for callback is attached to
9541 * the isl_ast_node passed to the corresponding after_each_for call.
9542 *
9543 * Additionally, check the basic functionality of
9544 * isl_ast_node_foreach_descendant_top_down by counting the number
9545 * of for loops in the resulting AST,
9546 * as well as that of isl_ast_node_map_descendant_bottom_up
9547 * by replacing the block node by its first child and
9548 * counting the number of for loops again.
9549 */
9551{
9552 int count = 0;
9553 int modified_count = 0;
9554 const char *str;
9555 isl_set *set;
9557 isl_ast_build *build;
9558 isl_ast_node *tree;
9559 struct isl_test_codegen_data data;
9560
9561 str = "[N] -> { : N >= 10 }";
9563 str = "[N] -> { A[i,j] -> S[8,i,3,j] : 0 <= i,j <= N; "
9564 "B[i,j] -> S[8,j,9,i] : 0 <= i,j <= N }";
9566
9567 data.before = 0;
9568 data.after = 0;
9569 data.depth = 0;
9572 &before_for, &data);
9574 &after_for, &data);
9576 isl_ast_build_free(build);
9577
9579 &count_for, &count) < 0)
9580 tree = isl_ast_node_free(tree);
9581
9583
9585 &modified_count) < 0)
9586 tree = isl_ast_node_free(tree);
9587
9588 if (!tree)
9589 return isl_stat_error;
9590
9591 isl_ast_node_free(tree);
9592
9593 if (data.before != 3 || data.after != 3 || count != 3)
9595 "unexpected number of for nodes",
9596 return isl_stat_error);
9597
9598 if (modified_count != 2)
9600 "unexpected number of for nodes after changes",
9601 return isl_stat_error);
9602
9603 return isl_stat_ok;
9604}
9605
9606/* Check that the AST generator handles domains that are integrally disjoint
9607 * but not rationally disjoint.
9608 */
9609static int test_ast_gen2(isl_ctx *ctx)
9610{
9611 const char *str;
9612 isl_set *set;
9615 isl_ast_build *build;
9616 isl_ast_node *tree;
9617
9618 str = "{ A[i,j] -> [i,j] : 0 <= i,j <= 1 }";
9622
9623 str = "{ [i,j] -> atomic[1] : i + j = 1; [i,j] -> unroll[1] : i = j }";
9625 build = isl_ast_build_set_options(build, options);
9627 isl_ast_build_free(build);
9628 if (!tree)
9629 return -1;
9630 isl_ast_node_free(tree);
9631
9632 return 0;
9633}
9634
9635/* Increment *user on each call.
9636 */
9638 __isl_keep isl_ast_build *build, void *user)
9639{
9640 int *n = user;
9641
9642 (*n)++;
9643
9644 return node;
9645}
9646
9647/* Test that unrolling tries to minimize the number of instances.
9648 * In particular, for the schedule given below, make sure it generates
9649 * 3 nodes (rather than 101).
9650 */
9651static int test_ast_gen3(isl_ctx *ctx)
9652{
9653 const char *str;
9654 isl_set *set;
9657 isl_ast_build *build;
9658 isl_ast_node *tree;
9659 int n_domain = 0;
9660
9661 str = "[n] -> { A[i] -> [i] : 0 <= i <= 100 and n <= i <= n + 2 }";
9664
9665 str = "{ [i] -> unroll[0] }";
9667
9669 build = isl_ast_build_set_options(build, options);
9671 &count_domains, &n_domain);
9673 isl_ast_build_free(build);
9674 if (!tree)
9675 return -1;
9676
9677 isl_ast_node_free(tree);
9678
9679 if (n_domain != 3)
9681 "unexpected number of for nodes", return -1);
9682
9683 return 0;
9684}
9685
9686/* Check that if the ast_build_exploit_nested_bounds options is set,
9687 * we do not get an outer if node in the generated AST,
9688 * while we do get such an outer if node if the options is not set.
9689 */
9690static int test_ast_gen4(isl_ctx *ctx)
9691{
9692 const char *str;
9693 isl_set *set;
9695 isl_ast_build *build;
9696 isl_ast_node *tree;
9698 int enb;
9699
9701 str = "[N,M] -> { A[i,j] -> [i,j] : 0 <= i <= N and 0 <= j <= M }";
9702
9704
9709 isl_ast_build_free(build);
9710 if (!tree)
9711 return -1;
9712
9714 isl_ast_node_free(tree);
9715
9716 if (type == isl_ast_node_if)
9718 "not expecting if node", return -1);
9719
9721
9726 isl_ast_build_free(build);
9727 if (!tree)
9728 return -1;
9729
9731 isl_ast_node_free(tree);
9732
9733 if (type != isl_ast_node_if)
9735 "expecting if node", return -1);
9736
9738
9739 return 0;
9740}
9741
9742/* This function is called for each leaf in the AST generated
9743 * from test_ast_gen5.
9744 *
9745 * We finalize the AST generation by extending the outer schedule
9746 * with a zero-dimensional schedule. If this results in any for loops,
9747 * then this means that we did not pass along enough information
9748 * about the outer schedule to the inner AST generation.
9749 */
9751 void *user)
9752{
9753 isl_union_map *schedule, *extra;
9754 isl_ast_node *tree;
9755
9761 isl_ast_build_free(build);
9762
9763 if (!tree)
9764 return NULL;
9765
9768 "code should not contain any for loop",
9769 return isl_ast_node_free(tree));
9770
9771 return tree;
9772}
9773
9774/* Check that we do not lose any information when going back and
9775 * forth between internal and external schedule.
9776 *
9777 * In particular, we create an AST where we unroll the only
9778 * non-constant dimension in the schedule. We therefore do
9779 * not expect any for loops in the AST. However, older versions
9780 * of isl would not pass along enough information about the outer
9781 * schedule when performing an inner code generation from a create_leaf
9782 * callback, resulting in the inner code generation producing a for loop.
9783 */
9784static int test_ast_gen5(isl_ctx *ctx)
9785{
9786 const char *str;
9787 isl_set *set;
9789 isl_ast_build *build;
9790 isl_ast_node *tree;
9791
9792 str = "{ A[] -> [1, 1, 2]; B[i] -> [1, i, 0] : i >= 1 and i <= 2 }";
9794
9795 str = "{ [a, b, c] -> unroll[1] : exists (e0 = [(a)/4]: "
9796 "4e0 >= -1 + a - b and 4e0 <= -2 + a + b) }";
9798
9801 build = isl_ast_build_set_options(build, options);
9802 build = isl_ast_build_set_create_leaf(build, &create_leaf, NULL);
9804 isl_ast_build_free(build);
9805 isl_ast_node_free(tree);
9806 if (!tree)
9807 return -1;
9808
9809 return 0;
9810}
9811
9812/* Check that the expression
9813 *
9814 * [n] -> { [n/2] : n <= 0 and n % 2 = 0; [0] : n > 0 }
9815 *
9816 * is not combined into
9817 *
9818 * min(n/2, 0)
9819 *
9820 * as this would result in n/2 being evaluated in parts of
9821 * the definition domain where n is not a multiple of 2.
9822 */
9823static int test_ast_expr(isl_ctx *ctx)
9824{
9825 const char *str;
9826 isl_pw_aff *pa;
9827 isl_ast_build *build;
9828 isl_ast_expr *expr;
9829 int min_max;
9830 int is_min;
9831
9834
9835 str = "[n] -> { [n/2] : n <= 0 and n % 2 = 0; [0] : n > 0 }";
9837 build = isl_ast_build_alloc(ctx);
9838 expr = isl_ast_build_expr_from_pw_aff(build, pa);
9839 is_min = isl_ast_expr_get_type(expr) == isl_ast_expr_op &&
9841 isl_ast_build_free(build);
9842 isl_ast_expr_free(expr);
9843
9845
9846 if (!expr)
9847 return -1;
9848 if (is_min)
9850 "expressions should not be combined", return -1);
9851
9852 return 0;
9853}
9854
9855static int test_ast_gen(isl_ctx *ctx)
9856{
9857 if (test_ast_gen1(ctx) < 0)
9858 return -1;
9859 if (test_ast_gen2(ctx) < 0)
9860 return -1;
9861 if (test_ast_gen3(ctx) < 0)
9862 return -1;
9863 if (test_ast_gen4(ctx) < 0)
9864 return -1;
9865 if (test_ast_gen5(ctx) < 0)
9866 return -1;
9867 if (test_ast_expr(ctx) < 0)
9868 return -1;
9869 return 0;
9870}
9871
9872/* Check if dropping output dimensions from an isl_pw_multi_aff
9873 * works properly.
9874 */
9876{
9877 const char *str;
9878 isl_pw_multi_aff *pma1, *pma2;
9879 int equal;
9880
9881 str = "{ [i,j] -> [i+j, 4i-j] }";
9883 str = "{ [i,j] -> [4i-j] }";
9885
9886 pma1 = isl_pw_multi_aff_drop_dims(pma1, isl_dim_out, 0, 1);
9887
9889
9892 if (equal < 0)
9893 return -1;
9894 if (!equal)
9896 "expressions not equal", return -1);
9897
9898 return 0;
9899}
9900
9901/* Check that we can properly parse multi piecewise affine expressions
9902 * where the piecewise affine expressions have different domains.
9903 */
9905{
9906 const char *str;
9907 isl_set *dom, *dom2;
9908 isl_multi_pw_aff *mpa1, *mpa2;
9909 isl_pw_aff *pa;
9910 int equal;
9911 int equal_domain;
9912
9913 mpa1 = isl_multi_pw_aff_read_from_str(ctx, "{ [i] -> [i] }");
9914 dom = isl_set_read_from_str(ctx, "{ [i] : i > 0 }");
9915 mpa1 = isl_multi_pw_aff_intersect_domain(mpa1, dom);
9916 mpa2 = isl_multi_pw_aff_read_from_str(ctx, "{ [i] -> [2i] }");
9917 mpa2 = isl_multi_pw_aff_flat_range_product(mpa1, mpa2);
9918 str = "{ [i] -> [(i : i > 0), 2i] }";
9920
9921 equal = isl_multi_pw_aff_plain_is_equal(mpa1, mpa2);
9922
9923 pa = isl_multi_pw_aff_get_pw_aff(mpa1, 0);
9924 dom = isl_pw_aff_domain(pa);
9925 pa = isl_multi_pw_aff_get_pw_aff(mpa1, 1);
9926 dom2 = isl_pw_aff_domain(pa);
9927 equal_domain = isl_set_is_equal(dom, dom2);
9928
9929 isl_set_free(dom);
9930 isl_set_free(dom2);
9931 isl_multi_pw_aff_free(mpa1);
9932 isl_multi_pw_aff_free(mpa2);
9933
9934 if (equal < 0)
9935 return -1;
9936 if (!equal)
9938 "expressions not equal", return -1);
9939
9940 if (equal_domain < 0)
9941 return -1;
9942 if (equal_domain)
9944 "domains unexpectedly equal", return -1);
9945
9946 return 0;
9947}
9948
9949/* Check that the dimensions in the explicit domain
9950 * of a multi piecewise affine expression are properly
9951 * taken into account.
9952 */
9954{
9955 const char *str;
9956 isl_bool involves1, involves2, involves3, equal;
9957 isl_multi_pw_aff *mpa, *mpa1, *mpa2;
9958
9959 str = "{ A[x,y] -> B[] : x >= y }";
9961 involves1 = isl_multi_pw_aff_involves_dims(mpa, isl_dim_in, 0, 2);
9962 mpa1 = isl_multi_pw_aff_copy(mpa);
9963
9964 mpa = isl_multi_pw_aff_insert_dims(mpa, isl_dim_in, 0, 1);
9965 involves2 = isl_multi_pw_aff_involves_dims(mpa, isl_dim_in, 0, 1);
9966 involves3 = isl_multi_pw_aff_involves_dims(mpa, isl_dim_in, 1, 2);
9967 str = "{ [a,x,y] -> B[] : x >= y }";
9969 equal = isl_multi_pw_aff_plain_is_equal(mpa, mpa2);
9970 isl_multi_pw_aff_free(mpa2);
9971
9972 mpa = isl_multi_pw_aff_drop_dims(mpa, isl_dim_in, 0, 1);
9973 mpa = isl_multi_pw_aff_set_tuple_name(mpa, isl_dim_in, "A");
9974 if (equal >= 0 && equal)
9975 equal = isl_multi_pw_aff_plain_is_equal(mpa, mpa1);
9976 isl_multi_pw_aff_free(mpa1);
9977 isl_multi_pw_aff_free(mpa);
9978
9979 if (involves1 < 0 || involves2 < 0 || involves3 < 0 || equal < 0)
9980 return -1;
9981 if (!equal)
9983 "incorrect result of dimension insertion/removal",
9984 return isl_stat_error);
9985 if (!involves1 || involves2 || !involves3)
9987 "incorrect characterization of involved dimensions",
9988 return isl_stat_error);
9989
9990 return 0;
9991}
9992
9993/* Check that isl_multi_union_pw_aff_multi_val_on_domain
9994 * sets the explicit domain of a zero-dimensional result,
9995 * such that it can be converted to an isl_union_map.
9996 */
9998{
9999 isl_space *space;
10000 isl_union_set *dom;
10001 isl_multi_val *mv;
10003 isl_union_map *umap;
10004
10005 dom = isl_union_set_read_from_str(ctx, "{ A[]; B[] }");
10006 space = isl_union_set_get_space(dom);
10007 mv = isl_multi_val_zero(isl_space_set_from_params(space));
10010 isl_union_map_free(umap);
10011 if (!umap)
10012 return isl_stat_error;
10013
10014 return isl_stat_ok;
10015}
10016
10017/* String descriptions of boxes that
10018 * are used for reconstructing box maps from their lower and upper bounds.
10019 */
10020static const char *multi_pw_aff_box_tests[] = {
10021 "{ A[x, y] -> [] : x + y >= 0 }",
10022 "[N] -> { A[x, y] -> [x] : x + y <= N }",
10023 "[N] -> { A[x, y] -> [x : y] : x + y <= N }",
10024};
10025
10026/* Check that map representations of boxes can be reconstructed
10027 * from their lower and upper bounds.
10028 */
10030{
10031 int i;
10032
10033 for (i = 0; i < ARRAY_SIZE(multi_pw_aff_box_tests); ++i) {
10034 const char *str;
10036 isl_map *map, *box;
10037 isl_multi_pw_aff *min, *max;
10038
10044 box = isl_map_lower_bound_multi_pw_aff(box, min);
10045 box = isl_map_upper_bound_multi_pw_aff(box, max);
10046 equal = isl_map_is_equal(map, box);
10048 isl_map_free(box);
10049 if (equal < 0)
10050 return isl_stat_error;
10051 if (!equal)
10053 "unexpected result", return isl_stat_error);
10054 }
10055
10056 return isl_stat_ok;
10057}
10058
10059/* Perform some tests on multi piecewise affine expressions.
10060 */
10062{
10063 if (test_multi_pw_aff_1(ctx) < 0)
10064 return -1;
10065 if (test_multi_pw_aff_2(ctx) < 0)
10066 return -1;
10067 if (test_multi_pw_aff_3(ctx) < 0)
10068 return -1;
10069 if (test_multi_pw_aff_box(ctx) < 0)
10070 return -1;
10071 return 0;
10072}
10073
10074/* This is a regression test for a bug where isl_basic_map_simplify
10075 * would end up in an infinite loop. In particular, we construct
10076 * an empty basic set that is not obviously empty.
10077 * isl_basic_set_is_empty marks the basic set as empty.
10078 * After projecting out i3, the variable can be dropped completely,
10079 * but isl_basic_map_simplify refrains from doing so if the basic set
10080 * is empty and would end up in an infinite loop if it didn't test
10081 * explicitly for empty basic maps in the outer loop.
10082 */
10083static int test_simplify_1(isl_ctx *ctx)
10084{
10085 const char *str;
10086 isl_basic_set *bset;
10087 int empty;
10088
10089 str = "{ [i0, i1, i2, i3] : i0 >= -2 and 6i2 <= 4 + i0 + 5i1 and "
10090 "i2 <= 22 and 75i2 <= 111 + 13i0 + 60i1 and "
10091 "25i2 >= 38 + 6i0 + 20i1 and i0 <= -1 and i2 >= 20 and "
10092 "i3 >= i2 }";
10093 bset = isl_basic_set_read_from_str(ctx, str);
10094 empty = isl_basic_set_is_empty(bset);
10095 bset = isl_basic_set_project_out(bset, isl_dim_set, 3, 1);
10096 isl_basic_set_free(bset);
10097 if (!bset)
10098 return -1;
10099 if (!empty)
10101 "basic set should be empty", return -1);
10102
10103 return 0;
10104}
10105
10106/* Check that the equality in the set description below
10107 * is simplified away.
10108 */
10109static int test_simplify_2(isl_ctx *ctx)
10110{
10111 const char *str;
10112 isl_basic_set *bset;
10114
10115 str = "{ [a] : exists e0, e1: 32e1 = 31 + 31a + 31e0 }";
10116 bset = isl_basic_set_read_from_str(ctx, str);
10118 isl_basic_set_free(bset);
10119
10120 if (universe < 0)
10121 return -1;
10122 if (!universe)
10124 "equality not simplified away", return -1);
10125 return 0;
10126}
10127
10128/* Some simplification tests.
10129 */
10130static int test_simplify(isl_ctx *ctx)
10131{
10132 if (test_simplify_1(ctx) < 0)
10133 return -1;
10134 if (test_simplify_2(ctx) < 0)
10135 return -1;
10136 return 0;
10137}
10138
10139/* This is a regression test for a bug where isl_tab_basic_map_partial_lexopt
10140 * with gbr context would fail to disable the use of the shifted tableau
10141 * when transferring equalities for the input to the context, resulting
10142 * in invalid sample values.
10143 */
10145{
10146 const char *str;
10147 isl_basic_set *bset;
10148 isl_basic_map *bmap;
10149 isl_map *map;
10150
10151 str = "{ [1, b, c, 1 - c] -> [e] : 2e <= -c and 2e >= -3 + c }";
10152 bmap = isl_basic_map_read_from_str(ctx, str);
10153 str = "{ [a, b, c, d] : c <= 1 and 2d >= 6 - 4b - c }";
10154 bset = isl_basic_set_read_from_str(ctx, str);
10155 map = isl_basic_map_partial_lexmin(bmap, bset, NULL);
10157
10158 if (!map)
10159 return -1;
10160
10161 return 0;
10162}
10163
10164/* Check that the variable compression performed on the existentially
10165 * quantified variables inside isl_basic_set_compute_divs is not confused
10166 * by the implicit equalities among the parameters.
10167 */
10169{
10170 const char *str;
10171 isl_basic_set *bset;
10172 isl_set *set;
10173
10174 str = "[a, b, c, d, e] -> { [] : exists (e0: 2d = b and a <= 124 and "
10175 "b <= 2046 and b >= 0 and b <= 60 + 64a and 2e >= b + 2c and "
10176 "2e >= b and 2e <= 1 + b and 2e <= 1 + b + 2c and "
10177 "32768e0 >= -124 + a and 2097152e0 <= 60 + 64a - b) }";
10178 bset = isl_basic_set_read_from_str(ctx, str);
10181 if (!set)
10182 return -1;
10183
10184 return 0;
10185}
10186
10187/* Check that isl_schedule_get_map is not confused by a schedule tree
10188 * with divergent filter node parameters, as can result from a call
10189 * to isl_schedule_intersect_domain.
10190 */
10192{
10193 const char *str;
10194 isl_union_set *uset;
10195 isl_schedule *sched1, *sched2;
10196 isl_union_map *umap;
10197
10198 uset = isl_union_set_read_from_str(ctx, "{ A[i] }");
10199 sched1 = isl_schedule_from_domain(uset);
10200 uset = isl_union_set_read_from_str(ctx, "{ B[] }");
10201 sched2 = isl_schedule_from_domain(uset);
10202
10203 sched1 = isl_schedule_sequence(sched1, sched2);
10204 str = "[n] -> { A[i] : 0 <= i < n; B[] }";
10205 uset = isl_union_set_read_from_str(ctx, str);
10206 sched1 = isl_schedule_intersect_domain(sched1, uset);
10207 umap = isl_schedule_get_map(sched1);
10208 isl_schedule_free(sched1);
10209 isl_union_map_free(umap);
10210 if (!umap)
10211 return -1;
10212
10213 return 0;
10214}
10215
10216/* Check that a zero-dimensional prefix schedule keeps track
10217 * of the domain and outer filters.
10218 */
10220{
10221 const char *str;
10223 isl_union_set *uset;
10224 isl_union_set_list *filters;
10226 isl_schedule_node *node;
10227
10228 str = "{ S1[i,j] : 0 <= i,j < 10; S2[i,j] : 0 <= i,j < 10 }";
10229 uset = isl_union_set_read_from_str(ctx, str);
10230 node = isl_schedule_node_from_domain(uset);
10231 node = isl_schedule_node_child(node, 0);
10232
10233 str = "{ S1[i,j] : i > j }";
10234 uset = isl_union_set_read_from_str(ctx, str);
10235 filters = isl_union_set_list_from_union_set(uset);
10236 str = "{ S1[i,j] : i <= j; S2[i,j] }";
10237 uset = isl_union_set_read_from_str(ctx, str);
10238 filters = isl_union_set_list_add(filters, uset);
10239 node = isl_schedule_node_insert_sequence(node, filters);
10240
10241 node = isl_schedule_node_grandchild(node, 0, 0);
10243 str = "([] : { S1[i,j] : i > j })";
10245 equal = isl_multi_union_pw_aff_plain_is_equal(mupa, mupa2);
10246 isl_multi_union_pw_aff_free(mupa2);
10247 isl_multi_union_pw_aff_free(mupa);
10249
10250 if (equal < 0)
10251 return -1;
10252 if (!equal)
10253 isl_die(ctx, isl_error_unknown, "unexpected prefix schedule",
10254 return -1);
10255
10256 return 0;
10257}
10258
10259/* Check that the reaching domain elements and the prefix schedule
10260 * at a leaf node are the same before and after grouping.
10261 */
10263{
10264 int equal;
10265 const char *str;
10266 isl_id *id;
10267 isl_union_set *uset;
10269 isl_union_pw_multi_aff *upma1, *upma2;
10270 isl_union_set *domain1, *domain2;
10271 isl_union_map *umap1, *umap2;
10272 isl_schedule_node *node;
10273
10274 str = "{ S1[i,j] : 0 <= i,j < 10; S2[i,j] : 0 <= i,j < 10 }";
10275 uset = isl_union_set_read_from_str(ctx, str);
10276 node = isl_schedule_node_from_domain(uset);
10277 node = isl_schedule_node_child(node, 0);
10278 str = "[{ S1[i,j] -> [i]; S2[i,j] -> [9 - i] }]";
10281 node = isl_schedule_node_child(node, 0);
10282 str = "[{ S1[i,j] -> [j]; S2[i,j] -> [j] }]";
10285 node = isl_schedule_node_child(node, 0);
10288 domain1 = isl_schedule_node_get_domain(node);
10289 id = isl_id_alloc(ctx, "group", NULL);
10290 node = isl_schedule_node_parent(node);
10291 node = isl_schedule_node_group(node, id);
10292 node = isl_schedule_node_child(node, 0);
10295 domain2 = isl_schedule_node_get_domain(node);
10297 if (equal >= 0 && equal)
10298 equal = isl_union_set_is_equal(domain1, domain2);
10299 if (equal >= 0 && equal)
10300 equal = isl_union_map_is_equal(umap1, umap2);
10301 isl_union_map_free(umap1);
10302 isl_union_map_free(umap2);
10303 isl_union_set_free(domain1);
10304 isl_union_set_free(domain2);
10308
10309 if (equal < 0)
10310 return -1;
10311 if (!equal)
10313 "expressions not equal", return -1);
10314
10315 return 0;
10316}
10317
10318/* Check that we can have nested groupings and that the union map
10319 * schedule representation is the same before and after the grouping.
10320 * Note that after the grouping, the union map representation contains
10321 * the domain constraints from the ranges of the expansion nodes,
10322 * while they are missing from the union map representation of
10323 * the tree without expansion nodes.
10324 *
10325 * Also check that the global expansion is as expected.
10326 */
10328{
10329 int equal, equal_expansion;
10330 const char *str;
10331 isl_id *id;
10332 isl_union_set *uset;
10333 isl_union_map *umap1, *umap2;
10334 isl_union_map *expansion1, *expansion2;
10335 isl_union_set_list *filters;
10338 isl_schedule_node *node;
10339
10340 str = "{ S1[i,j] : 0 <= i,j < 10; S2[i,j] : 0 <= i,j < 10; "
10341 "S3[i,j] : 0 <= i,j < 10 }";
10342 uset = isl_union_set_read_from_str(ctx, str);
10343 node = isl_schedule_node_from_domain(uset);
10344 node = isl_schedule_node_child(node, 0);
10345 str = "[{ S1[i,j] -> [i]; S2[i,j] -> [i]; S3[i,j] -> [i] }]";
10348 node = isl_schedule_node_child(node, 0);
10349 str = "{ S1[i,j] }";
10350 uset = isl_union_set_read_from_str(ctx, str);
10351 filters = isl_union_set_list_from_union_set(uset);
10352 str = "{ S2[i,j]; S3[i,j] }";
10353 uset = isl_union_set_read_from_str(ctx, str);
10354 filters = isl_union_set_list_add(filters, uset);
10355 node = isl_schedule_node_insert_sequence(node, filters);
10356 node = isl_schedule_node_grandchild(node, 1, 0);
10357 str = "{ S2[i,j] }";
10358 uset = isl_union_set_read_from_str(ctx, str);
10359 filters = isl_union_set_list_from_union_set(uset);
10360 str = "{ S3[i,j] }";
10361 uset = isl_union_set_read_from_str(ctx, str);
10362 filters = isl_union_set_list_add(filters, uset);
10363 node = isl_schedule_node_insert_sequence(node, filters);
10364
10368 umap1 = isl_union_map_intersect_domain(umap1, uset);
10370
10371 node = isl_schedule_node_grandparent(node);
10372 id = isl_id_alloc(ctx, "group1", NULL);
10373 node = isl_schedule_node_group(node, id);
10374 node = isl_schedule_node_grandchild(node, 1, 0);
10375 id = isl_id_alloc(ctx, "group2", NULL);
10376 node = isl_schedule_node_group(node, id);
10377
10381
10382 node = isl_schedule_node_root(node);
10383 node = isl_schedule_node_child(node, 0);
10384 expansion1 = isl_schedule_node_get_subtree_expansion(node);
10386
10387 str = "{ group1[i] -> S1[i,j] : 0 <= i,j < 10; "
10388 "group1[i] -> S2[i,j] : 0 <= i,j < 10; "
10389 "group1[i] -> S3[i,j] : 0 <= i,j < 10 }";
10390
10391 expansion2 = isl_union_map_read_from_str(ctx, str);
10392
10393 equal = isl_union_map_is_equal(umap1, umap2);
10394 equal_expansion = isl_union_map_is_equal(expansion1, expansion2);
10395
10396 isl_union_map_free(umap1);
10397 isl_union_map_free(umap2);
10398 isl_union_map_free(expansion1);
10399 isl_union_map_free(expansion2);
10400
10401 if (equal < 0 || equal_expansion < 0)
10402 return -1;
10403 if (!equal)
10405 "expressions not equal", return -1);
10406 if (!equal_expansion)
10408 "unexpected expansion", return -1);
10409
10410 return 0;
10411}
10412
10413/* Some tests for the isl_schedule_node_group function.
10414 */
10416{
10417 if (test_schedule_tree_group_1(ctx) < 0)
10418 return -1;
10419 if (test_schedule_tree_group_2(ctx) < 0)
10420 return -1;
10421 return 0;
10422}
10423
10424struct {
10425 const char *set;
10426 const char *dual;
10427} coef_tests[] = {
10428 { "{ rat: [i] : 0 <= i <= 10 }",
10429 "{ rat: coefficients[[cst] -> [a]] : cst >= 0 and 10a + cst >= 0 }" },
10430 { "{ rat: [i] : FALSE }",
10431 "{ rat: coefficients[[cst] -> [a]] }" },
10432 { "{ rat: [i] : }",
10433 "{ rat: coefficients[[cst] -> [0]] : cst >= 0 }" },
10434 { "{ [0:,1,2:3] }",
10435 "{ rat: coefficients[[c_cst] -> [a, b, c]] : "
10436 "a >= 0 and 2c >= -c_cst - b and 3c >= -c_cst - b }" },
10437 { "[M, N] -> { [x = (1 - N):-1, -4x:(M - 4x)] }",
10438 "{ rat: coefficients[[c_cst, c_M = 0:, c_N = 0:] -> [a, b = -c_M:]] :"
10439 "4b >= -c_N + a and 4b >= -c_cst - 2c_N + a }" },
10440 { "{ rat : [x, y] : 1 <= 2x <= 9 and 2 <= 3y <= 16 }",
10441 "{ rat: coefficients[[c_cst] -> [c_x, c_y]] : "
10442 "4c_y >= -6c_cst - 3c_x and 4c_y >= -6c_cst - 27c_x and "
10443 "32c_y >= -6c_cst - 3c_x and 32c_y >= -6c_cst - 27c_x }" },
10444 { "{ [x, y, z] : 3y <= 2x - 2 and y >= -2 + 2x and 2y >= 2 - x }",
10445 "{ rat: coefficients[[cst] -> [a, b, c]] }" },
10447
10448struct {
10449 const char *set;
10450 const char *dual;
10451} sol_tests[] = {
10452 { "{ rat: coefficients[[cst] -> [a]] : cst >= 0 and 10a + cst >= 0 }",
10453 "{ rat: [i] : 0 <= i <= 10 }" },
10454 { "{ rat: coefficients[[cst] -> [a]] : FALSE }",
10455 "{ rat: [i] }" },
10456 { "{ rat: coefficients[[cst] -> [a]] }",
10457 "{ rat: [i] : FALSE }" },
10459
10460/* Test the basic functionality of isl_basic_set_coefficients and
10461 * isl_basic_set_solutions.
10462 */
10463static int test_dual(isl_ctx *ctx)
10464{
10465 int i;
10466
10467 for (i = 0; i < ARRAY_SIZE(coef_tests); ++i) {
10468 int equal;
10469 isl_basic_set *bset1, *bset2;
10470
10473 bset1 = isl_basic_set_coefficients(bset1);
10474 equal = isl_basic_set_is_equal(bset1, bset2);
10475 isl_basic_set_free(bset1);
10476 isl_basic_set_free(bset2);
10477 if (equal < 0)
10478 return -1;
10479 if (!equal)
10481 "incorrect dual", return -1);
10482 }
10483
10484 for (i = 0; i < ARRAY_SIZE(sol_tests); ++i) {
10485 int equal;
10486 isl_basic_set *bset1, *bset2;
10487
10488 bset1 = isl_basic_set_read_from_str(ctx, sol_tests[i].set);
10490 bset1 = isl_basic_set_solutions(bset1);
10491 equal = isl_basic_set_is_equal(bset1, bset2);
10492 isl_basic_set_free(bset1);
10493 isl_basic_set_free(bset2);
10494 if (equal < 0)
10495 return -1;
10496 if (!equal)
10498 "incorrect dual", return -1);
10499 }
10500
10501 return 0;
10502}
10503
10504struct {
10507 const char *domain;
10508 const char *schedule;
10509 const char *sizes;
10510 const char *tile;
10511 const char *point;
10512} tile_tests[] = {
10513 { 0, 0, "[n] -> { S[i,j] : 0 <= i,j < n }",
10514 "[{ S[i,j] -> [i] }, { S[i,j] -> [j] }]",
10515 "{ [32,32] }",
10516 "[{ S[i,j] -> [floor(i/32)] }, { S[i,j] -> [floor(j/32)] }]",
10517 "[{ S[i,j] -> [i] }, { S[i,j] -> [j] }]",
10518 },
10519 { 1, 0, "[n] -> { S[i,j] : 0 <= i,j < n }",
10520 "[{ S[i,j] -> [i] }, { S[i,j] -> [j] }]",
10521 "{ [32,32] }",
10522 "[{ S[i,j] -> [32*floor(i/32)] }, { S[i,j] -> [32*floor(j/32)] }]",
10523 "[{ S[i,j] -> [i] }, { S[i,j] -> [j] }]",
10524 },
10525 { 0, 1, "[n] -> { S[i,j] : 0 <= i,j < n }",
10526 "[{ S[i,j] -> [i] }, { S[i,j] -> [j] }]",
10527 "{ [32,32] }",
10528 "[{ S[i,j] -> [floor(i/32)] }, { S[i,j] -> [floor(j/32)] }]",
10529 "[{ S[i,j] -> [i%32] }, { S[i,j] -> [j%32] }]",
10530 },
10531 { 1, 1, "[n] -> { S[i,j] : 0 <= i,j < n }",
10532 "[{ S[i,j] -> [i] }, { S[i,j] -> [j] }]",
10533 "{ [32,32] }",
10534 "[{ S[i,j] -> [32*floor(i/32)] }, { S[i,j] -> [32*floor(j/32)] }]",
10535 "[{ S[i,j] -> [i%32] }, { S[i,j] -> [j%32] }]",
10536 },
10538
10539/* Basic tiling tests. Create a schedule tree with a domain and a band node,
10540 * tile the band and then check if the tile and point bands have the
10541 * expected partial schedule.
10542 */
10543static int test_tile(isl_ctx *ctx)
10544{
10545 int i;
10546 int scale;
10547 int shift;
10548
10551
10552 for (i = 0; i < ARRAY_SIZE(tile_tests); ++i) {
10553 int opt;
10554 int equal;
10555 const char *str;
10558 isl_schedule_node *node;
10560
10561 opt = tile_tests[i].scale_tile;
10563 opt = tile_tests[i].shift_point;
10565
10566 str = tile_tests[i].domain;
10569 node = isl_schedule_node_child(node, 0);
10570 str = tile_tests[i].schedule;
10573 str = tile_tests[i].sizes;
10575 node = isl_schedule_node_band_tile(node, sizes);
10576
10577 str = tile_tests[i].tile;
10580 equal = isl_multi_union_pw_aff_plain_is_equal(mupa, mupa2);
10581 isl_multi_union_pw_aff_free(mupa);
10582 isl_multi_union_pw_aff_free(mupa2);
10583
10584 node = isl_schedule_node_child(node, 0);
10585
10586 str = tile_tests[i].point;
10589 if (equal >= 0 && equal)
10590 equal = isl_multi_union_pw_aff_plain_is_equal(mupa,
10591 mupa2);
10592 isl_multi_union_pw_aff_free(mupa);
10593 isl_multi_union_pw_aff_free(mupa2);
10594
10596
10597 if (equal < 0)
10598 return -1;
10599 if (!equal)
10601 "unexpected result", return -1);
10602 }
10603
10606
10607 return 0;
10608}
10609
10610/* Check that the domain hash of a space is equal to the hash
10611 * of the domain of the space, both ignoring parameters.
10612 */
10614{
10615 isl_map *map;
10616 isl_space *space;
10617 uint32_t hash1, hash2;
10618
10619 map = isl_map_read_from_str(ctx, "[n] -> { A[B[x] -> C[]] -> D[] }");
10620 space = isl_map_get_space(map);
10622 hash1 = isl_space_get_tuple_domain_hash(space);
10623 space = isl_space_domain(space);
10624 hash2 = isl_space_get_tuple_hash(space);
10625 isl_space_free(space);
10626
10627 if (!space)
10628 return -1;
10629 if (hash1 != hash2)
10631 "domain hash not equal to hash of domain", return -1);
10632
10633 return 0;
10634}
10635
10636/* Check that a universe basic set that is not obviously equal to the universe
10637 * is still recognized as being equal to the universe.
10638 */
10639static int test_universe(isl_ctx *ctx)
10640{
10641 const char *s;
10642 isl_basic_set *bset;
10643 isl_bool is_univ;
10644
10645 s = "{ [] : exists x, y : 3y <= 2x and y >= -3 + 2x and 2y >= 2 - x }";
10646 bset = isl_basic_set_read_from_str(ctx, s);
10647 is_univ = isl_basic_set_is_universe(bset);
10648 isl_basic_set_free(bset);
10649
10650 if (is_univ < 0)
10651 return -1;
10652 if (!is_univ)
10654 "not recognized as universe set", return -1);
10655
10656 return 0;
10657}
10658
10659/* Sets for which chambers are computed and checked.
10660 */
10661const char *chambers_tests[] = {
10662 "[A, B, C] -> { [x, y, z] : x >= 0 and y >= 0 and y <= A - x and "
10663 "z >= 0 and z <= C - y and z <= B - x - y }",
10664};
10665
10666/* Add the domain of "cell" to "cells".
10667 */
10669{
10670 isl_basic_set_list **cells = user;
10671 isl_basic_set *dom;
10672
10673 dom = isl_cell_get_domain(cell);
10674 isl_cell_free(cell);
10675 *cells = isl_basic_set_list_add(*cells, dom);
10676
10677 return *cells ? isl_stat_ok : isl_stat_error;
10678}
10679
10680/* Check that the elements of "list" are pairwise disjoint.
10681 */
10683{
10684 int i, j;
10685 isl_size n;
10686
10687 n = isl_basic_set_list_n_basic_set(list);
10688 if (n < 0)
10689 return isl_stat_error;
10690
10691 for (i = 0; i < n; ++i) {
10692 isl_basic_set *bset_i;
10693
10694 bset_i = isl_basic_set_list_get_basic_set(list, i);
10695 for (j = i + 1; j < n; ++j) {
10696 isl_basic_set *bset_j;
10697 isl_bool disjoint;
10698
10699 bset_j = isl_basic_set_list_get_basic_set(list, j);
10700 disjoint = isl_basic_set_is_disjoint(bset_i, bset_j);
10701 isl_basic_set_free(bset_j);
10702 if (!disjoint)
10703 isl_die(isl_basic_set_list_get_ctx(list),
10704 isl_error_unknown, "not disjoint",
10705 break);
10706 if (disjoint < 0 || !disjoint)
10707 break;
10708 }
10709 isl_basic_set_free(bset_i);
10710 if (j < n)
10711 return isl_stat_error;
10712 }
10713
10714 return isl_stat_ok;
10715}
10716
10717/* Check that the chambers computed by isl_vertices_foreach_disjoint_cell
10718 * are pairwise disjoint.
10719 */
10720static int test_chambers(isl_ctx *ctx)
10721{
10722 int i;
10723
10724 for (i = 0; i < ARRAY_SIZE(chambers_tests); ++i) {
10725 isl_basic_set *bset;
10726 isl_vertices *vertices;
10727 isl_basic_set_list *cells;
10728 isl_stat ok;
10729
10731 vertices = isl_basic_set_compute_vertices(bset);
10732 cells = isl_basic_set_list_alloc(ctx, 0);
10734 &cells) < 0)
10735 cells = isl_basic_set_list_free(cells);
10736 ok = check_pairwise_disjoint(cells);
10737 isl_basic_set_list_free(cells);
10738 isl_vertices_free(vertices);
10739 isl_basic_set_free(bset);
10740
10741 if (ok < 0)
10742 return -1;
10743 }
10744
10745 return 0;
10746}
10747
10748struct {
10749 const char *name;
10750 int (*fn)(isl_ctx *ctx);
10751} tests [] = {
10752 { "universe", &test_universe },
10753 { "domain hash", &test_domain_hash },
10754 { "dual", &test_dual },
10755 { "dependence analysis", &test_flow },
10756 { "val", &test_val },
10757 { "compute divs", &test_compute_divs },
10758 { "partial lexmin", &test_partial_lexmin },
10759 { "simplify", &test_simplify },
10760 { "curry", &test_curry },
10761 { "piecewise multi affine expressions", &test_pw_multi_aff },
10762 { "multi piecewise affine expressions", &test_multi_pw_aff },
10763 { "conversion", &test_conversion },
10764 { "list", &test_list },
10765 { "align parameters", &test_align_parameters },
10766 { "drop unused parameters", &test_drop_unused_parameters },
10767 { "pullback", &test_pullback },
10768 { "AST", &test_ast },
10769 { "AST build", &test_ast_build },
10770 { "AST generation", &test_ast_gen },
10771 { "eliminate", &test_eliminate },
10772 { "deltas_map", &test_deltas_map },
10773 { "residue class", &test_residue_class },
10774 { "div", &test_div },
10775 { "slice", &test_slice },
10776 { "sample", &test_sample },
10777 { "empty projection", &test_empty_projection },
10778 { "output", &test_output },
10779 { "vertices", &test_vertices },
10780 { "chambers", &test_chambers },
10781 { "fixed", &test_fixed },
10782 { "equal", &test_equal },
10783 { "disjoint", &test_disjoint },
10784 { "product", &test_product },
10785 { "dim_max", &test_dim_max },
10786 { "affine", &test_aff },
10787 { "injective", &test_injective },
10788 { "schedule (whole component)", &test_schedule_whole },
10789 { "schedule (incremental)", &test_schedule_incremental },
10790 { "schedule tree", &test_schedule_tree },
10791 { "schedule tree prefix", &test_schedule_tree_prefix },
10792 { "schedule tree grouping", &test_schedule_tree_group },
10793 { "tile", &test_tile },
10794 { "union map", &test_union_map },
10795 { "union_pw", &test_union_pw },
10796 { "locus", &test_locus },
10797 { "eval", &test_eval },
10798 { "parse", &test_parse },
10799 { "single-valued", &test_sv },
10800 { "recession cone", &test_recession_cone },
10801 { "affine hull", &test_affine_hull },
10802 { "simple_hull", &test_simple_hull },
10803 { "box hull", &test_box_hull },
10804 { "coalesce", &test_coalesce },
10805 { "factorize", &test_factorize },
10806 { "subset", &test_subset },
10807 { "subtract", &test_subtract },
10808 { "intersect", &test_intersect },
10809 { "lexmin", &test_lexmin },
10810 { "min", &test_min },
10811 { "set lower bounds", &test_min_mpa },
10812 { "gist", &test_gist },
10813 { "piecewise quasi-polynomials", &test_pwqp },
10814 { "lift", &test_lift },
10815 { "bind parameters", &test_bind },
10816 { "unbind parameters", &test_unbind },
10817 { "bound", &test_bound },
10818 { "get lists", &test_get_list },
10819 { "union", &test_union },
10820 { "split periods", &test_split_periods },
10821 { "lexicographic order", &test_lex },
10822 { "bijectivity", &test_bijective },
10823 { "dataflow analysis", &test_dep },
10824 { "reading", &test_read },
10825 { "bounded", &test_bounded },
10826 { "construction", &test_construction },
10827 { "dimension manipulation", &test_dim },
10828 { "map application", &test_application },
10829 { "convex hull", &test_convex_hull },
10830 { "transitive closure", &test_closure },
10831 { "isl_bool", &test_isl_bool},
10833
10834int main(int argc, char **argv)
10835{
10836 int i;
10837 struct isl_ctx *ctx;
10838 struct isl_options *options;
10839
10840 options = isl_options_new_with_defaults();
10841 assert(options);
10842 argc = isl_options_parse(options, argc, argv, ISL_ARG_ALL);
10843
10844 ctx = isl_ctx_alloc_with_options(&isl_options_args, options);
10845 for (i = 0; i < ARRAY_SIZE(tests); ++i) {
10846 printf("%s\n", tests[i].name);
10847 if (tests[i].fn(ctx) < 0)
10848 goto error;
10849 }
10850 isl_ctx_free(ctx);
10851 return 0;
10852error:
10853 isl_ctx_free(ctx);
10854 return -1;
10855}
__isl_give isl_aff * isl_aff_add_constant_si(__isl_take isl_aff *aff, int v)
Definition isl_aff.c:1099
__isl_overload __isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_preimage_domain_wrapped_domain_union_pw_multi_aff(__isl_take isl_union_pw_multi_aff *upma1, __isl_take isl_union_pw_multi_aff *upma2)
Definition isl_aff.c:8044
__isl_give isl_union_set * isl_multi_union_pw_aff_zero_union_set(__isl_take isl_multi_union_pw_aff *mupa)
Definition isl_aff.c:9085
__isl_export __isl_give isl_pw_multi_aff * isl_pw_multi_aff_bind_domain(__isl_take isl_pw_multi_aff *pma, __isl_take isl_multi_id *tuple)
__isl_give isl_set * isl_multi_aff_lex_le_set(__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2)
Definition isl_aff.c:4568
__isl_give isl_set * isl_set_from_pw_multi_aff(__isl_take isl_pw_multi_aff *pma)
__isl_null isl_aff * isl_aff_free(__isl_take isl_aff *aff)
Definition isl_aff.c:449
__isl_null isl_union_pw_multi_aff * isl_union_pw_multi_aff_free(__isl_take isl_union_pw_multi_aff *upma)
__isl_constructor __isl_give isl_pw_multi_aff * isl_pw_multi_aff_read_from_str(isl_ctx *ctx, const char *str)
__isl_export __isl_give isl_multi_pw_aff * isl_multi_pw_aff_intersect_domain(__isl_take isl_multi_pw_aff *mpa, __isl_take isl_set *domain)
__isl_export __isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_intersect_domain_wrapped_domain(__isl_take isl_union_pw_multi_aff *upma, __isl_take isl_union_set *uset)
__isl_null isl_union_pw_aff * isl_union_pw_aff_free(__isl_take isl_union_pw_aff *upa)
__isl_constructor __isl_give isl_multi_pw_aff * isl_multi_pw_aff_read_from_str(isl_ctx *ctx, const char *str)
__isl_export __isl_give isl_union_set * isl_multi_union_pw_aff_bind(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_multi_id *tuple)
__isl_overload __isl_give isl_multi_pw_aff * isl_multi_pw_aff_pullback_multi_pw_aff(__isl_take isl_multi_pw_aff *mpa1, __isl_take isl_multi_pw_aff *mpa2)
__isl_export __isl_give isl_val * isl_pw_aff_eval(__isl_take isl_pw_aff *pa, __isl_take isl_point *pnt)
__isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_intersect_range(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_set *set)
Definition isl_aff.c:9332
__isl_give isl_set * isl_set_from_pw_aff(__isl_take isl_pw_aff *pwaff)
__isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_subtract_domain(__isl_take isl_union_pw_multi_aff *upma, __isl_take isl_union_set *uset)
__isl_constructor __isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_read_from_str(isl_ctx *ctx, const char *str)
isl_bool isl_pw_multi_aff_is_equal(__isl_keep isl_pw_multi_aff *pma1, __isl_keep isl_pw_multi_aff *pma2)
Definition isl_aff.c:7241
__isl_export isl_bool isl_pw_aff_plain_is_equal(__isl_keep isl_pw_aff *pwaff1, __isl_keep isl_pw_aff *pwaff2)
__isl_overload __isl_give isl_set * isl_pw_aff_bind_id(__isl_take isl_pw_aff *pa, __isl_take isl_id *id)
Definition isl_aff.c:3106
__isl_export __isl_give isl_aff * isl_aff_unbind_params_insert_domain(__isl_take isl_aff *aff, __isl_take isl_multi_id *domain)
__isl_constructor __isl_give isl_pw_aff * isl_pw_aff_read_from_str(isl_ctx *ctx, const char *str)
__isl_export __isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_intersect_domain_wrapped_range(__isl_take isl_union_pw_multi_aff *upma, __isl_take isl_union_set *uset)
__isl_export isl_size isl_pw_multi_aff_n_piece(__isl_keep isl_pw_multi_aff *pma)
__isl_give isl_union_pw_aff * isl_multi_union_pw_aff_apply_pw_aff(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_pw_aff *pa)
Definition isl_aff.c:9635
__isl_export isl_bool isl_aff_plain_is_equal(__isl_keep isl_aff *aff1, __isl_keep isl_aff *aff2)
Definition isl_aff.c:784
isl_bool isl_aff_plain_is_zero(__isl_keep isl_aff *aff)
Definition isl_aff.c:757
__isl_export isl_bool isl_union_pw_aff_plain_is_equal(__isl_keep isl_union_pw_aff *upa1, __isl_keep isl_union_pw_aff *upa2)
__isl_constructor __isl_give isl_union_pw_aff * isl_union_pw_aff_read_from_str(isl_ctx *ctx, const char *str)
__isl_export __isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_add(__isl_take isl_union_pw_multi_aff *upma1, __isl_take isl_union_pw_multi_aff *upma2)
__isl_constructor __isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_read_from_str(isl_ctx *ctx, const char *str)
__isl_give char * isl_multi_aff_to_str(__isl_keep isl_multi_aff *ma)
__isl_overload __isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_pullback_union_pw_multi_aff(__isl_take isl_union_pw_multi_aff *upma1, __isl_take isl_union_pw_multi_aff *upma2)
Definition isl_aff.c:7934
__isl_export __isl_give isl_pw_aff * isl_pw_aff_drop_unused_params(__isl_take isl_pw_aff *pa)
isl_bool isl_union_pw_multi_aff_involves_nan(__isl_keep isl_union_pw_multi_aff *upma)
__isl_export __isl_give isl_pw_aff * isl_pw_aff_min(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3811
__isl_constructor __isl_give isl_multi_aff * isl_multi_aff_read_from_str(isl_ctx *ctx, const char *str)
__isl_give isl_union_pw_aff * isl_union_pw_aff_param_on_domain_id(__isl_take isl_union_set *domain, __isl_take isl_id *id)
Definition isl_aff.c:8293
__isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_from_union_map(__isl_take isl_union_map *umap)
Definition isl_aff.c:8905
__isl_overload __isl_give isl_multi_aff * isl_multi_aff_pullback_multi_aff(__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2)
Definition isl_aff.c:6097
__isl_export __isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_union_add(__isl_take isl_union_pw_multi_aff *upma1, __isl_take isl_union_pw_multi_aff *upma2)
__isl_overload __isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_pullback_union_pw_multi_aff(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_union_pw_multi_aff *upma)
Definition isl_aff.c:9814
__isl_null isl_pw_aff * isl_pw_aff_free(__isl_take isl_pw_aff *pwaff)
__isl_overload __isl_give isl_union_map * isl_union_map_from_multi_union_pw_aff(__isl_take isl_multi_union_pw_aff *mupa)
Definition isl_aff.c:9157
__isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_multi_val_on_domain(__isl_take isl_union_set *domain, __isl_take isl_multi_val *mv)
Definition isl_aff.c:8972
__isl_give isl_aff * isl_aff_set_tuple_id(__isl_take isl_aff *aff, enum isl_dim_type type, __isl_take isl_id *id)
Definition isl_aff.c:2231
__isl_give isl_aff * isl_aff_scale_down_ui(__isl_take isl_aff *aff, unsigned f)
Definition isl_aff.c:2171
__isl_export __isl_give isl_aff * isl_aff_div(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:3559
__isl_export __isl_give isl_aff * isl_aff_floor(__isl_take isl_aff *aff)
Definition isl_aff.c:1729
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_from_multi_pw_aff(__isl_take isl_multi_pw_aff *mpa)
Definition isl_aff.c:7021
__isl_give isl_aff * isl_aff_add_coefficient_si(__isl_take isl_aff *aff, enum isl_dim_type type, int pos, int v)
Definition isl_aff.c:1426
__isl_export __isl_give isl_pw_multi_aff * isl_pw_multi_aff_bind_domain_wrapped_domain(__isl_take isl_pw_multi_aff *pma, __isl_take isl_multi_id *tuple)
__isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_apply_pw_multi_aff(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_pw_multi_aff *pma)
Definition isl_aff.c:9715
__isl_give isl_union_pw_aff * isl_union_pw_aff_aff_on_domain(__isl_take isl_union_set *domain, __isl_take isl_aff *aff)
Definition isl_aff.c:8278
__isl_give isl_aff * isl_aff_zero_on_domain(__isl_take isl_local_space *ls)
Definition isl_aff.c:235
__isl_export __isl_give isl_pw_multi_aff * isl_pw_multi_aff_product(__isl_take isl_pw_multi_aff *pma1, __isl_take isl_pw_multi_aff *pma2)
Definition isl_aff.c:4880
isl_bool isl_pw_aff_involves_nan(__isl_keep isl_pw_aff *pa)
__isl_export __isl_give isl_aff * isl_aff_sub(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:2029
__isl_constructor __isl_give isl_multi_pw_aff * isl_multi_pw_aff_from_pw_multi_aff(__isl_take isl_pw_multi_aff *pma)
Definition isl_aff.c:7106
__isl_export isl_bool isl_pw_multi_aff_plain_is_equal(__isl_keep isl_pw_multi_aff *pma1, __isl_keep isl_pw_multi_aff *pma2)
__isl_export __isl_give isl_aff * isl_aff_gist(__isl_take isl_aff *aff, __isl_take isl_set *context)
Definition isl_aff.c:2325
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_from_map(__isl_take isl_map *map)
Definition isl_aff.c:5617
__isl_constructor __isl_give isl_aff * isl_aff_read_from_str(isl_ctx *ctx, const char *str)
__isl_export isl_bool isl_union_pw_multi_aff_involves_locals(__isl_keep isl_union_pw_multi_aff *upma)
__isl_export __isl_give isl_aff * isl_aff_add(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:1976
__isl_export isl_bool isl_union_pw_multi_aff_plain_is_equal(__isl_keep isl_union_pw_multi_aff *upma1, __isl_keep isl_union_pw_multi_aff *upma2)
__isl_null isl_pw_multi_aff * isl_pw_multi_aff_free(__isl_take isl_pw_multi_aff *pma)
__isl_give isl_set * isl_multi_aff_lex_lt_set(__isl_take isl_multi_aff *ma1, __isl_take isl_multi_aff *ma2)
Definition isl_aff.c:4577
__isl_give isl_printer * isl_printer_print_pw_aff(__isl_take isl_printer *p, __isl_keep isl_pw_aff *pwaff)
__isl_give char * isl_multi_pw_aff_to_str(__isl_keep isl_multi_pw_aff *mpa)
__isl_export __isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_intersect_params(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_set *params)
__isl_export __isl_give isl_pw_aff * isl_pw_aff_max(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2)
Definition isl_aff.c:3819
__isl_export __isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_intersect_domain(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_union_set *uset)
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_copy(__isl_keep isl_pw_multi_aff *pma)
__isl_export __isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_union_add(__isl_take isl_multi_union_pw_aff *mupa1, __isl_take isl_multi_union_pw_aff *mupa2)
isl_size isl_pw_aff_n_piece(__isl_keep isl_pw_aff *pwaff)
__isl_export __isl_give isl_set * isl_pw_aff_domain(__isl_take isl_pw_aff *pwaff)
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_drop_dims(__isl_take isl_pw_multi_aff *pma, enum isl_dim_type type, unsigned first, unsigned n)
__isl_export __isl_give isl_aff * isl_aff_mul(__isl_take isl_aff *aff1, __isl_take isl_aff *aff2)
Definition isl_aff.c:3516
__isl_give isl_map * isl_map_from_pw_multi_aff(__isl_take isl_pw_multi_aff *pma)
__isl_overload __isl_give isl_basic_set * isl_aff_bind_id(__isl_take isl_aff *aff, __isl_take isl_id *id)
Definition isl_aff.c:3068
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_from_set(__isl_take isl_set *set)
Definition isl_aff.c:5657
__isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_apply_multi_aff(__isl_take isl_multi_union_pw_aff *mupa, __isl_take isl_multi_aff *ma)
Definition isl_aff.c:9560
isl_bool isl_aff_is_nan(__isl_keep isl_aff *aff)
Definition isl_aff.c:772
__isl_give isl_pw_multi_aff * isl_pw_multi_aff_alloc(__isl_take isl_set *set, __isl_take isl_multi_aff *maff)
struct isl_union_pw_multi_aff isl_union_pw_multi_aff
Definition aff_type.h:38
struct isl_union_pw_aff isl_union_pw_aff
Definition aff_type.h:23
struct isl_multi_aff isl_multi_aff
Definition aff_type.h:29
struct isl_multi_pw_aff isl_multi_pw_aff
Definition aff_type.h:43
struct isl_multi_union_pw_aff isl_multi_union_pw_aff
Definition aff_type.h:46
#define ISL_ARG_ALL
Definition arg.h:288
__isl_export __isl_give isl_ast_node_list * isl_ast_node_block_get_children(__isl_keep isl_ast_node *node)
Definition isl_ast.c:1576
__isl_null isl_ast_expr * isl_ast_expr_free(__isl_take isl_ast_expr *expr)
Definition isl_ast.c:243
isl_stat isl_ast_node_foreach_descendant_top_down(__isl_keep isl_ast_node *node, isl_bool(*fn)(__isl_keep isl_ast_node *node, void *user), void *user)
Definition isl_ast.c:1888
enum isl_ast_expr_op_type isl_ast_expr_get_op_type(__isl_keep isl_ast_expr *expr)
Definition isl_ast.c:342
__isl_give isl_ast_expr * isl_ast_expr_neg(__isl_take isl_ast_expr *expr)
Definition isl_ast.c:642
isl_bool isl_ast_expr_is_equal(__isl_keep isl_ast_expr *expr1, __isl_keep isl_ast_expr *expr2)
Definition isl_ast.c:511
__isl_give isl_ast_expr * isl_ast_expr_add(__isl_take isl_ast_expr *expr1, __isl_take isl_ast_expr *expr2)
Definition isl_ast.c:694
__isl_give isl_ast_expr * isl_ast_expr_from_id(__isl_take isl_id *id)
Definition isl_ast.c:541
__isl_give isl_ast_expr * isl_ast_expr_sub(__isl_take isl_ast_expr *expr1, __isl_take isl_ast_expr *expr2)
Definition isl_ast.c:702
__isl_give isl_id * isl_ast_node_get_annotation(__isl_keep isl_ast_node *node)
Definition isl_ast.c:1704
__isl_null isl_ast_node * isl_ast_node_free(__isl_take isl_ast_node *node)
Definition isl_ast.c:1180
isl_ctx * isl_ast_node_get_ctx(__isl_keep isl_ast_node *node)
Definition isl_ast.c:902
__isl_export __isl_give isl_ast_node * isl_ast_node_map_descendant_bottom_up(__isl_take isl_ast_node *node, __isl_give isl_ast_node *(*fn)(__isl_take isl_ast_node *node, void *user), void *user)
Definition isl_ast.c:1944
__isl_give isl_ast_expr * isl_ast_expr_copy(__isl_keep isl_ast_expr *expr)
Definition isl_ast.c:195
__isl_export __isl_give char * isl_ast_expr_to_C_str(__isl_keep isl_ast_expr *expr)
Definition isl_ast.c:3902
isl_stat isl_options_set_ast_build_detect_min_max(isl_ctx *ctx, int val)
__isl_give isl_ast_build * isl_ast_build_set_before_each_for(__isl_take isl_ast_build *build, __isl_give isl_id *(*fn)(__isl_keep isl_ast_build *build, void *user), void *user)
__isl_export __isl_give isl_ast_build * isl_ast_build_from_context(__isl_take isl_set *set)
__isl_export __isl_give isl_ast_node * isl_ast_build_node_from_schedule_map(__isl_keep isl_ast_build *build, __isl_take isl_union_map *schedule)
__isl_overload __isl_give isl_ast_expr * isl_ast_build_expr_from_set(__isl_keep isl_ast_build *build, __isl_take isl_set *set)
__isl_give isl_ast_build * isl_ast_build_set_options(__isl_take isl_ast_build *build, __isl_take isl_union_map *options)
__isl_overload __isl_give isl_ast_expr * isl_ast_build_expr_from_pw_aff(__isl_keep isl_ast_build *build, __isl_take isl_pw_aff *pa)
__isl_null isl_ast_build * isl_ast_build_free(__isl_take isl_ast_build *build)
__isl_give isl_space * isl_ast_build_get_schedule_space(__isl_keep isl_ast_build *build)
__isl_constructor __isl_give isl_ast_build * isl_ast_build_alloc(isl_ctx *ctx)
__isl_export __isl_give isl_ast_build * isl_ast_build_set_at_each_domain(__isl_take isl_ast_build *build, __isl_give isl_ast_node *(*fn)(__isl_take isl_ast_node *node, __isl_keep isl_ast_build *build, void *user), void *user)
__isl_export __isl_give isl_union_map * isl_ast_build_get_schedule(__isl_keep isl_ast_build *build)
isl_ctx * isl_ast_build_get_ctx(__isl_keep isl_ast_build *build)
int isl_options_get_ast_build_exploit_nested_bounds(isl_ctx *ctx)
__isl_give isl_ast_build * isl_ast_build_set_after_each_for(__isl_take isl_ast_build *build, __isl_give isl_ast_node *(*fn)(__isl_take isl_ast_node *node, __isl_keep isl_ast_build *build, void *user), void *user)
__isl_give isl_ast_build * isl_ast_build_set_create_leaf(__isl_take isl_ast_build *build, __isl_give isl_ast_node *(*fn)(__isl_take isl_ast_build *build, void *user), void *user)
int isl_options_get_ast_build_detect_min_max(isl_ctx *ctx)
isl_stat isl_options_set_ast_build_exploit_nested_bounds(isl_ctx *ctx, int val)
@ isl_ast_expr_op
Definition ast_type.h:77
isl_ast_node_type
Definition ast_type.h:82
@ isl_ast_node_block
Definition ast_type.h:86
@ isl_ast_node_for
Definition ast_type.h:84
@ isl_ast_node_if
Definition ast_type.h:85
@ isl_ast_expr_op_min
Definition ast_type.h:23
__isl_give isl_constraint * isl_constraint_alloc_equality(__isl_take isl_local_space *ls)
__isl_give isl_constraint * isl_constraint_alloc_inequality(__isl_take isl_local_space *ls)
__isl_give isl_basic_set * isl_basic_set_add_constraint(__isl_take isl_basic_set *bset, __isl_take isl_constraint *constraint)
isl_size isl_basic_set_n_constraint(__isl_keep isl_basic_set *bset)
__isl_give isl_constraint * isl_constraint_set_constant_si(__isl_take isl_constraint *constraint, int v)
__isl_give isl_constraint * isl_constraint_set_coefficient_si(__isl_take isl_constraint *constraint, enum isl_dim_type type, int pos, int v)
isl_ctx * isl_ctx_alloc_with_options(struct isl_args *args, __isl_take void *opt)
isl_stat isl_stat_non_null(void *obj)
Definition isl_ctx.c:34
#define __isl_take
Definition ctx.h:22
isl_stat
Definition ctx.h:84
@ isl_stat_error
Definition ctx.h:85
@ isl_stat_ok
Definition ctx.h:86
#define __isl_give
Definition ctx.h:19
#define isl_die(ctx, errno, msg, code)
Definition ctx.h:138
isl_bool isl_bool_ok(int b)
Definition isl_ctx.c:58
@ isl_error_unknown
Definition ctx.h:78
@ isl_error_internal
Definition ctx.h:79
#define isl_alloc_array(ctx, type, n)
Definition ctx.h:132
#define __isl_keep
Definition ctx.h:25
int isl_size
Definition ctx.h:97
isl_bool isl_bool_not(isl_bool b)
Definition isl_ctx.c:44
isl_bool
Definition ctx.h:89
@ isl_bool_false
Definition ctx.h:91
@ isl_bool_true
Definition ctx.h:92
@ isl_bool_error
Definition ctx.h:90
void isl_ctx_free(isl_ctx *ctx)
Definition isl_ctx.c:300
__isl_export __isl_give isl_multi_val * isl_fixed_box_get_size(__isl_keep isl_fixed_box *box)
Definition isl_box.c:220
__isl_export __isl_give isl_multi_aff * isl_fixed_box_get_offset(__isl_keep isl_fixed_box *box)
Definition isl_box.c:210
__isl_null isl_fixed_box * isl_fixed_box_free(__isl_take isl_fixed_box *box)
Definition isl_box.c:36
__isl_export __isl_give isl_union_access_info * isl_union_access_info_set_schedule(__isl_take isl_union_access_info *access, __isl_take isl_schedule *schedule)
Definition isl_flow.c:1706
isl_stat isl_flow_foreach(__isl_keep isl_flow *deps, isl_stat(*fn)(__isl_take isl_map *dep, int must, void *dep_user, void *user), void *user)
Definition isl_flow.c:488
__isl_null isl_union_flow * isl_union_flow_free(__isl_take isl_union_flow *flow)
Definition isl_flow.c:2108
__isl_give isl_flow * isl_access_info_compute_flow(__isl_take isl_access_info *acc)
Definition isl_flow.c:1371
__isl_export __isl_give isl_union_access_info * isl_union_access_info_set_must_source(__isl_take isl_union_access_info *access, __isl_take isl_union_map *must_source)
Definition isl_flow.c:1630
__isl_constructor __isl_give isl_union_access_info * isl_union_access_info_from_sink(__isl_take isl_union_map *sink)
Definition isl_flow.c:1590
__isl_export __isl_give isl_union_flow * isl_union_access_info_compute_flow(__isl_take isl_union_access_info *access)
Definition isl_flow.c:3206
int isl_union_map_compute_flow(__isl_take isl_union_map *sink, __isl_take isl_union_map *must_source, __isl_take isl_union_map *may_source, __isl_take isl_union_map *schedule, __isl_give isl_union_map **must_dep, __isl_give isl_union_map **may_dep, __isl_give isl_union_map **must_no_source, __isl_give isl_union_map **may_no_source)
Definition isl_flow.c:3302
__isl_export __isl_give isl_union_map * isl_union_flow_get_must_dependence(__isl_keep isl_union_flow *flow)
Definition isl_flow.c:2159
__isl_give isl_access_info * isl_access_info_add_source(__isl_take isl_access_info *acc, __isl_take isl_map *source, int must, void *source_user)
Definition isl_flow.c:283
__isl_give isl_access_info * isl_access_info_alloc(__isl_take isl_map *sink, void *sink_user, isl_access_level_before fn, int max_source)
Definition isl_flow.c:214
__isl_null isl_flow * isl_flow_free(__isl_take isl_flow *deps)
Definition isl_flow.c:522
m
Definition guard1-0.c:2
__isl_export __isl_give ISL_HMAP __isl_take ISL_KEY __isl_take ISL_VAL * val
Definition hmap.h:32
isl_stat isl_stat(* fn)(__isl_take ISL_KEY *key, __isl_take ISL_VAL *val, void *user)
Definition hmap.h:37
isl_stat isl_stat void * user
Definition hmap.h:39
isl_bool isl_bool(* test)(__isl_keep ISL_KEY *key, __isl_keep ISL_VAL *val, void *user)
Definition hmap.h:41
__isl_export __isl_keep const char * isl_id_get_name(__isl_keep isl_id *id)
Definition isl_id.c:41
__isl_null isl_id * isl_id_free(__isl_take isl_id *id)
Definition isl_id.c:207
__isl_constructor __isl_give isl_multi_id * isl_multi_id_read_from_str(isl_ctx *ctx, const char *str)
__isl_give isl_id * isl_id_alloc(isl_ctx *ctx, __isl_keep const char *name, void *user)
__isl_constructor __isl_give isl_id * isl_id_read_from_str(isl_ctx *ctx, const char *str)
struct isl_multi_id isl_multi_id
Definition id_type.h:16
__isl_export __isl_give isl_val * isl_set_min_val(__isl_keep isl_set *set, __isl_keep isl_aff *obj)
Definition isl_ilp.c:600
__isl_export __isl_give isl_val * isl_set_max_val(__isl_keep isl_set *set, __isl_keep isl_aff *obj)
Definition isl_ilp.c:612
__isl_give isl_val * isl_basic_set_max_val(__isl_keep isl_basic_set *bset, __isl_keep isl_aff *obj)
Definition isl_ilp.c:562
__isl_export __isl_give isl_multi_val * isl_pw_multi_aff_max_multi_val(__isl_take isl_pw_multi_aff *pma)
int GMPQAPI cmp(mp_rat op1, mp_rat op2)
bool test_div(testspec_t *t, FILE *ofp)
Definition imdrover.c:615
__isl_give isl_multi_union_pw_aff * isl_multi_union_pw_aff_zero(__isl_take isl_space *space)
Definition isl_aff.c:8707
__isl_give isl_basic_set * isl_basic_set_recession_cone(__isl_take isl_basic_set *bset)
enum isl_ast_expr_type isl_ast_expr_get_type(__isl_keep isl_ast_expr *expr)
Definition isl_ast.c:276
enum isl_ast_node_type isl_ast_node_get_type(__isl_keep isl_ast_node *node)
Definition isl_ast.c:907
static __isl_give isl_ast_expr * scale(__isl_take isl_ast_expr *expr, __isl_take isl_val *v)
static int count(int *con, unsigned len, int status)
isl_stat isl_set_dim_residue_class(__isl_keep isl_set *set, int pos, isl_int *modulo, isl_int *residue)
__isl_give isl_factorizer * isl_basic_set_factorizer(__isl_keep isl_basic_set *bset)
__isl_null isl_factorizer * isl_factorizer_free(__isl_take isl_factorizer *f)
mpz_t isl_int
Definition isl_int_gmp.h:9
#define isl_int_init(i)
Definition isl_int_gmp.h:11
#define isl_int_clear(i)
Definition isl_int_gmp.h:12
#define isl_int_cmp_si(i, si)
Definition isl_int_gmp.h:56
#define S(TYPE, NAME)
__isl_give isl_map * isl_map_align_divs_internal(__isl_take isl_map *map)
Definition isl_map.c:10397
__isl_give isl_set * isl_set_normalize(__isl_take isl_set *set)
Definition isl_map.c:11199
static unsigned pos(__isl_keep isl_space *space, enum isl_dim_type type)
Definition isl_map.c:73
isl_bool isl_map_plain_is_fixed(__isl_keep isl_map *map, enum isl_dim_type type, unsigned pos, isl_int *val)
Definition isl_map.c:10809
#define isl_basic_set_list
__isl_give isl_map * isl_map_plain_gist_basic_map(__isl_take isl_map *map, __isl_take isl_basic_map *context)
#define isl_set
#define isl_basic_set
static struct isl_arg_choice convex[]
Definition isl_options.c:69
static struct isl_arg_choice on_error[]
Definition isl_options.c:45
static struct isl_arg_choice bound[]
Definition isl_options.c:39
#define ISL_CONVEX_HULL_FM
#define ISL_CONVEX_HULL_WRAP
enum isl_schedule_node_type isl_schedule_node_get_type(__isl_keep isl_schedule_node *node)
uint32_t isl_space_get_tuple_domain_hash(__isl_keep isl_space *space)
Definition isl_space.c:2854
uint32_t isl_space_get_tuple_hash(__isl_keep isl_space *space)
Definition isl_space.c:2821
const char * pwqp
Definition isl_test.c:3636
void test_parse_map(isl_ctx *ctx, const char *str)
Definition isl_test.c:66
static int test_union_map_mupa_conversion(isl_ctx *ctx)
Definition isl_test.c:9196
struct @016117341140033035307325017250231030001172225320 coalesce_tests[]
int sv
Definition isl_test.c:3554
static int test_min_special2(isl_ctx *ctx)
Definition isl_test.c:3093
static int test_conflicting_context_schedule(isl_ctx *ctx)
Definition isl_test.c:4867
struct @020074134063177147374305013173201056235322265307 pma_equal_tests[]
static int test_eval(isl_ctx *ctx)
Definition isl_test.c:8510
const char * minuend
Definition isl_test.c:4138
int shift_point
Definition isl_test.c:10506
static int test_closure(isl_ctx *ctx)
Definition isl_test.c:2585
const char * poly
Definition isl_test.c:3868
static int test_un_locus(isl_ctx *ctx)
Definition isl_test.c:8156
static int test_union_map(isl_ctx *ctx)
Definition isl_test.c:8041
static int test_read(isl_ctx *ctx)
Definition isl_test.c:553
static int common_space(void *first, void *second)
Definition isl_test.c:3236
static int test_ast_gen5(isl_ctx *ctx)
Definition isl_test.c:9784
const char * arg1
Definition isl_test.c:871
__isl_give isl_val *(* fn)(__isl_take isl_val *v1, __isl_take isl_val *v2)
Definition isl_test.c:858
static int test_mupa_pa(isl_ctx *ctx)
Definition isl_test.c:6482
static isl_stat uset_check_equal(__isl_keep isl_union_set *uset, const char *str)
Definition isl_test.c:3321
static int test_convex_hull(isl_ctx *ctx)
Definition isl_test.c:1728
static int test_list(isl_ctx *ctx)
Definition isl_test.c:8983
static int test_bound(isl_ctx *ctx)
Definition isl_test.c:3911
const char * tile
Definition isl_test.c:10510
static int test_bin_upma(isl_ctx *ctx)
Definition isl_test.c:5637
static int test_pwqp(struct isl_ctx *ctx)
Definition isl_test.c:3705
int test_equal(isl_ctx *ctx)
Definition isl_test.c:7733
static isl_stat check_pairwise_disjoint(__isl_keep isl_basic_set_list *list)
Definition isl_test.c:10682
static int test_val(isl_ctx *ctx)
Definition isl_test.c:988
int test_factorize(isl_ctx *ctx)
Definition isl_test.c:4251
static const char * parse_union_pw_multi_aff_fail_tests[]
Definition isl_test.c:208
enum isl_fold type
Definition isl_test.c:3867
struct @217300273003272264354301305257075337216352210333 val_bin_tests[]
static __isl_give isl_id * before_for(__isl_keep isl_ast_build *build, void *user)
Definition isl_test.c:9411
const char * pa
Definition isl_test.c:7173
static int test_deltas_map(isl_ctx *ctx)
Definition isl_test.c:8812
static int test_empty_projection(isl_ctx *ctx)
Definition isl_test.c:8713
static int test_dual(isl_ctx *ctx)
Definition isl_test.c:10463
static isl_stat test_bind_map_domain(isl_ctx *ctx)
Definition isl_test.c:6934
static int test_parse_mupa(isl_ctx *ctx)
Definition isl_test.c:313
static isl_stat test_unbind_multi_aff(isl_ctx *ctx)
Definition isl_test.c:7410
static isl_stat set_check_equal(__isl_keep isl_set *set, const char *str)
Definition isl_test.c:3289
static int test_coalescing_schedule(isl_ctx *ctx)
Definition isl_test.c:4889
struct @061124063161067110073243100231030174062076155272 mpa_bin_tests[]
static isl_stat test_aff_set_tuple_id(isl_ctx *ctx)
Definition isl_test.c:6730
struct @174057113116164366203126207022041076172367046214 mupa_uset_tests[]
static isl_stat test_bind_set(isl_ctx *ctx)
Definition isl_test.c:6879
int test_coalesce_set(isl_ctx *ctx, const char *str, int check_one)
Definition isl_test.c:1904
static int test_un_val(isl_ctx *ctx)
Definition isl_test.c:836
static int test_min_special(isl_ctx *ctx)
Definition isl_test.c:3058
struct @237150141343053203027125264373312344000200200232 unbind_set_tests[]
static isl_stat add_cell(__isl_take isl_cell *cell, void *user)
Definition isl_test.c:10668
static isl_stat val_check_equal(__isl_keep isl_val *val, const char *str)
Definition isl_test.c:753
static isl_stat test_union_pw_op(isl_ctx *ctx, const char *a, const char *b, __isl_give isl_union_pw_qpolynomial *(*fn)(__isl_take isl_union_pw_qpolynomial *upwqp1, __isl_take isl_union_pw_qpolynomial *upwqp2), const char *res)
Definition isl_test.c:8057
static isl_stat test_coalesce_special6(isl_ctx *ctx)
Definition isl_test.c:2457
static int test_application(isl_ctx *ctx)
Definition isl_test.c:1327
static int test_min(struct isl_ctx *ctx)
Definition isl_test.c:3182
static int test_ast_gen2(isl_ctx *ctx)
Definition isl_test.c:9609
static int test_lift(isl_ctx *ctx)
Definition isl_test.c:4000
int single_disjunct
Definition isl_test.c:1936
static int test_div(isl_ctx *ctx)
Definition isl_test.c:1029
static int check_single_piece(isl_ctx *ctx, __isl_take isl_pw_aff *pa)
Definition isl_test.c:7451
static isl_stat test_ast_gen1(isl_ctx *ctx)
Definition isl_test.c:9550
const char * set
Definition isl_test.c:1364
static int test_mupa_ma(isl_ctx *ctx)
Definition isl_test.c:6399
struct @216257140162010135245171323044214145146165047335 bin_locus_tests[]
static int test_split_periods(isl_ctx *ctx)
Definition isl_test.c:3794
static isl_stat test_bind_pa(isl_ctx *ctx)
Definition isl_test.c:7188
static int test_ast_gen(isl_ctx *ctx)
Definition isl_test.c:9855
const char * hull
Definition isl_test.c:1493
static isl_stat test_bound_space(isl_ctx *ctx)
Definition isl_test.c:3891
static int test_lex(struct isl_ctx *ctx)
Definition isl_test.c:2863
const char * condition
Definition isl_test.c:4698
static isl_stat test_coalesce_special8(isl_ctx *ctx)
Definition isl_test.c:2492
static int test_ast_build(isl_ctx *ctx)
Definition isl_test.c:9368
const char * umap_mupa_conversion_tests[]
Definition isl_test.c:9180
struct @105221326373240210216336053113147175001126267127 bind_pma_domain_tests[]
int test_eliminate(isl_ctx *ctx)
Definition isl_test.c:8793
const char * difference
Definition isl_test.c:4140
struct @046213276021216247135016337073226265266123046377 upma_bin_fail_tests[]
static int test_skewing_schedule(isl_ctx *ctx)
Definition isl_test.c:4922
static int test_lexmin(struct isl_ctx *ctx)
Definition isl_test.c:2932
static struct @015267075333042347372041363346316206161075303054 upma_test_tests[]
static __isl_give isl_union_map * compute_schedule(isl_ctx *ctx, const char *domain, const char *validity, const char *proximity)
Definition isl_test.c:4479
int tight
Definition isl_test.c:3866
static int test_strongly_satisfying_schedule(isl_ctx *ctx)
Definition isl_test.c:4833
static isl_stat test_upma_uset(isl_ctx *ctx)
Definition isl_test.c:5743
int test_fixed(isl_ctx *ctx)
Definition isl_test.c:7790
struct @343352217161364004312145033045065131243340231327 mupa_ma_tests[]
static int test_disjoint(isl_ctx *ctx)
Definition isl_test.c:7694
static isl_stat test_upma_test(isl_ctx *ctx)
Definition isl_test.c:5565
static const char * reparse_pw_multi_aff_tests[]
Definition isl_test.c:163
static isl_stat check_injective(__isl_take isl_map *map, void *user)
Definition isl_test.c:4293
static int test_eval_2(isl_ctx *ctx)
Definition isl_test.c:8400
static int test_bin_upma_fail(isl_ctx *ctx)
Definition isl_test.c:5678
static int test_special_conditional_schedule_constraints_2(isl_ctx *ctx)
Definition isl_test.c:4643
static int test_locus(isl_ctx *ctx)
Definition isl_test.c:8358
static isl_stat test_subset_duplicate_integer_divisions(isl_ctx *ctx)
Definition isl_test.c:4023
struct @277255054242064365360344327310257371007324027162 aff_bin_tests[]
static int test_recession_cone(struct isl_ctx *ctx)
Definition isl_test.c:1375
static int test_product_pma(isl_ctx *ctx)
Definition isl_test.c:7634
static isl_stat test_unbind_set(isl_ctx *ctx)
Definition isl_test.c:7309
static int test_plain_fixed(isl_ctx *ctx, __isl_take isl_map *map, enum isl_dim_type type, unsigned pos, int fixed)
Definition isl_test.c:7771
const char * ma
Definition isl_test.c:7387
int test_product(isl_ctx *ctx)
Definition isl_test.c:7655
static int test_isl_bool(isl_ctx *ctx)
Definition isl_test.c:2841
struct @263260042340030002023204212344055054207256061003 lexmin_tests[]
static struct @312242276265273206050076024022221044217204247150 bind_pa_tests[]
struct @032326224263051015242172034057017051301131332221 upma_uset_tests[]
static const char * reparse_multi_union_pw_aff_tests[]
Definition isl_test.c:284
static isl_stat test_pwqp_max(isl_ctx *ctx)
Definition isl_test.c:3683
static int test_eval_1(isl_ctx *ctx)
Definition isl_test.c:8372
const char * output_tests[]
Definition isl_test.c:8525
static int test_coalesce_special3(isl_ctx *ctx)
Definition isl_test.c:2366
static int test_gist(struct isl_ctx *ctx)
Definition isl_test.c:1839
const char * map
Definition isl_test.c:1791
struct @275270173251312013201020346130124230036336200035 bind_umap_range_tests[]
static void test_parse_pwaff(isl_ctx *ctx, const char *str)
Definition isl_test.c:104
struct @336041326377237040302274063337145151235045104073 aff_eval_tests[]
static int test_construction_2(isl_ctx *ctx)
Definition isl_test.c:657
int test_one_schedule(isl_ctx *ctx, const char *d, const char *w, const char *r, const char *s, int tilable, int parallel)
Definition isl_test.c:4306
int test_slice(isl_ctx *ctx)
Definition isl_test.c:8736
struct @346121156341046050001065107224026155011163173256 opt_tests[]
static int test_min_mpa(isl_ctx *ctx)
Definition isl_test.c:3150
static int test_universe(isl_ctx *ctx)
Definition isl_test.c:10639
static int test_conditional_schedule_constraints(isl_ctx *ctx)
Definition isl_test.c:4775
static isl_stat test_gist_empty(isl_ctx *ctx)
Definition isl_test.c:1772
int test_parse_map_equal(isl_ctx *ctx, const char *str, const char *str2)
Definition isl_test.c:75
const char * arg2
Definition isl_test.c:873
struct @073317244344013303260303174253310074300236206353 mupa_un_tests[]
static int test_tile(isl_ctx *ctx)
Definition isl_test.c:10543
static isl_stat test_ma_conversion(isl_ctx *ctx)
Definition isl_test.c:9032
int test_vertices(isl_ctx *ctx)
Definition isl_test.c:7882
static int test_ast_expr(isl_ctx *ctx)
Definition isl_test.c:9823
struct @027213002172344323165175365021062236374012126065 live_range_tests[]
int equal
Definition isl_test.c:7720
static int test_ast(isl_ctx *ctx)
Definition isl_test.c:9317
int test_union_pw(isl_ctx *ctx)
Definition isl_test.c:8075
static isl_stat test_bind_aff(isl_ctx *ctx)
Definition isl_test.c:7144
static int test_un_mpa(isl_ctx *ctx)
Definition isl_test.c:5821
static isl_stat test_parse_upma(isl_ctx *ctx)
Definition isl_test.c:222
static int test_subtract(isl_ctx *ctx)
Definition isl_test.c:4147
static isl_stat test_bind_mupa(isl_ctx *ctx)
Definition isl_test.c:7234
const char * pma
Definition isl_test.c:3019
static struct @032104377171373353064050046203260213352306036137 umap_bin_tests[]
static int test_mupa_set(isl_ctx *ctx)
Definition isl_test.c:6251
static isl_stat test_coalesce_union(isl_ctx *ctx, const char *str1, const char *str2)
Definition isl_test.c:2310
static int test_ast_gen3(isl_ctx *ctx)
Definition isl_test.c:9651
const char * conditional_validity
Definition isl_test.c:4699
struct @123161370147266307110215130177302342032352135375 coalesce_unbounded_tests[]
const char * p
Definition isl_test.c:8454
struct @306152342120224230045201022302340006115324040221 mpa_un_tests[]
int test_output(isl_ctx *ctx)
Definition isl_test.c:8623
static int test_bin_aff(isl_ctx *ctx)
Definition isl_test.c:5437
int scale_tile
Definition isl_test.c:10505
static int test_multi_pw_aff(isl_ctx *ctx)
Definition isl_test.c:10061
static int test_bind(isl_ctx *ctx)
Definition isl_test.c:7261
struct @136277052127235302001362335036236067334354155255 coef_tests[]
static int test_simplify_1(isl_ctx *ctx)
Definition isl_test.c:10083
const char * schedule
Definition isl_test.c:10508
#define ARRAY_SIZE(array)
Definition isl_test.c:47
static int test_get_list(isl_ctx *ctx)
Definition isl_test.c:3982
const char * offset
Definition isl_test.c:1577
static struct @016015352272170164072066104344001241103075150127 bind_aff_tests[]
static struct @246277342025272067075065104332037275214221302171 opt_pw_tests[]
static int test_schedule_tree_group(isl_ctx *ctx)
Definition isl_test.c:10415
static int test_map_conversion(isl_ctx *ctx)
Definition isl_test.c:9109
static isl_stat test_bind_pma_domain(isl_ctx *ctx)
Definition isl_test.c:7041
static int test_domain_hash(isl_ctx *ctx)
Definition isl_test.c:10613
static int test_schedule_incremental(isl_ctx *ctx)
Definition isl_test.c:5264
struct @234372225360351010125242076055167203305366236111 mupa_set_tests[]
struct @212251224320377234215223061215057205173040036122 sol_tests[]
static int test_bijective(struct isl_ctx *ctx)
Definition isl_test.c:3609
const char * flow
Definition isl_test.c:4697
static int test_parse_multi(isl_ctx *ctx)
Definition isl_test.c:351
static int test_simple_hull(struct isl_ctx *ctx)
Definition isl_test.c:1541
static int test_mpa_conversion(isl_ctx *ctx)
Definition isl_test.c:9149
static int test_bin_pw_aff(isl_ctx *ctx)
Definition isl_test.c:5501
static int test_dim_max_2(isl_ctx *ctx)
Definition isl_test.c:7495
const char * f2
Definition isl_test.c:7722
const char * set_conversion_tests[]
Definition isl_test.c:9054
static isl_stat test_intersect_2(isl_ctx *ctx)
Definition isl_test.c:4225
struct @112052067337023134134123200132300000022321127266 tile_tests[]
static int test_plain_gist(isl_ctx *ctx)
Definition isl_test.c:1809
int test_drop_unused_parameters(isl_ctx *ctx)
Definition isl_test.c:8930
static isl_stat test_subtract_empty(isl_ctx *ctx)
Definition isl_test.c:4120
static isl_stat test_union_set_contains(isl_ctx *ctx)
Definition isl_test.c:8013
static isl_stat test_multi_pw_aff_box(isl_ctx *ctx)
Definition isl_test.c:10029
static int test_schedule_whole(isl_ctx *ctx)
Definition isl_test.c:5249
static int test_construction(isl_ctx *ctx)
Definition isl_test.c:687
struct @277045303356023321271362066163360052210373341215 recession_cone_tests[]
static isl_bool uset_is_equal(__isl_keep isl_union_set *uset, const char *str)
Definition isl_test.c:3304
int test_sv(isl_ctx *ctx)
Definition isl_test.c:3567
static isl_stat check_bool(isl_ctx *ctx, isl_bool actual, isl_bool expected)
Definition isl_test.c:2826
static isl_stat test_plain_unshifted_simple_hull_special(isl_ctx *ctx)
Definition isl_test.c:1464
static int test_coalesce_special(struct isl_ctx *ctx)
Definition isl_test.c:2267
static int test_subset(isl_ctx *ctx)
Definition isl_test.c:4092
struct @365347224236156042276345137037354162060170254355 aff_bin_op[]
const char * name
Definition isl_test.c:10749
const char * point
Definition isl_test.c:10511
static isl_stat test_gist_empty_pair(isl_ctx *ctx, const char *map, const char *context)
Definition isl_test.c:1741
static int test_box_hull(struct isl_ctx *ctx)
Definition isl_test.c:1595
static int test_compute_divs(isl_ctx *ctx)
Definition isl_test.c:10168
static isl_stat test_eval_3(isl_ctx *ctx)
Definition isl_test.c:8429
void test_affine_hull_case(struct isl_ctx *ctx, const char *name)
Definition isl_test.c:1335
static int test_construction_1(isl_ctx *ctx)
Definition isl_test.c:626
static isl_stat test_coalesce_special5(isl_ctx *ctx)
Definition isl_test.c:2443
const char * context
Definition isl_test.c:1792
static isl_stat collect_must_may(__isl_take isl_map *dep, int must, void *dep_user, void *user)
Definition isl_test.c:3223
static int test_unbind(isl_ctx *ctx)
Definition isl_test.c:7437
static int test_mupa_pma(isl_ctx *ctx)
Definition isl_test.c:6602
int test_special_schedule(isl_ctx *ctx, const char *domain, const char *validity, const char *proximity, const char *expected_sched)
Definition isl_test.c:4502
struct @073223071055162131251174000110304051102024241067 pw_aff_bin_op[]
static __isl_give isl_map * cocoa_fig_1_right_tc(isl_ctx *ctx)
Definition isl_test.c:2580
static int test_output_set(isl_ctx *ctx)
Definition isl_test.c:8542
const char * subtrahend
Definition isl_test.c:4139
static __isl_give isl_ast_node * select_first(__isl_take isl_ast_node *node, void *user)
Definition isl_test.c:9520
struct @225231020345174122145152306206242040116330170152 subtract_domain_tests[]
int test_affine_hull(struct isl_ctx *ctx)
Definition isl_test.c:1403
static int test_intersect_1(isl_ctx *ctx)
Definition isl_test.c:4201
static isl_stat test_coalesce_intersection(isl_ctx *ctx, const char *s1, const char *s2)
Definition isl_test.c:2406
int test_plain_injective(isl_ctx *ctx, const char *str, int injective)
Definition isl_test.c:5277
static int test_chambers(isl_ctx *ctx)
Definition isl_test.c:10720
const char * map1
Definition isl_test.c:365
__isl_give isl_val *(* op)(__isl_take isl_val *v)
Definition isl_test.c:781
static const char * elimination_tests[]
Definition isl_test.c:1000
struct @153221355010016326374145353067372356257264351356 mupa_pma_tests[]
const char * aff
Definition isl_test.c:7130
static isl_bool count_for(__isl_keep isl_ast_node *node, void *user)
Definition isl_test.c:9508
struct @326352374276177063217211122037271225223365343330 mupa_bin_tests[]
int test_dim_max(isl_ctx *ctx)
Definition isl_test.c:7508
const char * obj
Definition isl_test.c:3166
static int test_bounded(isl_ctx *ctx)
Definition isl_test.c:586
const char * lexmin
Definition isl_test.c:2888
static char * get_filename(isl_ctx *ctx, const char *name, const char *suffix)
Definition isl_test.c:49
const char * map2
Definition isl_test.c:366
struct @175201007007107104020277010220303030346261040141 pw_aff_bin_tests[]
const char * set1
Definition isl_test.c:4055
static __isl_give isl_map * cocoa_fig_1_right_power(isl_ctx *ctx)
Definition isl_test.c:2568
int outer_band_n
Definition isl_test.c:4700
static struct @110236216215267062025113222262143012150125310315 bind_set_tests[]
static int test_union(isl_ctx *ctx)
Definition isl_test.c:3814
struct @230361366346155317003354075102156334256111143174 parse_map_equal_tests[]
static isl_stat test_aff_normalize(isl_ctx *ctx)
Definition isl_test.c:6752
static int map_check_equal(__isl_keep isl_map *map, const char *str)
Definition isl_test.c:3257
struct @121334201376000072241342302345242002002112124351 bind_pma_domain_wrapped_tests[]
struct @034023122066004347332201145302160211004356015173 mupa_upma_tests[]
int test_injective(isl_ctx *ctx)
Definition isl_test.c:5297
struct @166252077064030177264324146316062043227161027001 mupa_pa_tests[]
static int test_bin_locus(isl_ctx *ctx)
Definition isl_test.c:8263
static int test_ast_gen4(isl_ctx *ctx)
Definition isl_test.c:9690
static isl_stat test_pw_max(struct isl_ctx *ctx)
Definition isl_test.c:3032
static int test_curry(isl_ctx *ctx)
Definition isl_test.c:9241
static int test_partial_lexmin(isl_ctx *ctx)
Definition isl_test.c:10144
static int test_bin_val(isl_ctx *ctx)
Definition isl_test.c:956
static int test_special_conditional_schedule_constraints(isl_ctx *ctx)
Definition isl_test.c:4565
const char * tuple
Definition isl_test.c:6860
static struct @227153107326043146302145062112014100102317066121 box_hull_tests[]
void test_convex_hull_case(struct isl_ctx *ctx, const char *name)
Definition isl_test.c:1627
static int test_padded_schedule(isl_ctx *ctx)
Definition isl_test.c:4527
int test_parse(struct isl_ctx *ctx)
Definition isl_test.c:485
struct @225310166120276347227137376175363010237007305060 upma_bin_tests[]
const char * sizes
Definition isl_test.c:10509
struct @135300012331366305032307165220313216350342356305 subset_tests[]
static int test_mupa_uset(isl_ctx *ctx)
Definition isl_test.c:6312
static isl_stat test_unbind_aff(isl_ctx *ctx)
Definition isl_test.c:7358
static int test_dep(struct isl_ctx *ctx)
Definition isl_test.c:3335
static struct @125356034062032156215334117027034307076106117034 unbind_multi_aff_tests[]
void test_application_case(struct isl_ctx *ctx, const char *name)
Definition isl_test.c:1299
const char * res
Definition isl_test.c:783
static isl_stat test_bind_umap_range(isl_ctx *ctx)
Definition isl_test.c:6983
struct @221223354274216223320306321046225142311132162156 tests[]
static int test_mupa_upma(isl_ctx *ctx)
Definition isl_test.c:6700
struct @306255212222345361073270334305355037300163072106 sv_tests[]
struct @307311126023073361146236001125175247211007332263 val_bin_op[]
static int test_bin_mpa(isl_ctx *ctx)
Definition isl_test.c:5951
struct @174057011213107332265220210271111213013313024017 bind_map_domain_tests[]
const char * set2
Definition isl_test.c:4056
struct @250133302144052016047034213024303200342344001123 unbind_aff_tests[]
int subset
Definition isl_test.c:4057
static isl_stat test_output_mpa(isl_ctx *ctx)
Definition isl_test.c:8597
static int test_simplify_2(isl_ctx *ctx)
Definition isl_test.c:10109
static isl_stat test_pwqp_gist(isl_ctx *ctx)
Definition isl_test.c:3651
static int test_flow(isl_ctx *ctx)
Definition isl_test.c:3529
static isl_stat test_coalesce_special4(isl_ctx *ctx)
Definition isl_test.c:2429
static int test_conversion(isl_ctx *ctx)
Definition isl_test.c:9224
static isl_stat check_single_expr_min(isl_ctx *ctx, const char *s1, const char *s2)
Definition isl_test.c:3121
const char * arg
Definition isl_test.c:782
static isl_bool set_is_equal(__isl_keep isl_set *set, const char *str)
Definition isl_test.c:3272
const char * gist
Definition isl_test.c:1793
const char * ma1
Definition isl_test.c:9265
static isl_stat test_bind_pma_domain_wrapped(isl_ctx *ctx)
Definition isl_test.c:7098
static struct @050155310362100077075031154044213015144052006053 bin_locus_ma_tests[]
static int test_schedule_tree(isl_ctx *ctx)
Definition isl_test.c:10191
const char * dual
Definition isl_test.c:10426
static int test_schedule_tree_group_2(isl_ctx *ctx)
Definition isl_test.c:10327
static int test_convex_hull_algo(isl_ctx *ctx, int convex)
Definition isl_test.c:1682
const char * cone
Definition isl_test.c:1365
static struct @320003045101313370267023112313076000262133016064 bind_mupa_tests[]
static int test_parse_multi_val(isl_ctx *ctx, const char *str)
Definition isl_test.c:115
static int test_un_mupa(isl_ctx *ctx)
Definition isl_test.c:6016
int test_schedule(isl_ctx *ctx)
Definition isl_test.c:4936
static int test_bin_mupa(isl_ctx *ctx)
Definition isl_test.c:6146
const char * size
Definition isl_test.c:1578
static int test_various_simple_hull(isl_ctx *ctx)
Definition isl_test.c:1514
static int test_eval_aff(isl_ctx *ctx)
Definition isl_test.c:8485
static int test_multi_pw_aff_1(isl_ctx *ctx)
Definition isl_test.c:9904
struct @345352160040353307102050305160332264207213132026 pwqp_gist_tests[]
static isl_stat find_vertex(__isl_take isl_vertex *vertex, void *user)
Definition isl_test.c:7847
int test_aff(isl_ctx *ctx)
Definition isl_test.c:6766
static int test_dim_max_1(isl_ctx *ctx)
Definition isl_test.c:7473
static int test_multi_pw_aff_2(isl_ctx *ctx)
Definition isl_test.c:9953
const char * mupa
Definition isl_test.c:7217
struct @217276206324134050271014074335325122205326340376 convex_hull_tests[]
static int test_coalesce(struct isl_ctx *ctx)
Definition isl_test.c:2508
static int test_align_parameters(isl_ctx *ctx)
Definition isl_test.c:8915
static int test_simplify(isl_ctx *ctx)
Definition isl_test.c:10130
const char * f
Definition isl_test.c:8453
static __isl_give isl_ast_node * after_for(__isl_take isl_ast_node *node, __isl_keep isl_ast_build *build, void *user)
Definition isl_test.c:9470
int bijective
Definition isl_test.c:3592
static isl_stat test_coalesce_special7(isl_ctx *ctx)
Definition isl_test.c:2473
void test_parse_pwqp(isl_ctx *ctx, const char *str)
Definition isl_test.c:95
struct @243145263041116036205134344043334252153027152135 simple_hull_tests[]
static int test_schedule_tree_group_1(isl_ctx *ctx)
Definition isl_test.c:10262
struct @031064245322346342056014251357027126016366134020 bijective_tests[]
const char * chambers_tests[]
Definition isl_test.c:10661
struct @033013227044342070133067222073072061020241124316 plain_gist_tests[]
static int test_has_schedule(isl_ctx *ctx, const char *domain, const char *validity, const char *proximity)
Definition isl_test.c:4489
static __isl_give isl_map * cocoa_fig_1_right_graph(isl_ctx *ctx)
Definition isl_test.c:2545
struct isl_vertices_test_data vertices_tests[]
int test_sample(isl_ctx *ctx)
Definition isl_test.c:8660
static isl_stat test_bin_locus_ma(isl_ctx *ctx)
Definition isl_test.c:8327
const char * mpa_conversion_tests[]
Definition isl_test.c:9137
static int test_set_conversion(isl_ctx *ctx)
Definition isl_test.c:9068
static int test_upa(isl_ctx *ctx)
Definition isl_test.c:5347
const char * id
Definition isl_test.c:7131
static isl_stat test_output_ma(isl_ctx *ctx)
Definition isl_test.c:8569
static isl_stat test_parse_pma(isl_ctx *ctx)
Definition isl_test.c:189
static const char * parse_multi_pw_aff_fail_tests[]
Definition isl_test.c:153
static struct @234152315152023263103113146365272230152161306351 bound_tests[]
static __isl_give isl_ast_node * count_domains(__isl_take isl_ast_node *node, __isl_keep isl_ast_build *build, void *user)
Definition isl_test.c:9637
static const char * reparse_multi_pw_aff_tests[]
Definition isl_test.c:128
int test_coalesce_unbounded_wrapping(isl_ctx *ctx)
Definition isl_test.c:1962
const char * str
Definition isl_test.c:1937
static const char * multi_pw_aff_box_tests[]
Definition isl_test.c:10020
struct @341133352173154043211061172152136021073007253337 pullback_tests[]
static int test_residue_class(isl_ctx *ctx)
Definition isl_test.c:8833
struct @340232322145356212010141242212302323170034116022 val_un_tests[]
static __isl_give isl_union_map * compute_schedule_with_context(isl_ctx *ctx, const char *domain, const char *validity, const char *proximity, const char *context)
Definition isl_test.c:4449
struct @377335042054304314277065373361216112115061122073 un_locus_tests[]
static int test_parse_mpa(isl_ctx *ctx)
Definition isl_test.c:240
const char * conversion_tests[]
Definition isl_test.c:9095
static int test_intersect(isl_ctx *ctx)
Definition isl_test.c:4241
static isl_stat test_coalesce_special2(struct isl_ctx *ctx)
Definition isl_test.c:2347
const char * f1
Definition isl_test.c:7721
static int map_is_equal(__isl_keep isl_map *map, const char *str)
Definition isl_test.c:3242
static int test_schedule_tree_prefix(isl_ctx *ctx)
Definition isl_test.c:10219
static __isl_give isl_ast_node * create_leaf(__isl_take isl_ast_build *build, void *user)
Definition isl_test.c:9750
static isl_stat test_bin_union_map(isl_ctx *ctx)
Definition isl_test.c:7981
static int test_dim(isl_ctx *ctx)
Definition isl_test.c:696
static isl_stat test_multi_pw_aff_3(isl_ctx *ctx)
Definition isl_test.c:9997
static int test_pullback(isl_ctx *ctx)
Definition isl_test.c:9289
static int test_pw_multi_aff(isl_ctx *ctx)
Definition isl_test.c:9875
static int test_align_parameters_1(isl_ctx *ctx)
Definition isl_test.c:8857
static isl_stat test_align_parameters_2(isl_ctx *ctx)
Definition isl_test.c:8893
static int test_elimination(isl_ctx *ctx)
Definition isl_test.c:1009
#define assert(exp)
char * expected
static __isl_give isl_map * universe(__isl_take isl_map *map)
#define isl_union_set_list
#define isl_union_set
isl_stat isl_vertices_foreach_disjoint_cell(__isl_keep isl_vertices *vertices, isl_stat(*fn)(__isl_take isl_cell *cell, void *user), void *user)
__isl_give isl_local_space * isl_local_space_from_space(__isl_take isl_space *space)
__isl_null isl_local_space * isl_local_space_free(__isl_take isl_local_space *ls)
__isl_give isl_local_space * isl_local_space_copy(__isl_keep isl_local_space *ls)
__isl_give isl_basic_set * isl_basic_map_domain(__isl_take isl_basic_map *bmap)
Definition isl_map.c:6602
__isl_export __isl_give isl_map * isl_map_intersect_range(__isl_take isl_map *map, __isl_take isl_set *set)
Definition isl_map.c:8973
__isl_export __isl_give isl_map * isl_map_union(__isl_take isl_map *map1, __isl_take isl_map *map2)
Definition isl_map.c:8894
__isl_export __isl_give isl_multi_pw_aff * isl_map_max_multi_pw_aff(__isl_take isl_map *map)
Definition isl_aff.c:6845
__isl_give isl_pw_multi_aff * isl_basic_map_lexmin_pw_multi_aff(__isl_take isl_basic_map *bmap)
__isl_give isl_map * isl_map_eliminate(__isl_take isl_map *map, enum isl_dim_type type, unsigned first, unsigned n)
Definition isl_map.c:2717
__isl_give isl_map * isl_map_power(__isl_take isl_map *map, isl_bool *exact)
__isl_export __isl_give isl_map * isl_map_intersect(__isl_take isl_map *map1, __isl_take isl_map *map2)
Definition isl_map.c:4514
__isl_export isl_bool isl_map_is_empty(__isl_keep isl_map *map)
Definition isl_map.c:9801
__isl_export __isl_give isl_map * isl_map_universe(__isl_take isl_space *space)
Definition isl_map.c:6967
__isl_export __isl_give isl_map * isl_map_gist(__isl_take isl_map *map, __isl_take isl_map *context)
__isl_give isl_map * isl_basic_map_partial_lexmin(__isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom, __isl_give isl_set **empty)
__isl_export isl_bool isl_basic_map_is_equal(__isl_keep isl_basic_map *bmap1, __isl_keep isl_basic_map *bmap2)
Definition isl_map.c:9780
__isl_give isl_basic_map * isl_basic_map_from_range(__isl_take isl_basic_set *bset)
Definition isl_map.c:6809
__isl_export __isl_give isl_set * isl_map_bind_domain(__isl_take isl_map *map, __isl_take isl_multi_id *tuple)
Definition isl_map.c:13398
__isl_give isl_map * isl_map_copy(__isl_keep isl_map *map)
Definition isl_map.c:1494
__isl_give isl_map * isl_map_move_dims(__isl_take isl_map *map, enum isl_dim_type dst_type, unsigned dst_pos, enum isl_dim_type src_type, unsigned src_pos, unsigned n)
Definition isl_map.c:4937
__isl_null isl_basic_map * isl_basic_map_free(__isl_take isl_basic_map *bmap)
Definition isl_map.c:1503
__isl_constructor __isl_give isl_basic_map * isl_basic_map_read_from_str(isl_ctx *ctx, const char *str)
__isl_export __isl_give isl_space * isl_map_get_space(__isl_keep isl_map *map)
Definition isl_map.c:599
__isl_give isl_map * isl_map_order_gt(__isl_take isl_map *map, enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2)
Definition isl_map.c:14132
isl_size isl_basic_map_dim(__isl_keep isl_basic_map *bmap, enum isl_dim_type type)
Definition isl_map.c:83
isl_ctx * isl_map_get_ctx(__isl_keep isl_map *map)
Definition isl_map.c:392
__isl_export __isl_give isl_map * isl_map_intersect_domain(__isl_take isl_map *map, __isl_take isl_set *set)
Definition isl_map.c:9001
__isl_give isl_map * isl_map_oppose(__isl_take isl_map *map, enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2)
Definition isl_map.c:13971
__isl_overload __isl_give isl_map * isl_map_lower_bound_multi_pw_aff(__isl_take isl_map *map, __isl_take isl_multi_pw_aff *lower)
Definition isl_map.c:7735
__isl_export isl_bool isl_set_is_wrapping(__isl_keep isl_set *set)
Definition isl_map.c:12804
__isl_give isl_map * isl_map_transitive_closure(__isl_take isl_map *map, isl_bool *exact)
__isl_export __isl_give isl_map * isl_map_lexmin(__isl_take isl_map *map)
__isl_export isl_bool isl_map_is_equal(__isl_keep isl_map *map1, __isl_keep isl_map *map2)
Definition isl_map.c:9902
__isl_give isl_basic_map * isl_basic_map_read_from_file(isl_ctx *ctx, FILE *input)
Definition isl_input.c:3288
__isl_export __isl_give isl_map * isl_map_empty(__isl_take isl_space *space)
Definition isl_map.c:6957
__isl_export __isl_give isl_map * isl_set_unwrap(__isl_take isl_set *set)
Definition isl_map.c:12909
__isl_constructor __isl_give isl_map * isl_map_read_from_str(isl_ctx *ctx, const char *str)
__isl_export isl_bool isl_map_is_injective(__isl_keep isl_map *map)
Definition isl_map.c:12657
__isl_give isl_map * isl_map_lex_le(__isl_take isl_space *set_space)
Definition isl_map.c:5964
__isl_give isl_map * isl_map_deltas_map(__isl_take isl_map *map)
Definition isl_map.c:9517
__isl_overload __isl_give isl_map * isl_map_upper_bound_multi_pw_aff(__isl_take isl_map *map, __isl_take isl_multi_pw_aff *upper)
Definition isl_map.c:7745
__isl_give isl_basic_map * isl_basic_map_curry(__isl_take isl_basic_map *bmap)
Definition isl_map.c:13792
__isl_give isl_map * isl_map_equate(__isl_take isl_map *map, enum isl_dim_type type1, int pos1, enum isl_dim_type type2, int pos2)
Definition isl_map.c:13957
__isl_give isl_map * isl_map_lex_ge(__isl_take isl_space *set_space)
Definition isl_map.c:6020
__isl_export __isl_give isl_map * isl_map_coalesce(__isl_take isl_map *map)
__isl_give isl_map * isl_map_add_dims(__isl_take isl_map *map, enum isl_dim_type type, unsigned n)
Definition isl_map.c:4795
__isl_null isl_map * isl_map_free(__isl_take isl_map *map)
Definition isl_map.c:7040
__isl_give isl_map * isl_map_neg(__isl_take isl_map *map)
Definition isl_map.c:5577
__isl_constructor __isl_give isl_map * isl_map_from_basic_map(__isl_take isl_basic_map *bmap)
Definition isl_map.c:4037
__isl_give isl_map * isl_map_project_out(__isl_take isl_map *map, enum isl_dim_type type, unsigned first, unsigned n)
Definition isl_map.c:5181
__isl_give isl_basic_map * isl_basic_map_copy(__isl_keep isl_basic_map *bmap)
Definition isl_map.c:1479
__isl_export isl_bool isl_map_is_bijective(__isl_keep isl_map *map)
Definition isl_map.c:12683
__isl_export __isl_give isl_multi_pw_aff * isl_map_min_multi_pw_aff(__isl_take isl_map *map)
Definition isl_aff.c:6836
__isl_export __isl_give isl_set * isl_map_range(__isl_take isl_map *map)
Definition isl_map.c:6728
#define ISL_SCHEDULE_ALGORITHM_ISL
Definition options.h:38
#define ISL_SCHEDULE_ALGORITHM_FEAUTRIER
Definition options.h:39
int isl_options_get_coalesce_bounded_wrapping(isl_ctx *ctx)
isl_stat isl_options_set_coalesce_bounded_wrapping(isl_ctx *ctx, int val)
isl_stat isl_options_set_on_error(isl_ctx *ctx, int val)
int isl_options_get_on_error(isl_ctx *ctx)
#define ISL_ON_ERROR_CONTINUE
Definition options.h:30
__isl_give isl_point * isl_point_zero(__isl_take isl_space *space)
Definition isl_point.c:98
__isl_give isl_point * isl_point_set_coordinate_val(__isl_take isl_point *pnt, enum isl_dim_type type, int pos, __isl_take isl_val *v)
Definition isl_point.c:452
__isl_give isl_union_pw_qpolynomial * isl_union_pw_qpolynomial_copy(__isl_keep isl_union_pw_qpolynomial *upwqp)
__isl_give isl_pw_qpolynomial * isl_pw_qpolynomial_split_periods(__isl_take isl_pw_qpolynomial *pwqp, int max_periods)
__isl_give isl_pw_qpolynomial_fold * isl_pw_qpolynomial_fold_read_from_str(isl_ctx *ctx, const char *str)
__isl_give isl_val * isl_pw_qpolynomial_max(__isl_take isl_pw_qpolynomial *pwqp)
__isl_give isl_space * isl_pw_qpolynomial_get_domain_space(__isl_keep isl_pw_qpolynomial *pwqp)
__isl_give isl_pw_qpolynomial * isl_pw_qpolynomial_intersect_domain(__isl_take isl_pw_qpolynomial *pwpq, __isl_take isl_set *set)
__isl_give isl_pw_qpolynomial * isl_pw_qpolynomial_gist(__isl_take isl_pw_qpolynomial *pwqp, __isl_take isl_set *context)
isl_bool isl_pw_qpolynomial_is_zero(__isl_keep isl_pw_qpolynomial *pwqp)
__isl_give isl_pw_qpolynomial * isl_pw_qpolynomial_coalesce(__isl_take isl_pw_qpolynomial *pwqp)
__isl_constructor __isl_give isl_pw_qpolynomial * isl_pw_qpolynomial_read_from_str(isl_ctx *ctx, const char *str)
__isl_null isl_pw_qpolynomial * isl_pw_qpolynomial_free(__isl_take isl_pw_qpolynomial *pwqp)
__isl_give isl_qpolynomial * isl_qpolynomial_from_aff(__isl_take isl_aff *aff)
__isl_give isl_union_pw_qpolynomial * isl_union_pw_qpolynomial_domain_reverse(__isl_take isl_union_pw_qpolynomial *upwqp)
__isl_give isl_pw_qpolynomial * isl_pw_qpolynomial_move_dims(__isl_take isl_pw_qpolynomial *pwqp, enum isl_dim_type dst_type, unsigned dst_pos, enum isl_dim_type src_type, unsigned src_pos, unsigned n)
__isl_constructor __isl_give isl_union_pw_qpolynomial * isl_union_pw_qpolynomial_read_from_str(isl_ctx *ctx, const char *str)
__isl_give isl_pw_qpolynomial * isl_pw_qpolynomial_sub(__isl_take isl_pw_qpolynomial *pwqp1, __isl_take isl_pw_qpolynomial *pwqp2)
__isl_give isl_union_pw_qpolynomial * isl_union_pw_qpolynomial_intersect_domain(__isl_take isl_union_pw_qpolynomial *upwpq, __isl_take isl_union_set *uset)
__isl_export __isl_give isl_val * isl_pw_qpolynomial_eval(__isl_take isl_pw_qpolynomial *pwqp, __isl_take isl_point *pnt)
__isl_give isl_union_pw_qpolynomial * isl_union_pw_qpolynomial_add(__isl_take isl_union_pw_qpolynomial *upwqp1, __isl_take isl_union_pw_qpolynomial *upwqp2)
__isl_give isl_pw_qpolynomial * isl_pw_qpolynomial_fix_val(__isl_take isl_pw_qpolynomial *pwqp, enum isl_dim_type type, unsigned n, __isl_take isl_val *v)
__isl_give isl_union_pw_qpolynomial * isl_union_pw_qpolynomial_sub(__isl_take isl_union_pw_qpolynomial *upwqp1, __isl_take isl_union_pw_qpolynomial *upwqp2)
isl_bool isl_pw_qpolynomial_fold_plain_is_equal(__isl_keep isl_pw_qpolynomial_fold *pwf1, __isl_keep isl_pw_qpolynomial_fold *pwf2)
__isl_export __isl_give isl_val * isl_union_pw_qpolynomial_eval(__isl_take isl_union_pw_qpolynomial *upwqp, __isl_take isl_point *pnt)
__isl_null isl_union_pw_qpolynomial * isl_union_pw_qpolynomial_free(__isl_take isl_union_pw_qpolynomial *upwqp)
__isl_null isl_pw_qpolynomial_fold * isl_pw_qpolynomial_fold_free(__isl_take isl_pw_qpolynomial_fold *pwf)
isl_bool isl_union_pw_qpolynomial_plain_is_equal(__isl_keep isl_union_pw_qpolynomial *upwqp1, __isl_keep isl_union_pw_qpolynomial *upwqp2)
__isl_give isl_pw_qpolynomial_fold * isl_pw_qpolynomial_bound(__isl_take isl_pw_qpolynomial *pwqp, enum isl_fold type, isl_bool *tight)
Definition isl_bound.c:486
__isl_export __isl_give isl_union_set * isl_union_pw_qpolynomial_domain(__isl_take isl_union_pw_qpolynomial *upwqp)
isl_bool isl_pw_qpolynomial_plain_is_equal(__isl_keep isl_pw_qpolynomial *pwqp1, __isl_keep isl_pw_qpolynomial *pwqp2)
__isl_give isl_val * isl_qpolynomial_eval(__isl_take isl_qpolynomial *qp, __isl_take isl_point *pnt)
struct isl_union_pw_qpolynomial isl_union_pw_qpolynomial
isl_fold
@ isl_fold_min
@ isl_fold_max
__isl_null isl_printer * isl_printer_free(__isl_take isl_printer *printer)
#define ISL_FORMAT_C
Definition printer.h:31
__isl_give char * isl_printer_get_str(__isl_keep isl_printer *printer)
__isl_give isl_printer * isl_printer_to_str(isl_ctx *ctx)
__isl_give isl_printer * isl_printer_set_output_format(__isl_take isl_printer *p, int output_format)
__isl_export __isl_give isl_schedule_node * isl_schedule_get_root(__isl_keep isl_schedule *schedule)
__isl_export __isl_give isl_schedule_constraints * isl_schedule_constraints_set_proximity(__isl_take isl_schedule_constraints *sc, __isl_take isl_union_map *proximity)
isl_stat isl_options_set_schedule_whole_component(isl_ctx *ctx, int val)
__isl_null isl_schedule * isl_schedule_free(__isl_take isl_schedule *sched)
__isl_export __isl_give isl_schedule_constraints * isl_schedule_constraints_set_conditional_validity(__isl_take isl_schedule_constraints *sc, __isl_take isl_union_map *condition, __isl_take isl_union_map *validity)
__isl_export __isl_give isl_union_map * isl_schedule_get_map(__isl_keep isl_schedule *sched)
isl_stat isl_options_set_schedule_maximize_coincidence(isl_ctx *ctx, int val)
__isl_export __isl_give isl_schedule * isl_schedule_from_domain(__isl_take isl_union_set *domain)
isl_stat isl_options_set_schedule_treat_coalescing(isl_ctx *ctx, int val)
__isl_export __isl_give isl_schedule_constraints * isl_schedule_constraints_set_context(__isl_take isl_schedule_constraints *sc, __isl_take isl_set *context)
__isl_give isl_schedule * isl_schedule_intersect_domain(__isl_take isl_schedule *schedule, __isl_take isl_union_set *domain)
int isl_options_get_schedule_treat_coalescing(isl_ctx *ctx)
__isl_give isl_schedule * isl_schedule_sequence(__isl_take isl_schedule *schedule1, __isl_take isl_schedule *schedule2)
int isl_options_get_schedule_maximize_coincidence(isl_ctx *ctx)
int isl_options_get_schedule_whole_component(isl_ctx *ctx)
__isl_export __isl_give isl_union_set * isl_schedule_get_domain(__isl_keep isl_schedule *schedule)
__isl_export __isl_give isl_schedule_constraints * isl_schedule_constraints_on_domain(__isl_take isl_union_set *domain)
__isl_export __isl_give isl_schedule_constraints * isl_schedule_constraints_set_coincidence(__isl_take isl_schedule_constraints *sc, __isl_take isl_union_map *coincidence)
__isl_export __isl_give isl_schedule_constraints * isl_schedule_constraints_set_validity(__isl_take isl_schedule_constraints *sc, __isl_take isl_union_map *validity)
__isl_export __isl_give isl_schedule * isl_schedule_constraints_compute_schedule(__isl_take isl_schedule_constraints *sc)
__isl_export isl_size isl_schedule_node_band_n_member(__isl_keep isl_schedule_node *node)
__isl_export __isl_give isl_multi_union_pw_aff * isl_schedule_node_band_get_partial_schedule(__isl_keep isl_schedule_node *node)
__isl_give isl_schedule_node * isl_schedule_node_group(__isl_take isl_schedule_node *node, __isl_take isl_id *group_id)
__isl_export __isl_give isl_schedule_node * isl_schedule_node_first_child(__isl_take isl_schedule_node *node)
__isl_export __isl_give isl_multi_union_pw_aff * isl_schedule_node_get_prefix_schedule_multi_union_pw_aff(__isl_keep isl_schedule_node *node)
__isl_give isl_union_map * isl_schedule_node_get_subtree_expansion(__isl_keep isl_schedule_node *node)
int isl_options_get_tile_scale_tile_loops(isl_ctx *ctx)
__isl_give isl_schedule_node * isl_schedule_node_grandchild(__isl_take isl_schedule_node *node, int pos1, int pos2)
__isl_export __isl_give isl_schedule * isl_schedule_node_get_schedule(__isl_keep isl_schedule_node *node)
__isl_export __isl_give isl_schedule_node * isl_schedule_node_band_tile(__isl_take isl_schedule_node *node, __isl_take isl_multi_val *sizes)
__isl_export __isl_give isl_union_pw_multi_aff * isl_schedule_node_get_prefix_schedule_union_pw_multi_aff(__isl_keep isl_schedule_node *node)
__isl_export __isl_give isl_schedule_node * isl_schedule_node_insert_partial_schedule(__isl_take isl_schedule_node *node, __isl_take isl_multi_union_pw_aff *schedule)
__isl_export __isl_give isl_schedule_node * isl_schedule_node_root(__isl_take isl_schedule_node *node)
int isl_options_get_tile_shift_point_loops(isl_ctx *ctx)
isl_stat isl_options_set_tile_scale_tile_loops(isl_ctx *ctx, int val)
__isl_give isl_union_set * isl_schedule_node_get_domain(__isl_keep isl_schedule_node *node)
__isl_export __isl_give isl_schedule_node * isl_schedule_node_from_domain(__isl_take isl_union_set *domain)
__isl_export __isl_give isl_schedule_node * isl_schedule_node_parent(__isl_take isl_schedule_node *node)
__isl_give isl_schedule_node * isl_schedule_node_grandparent(__isl_take isl_schedule_node *node)
__isl_export __isl_give isl_union_map * isl_schedule_node_get_prefix_schedule_union_map(__isl_keep isl_schedule_node *node)
__isl_null isl_schedule_node * isl_schedule_node_free(__isl_take isl_schedule_node *node)
__isl_export __isl_give isl_schedule_node * isl_schedule_node_insert_sequence(__isl_take isl_schedule_node *node, __isl_take isl_union_set_list *filters)
__isl_export __isl_give isl_schedule_node * isl_schedule_node_child(__isl_take isl_schedule_node *node, int pos)
isl_stat isl_options_set_tile_shift_point_loops(isl_ctx *ctx, int val)
@ isl_schedule_node_band
a(0)
b(9)
__isl_export __isl_give isl_set * isl_set_universe(__isl_take isl_space *space)
Definition isl_map.c:6985
__isl_constructor __isl_give isl_basic_set * isl_basic_set_read_from_str(isl_ctx *ctx, const char *str)
__isl_export __isl_give isl_point * isl_set_sample_point(__isl_take isl_set *set)
__isl_give isl_basic_set * isl_basic_set_solutions(__isl_take isl_basic_set *bset)
Definition isl_farkas.c:866
__isl_export __isl_give isl_basic_set * isl_set_unshifted_simple_hull(__isl_take isl_set *set)
__isl_export __isl_give isl_set * isl_set_coalesce(__isl_take isl_set *set)
isl_size isl_basic_set_dim(__isl_keep isl_basic_set *bset, enum isl_dim_type type)
Definition isl_map.c:202
__isl_give isl_basic_set * isl_basic_set_read_from_file(isl_ctx *ctx, FILE *input)
Definition isl_input.c:3300
isl_bool isl_basic_set_plain_is_universe(__isl_keep isl_basic_set *bset)
Definition isl_map.c:9959
__isl_give isl_basic_set * isl_set_convex_hull(__isl_take isl_set *set)
__isl_export __isl_give isl_set * isl_set_product(__isl_take isl_set *set1, __isl_take isl_set *set2)
Definition isl_map.c:11635
__isl_export __isl_give isl_set * isl_basic_set_union(__isl_take isl_basic_set *bset1, __isl_take isl_basic_set *bset2)
Definition isl_map.c:10148
__isl_export __isl_give isl_set * isl_set_subtract(__isl_take isl_set *set1, __isl_take isl_set *set2)
isl_ctx * isl_set_get_ctx(__isl_keep isl_set *set)
Definition isl_map.c:397
__isl_export __isl_give isl_space * isl_set_get_space(__isl_keep isl_set *set)
Definition isl_map.c:604
__isl_give isl_set * isl_set_lower_bound_si(__isl_take isl_set *set, enum isl_dim_type type, unsigned pos, int value)
Definition isl_map.c:7422
__isl_give isl_set * isl_basic_set_compute_divs(__isl_take isl_basic_set *bset)
Definition isl_map.c:8767
__isl_export isl_bool isl_set_is_equal(__isl_keep isl_set *set1, __isl_keep isl_set *set2)
Definition isl_map.c:9748
__isl_export __isl_give isl_set * isl_set_union(__isl_take isl_set *set1, __isl_take isl_set *set2)
Definition isl_map.c:8929
__isl_give isl_basic_set * isl_basic_set_project_out(__isl_take isl_basic_set *bset, enum isl_dim_type type, unsigned first, unsigned n)
Definition isl_map.c:5170
__isl_give isl_basic_set * isl_basic_set_fix_si(__isl_take isl_basic_set *bset, enum isl_dim_type type, unsigned pos, int value)
Definition isl_map.c:7160
__isl_export __isl_give isl_basic_set * isl_basic_set_params(__isl_take isl_basic_set *bset)
Definition isl_map.c:6531
__isl_export isl_bool isl_set_is_disjoint(__isl_keep isl_set *set1, __isl_keep isl_set *set2)
__isl_null isl_basic_set * isl_basic_set_free(__isl_take isl_basic_set *bset)
Definition isl_map.c:1523
__isl_give isl_basic_set * isl_set_simple_hull(__isl_take isl_set *set)
isl_bool isl_basic_set_is_disjoint(__isl_keep isl_basic_set *bset1, __isl_keep isl_basic_set *bset2)
__isl_give isl_pw_aff * isl_set_dim_min(__isl_take isl_set *set, int pos)
Definition isl_map.c:8157
__isl_null isl_set * isl_set_free(__isl_take isl_set *set)
Definition isl_map.c:4055
__isl_export isl_bool isl_set_is_subset(__isl_keep isl_set *set1, __isl_keep isl_set *set2)
__isl_give isl_set * isl_set_remove_divs_involving_dims(__isl_take isl_set *set, enum isl_dim_type type, unsigned first, unsigned n)
Definition isl_map.c:3466
__isl_give isl_set * isl_set_copy(__isl_keep isl_set *set)
Definition isl_map.c:1470
__isl_give isl_printer * isl_printer_print_set(__isl_take isl_printer *printer, __isl_keep isl_set *map)
__isl_export __isl_give isl_set * isl_set_bind(__isl_take isl_set *set, __isl_take isl_multi_id *tuple)
Definition isl_map.c:13339
__isl_give isl_set * isl_set_compute_divs(__isl_take isl_set *set)
Definition isl_map.c:8772
isl_bool isl_set_plain_is_equal(__isl_keep isl_set *set1, __isl_keep isl_set *set2)
Definition isl_map.c:11240
__isl_export isl_bool isl_basic_set_is_subset(__isl_keep isl_basic_set *bset1, __isl_keep isl_basic_set *bset2)
Definition isl_map.c:9774
__isl_give isl_basic_set * isl_basic_set_lower_bound_val(__isl_take isl_basic_set *bset, enum isl_dim_type type, unsigned pos, __isl_take isl_val *value)
Definition isl_map.c:7785
__isl_constructor __isl_give isl_set * isl_set_read_from_str(isl_ctx *ctx, const char *str)
__isl_give isl_basic_set * isl_basic_set_upper_bound_val(__isl_take isl_basic_set *bset, enum isl_dim_type type, unsigned pos, __isl_take isl_val *value)
Definition isl_map.c:7794
__isl_export __isl_give isl_basic_set * isl_basic_set_sample(__isl_take isl_basic_set *bset)
__isl_export __isl_give isl_basic_set * isl_basic_set_apply(__isl_take isl_basic_set *bset, __isl_take isl_basic_map *bmap)
Definition isl_map.c:5407
isl_bool isl_basic_set_plain_is_equal(__isl_keep isl_basic_set *bset1, __isl_keep isl_basic_set *bset2)
Definition isl_map.c:11094
__isl_give isl_basic_set * isl_set_plain_unshifted_simple_hull(__isl_take isl_set *set)
isl_size isl_set_dim(__isl_keep isl_set *set, enum isl_dim_type type)
Definition isl_map.c:132
__isl_give char * isl_set_to_str(__isl_keep isl_set *set)
__isl_export __isl_give isl_basic_set * isl_basic_set_gist(__isl_take isl_basic_set *bset, __isl_take isl_basic_set *context)
__isl_give isl_basic_set * isl_basic_set_from_multi_aff(__isl_take isl_multi_aff *ma)
isl_bool isl_basic_set_is_universe(__isl_keep isl_basic_set *bset)
Definition isl_map.c:10018
__isl_export __isl_give isl_multi_pw_aff * isl_set_min_multi_pw_aff(__isl_take isl_set *set)
Definition isl_aff.c:6814
__isl_export __isl_give isl_set * isl_set_lexmin(__isl_take isl_set *set)
__isl_export __isl_give isl_set * isl_set_lexmax(__isl_take isl_set *set)
isl_bool isl_set_is_bounded(__isl_keep isl_set *set)
__isl_give isl_basic_set * isl_basic_set_coefficients(__isl_take isl_basic_set *bset)
Definition isl_farkas.c:839
__isl_export isl_bool isl_basic_set_is_empty(__isl_keep isl_basic_set *bset)
Definition isl_map.c:10123
__isl_export __isl_give isl_basic_set * isl_basic_set_affine_hull(__isl_take isl_basic_set *bset)
__isl_export __isl_give isl_fixed_box * isl_set_get_simple_fixed_box_hull(__isl_keep isl_set *set)
Definition isl_box.c:440
__isl_export __isl_give isl_pw_multi_aff * isl_set_lexmin_pw_multi_aff(__isl_take isl_set *set)
__isl_export __isl_give isl_set * isl_set_intersect(__isl_take isl_set *set1, __isl_take isl_set *set2)
Definition isl_map.c:4521
__isl_export isl_bool isl_basic_set_is_equal(__isl_keep isl_basic_set *bset1, __isl_keep isl_basic_set *bset2)
Definition isl_map.c:9794
__isl_export __isl_give isl_set * isl_set_empty(__isl_take isl_space *space)
Definition isl_map.c:6962
__isl_constructor __isl_give isl_set * isl_set_from_basic_set(__isl_take isl_basic_set *bset)
Definition isl_map.c:4024
__isl_give isl_basic_set * isl_basic_set_copy(__isl_keep isl_basic_set *bset)
Definition isl_map.c:1465
__isl_export __isl_give isl_basic_set * isl_basic_set_intersect(__isl_take isl_basic_set *bset1, __isl_take isl_basic_set *bset2)
Definition isl_map.c:4312
__isl_give isl_basic_set * isl_basic_set_universe(__isl_take isl_space *space)
Definition isl_map.c:6910
__isl_export __isl_give isl_set * isl_set_drop_unused_params(__isl_take isl_set *set)
Definition isl_map.c:13274
__isl_export __isl_give isl_basic_set * isl_set_affine_hull(__isl_take isl_set *set)
__isl_give isl_set * isl_set_fix_si(__isl_take isl_set *set, enum isl_dim_type type, unsigned pos, int value)
Definition isl_map.c:7253
__isl_give isl_basic_set * isl_basic_set_lift(__isl_take isl_basic_set *bset)
Definition isl_map.c:12007
__isl_give isl_basic_set * isl_basic_set_drop_unused_params(__isl_take isl_basic_set *bset)
Definition isl_map.c:13287
__isl_export isl_bool isl_set_is_empty(__isl_keep isl_set *set)
Definition isl_map.c:9828
__isl_export __isl_give isl_set * isl_set_unbind_params(__isl_take isl_set *set, __isl_take isl_multi_id *tuple)
Definition isl_map.c:13449
__isl_give isl_pw_aff * isl_set_dim_max(__isl_take isl_set *set, int pos)
Definition isl_map.c:8149
__isl_null isl_space * isl_space_free(__isl_take isl_space *space)
Definition isl_space.c:478
__isl_export __isl_give isl_space * isl_space_params(__isl_take isl_space *space)
Definition isl_space.c:2305
__isl_give isl_space * isl_space_set_from_params(__isl_take isl_space *space)
Definition isl_space.c:2321
__isl_give isl_space * isl_space_copy(__isl_keep isl_space *space)
Definition isl_space.c:469
__isl_export __isl_give isl_space * isl_space_unit(isl_ctx *ctx)
Definition isl_space.c:237
__isl_give isl_space * isl_space_set_tuple_name(__isl_take isl_space *space, enum isl_dim_type type, const char *s)
Definition isl_space.c:818
__isl_overload __isl_give isl_space * isl_space_add_named_tuple_id_ui(__isl_take isl_space *space, __isl_take isl_id *tuple_id, unsigned dim)
Definition isl_space.c:2367
__isl_give isl_space * isl_space_set_alloc(isl_ctx *ctx, unsigned nparam, unsigned dim)
Definition isl_space.c:188
__isl_give isl_space * isl_space_set_dim_name(__isl_take isl_space *space, enum isl_dim_type type, unsigned pos, __isl_keep const char *name)
__isl_give isl_space * isl_space_alloc(isl_ctx *ctx, unsigned nparam, unsigned n_in, unsigned n_out)
Definition isl_space.c:28
__isl_give isl_space * isl_space_params_alloc(isl_ctx *ctx, unsigned nparam)
Definition isl_space.c:227
__isl_export __isl_give isl_space * isl_space_domain(__isl_take isl_space *space)
Definition isl_space.c:2232
isl_dim_type
Definition space_type.h:13
@ isl_dim_param
Definition space_type.h:15
@ isl_dim_in
Definition space_type.h:16
@ isl_dim_set
Definition space_type.h:18
@ isl_dim_div
Definition space_type.h:19
@ isl_dim_out
Definition space_type.h:17
struct isl_ctx * ctx
isl_local_space * ls
struct isl_options * opt
unsigned schedule_algorithm
const char * vertex[6]
Definition isl_test.c:7818
isl_map * must
Definition isl_test.c:3219
isl_map * may
Definition isl_test.c:3220
static std::vector< Signature > min_max
static Signature range
static Signature domain
__isl_null isl_union_map * isl_union_map_free(__isl_take isl_union_map *umap)
__isl_export __isl_give isl_space * isl_union_map_get_space(__isl_keep isl_union_map *umap)
__isl_give isl_union_map * isl_union_map_lex_ge_at_multi_union_pw_aff(__isl_take isl_union_map *umap, __isl_take isl_multi_union_pw_aff *mupa)
__isl_export __isl_give isl_union_map * isl_union_map_reverse(__isl_take isl_union_map *umap)
__isl_give isl_map * isl_map_from_union_map(__isl_take isl_union_map *umap)
__isl_export __isl_give isl_union_set * isl_union_map_deltas(__isl_take isl_union_map *umap)
__isl_export isl_bool isl_union_map_is_single_valued(__isl_keep isl_union_map *umap)
__isl_export __isl_give isl_union_map * isl_union_map_intersect_range_factor_range(__isl_take isl_union_map *umap, __isl_take isl_union_map *factor)
__isl_export __isl_give isl_union_map * isl_union_map_intersect_range_factor_domain(__isl_take isl_union_map *umap, __isl_take isl_union_map *factor)
__isl_export isl_stat isl_union_map_foreach_map(__isl_keep isl_union_map *umap, isl_stat(*fn)(__isl_take isl_map *map, void *user), void *user)
isl_bool isl_union_map_plain_is_injective(__isl_keep isl_union_map *umap)
__isl_give isl_union_map * isl_union_map_lex_le_at_multi_union_pw_aff(__isl_take isl_union_map *umap, __isl_take isl_multi_union_pw_aff *mupa)
__isl_give isl_union_map * isl_union_map_lex_lt_at_multi_union_pw_aff(__isl_take isl_union_map *umap, __isl_take isl_multi_union_pw_aff *mupa)
__isl_export __isl_give isl_union_map * isl_union_map_subtract_domain(__isl_take isl_union_map *umap, __isl_take isl_union_set *dom)
__isl_export __isl_give isl_union_map * isl_union_map_apply_range(__isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2)
__isl_give isl_union_map * isl_union_map_copy(__isl_keep isl_union_map *umap)
__isl_constructor __isl_give isl_union_map * isl_union_map_read_from_str(isl_ctx *ctx, const char *str)
__isl_export isl_bool isl_union_map_is_empty(__isl_keep isl_union_map *umap)
__isl_export __isl_give isl_union_set * isl_union_map_range(__isl_take isl_union_map *umap)
__isl_export __isl_give isl_union_map * isl_union_map_from_domain(__isl_take isl_union_set *uset)
__isl_export __isl_give isl_union_map * isl_union_map_apply_domain(__isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2)
__isl_export __isl_give isl_union_map * isl_union_map_range_product(__isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2)
__isl_export __isl_give isl_union_map * isl_union_map_intersect_domain_factor_domain(__isl_take isl_union_map *umap, __isl_take isl_union_map *factor)
__isl_give isl_union_map * isl_union_map_empty(__isl_take isl_space *space)
__isl_export isl_bool isl_union_map_is_equal(__isl_keep isl_union_map *umap1, __isl_keep isl_union_map *umap2)
__isl_export __isl_give isl_union_map * isl_union_map_union(__isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2)
__isl_give isl_union_map * isl_union_map_intersect_domain(__isl_take isl_union_map *umap, __isl_take isl_union_set *uset)
__isl_export __isl_give isl_union_set * isl_union_map_bind_range(__isl_take isl_union_map *umap, __isl_take isl_multi_id *tuple)
__isl_export __isl_give isl_union_map * isl_union_map_intersect_domain_factor_range(__isl_take isl_union_map *umap, __isl_take isl_union_map *factor)
__isl_overload __isl_give isl_union_map * isl_union_map_eq_at_multi_union_pw_aff(__isl_take isl_union_map *umap, __isl_take isl_multi_union_pw_aff *mupa)
__isl_export __isl_give isl_union_set * isl_union_map_domain(__isl_take isl_union_map *umap)
__isl_give isl_union_map * isl_union_map_lex_gt_at_multi_union_pw_aff(__isl_take isl_union_map *umap, __isl_take isl_multi_union_pw_aff *mupa)
__isl_export __isl_give isl_union_map * isl_union_map_intersect(__isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2)
struct isl_union_map isl_union_map
__isl_give isl_set * isl_set_from_union_set(__isl_take isl_union_set *uset)
__isl_give isl_union_map * isl_union_set_lex_gt_union_set(__isl_take isl_union_set *uset1, __isl_take isl_union_set *uset2)
__isl_give isl_union_set * isl_union_set_product(__isl_take isl_union_set *uset1, __isl_take isl_union_set *uset2)
__isl_constructor __isl_give isl_union_set * isl_union_set_read_from_str(isl_ctx *ctx, const char *str)
__isl_export isl_bool isl_union_set_is_equal(__isl_keep isl_union_set *uset1, __isl_keep isl_union_set *uset2)
__isl_export __isl_give isl_space * isl_union_set_get_space(__isl_keep isl_union_set *uset)
__isl_constructor __isl_give isl_union_set * isl_union_set_from_set(__isl_take isl_set *set)
isl_size isl_union_set_n_set(__isl_keep isl_union_set *uset)
__isl_export __isl_give isl_set * isl_union_set_extract_set(__isl_keep isl_union_set *uset, __isl_take isl_space *space)
isl_ctx * isl_union_set_get_ctx(__isl_keep isl_union_set *uset)
__isl_give isl_union_set * isl_union_set_copy(__isl_keep isl_union_set *uset)
__isl_null isl_union_set * isl_union_set_free(__isl_take isl_union_set *uset)
__isl_export isl_bool isl_union_set_is_subset(__isl_keep isl_union_set *uset1, __isl_keep isl_union_set *uset2)
isl_bool isl_union_set_contains(__isl_keep isl_union_set *uset, __isl_keep isl_space *space)
__isl_export __isl_give isl_val * isl_val_abs(__isl_take isl_val *v)
Definition isl_val.c:456
__isl_export isl_bool isl_val_is_nan(__isl_keep isl_val *v)
Definition isl_val.c:1161
__isl_give isl_val * isl_val_copy(__isl_keep isl_val *v)
Definition isl_val.c:219
__isl_export int isl_val_cmp_si(__isl_keep isl_val *v, long i)
Definition isl_val.c:1394
__isl_export __isl_give isl_val * isl_val_floor(__isl_take isl_val *v)
Definition isl_val.c:470
__isl_export __isl_give isl_val * isl_val_inv(__isl_take isl_val *v)
Definition isl_val.c:429
__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_ceil(__isl_take isl_val *v)
Definition isl_val.c:491
__isl_export __isl_give isl_val * isl_val_div(__isl_take isl_val *v1, __isl_take isl_val *v2)
Definition isl_val.c:875
__isl_export __isl_give isl_val * isl_val_add(__isl_take isl_val *v1, __isl_take isl_val *v2)
Definition isl_val.c:626
__isl_export __isl_give isl_val * isl_val_one(isl_ctx *ctx)
Definition isl_val.c:48
__isl_constructor __isl_give isl_val * isl_val_int_from_si(isl_ctx *ctx, long i)
Definition isl_val.c:128
isl_ctx * isl_val_get_ctx(__isl_keep isl_val *val)
Definition isl_val.c:355
__isl_export __isl_give isl_val * isl_val_gcd(__isl_take isl_val *v1, __isl_take isl_val *v2)
Definition isl_val.c:1016
__isl_constructor __isl_give isl_multi_val * isl_multi_val_read_from_str(isl_ctx *ctx, const char *str)
__isl_null isl_val * isl_val_free(__isl_take isl_val *v)
Definition isl_val.c:263
__isl_export __isl_give isl_val * isl_val_sub(__isl_take isl_val *v1, __isl_take isl_val *v2)
Definition isl_val.c:704
__isl_export __isl_give isl_val * isl_val_pow2(__isl_take isl_val *v)
Definition isl_val.c:532
__isl_export isl_bool isl_val_eq(__isl_keep isl_val *v1, __isl_keep isl_val *v2)
Definition isl_val.c:1421
__isl_export __isl_give isl_val * isl_val_neg(__isl_take isl_val *v)
Definition isl_val.c:410
__isl_export __isl_give isl_val * isl_val_min(__isl_take isl_val *v1, __isl_take isl_val *v2)
Definition isl_val.c:570
__isl_constructor __isl_give isl_val * isl_val_read_from_str(isl_ctx *ctx, const char *str)
__isl_export __isl_give isl_val * isl_val_mul(__isl_take isl_val *v1, __isl_take isl_val *v2)
Definition isl_val.c:782
struct isl_multi_val isl_multi_val
Definition val_type.h:16
__isl_null isl_vertices * isl_vertices_free(__isl_take isl_vertices *vertices)
isl_size isl_vertices_get_n_vertices(__isl_keep isl_vertices *vertices)
__isl_null isl_vertex * isl_vertex_free(__isl_take isl_vertex *vertex)
isl_ctx * isl_vertex_get_ctx(__isl_keep isl_vertex *vertex)
__isl_give isl_basic_set * isl_cell_get_domain(__isl_keep isl_cell *cell)
isl_stat isl_vertices_foreach_vertex(__isl_keep isl_vertices *vertices, isl_stat(*fn)(__isl_take isl_vertex *vertex, void *user), void *user)
__isl_give isl_basic_set * isl_vertex_get_domain(__isl_keep isl_vertex *vertex)
__isl_give isl_vertices * isl_basic_set_compute_vertices(__isl_keep isl_basic_set *bset)
__isl_give isl_multi_aff * isl_vertex_get_expr(__isl_keep isl_vertex *vertex)
__isl_null isl_cell * isl_cell_free(__isl_take isl_cell *cell)
n
Definition youcefn.c:8