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
1570void test_convex_hull_case(struct isl_ctx *ctx, const char *name)
1571{
1572 char *filename;
1573 FILE *input;
1574 struct isl_basic_set *bset1, *bset2;
1575 struct isl_set *set;
1576
1577 filename = get_filename(ctx, name, "polylib");
1578 assert(filename);
1579 input = fopen(filename, "r");
1580 assert(input);
1581
1582 bset1 = isl_basic_set_read_from_file(ctx, input);
1583 bset2 = isl_basic_set_read_from_file(ctx, input);
1584
1585 set = isl_basic_set_union(bset1, bset2);
1586 bset1 = isl_set_convex_hull(set);
1587
1588 bset2 = isl_basic_set_read_from_file(ctx, input);
1589
1590 assert(isl_basic_set_is_equal(bset1, bset2) == 1);
1591
1592 isl_basic_set_free(bset1);
1593 isl_basic_set_free(bset2);
1594 free(filename);
1595
1596 fclose(input);
1597}
1598
1599struct {
1600 const char *set;
1601 const char *hull;
1602} convex_hull_tests[] = {
1603 { "{ [i0, i1, i2] : (i2 = 1 and i0 = 0 and i1 >= 0) or "
1604 "(i0 = 1 and i1 = 0 and i2 = 1) or "
1605 "(i0 = 0 and i1 = 0 and i2 = 0) }",
1606 "{ [i0, i1, i2] : i0 >= 0 and i2 >= i0 and i2 <= 1 and i1 >= 0 }" },
1607 { "[n] -> { [i0, i1, i0] : i0 <= -4 + n; "
1608 "[i0, i0, i2] : n = 6 and i0 >= 0 and i2 <= 7 - i0 and "
1609 "i2 <= 5 and i2 >= 4; "
1610 "[3, i1, 3] : n = 5 and i1 <= 2 and i1 >= 0 }",
1611 "[n] -> { [i0, i1, i2] : i2 <= -1 + n and 2i2 <= -6 + 3n - i0 and "
1612 "i2 <= 5 + i0 and i2 >= i0 }" },
1613 { "{ [x, y] : 3y <= 2x and y >= -2 + 2x and 2y >= 2 - x }",
1614 "{ [x, y] : 1 = 0 }" },
1615 { "{ [x, y, z] : 0 <= x, y, z <= 10; [x, y, 0] : x >= 0 and y > 0; "
1616 "[x, y, 0] : x >= 0 and y < 0 }",
1617 "{ [x, y, z] : x >= 0 and 0 <= z <= 10 }" },
1618 { "{ [a, b, c] : a <= 1 and -a < b <= 1 and 0 <= c <= 2 - a - b and "
1619 "c <= a; "
1620 "[0, 2, 0]; [3, 1, 0] }",
1621 "{ [a, b, c] : b > -a and 2b >= -1 + a and 0 <= c <= a and "
1622 "5c <= 6 - a - 3b }" },
1624
1626{
1627 int i;
1628 int orig_convex = ctx->opt->convex;
1629 ctx->opt->convex = convex;
1630
1631 test_convex_hull_case(ctx, "convex0");
1632 test_convex_hull_case(ctx, "convex1");
1633 test_convex_hull_case(ctx, "convex2");
1634 test_convex_hull_case(ctx, "convex3");
1635 test_convex_hull_case(ctx, "convex4");
1636 test_convex_hull_case(ctx, "convex5");
1637 test_convex_hull_case(ctx, "convex6");
1638 test_convex_hull_case(ctx, "convex7");
1639 test_convex_hull_case(ctx, "convex8");
1640 test_convex_hull_case(ctx, "convex9");
1641 test_convex_hull_case(ctx, "convex10");
1642 test_convex_hull_case(ctx, "convex11");
1643 test_convex_hull_case(ctx, "convex12");
1644 test_convex_hull_case(ctx, "convex13");
1645 test_convex_hull_case(ctx, "convex14");
1646 test_convex_hull_case(ctx, "convex15");
1647
1648 for (i = 0; i < ARRAY_SIZE(convex_hull_tests); ++i) {
1649 isl_set *set1, *set2;
1650 int equal;
1651
1658
1659 if (equal < 0)
1660 return -1;
1661 if (!equal)
1663 "unexpected convex hull", return -1);
1664 }
1665
1666 ctx->opt->convex = orig_convex;
1667
1668 return 0;
1669}
1670
1672{
1674 return -1;
1676 return -1;
1677 return 0;
1678}
1679
1680/* Check that computing the gist of "map" with respect to "context"
1681 * does not make any copy of "map" get marked empty.
1682 * Earlier versions of isl would end up doing that.
1683 */
1684static isl_stat test_gist_empty_pair(isl_ctx *ctx, const char *map,
1685 const char *context)
1686{
1687 isl_map *m1, *m2, *m3;
1688 isl_bool empty_before, empty_after;
1689
1690 m1 = isl_map_read_from_str(ctx, map);
1691 m2 = isl_map_read_from_str(ctx, context);
1692 m3 = isl_map_copy(m1);
1693 empty_before = isl_map_is_empty(m3);
1694 m1 = isl_map_gist(m1, m2);
1695 empty_after = isl_map_is_empty(m3);
1696 isl_map_free(m1);
1697 isl_map_free(m3);
1698
1699 if (empty_before < 0 || empty_after < 0)
1700 return isl_stat_error;
1701 if (empty_before)
1702 isl_die(ctx, isl_error_unknown, "map should not be empty",
1703 return isl_stat_error);
1704 if (empty_after)
1705 isl_die(ctx, isl_error_unknown, "map should still not be empty",
1706 return isl_stat_error);
1707
1708 return isl_stat_ok;
1709}
1710
1711/* Check that computing a gist does not make any copy of the input
1712 * get marked empty.
1713 * Earlier versions of isl would end up doing that on some pairs of inputs.
1714 */
1716{
1717 const char *map, *context;
1718
1719 map = "{ [] -> [a, b, c] : 2b = 1 + a }";
1720 context = "{ [] -> [a, b, c] : 2c = 2 + a }";
1721 if (test_gist_empty_pair(ctx, map, context) < 0)
1722 return isl_stat_error;
1723 map = "{ [] -> [0, 0] }";
1724 context = "{ [] -> [a, b] : a > b }";
1725 if (test_gist_empty_pair(ctx, map, context) < 0)
1726 return isl_stat_error;
1727
1728 return isl_stat_ok;
1729}
1730
1731/* Inputs to isl_map_plain_gist_basic_map, along with the expected output.
1732 */
1733struct {
1734 const char *map;
1735 const char *context;
1736 const char *gist;
1737} plain_gist_tests[] = {
1738 { "{ [i] -> [j] : i >= 1 and j >= 1 or i >= 2 and j <= 10 }",
1739 "{ [i] -> [j] : i >= 1 }",
1740 "{ [i] -> [j] : j >= 1 or i >= 2 and j <= 10 }" },
1741 { "{ [n] -> [i,j,k] : (i mod 3 = 2 and j mod 4 = 2) or "
1742 "(j mod 4 = 2 and k mod 6 = n) }",
1743 "{ [n] -> [i,j,k] : j mod 4 = 2 }",
1744 "{ [n] -> [i,j,k] : (i mod 3 = 2) or (k mod 6 = n) }" },
1745 { "{ [i] -> [j] : i > j and (exists a,b : i <= 2a + 5b <= 2) }",
1746 "{ [i] -> [j] : i > j }",
1747 "{ [i] -> [j] : exists a,b : i <= 2a + 5b <= 2 }" },
1749
1750/* Basic tests for isl_map_plain_gist_basic_map.
1751 */
1752static int test_plain_gist(isl_ctx *ctx)
1753{
1754 int i;
1755
1756 for (i = 0; i < ARRAY_SIZE(plain_gist_tests); ++i) {
1757 const char *str;
1758 int equal;
1759 isl_map *map, *gist;
1761
1763 str = plain_gist_tests[i].context;
1770 if (equal < 0)
1771 return -1;
1772 if (!equal)
1774 "incorrect gist result", return -1);
1775 }
1776
1777 return 0;
1778}
1779
1780/* Check that isl_set_gist behaves as expected.
1781 */
1782static int test_gist(struct isl_ctx *ctx)
1783{
1784 const char *str;
1785 isl_basic_set *bset1, *bset2;
1786 isl_map *map1, *map2;
1787 isl_size n_div;
1788
1789 str = "[p0, p2, p3, p5, p6, p10] -> { [] : "
1790 "exists (e0 = [(15 + p0 + 15p6 + 15p10)/16], e1 = [(p5)/8], "
1791 "e2 = [(p6)/128], e3 = [(8p2 - p5)/128], "
1792 "e4 = [(128p3 - p6)/4096]: 8e1 = p5 and 128e2 = p6 and "
1793 "128e3 = 8p2 - p5 and 4096e4 = 128p3 - p6 and p2 >= 0 and "
1794 "16e0 >= 16 + 16p6 + 15p10 and p2 <= 15 and p3 >= 0 and "
1795 "p3 <= 31 and p6 >= 128p3 and p5 >= 8p2 and p10 >= 0 and "
1796 "16e0 <= 15 + p0 + 15p6 + 15p10 and 16e0 >= p0 + 15p6 + 15p10 and "
1797 "p10 <= 15 and p10 <= -1 + p0 - p6) }";
1798 bset1 = isl_basic_set_read_from_str(ctx, str);
1799 str = "[p0, p2, p3, p5, p6, p10] -> { [] : exists (e0 = [(p5)/8], "
1800 "e1 = [(p6)/128], e2 = [(8p2 - p5)/128], "
1801 "e3 = [(128p3 - p6)/4096]: 8e0 = p5 and 128e1 = p6 and "
1802 "128e2 = 8p2 - p5 and 4096e3 = 128p3 - p6 and p5 >= -7 and "
1803 "p2 >= 0 and 8p2 <= -1 + p0 and p2 <= 15 and p3 >= 0 and "
1804 "p3 <= 31 and 128p3 <= -1 + p0 and p6 >= -127 and "
1805 "p5 <= -1 + p0 and p6 <= -1 + p0 and p6 >= 128p3 and "
1806 "p0 >= 1 and p5 >= 8p2 and p10 >= 0 and p10 <= 15 ) }";
1807 bset2 = isl_basic_set_read_from_str(ctx, str);
1808 bset1 = isl_basic_set_gist(bset1, bset2);
1809 assert(bset1 && bset1->n_div == 0);
1810 isl_basic_set_free(bset1);
1811
1812 /* Check that the integer divisions of the second disjunct
1813 * do not spread to the first disjunct.
1814 */
1815 str = "[t1] -> { S_0[] -> A[o0] : (exists (e0 = [(-t1 + o0)/16]: "
1816 "16e0 = -t1 + o0 and o0 >= 0 and o0 <= 15 and t1 >= 0)) or "
1817 "(exists (e0 = [(-1 + t1)/16], "
1818 "e1 = [(-16 + t1 - 16e0)/4294967296]: "
1819 "4294967296e1 = -16 + t1 - o0 - 16e0 and "
1820 "16e0 <= -1 + t1 and 16e0 >= -16 + t1 and o0 >= 0 and "
1821 "o0 <= 4294967295 and t1 <= -1)) }";
1823 str = "[t1] -> { S_0[] -> A[o0] : t1 >= 0 and t1 <= 4294967295 }";
1826 if (!map1)
1827 return -1;
1828 if (map1->n != 1)
1829 isl_die(ctx, isl_error_unknown, "expecting single disjunct",
1830 isl_map_free(map1); return -1);
1831 n_div = isl_basic_map_dim(map1->p[0], isl_dim_div);
1833 if (n_div < 0)
1834 return -1;
1835 if (n_div != 1)
1836 isl_die(ctx, isl_error_unknown, "expecting single div",
1837 return -1);
1838
1839 if (test_gist_empty(ctx) < 0)
1840 return -1;
1841 if (test_plain_gist(ctx) < 0)
1842 return -1;
1843
1844 return 0;
1845}
1846
1847int test_coalesce_set(isl_ctx *ctx, const char *str, int check_one)
1848{
1849 isl_set *set, *set2;
1850 int equal;
1851 int one;
1852
1857 one = set && set->n == 1;
1860
1861 if (equal < 0)
1862 return -1;
1863 if (!equal)
1865 "coalesced set not equal to input", return -1);
1866 if (check_one && !one)
1868 "coalesced set should not be a union", return -1);
1869
1870 return 0;
1871}
1872
1873/* Inputs for coalescing tests with unbounded wrapping.
1874 * "str" is a string representation of the input set.
1875 * "single_disjunct" is set if we expect the result to consist of
1876 * a single disjunct.
1877 */
1878struct {
1880 const char *str;
1882 { 1, "{ [x,y,z] : y + 2 >= 0 and x - y + 1 >= 0 and "
1883 "-x - y + 1 >= 0 and -3 <= z <= 3;"
1884 "[x,y,z] : -x+z + 20 >= 0 and -x-z + 20 >= 0 and "
1885 "x-z + 20 >= 0 and x+z + 20 >= 0 and "
1886 "-10 <= y <= 0}" },
1887 { 1, "{ [x,y] : 0 <= x,y <= 10; [5,y]: 4 <= y <= 11 }" },
1888 { 1, "{ [x,0,0] : -5 <= x <= 5; [0,y,1] : -5 <= y <= 5 }" },
1889 { 1, "{ [x,y] : 0 <= x <= 10 and 0 >= y >= -1 and x+y >= 0; [0,1] }" },
1890 { 1, "{ [x,y] : (0 <= x,y <= 4) or (2 <= x,y <= 5 and x + y <= 9) }" },
1891 { 0, "{ [x, y, z] : 0 <= x,y,z <= 100 and 0 < z <= 2 + 2x + 2y; "
1892 "[x, y, 0] : x,y <= 100 and y <= 9 + 11x and x <= 9 + 11y }" },
1893 { 1, "{ [0:1, 0:1]; [0, 2:3] }" },
1894 { 1, "{ [0:1, 0:1]; [0, 2:3]; [1, -2:-1] }" },
1895 { 1, "{ [0:3, 0:1]; [1:2, 2:5] }" },
1896 { 1, "{ [0:3, 0:1]; [0:2, 2:5] }" },
1897 { 1, "{ [0:3, 0:1]; [1:3, 2:5] }" },
1898 { 0, "{ [0:3, 0:1]; [1:4, 2:5] }" },
1899 { 0, "{ [0:3, 0:1]; [1:5, 2:5] }" },
1901
1902/* Test the functionality of isl_set_coalesce with the bounded wrapping
1903 * option turned off.
1904 */
1906{
1907 int i;
1908 int r = 0;
1909 int bounded;
1910
1913
1914 for (i = 0; i < ARRAY_SIZE(coalesce_unbounded_tests); ++i) {
1915 const char *str = coalesce_unbounded_tests[i].str;
1916 int check_one = coalesce_unbounded_tests[i].single_disjunct;
1917 if (test_coalesce_set(ctx, str, check_one) >= 0)
1918 continue;
1919 r = -1;
1920 break;
1921 }
1922
1924
1925 return r;
1926}
1927
1928/* Inputs for coalescing tests.
1929 * "str" is a string representation of the input set.
1930 * "single_disjunct" is set if we expect the result to consist of
1931 * a single disjunct.
1932 */
1933struct {
1934 int single_disjunct;
1935 const char *str;
1936} coalesce_tests[] = {
1937 { 1, "{[x,y]: x >= 0 & x <= 10 & y >= 0 & y <= 10 or "
1938 "y >= x & x >= 2 & 5 >= y }" },
1939 { 1, "{[x,y]: y >= 0 & 2x + y <= 30 & y <= 10 & x >= 0 or "
1940 "x + y >= 10 & y <= x & x + y <= 20 & y >= 0}" },
1941 { 0, "{[x,y]: y >= 0 & 2x + y <= 30 & y <= 10 & x >= 0 or "
1942 "x + y >= 10 & y <= x & x + y <= 19 & y >= 0}" },
1943 { 1, "{[x,y]: y >= 0 & x <= 5 & y <= x or "
1944 "y >= 0 & x >= 6 & x <= 10 & y <= x}" },
1945 { 0, "{[x,y]: y >= 0 & x <= 5 & y <= x or "
1946 "y >= 0 & x >= 7 & x <= 10 & y <= x}" },
1947 { 0, "{[x,y]: y >= 0 & x <= 5 & y <= x or "
1948 "y >= 0 & x >= 6 & x <= 10 & y + 1 <= x}" },
1949 { 1, "{[x,y]: y >= 0 & x <= 5 & y <= x or y >= 0 & x = 6 & y <= 6}" },
1950 { 0, "{[x,y]: y >= 0 & x <= 5 & y <= x or y >= 0 & x = 7 & y <= 6}" },
1951 { 1, "{[x,y]: y >= 0 & x <= 5 & y <= x or y >= 0 & x = 6 & y <= 5}" },
1952 { 0, "{[x,y]: y >= 0 & x <= 5 & y <= x or y >= 0 & x = 6 & y <= 7}" },
1953 { 1, "[n] -> { [i] : i = 1 and n >= 2 or 2 <= i and i <= n }" },
1954 { 0, "{[x,y] : x >= 0 and y >= 0 or 0 <= y and y <= 5 and x = -1}" },
1955 { 1, "[n] -> { [i] : 1 <= i and i <= n - 1 or 2 <= i and i <= n }" },
1956 { 0, "[n] -> { [[i0] -> [o0]] : exists (e0 = [(i0)/4], e1 = [(o0)/4], "
1957 "e2 = [(n)/2], e3 = [(-2 + i0)/4], e4 = [(-2 + o0)/4], "
1958 "e5 = [(-2n + i0)/4]: 2e2 = n and 4e3 = -2 + i0 and "
1959 "4e4 = -2 + o0 and i0 >= 8 + 2n and o0 >= 2 + i0 and "
1960 "o0 <= 56 + 2n and o0 <= -12 + 4n and i0 <= 57 + 2n and "
1961 "i0 <= -11 + 4n and o0 >= 6 + 2n and 4e0 <= i0 and "
1962 "4e0 >= -3 + i0 and 4e1 <= o0 and 4e1 >= -3 + o0 and "
1963 "4e5 <= -2n + i0 and 4e5 >= -3 - 2n + i0);"
1964 "[[i0] -> [o0]] : exists (e0 = [(i0)/4], e1 = [(o0)/4], "
1965 "e2 = [(n)/2], e3 = [(-2 + i0)/4], e4 = [(-2 + o0)/4], "
1966 "e5 = [(-2n + i0)/4]: 2e2 = n and 4e3 = -2 + i0 and "
1967 "4e4 = -2 + o0 and 2e0 >= 3 + n and e0 <= -4 + n and "
1968 "2e0 <= 27 + n and e1 <= -4 + n and 2e1 <= 27 + n and "
1969 "2e1 >= 2 + n and e1 >= 1 + e0 and i0 >= 7 + 2n and "
1970 "i0 <= -11 + 4n and i0 <= 57 + 2n and 4e0 <= -2 + i0 and "
1971 "4e0 >= -3 + i0 and o0 >= 6 + 2n and o0 <= -11 + 4n and "
1972 "o0 <= 57 + 2n and 4e1 <= -2 + o0 and 4e1 >= -3 + o0 and "
1973 "4e5 <= -2n + i0 and 4e5 >= -3 - 2n + i0 ) }" },
1974 { 0, "[n, m] -> { [o0, o2, o3] : (o3 = 1 and o0 >= 1 + m and "
1975 "o0 <= n + m and o2 <= m and o0 >= 2 + n and o2 >= 3) or "
1976 "(o0 >= 2 + n and o0 >= 1 + m and o0 <= n + m and n >= 1 and "
1977 "o3 <= -1 + o2 and o3 >= 1 - m + o2 and o3 >= 2 and o3 <= n) }" },
1978 { 0, "[M, N] -> { [[i0, i1, i2, i3, i4, i5, i6] -> "
1979 "[o0, o1, o2, o3, o4, o5, o6]] : "
1980 "(o6 <= -4 + 2M - 2N + i0 + i1 - i2 + i6 - o0 - o1 + o2 and "
1981 "o3 <= -2 + i3 and o6 >= 2 + i0 + i3 + i6 - o0 - o3 and "
1982 "o6 >= 2 - M + N + i3 + i4 + i6 - o3 - o4 and o0 <= -1 + i0 and "
1983 "o4 >= 4 - 3M + 3N - i0 - i1 + i2 + 2i3 + i4 + o0 + o1 - o2 - 2o3 "
1984 "and o6 <= -3 + 2M - 2N + i3 + i4 - i5 + i6 - o3 - o4 + o5 and "
1985 "2o6 <= -5 + 5M - 5N + 2i0 + i1 - i2 - i5 + 2i6 - 2o0 - o1 + o2 + o5 "
1986 "and o6 >= 2i0 + i1 + i6 - 2o0 - o1 and "
1987 "3o6 <= -5 + 4M - 4N + 2i0 + i1 - i2 + 2i3 + i4 - i5 + 3i6 "
1988 "- 2o0 - o1 + o2 - 2o3 - o4 + o5) or "
1989 "(N >= 2 and o3 <= -1 + i3 and o0 <= -1 + i0 and "
1990 "o6 >= i3 + i6 - o3 and M >= 0 and "
1991 "2o6 >= 1 + i0 + i3 + 2i6 - o0 - o3 and "
1992 "o6 >= 1 - M + i0 + i6 - o0 and N >= 2M and o6 >= i0 + i6 - o0) }" },
1993 { 0, "[M, N] -> { [o0] : (o0 = 0 and M >= 1 and N >= 2) or "
1994 "(o0 = 0 and M >= 1 and N >= 2M and N >= 2 + M) or "
1995 "(o0 = 0 and M >= 2 and N >= 3) or "
1996 "(M = 0 and o0 = 0 and N >= 3) }" },
1997 { 0, "{ [i0, i1, i2, i3] : (i1 = 10i0 and i0 >= 1 and 10i0 <= 100 and "
1998 "i3 <= 9 + 10 i2 and i3 >= 1 + 10i2 and i3 >= 0) or "
1999 "(i1 <= 9 + 10i0 and i1 >= 1 + 10i0 and i2 >= 0 and "
2000 "i0 >= 0 and i1 <= 100 and i3 <= 9 + 10i2 and i3 >= 1 + 10i2) }" },
2001 { 0, "[M] -> { [i1] : (i1 >= 2 and i1 <= M) or (i1 = M and M >= 1) }" },
2002 { 0, "{[x,y] : x,y >= 0; [x,y] : 10 <= x <= 20 and y >= -1 }" },
2003 { 1, "{ [x, y] : (x >= 1 and y >= 1 and x <= 2 and y <= 2) or "
2004 "(y = 3 and x = 1) }" },
2005 { 1, "[M] -> { [i0, i1, i2, i3, i4] : (i1 >= 3 and i4 >= 2 + i2 and "
2006 "i2 >= 2 and i0 >= 2 and i3 >= 1 + i2 and i0 <= M and "
2007 "i1 <= M and i3 <= M and i4 <= M) or "
2008 "(i1 >= 2 and i4 >= 1 + i2 and i2 >= 2 and i0 >= 2 and "
2009 "i3 >= 1 + i2 and i0 <= M and i1 <= -1 + M and i3 <= M and "
2010 "i4 <= -1 + M) }" },
2011 { 1, "{ [x, y] : (x >= 0 and y >= 0 and x <= 10 and y <= 10) or "
2012 "(x >= 1 and y >= 1 and x <= 11 and y <= 11) }" },
2013 { 0, "{[x,0] : x >= 0; [x,1] : x <= 20}" },
2014 { 1, "{ [x, 1 - x] : 0 <= x <= 1; [0,0] }" },
2015 { 1, "{ [0,0]; [i,i] : 1 <= i <= 10 }" },
2016 { 0, "{ [0,0]; [i,j] : 1 <= i,j <= 10 }" },
2017 { 1, "{ [0,0]; [i,2i] : 1 <= i <= 10 }" },
2018 { 0, "{ [0,0]; [i,2i] : 2 <= i <= 10 }" },
2019 { 0, "{ [1,0]; [i,2i] : 1 <= i <= 10 }" },
2020 { 0, "{ [0,1]; [i,2i] : 1 <= i <= 10 }" },
2021 { 0, "{ [a, b] : exists e : 2e = a and "
2022 "a >= 0 and (a <= 3 or (b <= 0 and b >= -4 + a)) }" },
2023 { 0, "{ [i, j, i', j'] : i <= 2 and j <= 2 and "
2024 "j' >= -1 + 2i + j - 2i' and i' <= -1 + i and "
2025 "j >= 1 and j' <= i + j - i' and i >= 1; "
2026 "[1, 1, 1, 1] }" },
2027 { 1, "{ [i,j] : exists a,b : i = 2a and j = 3b; "
2028 "[i,j] : exists a : j = 3a }" },
2029 { 1, "{ [a, b, c] : (c <= 7 - b and b <= 1 and b >= 0 and "
2030 "c >= 3 + b and b <= 3 + 8a and b >= -26 + 8a and "
2031 "a >= 3) or "
2032 "(b <= 1 and c <= 7 and b >= 0 and c >= 4 + b and "
2033 "b <= 3 + 8a and b >= -26 + 8a and a >= 3) }" },
2034 { 1, "{ [a, 0, c] : c >= 1 and c <= 29 and c >= -1 + 8a and "
2035 "c <= 6 + 8a and a >= 3; "
2036 "[a, -1, c] : c >= 1 and c <= 30 and c >= 8a and "
2037 "c <= 7 + 8a and a >= 3 and a <= 4 }" },
2038 { 1, "{ [x,y] : 0 <= x <= 2 and y >= 0 and x + 2y <= 4; "
2039 "[x,0] : 3 <= x <= 4 }" },
2040 { 1, "{ [x,y] : 0 <= x <= 3 and y >= 0 and x + 3y <= 6; "
2041 "[x,0] : 4 <= x <= 5 }" },
2042 { 0, "{ [x,y] : 0 <= x <= 2 and y >= 0 and x + 2y <= 4; "
2043 "[x,0] : 3 <= x <= 5 }" },
2044 { 0, "{ [x,y] : 0 <= x <= 2 and y >= 0 and x + y <= 4; "
2045 "[x,0] : 3 <= x <= 4 }" },
2046 { 1, "{ [i0, i1] : i0 <= 122 and i0 >= 1 and 128i1 >= -249 + i0 and "
2047 "i1 <= 0; "
2048 "[i0, 0] : i0 >= 123 and i0 <= 124 }" },
2049 { 1, "{ [0,0]; [1,1] }" },
2050 { 1, "[n] -> { [k] : 16k <= -1 + n and k >= 1; [0] : n >= 2 }" },
2051 { 1, "{ [k, ii, k - ii] : ii >= -6 + k and ii <= 6 and ii >= 1 and "
2052 "ii <= k;"
2053 "[k, 0, k] : k <= 6 and k >= 1 }" },
2054 { 1, "{ [i,j] : i = 4 j and 0 <= i <= 100;"
2055 "[i,j] : 1 <= i <= 100 and i >= 4j + 1 and i <= 4j + 2 }" },
2056 { 1, "{ [x,y] : x % 2 = 0 and y % 2 = 0; [x,x] : x % 2 = 0 }" },
2057 { 1, "[n] -> { [1] : n >= 0;"
2058 "[x] : exists (e0 = floor((x)/2): x >= 2 and "
2059 "2e0 >= -1 + x and 2e0 <= x and 2e0 <= n) }" },
2060 { 1, "[n] -> { [x, y] : exists (e0 = floor((x)/2), e1 = floor((y)/3): "
2061 "3e1 = y and x >= 2 and 2e0 >= -1 + x and "
2062 "2e0 <= x and 2e0 <= n);"
2063 "[1, y] : exists (e0 = floor((y)/3): 3e0 = y and "
2064 "n >= 0) }" },
2065 { 1, "[t1] -> { [i0] : (exists (e0 = floor((63t1)/64): "
2066 "128e0 >= -134 + 127t1 and t1 >= 2 and "
2067 "64e0 <= 63t1 and 64e0 >= -63 + 63t1)) or "
2068 "t1 = 1 }" },
2069 { 1, "{ [i, i] : exists (e0 = floor((1 + 2i)/3): 3e0 <= 2i and "
2070 "3e0 >= -1 + 2i and i <= 9 and i >= 1);"
2071 "[0, 0] }" },
2072 { 1, "{ [t1] : exists (e0 = floor((-11 + t1)/2): 2e0 = -11 + t1 and "
2073 "t1 >= 13 and t1 <= 16);"
2074 "[t1] : t1 <= 15 and t1 >= 12 }" },
2075 { 1, "{ [x,y] : x = 3y and 0 <= y <= 2; [-3,-1] }" },
2076 { 1, "{ [x,y] : 2x = 3y and 0 <= y <= 4; [-3,-2] }" },
2077 { 0, "{ [x,y] : 2x = 3y and 0 <= y <= 4; [-2,-2] }" },
2078 { 0, "{ [x,y] : 2x = 3y and 0 <= y <= 4; [-3,-1] }" },
2079 { 1, "{ [i] : exists j : i = 4 j and 0 <= i <= 100;"
2080 "[i] : exists j : 1 <= i <= 100 and i >= 4j + 1 and "
2081 "i <= 4j + 2 }" },
2082 { 1, "{ [c0] : (exists (e0 : c0 - 1 <= 3e0 <= c0)) or "
2083 "(exists (e0 : 3e0 = -2 + c0)) }" },
2084 { 0, "[n, b0, t0] -> "
2085 "{ [i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12] : "
2086 "(exists (e0 = floor((-32b0 + i4)/1048576), "
2087 "e1 = floor((i8)/32): 1048576e0 = -32b0 + i4 and 32e1 = i8 and "
2088 "n <= 2147483647 and b0 <= 32767 and b0 >= 0 and "
2089 "32b0 <= -2 + n and t0 <= 31 and t0 >= 0 and i0 >= 8 + n and "
2090 "3i4 <= -96 + 3t0 + i0 and 3i4 >= -95 - n + 3t0 + i0 and "
2091 "i8 >= -157 + i0 - 4i4 and i8 >= 0 and "
2092 "i8 <= -33 + i0 - 4i4 and 3i8 <= -91 + 4n - i0)) or "
2093 "(exists (e0 = floor((-32b0 + i4)/1048576), "
2094 "e1 = floor((i8)/32): 1048576e0 = -32b0 + i4 and 32e1 = i8 and "
2095 "n <= 2147483647 and b0 <= 32767 and b0 >= 0 and "
2096 "32b0 <= -2 + n and t0 <= 31 and t0 >= 0 and i0 <= 7 + n and "
2097 "4i4 <= -3 + i0 and 3i4 <= -96 + 3t0 + i0 and "
2098 "3i4 >= -95 - n + 3t0 + i0 and i8 >= -157 + i0 - 4i4 and "
2099 "i8 >= 0 and i8 <= -4 + i0 - 3i4 and i8 <= -41 + i0));"
2100 "[i0, i1, i2, i3, 0, i5, i6, i7, i8, i9, i10, i11, i12] : "
2101 "(exists (e0 = floor((i8)/32): b0 = 0 and 32e0 = i8 and "
2102 "n <= 2147483647 and t0 <= 31 and t0 >= 0 and i0 >= 11 and "
2103 "i0 >= 96 - 3t0 and i0 <= 95 + n - 3t0 and i0 <= 7 + n and "
2104 "i8 >= -40 + i0 and i8 <= -10 + i0)) }" },
2105 { 0, "{ [i0, i1, i2] : "
2106 "(exists (e0, e1 = floor((i0)/32), e2 = floor((i1)/32): "
2107 "32e1 = i0 and 32e2 = i1 and i1 >= -31 + i0 and "
2108 "i1 <= 31 + i0 and i2 >= -30 + i0 and i2 >= -30 + i1 and "
2109 "32e0 >= -30 + i0 and 32e0 >= -30 + i1 and "
2110 "32e0 >= -31 + i2 and 32e0 <= 30 + i2 and 32e0 <= 31 + i1 and "
2111 "32e0 <= 31 + i0)) or "
2112 "i0 >= 0 }" },
2113 { 1, "{ [a, b, c] : 2b = 1 + a and 2c = 2 + a; [0, 0, 0] }" },
2114 { 1, "{ [a, a, b, c] : 32*floor((a)/32) = a and 2*floor((b)/2) = b and "
2115 "2*floor((c)/2) = c and 0 <= a <= 192;"
2116 "[224, 224, b, c] : 2*floor((b)/2) = b and 2*floor((c)/2) = c }"
2117 },
2118 { 1, "[n] -> { [a,b] : (exists e : 1 <= a <= 7e and 9e <= b <= n) or "
2119 "(0 <= a <= b <= n) }" },
2120 { 1, "{ [a, b] : 0 <= a <= 2 and b >= 0 and "
2121 "((0 < b <= 13) or (2*floor((a + b)/2) >= -5 + a + 2b)) }" },
2122 { 1, "{ [a] : (2 <= a <= 5) or (a mod 2 = 1 and 1 <= a <= 5) }" },
2123 { 1, "{ [a, b, c] : (b = -1 + a and 0 < a <= 3 and "
2124 "9*floor((-4a + 2c)/9) <= -3 - 4a + 2c) or "
2125 "(exists (e0 = floor((-16 + 2c)/9): a = 4 and "
2126 "b = 3 and 9e0 <= -19 + 2c)) }" },
2127 { 1, "{ [a, b, c] : (b = -1 + a and 0 < a <= 3 and "
2128 "9*floor((-4a + 2c)/9) <= -3 - 4a + 2c) or "
2129 "(a = 4 and b = 3 and "
2130 "9*floor((-16 + 2c)/9) <= -19 + 2c) }" },
2131 { 0, "{ [a, b, c] : (b <= 2 and b <= -2 + a) or "
2132 "(b = -1 + a and 0 < a <= 3 and "
2133 "9*floor((-4a + 2c)/9) <= -3 - 4a + 2c) or "
2134 "(exists (e0 = floor((-16 + 2c)/9): a = 4 and "
2135 "b = 3 and 9e0 <= -19 + 2c)) }" },
2136 { 1, "{ [y, x] : (x - y) mod 3 = 2 and 2 <= y <= 200 and 0 <= x <= 2;"
2137 "[1, 0] }" },
2138 { 1, "{ [x, y] : (x - y) mod 3 = 2 and 2 <= y <= 200 and 0 <= x <= 2;"
2139 "[0, 1] }" },
2140 { 1, "{ [1, y] : -1 <= y <= 1; [x, -x] : 0 <= x <= 1 }" },
2141 { 1, "{ [1, y] : 0 <= y <= 1; [x, -x] : 0 <= x <= 1 }" },
2142 { 1, "{ [x, y] : 0 <= x <= 10 and x - 4*floor(x/4) <= 1 and y <= 0; "
2143 "[x, y] : 0 <= x <= 10 and x - 4*floor(x/4) > 1 and y <= 0; "
2144 "[x, y] : 0 <= x <= 10 and x - 5*floor(x/5) <= 1 and 0 < y; "
2145 "[x, y] : 0 <= x <= 10 and x - 5*floor(x/5) > 1 and 0 < y }" },
2146 { 1, "{ [x, 0] : 0 <= x <= 10 and x mod 2 = 0; "
2147 "[x, 0] : 0 <= x <= 10 and x mod 2 = 1; "
2148 "[x, y] : 0 <= x <= 10 and 1 <= y <= 10 }" },
2149 { 1, "{ [a] : a <= 8 and "
2150 "(a mod 10 = 7 or a mod 10 = 8 or a mod 10 = 9) }" },
2151 { 1, "{ [x, y] : 2y = -x and x <= 0 or "
2152 "x <= -1 and 2y <= -x - 1 and 2y >= x - 1 }" },
2153 { 0, "{ [x, y] : 2y = -x and x <= 0 or "
2154 "x <= -2 and 2y <= -x - 1 and 2y >= x - 1 }" },
2155 { 1, "{ [a] : (a <= 0 and 3*floor((a)/3) = a) or "
2156 "(a < 0 and 3*floor((a)/3) < a) }" },
2157 { 1, "{ [a] : (a <= 0 and 3*floor((a)/3) = a) or "
2158 "(a < -1 and 3*floor((a)/3) < a) }" },
2159 { 1, "{ [a, b] : a <= 1024 and b >= 0 and "
2160 "((-31 - a + b <= 32*floor((-1 - a)/32) <= -33 + b and "
2161 "32*floor((-1 - a)/32) <= -16 + b + 16*floor((-1 - a)/16))"
2162 "or (2 <= a <= 15 and b < a)) }" },
2163 { 1, "{ [a] : a > 0 and ((16*floor((a)/16) < a and "
2164 "32*floor((a)/32) < a) or a <= 15) }" },
2165 { 1, "{ [a, b, c, d] : (-a + d) mod 64 = 0 and a <= 8 and b <= 1 and "
2166 "10 - a <= c <= 3 and d >= 5 and 9 - 64b <= d <= 70;"
2167 "[a, b = 1, c, d] : (-a + d) mod 64 = 0 and a <= 8 and c >= 4 and "
2168 "10 - a <= c <= 5 and 5 <= d <= 73 - c }" },
2169 { 1, "[n, m] -> { S_0[i] : (-n + i) mod 3 = 0 and m >= 3 + n and "
2170 "i >= n and 3*floor((2 + n + 2m)/3) <= n + 3m - i; "
2171 "S_0[n] : n <= m <= 2 + n }" },
2172 { 1, "{ [a, b] : exists (e0: 0 <= a <= 1 and b >= 0 and "
2173 "2e0 >= -5 + a + 2b and 2e0 >= -1 + a + b and "
2174 "2e0 <= a + b); "
2175 "[a, b] : exists (e0: 0 <= a <= 1 and 2e0 >= -5 + a + 2b and "
2176 "2e0 >= -1 - a + b and 2e0 <= -a + b and "
2177 "2e0 < -a + 2b) }" },
2178 { 1, "{ [i, j, i - 8j] : 8 <= i <= 63 and -7 + i <= 8j <= i; "
2179 "[i, 0, i] : 0 <= i <= 7 }" },
2180 { 1, "{ [a, b] : a >= 0 and 0 <= b <= 1 - a; [1, 1] }" },
2181 { 0, "{ [a, b] : a >= 0 and 0 <= b <= 1 - a; [0, 2] }" },
2182 { 0, "{ [a, b] : a >= 0 and 0 <= b <= 1 - a; [-1, 3] }" },
2183 { 1, "{ [a, b] : a, b >= 0 and a + 2b <= 2; [1, 1] }" },
2184 { 0, "{ [a, b] : a, b >= 0 and a + 2b <= 2; [2, 1] }" },
2185 { 0, "{ [a, c] : (2 + a) mod 4 = 0 or "
2186 "(c = 4 + a and 4 * floor((a)/4) = a and a >= 0 and a <= 4) or "
2187 "(c = 3 + a and 4 * floor((-1 + a)/4) = -1 + a and "
2188 "a > 0 and a <= 5) }" },
2189 { 1, "{ [1, 0, 0]; [a, b, c] : -1 <= -a < b <= 0 and 2c > b }" },
2190 { 0, "{ [j, a, l] : a mod 2 = 0 and j <= 29 and a >= 2 and "
2191 "2a <= -5 + j and 32j + 2a + 2 <= 4l < 33j; "
2192 "[j, 0, l] : 4 <= j <= 29 and -3 + 33j <= 4l <= 33j }" },
2193 { 0, "{ [0:1, 0:1]; [0, 2:3] }" },
2194 { 1, "{ [a] : (a = 0 or ((1 + a) mod 2 = 0 and 0 < a <= 15) or "
2195 "((a) mod 2 = 0 and 0 < a <= 15)) }" },
2196 { 1, "{ rat: [0:2]; rat: [1:3] }" },
2197 { 1, "{ [a = 1:14] : a mod 4 = 0 and 4*floor((1 + a)/4) <= a; [0] }" },
2198 { 0, "{ [a = 4:6, b = 1:7, 8] : a mod 2 = 1 and b mod 2 = 1;"
2199 "[a = 1:7, 1:7, a] }" },
2200 { 1, "{ [a] : a mod 2 = 0 and (a <= 3 or a >= 12 or 4 <= a <= 11) }" },
2201 { 1, "{ [a] : 0 < a <= 341 or "
2202 "(0 < a <= 700 and 360*floor(a/360) >= -340 + a) }" },
2203 { 0, "{ [a] : 0 < a <= 341 or "
2204 "(0 < a <= 701 and 360*floor(a/360) >= -340 + a) }" },
2206
2207/* A specialized coalescing test case that would result
2208 * in a segmentation fault or a failed assertion in earlier versions of isl.
2209 */
2210static int test_coalesce_special(struct isl_ctx *ctx)
2211{
2212 const char *str;
2213 isl_map *map1, *map2;
2214
2215 str = "[y] -> { [S_L220_OUT[] -> T7[]] -> "
2216 "[[S_L309_IN[] -> T11[]] -> ce_imag2[1, o1]] : "
2217 "(y = 201 and o1 <= 239 and o1 >= 212) or "
2218 "(exists (e0 = [(y)/3]: 3e0 = y and y <= 198 and y >= 3 and "
2219 "o1 <= 239 and o1 >= 212)) or "
2220 "(exists (e0 = [(y)/3]: 3e0 = y and y <= 201 and y >= 3 and "
2221 "o1 <= 241 and o1 >= 240));"
2222 "[S_L220_OUT[] -> T7[]] -> "
2223 "[[S_L309_IN[] -> T11[]] -> ce_imag2[0, o1]] : "
2224 "(y = 2 and o1 <= 241 and o1 >= 212) or "
2225 "(exists (e0 = [(-2 + y)/3]: 3e0 = -2 + y and y <= 200 and "
2226 "y >= 5 and o1 <= 241 and o1 >= 212)) }";
2230 str = "[y] -> { [S_L220_OUT[] -> T7[]] -> "
2231 "[[S_L309_IN[] -> T11[]] -> ce_imag2[o0, o1]] : "
2232 "exists (e0 = [(-1 - y + o0)/3]: 3e0 = -1 - y + o0 and "
2233 "y <= 201 and o0 <= 2 and o1 >= 212 and o1 <= 241 and "
2234 "o0 >= 3 - y and o0 <= -2 + y and o0 >= 0) }";
2240 if (!map2)
2241 return -1;
2242
2243 return 0;
2244}
2245
2246/* Check that the union of the basic sets described by "str1" and "str2"
2247 * can be coalesced and that the result is equal to the union.
2248 * The explicit call to isl_basic_set_union prevents the implicit
2249 * equality constraints in the basic maps from being detected prior
2250 * to the call to isl_set_coalesce, at least at the point
2251 * where this function was introduced.
2252 */
2253static isl_stat test_coalesce_union(isl_ctx *ctx, const char *str1,
2254 const char *str2)
2255{
2256 isl_basic_set *bset1, *bset2;
2257 isl_set *set, *set2;
2259
2260 bset1 = isl_basic_set_read_from_str(ctx, str1);
2261 bset2 = isl_basic_set_read_from_str(ctx, str2);
2262 set = isl_basic_set_union(bset1, bset2);
2264
2265 bset1 = isl_basic_set_read_from_str(ctx, str1);
2266 bset2 = isl_basic_set_read_from_str(ctx, str2);
2267 set2 = isl_basic_set_union(bset1, bset2);
2268
2272
2273 if (equal < 0)
2274 return isl_stat_error;
2275 if (!equal)
2277 "coalesced set not equal to input",
2278 return isl_stat_error);
2279
2280 return isl_stat_non_null(set);
2281}
2282
2283/* A specialized coalescing test case that would result in an assertion
2284 * in an earlier version of isl. Use test_coalesce_union with
2285 * an explicit call to isl_basic_set_union to prevent the implicit
2286 * equality constraints in the first basic map from being detected prior
2287 * to the call to isl_set_coalesce, at least at the point
2288 * where this test case was introduced.
2289 */
2291{
2292 const char *str1;
2293 const char *str2;
2294
2295 str1 = "{ [x, y] : x, y >= 0 and x + 2y <= 1 and 2x + y <= 1 }";
2296 str2 = "{ [x,0] : -1 <= x <= 1 and x mod 2 = 1 }";
2297 return test_coalesce_union(ctx, str1, str2);
2298}
2299
2300/* Check that calling isl_set_coalesce does not leave other sets
2301 * that may share some information with the input to isl_set_coalesce
2302 * in an inconsistent state.
2303 * In particular, older versions of isl would modify all copies
2304 * of the basic sets in the isl_set_coalesce input in a way
2305 * that could leave them in an inconsistent state.
2306 * The result of printing any other set containing one of these
2307 * basic sets would then result in an invalid set description.
2308 */
2310{
2311 const char *str;
2312 char *s;
2313 isl_set *set1, *set2;
2314 isl_printer *p;
2315
2316 set1 = isl_set_read_from_str(ctx, "{ [0, 0, 0] }");
2317 str = "{ [a, b, a + b] : a >= 0 and b >= 0 and 0 < a + b }";
2322
2323 p = isl_printer_to_str(ctx);
2328 set1 = isl_set_read_from_str(ctx, s);
2329 free(s);
2331
2332 if (!set1)
2333 return -1;
2334
2335 return 0;
2336}
2337
2338/* Check that calling isl_set_coalesce on the intersection of
2339 * the sets described by "s1" and "s2" does not leave other sets
2340 * that may share some information with the input to isl_set_coalesce
2341 * in an inconsistent state.
2342 * In particular, when isl_set_coalesce detects equality constraints,
2343 * it does not immediately perform Gaussian elimination on them,
2344 * but then it needs to ensure that it is performed at some point.
2345 * The input set has implicit equality constraints in the first disjunct.
2346 * It is constructed as an intersection, because otherwise
2347 * those equality constraints would already be detected during parsing.
2348 */
2350 const char *s1, const char *s2)
2351{
2352 isl_set *set1, *set2;
2353
2354 set1 = isl_set_read_from_str(ctx, s1);
2355 set2 = isl_set_read_from_str(ctx, s2);
2360
2361 if (!set1)
2362 return isl_stat_error;
2363
2364 return isl_stat_ok;
2365}
2366
2367/* Check that calling isl_set_coalesce does not leave other sets
2368 * that may share some information with the input to isl_set_coalesce
2369 * in an inconsistent state, for the case where one disjunct
2370 * is a subset of the other.
2371 */
2373{
2374 const char *s1, *s2;
2375
2376 s1 = "{ [a, b] : b <= 0 or a <= 1 }";
2377 s2 = "{ [a, b] : -1 <= -a < b }";
2378 return test_coalesce_intersection(ctx, s1, s2);
2379}
2380
2381/* Check that calling isl_set_coalesce does not leave other sets
2382 * that may share some information with the input to isl_set_coalesce
2383 * in an inconsistent state, for the case where two disjuncts
2384 * can be fused.
2385 */
2387{
2388 const char *s1, *s2;
2389
2390 s1 = "{ [a, b, c] : b <= 0 }";
2391 s2 = "{ [a, b, c] : -1 <= -a < b and (c >= 0 or c < 0) }";
2392 return test_coalesce_intersection(ctx, s1, s2);
2393}
2394
2395/* Check that calling isl_set_coalesce does not leave other sets
2396 * that may share some information with the input to isl_set_coalesce
2397 * in an inconsistent state, for the case where two disjuncts
2398 * can be fused and where both disjuncts have implicit equality constraints.
2399 */
2401{
2402 const char *s1, *s2;
2403
2404 s1 = "{ [a, b, c] : c <= 0 }";
2405 s2 = "{ [a, b, c] : 0 <= a <= b <= c or (0 <= b <= c and a > 0) }";
2406 return test_coalesce_intersection(ctx, s1, s2);
2407}
2408
2409/* A specialized coalescing test case that would result in an assertion failure
2410 * in an earlier version of isl. Use test_coalesce_union with
2411 * an explicit call to isl_basic_set_union to prevent the implicit
2412 * equality constraints in the basic maps from being detected prior
2413 * to the call to isl_set_coalesce, at least at the point
2414 * where this test case was introduced.
2415 */
2417{
2418 const char *str1;
2419 const char *str2;
2420
2421 str1 = "{ [a, b, c=0:17] : a <= 7 and 2b <= 11 - a and "
2422 "c <= -7 + 2a and 2c >= - 3 + 3a - 2b }";
2423 str2 = "{ [a, b, c] : c > -15a and c >= -7 + 2a and c < 0 and "
2424 "3c <= -5 + 5a - 3b and 2b >= 11 - a }";
2425 return test_coalesce_union(ctx, str1, str2);
2426}
2427
2428/* A specialized coalescing test case that would result in a disjunct
2429 * getting dropped in an earlier version of isl. Use test_coalesce_union with
2430 * an explicit call to isl_basic_set_union to prevent the implicit
2431 * equality constraints in the basic maps from being detected prior
2432 * to the call to isl_set_coalesce, at least at the point
2433 * where this test case was introduced.
2434 */
2436{
2437 const char *str1;
2438 const char *str2;
2439
2440 str1 = "{ [a, b, c] : 2c <= -a and b >= -a and b <= 5 and "
2441 "6c > -7a and 11c >= -5a - b and a <= 3 }";
2442 str2 = "{ [a, b, c] : 6c > -7a and b >= -a and b <= 5 and "
2443 "11c >= -5a - b and a >= 4 and 2b <= a and 2c <= -a }";
2444 return test_coalesce_union(ctx, str1, str2);
2445}
2446
2447/* Test the functionality of isl_set_coalesce.
2448 * That is, check that the output is always equal to the input
2449 * and in some cases that the result consists of a single disjunct.
2450 */
2451static int test_coalesce(struct isl_ctx *ctx)
2452{
2453 int i;
2454
2455 for (i = 0; i < ARRAY_SIZE(coalesce_tests); ++i) {
2456 const char *str = coalesce_tests[i].str;
2457 int check_one = coalesce_tests[i].single_disjunct;
2458 if (test_coalesce_set(ctx, str, check_one) < 0)
2459 return -1;
2460 }
2461
2463 return -1;
2464 if (test_coalesce_special(ctx) < 0)
2465 return -1;
2466 if (test_coalesce_special2(ctx) < 0)
2467 return -1;
2468 if (test_coalesce_special3(ctx) < 0)
2469 return -1;
2470 if (test_coalesce_special4(ctx) < 0)
2471 return -1;
2472 if (test_coalesce_special5(ctx) < 0)
2473 return -1;
2474 if (test_coalesce_special6(ctx) < 0)
2475 return -1;
2476 if (test_coalesce_special7(ctx) < 0)
2477 return -1;
2478 if (test_coalesce_special8(ctx) < 0)
2479 return -1;
2480
2481 return 0;
2482}
2483
2484/* Construct a representation of the graph on the right of Figure 1
2485 * in "Computing the Transitive Closure of a Union of
2486 * Affine Integer Tuple Relations".
2487 */
2489{
2490 isl_set *dom;
2491 isl_map *up, *right;
2492
2493 dom = isl_set_read_from_str(ctx,
2494 "{ [x,y] : x >= 0 and -2 x + 3 y >= 0 and x <= 3 and "
2495 "2 x - 3 y + 3 >= 0 }");
2496 right = isl_map_read_from_str(ctx,
2497 "{ [x,y] -> [x2,y2] : x2 = x + 1 and y2 = y }");
2498 up = isl_map_read_from_str(ctx,
2499 "{ [x,y] -> [x2,y2] : x2 = x and y2 = y + 1 }");
2500 right = isl_map_intersect_domain(right, isl_set_copy(dom));
2501 right = isl_map_intersect_range(right, isl_set_copy(dom));
2503 up = isl_map_intersect_range(up, dom);
2504 return isl_map_union(up, right);
2505}
2506
2507/* Construct a representation of the power of the graph
2508 * on the right of Figure 1 in "Computing the Transitive Closure of
2509 * a Union of Affine Integer Tuple Relations".
2510 */
2512{
2513 return isl_map_read_from_str(ctx,
2514 "{ [1] -> [[0,0] -> [0,1]]; [2] -> [[0,0] -> [1,1]]; "
2515 " [1] -> [[0,1] -> [1,1]]; [1] -> [[2,2] -> [3,2]]; "
2516 " [2] -> [[2,2] -> [3,3]]; [1] -> [[3,2] -> [3,3]] }");
2517}
2518
2519/* Construct a representation of the transitive closure of the graph
2520 * on the right of Figure 1 in "Computing the Transitive Closure of
2521 * a Union of Affine Integer Tuple Relations".
2522 */
2527
2528static int test_closure(isl_ctx *ctx)
2529{
2530 const char *str;
2531 isl_map *map, *map2;
2532 isl_bool exact, equal;
2533
2534 /* COCOA example 1 */
2536 "[n] -> { [i,j] -> [i2,j2] : i2 = i + 1 and j2 = j + 1 and "
2537 "1 <= i and i < n and 1 <= j and j < n or "
2538 "i2 = i + 1 and j2 = j - 1 and "
2539 "1 <= i and i < n and 2 <= j and j <= n }");
2540 map = isl_map_power(map, &exact);
2541 assert(exact);
2543
2544 /* COCOA example 1 */
2546 "[n] -> { [i,j] -> [i2,j2] : i2 = i + 1 and j2 = j + 1 and "
2547 "1 <= i and i < n and 1 <= j and j < n or "
2548 "i2 = i + 1 and j2 = j - 1 and "
2549 "1 <= i and i < n and 2 <= j and j <= n }");
2551 assert(exact);
2553 "[n] -> { [i,j] -> [i2,j2] : exists (k1,k2,k : "
2554 "1 <= i and i < n and 1 <= j and j <= n and "
2555 "2 <= i2 and i2 <= n and 1 <= j2 and j2 <= n and "
2556 "i2 = i + k1 + k2 and j2 = j + k1 - k2 and "
2557 "k1 >= 0 and k2 >= 0 and k1 + k2 = k and k >= 1 )}");
2561
2563 "[n] -> { [x] -> [y] : y = x + 1 and 0 <= x and x <= n and "
2564 " 0 <= y and y <= n }");
2567 "[n] -> { [x] -> [y] : y > x and 0 <= x and x <= n and "
2568 " 0 <= y and y <= n }");
2572
2573 /* COCOA example 2 */
2575 "[n] -> { [i,j] -> [i2,j2] : i2 = i + 2 and j2 = j + 2 and "
2576 "1 <= i and i < n - 1 and 1 <= j and j < n - 1 or "
2577 "i2 = i + 2 and j2 = j - 2 and "
2578 "1 <= i and i < n - 1 and 3 <= j and j <= n }");
2580 assert(exact);
2582 "[n] -> { [i,j] -> [i2,j2] : exists (k1,k2,k : "
2583 "1 <= i and i < n - 1 and 1 <= j and j <= n and "
2584 "3 <= i2 and i2 <= n and 1 <= j2 and j2 <= n and "
2585 "i2 = i + 2 k1 + 2 k2 and j2 = j + 2 k1 - 2 k2 and "
2586 "k1 >= 0 and k2 >= 0 and k1 + k2 = k and k >= 1) }");
2590
2591 /* COCOA Fig.2 left */
2593 "[n] -> { [i,j] -> [i2,j2] : i2 = i + 2 and j2 = j and "
2594 "i <= 2 j - 3 and i <= n - 2 and j <= 2 i - 1 and "
2595 "j <= n or "
2596 "i2 = i and j2 = j + 2 and i <= 2 j - 1 and i <= n and "
2597 "j <= 2 i - 3 and j <= n - 2 or "
2598 "i2 = i + 1 and j2 = j + 1 and i <= 2 j - 1 and "
2599 "i <= n - 1 and j <= 2 i - 1 and j <= n - 1 }");
2601 assert(exact);
2603
2604 /* COCOA Fig.2 right */
2606 "[n] -> { [i,j] -> [i2,j2] : i2 = i + 3 and j2 = j and "
2607 "i <= 2 j - 4 and i <= n - 3 and j <= 2 i - 1 and "
2608 "j <= n or "
2609 "i2 = i and j2 = j + 3 and i <= 2 j - 1 and i <= n and "
2610 "j <= 2 i - 4 and j <= n - 3 or "
2611 "i2 = i + 1 and j2 = j + 1 and i <= 2 j - 1 and "
2612 "i <= n - 1 and j <= 2 i - 1 and j <= n - 1 }");
2613 map = isl_map_power(map, &exact);
2614 assert(exact);
2616
2617 /* COCOA Fig.2 right */
2619 "[n] -> { [i,j] -> [i2,j2] : i2 = i + 3 and j2 = j and "
2620 "i <= 2 j - 4 and i <= n - 3 and j <= 2 i - 1 and "
2621 "j <= n or "
2622 "i2 = i and j2 = j + 3 and i <= 2 j - 1 and i <= n and "
2623 "j <= 2 i - 4 and j <= n - 3 or "
2624 "i2 = i + 1 and j2 = j + 1 and i <= 2 j - 1 and "
2625 "i <= n - 1 and j <= 2 i - 1 and j <= n - 1 }");
2627 assert(exact);
2629 "[n] -> { [i,j] -> [i2,j2] : exists (k1,k2,k3,k : "
2630 "i <= 2 j - 1 and i <= n and j <= 2 i - 1 and "
2631 "j <= n and 3 + i + 2 j <= 3 n and "
2632 "3 + 2 i + j <= 3n and i2 <= 2 j2 -1 and i2 <= n and "
2633 "i2 <= 3 j2 - 4 and j2 <= 2 i2 -1 and j2 <= n and "
2634 "13 + 4 j2 <= 11 i2 and i2 = i + 3 k1 + k3 and "
2635 "j2 = j + 3 k2 + k3 and k1 >= 0 and k2 >= 0 and "
2636 "k3 >= 0 and k1 + k2 + k3 = k and k > 0) }");
2640
2643 assert(exact);
2648
2650 map = isl_map_power(map, &exact);
2655 if (equal < 0)
2656 return -1;
2657 if (!exact)
2658 isl_die(ctx, isl_error_unknown, "power not exact", return -1);
2659 if (!equal)
2660 isl_die(ctx, isl_error_unknown, "unexpected power", return -1);
2661
2662 /* COCOA Theorem 1 counter example */
2664 "{ [i,j] -> [i2,j2] : i = 0 and 0 <= j and j <= 1 and "
2665 "i2 = 1 and j2 = j or "
2666 "i = 0 and j = 0 and i2 = 0 and j2 = 1 }");
2668 assert(exact);
2670
2672 "[m,n] -> { [i,j] -> [i2,j2] : i2 = i and j2 = j + 2 and "
2673 "1 <= i,i2 <= n and 1 <= j,j2 <= m or "
2674 "i2 = i + 1 and 3 <= j2 - j <= 4 and "
2675 "1 <= i,i2 <= n and 1 <= j,j2 <= m }");
2677 assert(exact);
2679
2680 /* Kelly et al 1996, fig 12 */
2682 "[n] -> { [i,j] -> [i2,j2] : i2 = i and j2 = j + 1 and "
2683 "1 <= i,j,j+1 <= n or "
2684 "j = n and j2 = 1 and i2 = i + 1 and "
2685 "1 <= i,i+1 <= n }");
2687 assert(exact);
2689 "[n] -> { [i,j] -> [i2,j2] : 1 <= j < j2 <= n and "
2690 "1 <= i <= n and i = i2 or "
2691 "1 <= i < i2 <= n and 1 <= j <= n and "
2692 "1 <= j2 <= n }");
2696
2697 /* Omega's closure4 */
2699 "[m,n] -> { [x,y] -> [x2,y2] : x2 = x and y2 = y + 1 and "
2700 "1 <= x,y <= 10 or "
2701 "x2 = x + 1 and y2 = y and "
2702 "1 <= x <= 20 && 5 <= y <= 15 }");
2704 assert(exact);
2706
2708 "[n] -> { [x] -> [y]: 1 <= n <= y - x <= 10 }");
2710 assert(!exact);
2712 "[n] -> { [x] -> [y] : 1 <= n <= 10 and y >= n + x }");
2716
2717 str = "[n, m] -> { [i0, i1, i2, i3] -> [o0, o1, o2, o3] : "
2718 "i3 = 1 and o0 = i0 and o1 = -1 + i1 and o2 = -1 + i2 and "
2719 "o3 = -2 + i2 and i1 <= -1 + i0 and i1 >= 1 - m + i0 and "
2720 "i1 >= 2 and i1 <= n and i2 >= 3 and i2 <= 1 + n and i2 <= m }";
2723 assert(exact);
2728
2729 str = "{[0] -> [1]; [2] -> [3]}";
2732 assert(exact);
2737
2738 str = "[n] -> { [[i0, i1, 1, 0, i0] -> [i5, 1]] -> "
2739 "[[i0, -1 + i1, 2, 0, i0] -> [-1 + i5, 2]] : "
2740 "exists (e0 = [(3 - n)/3]: i5 >= 2 and i1 >= 2 and "
2741 "3i0 <= -1 + n and i1 <= -1 + n and i5 <= -1 + n and "
2742 "3e0 >= 1 - n and 3e0 <= 2 - n and 3i0 >= -2 + n); "
2743 "[[i0, i1, 2, 0, i0] -> [i5, 1]] -> "
2744 "[[i0, i1, 1, 0, i0] -> [-1 + i5, 2]] : "
2745 "exists (e0 = [(3 - n)/3]: i5 >= 2 and i1 >= 1 and "
2746 "3i0 <= -1 + n and i1 <= -1 + n and i5 <= -1 + n and "
2747 "3e0 >= 1 - n and 3e0 <= 2 - n and 3i0 >= -2 + n); "
2748 "[[i0, i1, 1, 0, i0] -> [i5, 2]] -> "
2749 "[[i0, -1 + i1, 2, 0, i0] -> [i5, 1]] : "
2750 "exists (e0 = [(3 - n)/3]: i1 >= 2 and i5 >= 1 and "
2751 "3i0 <= -1 + n and i1 <= -1 + n and i5 <= -1 + n and "
2752 "3e0 >= 1 - n and 3e0 <= 2 - n and 3i0 >= -2 + n); "
2753 "[[i0, i1, 2, 0, i0] -> [i5, 2]] -> "
2754 "[[i0, i1, 1, 0, i0] -> [i5, 1]] : "
2755 "exists (e0 = [(3 - n)/3]: i5 >= 1 and i1 >= 1 and "
2756 "3i0 <= -1 + n and i1 <= -1 + n and i5 <= -1 + n and "
2757 "3e0 >= 1 - n and 3e0 <= 2 - n and 3i0 >= -2 + n) }";
2760 assert(map);
2762
2763 return 0;
2764}
2765
2766/* Check that the actual result of a boolean operation is equal
2767 * to the expected result.
2768 */
2770{
2771 if (actual != expected)
2773 "incorrect boolean operation", return isl_stat_error);
2774 return isl_stat_ok;
2775}
2776
2777/* Test operations on isl_bool values.
2778 *
2779 * This tests:
2780 *
2781 * isl_bool_not
2782 * isl_bool_ok
2783 */
2784static int test_isl_bool(isl_ctx *ctx)
2785{
2787 return -1;
2789 return -1;
2791 return -1;
2792 if (check_bool(ctx, isl_bool_ok(0), isl_bool_false) < 0)
2793 return -1;
2794 if (check_bool(ctx, isl_bool_ok(1), isl_bool_true) < 0)
2795 return -1;
2796 if (check_bool(ctx, isl_bool_ok(-1), isl_bool_true) < 0)
2797 return -1;
2798 if (check_bool(ctx, isl_bool_ok(2), isl_bool_true) < 0)
2799 return -1;
2800 if (check_bool(ctx, isl_bool_ok(-2), isl_bool_true) < 0)
2801 return -1;
2802
2803 return 0;
2804}
2805
2806static int test_lex(struct isl_ctx *ctx)
2807{
2808 isl_space *space;
2809 isl_map *map;
2810 int empty;
2811
2812 space = isl_space_set_alloc(ctx, 0, 0);
2813 map = isl_map_lex_le(space);
2814 empty = isl_map_is_empty(map);
2816
2817 if (empty < 0)
2818 return -1;
2819 if (empty)
2821 "expecting non-empty result", return -1);
2822
2823 return 0;
2824}
2825
2826/* Inputs for isl_map_lexmin tests.
2827 * "map" is the input and "lexmin" is the expected result.
2828 */
2829struct {
2830 const char *map;
2831 const char *lexmin;
2832} lexmin_tests [] = {
2833 { "{ [x] -> [y] : x <= y <= 10; [x] -> [5] : -8 <= x <= 8 }",
2834 "{ [x] -> [5] : 6 <= x <= 8; "
2835 "[x] -> [x] : x <= 5 or (9 <= x <= 10) }" },
2836 { "{ [x] -> [y] : 4y = x or 4y = -1 + x or 4y = -2 + x }",
2837 "{ [x] -> [y] : 4y = x or 4y = -1 + x or 4y = -2 + x }" },
2838 { "{ [x] -> [y] : x = 4y; [x] -> [y] : x = 2y }",
2839 "{ [x] -> [y] : (4y = x and x >= 0) or "
2840 "(exists (e0 = [(x)/4], e1 = [(-2 + x)/4]: 2y = x and "
2841 "4e1 = -2 + x and 4e0 <= -1 + x and 4e0 >= -3 + x)) or "
2842 "(exists (e0 = [(x)/4]: 2y = x and 4e0 = x and x <= -4)) }" },
2843 { "{ T[a] -> S[b, c] : a = 4b-2c and c >= b }",
2844 "{ T[a] -> S[b, c] : 2b = a and 2c = a }" },
2845 /* Check that empty pieces are properly combined. */
2846 { "[K, N] -> { [x, y] -> [a, b] : K+2<=N<=K+4 and x>=4 and "
2847 "2N-6<=x<K+N and N-1<=a<=K+N-1 and N+b-6<=a<=2N-4 and "
2848 "b<=2N-3K+a and 3b<=4N-K+1 and b>=N and a>=x+1 }",
2849 "[K, N] -> { [x, y] -> [1 + x, N] : x >= -6 + 2N and "
2850 "x <= -5 + 2N and x >= -1 + 3K - N and x <= -2 + K + N and "
2851 "x >= 4 }" },
2852 { "{ [i, k, j] -> [a, b, c, d] : 8*floor((b)/8) = b and k <= 255 and "
2853 "a <= 255 and c <= 255 and d <= 255 - j and "
2854 "255 - j <= 7d <= 7 - i and 240d <= 239 + a and "
2855 "247d <= 247 + k - j and 247d <= 247 + k - b and "
2856 "247d <= 247 + i and 248 - b <= 248d <= c and "
2857 "254d >= i - a + b and 254d >= -a + b and "
2858 "255d >= -i + a - b and 1792d >= -63736 + 257b }",
2859 "{ [i, k, j] -> "
2860 "[-127762 + i + 502j, -62992 + 248j, 63240 - 248j, 255 - j] : "
2861 "k <= 255 and 7j >= 1778 + i and 246j >= 62738 - k and "
2862 "247j >= 62738 - i and 509j <= 129795 + i and "
2863 "742j >= 188724 - i; "
2864 "[0, k, j] -> [1, 0, 248, 1] : k <= 255 and 248 <= j <= 254, k }" },
2865 { "{ [a] -> [b] : 0 <= b <= 255 and -509 + a <= 512b < a and "
2866 "16*floor((8 + b)/16) <= 7 + b; "
2867 "[a] -> [1] }",
2868 "{ [a] -> [b = 1] : a >= 510 or a <= 0; "
2869 "[a] -> [b = 0] : 0 < a <= 509 }" },
2870 { "{ rat: [i] : 1 <= 2i <= 9 }", "{ rat: [i] : 2i = 1 }" },
2871 { "{ rat: [i] : 1 <= 2i <= 9 or i >= 10 }", "{ rat: [i] : 2i = 1 }" },
2872 { "{ rat: [i] : 21 <= 2i <= 29 or i = 5 }", "{ rat: [5] }" },
2874
2875static int test_lexmin(struct isl_ctx *ctx)
2876{
2877 int i;
2878 int equal;
2879 const char *str;
2880 isl_basic_map *bmap;
2881 isl_map *map, *map2;
2882 isl_set *set;
2883 isl_set *set2;
2885
2886 str = "[p0, p1] -> { [] -> [] : "
2887 "exists (e0 = [(2p1)/3], e1, e2, e3 = [(3 - p1 + 3e0)/3], "
2888 "e4 = [(p1)/3], e5 = [(p1 + 3e4)/3]: "
2889 "3e0 >= -2 + 2p1 and 3e0 >= p1 and 3e3 >= 1 - p1 + 3e0 and "
2890 "3e0 <= 2p1 and 3e3 >= -2 + p1 and 3e3 <= -1 + p1 and p1 >= 3 and "
2891 "3e5 >= -2 + 2p1 and 3e5 >= p1 and 3e5 <= -1 + p1 + 3e4 and "
2892 "3e4 <= p1 and 3e4 >= -2 + p1 and e3 <= -1 + e0 and "
2893 "3e4 >= 6 - p1 + 3e1 and 3e1 >= p1 and 3e5 >= -2 + p1 + 3e4 and "
2894 "2e4 >= 3 - p1 + 2e1 and e4 <= e1 and 3e3 <= 2 - p1 + 3e0 and "
2895 "e5 >= 1 + e1 and 3e4 >= 6 - 2p1 + 3e1 and "
2896 "p0 >= 2 and p1 >= p0 and 3e2 >= p1 and 3e4 >= 6 - p1 + 3e2 and "
2897 "e2 <= e1 and e3 >= 1 and e4 <= e2) }";
2901 if (!map)
2902 return -1;
2903
2904 str = "[C] -> { [obj,a,b,c] : obj <= 38 a + 7 b + 10 c and "
2905 "a + b <= 1 and c <= 10 b and c <= C and a,b,c,C >= 0 }";
2908 str = "[C] -> { [obj,a,b,c] : C = 8 }";
2913
2914 for (i = 0; i < ARRAY_SIZE(lexmin_tests); ++i) {
2921
2922 if (equal < 0)
2923 return -1;
2924 if (!equal)
2926 "unexpected result", return -1);
2927 }
2928
2929 str = "{ [i] -> [i', j] : j = i - 8i' and i' >= 0 and i' <= 7 and "
2930 " 8i' <= i and 8i' >= -7 + i }";
2931 bmap = isl_basic_map_read_from_str(ctx, str);
2938
2939 str = "[i] -> { [i', j] : j = i - 8i' and i' >= 0 and i' <= 7 and "
2940 " 8i' <= i and 8i' >= -7 + i }";
2947 if (equal < 0)
2948 return -1;
2949 if (!equal)
2951 "unexpected difference between set and "
2952 "piecewise affine expression", return -1);
2953
2954 return 0;
2955}
2956
2957/* Inputs for isl_pw_multi_aff_max_multi_val tests.
2958 * "pma" is the input.
2959 * "res" is the expected result.
2960 */
2961static struct {
2962 const char *pma;
2963 const char *res;
2964} opt_pw_tests[] = {
2965 { "{ [-1] -> [-1]; [1] -> [1] }", "{ [1] }" },
2966 { "{ [a, b] -> [floor((b - 2*floor((-a)/4))/5)] : "
2967 "0 <= a, b <= 100 and b mod 2 = 0}", "{ [30] }" },
2968 { "[N] -> { [i,j] -> A[i, -i, i + j] : 0 <= i,j <= N <= 10 }",
2969 "{ A[10, 0, 20] }" },
2970 { "[N] -> {A[N, -N, 2N] : 0 <= N }", "{ A[infty, 0, infty] }" },
2972
2973/* Perform basic isl_pw_multi_aff_max_multi_val tests.
2974 */
2975static isl_stat test_pw_max(struct isl_ctx *ctx)
2976{
2977 int i;
2979 isl_multi_val *mv;
2980 isl_stat r;
2981
2982 for (i = 0; i < ARRAY_SIZE(opt_pw_tests); ++i) {
2985 r = multi_val_check_plain_equal(mv, opt_pw_tests[i].res);
2986 isl_multi_val_free(mv);
2987
2988 if (r < 0)
2989 return isl_stat_error;
2990 }
2991
2992 return isl_stat_ok;
2993}
2994
2995/* A specialized isl_set_min_val test case that would return the wrong result
2996 * in earlier versions of isl.
2997 * The explicit call to isl_basic_set_union prevents the second basic set
2998 * from being determined to be empty prior to the call to isl_set_min_val,
2999 * at least at the point where this test case was introduced.
3000 */
3002{
3003 const char *str;
3004 isl_basic_set *bset1, *bset2;
3005 isl_set *set;
3006 isl_aff *obj;
3007 isl_val *res;
3008 int ok;
3009
3010 str = "{ [a, b] : a >= 2 and b >= 0 and 14 - a <= b <= 9 }";
3011 bset1 = isl_basic_set_read_from_str(ctx, str);
3012 str = "{ [a, b] : 1 <= a, b and a + b <= 1 }";
3013 bset2 = isl_basic_set_read_from_str(ctx, str);
3014 set = isl_basic_set_union(bset1, bset2);
3015 obj = isl_aff_read_from_str(ctx, "{ [a, b] -> [a] }");
3016
3018 ok = isl_val_cmp_si(res, 5) == 0;
3019
3023
3024 if (!res)
3025 return -1;
3026 if (!ok)
3027 isl_die(ctx, isl_error_unknown, "unexpected minimum",
3028 return -1);
3029
3030 return 0;
3031}
3032
3033/* A specialized isl_set_min_val test case that would return an error
3034 * in earlier versions of isl.
3035 */
3037{
3038 const char *str;
3039 isl_basic_set *bset;
3040 isl_aff *obj;
3041 isl_val *res;
3042
3043 str = "{ [i, j, k] : 2j = i and 2k = i + 1 and i >= 2 }";
3044 bset = isl_basic_set_read_from_str(ctx, str);
3045
3046 obj = isl_aff_read_from_str(ctx, "{ [i, j, k] -> [i] }");
3047
3048 res = isl_basic_set_max_val(bset, obj);
3049
3050 isl_basic_set_free(bset);
3053
3054 if (!res)
3055 return -1;
3056
3057 return 0;
3058}
3059
3060/* Check that the result of isl_set_min_multi_pw_aff
3061 * on the union of the sets with string descriptions "s1" and "s2"
3062 * consists of a single expression (on a single cell).
3063 */
3064static isl_stat check_single_expr_min(isl_ctx *ctx, const char *s1,
3065 const char *s2)
3066{
3067 isl_size n;
3068 isl_set *set1, *set2;
3069 isl_multi_pw_aff *mpa;
3071
3072 set1 = isl_set_read_from_str(ctx, s1);
3073 set2 = isl_set_read_from_str(ctx, s2);
3079
3080 if (n < 0)
3081 return isl_stat_error;
3082 if (n != 1)
3083 isl_die(ctx, isl_error_unknown, "expecting single expression",
3084 return isl_stat_error);
3085 return isl_stat_ok;
3086}
3087
3088/* A specialized isl_set_min_multi_pw_aff test that checks
3089 * that the minimum of 2N and 3N for N >= 0 is represented
3090 * by a single expression, without splitting off the special case N = 0.
3091 * Do this for both orderings.
3092 */
3093static int test_min_mpa(isl_ctx *ctx)
3094{
3095 const char *s1, *s2;
3096
3097 s1 = "[N=0:] -> { [1, 3N:] }";
3098 s2 = "[N=0:] -> { [10, 2N:] }";
3099 if (check_single_expr_min(ctx, s1, s2) < 0)
3100 return -1;
3101 if (check_single_expr_min(ctx, s2, s1) < 0)
3102 return -1;
3103
3104 return 0;
3105}
3106
3107struct {
3108 const char *set;
3109 const char *obj;
3112 const char *res;
3113} opt_tests[] = {
3114 { "{ [-1]; [1] }", "{ [x] -> [x] }", &isl_set_min_val, "-1" },
3115 { "{ [-1]; [1] }", "{ [x] -> [x] }", &isl_set_max_val, "1" },
3116 { "{ [a, b] : 0 <= a, b <= 100 and b mod 2 = 0}",
3117 "{ [a, b] -> [floor((b - 2*floor((-a)/4))/5)] }",
3118 &isl_set_max_val, "30" },
3119
3121
3122/* Perform basic isl_set_min_val and isl_set_max_val tests.
3123 * In particular, check the results on non-convex inputs.
3124 */
3125static int test_min(struct isl_ctx *ctx)
3126{
3127 int i;
3128 isl_set *set;
3129 isl_aff *obj;
3130 isl_val *val, *res;
3131 isl_bool ok;
3132
3133 for (i = 0; i < ARRAY_SIZE(opt_tests); ++i) {
3137 val = opt_tests[i].fn(set, obj);
3138 ok = isl_val_eq(res, val);
3143
3144 if (ok < 0)
3145 return -1;
3146 if (!ok)
3148 "unexpected optimum", return -1);
3149 }
3150
3151 if (test_pw_max(ctx) < 0)
3152 return -1;
3153 if (test_min_special(ctx) < 0)
3154 return -1;
3155 if (test_min_special2(ctx) < 0)
3156 return -1;
3157
3158 return 0;
3159}
3160
3165
3167 void *dep_user, void *user)
3168{
3169 struct must_may *mm = (struct must_may *)user;
3170
3171 if (must)
3172 mm->must = isl_map_union(mm->must, dep);
3173 else
3174 mm->may = isl_map_union(mm->may, dep);
3175
3176 return isl_stat_ok;
3177}
3178
3179static int common_space(void *first, void *second)
3180{
3181 int depth = *(int *)first;
3182 return 2 * depth;
3183}
3184
3185static int map_is_equal(__isl_keep isl_map *map, const char *str)
3186{
3187 isl_map *map2;
3188 int equal;
3189
3190 if (!map)
3191 return -1;
3192
3196
3197 return equal;
3198}
3199
3200static int map_check_equal(__isl_keep isl_map *map, const char *str)
3201{
3202 int equal;
3203
3205 if (equal < 0)
3206 return -1;
3207 if (!equal)
3209 "result not as expected", return -1);
3210 return 0;
3211}
3212
3213/* Is "set" equal to the set described by "str"?
3214 */
3216{
3217 isl_set *set2;
3219
3220 if (!set)
3221 return isl_bool_error;
3222
3226
3227 return equal;
3228}
3229
3230/* Check that "set" is equal to the set described by "str".
3231 */
3233{
3235
3237 if (equal < 0)
3238 return isl_stat_error;
3239 if (!equal)
3241 "result not as expected", return isl_stat_error);
3242 return isl_stat_ok;
3243}
3244
3245/* Is "uset" equal to the union set described by "str"?
3246 */
3248{
3249 isl_union_set *uset2;
3251
3252 if (!uset)
3253 return isl_bool_error;
3254
3256 equal = isl_union_set_is_equal(uset, uset2);
3257 isl_union_set_free(uset2);
3258
3259 return equal;
3260}
3261
3262/* Check that "uset" is equal to the union set described by "str".
3263 */
3265 const char *str)
3266{
3268
3269 equal = uset_is_equal(uset, str);
3270 if (equal < 0)
3271 return isl_stat_error;
3272 if (!equal)
3274 "result not as expected", return isl_stat_error);
3275 return isl_stat_ok;
3276}
3277
3278static int test_dep(struct isl_ctx *ctx)
3279{
3280 const char *str;
3281 isl_space *space;
3282 isl_map *map;
3283 isl_access_info *ai;
3284 isl_flow *flow;
3285 int depth;
3286 struct must_may mm;
3287
3288 depth = 3;
3289
3290 str = "{ [2,i,0] -> [i] : 0 <= i <= 10 }";
3292 ai = isl_access_info_alloc(map, &depth, &common_space, 2);
3293
3294 str = "{ [0,i,0] -> [i] : 0 <= i <= 10 }";
3296 ai = isl_access_info_add_source(ai, map, 1, &depth);
3297
3298 str = "{ [1,i,0] -> [5] : 0 <= i <= 10 }";
3300 ai = isl_access_info_add_source(ai, map, 1, &depth);
3301
3303 space = isl_space_alloc(ctx, 0, 3, 3);
3304 mm.must = isl_map_empty(isl_space_copy(space));
3305 mm.may = isl_map_empty(space);
3306
3308
3309 str = "{ [0,i,0] -> [2,i,0] : (0 <= i <= 4) or (6 <= i <= 10); "
3310 " [1,10,0] -> [2,5,0] }";
3312 str = "{ [i,j,k] -> [l,m,n] : 1 = 0 }";
3313 assert(map_is_equal(mm.may, str));
3314
3315 isl_map_free(mm.must);
3316 isl_map_free(mm.may);
3318
3319
3320 str = "{ [2,i,0] -> [i] : 0 <= i <= 10 }";
3322 ai = isl_access_info_alloc(map, &depth, &common_space, 2);
3323
3324 str = "{ [0,i,0] -> [i] : 0 <= i <= 10 }";
3326 ai = isl_access_info_add_source(ai, map, 1, &depth);
3327
3328 str = "{ [1,i,0] -> [5] : 0 <= i <= 10 }";
3330 ai = isl_access_info_add_source(ai, map, 0, &depth);
3331
3333 space = isl_space_alloc(ctx, 0, 3, 3);
3334 mm.must = isl_map_empty(isl_space_copy(space));
3335 mm.may = isl_map_empty(space);
3336
3338
3339 str = "{ [0,i,0] -> [2,i,0] : (0 <= i <= 4) or (6 <= i <= 10) }";
3341 str = "{ [0,5,0] -> [2,5,0]; [1,i,0] -> [2,5,0] : 0 <= i <= 10 }";
3342 assert(map_is_equal(mm.may, str));
3343
3344 isl_map_free(mm.must);
3345 isl_map_free(mm.may);
3347
3348
3349 str = "{ [2,i,0] -> [i] : 0 <= i <= 10 }";
3351 ai = isl_access_info_alloc(map, &depth, &common_space, 2);
3352
3353 str = "{ [0,i,0] -> [i] : 0 <= i <= 10 }";
3355 ai = isl_access_info_add_source(ai, map, 0, &depth);
3356
3357 str = "{ [1,i,0] -> [5] : 0 <= i <= 10 }";
3359 ai = isl_access_info_add_source(ai, map, 0, &depth);
3360
3362 space = isl_space_alloc(ctx, 0, 3, 3);
3363 mm.must = isl_map_empty(isl_space_copy(space));
3364 mm.may = isl_map_empty(space);
3365
3367
3368 str = "{ [0,i,0] -> [2,i,0] : 0 <= i <= 10; "
3369 " [1,i,0] -> [2,5,0] : 0 <= i <= 10 }";
3370 assert(map_is_equal(mm.may, str));
3371 str = "{ [i,j,k] -> [l,m,n] : 1 = 0 }";
3373
3374 isl_map_free(mm.must);
3375 isl_map_free(mm.may);
3377
3378
3379 str = "{ [0,i,2] -> [i] : 0 <= i <= 10 }";
3381 ai = isl_access_info_alloc(map, &depth, &common_space, 2);
3382
3383 str = "{ [0,i,0] -> [i] : 0 <= i <= 10 }";
3385 ai = isl_access_info_add_source(ai, map, 0, &depth);
3386
3387 str = "{ [0,i,1] -> [5] : 0 <= i <= 10 }";
3389 ai = isl_access_info_add_source(ai, map, 0, &depth);
3390
3392 space = isl_space_alloc(ctx, 0, 3, 3);
3393 mm.must = isl_map_empty(isl_space_copy(space));
3394 mm.may = isl_map_empty(space);
3395
3397
3398 str = "{ [0,i,0] -> [0,i,2] : 0 <= i <= 10; "
3399 " [0,i,1] -> [0,5,2] : 0 <= i <= 5 }";
3400 assert(map_is_equal(mm.may, str));
3401 str = "{ [i,j,k] -> [l,m,n] : 1 = 0 }";
3403
3404 isl_map_free(mm.must);
3405 isl_map_free(mm.may);
3407
3408
3409 str = "{ [0,i,1] -> [i] : 0 <= i <= 10 }";
3411 ai = isl_access_info_alloc(map, &depth, &common_space, 2);
3412
3413 str = "{ [0,i,0] -> [i] : 0 <= i <= 10 }";
3415 ai = isl_access_info_add_source(ai, map, 0, &depth);
3416
3417 str = "{ [0,i,2] -> [5] : 0 <= i <= 10 }";
3419 ai = isl_access_info_add_source(ai, map, 0, &depth);
3420
3422 space = isl_space_alloc(ctx, 0, 3, 3);
3423 mm.must = isl_map_empty(isl_space_copy(space));
3424 mm.may = isl_map_empty(space);
3425
3427
3428 str = "{ [0,i,0] -> [0,i,1] : 0 <= i <= 10; "
3429 " [0,i,2] -> [0,5,1] : 0 <= i <= 4 }";
3430 assert(map_is_equal(mm.may, str));
3431 str = "{ [i,j,k] -> [l,m,n] : 1 = 0 }";
3433
3434 isl_map_free(mm.must);
3435 isl_map_free(mm.may);
3437
3438
3439 depth = 5;
3440
3441 str = "{ [1,i,0,0,0] -> [i,j] : 0 <= i <= 10 and 0 <= j <= 10 }";
3443 ai = isl_access_info_alloc(map, &depth, &common_space, 1);
3444
3445 str = "{ [0,i,0,j,0] -> [i,j] : 0 <= i <= 10 and 0 <= j <= 10 }";
3447 ai = isl_access_info_add_source(ai, map, 1, &depth);
3448
3450 space = isl_space_alloc(ctx, 0, 5, 5);
3451 mm.must = isl_map_empty(isl_space_copy(space));
3452 mm.may = isl_map_empty(space);
3453
3455
3456 str = "{ [0,i,0,j,0] -> [1,i,0,0,0] : 0 <= i,j <= 10 }";
3458 str = "{ [0,0,0,0,0] -> [0,0,0,0,0] : 1 = 0 }";
3459 assert(map_is_equal(mm.may, str));
3460
3461 isl_map_free(mm.must);
3462 isl_map_free(mm.may);
3464
3465 return 0;
3466}
3467
3468/* Check that the dependence analysis proceeds without errors.
3469 * Earlier versions of isl would break down during the analysis
3470 * due to the use of the wrong spaces.
3471 */
3472static int test_flow(isl_ctx *ctx)
3473{
3474 const char *str;
3475 isl_union_map *access, *schedule;
3476 isl_union_map *must_dep, *may_dep;
3477 int r;
3478
3479 str = "{ S0[j] -> i[]; S1[j,i] -> i[]; S2[] -> i[]; S3[] -> i[] }";
3480 access = isl_union_map_read_from_str(ctx, str);
3481 str = "{ S0[j] -> [0,j,0,0] : 0 <= j < 10; "
3482 "S1[j,i] -> [0,j,1,i] : 0 <= j < i < 10; "
3483 "S2[] -> [1,0,0,0]; "
3484 "S3[] -> [-1,0,0,0] }";
3488 &must_dep, &may_dep, NULL, NULL);
3489 isl_union_map_free(may_dep);
3490 isl_union_map_free(must_dep);
3491
3492 return r;
3493}
3494
3495struct {
3496 const char *map;
3497 int sv;
3498} sv_tests[] = {
3499 { "[N] -> { [i] -> [f] : 0 <= i <= N and 0 <= i - 10 f <= 9 }", 1 },
3500 { "[N] -> { [i] -> [f] : 0 <= i <= N and 0 <= i - 10 f <= 10 }", 0 },
3501 { "{ [i] -> [3*floor(i/2) + 5*floor(i/3)] }", 1 },
3502 { "{ S1[i] -> [i] : 0 <= i <= 9; S2[i] -> [i] : 0 <= i <= 9 }", 1 },
3503 { "{ [i] -> S1[i] : 0 <= i <= 9; [i] -> S2[i] : 0 <= i <= 9 }", 0 },
3504 { "{ A[i] -> [i]; B[i] -> [i]; B[i] -> [i + 1] }", 0 },
3505 { "{ A[i] -> [i]; B[i] -> [i] : i < 0; B[i] -> [i + 1] : i > 0 }", 1 },
3506 { "{ A[i] -> [i]; B[i] -> A[i] : i < 0; B[i] -> [i + 1] : i > 0 }", 1 },
3507 { "{ A[i] -> [i]; B[i] -> [j] : i - 1 <= j <= i }", 0 },
3509
3511{
3512 isl_union_map *umap;
3513 int i;
3514 int sv;
3515
3516 for (i = 0; i < ARRAY_SIZE(sv_tests); ++i) {
3519 isl_union_map_free(umap);
3520 if (sv < 0)
3521 return -1;
3522 if (sv_tests[i].sv && !sv)
3524 "map not detected as single valued", return -1);
3525 if (!sv_tests[i].sv && sv)
3527 "map detected as single valued", return -1);
3528 }
3529
3530 return 0;
3531}
3532
3533struct {
3534 const char *str;
3536} bijective_tests[] = {
3537 { "[N,M]->{[i,j] -> [i]}", 0 },
3538 { "[N,M]->{[i,j] -> [i] : j=i}", 1 },
3539 { "[N,M]->{[i,j] -> [i] : j=0}", 1 },
3540 { "[N,M]->{[i,j] -> [i] : j=N}", 1 },
3541 { "[N,M]->{[i,j] -> [j,i]}", 1 },
3542 { "[N,M]->{[i,j] -> [i+j]}", 0 },
3543 { "[N,M]->{[i,j] -> []}", 0 },
3544 { "[N,M]->{[i,j] -> [i,j,N]}", 1 },
3545 { "[N,M]->{[i,j] -> [2i]}", 0 },
3546 { "[N,M]->{[i,j] -> [i,i]}", 0 },
3547 { "[N,M]->{[i,j] -> [2i,i]}", 0 },
3548 { "[N,M]->{[i,j] -> [2i,j]}", 1 },
3549 { "[N,M]->{[i,j] -> [x,y] : 2x=i & y =j}", 1 },
3551
3552static int test_bijective(struct isl_ctx *ctx)
3553{
3554 isl_map *map;
3555 int i;
3556 int bijective;
3557
3558 for (i = 0; i < ARRAY_SIZE(bijective_tests); ++i) {
3562 if (bijective < 0)
3563 return -1;
3566 "map not detected as bijective", return -1);
3569 "map detected as bijective", return -1);
3570 }
3571
3572 return 0;
3573}
3574
3575/* Inputs for isl_pw_qpolynomial_gist tests.
3576 * "pwqp" is the input, "set" is the context and "gist" is the expected result.
3577 */
3578struct {
3579 const char *pwqp;
3580 const char *set;
3581 const char *gist;
3582} pwqp_gist_tests[] = {
3583 { "{ [i] -> i }", "{ [k] : exists a : k = 2a }", "{ [i] -> i }" },
3584 { "{ [i] -> i + [ (i + [i/3])/2 ] }", "{ [10] }", "{ [i] -> 16 }" },
3585 { "{ [i] -> ([(i)/2]) }", "{ [k] : exists a : k = 2a+1 }",
3586 "{ [i] -> -1/2 + 1/2 * i }" },
3587 { "{ [i] -> i^2 : i != 0 }", "{ [i] : i != 0 }", "{ [i] -> i^2 }" },
3588 { "{ [i] -> i^2 : i > 0; [i] -> i^2 : i < 0 }", "{ [i] : i != 0 }",
3589 "{ [i] -> i^2 }" },
3591
3592/* Perform some basic isl_pw_qpolynomial_gist tests.
3593 */
3595{
3596 int i;
3597 const char *str;
3598 isl_set *set;
3599 isl_pw_qpolynomial *pwqp1, *pwqp2;
3601
3602 for (i = 0; i < ARRAY_SIZE(pwqp_gist_tests); ++i) {
3603 str = pwqp_gist_tests[i].pwqp;
3605 str = pwqp_gist_tests[i].set;
3607 pwqp1 = isl_pw_qpolynomial_gist(pwqp1, set);
3608 str = pwqp_gist_tests[i].gist;
3610 pwqp1 = isl_pw_qpolynomial_sub(pwqp1, pwqp2);
3613
3614 if (equal < 0)
3615 return isl_stat_error;
3616 if (!equal)
3618 "unexpected result", return isl_stat_error);
3619 }
3620
3621 return isl_stat_ok;
3622}
3623
3624/* Perform a basic isl_pw_qpolynomial_max test.
3625 */
3627{
3628 const char *str;
3630 isl_val *v;
3631 int ok;
3632
3633 str = "{ [x=2:9, y] -> floor((x + 1)/4)^3 - floor((2x)/3)^2 }";
3636 ok = isl_val_cmp_si(v, -1) == 0;
3637 isl_val_free(v);
3638
3639 if (!v)
3640 return isl_stat_error;
3641 if (!ok)
3642 isl_die(ctx, isl_error_unknown, "unexpected maximum",
3643 return isl_stat_error);
3644
3645 return isl_stat_ok;
3646}
3647
3648static int test_pwqp(struct isl_ctx *ctx)
3649{
3650 const char *str;
3651 isl_set *set;
3652 isl_pw_qpolynomial *pwqp1, *pwqp2;
3653 int equal;
3654
3655 str = "{ [i,j,k] -> 1 + 9 * [i/5] + 7 * [j/11] + 4 * [k/13] }";
3657
3659 isl_dim_in, 1, 1);
3660
3661 str = "[j] -> { [i,k] -> 1 + 9 * [i/5] + 7 * [j/11] + 4 * [k/13] }";
3663
3664 pwqp1 = isl_pw_qpolynomial_sub(pwqp1, pwqp2);
3665
3667
3669
3670 if (test_pwqp_gist(ctx) < 0)
3671 return -1;
3672
3673 str = "{ [i] -> ([([i/2] + [i/2])/5]) }";
3675 str = "{ [i] -> ([(2 * [i/2])/5]) }";
3677
3678 pwqp1 = isl_pw_qpolynomial_sub(pwqp1, pwqp2);
3679
3681
3683
3684 str = "{ [x] -> ([x/2] + [(x+1)/2]) }";
3686 str = "{ [x] -> x }";
3688
3689 pwqp1 = isl_pw_qpolynomial_sub(pwqp1, pwqp2);
3690
3692
3694
3695 str = "{ [i] -> ([i/2]) : i >= 0; [i] -> ([i/3]) : i < 0 }";
3698 pwqp1 = isl_pw_qpolynomial_coalesce(pwqp1);
3699 pwqp1 = isl_pw_qpolynomial_sub(pwqp1, pwqp2);
3702
3703 str = "{ [a,b,a] -> (([(2*[a/3]+b)/5]) * ([(2*[a/3]+b)/5])) }";
3705 str = "{ [a,b,c] -> (([(2*[a/3]+b)/5]) * ([(2*[c/3]+b)/5])) }";
3707 set = isl_set_read_from_str(ctx, "{ [a,b,a] }");
3712 if (equal < 0)
3713 return -1;
3714 if (!equal)
3715 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
3716
3717 str = "{ [a,b,c] -> (([(2*[a/3]+1)/5]) * ([(2*[c/3]+1)/5])) : b = 1 }";
3719 str = "{ [a,b,c] -> (([(2*[a/3]+b)/5]) * ([(2*[c/3]+b)/5])) }";
3721 pwqp1 = isl_pw_qpolynomial_fix_val(pwqp1, isl_dim_set, 1,
3722 isl_val_one(ctx));
3726 if (equal < 0)
3727 return -1;
3728 if (!equal)
3729 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
3730
3731 if (test_pwqp_max(ctx) < 0)
3732 return -1;
3733
3734 return 0;
3735}
3736
3738{
3739 const char *str;
3741
3742 str = "{ [U,V] -> 1/3 * U + 2/3 * V - [(U + 2V)/3] + [U/2] : "
3743 "U + 2V + 3 >= 0 and - U -2V >= 0 and - U + 10 >= 0 and "
3744 "U >= 0; [U,V] -> U^2 : U >= 100 }";
3746
3748
3750
3751 if (!pwqp)
3752 return -1;
3753
3754 return 0;
3755}
3756
3757static int test_union(isl_ctx *ctx)
3758{
3759 const char *str;
3760 isl_union_set *uset1, *uset2;
3761 isl_union_map *umap1, *umap2;
3762 int equal;
3763
3764 str = "{ [i] : 0 <= i <= 1 }";
3765 uset1 = isl_union_set_read_from_str(ctx, str);
3766 str = "{ [1] -> [0] }";
3767 umap1 = isl_union_map_read_from_str(ctx, str);
3768
3770 equal = isl_union_map_is_equal(umap1, umap2);
3771
3772 isl_union_map_free(umap1);
3773 isl_union_map_free(umap2);
3774
3775 if (equal < 0)
3776 return -1;
3777 if (!equal)
3778 isl_die(ctx, isl_error_unknown, "union maps not equal",
3779 return -1);
3780
3781 str = "{ A[i] -> B[i]; B[i] -> C[i]; A[0] -> C[1] }";
3782 umap1 = isl_union_map_read_from_str(ctx, str);
3783 str = "{ A[i]; B[i] }";
3784 uset1 = isl_union_set_read_from_str(ctx, str);
3785
3786 uset2 = isl_union_map_domain(umap1);
3787
3788 equal = isl_union_set_is_equal(uset1, uset2);
3789
3790 isl_union_set_free(uset1);
3791 isl_union_set_free(uset2);
3792
3793 if (equal < 0)
3794 return -1;
3795 if (!equal)
3796 isl_die(ctx, isl_error_unknown, "union sets not equal",
3797 return -1);
3798
3799 return 0;
3800}
3801
3802/* Inputs for basic isl_pw_qpolynomial_bound tests.
3803 * "type" is the type of bound that should be computed.
3804 * "poly" is a string representation of the input.
3805 * "bound" is a string representation of the expected result.
3806 * "tight" is set if the result is expected to be tight.
3807 */
3808static struct {
3811 const char *poly;
3812 const char *bound;
3813} bound_tests[] = {
3814 /* Check that computing a bound of a non-zero polynomial
3815 * over an unbounded domain does not produce a rational value.
3816 * In particular, check that the upper bound is infinity.
3817 */
3818 { 0, isl_fold_max, "{ [m, n] -> -m * n }", "{ max(infty) }" },
3819 { 1, isl_fold_max, "{ [[a, b, c, d] -> [e]] -> 0 }",
3820 "{ [a, b, c, d] -> max(0) }" },
3821 { 1, isl_fold_max, "{ [[x] -> [x]] -> 1 : exists a : x = 2 a }",
3822 "{ [x] -> max(1) : x mod 2 = 0 }" },
3823 { 1, isl_fold_min, "{ [x=5:10] -> (x + 2)^2 }", "{ min(49) }" },
3824 { 1, isl_fold_max, "{ [0:10] -> 1 }", "{ max(1) }" },
3825 { 1, isl_fold_max, "{ [[m] -> [0:m]] -> m^2 }",
3826 "{ [m] -> max(m^2) : m >= 0 }" },
3827 { 1, isl_fold_max, "{ [[a=0:1] -> [b=0:1]] -> (floor((a + b)/2)) }",
3828 "{ [a=0:1] -> max(a) }" },
3830
3831/* Check that the bound computation can handle differences
3832 * in domain dimension names of the input polynomial and its domain.
3833 */
3835{
3836 const char *str;
3837 isl_set *set;
3840
3841 str = "{ [[c] -> [c]] }";
3843 str = "{ [[a] -> [b]] -> 1 }";
3848
3849 return isl_stat_non_null(pwf);
3850}
3851
3852/* Perform basic isl_pw_qpolynomial_bound tests.
3853 */
3854static int test_bound(isl_ctx *ctx)
3855{
3856 int i;
3857
3858 if (test_bound_space(ctx) < 0)
3859 return -1;
3860
3861 for (i = 0; i < ARRAY_SIZE(bound_tests); ++i) {
3862 const char *str;
3863 enum isl_fold type;
3866 isl_pw_qpolynomial_fold *pwf1, *pwf2;
3867
3868 str = bound_tests[i].poly;
3870 type = bound_tests[i].type;
3872 str = bound_tests[i].bound;
3877 if (equal < 0)
3878 return -1;
3879 if (!equal)
3881 "incorrect bound result", return -1);
3882 if (bound_tests[i].tight && !tight)
3884 "bound unexpectedly not tight", return -1);
3885 }
3886
3887 return 0;
3888}
3889
3890/* isl_set is defined to isl_map internally, so the corresponding elements
3891 * are isl_basic_map objects.
3892 */
3893#undef EL_BASE
3894#undef SET_BASE
3895#define EL_BASE basic_map
3896#define SET_BASE set
3897#include "isl_test_list_templ.c"
3898
3899#undef EL_BASE
3900#undef SET_BASE
3901#define EL_BASE basic_set
3902#define SET_BASE union_set
3903#include "isl_test_list_templ.c"
3904
3905#undef EL_BASE
3906#undef SET_BASE
3907#define EL_BASE set
3908#define SET_BASE union_set
3909#include "isl_test_list_templ.c"
3910
3911#undef EL_BASE
3912#undef SET_BASE
3913#define EL_BASE basic_map
3914#define SET_BASE map
3915#include "isl_test_list_templ.c"
3916
3917#undef EL_BASE
3918#undef SET_BASE
3919#define EL_BASE map
3920#define SET_BASE union_map
3921#include "isl_test_list_templ.c"
3922
3923/* Check that the conversion from isl objects to lists works as expected.
3924 */
3925static int test_get_list(isl_ctx *ctx)
3926{
3927 if (test_get_list_basic_map_from_set(ctx, "{ [0]; [2]; [3] }"))
3928 return -1;
3929 if (test_get_list_basic_set_from_union_set(ctx, "{ A[0]; B[2]; B[3] }"))
3930 return -1;
3931 if (test_get_list_set_from_union_set(ctx, "{ A[0]; A[2]; B[3] }"))
3932 return -1;
3933 if (test_get_list_basic_map_from_map(ctx,
3934 "{ [0] -> [0]; [2] -> [0]; [3] -> [0] }"))
3935 return -1;
3936 if (test_get_list_map_from_union_map(ctx,
3937 "{ A[0] -> [0]; A[2] -> [0]; B[3] -> [0] }"))
3938 return -1;
3939
3940 return 0;
3941}
3942
3943static int test_lift(isl_ctx *ctx)
3944{
3945 const char *str;
3946 isl_basic_map *bmap;
3947 isl_basic_set *bset;
3948
3949 str = "{ [i0] : exists e0 : i0 = 4e0 }";
3950 bset = isl_basic_set_read_from_str(ctx, str);
3951 bset = isl_basic_set_lift(bset);
3952 bmap = isl_basic_map_from_range(bset);
3953 bset = isl_basic_map_domain(bmap);
3954 isl_basic_set_free(bset);
3955
3956 return 0;
3957}
3958
3959/* Check that isl_set_is_subset is not confused by identical
3960 * integer divisions.
3961 * The call to isl_set_normalize ensures that the equality constraints
3962 * a = b = 0 are discovered, turning e0 and e1 into identical
3963 * integer divisions. Any further simplification would remove
3964 * the duplicate integer divisions.
3965 */
3967{
3968 const char *str;
3969 isl_bool is_subset;
3970 isl_set *set1, *set2;
3971
3972 str = "{ [a, b, c, d] : "
3973 "exists (e0 = floor((a + d)/4), e1 = floor((d)/4), "
3974 "e2 = floor((-a - d + 4 *floor((a + d)/4))/10), "
3975 "e3 = floor((-d + 4*floor((d)/4))/10): "
3976 "10e2 = -a - 2c - d + 4e0 and 10e3 = -2c - d + 4e1 and "
3977 "b >= 0 and a <= 0 and b <= a) }";
3981
3982 is_subset = isl_set_is_subset(set1, set2);
3983
3986
3987 if (is_subset < 0)
3988 return isl_stat_error;
3989 if (!is_subset)
3991 "set is not considered to be a subset of itself",
3992 return isl_stat_error);
3993
3994 return isl_stat_ok;
3995}
3996
3997struct {
3998 const char *set1;
3999 const char *set2;
4001} subset_tests[] = {
4002 { "{ [112, 0] }",
4003 "{ [i0, i1] : exists (e0 = [(i0 - i1)/16], e1: "
4004 "16e0 <= i0 - i1 and 16e0 >= -15 + i0 - i1 and "
4005 "16e1 <= i1 and 16e0 >= -i1 and 16e1 >= -i0 + i1) }", 1 },
4006 { "{ [65] }",
4007 "{ [i] : exists (e0 = [(255i)/256], e1 = [(127i + 65e0)/191], "
4008 "e2 = [(3i + 61e1)/65], e3 = [(52i + 12e2)/61], "
4009 "e4 = [(2i + e3)/3], e5 = [(4i + e3)/4], e6 = [(8i + e3)/12]: "
4010 "3e4 = 2i + e3 and 4e5 = 4i + e3 and 12e6 = 8i + e3 and "
4011 "i <= 255 and 64e3 >= -45 + 67i and i >= 0 and "
4012 "256e0 <= 255i and 256e0 >= -255 + 255i and "
4013 "191e1 <= 127i + 65e0 and 191e1 >= -190 + 127i + 65e0 and "
4014 "65e2 <= 3i + 61e1 and 65e2 >= -64 + 3i + 61e1 and "
4015 "61e3 <= 52i + 12e2 and 61e3 >= -60 + 52i + 12e2) }", 1 },
4016 { "{ [i] : 0 <= i <= 10 }", "{ rat: [i] : 0 <= i <= 10 }", 1 },
4017 { "{ rat: [i] : 0 <= i <= 10 }", "{ [i] : 0 <= i <= 10 }", 0 },
4018 { "{ rat: [0] }", "{ [i] : 0 <= i <= 10 }", 1 },
4019 { "{ rat: [(1)/2] }", "{ [i] : 0 <= i <= 10 }", 0 },
4020 { "{ [t, i] : (exists (e0 = [(2 + t)/4]: 4e0 <= 2 + t and "
4021 "4e0 >= -1 + t and i >= 57 and i <= 62 and "
4022 "4e0 <= 62 + t - i and 4e0 >= -61 + t + i and "
4023 "t >= 0 and t <= 511 and 4e0 <= -57 + t + i and "
4024 "4e0 >= 58 + t - i and i >= 58 + t and i >= 62 - t)) }",
4025 "{ [i0, i1] : (exists (e0 = [(4 + i0)/4]: 4e0 <= 62 + i0 - i1 and "
4026 "4e0 >= 1 + i0 and i0 >= 0 and i0 <= 511 and "
4027 "4e0 <= -57 + i0 + i1)) or "
4028 "(exists (e0 = [(2 + i0)/4]: 4e0 <= i0 and "
4029 "4e0 >= 58 + i0 - i1 and i0 >= 2 and i0 <= 511 and "
4030 "4e0 >= -61 + i0 + i1)) or "
4031 "(i1 <= 66 - i0 and i0 >= 2 and i1 >= 59 + i0) }", 1 },
4032 { "[a, b] -> { : a = 0 and b = -1 }", "[b, a] -> { : b >= -10 }", 1 },
4034
4035static int test_subset(isl_ctx *ctx)
4036{
4037 int i;
4038 isl_set *set1, *set2;
4039 int subset;
4040
4042 return -1;
4043
4044 for (i = 0; i < ARRAY_SIZE(subset_tests); ++i) {
4050 if (subset < 0)
4051 return -1;
4052 if (subset != subset_tests[i].subset)
4054 "incorrect subset result", return -1);
4055 }
4056
4057 return 0;
4058}
4059
4060/* Perform a set subtraction with a set that has a non-obviously empty disjunct.
4061 * Older versions of isl would fail on such cases.
4062 */
4064{
4065 const char *str;
4066 isl_set *s1, *s2;
4067
4068 s1 = isl_set_read_from_str(ctx, "{ [0] }");
4069 str = "{ [a] : (exists (e0, e1, e2: 1056e1 <= 32 + a - 33e0 and "
4070 "1089e1 >= a - 33e0 and 1089e1 <= 1 + a - 33e0 and "
4071 "33e2 >= -a + 33e0 + 1056e1 and "
4072 "33e2 < -2a + 66e0 + 2112e1)) or a = 0 }";
4073 s2 = isl_set_read_from_str(ctx, str);
4074 s1 = isl_set_subtract(s1, s2);
4075 isl_set_free(s1);
4076
4077 return isl_stat_non_null(s1);
4078}
4079
4080struct {
4081 const char *minuend;
4082 const char *subtrahend;
4083 const char *difference;
4085 { "{ A[i] -> B[i] }", "{ A[i] }", "{ }" },
4086 { "{ A[i] -> B[i] }", "{ B[i] }", "{ A[i] -> B[i] }" },
4087 { "{ A[i] -> B[i] }", "{ A[i] : i > 0 }", "{ A[i] -> B[i] : i <= 0 }" },
4089
4090static int test_subtract(isl_ctx *ctx)
4091{
4092 int i;
4093 isl_union_map *umap1, *umap2;
4094 isl_union_pw_multi_aff *upma1, *upma2;
4095 isl_union_set *uset;
4096 int equal;
4097
4098 if (test_subtract_empty(ctx) < 0)
4099 return -1;
4100
4101 for (i = 0; i < ARRAY_SIZE(subtract_domain_tests); ++i) {
4102 umap1 = isl_union_map_read_from_str(ctx,
4104 uset = isl_union_set_read_from_str(ctx,
4106 umap2 = isl_union_map_read_from_str(ctx,
4108 umap1 = isl_union_map_subtract_domain(umap1, uset);
4109 equal = isl_union_map_is_equal(umap1, umap2);
4110 isl_union_map_free(umap1);
4111 isl_union_map_free(umap2);
4112 if (equal < 0)
4113 return -1;
4114 if (!equal)
4116 "incorrect subtract domain result", return -1);
4117 }
4118
4119 for (i = 0; i < ARRAY_SIZE(subtract_domain_tests); ++i) {
4122 uset = isl_union_set_read_from_str(ctx,
4126 upma1 = isl_union_pw_multi_aff_subtract_domain(upma1, uset);
4130 if (equal < 0)
4131 return -1;
4132 if (!equal)
4134 "incorrect subtract domain result", return -1);
4135 }
4136
4137 return 0;
4138}
4139
4140/* Check that intersecting the empty basic set with another basic set
4141 * does not increase the number of constraints. In particular,
4142 * the empty basic set should maintain its canonical representation.
4143 */
4145{
4146 isl_size n1, n2;
4147 isl_basic_set *bset1, *bset2;
4148
4149 bset1 = isl_basic_set_read_from_str(ctx, "{ [a,b,c] : 1 = 0 }");
4150 bset2 = isl_basic_set_read_from_str(ctx, "{ [1,2,3] }");
4151 n1 = isl_basic_set_n_constraint(bset1);
4152 bset1 = isl_basic_set_intersect(bset1, bset2);
4153 n2 = isl_basic_set_n_constraint(bset1);
4154 isl_basic_set_free(bset1);
4155 if (n1 < 0 || n2 < 0)
4156 return -1;
4157 if (n1 != n2)
4159 "number of constraints of empty set changed",
4160 return -1);
4161
4162 return 0;
4163}
4164
4165/* Check that intersecting a set with itself does not cause
4166 * an explosion in the number of disjuncts.
4167 */
4169{
4170 int i;
4171 isl_set *set;
4172
4173 set = isl_set_read_from_str(ctx, "{ [x,y] : x >= 0 or y >= 0 }");
4174 for (i = 0; i < 100; ++i)
4177 if (!set)
4178 return isl_stat_error;
4179 return isl_stat_ok;
4180}
4181
4182/* Perform some intersection tests.
4183 */
4184static int test_intersect(isl_ctx *ctx)
4185{
4186 if (test_intersect_1(ctx) < 0)
4187 return -1;
4188 if (test_intersect_2(ctx) < 0)
4189 return -1;
4190
4191 return 0;
4192}
4193
4195{
4196 const char *str;
4197 isl_basic_set *bset;
4199
4200 str = "{ [i0, i1, i2, i3, i4, i5, i6, i7] : 3i5 <= 2 - 2i0 and "
4201 "i0 >= -2 and i6 >= 1 + i3 and i7 >= 0 and 3i5 >= -2i0 and "
4202 "2i4 <= i2 and i6 >= 1 + 2i0 + 3i1 and i4 <= -1 and "
4203 "i6 >= 1 + 2i0 + 3i5 and i6 <= 2 + 2i0 + 3i5 and "
4204 "3i5 <= 2 - 2i0 - i2 + 3i4 and i6 <= 2 + 2i0 + 3i1 and "
4205 "i0 <= -1 and i7 <= i2 + i3 - 3i4 - i6 and "
4206 "3i5 >= -2i0 - i2 + 3i4 }";
4207 bset = isl_basic_set_read_from_str(ctx, str);
4209 isl_basic_set_free(bset);
4211 if (!f)
4213 "failed to construct factorizer", return -1);
4214
4215 str = "{ [i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12] : "
4216 "i12 <= 2 + i0 - i11 and 2i8 >= -i4 and i11 >= i1 and "
4217 "3i5 <= -i2 and 2i11 >= -i4 - 2i7 and i11 <= 3 + i0 + 3i9 and "
4218 "i11 <= -i4 - 2i7 and i12 >= -i10 and i2 >= -2 and "
4219 "i11 >= i1 + 3i10 and i11 >= 1 + i0 + 3i9 and "
4220 "i11 <= 1 - i4 - 2i8 and 6i6 <= 6 - i2 and 3i6 >= 1 - i2 and "
4221 "i11 <= 2 + i1 and i12 <= i4 + i11 and i12 >= i0 - i11 and "
4222 "3i5 >= -2 - i2 and i12 >= -1 + i4 + i11 and 3i3 <= 3 - i2 and "
4223 "9i6 <= 11 - i2 + 6i5 and 3i3 >= 1 - i2 and "
4224 "9i6 <= 5 - i2 + 6i3 and i12 <= -1 and i2 <= 0 }";
4225 bset = isl_basic_set_read_from_str(ctx, str);
4227 isl_basic_set_free(bset);
4229 if (!f)
4231 "failed to construct factorizer", return -1);
4232
4233 return 0;
4234}
4235
4237{
4238 int *injective = user;
4239
4240 *injective = isl_map_is_injective(map);
4242
4243 if (*injective < 0 || !*injective)
4244 return isl_stat_error;
4245
4246 return isl_stat_ok;
4247}
4248
4249int test_one_schedule(isl_ctx *ctx, const char *d, const char *w,
4250 const char *r, const char *s, int tilable, int parallel)
4251{
4252 int i;
4253 isl_union_set *D;
4254 isl_union_map *W, *R, *S;
4255 isl_union_map *empty;
4256 isl_union_map *dep_raw, *dep_war, *dep_waw, *dep;
4257 isl_union_map *validity, *proximity, *coincidence;
4260 isl_union_set *delta;
4262 isl_set *delta_set;
4263 isl_set *slice;
4264 isl_set *origin;
4266 isl_schedule *sched;
4267 int is_nonneg, is_parallel, is_tilable, is_injection, is_complete;
4268 isl_size n;
4269
4270 D = isl_union_set_read_from_str(ctx, d);
4271 W = isl_union_map_read_from_str(ctx, w);
4272 R = isl_union_map_read_from_str(ctx, r);
4274
4277
4280 isl_union_map_copy(W), empty,
4282 &dep_raw, NULL, NULL, NULL);
4287 &dep_waw, &dep_war, NULL, NULL);
4288
4289 dep = isl_union_map_union(dep_waw, dep_war);
4290 dep = isl_union_map_union(dep, dep_raw);
4291 validity = isl_union_map_copy(dep);
4292 coincidence = isl_union_map_copy(dep);
4293 proximity = isl_union_map_copy(dep);
4294
4296 sc = isl_schedule_constraints_set_validity(sc, validity);
4297 sc = isl_schedule_constraints_set_coincidence(sc, coincidence);
4298 sc = isl_schedule_constraints_set_proximity(sc, proximity);
4301 isl_schedule_free(sched);
4305
4306 is_injection = 1;
4308
4310 is_complete = isl_union_set_is_subset(D, domain);
4313
4317
4318 delta = isl_union_map_deltas(test);
4319 n = isl_union_set_n_set(delta);
4320 if (n < 0) {
4321 isl_union_set_free(delta);
4322 return -1;
4323 }
4324 if (n == 0) {
4325 is_tilable = 1;
4326 is_parallel = 1;
4327 is_nonneg = 1;
4328 isl_union_set_free(delta);
4329 } else {
4330 isl_size dim;
4331
4332 delta_set = isl_set_from_union_set(delta);
4333
4334 slice = isl_set_universe(isl_set_get_space(delta_set));
4335 for (i = 0; i < tilable; ++i)
4336 slice = isl_set_lower_bound_si(slice, isl_dim_set, i, 0);
4337 is_tilable = isl_set_is_subset(delta_set, slice);
4338 isl_set_free(slice);
4339
4340 slice = isl_set_universe(isl_set_get_space(delta_set));
4341 for (i = 0; i < parallel; ++i)
4342 slice = isl_set_fix_si(slice, isl_dim_set, i, 0);
4343 is_parallel = isl_set_is_subset(delta_set, slice);
4344 isl_set_free(slice);
4345
4346 origin = isl_set_universe(isl_set_get_space(delta_set));
4347 dim = isl_set_dim(origin, isl_dim_set);
4348 if (dim < 0)
4349 origin = isl_set_free(origin);
4350 for (i = 0; i < dim; ++i)
4351 origin = isl_set_fix_si(origin, isl_dim_set, i, 0);
4352
4353 delta_set = isl_set_union(delta_set, isl_set_copy(origin));
4354 delta_set = isl_set_lexmin(delta_set);
4355
4356 is_nonneg = isl_set_is_equal(delta_set, origin);
4357
4358 isl_set_free(origin);
4359 isl_set_free(delta_set);
4360 }
4361
4362 if (is_nonneg < 0 || is_parallel < 0 || is_tilable < 0 ||
4363 is_injection < 0 || is_complete < 0)
4364 return -1;
4365 if (!is_complete)
4367 "generated schedule incomplete", return -1);
4368 if (!is_injection)
4370 "generated schedule not injective on each statement",
4371 return -1);
4372 if (!is_nonneg)
4374 "negative dependences in generated schedule",
4375 return -1);
4376 if (!is_tilable)
4378 "generated schedule not as tilable as expected",
4379 return -1);
4380 if (!is_parallel)
4382 "generated schedule not as parallel as expected",
4383 return -1);
4384
4385 return 0;
4386}
4387
4388/* Compute a schedule for the given instance set, validity constraints,
4389 * proximity constraints and context and return a corresponding union map
4390 * representation.
4391 */
4393 const char *domain, const char *validity, const char *proximity,
4394 const char *context)
4395{
4396 isl_set *con;
4397 isl_union_set *dom;
4398 isl_union_map *dep;
4399 isl_union_map *prox;
4402 isl_union_map *sched;
4403
4404 con = isl_set_read_from_str(ctx, context);
4406 dep = isl_union_map_read_from_str(ctx, validity);
4407 prox = isl_union_map_read_from_str(ctx, proximity);
4415
4416 return sched;
4417}
4418
4419/* Compute a schedule for the given instance set, validity constraints and
4420 * proximity constraints and return a corresponding union map representation.
4421 */
4423 const char *domain, const char *validity, const char *proximity)
4424{
4425 return compute_schedule_with_context(ctx, domain, validity, proximity,
4426 "{ : }");
4427}
4428
4429/* Check that a schedule can be constructed on the given domain
4430 * with the given validity and proximity constraints.
4431 */
4432static int test_has_schedule(isl_ctx *ctx, const char *domain,
4433 const char *validity, const char *proximity)
4434{
4435 isl_union_map *sched;
4436
4437 sched = compute_schedule(ctx, domain, validity, proximity);
4438 if (!sched)
4439 return -1;
4440
4441 isl_union_map_free(sched);
4442 return 0;
4443}
4444
4446 const char *validity, const char *proximity, const char *expected_sched)
4447{
4448 isl_union_map *sched1, *sched2;
4449 int equal;
4450
4451 sched1 = compute_schedule(ctx, domain, validity, proximity);
4452 sched2 = isl_union_map_read_from_str(ctx, expected_sched);
4453
4454 equal = isl_union_map_is_equal(sched1, sched2);
4455 isl_union_map_free(sched1);
4456 isl_union_map_free(sched2);
4457
4458 if (equal < 0)
4459 return -1;
4460 if (!equal)
4461 isl_die(ctx, isl_error_unknown, "unexpected schedule",
4462 return -1);
4463
4464 return 0;
4465}
4466
4467/* Check that the schedule map is properly padded, i.e., that the range
4468 * lives in a single space.
4469 */
4471{
4472 const char *str;
4473 isl_union_set *D;
4474 isl_union_map *validity, *proximity;
4476 isl_schedule *sched;
4477 isl_union_map *umap;
4479 isl_set *set;
4480
4481 str = "[N] -> { S0[i] : 0 <= i <= N; S1[i, j] : 0 <= i, j <= N }";
4484 proximity = isl_union_map_copy(validity);
4486 sc = isl_schedule_constraints_set_validity(sc, validity);
4487 sc = isl_schedule_constraints_set_proximity(sc, proximity);
4489 umap = isl_schedule_get_map(sched);
4490 isl_schedule_free(sched);
4491 range = isl_union_map_range(umap);
4494
4495 if (!set)
4496 return -1;
4497
4498 return 0;
4499}
4500
4501/* Check that conditional validity constraints are also taken into
4502 * account across bands.
4503 * In particular, try to make sure that live ranges D[1,0]->C[2,1] and
4504 * D[2,0]->C[3,0] are not local in the outer band of the generated schedule
4505 * and then check that the adjacent order constraint C[2,1]->D[2,0]
4506 * is enforced by the rest of the schedule.
4507 */
4509{
4510 const char *str;
4512 isl_union_map *validity, *proximity, *condition;
4513 isl_union_map *sink, *source, *dep;
4516 isl_union_access_info *access;
4518 int empty;
4519
4520 str = "[n] -> { C[k, i] : k <= -1 + n and i >= 0 and i <= -1 + k; "
4521 "A[k] : k >= 1 and k <= -1 + n; "
4522 "B[k, i] : k <= -1 + n and i >= 0 and i <= -1 + k; "
4523 "D[k, i] : k <= -1 + n and i >= 0 and i <= -1 + k }";
4526 str = "[n] -> { D[k, i] -> C[1 + k, k - i] : "
4527 "k <= -2 + n and i >= 1 and i <= -1 + k; "
4528 "D[k, i] -> C[1 + k, i] : "
4529 "k <= -2 + n and i >= 1 and i <= -1 + k; "
4530 "D[k, 0] -> C[1 + k, k] : k >= 1 and k <= -2 + n; "
4531 "D[k, 0] -> C[1 + k, 0] : k >= 1 and k <= -2 + n }";
4532 validity = isl_union_map_read_from_str(ctx, str);
4533 sc = isl_schedule_constraints_set_validity(sc, validity);
4534 str = "[n] -> { C[k, i] -> D[k, i] : "
4535 "0 <= i <= -1 + k and k <= -1 + n }";
4536 proximity = isl_union_map_read_from_str(ctx, str);
4537 sc = isl_schedule_constraints_set_proximity(sc, proximity);
4538 str = "[n] -> { [D[k, i] -> a[]] -> [C[1 + k, k - i] -> b[]] : "
4539 "i <= -1 + k and i >= 1 and k <= -2 + n; "
4540 "[B[k, i] -> c[]] -> [B[k, 1 + i] -> c[]] : "
4541 "k <= -1 + n and i >= 0 and i <= -2 + k }";
4543 str = "[n] -> { [B[k, i] -> e[]] -> [D[k, i] -> a[]] : "
4544 "i >= 0 and i <= -1 + k and k <= -1 + n; "
4545 "[C[k, i] -> b[]] -> [D[k', -1 + k - i] -> a[]] : "
4546 "i >= 0 and i <= -1 + k and k <= -1 + n and "
4547 "k' <= -1 + n and k' >= k - i and k' >= 1 + k; "
4548 "[C[k, i] -> b[]] -> [D[k, -1 + k - i] -> a[]] : "
4549 "i >= 0 and i <= -1 + k and k <= -1 + n; "
4550 "[B[k, i] -> c[]] -> [A[k'] -> d[]] : "
4551 "k <= -1 + n and i >= 0 and i <= -1 + k and "
4552 "k' >= 1 and k' <= -1 + n and k' >= 1 + k }";
4553 validity = isl_union_map_read_from_str(ctx, str);
4555 validity);
4557 str = "{ D[2,0] -> [] }";
4558 sink = isl_union_map_read_from_str(ctx, str);
4559 access = isl_union_access_info_from_sink(sink);
4560 str = "{ C[2,1] -> [] }";
4561 source = isl_union_map_read_from_str(ctx, str);
4562 access = isl_union_access_info_set_must_source(access, source);
4567 empty = isl_union_map_is_empty(dep);
4568 isl_union_map_free(dep);
4569
4570 if (empty < 0)
4571 return -1;
4572 if (empty)
4574 "conditional validity not respected", return -1);
4575
4576 return 0;
4577}
4578
4579/* Check that the test for violated conditional validity constraints
4580 * is not confused by domain compression.
4581 * In particular, earlier versions of isl would apply
4582 * a schedule on the compressed domains to the original domains,
4583 * resulting in a failure to detect that the default schedule
4584 * violates the conditional validity constraints.
4585 */
4587{
4588 const char *str;
4589 isl_bool empty;
4591 isl_union_map *validity, *condition;
4594 isl_union_map *umap;
4595 isl_map *map, *ge;
4596
4597 str = "{ A[0, i] : 0 <= i <= 10; B[1, i] : 0 <= i <= 10 }";
4600 str = "{ B[1, i] -> A[0, i + 1] }";
4602 str = "{ A[0, i] -> B[1, i - 1] }";
4603 validity = isl_union_map_read_from_str(ctx, str);
4605 isl_union_map_copy(validity));
4609 validity = isl_union_map_apply_domain(validity,
4610 isl_union_map_copy(umap));
4611 validity = isl_union_map_apply_range(validity, umap);
4612 map = isl_map_from_union_map(validity);
4614 map = isl_map_intersect(map, ge);
4615 empty = isl_map_is_empty(map);
4617
4618 if (empty < 0)
4619 return -1;
4620 if (!empty)
4622 "conditional validity constraints not satisfied",
4623 return -1);
4624
4625 return 0;
4626}
4627
4628/* Input for testing of schedule construction based on
4629 * conditional constraints.
4630 *
4631 * domain is the iteration domain
4632 * flow are the flow dependences, which determine the validity and
4633 * proximity constraints
4634 * condition are the conditions on the conditional validity constraints
4635 * conditional_validity are the conditional validity constraints
4636 * outer_band_n is the expected number of members in the outer band
4637 */
4638struct {
4639 const char *domain;
4640 const char *flow;
4641 const char *condition;
4644} live_range_tests[] = {
4645 /* Contrived example that illustrates that we need to keep
4646 * track of tagged condition dependences and
4647 * tagged conditional validity dependences
4648 * in isl_sched_edge separately.
4649 * In particular, the conditional validity constraints on A
4650 * cannot be satisfied,
4651 * but they can be ignored because there are no corresponding
4652 * condition constraints. However, we do have an additional
4653 * conditional validity constraint that maps to the same
4654 * dependence relation
4655 * as the condition constraint on B. If we did not make a distinction
4656 * between tagged condition and tagged conditional validity
4657 * dependences, then we
4658 * could end up treating this shared dependence as an condition
4659 * constraint on A, forcing a localization of the conditions,
4660 * which is impossible.
4661 */
4662 { "{ S[i] : 0 <= 1 < 100; T[i] : 0 <= 1 < 100 }",
4663 "{ S[i] -> S[i+1] : 0 <= i < 99 }",
4664 "{ [S[i] -> B[]] -> [S[i+1] -> B[]] : 0 <= i < 99 }",
4665 "{ [S[i] -> A[]] -> [T[i'] -> A[]] : 0 <= i', i < 100 and i != i';"
4666 "[T[i] -> A[]] -> [S[i'] -> A[]] : 0 <= i', i < 100 and i != i';"
4667 "[S[i] -> A[]] -> [S[i+1] -> A[]] : 0 <= i < 99 }",
4668 1
4669 },
4670 /* TACO 2013 Fig. 7 */
4671 { "[n] -> { S1[i,j] : 0 <= i,j < n; S2[i,j] : 0 <= i,j < n }",
4672 "[n] -> { S1[i,j] -> S2[i,j] : 0 <= i,j < n;"
4673 "S2[i,j] -> S2[i,j+1] : 0 <= i < n and 0 <= j < n - 1 }",
4674 "[n] -> { [S1[i,j] -> t[]] -> [S2[i,j] -> t[]] : 0 <= i,j < n;"
4675 "[S2[i,j] -> x1[]] -> [S2[i,j+1] -> x1[]] : "
4676 "0 <= i < n and 0 <= j < n - 1 }",
4677 "[n] -> { [S2[i,j] -> t[]] -> [S1[i,j'] -> t[]] : "
4678 "0 <= i < n and 0 <= j < j' < n;"
4679 "[S2[i,j] -> t[]] -> [S1[i',j'] -> t[]] : "
4680 "0 <= i < i' < n and 0 <= j,j' < n;"
4681 "[S2[i,j] -> x1[]] -> [S2[i,j'] -> x1[]] : "
4682 "0 <= i,j,j' < n and j < j' }",
4683 2
4684 },
4685 /* TACO 2013 Fig. 7, without tags */
4686 { "[n] -> { S1[i,j] : 0 <= i,j < n; S2[i,j] : 0 <= i,j < n }",
4687 "[n] -> { S1[i,j] -> S2[i,j] : 0 <= i,j < n;"
4688 "S2[i,j] -> S2[i,j+1] : 0 <= i < n and 0 <= j < n - 1 }",
4689 "[n] -> { S1[i,j] -> S2[i,j] : 0 <= i,j < n;"
4690 "S2[i,j] -> S2[i,j+1] : 0 <= i < n and 0 <= j < n - 1 }",
4691 "[n] -> { S2[i,j] -> S1[i,j'] : 0 <= i < n and 0 <= j < j' < n;"
4692 "S2[i,j] -> S1[i',j'] : 0 <= i < i' < n and 0 <= j,j' < n;"
4693 "S2[i,j] -> S2[i,j'] : 0 <= i,j,j' < n and j < j' }",
4694 1
4695 },
4696 /* TACO 2013 Fig. 12 */
4697 { "{ S1[i,0] : 0 <= i <= 1; S2[i,j] : 0 <= i <= 1 and 1 <= j <= 2;"
4698 "S3[i,3] : 0 <= i <= 1 }",
4699 "{ S1[i,0] -> S2[i,1] : 0 <= i <= 1;"
4700 "S2[i,1] -> S2[i,2] : 0 <= i <= 1;"
4701 "S2[i,2] -> S3[i,3] : 0 <= i <= 1 }",
4702 "{ [S1[i,0]->t[]] -> [S2[i,1]->t[]] : 0 <= i <= 1;"
4703 "[S2[i,1]->t[]] -> [S2[i,2]->t[]] : 0 <= i <= 1;"
4704 "[S2[i,2]->t[]] -> [S3[i,3]->t[]] : 0 <= i <= 1 }",
4705 "{ [S2[i,1]->t[]] -> [S2[i,2]->t[]] : 0 <= i <= 1;"
4706 "[S2[0,j]->t[]] -> [S2[1,j']->t[]] : 1 <= j,j' <= 2;"
4707 "[S2[0,j]->t[]] -> [S1[1,0]->t[]] : 1 <= j <= 2;"
4708 "[S3[0,3]->t[]] -> [S2[1,j]->t[]] : 1 <= j <= 2;"
4709 "[S3[0,3]->t[]] -> [S1[1,0]->t[]] }",
4710 1
4711 }
4713
4714/* Test schedule construction based on conditional constraints.
4715 * In particular, check the number of members in the outer band node
4716 * as an indication of whether tiling is possible or not.
4717 */
4719{
4720 int i;
4724 isl_union_map *validity;
4727 isl_schedule_node *node;
4728 isl_size n_member;
4729
4731 return -1;
4733 return -1;
4734
4735 for (i = 0; i < ARRAY_SIZE(live_range_tests); ++i) {
4742 validity = isl_union_map_read_from_str(ctx,
4749 condition, validity);
4752 while (node &&
4754 node = isl_schedule_node_first_child(node);
4755 n_member = isl_schedule_node_band_n_member(node);
4758
4759 if (!schedule || n_member < 0)
4760 return -1;
4761 if (n_member != live_range_tests[i].outer_band_n)
4763 "unexpected number of members in outer band",
4764 return -1);
4765 }
4766 return 0;
4767}
4768
4769/* Check that the schedule computed for the given instance set and
4770 * dependence relation strongly satisfies the dependences.
4771 * In particular, check that no instance is scheduled before
4772 * or together with an instance on which it depends.
4773 * Earlier versions of isl would produce a schedule that
4774 * only weakly satisfies the dependences.
4775 */
4777{
4778 const char *domain, *dep;
4780 isl_map *map, *ge;
4781 int empty;
4782
4783 domain = "{ B[i0, i1] : 0 <= i0 <= 1 and 0 <= i1 <= 11; "
4784 "A[i0] : 0 <= i0 <= 1 }";
4785 dep = "{ B[i0, i1] -> B[i0, 1 + i1] : 0 <= i0 <= 1 and 0 <= i1 <= 10; "
4786 "B[0, 11] -> A[1]; A[i0] -> B[i0, 0] : 0 <= i0 <= 1 }";
4787 schedule = compute_schedule(ctx, domain, dep, dep);
4788 D = isl_union_map_read_from_str(ctx, dep);
4793 map = isl_map_intersect(map, ge);
4794 empty = isl_map_is_empty(map);
4796
4797 if (empty < 0)
4798 return -1;
4799 if (!empty)
4801 "dependences not strongly satisfied", return -1);
4802
4803 return 0;
4804}
4805
4806/* Compute a schedule for input where the instance set constraints
4807 * conflict with the context constraints.
4808 * Earlier versions of isl did not properly handle this situation.
4809 */
4811{
4813 const char *domain, *context;
4814
4815 domain = "[n] -> { A[] : n >= 0 }";
4816 context = "[n] -> { : n < 0 }";
4818 domain, "{}", "{}", context);
4820
4821 if (!schedule)
4822 return -1;
4823
4824 return 0;
4825}
4826
4827/* Check that a set of schedule constraints that only allow for
4828 * a coalescing schedule still produces a schedule even if the user
4829 * request a non-coalescing schedule. Earlier versions of isl
4830 * would not handle this case correctly.
4831 */
4833{
4834 const char *domain, *dep;
4835 isl_union_set *I;
4836 isl_union_map *D;
4839 int treat_coalescing;
4840
4841 domain = "{ S[a, b] : 0 <= a <= 1 and 0 <= b <= 1 }";
4842 dep = "{ S[a, b] -> S[a + b, 1 - b] }";
4844 D = isl_union_map_read_from_str(ctx, dep);
4847 treat_coalescing = isl_options_get_schedule_treat_coalescing(ctx);
4850 isl_options_set_schedule_treat_coalescing(ctx, treat_coalescing);
4852 if (!schedule)
4853 return -1;
4854 return 0;
4855}
4856
4857/* Check that the scheduler does not perform any needless
4858 * compound skewing. Earlier versions of isl would compute
4859 * schedules in terms of transformed schedule coefficients and
4860 * would not accurately keep track of the sum of the original
4861 * schedule coefficients. It could then produce the schedule
4862 * S[t,i,j,k] -> [t, 2t + i, 2t + i + j, 2t + i + j + k]
4863 * for the input below instead of the schedule below.
4864 */
4866{
4867 const char *D, *V, *P, *S;
4868
4869 D = "[n] -> { S[t,i,j,k] : 0 <= t,i,j,k < n }";
4870 V = "[n] -> { S[t,i,j,k] -> S[t+1,a,b,c] : 0 <= t,i,j,k,a,b,c < n and "
4871 "-2 <= a-i <= 2 and -1 <= a-i + b-j <= 1 and "
4872 "-1 <= a-i + b-j + c-k <= 1 }";
4873 P = "{ }";
4874 S = "{ S[t,i,j,k] -> [t, 2t + i, t + i + j, 2t + k] }";
4875
4876 return test_special_schedule(ctx, D, V, P, S);
4877}
4878
4880{
4881 const char *D, *W, *R, *V, *P, *S;
4882 int max_coincidence;
4883 int treat_coalescing;
4884
4885 /* Handle resulting schedule with zero bands. */
4886 if (test_one_schedule(ctx, "{[]}", "{}", "{}", "{[] -> []}", 0, 0) < 0)
4887 return -1;
4888
4889 /* Jacobi */
4890 D = "[T,N] -> { S1[t,i] : 1 <= t <= T and 2 <= i <= N - 1 }";
4891 W = "{ S1[t,i] -> a[t,i] }";
4892 R = "{ S1[t,i] -> a[t-1,i]; S1[t,i] -> a[t-1,i-1]; "
4893 "S1[t,i] -> a[t-1,i+1] }";
4894 S = "{ S1[t,i] -> [t,i] }";
4895 if (test_one_schedule(ctx, D, W, R, S, 2, 0) < 0)
4896 return -1;
4897
4898 /* Fig. 5 of CC2008 */
4899 D = "[N] -> { S_0[i, j] : i >= 0 and i <= -1 + N and j >= 2 and "
4900 "j <= -1 + N }";
4901 W = "[N] -> { S_0[i, j] -> a[i, j] : i >= 0 and i <= -1 + N and "
4902 "j >= 2 and j <= -1 + N }";
4903 R = "[N] -> { S_0[i, j] -> a[j, i] : i >= 0 and i <= -1 + N and "
4904 "j >= 2 and j <= -1 + N; "
4905 "S_0[i, j] -> a[i, -1 + j] : i >= 0 and i <= -1 + N and "
4906 "j >= 2 and j <= -1 + N }";
4907 S = "[N] -> { S_0[i, j] -> [0, i, 0, j, 0] }";
4908 if (test_one_schedule(ctx, D, W, R, S, 2, 0) < 0)
4909 return -1;
4910
4911 D = "{ S1[i] : 0 <= i <= 10; S2[i] : 0 <= i <= 9 }";
4912 W = "{ S1[i] -> a[i] }";
4913 R = "{ S2[i] -> a[i+1] }";
4914 S = "{ S1[i] -> [0,i]; S2[i] -> [1,i] }";
4915 if (test_one_schedule(ctx, D, W, R, S, 1, 1) < 0)
4916 return -1;
4917
4918 D = "{ S1[i] : 0 <= i < 10; S2[i] : 0 <= i < 10 }";
4919 W = "{ S1[i] -> a[i] }";
4920 R = "{ S2[i] -> a[9-i] }";
4921 S = "{ S1[i] -> [0,i]; S2[i] -> [1,i] }";
4922 if (test_one_schedule(ctx, D, W, R, S, 1, 1) < 0)
4923 return -1;
4924
4925 D = "[N] -> { S1[i] : 0 <= i < N; S2[i] : 0 <= i < N }";
4926 W = "{ S1[i] -> a[i] }";
4927 R = "[N] -> { S2[i] -> a[N-1-i] }";
4928 S = "{ S1[i] -> [0,i]; S2[i] -> [1,i] }";
4929 if (test_one_schedule(ctx, D, W, R, S, 1, 1) < 0)
4930 return -1;
4931
4932 D = "{ S1[i] : 0 < i < 10; S2[i] : 0 <= i < 10 }";
4933 W = "{ S1[i] -> a[i]; S2[i] -> b[i] }";
4934 R = "{ S2[i] -> a[i]; S1[i] -> b[i-1] }";
4935 S = "{ S1[i] -> [i,0]; S2[i] -> [i,1] }";
4936 if (test_one_schedule(ctx, D, W, R, S, 0, 0) < 0)
4937 return -1;
4938
4939 D = "[N] -> { S1[i] : 1 <= i <= N; S2[i,j] : 1 <= i,j <= N }";
4940 W = "{ S1[i] -> a[0,i]; S2[i,j] -> a[i,j] }";
4941 R = "{ S2[i,j] -> a[i-1,j] }";
4942 S = "{ S1[i] -> [0,i,0]; S2[i,j] -> [1,i,j] }";
4943 if (test_one_schedule(ctx, D, W, R, S, 2, 1) < 0)
4944 return -1;
4945
4946 D = "[N] -> { S1[i] : 1 <= i <= N; S2[i,j] : 1 <= i,j <= N }";
4947 W = "{ S1[i] -> a[i,0]; S2[i,j] -> a[i,j] }";
4948 R = "{ S2[i,j] -> a[i,j-1] }";
4949 S = "{ S1[i] -> [0,i,0]; S2[i,j] -> [1,i,j] }";
4950 if (test_one_schedule(ctx, D, W, R, S, 2, 1) < 0)
4951 return -1;
4952
4953 D = "[N] -> { S_0[]; S_1[i] : i >= 0 and i <= -1 + N; S_2[] }";
4954 W = "[N] -> { S_0[] -> a[0]; S_2[] -> b[0]; "
4955 "S_1[i] -> a[1 + i] : i >= 0 and i <= -1 + N }";
4956 R = "[N] -> { S_2[] -> a[N]; S_1[i] -> a[i] : i >= 0 and i <= -1 + N }";
4957 S = "[N] -> { S_1[i] -> [1, i, 0]; S_2[] -> [2, 0, 1]; "
4958 "S_0[] -> [0, 0, 0] }";
4959 if (test_one_schedule(ctx, D, W, R, S, 1, 0) < 0)
4960 return -1;
4961 ctx->opt->schedule_parametric = 0;
4962 if (test_one_schedule(ctx, D, W, R, S, 0, 0) < 0)
4963 return -1;
4964 ctx->opt->schedule_parametric = 1;
4965
4966 D = "[N] -> { S1[i] : 1 <= i <= N; S2[i] : 1 <= i <= N; "
4967 "S3[i,j] : 1 <= i,j <= N; S4[i] : 1 <= i <= N }";
4968 W = "{ S1[i] -> a[i,0]; S2[i] -> a[0,i]; S3[i,j] -> a[i,j] }";
4969 R = "[N] -> { S3[i,j] -> a[i-1,j]; S3[i,j] -> a[i,j-1]; "
4970 "S4[i] -> a[i,N] }";
4971 S = "{ S1[i] -> [0,i,0]; S2[i] -> [1,i,0]; S3[i,j] -> [2,i,j]; "
4972 "S4[i] -> [4,i,0] }";
4973 max_coincidence = isl_options_get_schedule_maximize_coincidence(ctx);
4975 if (test_one_schedule(ctx, D, W, R, S, 2, 0) < 0)
4976 return -1;
4978
4979 D = "[N] -> { S_0[i, j] : i >= 1 and i <= N and j >= 1 and j <= N }";
4980 W = "[N] -> { S_0[i, j] -> s[0] : i >= 1 and i <= N and j >= 1 and "
4981 "j <= N }";
4982 R = "[N] -> { S_0[i, j] -> s[0] : i >= 1 and i <= N and j >= 1 and "
4983 "j <= N; "
4984 "S_0[i, j] -> a[i, j] : i >= 1 and i <= N and j >= 1 and "
4985 "j <= N }";
4986 S = "[N] -> { S_0[i, j] -> [0, i, 0, j, 0] }";
4987 if (test_one_schedule(ctx, D, W, R, S, 0, 0) < 0)
4988 return -1;
4989
4990 D = "[N] -> { S_0[t] : t >= 0 and t <= -1 + N; "
4991 " S_2[t] : t >= 0 and t <= -1 + N; "
4992 " S_1[t, i] : t >= 0 and t <= -1 + N and i >= 0 and "
4993 "i <= -1 + N }";
4994 W = "[N] -> { S_0[t] -> a[t, 0] : t >= 0 and t <= -1 + N; "
4995 " S_2[t] -> b[t] : t >= 0 and t <= -1 + N; "
4996 " S_1[t, i] -> a[t, 1 + i] : t >= 0 and t <= -1 + N and "
4997 "i >= 0 and i <= -1 + N }";
4998 R = "[N] -> { S_1[t, i] -> a[t, i] : t >= 0 and t <= -1 + N and "
4999 "i >= 0 and i <= -1 + N; "
5000 " S_2[t] -> a[t, N] : t >= 0 and t <= -1 + N }";
5001 S = "[N] -> { S_2[t] -> [0, t, 2]; S_1[t, i] -> [0, t, 1, i, 0]; "
5002 " S_0[t] -> [0, t, 0] }";
5003
5004 if (test_one_schedule(ctx, D, W, R, S, 2, 1) < 0)
5005 return -1;
5006 ctx->opt->schedule_parametric = 0;
5007 if (test_one_schedule(ctx, D, W, R, S, 0, 0) < 0)
5008 return -1;
5009 ctx->opt->schedule_parametric = 1;
5010
5011 D = "[N] -> { S1[i,j] : 0 <= i,j < N; S2[i,j] : 0 <= i,j < N }";
5012 S = "{ S1[i,j] -> [0,i,j]; S2[i,j] -> [1,i,j] }";
5013 if (test_one_schedule(ctx, D, "{}", "{}", S, 2, 2) < 0)
5014 return -1;
5015
5016 D = "[M, N] -> { S_1[i] : i >= 0 and i <= -1 + M; "
5017 "S_0[i, j] : i >= 0 and i <= -1 + M and j >= 0 and j <= -1 + N }";
5018 W = "[M, N] -> { S_0[i, j] -> a[j] : i >= 0 and i <= -1 + M and "
5019 "j >= 0 and j <= -1 + N; "
5020 "S_1[i] -> b[0] : i >= 0 and i <= -1 + M }";
5021 R = "[M, N] -> { S_0[i, j] -> a[0] : i >= 0 and i <= -1 + M and "
5022 "j >= 0 and j <= -1 + N; "
5023 "S_1[i] -> b[0] : i >= 0 and i <= -1 + M }";
5024 S = "[M, N] -> { S_1[i] -> [1, i, 0]; S_0[i, j] -> [0, i, 0, j, 0] }";
5025 if (test_one_schedule(ctx, D, W, R, S, 0, 0) < 0)
5026 return -1;
5027
5028 D = "{ S_0[i] : i >= 0 }";
5029 W = "{ S_0[i] -> a[i] : i >= 0 }";
5030 R = "{ S_0[i] -> a[0] : i >= 0 }";
5031 S = "{ S_0[i] -> [0, i, 0] }";
5032 if (test_one_schedule(ctx, D, W, R, S, 0, 0) < 0)
5033 return -1;
5034
5035 D = "{ S_0[i] : i >= 0; S_1[i] : i >= 0 }";
5036 W = "{ S_0[i] -> a[i] : i >= 0; S_1[i] -> b[i] : i >= 0 }";
5037 R = "{ S_0[i] -> b[0] : i >= 0; S_1[i] -> a[i] : i >= 0 }";
5038 S = "{ S_1[i] -> [0, i, 1]; S_0[i] -> [0, i, 0] }";
5039 if (test_one_schedule(ctx, D, W, R, S, 0, 0) < 0)
5040 return -1;
5041
5042 D = "[n] -> { S_0[j, k] : j <= -1 + n and j >= 0 and "
5043 "k <= -1 + n and k >= 0 }";
5044 W = "[n] -> { S_0[j, k] -> B[j] : j <= -1 + n and j >= 0 and " "k <= -1 + n and k >= 0 }";
5045 R = "[n] -> { S_0[j, k] -> B[j] : j <= -1 + n and j >= 0 and "
5046 "k <= -1 + n and k >= 0; "
5047 "S_0[j, k] -> B[k] : j <= -1 + n and j >= 0 and "
5048 "k <= -1 + n and k >= 0; "
5049 "S_0[j, k] -> A[k] : j <= -1 + n and j >= 0 and "
5050 "k <= -1 + n and k >= 0 }";
5051 S = "[n] -> { S_0[j, k] -> [2, j, k] }";
5053 if (test_one_schedule(ctx, D, W, R, S, 0, 0) < 0)
5054 return -1;
5056
5057 D = "{Stmt_for_body24[i0, i1, i2, i3]:"
5058 "i0 >= 0 and i0 <= 1 and i1 >= 0 and i1 <= 6 and i2 >= 2 and "
5059 "i2 <= 6 - i1 and i3 >= 0 and i3 <= -1 + i2;"
5060 "Stmt_for_body24[i0, i1, 1, 0]:"
5061 "i0 >= 0 and i0 <= 1 and i1 >= 0 and i1 <= 5;"
5062 "Stmt_for_body7[i0, i1, i2]:"
5063 "i0 >= 0 and i0 <= 1 and i1 >= 0 and i1 <= 7 and i2 >= 0 and "
5064 "i2 <= 7 }";
5065
5066 V = "{Stmt_for_body24[0, i1, i2, i3] -> "
5067 "Stmt_for_body24[1, i1, i2, i3]:"
5068 "i3 >= 0 and i3 <= -1 + i2 and i1 >= 0 and i2 <= 6 - i1 and "
5069 "i2 >= 1;"
5070 "Stmt_for_body24[0, i1, i2, i3] -> "
5071 "Stmt_for_body7[1, 1 + i1 + i3, 1 + i1 + i2]:"
5072 "i3 <= -1 + i2 and i2 <= 6 - i1 and i2 >= 1 and i1 >= 0 and "
5073 "i3 >= 0;"
5074 "Stmt_for_body24[0, i1, i2, i3] ->"
5075 "Stmt_for_body7[1, i1, 1 + i1 + i3]:"
5076 "i3 >= 0 and i2 <= 6 - i1 and i1 >= 0 and i3 <= -1 + i2;"
5077 "Stmt_for_body7[0, i1, i2] -> Stmt_for_body7[1, i1, i2]:"
5078 "(i2 >= 1 + i1 and i2 <= 6 and i1 >= 0 and i1 <= 4) or "
5079 "(i2 >= 3 and i2 <= 7 and i1 >= 1 and i2 >= 1 + i1) or "
5080 "(i2 >= 0 and i2 <= i1 and i2 >= -7 + i1 and i1 <= 7);"
5081 "Stmt_for_body7[0, i1, 1 + i1] -> Stmt_for_body7[1, i1, 1 + i1]:"
5082 "i1 <= 6 and i1 >= 0;"
5083 "Stmt_for_body7[0, 0, 7] -> Stmt_for_body7[1, 0, 7];"
5084 "Stmt_for_body7[i0, i1, i2] -> "
5085 "Stmt_for_body24[i0, o1, -1 + i2 - o1, -1 + i1 - o1]:"
5086 "i0 >= 0 and i0 <= 1 and o1 >= 0 and i2 >= 1 + i1 and "
5087 "o1 <= -2 + i2 and i2 <= 7 and o1 <= -1 + i1;"
5088 "Stmt_for_body7[i0, i1, i2] -> "
5089 "Stmt_for_body24[i0, i1, o2, -1 - i1 + i2]:"
5090 "i0 >= 0 and i0 <= 1 and i1 >= 0 and o2 >= -i1 + i2 and "
5091 "o2 >= 1 and o2 <= 6 - i1 and i2 >= 1 + i1 }";
5092 P = V;
5093
5094 treat_coalescing = isl_options_get_schedule_treat_coalescing(ctx);
5096 if (test_has_schedule(ctx, D, V, P) < 0)
5097 return -1;
5098 isl_options_set_schedule_treat_coalescing(ctx, treat_coalescing);
5099
5100 D = "{ S_0[i, j] : i >= 1 and i <= 10 and j >= 1 and j <= 8 }";
5101 V = "{ S_0[i, j] -> S_0[i, 1 + j] : i >= 1 and i <= 10 and "
5102 "j >= 1 and j <= 7;"
5103 "S_0[i, j] -> S_0[1 + i, j] : i >= 1 and i <= 9 and "
5104 "j >= 1 and j <= 8 }";
5105 P = "{ }";
5106 S = "{ S_0[i, j] -> [i + j, i] }";
5108 if (test_special_schedule(ctx, D, V, P, S) < 0)
5109 return -1;
5111
5112 /* Fig. 1 from Feautrier's "Some Efficient Solutions..." pt. 2, 1992 */
5113 D = "[N] -> { S_0[i, j] : i >= 0 and i <= -1 + N and "
5114 "j >= 0 and j <= -1 + i }";
5115 V = "[N] -> { S_0[i, j] -> S_0[i, 1 + j] : j <= -2 + i and "
5116 "i <= -1 + N and j >= 0;"
5117 "S_0[i, -1 + i] -> S_0[1 + i, 0] : i >= 1 and "
5118 "i <= -2 + N }";
5119 P = "{ }";
5120 S = "{ S_0[i, j] -> [i, j] }";
5122 if (test_special_schedule(ctx, D, V, P, S) < 0)
5123 return -1;
5125
5126 /* Test both algorithms on a case with only proximity dependences. */
5127 D = "{ S[i,j] : 0 <= i <= 10 }";
5128 V = "{ }";
5129 P = "{ S[i,j] -> S[i+1,j] : 0 <= i,j <= 10 }";
5130 S = "{ S[i, j] -> [j, i] }";
5132 if (test_special_schedule(ctx, D, V, P, S) < 0)
5133 return -1;
5135 if (test_special_schedule(ctx, D, V, P, S) < 0)
5136 return -1;
5137
5138 D = "{ A[a]; B[] }";
5139 V = "{}";
5140 P = "{ A[a] -> B[] }";
5141 if (test_has_schedule(ctx, D, V, P) < 0)
5142 return -1;
5143
5144 if (test_padded_schedule(ctx) < 0)
5145 return -1;
5146
5147 /* Check that check for progress is not confused by rational
5148 * solution.
5149 */
5150 D = "[N] -> { S0[i, j] : i >= 0 and i <= N and j >= 0 and j <= N }";
5151 V = "[N] -> { S0[i0, -1 + N] -> S0[2 + i0, 0] : i0 >= 0 and "
5152 "i0 <= -2 + N; "
5153 "S0[i0, i1] -> S0[i0, 1 + i1] : i0 >= 0 and "
5154 "i0 <= N and i1 >= 0 and i1 <= -1 + N }";
5155 P = "{}";
5157 if (test_has_schedule(ctx, D, V, P) < 0)
5158 return -1;
5160
5161 /* Check that we allow schedule rows that are only non-trivial
5162 * on some full-dimensional domains.
5163 */
5164 D = "{ S1[j] : 0 <= j <= 1; S0[]; S2[k] : 0 <= k <= 1 }";
5165 V = "{ S0[] -> S1[j] : 0 <= j <= 1; S2[0] -> S0[];"
5166 "S1[j] -> S2[1] : 0 <= j <= 1 }";
5167 P = "{}";
5169 if (test_has_schedule(ctx, D, V, P) < 0)
5170 return -1;
5172
5174 return -1;
5175
5177 return -1;
5178
5180 return -1;
5181
5182 if (test_coalescing_schedule(ctx) < 0)
5183 return -1;
5184 if (test_skewing_schedule(ctx) < 0)
5185 return -1;
5186
5187 return 0;
5188}
5189
5190/* Perform scheduling tests using the whole component scheduler.
5191 */
5193{
5194 int whole;
5195 int r;
5196
5199 r = test_schedule(ctx);
5201
5202 return r;
5203}
5204
5205/* Perform scheduling tests using the incremental scheduler.
5206 */
5208{
5209 int whole;
5210 int r;
5211
5214 r = test_schedule(ctx);
5216
5217 return r;
5218}
5219
5220int test_plain_injective(isl_ctx *ctx, const char *str, int injective)
5221{
5222 isl_union_map *umap;
5223 int test;
5224
5225 umap = isl_union_map_read_from_str(ctx, str);
5227 isl_union_map_free(umap);
5228 if (test < 0)
5229 return -1;
5230 if (test == injective)
5231 return 0;
5232 if (injective)
5234 "map not detected as injective", return -1);
5235 else
5237 "map detected as injective", return -1);
5238}
5239
5241{
5242 const char *str;
5243
5244 if (test_plain_injective(ctx, "{S[i,j] -> A[0]; T[i,j] -> B[1]}", 0))
5245 return -1;
5246 if (test_plain_injective(ctx, "{S[] -> A[0]; T[] -> B[0]}", 1))
5247 return -1;
5248 if (test_plain_injective(ctx, "{S[] -> A[0]; T[] -> A[1]}", 1))
5249 return -1;
5250 if (test_plain_injective(ctx, "{S[] -> A[0]; T[] -> A[0]}", 0))
5251 return -1;
5252 if (test_plain_injective(ctx, "{S[i] -> A[i,0]; T[i] -> A[i,1]}", 1))
5253 return -1;
5254 if (test_plain_injective(ctx, "{S[i] -> A[i]; T[i] -> A[i]}", 0))
5255 return -1;
5256 if (test_plain_injective(ctx, "{S[] -> A[0,0]; T[] -> A[0,1]}", 1))
5257 return -1;
5258 if (test_plain_injective(ctx, "{S[] -> A[0,0]; T[] -> A[1,0]}", 1))
5259 return -1;
5260
5261 str = "{S[] -> A[0,0]; T[] -> A[0,1]; U[] -> A[1,0]}";
5262 if (test_plain_injective(ctx, str, 1))
5263 return -1;
5264 str = "{S[] -> A[0,0]; T[] -> A[0,1]; U[] -> A[0,0]}";
5265 if (test_plain_injective(ctx, str, 0))
5266 return -1;
5267
5268 return 0;
5269}
5270
5271#undef BASE
5272#define BASE aff
5274
5275#undef BASE
5276#define BASE pw_multi_aff
5278
5279#undef BASE
5280#define BASE union_pw_aff
5282
5283/* Basic tests on isl_union_pw_aff.
5284 *
5285 * In particular, check that isl_union_pw_aff_aff_on_domain
5286 * aligns the parameters of the input objects and
5287 * that isl_union_pw_aff_param_on_domain_id properly
5288 * introduces the parameter.
5289 */
5290static int test_upa(isl_ctx *ctx)
5291{
5292 const char *str;
5293 isl_id *id;
5294 isl_aff *aff;
5296 isl_union_pw_aff *upa;
5297 isl_stat ok;
5298
5299 aff = isl_aff_read_from_str(ctx, "[N] -> { [N] }");
5300 str = "[M] -> { A[i] : 0 <= i < M; B[] }";
5303 str = "[N, M] -> { A[i] -> [N] : 0 <= i < M; B[] -> [N] }";
5304 ok = union_pw_aff_check_plain_equal(upa, str);
5306 if (ok < 0)
5307 return -1;
5308
5309 id = isl_id_alloc(ctx, "N", NULL);
5310 str = "[M] -> { A[i] : 0 <= i < M; B[] }";
5313 str = "[N, M] -> { A[i] -> [N] : 0 <= i < M; B[] -> [N] }";
5314 ok = union_pw_aff_check_plain_equal(upa, str);
5316 if (ok < 0)
5317 return -1;
5318
5319 return 0;
5320}
5321
5322struct {
5323 __isl_give isl_aff *(*fn)(__isl_take isl_aff *aff1,
5324 __isl_take isl_aff *aff2);
5325} aff_bin_op[] = {
5326 ['+'] = { &isl_aff_add },
5327 ['-'] = { &isl_aff_sub },
5328 ['*'] = { &isl_aff_mul },
5329 ['/'] = { &isl_aff_div },
5331
5332struct {
5333 const char *arg1;
5334 unsigned char op;
5335 const char *arg2;
5336 const char *res;
5337} aff_bin_tests[] = {
5338 { "{ [i] -> [i] }", '+', "{ [i] -> [i] }",
5339 "{ [i] -> [2i] }" },
5340 { "{ [i] -> [i] }", '-', "{ [i] -> [i] }",
5341 "{ [i] -> [0] }" },
5342 { "{ [i] -> [i] }", '*', "{ [i] -> [2] }",
5343 "{ [i] -> [2i] }" },
5344 { "{ [i] -> [2] }", '*', "{ [i] -> [i] }",
5345 "{ [i] -> [2i] }" },
5346 { "{ [i] -> [i] }", '/', "{ [i] -> [2] }",
5347 "{ [i] -> [i/2] }" },
5348 { "{ [i] -> [2i] }", '/', "{ [i] -> [2] }",
5349 "{ [i] -> [i] }" },
5350 { "{ [i] -> [i] }", '+', "{ [i] -> [NaN] }",
5351 "{ [i] -> [NaN] }" },
5352 { "{ [i] -> [i] }", '-', "{ [i] -> [NaN] }",
5353 "{ [i] -> [NaN] }" },
5354 { "{ [i] -> [i] }", '*', "{ [i] -> [NaN] }",
5355 "{ [i] -> [NaN] }" },
5356 { "{ [i] -> [2] }", '*', "{ [i] -> [NaN] }",
5357 "{ [i] -> [NaN] }" },
5358 { "{ [i] -> [i] }", '/', "{ [i] -> [NaN] }",
5359 "{ [i] -> [NaN] }" },
5360 { "{ [i] -> [2] }", '/', "{ [i] -> [NaN] }",
5361 "{ [i] -> [NaN] }" },
5362 { "{ [i] -> [NaN] }", '+', "{ [i] -> [i] }",
5363 "{ [i] -> [NaN] }" },
5364 { "{ [i] -> [NaN] }", '-', "{ [i] -> [i] }",
5365 "{ [i] -> [NaN] }" },
5366 { "{ [i] -> [NaN] }", '*', "{ [i] -> [2] }",
5367 "{ [i] -> [NaN] }" },
5368 { "{ [i] -> [NaN] }", '*', "{ [i] -> [i] }",
5369 "{ [i] -> [NaN] }" },
5370 { "{ [i] -> [NaN] }", '/', "{ [i] -> [2] }",
5371 "{ [i] -> [NaN] }" },
5372 { "{ [i] -> [NaN] }", '/', "{ [i] -> [i] }",
5373 "{ [i] -> [NaN] }" },
5374 { "{ [i] -> [i] }", '/', "{ [i] -> [0] }",
5375 "{ [i] -> [NaN] }" },
5377
5378/* Perform some basic tests of binary operations on isl_aff objects.
5379 */
5380static int test_bin_aff(isl_ctx *ctx)
5381{
5382 int i;
5383 isl_aff *aff1, *aff2, *res;
5384 __isl_give isl_aff *(*fn)(__isl_take isl_aff *aff1,
5385 __isl_take isl_aff *aff2);
5386 int ok;
5387
5388 for (i = 0; i < ARRAY_SIZE(aff_bin_tests); ++i) {
5392 fn = aff_bin_op[aff_bin_tests[i].op].fn;
5393 aff1 = fn(aff1, aff2);
5394 if (isl_aff_is_nan(res))
5395 ok = isl_aff_is_nan(aff1);
5396 else
5397 ok = isl_aff_plain_is_equal(aff1, res);
5398 isl_aff_free(aff1);
5400 if (ok < 0)
5401 return -1;
5402 if (!ok)
5404 "unexpected result", return -1);
5405 }
5406
5407 return 0;
5408}
5409
5410struct {
5412 __isl_take isl_pw_aff *pa2);
5413} pw_aff_bin_op[] = {
5414 ['m'] = { &isl_pw_aff_min },
5415 ['M'] = { &isl_pw_aff_max },
5417
5418/* Inputs for binary isl_pw_aff operation tests.
5419 * "arg1" and "arg2" are the two arguments, "op" identifies the operation
5420 * defined by pw_aff_bin_op, and "res" is the expected result.
5421 */
5422struct {
5423 const char *arg1;
5424 unsigned char op;
5425 const char *arg2;
5426 const char *res;
5427} pw_aff_bin_tests[] = {
5428 { "{ [i] -> [i] }", 'm', "{ [i] -> [i] }",
5429 "{ [i] -> [i] }" },
5430 { "{ [i] -> [i] }", 'M', "{ [i] -> [i] }",
5431 "{ [i] -> [i] }" },
5432 { "{ [i] -> [i] }", 'm', "{ [i] -> [0] }",
5433 "{ [i] -> [i] : i <= 0; [i] -> [0] : i > 0 }" },
5434 { "{ [i] -> [i] }", 'M', "{ [i] -> [0] }",
5435 "{ [i] -> [i] : i >= 0; [i] -> [0] : i < 0 }" },
5436 { "{ [i] -> [i] }", 'm', "{ [i] -> [NaN] }",
5437 "{ [i] -> [NaN] }" },
5438 { "{ [i] -> [NaN] }", 'm', "{ [i] -> [i] }",
5439 "{ [i] -> [NaN] }" },
5441
5442/* Perform some basic tests of binary operations on isl_pw_aff objects.
5443 */
5444static int test_bin_pw_aff(isl_ctx *ctx)
5445{
5446 int i;
5447 isl_bool ok;
5448 isl_pw_aff *pa1, *pa2, *res;
5449
5450 for (i = 0; i < ARRAY_SIZE(pw_aff_bin_tests); ++i) {
5454 pa1 = pw_aff_bin_op[pw_aff_bin_tests[i].op].fn(pa1, pa2);
5456 ok = isl_pw_aff_involves_nan(pa1);
5457 else
5458 ok = isl_pw_aff_plain_is_equal(pa1, res);
5459 isl_pw_aff_free(pa1);
5461 if (ok < 0)
5462 return -1;
5463 if (!ok)
5465 "unexpected result", return -1);
5466 }
5467
5468 return 0;
5469}
5470
5471/* Inputs for basic tests of test operations on
5472 * isl_union_pw_multi_aff objects.
5473 * "fn" is the function that is being tested.
5474 * "arg" is a string description of the input.
5475 * "res" is the expected result.
5476 */
5477static struct {
5479 const char *arg;
5480 isl_bool res;
5481} upma_test_tests[] = {
5482 { &isl_union_pw_multi_aff_involves_nan, "{ A[] -> [0]; B[0] -> [1] }",
5484 { &isl_union_pw_multi_aff_involves_nan, "{ A[] -> [NaN]; B[0] -> [1] }",
5485 isl_bool_true },
5486 { &isl_union_pw_multi_aff_involves_nan, "{ A[] -> [0]; B[0] -> [NaN] }",
5487 isl_bool_true },
5489 "{ A[] -> [0]; B[0] -> [1, NaN, 5] }",
5490 isl_bool_true },
5492 "{ A[] -> [0]; B[0] -> [1] }",
5495 "{ A[] -> [0]; B[x] -> [1] : x mod 2 = 0 }",
5496 isl_bool_true },
5498 "{ A[] -> [0]; B[x] -> [x // 2] }",
5499 isl_bool_true },
5501 "{ A[i] -> [i // 2]; B[0] -> [1] }",
5502 isl_bool_true },
5504
5505/* Perform some basic tests of test operations on
5506 * isl_union_pw_multi_aff objects.
5507 */
5509{
5510 int i;
5512 isl_bool res;
5513
5514 for (i = 0; i < ARRAY_SIZE(upma_test_tests); ++i) {
5515 const char *str;
5516
5517 str = upma_test_tests[i].arg;
5519 res = upma_test_tests[i].fn(upma);
5521 if (res < 0)
5522 return isl_stat_error;
5523 if (res != upma_test_tests[i].res)
5525 "unexpected result", return isl_stat_error);
5526 }
5527
5528 return isl_stat_ok;
5529}
5530
5531struct {
5535 const char *arg1;
5536 const char *arg2;
5537 const char *res;
5538} upma_bin_tests[] = {
5539 { &isl_union_pw_multi_aff_add, "{ A[] -> [0]; B[0] -> [1] }",
5540 "{ B[x] -> [2] : x >= 0 }", "{ B[0] -> [3] }" },
5541 { &isl_union_pw_multi_aff_union_add, "{ A[] -> [0]; B[0] -> [1] }",
5542 "{ B[x] -> [2] : x >= 0 }",
5543 "{ A[] -> [0]; B[0] -> [3]; B[x] -> [2] : x >= 1 }" },
5545 "{ A[] -> B[0]; C[x] -> B[1] : x < 10; C[y] -> B[2] : y >= 10 }",
5546 "{ D[i] -> A[] : i < 0; D[i] -> C[i + 5] : i >= 0 }",
5547 "{ D[i] -> B[0] : i < 0; D[i] -> B[1] : 0 <= i < 5; "
5548 "D[i] -> B[2] : i >= 5 }" },
5549 { &isl_union_pw_multi_aff_union_add, "{ B[x] -> A[1] : x <= 0 }",
5550 "{ B[x] -> C[2] : x > 0 }",
5551 "{ B[x] -> A[1] : x <= 0; B[x] -> C[2] : x > 0 }" },
5552 { &isl_union_pw_multi_aff_union_add, "{ B[x] -> A[1] : x <= 0 }",
5553 "{ B[x] -> A[2] : x >= 0 }",
5554 "{ B[x] -> A[1] : x < 0; B[x] -> A[2] : x > 0; B[0] -> A[3] }" },
5555 {
5557 "{ B[x] -> C[x + 2] }",
5558 "{ D[y] -> B[2y] }",
5559 "{ }" },
5560 {
5562 "{ [A[x] -> B[x + 1]] -> C[x + 2] }",
5563 "{ D[y] -> B[2y] }",
5564 "{ }" },
5565 {
5567 "{ [A[x] -> B[x + 1]] -> C[x + 2]; B[x] -> C[x + 2] }",
5568 "{ D[y] -> A[2y] }",
5569 "{ [D[y] -> B[2y + 1]] -> C[2y + 2] }" },
5570 {
5572 "{ T[A[x] -> B[x + 1]] -> C[x + 2]; B[x] -> C[x + 2] }",
5573 "{ D[y] -> A[2y] }",
5574 "{ T[D[y] -> B[2y + 1]] -> C[2y + 2] }" },
5576
5577/* Perform some basic tests of binary operations on
5578 * isl_union_pw_multi_aff objects.
5579 */
5580static int test_bin_upma(isl_ctx *ctx)
5581{
5582 int i;
5583 isl_union_pw_multi_aff *upma1, *upma2, *res;
5584 int ok;
5585
5586 for (i = 0; i < ARRAY_SIZE(upma_bin_tests); ++i) {
5588 upma_bin_tests[i].arg1);
5590 upma_bin_tests[i].arg2);
5592 upma_bin_tests[i].res);
5593 upma1 = upma_bin_tests[i].fn(upma1, upma2);
5597 if (ok < 0)
5598 return -1;
5599 if (!ok)
5601 "unexpected result", return -1);
5602 }
5603
5604 return 0;
5605}
5606
5607struct {
5611 const char *arg1;
5612 const char *arg2;
5613} upma_bin_fail_tests[] = {
5614 { &isl_union_pw_multi_aff_union_add, "{ B[x] -> A[1] : x <= 0 }",
5615 "{ B[x] -> C[2] : x >= 0 }" },
5617
5618/* Perform some basic tests of binary operations on
5619 * isl_union_pw_multi_aff objects that are expected to fail.
5620 */
5622{
5623 int i, n;
5624 isl_union_pw_multi_aff *upma1, *upma2;
5625 int on_error;
5626
5630 for (i = 0; i < n; ++i) {
5635 upma1 = upma_bin_fail_tests[i].fn(upma1, upma2);
5637 if (upma1)
5638 break;
5639 }
5641 if (i < n)
5643 "operation not expected to succeed", return -1);
5644
5645 return 0;
5646}
5647
5648/* Inputs for basic tests of binary operations on
5649 * pairs of isl_union_pw_multi_aff and isl_union_set objects.
5650 * "fn" is the function that is being tested.
5651 * "arg1" and "arg2" are string descriptions of the inputs.
5652 * "res" is a string description of the expected result.
5653 */
5654struct {
5658 const char *arg1;
5659 const char *arg2;
5660 const char *res;
5661} upma_uset_tests[] = {
5663 "{ A[i] -> B[i] }", "{ B[0] }",
5664 "{ }" },
5666 "{ [A[i] -> B[i]] -> C[i + 1] }", "{ A[1]; B[0] }",
5667 "{ [A[1] -> B[1]] -> C[2] }" },
5669 "{ [A[i] -> B[i]] -> C[i + 1] }", "{ A[1]; B[0] }",
5670 "{ [A[0] -> B[0]] -> C[1] }" },
5672 "{ [A[i] -> B[i]] -> C[i + 1] }", "[N] -> { B[N] }",
5673 "[N] -> { [A[N] -> B[N]] -> C[N + 1] }" },
5675 "[M] -> { [A[M] -> B[M]] -> C[M + 1] }", "[N] -> { B[N] }",
5676 "[N, M] -> { [A[N] -> B[N]] -> C[N + 1] : N = M }" },
5678 "{ [A[] -> B[]] -> C[]; N[A[] -> B[]] -> D[]; [B[] -> A[]] -> E[] }",
5679 "{ B[] }",
5680 "{ [A[] -> B[]] -> C[]; N[A[] -> B[]] -> D[] }" },
5682
5683/* Perform some basic tests of binary operations on
5684 * pairs of isl_union_pw_multi_aff and isl_union_set objects.
5685 */
5687{
5688 int i;
5689 isl_bool ok;
5691 isl_union_set *uset;
5692
5693 for (i = 0; i < ARRAY_SIZE(upma_uset_tests); ++i) {
5696 uset = isl_union_set_read_from_str(ctx,
5699 upma_uset_tests[i].res);
5700 upma = upma_uset_tests[i].fn(upma, uset);
5704 if (ok < 0)
5705 return isl_stat_error;
5706 if (!ok)
5708 "unexpected result", return isl_stat_error);
5709 }
5710
5711 return isl_stat_ok;
5712}
5713
5714/* Inputs for basic tests of unary operations on isl_multi_pw_aff objects.
5715 * "fn" is the function that is tested.
5716 * "arg" is a string description of the input.
5717 * "res" is a string description of the expected result.
5718 */
5719struct {
5721 const char *arg;
5722 const char *res;
5723} mpa_un_tests[] = {
5724 { &isl_multi_pw_aff_range_factor_domain,
5725 "{ A[x] -> [B[(1 : x >= 5)] -> C[(2 : x <= 10)]] }",
5726 "{ A[x] -> B[(1 : x >= 5)] }" },
5727 { &isl_multi_pw_aff_range_factor_range,
5728 "{ A[x] -> [B[(1 : x >= 5)] -> C[(2 : x <= 10)]] }",
5729 "{ A[y] -> C[(2 : y <= 10)] }" },
5730 { &isl_multi_pw_aff_range_factor_domain,
5731 "{ A[x] -> [B[(1 : x >= 5)] -> C[]] }",
5732 "{ A[x] -> B[(1 : x >= 5)] }" },
5733 { &isl_multi_pw_aff_range_factor_range,
5734 "{ A[x] -> [B[(1 : x >= 5)] -> C[]] }",
5735 "{ A[y] -> C[] }" },
5736 { &isl_multi_pw_aff_range_factor_domain,
5737 "{ A[x] -> [B[] -> C[(2 : x <= 10)]] }",
5738 "{ A[x] -> B[] }" },
5739 { &isl_multi_pw_aff_range_factor_range,
5740 "{ A[x] -> [B[] -> C[(2 : x <= 10)]] }",
5741 "{ A[y] -> C[(2 : y <= 10)] }" },
5742 { &isl_multi_pw_aff_range_factor_domain,
5743 "{ A[x] -> [B[] -> C[]] }",
5744 "{ A[x] -> B[] }" },
5745 { &isl_multi_pw_aff_range_factor_range,
5746 "{ A[x] -> [B[] -> C[]] }",
5747 "{ A[y] -> C[] }" },
5748 { &isl_multi_pw_aff_factor_range,
5749 "{ [B[] -> C[]] }",
5750 "{ C[] }" },
5751 { &isl_multi_pw_aff_range_factor_domain,
5752 "{ A[x] -> [B[] -> C[]] : x >= 0 }",
5753 "{ A[x] -> B[] : x >= 0 }" },
5754 { &isl_multi_pw_aff_range_factor_range,
5755 "{ A[x] -> [B[] -> C[]] : x >= 0 }",
5756 "{ A[y] -> C[] : y >= 0 }" },
5757 { &isl_multi_pw_aff_factor_range,
5758 "[N] -> { [B[] -> C[]] : N >= 0 }",
5759 "[N] -> { C[] : N >= 0 }" },
5761
5762/* Perform some basic tests of unary operations on isl_multi_pw_aff objects.
5763 */
5764static int test_un_mpa(isl_ctx *ctx)
5765{
5766 int i;
5767 isl_bool ok;
5768 isl_multi_pw_aff *mpa, *res;
5769
5770 for (i = 0; i < ARRAY_SIZE(mpa_un_tests); ++i) {
5773 mpa = mpa_un_tests[i].fn(mpa);
5774 ok = isl_multi_pw_aff_plain_is_equal(mpa, res);
5775 isl_multi_pw_aff_free(mpa);
5776 isl_multi_pw_aff_free(res);
5777 if (ok < 0)
5778 return -1;
5779 if (!ok)
5781 "unexpected result", return -1);
5782 }
5783
5784 return 0;
5785}
5786
5787/* Inputs for basic tests of binary operations on isl_multi_pw_aff objects.
5788 * "fn" is the function that is tested.
5789 * "arg1" and "arg2" are string descriptions of the inputs.
5790 * "res" is a string description of the expected result.
5791 */
5792struct {
5796 const char *arg1;
5797 const char *arg2;
5798 const char *res;
5799} mpa_bin_tests[] = {
5800 { &isl_multi_pw_aff_add, "{ A[] -> [1] }", "{ A[] -> [2] }",
5801 "{ A[] -> [3] }" },
5802 { &isl_multi_pw_aff_add, "{ A[x] -> [(1 : x >= 5)] }",
5803 "{ A[x] -> [(x : x <= 10)] }",
5804 "{ A[x] -> [(1 + x : 5 <= x <= 10)] }" },
5805 { &isl_multi_pw_aff_add, "{ A[x] -> [] : x >= 5 }",
5806 "{ A[x] -> [] : x <= 10 }",
5807 "{ A[x] -> [] : 5 <= x <= 10 }" },
5808 { &isl_multi_pw_aff_add, "{ A[x] -> [] : x >= 5 }",
5809 "[N] -> { A[x] -> [] : x <= N }",
5810 "[N] -> { A[x] -> [] : 5 <= x <= N }" },
5811 { &isl_multi_pw_aff_add,
5812 "[N] -> { A[x] -> [] : x <= N }",
5813 "{ A[x] -> [] : x >= 5 }",
5814 "[N] -> { A[x] -> [] : 5 <= x <= N }" },
5815 { &isl_multi_pw_aff_range_product, "{ A[x] -> B[(1 : x >= 5)] }",
5816 "{ A[y] -> C[(2 : y <= 10)] }",
5817 "{ A[x] -> [B[(1 : x >= 5)] -> C[(2 : x <= 10)]] }" },
5818 { &isl_multi_pw_aff_range_product, "{ A[x] -> B[1] : x >= 5 }",
5819 "{ A[y] -> C[2] : y <= 10 }",
5820 "{ A[x] -> [B[(1 : x >= 5)] -> C[(2 : x <= 10)]] }" },
5821 { &isl_multi_pw_aff_range_product, "{ A[x] -> B[1] : x >= 5 }",
5822 "[N] -> { A[y] -> C[2] : y <= N }",
5823 "[N] -> { A[x] -> [B[(1 : x >= 5)] -> C[(2 : x <= N)]] }" },
5824 { &isl_multi_pw_aff_range_product, "[N] -> { A[x] -> B[1] : x >= N }",
5825 "{ A[y] -> C[2] : y <= 10 }",
5826 "[N] -> { A[x] -> [B[(1 : x >= N)] -> C[(2 : x <= 10)]] }" },
5827 { &isl_multi_pw_aff_range_product, "{ A[] -> B[1] }", "{ A[] -> C[2] }",
5828 "{ A[] -> [B[1] -> C[2]] }" },
5829 { &isl_multi_pw_aff_range_product, "{ A[] -> B[] }", "{ A[] -> C[] }",
5830 "{ A[] -> [B[] -> C[]] }" },
5831 { &isl_multi_pw_aff_range_product, "{ A[x] -> B[(1 : x >= 5)] }",
5832 "{ A[y] -> C[] : y <= 10 }",
5833 "{ A[x] -> [B[(1 : x >= 5)] -> C[]] : x <= 10 }" },
5834 { &isl_multi_pw_aff_range_product, "{ A[y] -> C[] : y <= 10 }",
5835 "{ A[x] -> B[(1 : x >= 5)] }",
5836 "{ A[x] -> [C[] -> B[(1 : x >= 5)]] : x <= 10 }" },
5837 { &isl_multi_pw_aff_product, "{ A[x] -> B[(1 : x >= 5)] }",
5838 "{ A[y] -> C[(2 : y <= 10)] }",
5839 "{ [A[x] -> A[y]] -> [B[(1 : x >= 5)] -> C[(2 : y <= 10)]] }" },
5840 { &isl_multi_pw_aff_product, "{ A[x] -> B[(1 : x >= 5)] }",
5841 "{ A[y] -> C[] : y <= 10 }",
5842 "{ [A[x] -> A[y]] -> [B[(1 : x >= 5)] -> C[]] : y <= 10 }" },
5843 { &isl_multi_pw_aff_product, "{ A[y] -> C[] : y <= 10 }",
5844 "{ A[x] -> B[(1 : x >= 5)] }",
5845 "{ [A[y] -> A[x]] -> [C[] -> B[(1 : x >= 5)]] : y <= 10 }" },
5846 { &isl_multi_pw_aff_product, "{ A[x] -> B[(1 : x >= 5)] }",
5847 "[N] -> { A[y] -> C[] : y <= N }",
5848 "[N] -> { [A[x] -> A[y]] -> [B[(1 : x >= 5)] -> C[]] : y <= N }" },
5849 { &isl_multi_pw_aff_product, "[N] -> { A[y] -> C[] : y <= N }",
5850 "{ A[x] -> B[(1 : x >= 5)] }",
5851 "[N] -> { [A[y] -> A[x]] -> [C[] -> B[(1 : x >= 5)]] : y <= N }" },
5852 { &isl_multi_pw_aff_product, "{ A[x] -> B[] : x >= 5 }",
5853 "{ A[y] -> C[] : y <= 10 }",
5854 "{ [A[x] -> A[y]] -> [B[] -> C[]] : x >= 5 and y <= 10 }" },
5855 { &isl_multi_pw_aff_product, "{ A[] -> B[1] }", "{ A[] -> C[2] }",
5856 "{ [A[] -> A[]] -> [B[1] -> C[2]] }" },
5857 { &isl_multi_pw_aff_product, "{ A[] -> B[] }", "{ A[] -> C[] }",
5858 "{ [A[] -> A[]] -> [B[] -> C[]] }" },
5860 "{ B[i,j] -> C[i + 2j] }", "{ A[a,b] -> B[b,a] }",
5861 "{ A[a,b] -> C[b + 2a] }" },
5863 "{ B[i,j] -> C[i + 2j] }",
5864 "{ A[a,b] -> B[(b : b > a),(a : b > a)] }",
5865 "{ A[a,b] -> C[(b + 2a : b > a)] }" },
5867 "{ B[i,j] -> C[(i + 2j : j > 4)] }",
5868 "{ A[a,b] -> B[(b : b > a),(a : b > a)] }",
5869 "{ A[a,b] -> C[(b + 2a : b > a > 4)] }" },
5871 "{ B[i,j] -> C[] }",
5872 "{ A[a,b] -> B[(b : b > a),(a : b > a)] }",
5873 "{ A[a,b] -> C[] }" },
5875 "{ B[i,j] -> C[] : i > j }",
5876 "{ A[a,b] -> B[b,a] }",
5877 "{ A[a,b] -> C[] : b > a }" },
5879 "{ B[i,j] -> C[] : j > 5 }",
5880 "{ A[a,b] -> B[(b : b > a),(a : b > a)] }",
5881 "{ A[a,b] -> C[] : b > a > 5 }" },
5883 "[N] -> { B[i,j] -> C[] : j > N }",
5884 "{ A[a,b] -> B[(b : b > a),(a : b > a)] }",
5885 "[N] -> { A[a,b] -> C[] : b > a > N }" },
5887 "[M,N] -> { B[] -> C[] : N > 5 }",
5888 "[M,N] -> { A[] -> B[] : M > N }",
5889 "[M,N] -> { A[] -> C[] : M > N > 5 }" },
5891
5892/* Perform some basic tests of binary operations on isl_multi_pw_aff objects.
5893 */
5894static int test_bin_mpa(isl_ctx *ctx)
5895{
5896 int i;
5897 isl_bool ok;
5898 isl_multi_pw_aff *mpa1, *mpa2, *res;
5899
5900 for (i = 0; i < ARRAY_SIZE(mpa_bin_tests); ++i) {
5902 mpa_bin_tests[i].arg1);
5904 mpa_bin_tests[i].arg2);
5906 mpa_bin_tests[i].res);
5907 mpa1 = mpa_bin_tests[i].fn(mpa1, mpa2);
5908 ok = isl_multi_pw_aff_plain_is_equal(mpa1, res);
5909 isl_multi_pw_aff_free(mpa1);
5910 isl_multi_pw_aff_free(res);
5911 if (ok < 0)
5912 return -1;
5913 if (!ok)
5915 "unexpected result", return -1);
5916 }
5917
5918 return 0;
5919}
5920
5921/* Inputs for basic tests of unary operations on
5922 * isl_multi_union_pw_aff objects.
5923 * "fn" is the function that is tested.
5924 * "arg" is a string description of the input.
5925 * "res" is a string description of the expected result.
5926 */
5927struct {
5930 const char *arg;
5931 const char *res;
5932} mupa_un_tests[] = {
5933 { &isl_multi_union_pw_aff_factor_range,
5934 "[B[{ A[] -> [1] }] -> C[{ A[] -> [2] }]]",
5935 "C[{ A[] -> [2] }]" },
5936 { &isl_multi_union_pw_aff_factor_range,
5937 "[B[] -> C[{ A[] -> [2] }]]",
5938 "C[{ A[] -> [2] }]" },
5939 { &isl_multi_union_pw_aff_factor_range,
5940 "[B[{ A[] -> [1] }] -> C[]]",
5941 "C[]" },
5942 { &isl_multi_union_pw_aff_factor_range,
5943 "[B[] -> C[]]",
5944 "C[]" },
5945 { &isl_multi_union_pw_aff_factor_range,
5946 "([B[] -> C[]] : { A[x] : x >= 0 })",
5947 "(C[] : { A[x] : x >= 0 })" },
5948 { &isl_multi_union_pw_aff_factor_range,
5949 "[N] -> ([B[] -> C[]] : { A[x] : x <= N })",
5950 "[N] -> (C[] : { A[x] : x <= N })" },
5951 { &isl_multi_union_pw_aff_factor_range,
5952 "[N] -> ([B[] -> C[]] : { : N >= 0 })",
5953 "[N] -> (C[] : { : N >= 0 })" },
5955
5956/* Perform some basic tests of unary operations on
5957 * isl_multi_union_pw_aff objects.
5958 */
5959static int test_un_mupa(isl_ctx *ctx)
5960{
5961 int i;
5962 isl_bool ok;
5964
5965 for (i = 0; i < ARRAY_SIZE(mupa_un_tests); ++i) {
5967 mupa_un_tests[i].arg);
5969 mupa_un_tests[i].res);
5970 mupa = mupa_un_tests[i].fn(mupa);
5971 ok = isl_multi_union_pw_aff_plain_is_equal(mupa, res);
5972 isl_multi_union_pw_aff_free(mupa);
5973 isl_multi_union_pw_aff_free(res);
5974 if (ok < 0)
5975 return -1;
5976 if (!ok)
5978 "unexpected result", return -1);
5979 }
5980
5981 return 0;
5982}
5983
5984/* Inputs for basic tests of binary operations on
5985 * isl_multi_union_pw_aff objects.
5986 * "fn" is the function that is tested.
5987 * "arg1" and "arg2" are string descriptions of the inputs.
5988 * "res" is a string description of the expected result.
5989 */
5990struct {
5994 const char *arg1;
5995 const char *arg2;
5996 const char *res;
5997} mupa_bin_tests[] = {
5998 { &isl_multi_union_pw_aff_add, "[{ A[] -> [1] }]", "[{ A[] -> [2] }]",
5999 "[{ A[] -> [3] }]" },
6000 { &isl_multi_union_pw_aff_sub, "[{ A[] -> [1] }]", "[{ A[] -> [2] }]",
6001 "[{ A[] -> [-1] }]" },
6002 { &isl_multi_union_pw_aff_add,
6003 "[{ A[] -> [1]; B[] -> [4] }]",
6004 "[{ A[] -> [2]; C[] -> [5] }]",
6005 "[{ A[] -> [3] }]" },
6007 "[{ A[] -> [1]; B[] -> [4] }]",
6008 "[{ A[] -> [2]; C[] -> [5] }]",
6009 "[{ A[] -> [3]; B[] -> [4]; C[] -> [5] }]" },
6010 { &isl_multi_union_pw_aff_add, "[{ A[x] -> [(1)] : x >= 5 }]",
6011 "[{ A[x] -> [(x)] : x <= 10 }]",
6012 "[{ A[x] -> [(1 + x)] : 5 <= x <= 10 }]" },
6013 { &isl_multi_union_pw_aff_add, "([] : { A[x] : x >= 5 })",
6014 "([] : { A[x] : x <= 10 })",
6015 "([] : { A[x] : 5 <= x <= 10 })" },
6016 { &isl_multi_union_pw_aff_add, "([] : { A[x] : x >= 5 })",
6017 "[N] -> ([] : { A[x] : x <= N })",
6018 "[N] -> ([] : { A[x] : 5 <= x <= N })" },
6019 { &isl_multi_union_pw_aff_add, "[N] -> ([] : { A[x] : x >= N })",
6020 "([] : { A[x] : x <= 10 })",
6021 "[N] -> ([] : { A[x] : N <= x <= 10 })" },
6022 { &isl_multi_union_pw_aff_union_add, "[{ A[x] -> [(1)] : x >= 5 }]",
6023 "[{ A[x] -> [(x)] : x <= 10 }]",
6024 "[{ A[x] -> [(1 + x)] : 5 <= x <= 10; "
6025 "A[x] -> [(1)] : x > 10; A[x] -> [(x)] : x < 5 }]" },
6026 { &isl_multi_union_pw_aff_union_add, "([] : { A[x] : x >= 5 })",
6027 "([] : { A[x] : x <= 10 })",
6028 "([] : { A[x] })" },
6029 { &isl_multi_union_pw_aff_union_add, "([] : { A[x] : x >= 0 })",
6030 "[N] -> ([] : { A[x] : x >= N })",
6031 "[N] -> ([] : { A[x] : x >= 0 or x >= N })" },
6033 "[N] -> ([] : { A[] : N >= 0})",
6034 "[N] -> ([] : { A[] : N <= 0})",
6035 "[N] -> ([] : { A[] })" },
6037 "[N] -> ([] : { A[] })",
6038 "[N] -> ([] : { : })",
6039 "[N] -> ([] : { : })" },
6041 "[N] -> ([] : { : })",
6042 "[N] -> ([] : { A[] })",
6043 "[N] -> ([] : { : })" },
6045 "[N] -> ([] : { : N >= 0})",
6046 "[N] -> ([] : { : N <= 0})",
6047 "[N] -> ([] : { : })" },
6048 { &isl_multi_union_pw_aff_range_product,
6049 "B[{ A[] -> [1] }]",
6050 "C[{ A[] -> [2] }]",
6051 "[B[{ A[] -> [1] }] -> C[{ A[] -> [2] }]]" },
6052 { &isl_multi_union_pw_aff_range_product,
6053 "(B[] : { A[x] : x >= 5 })",
6054 "(C[] : { A[x] : x <= 10 })",
6055 "([B[] -> C[]] : { A[x] : 5 <= x <= 10 })" },
6056 { &isl_multi_union_pw_aff_range_product,
6057 "B[{ A[x] -> [x + 1] : x >= 5 }]",
6058 "(C[] : { A[x] : x <= 10 })",
6059 "[B[{ A[x] -> [x + 1] : 5 <= x <= 10 }] -> C[]]" },
6060 { &isl_multi_union_pw_aff_range_product,
6061 "(C[] : { A[x] : x <= 10 })",
6062 "B[{ A[x] -> [x + 1] : x >= 5 }]",
6063 "[C[] -> B[{ A[x] -> [x + 1] : 5 <= x <= 10 }]]" },
6064 { &isl_multi_union_pw_aff_range_product,
6065 "B[{ A[x] -> [x + 1] : x >= 5 }]",
6066 "[N] -> (C[] : { A[x] : x <= N })",
6067 "[N] -> [B[{ A[x] -> [x + 1] : 5 <= x <= N }] -> C[]]" },
6068 { &isl_multi_union_pw_aff_range_product,
6069 "[N] -> (C[] : { A[x] : x <= N })",
6070 "B[{ A[x] -> [x + 1] : x >= 5 }]",
6071 "[N] -> [C[] -> B[{ A[x] -> [x + 1] : 5 <= x <= N }]]" },
6072 { &isl_multi_union_pw_aff_range_product,
6073 "B[{ A[] -> [1]; D[] -> [3] }]",
6074 "C[{ A[] -> [2] }]",
6075 "[B[{ A[] -> [1]; D[] -> [3] }] -> C[{ A[] -> [2] }]]" },
6076 { &isl_multi_union_pw_aff_range_product,
6077 "B[] }]",
6078 "(C[] : { A[x] })",
6079 "([B[] -> C[]] : { A[x] })" },
6080 { &isl_multi_union_pw_aff_range_product,
6081 "(B[] : { A[x] })",
6082 "C[] }]",
6083 "([B[] -> C[]] : { A[x] })" },
6085
6086/* Perform some basic tests of binary operations on
6087 * isl_multi_union_pw_aff objects.
6088 */
6089static int test_bin_mupa(isl_ctx *ctx)
6090{
6091 int i;
6092 isl_bool ok;
6093 isl_multi_union_pw_aff *mupa1, *mupa2, *res;
6094
6095 for (i = 0; i < ARRAY_SIZE(mupa_bin_tests); ++i) {
6097 mupa_bin_tests[i].arg1);
6099 mupa_bin_tests[i].arg2);
6101 mupa_bin_tests[i].res);
6102 mupa1 = mupa_bin_tests[i].fn(mupa1, mupa2);
6103 ok = isl_multi_union_pw_aff_plain_is_equal(mupa1, res);
6104 isl_multi_union_pw_aff_free(mupa1);
6105 isl_multi_union_pw_aff_free(res);
6106 if (ok < 0)
6107 return -1;
6108 if (!ok)
6110 "unexpected result", return -1);
6111 }
6112
6113 return 0;
6114}
6115
6116/* Inputs for basic tests of binary operations on
6117 * pairs of isl_multi_union_pw_aff and isl_set objects.
6118 * "fn" is the function that is tested.
6119 * "arg1" and "arg2" are string descriptions of the inputs.
6120 * "res" is a string description of the expected result.
6121 */
6122struct {
6126 const char *arg1;
6127 const char *arg2;
6128 const char *res;
6129} mupa_set_tests[] = {
6131 "C[{ B[i,j] -> [i + 2j] }]", "{ C[1] }",
6132 "C[{ B[i,j] -> [i + 2j] : i + 2j = 1 }]" },
6134 "C[{ B[i,j] -> [i + 2j] }]", "[N] -> { C[N] }",
6135 "[N] -> C[{ B[i,j] -> [i + 2j] : i + 2j = N }]" },
6137 "[N] -> C[{ B[i,j] -> [i + 2j + N] }]", "{ C[1] }",
6138 "[N] -> C[{ B[i,j] -> [i + 2j + N] : i + 2j + N = 1 }]" },
6140 "C[{ B[i,j] -> [i + 2j] }]", "[N] -> { C[x] : N >= 0 }",
6141 "[N] -> C[{ B[i,j] -> [i + 2j] : N >= 0 }]" },
6143 "C[]", "{ C[] }", "C[]" },
6145 "[N] -> (C[] : { : N >= 0 })",
6146 "{ C[] }",
6147 "[N] -> (C[] : { : N >= 0 })" },
6149 "(C[] : { A[a,b] })",
6150 "{ C[] }",
6151 "(C[] : { A[a,b] })" },
6153 "[N] -> (C[] : { A[a,b] : a,b <= N })",
6154 "{ C[] }",
6155 "[N] -> (C[] : { A[a,b] : a,b <= N })" },
6157 "C[]",
6158 "[N] -> { C[] : N >= 0 }",
6159 "[N] -> (C[] : { : N >= 0 })" },
6161 "(C[] : { A[a,b] })",
6162 "[N] -> { C[] : N >= 0 }",
6163 "[N] -> (C[] : { A[a,b] : N >= 0 })" },
6165 "[N] -> (C[] : { : N >= 0 })",
6166 "[N] -> { C[] : N < 1024 }",
6167 "[N] -> (C[] : { : 0 <= N < 1024 })" },
6169 "C[{ B[i,j] -> [i + 2j] }]", "[N] -> { : N >= 0 }",
6170 "[N] -> C[{ B[i,j] -> [i + 2j] : N >= 0}]" },
6172 "[N] -> C[{ B[i,j] -> [i + 2j] : N <= 256 }]", "[N] -> { : N >= 0 }",
6173 "[N] -> C[{ B[i,j] -> [i + 2j] : 0 <= N <= 256 }]" },
6175 "[N] -> C[{ B[i,j] -> [i + 2j] : N <= 256 }]", "{ : }",
6176 "[N] -> C[{ B[i,j] -> [i + 2j] : N <= 256 }]" },
6178 "C[]", "[N] -> { : N >= 0 }",
6179 "[N] -> (C[] : { : N >= 0 })" },
6181 "(C[] : { A[a,b] })", "[N] -> { : N >= 0 }",
6182 "[N] -> (C[] : { A[a,b] : N >= 0 })" },
6184 "[N] -> (C[] : { A[a,N] })", "{ : }",
6185 "[N] -> (C[] : { A[a,N] })" },
6187 "[N] -> (C[] : { A[a,b] : N <= 256 })", "[N] -> { : N >= 0 }",
6188 "[N] -> (C[] : { A[a,b] : 0 <= N <= 256 })" },
6190
6191/* Perform some basic tests of binary operations on
6192 * pairs of isl_multi_union_pw_aff and isl_set objects.
6193 */
6194static int test_mupa_set(isl_ctx *ctx)
6195{
6196 int i;
6197 isl_bool ok;
6199 isl_set *set;
6200
6201 for (i = 0; i < ARRAY_SIZE(mupa_set_tests); ++i) {
6203 mupa_set_tests[i].arg1);
6206 mupa_set_tests[i].res);
6207 mupa = mupa_set_tests[i].fn(mupa, set);
6208 ok = isl_multi_union_pw_aff_plain_is_equal(mupa, res);
6209 isl_multi_union_pw_aff_free(mupa);
6210 isl_multi_union_pw_aff_free(res);
6211 if (ok < 0)
6212 return -1;
6213 if (!ok)
6215 "unexpected result", return -1);
6216 }
6217
6218 return 0;
6219}
6220
6221/* Inputs for basic tests of binary operations on
6222 * pairs of isl_multi_union_pw_aff and isl_union_set objects.
6223 * "fn" is the function that is tested.
6224 * "arg1" and "arg2" are string descriptions of the inputs.
6225 * "res" is a string description of the expected result.
6226 */
6227struct {
6231 const char *arg1;
6232 const char *arg2;
6233 const char *res;
6234} mupa_uset_tests[] = {
6236 "C[{ B[i,j] -> [i + 2j] }]", "{ B[i,i] }",
6237 "C[{ B[i,i] -> [3i] }]" },
6239 "(C[] : { B[i,j] })", "{ B[i,i] }",
6240 "(C[] : { B[i,i] })" },
6242 "(C[] : { B[i,j] })", "[N] -> { B[N,N] }",
6243 "[N] -> (C[] : { B[N,N] })" },
6245 "C[]", "{ B[i,i] }",
6246 "(C[] : { B[i,i] })" },
6248 "[N] -> (C[] : { : N >= 0 })", "{ B[i,i] }",
6249 "[N] -> (C[] : { B[i,i] : N >= 0 })" },
6251
6252/* Perform some basic tests of binary operations on
6253 * pairs of isl_multi_union_pw_aff and isl_union_set objects.
6254 */
6255static int test_mupa_uset(isl_ctx *ctx)
6256{
6257 int i;
6258 isl_bool ok;
6260 isl_union_set *uset;
6261
6262 for (i = 0; i < ARRAY_SIZE(mupa_uset_tests); ++i) {
6265 uset = isl_union_set_read_from_str(ctx,
6268 mupa_uset_tests[i].res);
6269 mupa = mupa_uset_tests[i].fn(mupa, uset);
6270 ok = isl_multi_union_pw_aff_plain_is_equal(mupa, res);
6271 isl_multi_union_pw_aff_free(mupa);
6272 isl_multi_union_pw_aff_free(res);
6273 if (ok < 0)
6274 return -1;
6275 if (!ok)
6277 "unexpected result", return -1);
6278 }
6279
6280 return 0;
6281}
6282
6283/* Inputs for basic tests of binary operations on
6284 * pairs of isl_multi_union_pw_aff and isl_multi_aff objects.
6285 * "fn" is the function that is tested.
6286 * "arg1" and "arg2" are string descriptions of the inputs.
6287 * "res" is a string description of the expected result.
6288 */
6289struct {
6293 const char *arg1;
6294 const char *arg2;
6295 const char *res;
6296} mupa_ma_tests[] = {
6298 "C[{ A[i,j] -> [i]; B[i,j] -> [j] }, "
6299 "{ A[i,j] -> [j]; B[i,j] -> [i] }]",
6300 "{ C[a,b] -> D[b,a] }",
6301 "D[{ A[i,j] -> [j]; B[i,j] -> [i] }, "
6302 "{ A[i,j] -> [i]; B[i,j] -> [j] }]" },
6304 "C[{ A[i,j] -> [i] : i >= 0; B[i,j] -> [j] }, "
6305 "{ A[i,j] -> [j]; B[i,j] -> [i] }]",
6306 "{ C[a,b] -> D[b,a] }",
6307 "D[{ A[i,j] -> [j] : i >= 0; B[i,j] -> [i] }, "
6308 "{ A[i,j] -> [i] : i >= 0; B[i,j] -> [j] }]" },
6310 "C[{ A[i,j] -> [i]; B[i,j] -> [j] }]",
6311 "[N] -> { C[a] -> D[a + N] }",
6312 "[N] -> D[{ A[i,j] -> [i + N]; B[i,j] -> [j + N] }] " },
6314 "C[]",
6315 "{ C[] -> D[] }",
6316 "D[]" },
6318 "[N] -> (C[] : { : N >= 0 })",
6319 "{ C[] -> D[] }",
6320 "[N] -> (D[] : { : N >= 0 })" },
6322 "C[]",
6323 "[N] -> { C[] -> D[N] }",
6324 "[N] -> D[{ [N] }]" },
6326 "(C[] : { A[i,j] : i >= j })",
6327 "{ C[] -> D[] }",
6328 "(D[] : { A[i,j] : i >= j })" },
6330 "[N] -> (C[] : { A[i,j] : N >= 0 })",
6331 "{ C[] -> D[] }",
6332 "[N] -> (D[] : { A[i,j] : N >= 0 })" },
6334 "(C[] : { A[i,j] : i >= j })",
6335 "[N] -> { C[] -> D[N] }",
6336 "[N] -> (D[{ A[i,j] -> [N] : i >= j }])" },
6338
6339/* Perform some basic tests of binary operations on
6340 * pairs of isl_multi_union_pw_aff and isl_multi_aff objects.
6341 */
6342static int test_mupa_ma(isl_ctx *ctx)
6343{
6344 int i;
6345 isl_bool ok;
6348
6349 for (i = 0; i < ARRAY_SIZE(mupa_ma_tests); ++i) {
6351 mupa_ma_tests[i].arg1);
6354 mupa_ma_tests[i].res);
6355 mupa = mupa_ma_tests[i].fn(mupa, ma);
6356 ok = isl_multi_union_pw_aff_plain_is_equal(mupa, res);
6357 isl_multi_union_pw_aff_free(mupa);
6358 isl_multi_union_pw_aff_free(res);
6359 if (ok < 0)
6360 return -1;
6361 if (!ok)
6363 "unexpected result", return -1);
6364 }
6365
6366 return 0;
6367}
6368
6369/* Inputs for basic tests of binary operations on
6370 * pairs of isl_multi_union_pw_aff and isl_pw_aff objects.
6371 * "fn" is the function that is tested.
6372 * "arg1" and "arg2" are string descriptions of the inputs.
6373 * "res" is a string description of the expected result.
6374 */
6375struct {
6379 const char *arg1;
6380 const char *arg2;
6381 const char *res;
6382} mupa_pa_tests[] = {
6384 "C[{ A[i,j] -> [i]; B[i,j] -> [j] }]",
6385 "[N] -> { C[a] -> [a + N] }",
6386 "[N] -> { A[i,j] -> [i + N]; B[i,j] -> [j + N] }" },
6388 "C[{ A[i,j] -> [i]; B[i,j] -> [j] }]",
6389 "{ C[a] -> [a] : a >= 0; C[a] -> [-a] : a < 0 }",
6390 "{ A[i,j] -> [i] : i >= 0; A[i,j] -> [-i] : i < 0; "
6391 "B[i,j] -> [j] : j >= 0; B[i,j] -> [-j] : j < 0 }" },
6393 "C[]",
6394 "[N] -> { C[] -> [N] }",
6395 "[N] -> { [N] }" },
6397 "C[]",
6398 "[N] -> { C[] -> [N] : N >= 0; C[] -> [-N] : N < 0 }",
6399 "[N] -> { [N] : N >= 0; [-N] : N < 0 }" },
6401 "[N] -> (C[] : { : N >= 0 })",
6402 "[N] -> { C[] -> [N] }",
6403 "[N] -> { [N] : N >= 0 }" },
6405 "[N] -> (C[] : { : N >= 0 })",
6406 "[N] -> { C[] -> [N] : N >= 0; C[] -> [-N] : N < 0 }",
6407 "[N] -> { [N] : N >= 0 }" },
6409 "[N] -> (C[] : { : N >= 0 })",
6410 "{ C[] -> [0] }",
6411 "[N] -> { [0] : N >= 0 }" },
6413 "(C[] : { A[i,j] : i >= j })",
6414 "[N] -> { C[] -> [N] }",
6415 "[N] -> { A[i,j] -> [N] : i >= j }" },
6417 "(C[] : { A[i,j] : i >= j })",
6418 "[N] -> { C[] -> [N] : N >= 0 }",
6419 "[N] -> { A[i,j] -> [N] : i >= j and N >= 0 }" },
6421
6422/* Perform some basic tests of binary operations on
6423 * pairs of isl_multi_union_pw_aff and isl_pw_aff objects.
6424 */
6425static int test_mupa_pa(isl_ctx *ctx)
6426{
6427 int i;
6428 isl_bool ok;
6430 isl_union_pw_aff *upa, *res;
6431 isl_pw_aff *pa;
6432
6433 for (i = 0; i < ARRAY_SIZE(mupa_pa_tests); ++i) {
6435 mupa_pa_tests[i].arg1);
6438 mupa_pa_tests[i].res);
6439 upa = mupa_pa_tests[i].fn(mupa, pa);
6443 if (ok < 0)
6444 return -1;
6445 if (!ok)
6447 "unexpected result", return -1);
6448 }
6449
6450 return 0;
6451}
6452
6453/* Inputs for basic tests of binary operations on
6454 * pairs of isl_multi_union_pw_aff and isl_pw_multi_aff objects.
6455 * "fn" is the function that is tested.
6456 * "arg1" and "arg2" are string descriptions of the inputs.
6457 * "res" is a string description of the expected result.
6458 */
6459struct {
6463 const char *arg1;
6464 const char *arg2;
6465 const char *res;
6466} mupa_pma_tests[] = {
6468 "C[{ A[i,j] -> [i]; B[i,j] -> [j] }, "
6469 "{ A[i,j] -> [j]; B[i,j] -> [i] }]",
6470 "{ C[a,b] -> D[b,a] }",
6471 "D[{ A[i,j] -> [j]; B[i,j] -> [i] }, "
6472 "{ A[i,j] -> [i]; B[i,j] -> [j] }]" },
6474 "C[{ A[i,j] -> [i] : i >= 0; B[i,j] -> [j] }, "
6475 "{ A[i,j] -> [j]; B[i,j] -> [i] }]",
6476 "{ C[a,b] -> D[b,a] }",
6477 "D[{ A[i,j] -> [j] : i >= 0; B[i,j] -> [i] }, "
6478 "{ A[i,j] -> [i] : i >= 0; B[i,j] -> [j] }]" },
6480 "C[{ A[i,j] -> [i]; B[i,j] -> [j] }]",
6481 "[N] -> { C[a] -> D[a + N] }",
6482 "[N] -> D[{ A[i,j] -> [i + N]; B[i,j] -> [j + N] }]" },
6484 "C[{ A[i,j] -> [i]; B[i,j] -> [j] }]",
6485 "{ C[a] -> D[a] : a >= 0; C[a] -> D[-a] : a < 0 }",
6486 "D[{ A[i,j] -> [i] : i >= 0; A[i,j] -> [-i] : i < 0; "
6487 "B[i,j] -> [j] : j >= 0; B[i,j] -> [-j] : j < 0 }]" },
6489 "C[{ A[i,j] -> [i]; B[i,j] -> [j] }, "
6490 "{ A[i,j] -> [j]; B[i,j] -> [i] }]",
6491 "{ C[a,b] -> D[a,b] : a >= b; C[a,b] -> D[b,a] : a < b }",
6492 "D[{ A[i,j] -> [i] : i >= j; A[i,j] -> [j] : i < j; "
6493 "B[i,j] -> [j] : i <= j; B[i,j] -> [i] : i > j }, "
6494 "{ A[i,j] -> [j] : i >= j; A[i,j] -> [i] : i < j; "
6495 "B[i,j] -> [i] : i <= j; B[i,j] -> [j] : i > j }]" },
6497 "C[]",
6498 "{ C[] -> D[] }",
6499 "D[]" },
6501 "[N] -> (C[] : { : N >= 0 })",
6502 "{ C[] -> D[] }",
6503 "[N] -> (D[] : { : N >= 0 })" },
6505 "C[]",
6506 "[N] -> { C[] -> D[N] }",
6507 "[N] -> D[{ [N] }]" },
6509 "(C[] : { A[i,j] : i >= j })",
6510 "{ C[] -> D[] }",
6511 "(D[] : { A[i,j] : i >= j })" },
6513 "[N] -> (C[] : { A[i,j] : N >= 0 })",
6514 "{ C[] -> D[] }",
6515 "[N] -> (D[] : { A[i,j] : N >= 0 })" },
6517 "(C[] : { A[i,j] : i >= j })",
6518 "[N] -> { C[] -> D[N] }",
6519 "[N] -> (D[{ A[i,j] -> [N] : i >= j }])" },
6521 "C[]",
6522 "[N] -> { C[] -> D[N] : N >= 0; C[] -> D[-N] : N < 0 }",
6523 "[N] -> D[{ [N] : N >= 0; [-N] : N < 0 }]" },
6525 "[N] -> (C[] : { : N >= 0 })",
6526 "[N] -> { C[] -> D[N] }",
6527 "[N] -> D[{ [N] : N >= 0 }]" },
6529 "[N] -> (C[] : { : N >= 0 })",
6530 "[N] -> { C[] -> D[N] : N >= 0; C[] -> D[-N] : N < 0 }",
6531 "[N] -> D[{ [N] : N >= 0 }]" },
6533 "[N] -> (C[] : { : N >= 0 })",
6534 "{ C[] -> D[0] }",
6535 "[N] -> D[{ [0] : N >= 0 }]" },
6537 "(C[] : { A[i,j] : i >= j })",
6538 "[N] -> { C[] -> D[N] : N >= 0 }",
6539 "[N] -> D[{ A[i,j] -> [N] : i >= j and N >= 0 }]" },
6541
6542/* Perform some basic tests of binary operations on
6543 * pairs of isl_multi_union_pw_aff and isl_pw_multi_aff objects.
6544 */
6545static int test_mupa_pma(isl_ctx *ctx)
6546{
6547 int i;
6548 isl_bool ok;
6551
6552 for (i = 0; i < ARRAY_SIZE(mupa_pma_tests); ++i) {
6554 mupa_pma_tests[i].arg1);
6556 mupa_pma_tests[i].arg2);
6558 mupa_pma_tests[i].res);
6559 mupa = mupa_pma_tests[i].fn(mupa, pma);
6560 ok = isl_multi_union_pw_aff_plain_is_equal(mupa, res);
6561 isl_multi_union_pw_aff_free(mupa);
6562 isl_multi_union_pw_aff_free(res);
6563 if (ok < 0)
6564 return -1;
6565 if (!ok)
6567 "unexpected result", return -1);
6568 }
6569
6570 return 0;
6571}
6572
6573/* Inputs for basic tests of binary operations on
6574 * pairs of isl_multi_union_pw_aff and isl_union_pw_multi_aff objects.
6575 * "fn" is the function that is tested.
6576 * "arg1" and "arg2" are string descriptions of the inputs.
6577 * "res" is a string description of the expected result.
6578 */
6579struct {
6583 const char *arg1;
6584 const char *arg2;
6585 const char *res;
6586} mupa_upma_tests[] = {
6588 "C[{ B[i,j] -> [i + 2j] }]", "{ A[a,b] -> B[b,a] }",
6589 "C[{ A[a,b] -> [b + 2a] }]" },
6591 "C[{ B[i,j] -> [i + 2j] }]",
6592 "{ A[a,b] -> B[b,a] : b > a }",
6593 "C[{ A[a,b] -> [b + 2a] : b > a }]" },
6595 "C[{ B[i,j] -> [i + 2j] : j > 4 }]",
6596 "{ A[a,b] -> B[b,a] : b > a }",
6597 "C[{ A[a,b] -> [b + 2a] : b > a > 4 }]" },
6599 "C[{ B[i,j] -> [i + 2j] }]",
6600 "{ A[a,b] -> B[b,a] : a > b; A[a,b] -> B[a,b] : a <= b }",
6601 "C[{ A[a,b] -> [b + 2a] : a > b; A[a,b] -> [a + 2b] : a <= b }]" },
6603 "(C[] : { B[a,b] })",
6604 "{ A[a,b] -> B[b,a] }",
6605 "(C[] : { A[a,b] })" },
6607 "(C[] : { B[a,b] })",
6608 "{ B[a,b] -> A[b,a] }",
6609 "(C[] : { })" },
6611 "(C[] : { B[a,b] })",
6612 "{ A[a,b] -> B[b,a] : a > b }",
6613 "(C[] : { A[a,b] : a > b })" },
6615 "(C[] : { B[a,b] : a > b })",
6616 "{ A[a,b] -> B[b,a] }",
6617 "(C[] : { A[a,b] : b > a })" },
6619 "[N] -> (C[] : { B[a,b] : a > N })",
6620 "{ A[a,b] -> B[b,a] : a > b }",
6621 "[N] -> (C[] : { A[a,b] : a > b > N })" },
6623 "(C[] : { B[a,b] : a > b })",
6624 "[N] -> { A[a,b] -> B[b,a] : a > N }",
6625 "[N] -> (C[] : { A[a,b] : b > a > N })" },
6627 "C[]",
6628 "{ A[a,b] -> B[b,a] }",
6629 "C[]" },
6631 "[N] -> (C[] : { : N >= 0 })",
6632 "{ A[a,b] -> B[b,a] }",
6633 "[N] -> (C[] : { : N >= 0 })" },
6635 "C[]",
6636 "[N] -> { A[a,b] -> B[b,a] : N >= 0 }",
6637 "[N] -> (C[] : { : N >= 0 })" },
6639
6640/* Perform some basic tests of binary operations on
6641 * pairs of isl_multi_union_pw_aff and isl_union_pw_multi_aff objects.
6642 */
6643static int test_mupa_upma(isl_ctx *ctx)
6644{
6645 int i;
6646 isl_bool ok;
6649
6650 for (i = 0; i < ARRAY_SIZE(mupa_upma_tests); ++i) {
6656 mupa_upma_tests[i].res);
6657 mupa = mupa_upma_tests[i].fn(mupa, upma);
6658 ok = isl_multi_union_pw_aff_plain_is_equal(mupa, res);
6659 isl_multi_union_pw_aff_free(mupa);
6660 isl_multi_union_pw_aff_free(res);
6661 if (ok < 0)
6662 return -1;
6663 if (!ok)
6665 "unexpected result", return -1);
6666 }
6667
6668 return 0;
6669}
6670
6671/* Check that the input tuple of an isl_aff can be set properly.
6672 */
6674{
6675 isl_id *id;
6676 isl_aff *aff;
6678
6679 aff = isl_aff_read_from_str(ctx, "{ [x] -> [x + 1] }");
6680 id = isl_id_alloc(ctx, "A", NULL);
6682 equal = aff_check_plain_equal(aff, "{ A[x] -> [x + 1] }");
6684 if (equal < 0)
6685 return isl_stat_error;
6686
6687 return isl_stat_ok;
6688}
6689
6690/* Check that affine expressions get normalized on addition/subtraction.
6691 * In particular, check that (final) unused integer divisions get removed
6692 * such that an expression derived from expressions with integer divisions
6693 * is found to be obviously equal to one that is created directly.
6694 */
6696{
6697 isl_aff *aff, *aff2;
6698 isl_stat ok;
6699
6700 aff = isl_aff_read_from_str(ctx, "{ [x] -> [x//2] }");
6701 aff2 = isl_aff_read_from_str(ctx, "{ [x] -> [1 + x//2] }");
6702 aff = isl_aff_sub(aff2, aff);
6703 ok = aff_check_plain_equal(aff, "{ [x] -> [1] }");
6705
6706 return ok;
6707}
6708
6710{
6711 const char *str;
6712 isl_set *set;
6713 isl_space *space;
6714 isl_local_space *ls;
6715 isl_aff *aff;
6716 int zero;
6718
6719 if (test_upa(ctx) < 0)
6720 return -1;
6721 if (test_bin_aff(ctx) < 0)
6722 return -1;
6723 if (test_bin_pw_aff(ctx) < 0)
6724 return -1;
6725 if (test_upma_test(ctx) < 0)
6726 return -1;
6727 if (test_bin_upma(ctx) < 0)
6728 return -1;
6729 if (test_bin_upma_fail(ctx) < 0)
6730 return -1;
6731 if (test_upma_uset(ctx) < 0)
6732 return -1;
6733 if (test_un_mpa(ctx) < 0)
6734 return -1;
6735 if (test_bin_mpa(ctx) < 0)
6736 return -1;
6737 if (test_un_mupa(ctx) < 0)
6738 return -1;
6739 if (test_bin_mupa(ctx) < 0)
6740 return -1;
6741 if (test_mupa_set(ctx) < 0)
6742 return -1;
6743 if (test_mupa_uset(ctx) < 0)
6744 return -1;
6745 if (test_mupa_ma(ctx) < 0)
6746 return -1;
6747 if (test_mupa_pa(ctx) < 0)
6748 return -1;
6749 if (test_mupa_pma(ctx) < 0)
6750 return -1;
6751 if (test_mupa_upma(ctx) < 0)
6752 return -1;
6753
6754 space = isl_space_set_alloc(ctx, 0, 1);
6755 ls = isl_local_space_from_space(space);
6757
6765
6766 str = "{ [10] }";
6768 aff = isl_aff_gist(aff, set);
6769
6771 zero = isl_aff_plain_is_zero(aff);
6773
6774 if (zero < 0)
6775 return -1;
6776 if (!zero)
6777 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
6778
6779 aff = isl_aff_read_from_str(ctx, "{ [-1] }");
6782 equal = aff_check_plain_equal(aff, "{ [-1] }");
6784 if (equal < 0)
6785 return -1;
6786
6787 if (test_aff_set_tuple_id(ctx) < 0)
6788 return -1;
6789 if (test_aff_normalize(ctx) < 0)
6790 return -1;
6791
6792 return 0;
6793}
6794
6795/* Inputs for isl_set_bind tests.
6796 * "set" is the input set.
6797 * "tuple" is the binding tuple.
6798 * "res" is the expected result.
6799 */
6800static
6801struct {
6802 const char *set;
6803 const char *tuple;
6804 const char *res;
6805} bind_set_tests[] = {
6806 { "{ A[M, N] : M mod 2 = 0 and N mod 8 = 3 }",
6807 "{ A[M, N] }",
6808 "[M, N] -> { : M mod 2 = 0 and N mod 8 = 3 }" },
6809 { "{ B[N, M] : M mod 2 = 0 and N mod 8 = 3 }",
6810 "{ B[N, M] }",
6811 "[M, N] -> { : M mod 2 = 0 and N mod 8 = 3 }" },
6812 { "[M] -> { C[N] : M mod 2 = 0 and N mod 8 = 3 }",
6813 "{ C[N] }",
6814 "[M, N] -> { : M mod 2 = 0 and N mod 8 = 3 }" },
6815 { "[M] -> { D[x, N] : x mod 2 = 0 and N mod 8 = 3 and M >= 0 }",
6816 "{ D[M, N] }",
6817 "[M, N] -> { : M mod 2 = 0 and N mod 8 = 3 and M >= 0 }" },
6819
6820/* Perform basic isl_set_bind tests.
6821 */
6823{
6824 int i;
6825
6826 for (i = 0; i < ARRAY_SIZE(bind_set_tests); ++i) {
6827 const char *str;
6828 isl_set *set;
6830 isl_stat r;
6831
6833 str = bind_set_tests[i].tuple;
6838 if (r < 0)
6839 return isl_stat_error;
6840 }
6841
6842 return isl_stat_ok;
6843}
6844
6845/* Inputs for isl_map_bind_domain tests.
6846 * "map" is the input map.
6847 * "tuple" is the binding tuple.
6848 * "res" is the expected result.
6849 */
6850struct {
6851 const char *map;
6852 const char *tuple;
6853 const char *res;
6855 { "{ A[M, N] -> [M + floor(N/2)] }",
6856 "{ A[M, N] }",
6857 "[M, N] -> { [M + floor(N/2)] }" },
6858 { "{ B[N, M] -> [M + floor(N/2)] }",
6859 "{ B[N, M] }",
6860 "[N, M] -> { [M + floor(N/2)] }" },
6861 { "[M] -> { C[N] -> [M + floor(N/2)] }",
6862 "{ C[N] }",
6863 "[M, N] -> { [M + floor(N/2)] }" },
6864 { "[M] -> { C[x, N] -> [x + floor(N/2)] }",
6865 "{ C[M, N] }",
6866 "[M, N] -> { [M + floor(N/2)] }" },
6867 { "[M] -> { C[x, N] -> [M + floor(N/2)] }",
6868 "{ C[M, N] }",
6869 "[M, N] -> { [M + floor(N/2)] }" },
6870 { "[A, M] -> { C[N, x] -> [x + floor(N/2)] }",
6871 "{ C[N, M] }",
6872 "[A, N, M] -> { [M + floor(N/2)] }" },
6874
6875/* Perform basic isl_map_bind_domain tests.
6876 */
6878{
6879 int i;
6880
6881 for (i = 0; i < ARRAY_SIZE(bind_map_domain_tests); ++i) {
6882 const char *str;
6883 isl_map *map;
6884 isl_set *set;
6886 isl_stat r;
6887
6888 str = bind_map_domain_tests[i].map;
6890 str = bind_map_domain_tests[i].tuple;
6893 str = bind_map_domain_tests[i].res;
6894 r = set_check_equal(set, str);
6896 if (r < 0)
6897 return isl_stat_error;
6898 }
6899
6900 return isl_stat_ok;
6901}
6902
6903/* Inputs for isl_union_map_bind_range tests.
6904 * "map" is the input union map.
6905 * "tuple" is the binding tuple.
6906 * "res" is the expected result.
6907 */
6908struct {
6909 const char *map;
6910 const char *tuple;
6911 const char *res;
6913 { "{ B[N, M] -> A[M, N] : M mod 2 = 0 and N mod 8 = 3 }",
6914 "{ A[M, N] }",
6915 "[M, N] -> { B[N, M] : M mod 2 = 0 and N mod 8 = 3 }" },
6916 { "{ B[N, M] -> A[M, N] : M mod 2 = 0 and N mod 8 = 3 }",
6917 "{ B[M, N] }",
6918 "{ }" },
6919 { "{ A[] -> B[]; C[] -> D[]; E[] -> B[] }",
6920 "{ B[] }",
6921 "{ A[]; E[] }" },
6923
6924/* Perform basic isl_union_map_bind_range tests.
6925 */
6927{
6928 int i;
6929
6930 for (i = 0; i < ARRAY_SIZE(bind_umap_range_tests); ++i) {
6931 const char *str;
6932 isl_union_map *umap;
6933 isl_union_set *uset;
6935 isl_stat r;
6936
6937 str = bind_umap_range_tests[i].map;
6938 umap = isl_union_map_read_from_str(ctx, str);
6939 str = bind_umap_range_tests[i].tuple;
6941 uset = isl_union_map_bind_range(umap, tuple);
6942 str = bind_umap_range_tests[i].res;
6943 r = uset_check_equal(uset, str);
6944 isl_union_set_free(uset);
6945 if (r < 0)
6946 return isl_stat_error;
6947 }
6948
6949 return isl_stat_ok;
6950}
6951
6952/* Inputs for isl_pw_multi_aff_bind_domain tests.
6953 * "pma" is the input expression.
6954 * "tuple" is the binding tuple.
6955 * "res" is the expected result.
6956 */
6957struct {
6958 const char *pma;
6959 const char *tuple;
6960 const char *res;
6962 { "{ A[M, N] -> [M + floor(N/2)] }",
6963 "{ A[M, N] }",
6964 "[M, N] -> { [M + floor(N/2)] }" },
6965 { "{ B[N, M] -> [M + floor(N/2)] }",
6966 "{ B[N, M] }",
6967 "[N, M] -> { [M + floor(N/2)] }" },
6968 { "[M] -> { C[N] -> [M + floor(N/2)] }",
6969 "{ C[N] }",
6970 "[M, N] -> { [M + floor(N/2)] }" },
6971 { "[M] -> { C[x, N] -> [x + floor(N/2)] }",
6972 "{ C[M, N] }",
6973 "[M, N] -> { [M + floor(N/2)] }" },
6974 { "[M] -> { C[x, N] -> [M + floor(N/2)] }",
6975 "{ C[M, N] }",
6976 "[M, N] -> { [M + floor(N/2)] }" },
6977 { "[A, M] -> { C[N, x] -> [x + floor(N/2)] }",
6978 "{ C[N, M] }",
6979 "[A, N, M] -> { [M + floor(N/2)] }" },
6981
6982/* Perform basic isl_pw_multi_aff_bind_domain tests.
6983 */
6985{
6986 int i;
6987
6988 for (i = 0; i < ARRAY_SIZE(bind_pma_domain_tests); ++i) {
6989 const char *str;
6992 isl_stat r;
6993
6994 str = bind_pma_domain_tests[i].pma;
6996 str = bind_pma_domain_tests[i].tuple;
6999 str = bind_pma_domain_tests[i].res;
7000 r = pw_multi_aff_check_plain_equal(pma, str);
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_wrapped_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] -> B[]] -> [M + floor(N/2)] }",
7020 "{ A[M, N] }",
7021 "[M, N] -> { B[] -> [M + floor(N/2)] }" },
7022 { "{ [B[N, M] -> D[]] -> [M + floor(N/2)] }",
7023 "{ B[N, M] }",
7024 "[N, M] -> { D[] -> [M + floor(N/2)] }" },
7025 { "[M] -> { [C[N] -> B[x]] -> [x + M + floor(N/2)] }",
7026 "{ C[N] }",
7027 "[M, N] -> { B[x] -> [x + M + floor(N/2)] }" },
7028 { "[M] -> { [C[x, N] -> B[]] -> [x + floor(N/2)] }",
7029 "{ C[M, N] }",
7030 "[M, N] -> { B[] -> [M + floor(N/2)] }" },
7031 { "[M] -> { [C[x, N] -> B[]] -> [M + floor(N/2)] }",
7032 "{ C[M, N] }",
7033 "[M, N] -> { B[] -> [M + floor(N/2)] }" },
7034 { "[A, M] -> { [C[N, x] -> B[]] -> [x + floor(N/2)] }",
7035 "{ C[N, M] }",
7036 "[A, N, M] -> { B[] -> [M + floor(N/2)] }" },
7038
7039/* Perform basic isl_pw_multi_aff_bind_domain_wrapped_domain tests.
7040 */
7042{
7043 int i;
7044
7045 for (i = 0; i < ARRAY_SIZE(bind_pma_domain_wrapped_tests); ++i) {
7046 const char *str;
7049 isl_stat r;
7050
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_aff_bind_id tests.
7067 * "aff" is the input expression.
7068 * "id" is the binding id.
7069 * "res" is the expected result.
7070 */
7071static
7072struct {
7073 const char *aff;
7074 const char *id;
7075 const char *res;
7076} bind_aff_tests[] = {
7077 { "{ [4] }", "M", "[M = 4] -> { : }" },
7078 { "{ B[x] -> [floor(x/2)] }", "M", "[M] -> { B[x] : M = floor(x/2) }" },
7079 { "[M] -> { [4] }", "M", "[M = 4] -> { : }" },
7080 { "[M] -> { [floor(M/2)] }", "M", "[M] -> { : floor(M/2) = M }" },
7081 { "{ [NaN] }", "M", "{ : false }" },
7082 { "{ A[x] -> [NaN] }", "M", "{ A[x] : false }" },
7084
7085/* Perform basic isl_aff_bind_id tests.
7086 */
7088{
7089 int i;
7090
7091 for (i = 0; i < ARRAY_SIZE(bind_aff_tests); ++i) {
7092 isl_aff *aff;
7093 isl_set *res;
7094 isl_id *id;
7095 isl_stat r;
7096
7098 id = isl_id_read_from_str(ctx, bind_aff_tests[i].id);
7102 if (r < 0)
7103 return isl_stat_error;
7104 }
7105
7106 return isl_stat_ok;
7107}
7108
7109/* Inputs for isl_pw_aff_bind_id tests.
7110 * "pa" is the input expression.
7111 * "id" is the binding id.
7112 * "res" is the expected result.
7113 */
7114static
7115struct {
7116 const char *pa;
7117 const char *id;
7118 const char *res;
7119} bind_pa_tests[] = {
7120 { "{ [4] }", "M", "[M = 4] -> { : }" },
7121 { "{ B[x] -> [floor(x/2)] }", "M", "[M] -> { B[x] : M = floor(x/2) }" },
7122 { "[M] -> { [4] }", "M", "[M = 4] -> { : }" },
7123 { "[M] -> { [floor(M/2)] }", "M", "[M] -> { : floor(M/2) = M }" },
7124 { "[M] -> { [M] : M >= 0; [-M] : M < 0 }", "M", "[M] -> { : M >= 0 }" },
7125 { "{ [NaN] }", "M", "{ : false }" },
7126 { "{ A[x] -> [NaN] }", "M", "{ A[x] : false }" },
7128
7129/* Perform basic isl_pw_aff_bind_id tests.
7130 */
7132{
7133 int i;
7134
7135 for (i = 0; i < ARRAY_SIZE(bind_pa_tests); ++i) {
7136 isl_pw_aff *pa;
7137 isl_set *res;
7138 isl_id *id;
7139 isl_stat r;
7140
7142 id = isl_id_read_from_str(ctx, bind_pa_tests[i].id);
7143 res = isl_pw_aff_bind_id(pa, id);
7146 if (r < 0)
7147 return isl_stat_error;
7148 }
7149
7150 return isl_stat_ok;
7151}
7152
7153/* Inputs for isl_multi_union_pw_aff_bind tests.
7154 * "mupa" is the input expression.
7155 * "tuple" is the binding tuple.
7156 * "res" is the expected result.
7157 */
7158static
7159struct {
7160 const char *mupa;
7161 const char *tuple;
7162 const char *res;
7163} bind_mupa_tests[] = {
7164 { "A[{ [4] }, { [5] }]",
7165 "{ A[M, N] }",
7166 "[M = 4, N = 5] -> { : }" },
7167 { "A[{ B[x] -> [floor(x/2)] }, { B[y] -> [y + 5] }]",
7168 "{ A[M, N] }",
7169 "[M, N] -> { B[x] : M = floor(x/2) and N = x + 5 }" },
7170 { "[M] -> A[{ [4] }, { [M + 1] }]",
7171 "{ A[M, N] }",
7172 "[M = 4, N = 5] -> { : }" },
7174
7175/* Perform basic isl_multi_union_pw_aff_bind tests.
7176 */
7178{
7179 int i;
7180
7181 for (i = 0; i < ARRAY_SIZE(bind_mupa_tests); ++i) {
7182 const char *str;
7186 isl_stat r;
7187
7188 str = bind_mupa_tests[i].mupa;
7190 str = bind_mupa_tests[i].tuple;
7195 if (r < 0)
7196 return isl_stat_error;
7197 }
7198
7199 return isl_stat_ok;
7200}
7201
7202/* Perform tests that reinterpret dimensions as parameters.
7203 */
7204static int test_bind(isl_ctx *ctx)
7205{
7206 if (test_bind_set(ctx) < 0)
7207 return -1;
7208 if (test_bind_map_domain(ctx) < 0)
7209 return -1;
7210 if (test_bind_umap_range(ctx) < 0)
7211 return -1;
7212 if (test_bind_pma_domain(ctx) < 0)
7213 return -1;
7214 if (test_bind_pma_domain_wrapped(ctx) < 0)
7215 return -1;
7216 if (test_bind_aff(ctx) < 0)
7217 return -1;
7218 if (test_bind_pa(ctx) < 0)
7219 return -1;
7220 if (test_bind_mupa(ctx) < 0)
7221 return -1;
7222
7223 return 0;
7224}
7225
7226/* Inputs for isl_set_unbind_params tests.
7227 * "set" is the input parameter domain.
7228 * "tuple" is the tuple of the constructed set.
7229 * "res" is the expected result.
7230 */
7231struct {
7232 const char *set;
7233 const char *tuple;
7234 const char *res;
7235} unbind_set_tests[] = {
7236 { "[M, N] -> { : M mod 2 = 0 and N mod 8 = 3 }",
7237 "{ A[M, N] }",
7238 "{ A[M, N] : M mod 2 = 0 and N mod 8 = 3 }" },
7239 { "[M, N] -> { : M mod 2 = 0 and N mod 8 = 3 }",
7240 "{ B[N, M] }",
7241 "{ B[N, M] : M mod 2 = 0 and N mod 8 = 3 }" },
7242 { "[M, N] -> { : M mod 2 = 0 and N mod 8 = 3 }",
7243 "{ C[N] }",
7244 "[M] -> { C[N] : M mod 2 = 0 and N mod 8 = 3 }" },
7245 { "[M, N] -> { : M mod 2 = 0 and N mod 8 = 3 }",
7246 "{ D[T, N] }",
7247 "[M] -> { D[x, N] : M mod 2 = 0 and N mod 8 = 3 }" },
7249
7250/* Perform basic isl_set_unbind_params tests.
7251 */
7253{
7254 int i;
7255
7256 for (i = 0; i < ARRAY_SIZE(unbind_set_tests); ++i) {
7257 const char *str;
7258 isl_set *set;
7260 isl_stat r;
7261
7263 str = unbind_set_tests[i].tuple;
7268 if (r < 0)
7269 return isl_stat_error;
7270 }
7271
7272 return isl_stat_ok;
7273}
7274
7275/* Inputs for isl_aff_unbind_params_insert_domain tests.
7276 * "aff" is the input affine expression defined over a parameter domain.
7277 * "tuple" is the tuple of the domain that gets introduced.
7278 * "res" is the expected result.
7279 */
7280struct {
7281 const char *aff;
7282 const char *tuple;
7283 const char *res;
7284} unbind_aff_tests[] = {
7285 { "[M, N] -> { [M + floor(N/2)] }",
7286 "{ A[M, N] }",
7287 "{ A[M, N] -> [M + floor(N/2)] }" },
7288 { "[M, N] -> { [M + floor(N/2)] }",
7289 "{ B[N, M] }",
7290 "{ B[N, M] -> [M + floor(N/2)] }" },
7291 { "[M, N] -> { [M + floor(N/2)] }",
7292 "{ C[N] }",
7293 "[M] -> { C[N] -> [M + floor(N/2)] }" },
7294 { "[M, N] -> { [M + floor(N/2)] }",
7295 "{ D[A, B, C, N, Z] }",
7296 "[M] -> { D[A, B, C, N, Z] -> [M + floor(N/2)] }" },
7298
7299/* Perform basic isl_aff_unbind_params_insert_domain tests.
7300 */
7302{
7303 int i;
7304
7305 for (i = 0; i < ARRAY_SIZE(unbind_aff_tests); ++i) {
7306 const char *str;
7307 isl_aff *aff;
7309 isl_stat r;
7310
7312 str = unbind_aff_tests[i].tuple;
7315 r = aff_check_plain_equal(aff, unbind_aff_tests[i].res);
7317 if (r < 0)
7318 return isl_stat_error;
7319 }
7320
7321 return isl_stat_ok;
7322}
7323
7324/* Inputs for isl_multi_aff_unbind_params_insert_domain tests.
7325 * "ma" is the input multi affine expression defined over a parameter domain.
7326 * "tuple" is the tuple of the domain that gets introduced.
7327 * "res" is the expected result.
7328 */
7329static struct {
7330 const char *ma;
7331 const char *tuple;
7332 const char *res;
7334 { "[M, N] -> { T[M + floor(N/2)] }",
7335 "{ A[M, N] }",
7336 "{ A[M, N] -> T[M + floor(N/2)] }" },
7337 { "[M, N] -> { [M + floor(N/2)] }",
7338 "{ B[N, M] }",
7339 "{ B[N, M] -> [M + floor(N/2)] }" },
7340 { "[M, N] -> { [M + floor(N/2)] }",
7341 "{ C[N] }",
7342 "[M] -> { C[N] -> [M + floor(N/2)] }" },
7343 { "[M, N] -> { [M + floor(N/2)] }",
7344 "{ D[A, B, C, N, Z] }",
7345 "[M] -> { D[A, B, C, N, Z] -> [M + floor(N/2)] }" },
7346 { "[M, N] -> { T[M + floor(N/2), N + floor(M/3)] }",
7347 "{ A[M, N] }",
7348 "{ A[M, N] -> T[M + floor(N/2), N + floor(M/3)] }" },
7350
7351/* Perform basic isl_multi_aff_unbind_params_insert_domain tests.
7352 */
7354{
7355 int i;
7356
7357 for (i = 0; i < ARRAY_SIZE(unbind_multi_aff_tests); ++i) {
7358 const char *str;
7361 isl_stat r;
7362
7365 str = unbind_multi_aff_tests[i].tuple;
7367 ma = isl_multi_aff_unbind_params_insert_domain(ma, tuple);
7368 str = unbind_multi_aff_tests[i].res;
7369 r = multi_aff_check_plain_equal(ma, str);
7370 isl_multi_aff_free(ma);
7371 if (r < 0)
7372 return isl_stat_error;
7373 }
7374
7375 return isl_stat_ok;
7376}
7377
7378/* Perform tests that reinterpret parameters.
7379 */
7380static int test_unbind(isl_ctx *ctx)
7381{
7382 if (test_unbind_set(ctx) < 0)
7383 return -1;
7384 if (test_unbind_aff(ctx) < 0)
7385 return -1;
7386 if (test_unbind_multi_aff(ctx) < 0)
7387 return -1;
7388
7389 return 0;
7390}
7391
7392/* Check that "pa" consists of a single expression.
7393 */
7395{
7396 isl_size n;
7397
7400
7401 if (n < 0)
7402 return -1;
7403 if (n != 1)
7404 isl_die(ctx, isl_error_unknown, "expecting single expression",
7405 return -1);
7406
7407 return 0;
7408}
7409
7410/* Check that the computation below results in a single expression.
7411 * One or two expressions may result depending on which constraint
7412 * ends up being considered as redundant with respect to the other
7413 * constraints after the projection that is performed internally
7414 * by isl_set_dim_min.
7415 */
7416static int test_dim_max_1(isl_ctx *ctx)
7417{
7418 const char *str;
7419 isl_set *set;
7420 isl_pw_aff *pa;
7421
7422 str = "[n] -> { [a, b] : n >= 0 and 4a >= -4 + n and b >= 0 and "
7423 "-4a <= b <= 3 and b < n - 4a }";
7425 pa = isl_set_dim_min(set, 0);
7426 return check_single_piece(ctx, pa);
7427}
7428
7429/* Check that the computation below results in a single expression.
7430 * The PIP problem corresponding to these constraints has a row
7431 * that causes a split of the solution domain. The solver should
7432 * first pick rows that split off empty parts such that the actual
7433 * solution domain does not get split.
7434 * Note that the description contains some redundant constraints.
7435 * If these constraints get removed first, then the row mentioned
7436 * above does not appear in the PIP problem.
7437 */
7438static int test_dim_max_2(isl_ctx *ctx)
7439{
7440 const char *str;
7441 isl_set *set;
7442 isl_pw_aff *pa;
7443
7444 str = "[P, N] -> { [a] : a < N and a >= 0 and N > P and a <= P and "
7445 "N > 0 and P >= 0 }";
7447 pa = isl_set_dim_max(set, 0);
7448 return check_single_piece(ctx, pa);
7449}
7450
7452{
7453 int equal;
7454 const char *str;
7455 isl_set *set1, *set2;
7456 isl_set *set;
7457 isl_map *map;
7458 isl_pw_aff *pwaff;
7459
7460 if (test_dim_max_1(ctx) < 0)
7461 return -1;
7462 if (test_dim_max_2(ctx) < 0)
7463 return -1;
7464
7465 str = "[N] -> { [i] : 0 <= i <= min(N,10) }";
7467 pwaff = isl_set_dim_max(set, 0);
7468 set1 = isl_set_from_pw_aff(pwaff);
7469 str = "[N] -> { [10] : N >= 10; [N] : N <= 9 and N >= 0 }";
7474 if (equal < 0)
7475 return -1;
7476 if (!equal)
7477 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7478
7479 str = "[N] -> { [i] : 0 <= i <= max(2N,N+6) }";
7481 pwaff = isl_set_dim_max(set, 0);
7482 set1 = isl_set_from_pw_aff(pwaff);
7483 str = "[N] -> { [6 + N] : -6 <= N <= 5; [2N] : N >= 6 }";
7488 if (equal < 0)
7489 return -1;
7490 if (!equal)
7491 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7492
7493 str = "[N] -> { [i] : 0 <= i <= 2N or 0 <= i <= N+6 }";
7495 pwaff = isl_set_dim_max(set, 0);
7496 set1 = isl_set_from_pw_aff(pwaff);
7497 str = "[N] -> { [6 + N] : -6 <= N <= 5; [2N] : N >= 6 }";
7502 if (equal < 0)
7503 return -1;
7504 if (!equal)
7505 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7506
7507 str = "[N,M] -> { [i,j] -> [([i/16]), i%16, ([j/16]), j%16] : "
7508 "0 <= i < N and 0 <= j < M }";
7511
7512 pwaff = isl_set_dim_max(isl_set_copy(set), 0);
7513 set1 = isl_set_from_pw_aff(pwaff);
7514 str = "[N,M] -> { [([(N-1)/16])] : M,N > 0 }";
7519
7520 pwaff = isl_set_dim_max(isl_set_copy(set), 3);
7521 set1 = isl_set_from_pw_aff(pwaff);
7522 str = "[N,M] -> { [t] : t = min(M-1,15) and M,N > 0 }";
7524 if (equal >= 0 && equal)
7528
7530
7531 if (equal < 0)
7532 return -1;
7533 if (!equal)
7534 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7535
7536 /* Check that solutions are properly merged. */
7537 str = "[n] -> { [a, b, c] : c >= -4a - 2b and "
7538 "c <= -1 + n - 4a - 2b and c >= -2b and "
7539 "4a >= -4 + n and c >= 0 }";
7541 pwaff = isl_set_dim_min(set, 2);
7542 set1 = isl_set_from_pw_aff(pwaff);
7543 str = "[n] -> { [(0)] : n >= 1 }";
7548
7549 if (equal < 0)
7550 return -1;
7551 if (!equal)
7552 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7553
7554 /* Check that empty solution lie in the right space. */
7555 str = "[n] -> { [t,a] : 1 = 0 }";
7557 pwaff = isl_set_dim_max(set, 0);
7558 set1 = isl_set_from_pw_aff(pwaff);
7559 str = "[n] -> { [t] : 1 = 0 }";
7564
7565 if (equal < 0)
7566 return -1;
7567 if (!equal)
7568 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7569
7570 return 0;
7571}
7572
7573/* Basic test for isl_pw_multi_aff_product.
7574 *
7575 * Check that multiple pieces are properly handled.
7576 */
7578{
7580 const char *str;
7581 isl_pw_multi_aff *pma1, *pma2;
7582
7583 str = "{ A[i] -> B[1] : i < 0; A[i] -> B[2] : i >= 0 }";
7585 str = "{ C[] -> D[] }";
7587 pma1 = isl_pw_multi_aff_product(pma1, pma2);
7588 str = "{ [A[i] -> C[]] -> [B[(1)] -> D[]] : i < 0;"
7589 "[A[i] -> C[]] -> [B[(2)] -> D[]] : i >= 0 }";
7590 equal = pw_multi_aff_check_plain_equal(pma1, str);
7592 if (equal < 0)
7593 return -1;
7594
7595 return 0;
7596}
7597
7599{
7600 const char *str;
7601 isl_set *set;
7602 isl_union_set *uset1, *uset2;
7603 int ok;
7604
7605 str = "{ A[i] }";
7610 if (ok < 0)
7611 return -1;
7612 if (!ok)
7613 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7614
7615 str = "{ [] }";
7616 uset1 = isl_union_set_read_from_str(ctx, str);
7617 uset1 = isl_union_set_product(uset1, isl_union_set_copy(uset1));
7618 str = "{ [[] -> []] }";
7619 uset2 = isl_union_set_read_from_str(ctx, str);
7620 ok = isl_union_set_is_equal(uset1, uset2);
7621 isl_union_set_free(uset1);
7622 isl_union_set_free(uset2);
7623 if (ok < 0)
7624 return -1;
7625 if (!ok)
7626 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7627
7628 if (test_product_pma(ctx) < 0)
7629 return -1;
7630
7631 return 0;
7632}
7633
7634/* Check that two sets are not considered disjoint just because
7635 * they have a different set of (named) parameters.
7636 */
7637static int test_disjoint(isl_ctx *ctx)
7638{
7639 const char *str;
7640 isl_set *set, *set2;
7641 int disjoint;
7642
7643 str = "[n] -> { [[]->[]] }";
7645 str = "{ [[]->[]] }";
7647 disjoint = isl_set_is_disjoint(set, set2);
7650 if (disjoint < 0)
7651 return -1;
7652 if (disjoint)
7653 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7654
7655 return 0;
7656}
7657
7658/* Inputs for isl_pw_multi_aff_is_equal tests.
7659 * "f1" and "f2" are the two function that need to be compared.
7660 * "equal" is the expected result.
7661 */
7662struct {
7664 const char *f1;
7665 const char *f2;
7666} pma_equal_tests[] = {
7667 { 1, "[N] -> { [floor(N/2)] : 0 <= N <= 1 }",
7668 "[N] -> { [0] : 0 <= N <= 1 }" },
7669 { 1, "[N] -> { [floor(N/2)] : 0 <= N <= 2 }",
7670 "[N] -> { [0] : 0 <= N <= 1; [1] : N = 2 }" },
7671 { 0, "[N] -> { [floor(N/2)] : 0 <= N <= 2 }",
7672 "[N] -> { [0] : 0 <= N <= 1 }" },
7673 { 0, "{ [NaN] }", "{ [NaN] }" },
7675
7677{
7678 int i;
7679 const char *str;
7680 isl_set *set, *set2;
7681 int equal;
7682
7683 str = "{ S_6[i] }";
7685 str = "{ S_7[i] }";
7690 if (equal < 0)
7691 return -1;
7692 if (equal)
7693 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
7694
7695 for (i = 0; i < ARRAY_SIZE(pma_equal_tests); ++i) {
7696 int expected = pma_equal_tests[i].equal;
7698
7704 if (equal < 0)
7705 return -1;
7706 if (equal != expected)
7708 "unexpected equality result", return -1);
7709 }
7710
7711 return 0;
7712}
7713
7715 enum isl_dim_type type, unsigned pos, int fixed)
7716{
7717 isl_bool test;
7718
7721 if (test < 0)
7722 return -1;
7723 if (test == fixed)
7724 return 0;
7725 if (fixed)
7727 "map not detected as fixed", return -1);
7728 else
7730 "map detected as fixed", return -1);
7731}
7732
7734{
7735 const char *str;
7736 isl_map *map;
7737
7738 str = "{ [i] -> [i] }";
7740 if (test_plain_fixed(ctx, map, isl_dim_out, 0, 0))
7741 return -1;
7742 str = "{ [i] -> [1] }";
7744 if (test_plain_fixed(ctx, map, isl_dim_out, 0, 1))
7745 return -1;
7746 str = "{ S_1[p1] -> [o0] : o0 = -2 and p1 >= 1 and p1 <= 7 }";
7748 if (test_plain_fixed(ctx, map, isl_dim_out, 0, 1))
7749 return -1;
7751 map = isl_map_neg(map);
7752 if (test_plain_fixed(ctx, map, isl_dim_out, 0, 1))
7753 return -1;
7754
7755 return 0;
7756}
7757
7759 const char *set;
7760 int n;
7761 const char *vertex[6];
7762} vertices_tests[] = {
7763 { "{ A[t, i] : t = 12 and i >= 4 and i <= 12 }",
7764 2, { "{ A[12, 4] }", "{ A[12, 12] }" } },
7765 { "{ A[t, i] : t = 14 and i = 1 }",
7766 1, { "{ A[14, 1] }" } },
7767 { "[n, m] -> { [a, b, c] : b <= a and a <= n and b > 0 and c >= b and "
7768 "c <= m and m <= n and m > 0 }",
7769 6, {
7770 "[n, m] -> { [n, m, m] : 0 < m <= n }",
7771 "[n, m] -> { [n, 1, m] : 0 < m <= n }",
7772 "[n, m] -> { [n, 1, 1] : 0 < m <= n }",
7773 "[n, m] -> { [m, m, m] : 0 < m <= n }",
7774 "[n, m] -> { [1, 1, m] : 0 < m <= n }",
7775 "[n, m] -> { [1, 1, 1] : 0 < m <= n }"
7776 } },
7777 /* An input with implicit equality constraints among the parameters. */
7778 { "[N, M] -> { [a, b] : M >= 3 and 9 + 3M <= a <= 29 + 2N + 11M and "
7779 "2b >= M + a and 5 - 2N - M + a <= 2b <= 3 + a and "
7780 "3b >= 15 + a }",
7781 2, {
7782 "[N, M] -> { [(21), (12)] : M = 3 and N >= 0 }",
7783 "[N, M] -> { [(61 + 2N), (32 + N)] : M = 3 and N >= 0 }",
7784 }
7785 },
7787
7788/* Check that "vertex" corresponds to one of the vertices in data->vertex.
7789 */
7791{
7792 struct isl_vertices_test_data *data = user;
7793 isl_ctx *ctx;
7795 isl_basic_set *bset;
7797 int i;
7799
7804
7805 for (i = 0; i < data->n; ++i) {
7806 isl_pw_multi_aff *pma_i;
7807
7808 pma_i = isl_pw_multi_aff_read_from_str(ctx, data->vertex[i]);
7810 isl_pw_multi_aff_free(pma_i);
7811
7812 if (equal < 0 || equal)
7813 break;
7814 }
7815
7818
7819 if (equal < 0)
7820 return isl_stat_error;
7821
7822 return equal ? isl_stat_ok : isl_stat_error;
7823}
7824
7826{
7827 int i;
7828
7829 for (i = 0; i < ARRAY_SIZE(vertices_tests); ++i) {
7830 isl_basic_set *bset;
7831 isl_vertices *vertices;
7832 int ok = 1;
7833 isl_size n;
7834
7836 vertices = isl_basic_set_compute_vertices(bset);
7837 n = isl_vertices_get_n_vertices(vertices);
7838 if (vertices_tests[i].n != n)
7839 ok = 0;
7841 &vertices_tests[i]) < 0)
7842 ok = 0;
7843 isl_vertices_free(vertices);
7844 isl_basic_set_free(bset);
7845
7846 if (n < 0)
7847 return -1;
7848 if (!ok)
7849 isl_die(ctx, isl_error_unknown, "unexpected vertices",
7850 return -1);
7851 }
7852
7853 return 0;
7854}
7855
7856/* Inputs for basic tests of binary operations on isl_union_map.
7857 * "fn" is the function that is being tested.
7858 * "arg1" and "arg2" are string descriptions of the inputs.
7859 * "res" is a string description of the expected result.
7860 */
7861static struct {
7863 __isl_take isl_union_map *umap2);
7864 const char *arg1;
7865 const char *arg2;
7866 const char *res;
7867} umap_bin_tests[] = {
7869 "[n] -> { A[i] -> [] : 0 <= i <= n; B[] -> [] }",
7870 "[m] -> { A[i] -> [] : 0 <= i <= m; C[] -> [] }",
7871 "[m, n] -> { A[i] -> [] : 0 <= i <= n and i <= m }" },
7873 "{ [A[i] -> B[i + 1]] -> C[i + 2] }",
7874 "[N] -> { B[i] -> C[N] }",
7875 "{ }" },
7877 "{ [A[i] -> B[i + 1]] -> C[i + 2] }",
7878 "[N] -> { A[i] -> C[N] }",
7879 "[N] -> { [A[N - 2] -> B[N - 1]] -> C[N] }" },
7881 "{ T[A[i] -> B[i + 1]] -> C[i + 2] }",
7882 "[N] -> { A[i] -> C[N] }",
7883 "[N] -> { T[A[N - 2] -> B[N - 1]] -> C[N] }" },
7885 "{ [A[i] -> B[i + 1]] -> C[i + 2] }",
7886 "[N] -> { B[i] -> C[N] }",
7887 "[N] -> { [A[N - 2] -> B[N - 1]] -> C[N] }" },
7889 "{ T[A[i] -> B[i + 1]] -> C[i + 2] }",
7890 "[N] -> { B[i] -> C[N] }",
7891 "[N] -> { T[A[N - 2] -> B[N - 1]] -> C[N] }" },
7893 "{ [A[i] -> B[i + 1]] -> C[i + 2] }",
7894 "[N] -> { A[i] -> C[N] }",
7895 "{ }" },
7897 "{ A[i] -> [B[i + 1] -> C[i + 2]] }",
7898 "[N] -> { A[i] -> B[N] }",
7899 "[N] -> { A[N - 1] -> [B[N] -> C[N + 1]] }" },
7901 "{ A[i] -> T[B[i + 1] -> C[i + 2]] }",
7902 "[N] -> { A[i] -> B[N] }",
7903 "[N] -> { A[N - 1] -> T[B[N] -> C[N + 1]] }" },
7905 "{ A[i] -> [B[i + 1] -> C[i + 2]] }",
7906 "[N] -> { A[i] -> C[N] }",
7907 "{ }" },
7909 "{ A[i] -> [B[i + 1] -> C[i + 2]] }",
7910 "[N] -> { A[i] -> C[N] }",
7911 "[N] -> { A[N - 2] -> [B[N - 1] -> C[N]] }" },
7913 "{ A[i] -> T[B[i + 1] -> C[i + 2]] }",
7914 "[N] -> { A[i] -> C[N] }",
7915 "[N] -> { A[N - 2] -> T[B[N - 1] -> C[N]] }" },
7917 "{ A[i] -> [B[i + 1] -> C[i + 2]] }",
7918 "[N] -> { A[i] -> B[N] }",
7919 "{ }" },
7921
7922/* Perform basic tests of binary operations on isl_union_map.
7923 */
7925{
7926 int i;
7927
7928 for (i = 0; i < ARRAY_SIZE(umap_bin_tests); ++i) {
7929 const char *str;
7930 isl_union_map *umap1, *umap2, *res;
7932
7933 str = umap_bin_tests[i].arg1;
7934 umap1 = isl_union_map_read_from_str(ctx, str);
7935 str = umap_bin_tests[i].arg2;
7936 umap2 = isl_union_map_read_from_str(ctx, str);
7937 str = umap_bin_tests[i].res;
7939 umap1 = umap_bin_tests[i].fn(umap1, umap2);
7941 isl_union_map_free(umap1);
7943 if (equal < 0)
7944 return isl_stat_error;
7945 if (!equal)
7947 "unexpected result", return isl_stat_error);
7948 }
7949
7950 return isl_stat_ok;
7951}
7952
7953/* Check that isl_union_set_contains finds space independently
7954 * of the parameters.
7955 */
7957{
7958 const char *str;
7959 isl_bool ok;
7960 isl_space *space;
7961 isl_id *id;
7962 isl_union_set *uset;
7963
7964 str = "[N] -> { A[0:N]; B[*,*] }";
7965 uset = isl_union_set_read_from_str(ctx, str);
7966 space = isl_space_unit(ctx);
7967 id = isl_id_alloc(ctx, "A", NULL);
7968 space = isl_space_add_named_tuple_id_ui(space, id, 1);
7969 ok = isl_union_set_contains(uset, space);
7970 isl_space_free(space);
7971 isl_union_set_free(uset);
7972
7973 if (ok < 0)
7974 return isl_stat_error;
7975 if (!ok)
7977 "unexpected result", return isl_stat_error);
7978
7979 return isl_stat_ok;
7980}
7981
7982/* Perform basic tests of operations on isl_union_map or isl_union_set.
7983 */
7984static int test_union_map(isl_ctx *ctx)
7985{
7986 if (test_bin_union_map(ctx) < 0)
7987 return -1;
7988 if (test_union_set_contains(ctx) < 0)
7989 return -1;
7990 return 0;
7991}
7992
7993#undef BASE
7994#define BASE union_pw_qpolynomial
7996
7997/* Check that the result of applying "fn" to "a" and "b"
7998 * in (obviously) equal to "res".
7999 */
8000static isl_stat test_union_pw_op(isl_ctx *ctx, const char *a, const char *b,
8004 const char *res)
8005{
8006 isl_stat r;
8007 isl_union_pw_qpolynomial *upwqp1, *upwqp2;
8008
8011 upwqp1 = fn(upwqp1, upwqp2);
8012 r = union_pw_qpolynomial_check_plain_equal(upwqp1, res);
8014
8015 return r;
8016}
8017
8019{
8020 int equal;
8021 isl_stat r;
8022 const char *str;
8023 isl_union_set *uset;
8024 isl_union_pw_qpolynomial *upwqp1, *upwqp2;
8025 const char *a, *b;
8026
8027 str = "{ [x] -> x^2 }";
8029 upwqp2 = isl_union_pw_qpolynomial_copy(upwqp1);
8030 uset = isl_union_pw_qpolynomial_domain(upwqp1);
8031 upwqp1 = isl_union_pw_qpolynomial_copy(upwqp2);
8032 upwqp1 = isl_union_pw_qpolynomial_intersect_domain(upwqp1, uset);
8036 if (equal < 0)
8037 return -1;
8038 if (!equal)
8039 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
8040
8041 a = "{ A[x] -> x^2 : x >= 0; B[x] -> x }";
8042 b = "{ A[x] -> x }";
8043 str = "{ A[x] -> x^2 + x : x >= 0; A[x] -> x : x < 0; B[x] -> x }";
8045 return -1;
8046 str = "{ A[x] -> x^2 - x : x >= 0; A[x] -> -x : x < 0; B[x] -> x }";
8048 return -1;
8049
8050 str = "{ A[x] -> 0 }";
8051 a = "{ A[x] -> 1 }";
8052 b = "{ A[x] -> -1 }";
8054 return -1;
8055 a = "{ A[x] -> 1 }";
8056 b = "{ A[x] -> 1 }";
8058 return -1;
8059
8060 str = "{ [A[x] -> B[y,z]] -> x^2 + y * floor(x/4) * floor(z/2); "
8061 "C[z] -> z^3 }";
8064 str = "{ [B[y,z] -> A[x]] -> x^2 + y * floor(x/4) * floor(z/2) }";
8065 r = union_pw_qpolynomial_check_plain_equal(upwqp1, str);
8067 if (r < 0)
8068 return -1;
8069
8070 return 0;
8071}
8072
8073/* Inputs for basic tests of functions that select
8074 * subparts of the domain of an isl_multi_union_pw_aff.
8075 * "fn" is the function that is tested.
8076 * "arg" is a string description of the input.
8077 * "res" is a string description of the expected result.
8078 */
8079struct {
8082 const char *arg;
8083 const char *res;
8084} un_locus_tests[] = {
8086 "F[{ A[i,j] -> [i]; B[i,j] -> [i] }]",
8087 "{ A[0,j]; B[0,j] }" },
8089 "F[{ A[i,j] -> [i-j]; B[i,j] -> [i-j] : i >= 0 }]",
8090 "{ A[i,i]; B[i,i] : i >= 0 }" },
8092 "(F[] : { A[i,j]; B[i,i] : i >= 0 })",
8093 "{ A[i,j]; B[i,i] : i >= 0 }" },
8095
8096/* Perform some basic tests of functions that select
8097 * subparts of the domain of an isl_multi_union_pw_aff.
8098 */
8099static int test_un_locus(isl_ctx *ctx)
8100{
8101 int i;
8102 isl_bool ok;
8103 isl_union_set *uset, *res;
8105
8106 for (i = 0; i < ARRAY_SIZE(un_locus_tests); ++i) {
8108 un_locus_tests[i].arg);
8110 uset = un_locus_tests[i].fn(mupa);
8111 ok = isl_union_set_is_equal(uset, res);
8112 isl_union_set_free(uset);
8114 if (ok < 0)
8115 return -1;
8116 if (!ok)
8118 "unexpected result", return -1);
8119 }
8120
8121 return 0;
8122}
8123
8124/* Inputs for basic tests of functions that select
8125 * subparts of an isl_union_map based on a relation
8126 * specified by an isl_multi_union_pw_aff.
8127 * "fn" is the function that is tested.
8128 * "arg1" and "arg2" are string descriptions of the inputs.
8129 * "res" is a string description of the expected result.
8130 */
8131struct {
8135 const char *arg1;
8136 const char *arg2;
8137 const char *res;
8138} bin_locus_tests[] = {
8140 "{ A[i,j] -> B[i',j'] }",
8141 "F[{ A[i,j] -> [i]; B[i,j] -> [i] }]",
8142 "{ A[i,j] -> B[i,j'] }" },
8144 "{ A[i,j] -> B[i',j'] }",
8145 "F[{ A[i,j] -> [i]; B[i,j] -> [i] }, "
8146 "{ A[i,j] -> [j]; B[i,j] -> [j] }]",
8147 "{ A[i,j] -> B[i,j] }" },
8149 "{ A[i,j] -> B[i',j']; A[i,j] -> C[i',j'] }",
8150 "F[{ A[i,j] -> [i]; B[i,j] -> [i] }]",
8151 "{ A[i,j] -> B[i,j'] }" },
8153 "{ A[i,j] -> B[i',j']; A[i,j] -> C[i',j'] }",
8154 "F[{ A[i,j] -> [i]; B[i,j] -> [i]; C[i,j] -> [0] }]",
8155 "{ A[i,j] -> B[i,j']; A[0,j] -> C[i',j'] }" },
8157 "{ A[i,j] -> B[i',j'] }",
8158 "F[{ A[i,j] -> [i] : i > j; B[i,j] -> [i] }]",
8159 "{ A[i,j] -> B[i,j'] : i > j }" },
8161 "{ A[i,j] -> B[i',j'] }",
8162 "F[{ A[i,j] -> [i]; B[i,j] -> [i] }, "
8163 "{ A[i,j] -> [j]; B[i,j] -> [j] }]",
8164 "{ A[i,j] -> B[i',j'] : i,j <<= i',j' }" },
8166 "{ A[i,j] -> B[i',j'] }",
8167 "F[{ A[i,j] -> [i]; B[i,j] -> [i] }, "
8168 "{ A[i,j] -> [j]; B[i,j] -> [j] }]",
8169 "{ A[i,j] -> B[i',j'] : i,j << i',j' }" },
8171 "{ A[i,j] -> B[i',j'] }",
8172 "F[{ A[i,j] -> [i]; B[i,j] -> [i] }, "
8173 "{ A[i,j] -> [j]; B[i,j] -> [j] }]",
8174 "{ A[i,j] -> B[i',j'] : i,j >>= i',j' }" },
8176 "{ A[i,j] -> B[i',j'] }",
8177 "F[{ A[i,j] -> [i]; B[i,j] -> [i] }, "
8178 "{ A[i,j] -> [j]; B[i,j] -> [j] }]",
8179 "{ A[i,j] -> B[i',j'] : i,j >> i',j' }" },
8181 "{ A[i,j] -> B[i',j']; A[i,j] -> C[i',j'] }",
8182 "(F[] : { A[i,j]; B[i,j] })",
8183 "{ A[i,j] -> B[i',j'] }" },
8185 "{ A[i,j] -> B[i',j'] }",
8186 "(F[] : { A[i,j] : i > j; B[i,j] : i < j })",
8187 "{ A[i,j] -> B[i',j'] : i > j and i' < j' }" },
8189 "[N] -> { A[i,j] -> B[i',j'] : i,i' <= N }",
8190 "(F[] : { A[i,j] : i > j; B[i,j] : i < j })",
8191 "[N] -> { A[i,j] -> B[i',j'] : i > j and i' < j' and i,i' <= N }" },
8193 "{ A[i,j] -> B[i',j'] }",
8194 "[N] -> (F[] : { A[i,j] : i < N; B[i,j] : i < N })",
8195 "[N] -> { A[i,j] -> B[i',j'] : i,i' < N }" },
8197 "{ A[i,j] -> B[i',j'] }",
8198 "[N] -> (F[] : { : N >= 0 })",
8199 "[N] -> { A[i,j] -> B[i',j'] : N >= 0 }" },
8201
8202/* Perform some basic tests of functions that select
8203 * subparts of an isl_union_map based on a relation
8204 * specified by an isl_multi_union_pw_aff.
8205 */
8206static int test_bin_locus(isl_ctx *ctx)
8207{
8208 int i;
8209 isl_bool ok;
8210 isl_union_map *umap, *res;
8212
8213 for (i = 0; i < ARRAY_SIZE(bin_locus_tests); ++i) {
8214 umap = isl_union_map_read_from_str(ctx,
8219 umap = bin_locus_tests[i].fn(umap, mupa);
8220 ok = isl_union_map_is_equal(umap, res);
8221 isl_union_map_free(umap);
8223 if (ok < 0)
8224 return -1;
8225 if (!ok)
8227 "unexpected result", return -1);
8228 }
8229
8230 return 0;
8231}
8232
8233/* Inputs for basic tests of functions that determine
8234 * the part of the domain where two isl_multi_aff objects
8235 * related to each other in a specific way.
8236 * "fn" is the function that is being tested.
8237 * "arg1" and "arg2" are string descriptions of the inputs.
8238 * "res" is a string description of the expected result.
8239 */
8240static struct {
8243 const char *arg1;
8244 const char *arg2;
8245 const char *res;
8246} bin_locus_ma_tests[] = {
8247 { &isl_multi_aff_lex_le_set, "{ [] }", "{ [] }", "{ : }" },
8248 { &isl_multi_aff_lex_lt_set, "{ [] }", "{ [] }", "{ : false }" },
8250 "{ A[i] -> [i] }", "{ A[i] -> [0] }",
8251 "{ A[i] : i <= 0 }" },
8253 "{ A[i] -> [i] }", "{ A[i] -> [0] }",
8254 "{ A[i] : i < 0 }" },
8256 "{ A[i] -> [i, i] }", "{ A[i] -> [0, 0] }",
8257 "{ A[i] : i <= 0 }" },
8259 "{ A[i] -> [i, 0] }", "{ A[i] -> [0, 0] }",
8260 "{ A[i] : i <= 0 }" },
8262 "{ A[i] -> [i, 1] }", "{ A[i] -> [0, 0] }",
8263 "{ A[i] : i < 0 }" },
8265
8266/* Perform some basic tests of functions that determine
8267 * the part of the domain where two isl_multi_aff objects
8268 * related to each other in a specific way.
8269 */
8271{
8272 int i;
8273
8274 for (i = 0; i < ARRAY_SIZE(bin_locus_ma_tests); ++i) {
8275 const char *str;
8276 isl_bool ok;
8277 isl_multi_aff *ma1, *ma2;
8278 isl_set *set, *res;
8279
8280 str = bin_locus_ma_tests[i].arg1;
8282 str = bin_locus_ma_tests[i].arg2;
8283 ma2 = isl_multi_aff_read_from_str(ctx, str);
8285 set = bin_locus_ma_tests[i].fn(ma1, ma2);
8286 ok = isl_set_is_equal(set, res);
8289 if (ok < 0)
8290 return isl_stat_error;
8291 if (!ok)
8293 "unexpected result", return isl_stat_error);
8294 }
8295
8296 return isl_stat_ok;
8297}
8298
8299/* Perform basic locus tests.
8300 */
8301static int test_locus(isl_ctx *ctx)
8302{
8303 if (test_un_locus(ctx) < 0)
8304 return -1;
8305 if (test_bin_locus(ctx) < 0)
8306 return -1;
8307 if (test_bin_locus_ma(ctx) < 0)
8308 return -1;
8309 return 0;
8310}
8311
8312/* Test that isl_union_pw_qpolynomial_eval picks up the function
8313 * defined over the correct domain space.
8314 */
8315static int test_eval_1(isl_ctx *ctx)
8316{
8317 const char *str;
8318 isl_point *pnt;
8319 isl_set *set;
8321 isl_val *v;
8322 int cmp;
8323
8324 str = "{ A[x] -> x^2; B[x] -> -x^2 }";
8326 str = "{ A[6] }";
8329 v = isl_union_pw_qpolynomial_eval(upwqp, pnt);
8330 cmp = isl_val_cmp_si(v, 36);
8331 isl_val_free(v);
8332
8333 if (!v)
8334 return -1;
8335 if (cmp != 0)
8336 isl_die(ctx, isl_error_unknown, "unexpected value", return -1);
8337
8338 return 0;
8339}
8340
8341/* Check that isl_qpolynomial_eval handles getting called on a void point.
8342 */
8343static int test_eval_2(isl_ctx *ctx)
8344{
8345 const char *str;
8346 isl_point *pnt;
8347 isl_set *set;
8348 isl_qpolynomial *qp;
8349 isl_val *v;
8350 isl_bool ok;
8351
8352 str = "{ A[x] -> [x] }";
8354 str = "{ A[x] : false }";
8357 v = isl_qpolynomial_eval(qp, pnt);
8358 ok = isl_val_is_nan(v);
8359 isl_val_free(v);
8360
8361 if (ok < 0)
8362 return -1;
8363 if (!ok)
8364 isl_die(ctx, isl_error_unknown, "expecting NaN", return -1);
8365
8366 return 0;
8367}
8368
8369/* Check that a polynomial (without local variables) can be evaluated
8370 * in a rational point.
8371 */
8373{
8375 isl_point *pnt;
8376 isl_val *v;
8377 isl_stat r;
8378
8379 pwqp = isl_pw_qpolynomial_read_from_str(ctx, "{ [x] -> x^2 }");
8381 v = isl_val_read_from_str(ctx, "1/2");
8382 pnt = isl_point_set_coordinate_val(pnt, isl_dim_set, 0, v);
8383 v = isl_pw_qpolynomial_eval(pwqp, pnt);
8384 r = val_check_equal(v, "1/4");
8385 isl_val_free(v);
8386
8387 return r;
8388}
8389
8390/* Inputs for isl_pw_aff_eval test.
8391 * "f" is the affine function.
8392 * "p" is the point where the function should be evaluated.
8393 * "res" is the expected result.
8394 */
8395struct {
8396 const char *f;
8397 const char *p;
8398 const char *res;
8399} aff_eval_tests[] = {
8400 { "{ [i] -> [2 * i] }", "{ [4] }", "8" },
8401 { "{ [i] -> [2 * i] }", "{ [x] : false }", "NaN" },
8402 { "{ [i] -> [i + floor(i/2) + floor(i/3)] }", "{ [0] }", "0" },
8403 { "{ [i] -> [i + floor(i/2) + floor(i/3)] }", "{ [1] }", "1" },
8404 { "{ [i] -> [i + floor(i/2) + floor(i/3)] }", "{ [2] }", "3" },
8405 { "{ [i] -> [i + floor(i/2) + floor(i/3)] }", "{ [3] }", "5" },
8406 { "{ [i] -> [i + floor(i/2) + floor(i/3)] }", "{ [4] }", "7" },
8407 { "{ [i] -> [floor((3 * floor(i/2))/5)] }", "{ [0] }", "0" },
8408 { "{ [i] -> [floor((3 * floor(i/2))/5)] }", "{ [1] }", "0" },
8409 { "{ [i] -> [floor((3 * floor(i/2))/5)] }", "{ [2] }", "0" },
8410 { "{ [i] -> [floor((3 * floor(i/2))/5)] }", "{ [3] }", "0" },
8411 { "{ [i] -> [floor((3 * floor(i/2))/5)] }", "{ [4] }", "1" },
8412 { "{ [i] -> [floor((3 * floor(i/2))/5)] }", "{ [6] }", "1" },
8413 { "{ [i] -> [floor((3 * floor(i/2))/5)] }", "{ [8] }", "2" },
8414 { "{ [i] -> [i] : i > 0; [i] -> [-i] : i < 0 }", "{ [4] }", "4" },
8415 { "{ [i] -> [i] : i > 0; [i] -> [-i] : i < 0 }", "{ [-2] }", "2" },
8416 { "{ [i] -> [i] : i > 0; [i] -> [-i] : i < 0 }", "{ [0] }", "NaN" },
8417 { "[N] -> { [2 * N] }", "[N] -> { : N = 4 }", "8" },
8418 { "{ [i, j] -> [(i + j)/2] }", "{ [1, 1] }", "1" },
8419 { "{ [i, j] -> [(i + j)/2] }", "{ [1, 2] }", "3/2" },
8420 { "{ [i] -> [i] : i mod 2 = 0 }", "{ [4] }", "4" },
8421 { "{ [i] -> [i] : i mod 2 = 0 }", "{ [3] }", "NaN" },
8422 { "{ [i] -> [i] : i mod 2 = 0 }", "{ [x] : false }", "NaN" },
8423 { "[m, n] -> { [2m + 3n] }", "[n=1, m=10] -> { : }", "23" },
8425
8426/* Perform basic isl_pw_aff_eval tests.
8427 */
8428static int test_eval_aff(isl_ctx *ctx)
8429{
8430 int i;
8431
8432 for (i = 0; i < ARRAY_SIZE(aff_eval_tests); ++i) {
8433 isl_stat r;
8434 isl_pw_aff *pa;
8435 isl_set *set;
8436 isl_point *pnt;
8437 isl_val *v;
8438
8442 v = isl_pw_aff_eval(pa, pnt);
8444 isl_val_free(v);
8445 if (r < 0)
8446 return -1;
8447 }
8448 return 0;
8449}
8450
8451/* Perform basic evaluation tests.
8452 */
8453static int test_eval(isl_ctx *ctx)
8454{
8455 if (test_eval_1(ctx) < 0)
8456 return -1;
8457 if (test_eval_2(ctx) < 0)
8458 return -1;
8459 if (test_eval_3(ctx) < 0)
8460 return -1;
8461 if (test_eval_aff(ctx) < 0)
8462 return -1;
8463 return 0;
8464}
8465
8466/* Descriptions of sets that are tested for reparsing after printing.
8467 */
8468const char *output_tests[] = {
8469 "{ [1, y] : 0 <= y <= 1; [x, -x] : 0 <= x <= 1 }",
8470 "{ [x] : 1 = 0 }",
8471 "{ [x] : false }",
8472 "{ [x] : x mod 2 = 0 }",
8473 "{ [x] : x mod 2 = 1 }",
8474 "{ [x, y] : x mod 2 = 0 and 3*floor(y/2) < x }",
8475 "{ [y, x] : x mod 2 = 0 and 3*floor(y/2) < x }",
8476 "{ [x, y] : x mod 2 = 0 and 3*floor(y/2) = x + y }",
8477 "{ [y, x] : x mod 2 = 0 and 3*floor(y/2) = x + y }",
8478 "[n] -> { [y, x] : 2*((x + 2y) mod 3) = n }",
8479 "{ [x, y] : (2*floor(x/3) + 3*floor(y/4)) mod 5 = x }",
8480};
8481
8482/* Check that printing a set and reparsing a set from the printed output
8483 * results in the same set.
8484 */
8485static int test_output_set(isl_ctx *ctx)
8486{
8487 int i;
8488 char *str;
8489 isl_set *set1, *set2;
8491
8492 for (i = 0; i < ARRAY_SIZE(output_tests); ++i) {
8496 free(str);
8500 if (equal < 0)
8501 return -1;
8502 if (!equal)
8504 "parsed output not the same", return -1);
8505 }
8506
8507 return 0;
8508}
8509
8510/* Check that an isl_multi_aff is printed using a consistent space.
8511 */
8513{
8514 char *str;
8516 isl_aff *aff;
8517 isl_multi_aff *ma, *ma2;
8518
8519 ma = isl_multi_aff_read_from_str(ctx, "{ [a, b] -> [a + b] }");
8520 aff = isl_aff_read_from_str(ctx, "{ [c, d] -> [c + d] }");
8521 ma = isl_multi_aff_set_aff(ma, 0, aff);
8523 ma2 = isl_multi_aff_read_from_str(ctx, str);
8524 free(str);
8525 equal = isl_multi_aff_plain_is_equal(ma, ma2);
8526 isl_multi_aff_free(ma2);
8527 isl_multi_aff_free(ma);
8528
8529 if (equal < 0)
8530 return isl_stat_error;
8531 if (!equal)
8532 isl_die(ctx, isl_error_unknown, "bad conversion",
8533 return isl_stat_error);
8534
8535 return isl_stat_ok;
8536}
8537
8538/* Check that an isl_multi_pw_aff is printed using a consistent space.
8539 */
8541{
8542 char *str;
8544 isl_pw_aff *pa;
8545 isl_multi_pw_aff *mpa, *mpa2;
8546
8547 mpa = isl_multi_pw_aff_read_from_str(ctx, "{ [a, b] -> [a + b] }");
8548 pa = isl_pw_aff_read_from_str(ctx, "{ [c, d] -> [c + d] }");
8549 mpa = isl_multi_pw_aff_set_pw_aff(mpa, 0, pa);
8552 free(str);
8553 equal = isl_multi_pw_aff_plain_is_equal(mpa, mpa2);
8554 isl_multi_pw_aff_free(mpa2);
8555 isl_multi_pw_aff_free(mpa);
8556
8557 if (equal < 0)
8558 return isl_stat_error;
8559 if (!equal)
8560 isl_die(ctx, isl_error_unknown, "bad conversion",
8561 return isl_stat_error);
8562
8563 return isl_stat_ok;
8564}
8565
8567{
8568 char *s;
8569 const char *str;
8570 isl_pw_aff *pa;
8571 isl_printer *p;
8572 int equal;
8573
8574 if (test_output_set(ctx) < 0)
8575 return -1;
8576 if (test_output_ma(ctx) < 0)
8577 return -1;
8578 if (test_output_mpa(ctx) < 0)
8579 return -1;
8580
8581 str = "[x] -> { [1] : x % 4 <= 2; [2] : x = 3 }";
8583
8584 p = isl_printer_to_str(ctx);
8590 if (!s)
8591 equal = -1;
8592 else
8593 equal = !strcmp(s, "4 * floord(x, 4) + 2 >= x ? 1 : 2");
8594 free(s);
8595 if (equal < 0)
8596 return -1;
8597 if (!equal)
8598 isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
8599
8600 return 0;
8601}
8602
8604{
8605 const char *str;
8606 isl_basic_set *bset1, *bset2;
8607 int empty, subset;
8608
8609 str = "{ [a, b, c, d, e, f, g, h, i, j, k] : "
8610 "3i >= 1073741823b - c - 1073741823e + f and c >= 0 and "
8611 "3i >= -1 + 3221225466b + c + d - 3221225466e - f and "
8612 "2e >= a - b and 3e <= 2a and 3k <= -a and f <= -1 + a and "
8613 "3i <= 4 - a + 4b + 2c - e - 2f and 3k <= -a + c - f and "
8614 "3h >= -2 + a and 3g >= -3 - a and 3k >= -2 - a and "
8615 "3i >= -2 - a - 2c + 3e + 2f and 3h <= a + c - f and "
8616 "3h >= a + 2147483646b + 2c - 2147483646e - 2f and "
8617 "3g <= -1 - a and 3i <= 1 + c + d - f and a <= 1073741823 and "
8618 "f >= 1 - a + 1073741822b + c + d - 1073741822e and "
8619 "3i >= 1 + 2b - 2c + e + 2f + 3g and "
8620 "1073741822f <= 1073741822 - a + 1073741821b + 1073741822c +"
8621 "d - 1073741821e and "
8622 "3j <= 3 - a + 3b and 3g <= -2 - 2b + c + d - e - f and "
8623 "3j >= 1 - a + b + 2e and "
8624 "3f >= -3 + a + 3221225462b + 3c + d - 3221225465e and "
8625 "3i <= 4 - a + 4b - e and "
8626 "f <= 1073741822 + 1073741822b - 1073741822e and 3h <= a and "
8627 "f >= 0 and 2e <= 4 - a + 5b - d and 2e <= a - b + d and "
8628 "c <= -1 + a and 3i >= -2 - a + 3e and "
8629 "1073741822e <= 1073741823 - a + 1073741822b + c and "
8630 "3g >= -4 + 3221225464b + 3c + d - 3221225467e - 3f and "
8631 "3i >= -1 + 3221225466b + 3c + d - 3221225466e - 3f and "
8632 "1073741823e >= 1 + 1073741823b - d and "
8633 "3i >= 1073741823b + c - 1073741823e - f and "
8634 "3i >= 1 + 2b + e + 3g }";
8635 bset1 = isl_basic_set_read_from_str(ctx, str);
8637 empty = isl_basic_set_is_empty(bset2);
8638 subset = isl_basic_set_is_subset(bset2, bset1);
8639 isl_basic_set_free(bset1);
8640 isl_basic_set_free(bset2);
8641 if (empty < 0 || subset < 0)
8642 return -1;
8643 if (empty)
8644 isl_die(ctx, isl_error_unknown, "point not found", return -1);
8645 if (!subset)
8646 isl_die(ctx, isl_error_unknown, "bad point found", return -1);
8647
8648 return 0;
8649}
8650
8651/* Perform a projection on a basic set that is known to be empty
8652 * but that has not been assigned a canonical representation.
8653 * Earlier versions of isl would run into a stack overflow
8654 * on this example.
8655 */
8657{
8658 const char *str;
8659 isl_bool empty;
8660 isl_basic_set *bset;
8661
8662 str = "{ [a, b, c, d, e, f, g, h] : 5f = 1 + 4a - b + 5c - d - 2e and "
8663 "3h = 2 + b + c and 14c >= 9 - 3a + 25b and "
8664 "4c <= 50 - 3a + 23b and 6b <= -39 + a and "
8665 "9g >= -6 + 3a + b + c and e < a + b - 2d and "
8666 "7d >= -5 + 2a + 2b and 5g >= -14 + a - 4b + d + 2e and "
8667 "9g <= -28 - 5b - 2c + 3d + 6e }";
8668 bset = isl_basic_set_read_from_str(ctx, str);
8669 empty = isl_basic_set_is_empty(bset);
8670 bset = isl_basic_set_params(bset);
8671 isl_basic_set_free(bset);
8672
8673 if (empty < 0)
8674 return -1;
8675
8676 return 0;
8677}
8678
8680{
8681 const char *str;
8682 isl_map *map;
8683 int equal;
8684
8685 str = "{ [i] -> [j] }";
8688 equal = map_check_equal(map, "{ [i] -> [i] }");
8690 if (equal < 0)
8691 return -1;
8692
8693 str = "{ [i] -> [j] }";
8696 equal = map_check_equal(map, "{ [i] -> [j] }");
8698 if (equal < 0)
8699 return -1;
8700
8701 str = "{ [i] -> [j] }";
8704 equal = map_check_equal(map, "{ [i] -> [-i] }");
8706 if (equal < 0)
8707 return -1;
8708
8709 str = "{ [i] -> [j] }";
8712 equal = map_check_equal(map, "{ [0] -> [j] }");
8714 if (equal < 0)
8715 return -1;
8716
8717 str = "{ [i] -> [j] }";
8720 equal = map_check_equal(map, "{ [i] -> [j] : i > j }");
8722 if (equal < 0)
8723 return -1;
8724
8725 str = "{ [i] -> [j] }";
8728 equal = map_check_equal(map, "{ [i] -> [j] : false }");
8730 if (equal < 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] : i = 2j }";
8745 equal = map_check_equal(map, "{ [i] -> [j] : exists a : i = 2a }");
8747 if (equal < 0)
8748 return -1;
8749
8750 return 0;
8751}
8752
8753/* Check basic functionality of isl_map_deltas_map.
8754 */
8755static int test_deltas_map(isl_ctx *ctx)
8756{
8757 const char *str;
8758 isl_map *map;
8759 int equal;
8760
8761 str = "{ A[i] -> A[i + 1] }";
8764 equal = map_check_equal(map, "{ [A[i] -> A[i + 1]] -> A[1] }");
8766 if (equal < 0)
8767 return -1;
8768
8769 return 0;
8770}
8771
8772/* Check that isl_set_dim_residue_class detects that the values of j
8773 * in the set below are all odd and that it does not detect any spurious
8774 * strides.
8775 */
8777{
8778 const char *str;
8779 isl_set *set;
8780 isl_int m, r;
8781 isl_stat res;
8782
8783 str = "{ [i,j] : j = 4 i + 1 and 0 <= i <= 100; "
8784 "[i,j] : j = 4 i + 3 and 500 <= i <= 600 }";
8786 isl_int_init(m);
8787 isl_int_init(r);
8788 res = isl_set_dim_residue_class(set, 1, &m, &r);
8789 if (res >= 0 &&
8790 (isl_int_cmp_si(m, 2) != 0 || isl_int_cmp_si(r, 1) != 0))
8791 isl_die(ctx, isl_error_unknown, "incorrect residue class",
8793 isl_int_clear(r);
8796
8797 return res;
8798}
8799
8801{
8802 const char *str;
8803 isl_space *space;
8804 isl_multi_aff *ma1, *ma2;
8805 int equal;
8806
8807 str = "{ A[B[] -> C[]] -> D[E[] -> F[]] }";
8809
8810 space = isl_space_params_alloc(ctx, 1);
8811 space = isl_space_set_dim_name(space, isl_dim_param, 0, "N");
8812 ma1 = isl_multi_aff_align_params(ma1, space);
8813
8814 str = "[N] -> { A[B[] -> C[]] -> D[E[] -> F[]] }";
8815 ma2 = isl_multi_aff_read_from_str(ctx, str);
8816
8817 equal = isl_multi_aff_plain_is_equal(ma1, ma2);
8818
8819 isl_multi_aff_free(ma1);
8820 isl_multi_aff_free(ma2);
8821
8822 if (equal < 0)
8823 return -1;
8824 if (!equal)
8826 "result not as expected", return -1);
8827
8828 return 0;
8829}
8830
8831/* Check the isl_multi_*_from_*_list operation in case inputs
8832 * have unaligned parameters.
8833 * In particular, older versions of isl would simply fail
8834 * (without printing any error message).
8835 */
8837{
8838 isl_space *space;
8839 isl_map *map;
8840 isl_aff *aff;
8842
8843 map = isl_map_read_from_str(ctx, "{ A[] -> M[x] }");
8844 space = isl_map_get_space(map);
8846
8847 aff = isl_aff_read_from_str(ctx, "[N] -> { A[] -> [N] }");
8848 ma = isl_multi_aff_from_aff_list(space, isl_aff_list_from_aff(aff));
8849 isl_multi_aff_free(ma);
8850
8851 if (!ma)
8852 return isl_stat_error;
8853 return isl_stat_ok;
8854}
8855
8856/* Perform basic parameter alignment tests.
8857 */
8859{
8860 if (test_align_parameters_1(ctx) < 0)
8861 return -1;
8862 if (test_align_parameters_2(ctx) < 0)
8863 return -1;
8864
8865 return 0;
8866}
8867
8868/* Check that isl_*_drop_unused_params actually drops the unused parameters
8869 * by comparing the result using isl_*_plain_is_equal.
8870 * Note that this assumes that isl_*_plain_is_equal does not consider
8871 * objects that only differ by unused parameters to be equal.
8872 */
8874{
8875 const char *str_with, *str_without;
8876 isl_basic_set *bset1, *bset2;
8877 isl_set *set1, *set2;
8878 isl_pw_aff *pwa1, *pwa2;
8879 int equal;
8880
8881 str_with = "[n, m, o] -> { [m] }";
8882 str_without = "[m] -> { [m] }";
8883
8884 bset1 = isl_basic_set_read_from_str(ctx, str_with);
8885 bset2 = isl_basic_set_read_from_str(ctx, str_without);
8886 bset1 = isl_basic_set_drop_unused_params(bset1);
8887 equal = isl_basic_set_plain_is_equal(bset1, bset2);
8888 isl_basic_set_free(bset1);
8889 isl_basic_set_free(bset2);
8890
8891 if (equal < 0)
8892 return -1;
8893 if (!equal)
8895 "result not as expected", return -1);
8896
8897 set1 = isl_set_read_from_str(ctx, str_with);
8898 set2 = isl_set_read_from_str(ctx, str_without);
8903
8904 if (equal < 0)
8905 return -1;
8906 if (!equal)
8908 "result not as expected", return -1);
8909
8910 pwa1 = isl_pw_aff_read_from_str(ctx, str_with);
8911 pwa2 = isl_pw_aff_read_from_str(ctx, str_without);
8912 pwa1 = isl_pw_aff_drop_unused_params(pwa1);
8913 equal = isl_pw_aff_plain_is_equal(pwa1, pwa2);
8914 isl_pw_aff_free(pwa1);
8915 isl_pw_aff_free(pwa2);
8916
8917 if (equal < 0)
8918 return -1;
8919 if (!equal)
8921 "result not as expected", return -1);
8922
8923 return 0;
8924}
8925
8926static int test_list(isl_ctx *ctx)
8927{
8928 isl_id *a, *b, *c, *d, *id;
8929 isl_id_list *list;
8930 isl_size n;
8931 int ok;
8932
8933 a = isl_id_alloc(ctx, "a", NULL);
8934 b = isl_id_alloc(ctx, "b", NULL);
8935 c = isl_id_alloc(ctx, "c", NULL);
8936 d = isl_id_alloc(ctx, "d", NULL);
8937
8938 list = isl_id_list_alloc(ctx, 4);
8939 list = isl_id_list_add(list, b);
8940 list = isl_id_list_insert(list, 0, a);
8941 list = isl_id_list_add(list, c);
8942 list = isl_id_list_add(list, d);
8943 list = isl_id_list_drop(list, 1, 1);
8944
8945 n = isl_id_list_n_id(list);
8946 if (n < 0)
8947 return -1;
8948 if (n != 3) {
8949 isl_id_list_free(list);
8951 "unexpected number of elements in list", return -1);
8952 }
8953
8954 id = isl_id_list_get_id(list, 0);
8955 ok = id == a;
8956 isl_id_free(id);
8957 id = isl_id_list_get_id(list, 1);
8958 ok = ok && id == c;
8959 isl_id_free(id);
8960 id = isl_id_list_get_id(list, 2);
8961 ok = ok && id == d;
8962 isl_id_free(id);
8963
8964 isl_id_list_free(list);
8965
8966 if (!ok)
8968 "unexpected elements in list", return -1);
8969
8970 return 0;
8971}
8972
8973/* Check the conversion from an isl_multi_aff to an isl_basic_set.
8974 */
8976{
8977 const char *str;
8980 isl_basic_set *bset1, *bset2;
8981
8982 str = "[N] -> { A[0, N + 1] }";
8984 bset1 = isl_basic_set_read_from_str(ctx, str);
8986 equal = isl_basic_set_is_equal(bset1, bset2);
8987 isl_basic_set_free(bset1);
8988 isl_basic_set_free(bset2);
8989 if (equal < 0)
8990 return isl_stat_error;
8991 if (!equal)
8992 isl_die(ctx, isl_error_unknown, "bad conversion",
8993 return isl_stat_error);
8994 return isl_stat_ok;
8995}
8996
8997const char *set_conversion_tests[] = {
8998 "[N] -> { [i] : N - 1 <= 2 i <= N }",
8999 "[N] -> { [i] : exists a : i = 4 a and N - 1 <= i <= N }",
9000 "[N] -> { [i,j] : exists a : i = 4 a and N - 1 <= i, 2j <= N }",
9001 "[N] -> { [[i]->[j]] : exists a : i = 4 a and N - 1 <= i, 2j <= N }",
9002 "[N] -> { [3*floor(N/2) + 5*floor(N/3)] }",
9003 "[a, b] -> { [c, d] : (4*floor((-a + c)/4) = -a + c and "
9004 "32*floor((-b + d)/32) = -b + d and 5 <= c <= 8 and "
9005 "-3 + c <= d <= 28 + c) }",
9006};
9007
9008/* Check that converting from isl_set to isl_pw_multi_aff and back
9009 * to isl_set produces the original isl_set.
9010 */
9012{
9013 int i;
9014 const char *str;
9015 isl_set *set1, *set2;
9017 int equal;
9018
9019 for (i = 0; i < ARRAY_SIZE(set_conversion_tests); ++i) {
9027
9028 if (equal < 0)
9029 return -1;
9030 if (!equal)
9031 isl_die(ctx, isl_error_unknown, "bad conversion",
9032 return -1);
9033 }
9034
9035 return 0;
9036}
9037
9038const char *conversion_tests[] = {
9039 "{ [a, b, c, d] -> s0[a, b, e, f] : "
9040 "exists (e0 = [(a - 2c)/3], e1 = [(-4 + b - 5d)/9], "
9041 "e2 = [(-d + f)/9]: 3e0 = a - 2c and 9e1 = -4 + b - 5d and "
9042 "9e2 = -d + f and f >= 0 and f <= 8 and 9e >= -5 - 2a and "
9043 "9e <= -2 - 2a) }",
9044 "{ [a, b] -> [c] : exists (e0 = floor((-a - b + c)/5): "
9045 "5e0 = -a - b + c and c >= -a and c <= 4 - a) }",
9046 "{ [a, b] -> [c] : exists d : 18 * d = -3 - a + 2c and 1 <= c <= 3 }",
9047};
9048
9049/* Check that converting from isl_map to isl_pw_multi_aff and back
9050 * to isl_map produces the original isl_map.
9051 */
9053{
9054 int i;
9055 isl_map *map1, *map2;
9057 int equal;
9058
9059 for (i = 0; i < ARRAY_SIZE(conversion_tests); ++i) {
9066
9067 if (equal < 0)
9068 return -1;
9069 if (!equal)
9070 isl_die(ctx, isl_error_unknown, "bad conversion",
9071 return -1);
9072 }
9073
9074 return 0;
9075}
9076
9077/* Descriptions of isl_pw_multi_aff objects for testing conversion
9078 * to isl_multi_pw_aff and back.
9079 */
9080const char *mpa_conversion_tests[] = {
9081 "{ [x] -> A[x] }",
9082 "{ [x] -> A[x] : x >= 0 }",
9083 "{ [x] -> A[x] : x >= 0; [x] -> A[-x] : x < 0 }",
9084 "{ [x] -> A[x, x + 1] }",
9085 "{ [x] -> A[] }",
9086 "{ [x] -> A[] : x >= 0 }",
9087};
9088
9089/* Check that conversion from isl_pw_multi_aff to isl_multi_pw_aff and
9090 * back to isl_pw_multi_aff preserves the original meaning.
9091 */
9093{
9094 int i;
9095 isl_pw_multi_aff *pma1, *pma2;
9096 isl_multi_pw_aff *mpa;
9097 int equal;
9098
9099 for (i = 0; i < ARRAY_SIZE(mpa_conversion_tests); ++i) {
9100 const char *str;
9103 pma2 = isl_pw_multi_aff_copy(pma1);
9109
9110 if (equal < 0)
9111 return -1;
9112 if (!equal)
9113 isl_die(ctx, isl_error_unknown, "bad conversion",
9114 return -1);
9115 }
9116
9117 return 0;
9118}
9119
9120/* Descriptions of union maps that should be convertible
9121 * to an isl_multi_union_pw_aff.
9122 */
9124 "{ [a, b, c, d] -> s0[a, b, e, f] : "
9125 "exists (e0 = [(a - 2c)/3], e1 = [(-4 + b - 5d)/9], "
9126 "e2 = [(-d + f)/9]: 3e0 = a - 2c and 9e1 = -4 + b - 5d and "
9127 "9e2 = -d + f and f >= 0 and f <= 8 and 9e >= -5 - 2a and "
9128 "9e <= -2 - 2a) }",
9129 "{ [a, b] -> [c] : exists (e0 = floor((-a - b + c)/5): "
9130 "5e0 = -a - b + c and c >= -a and c <= 4 - a) }",
9131 "{ [a, b] -> [c] : exists d : 18 * d = -3 - a + 2c and 1 <= c <= 3 }",
9132 "{ A[] -> B[0]; C[] -> B[1] }",
9133 "{ A[] -> B[]; C[] -> B[] }",
9134};
9135
9136/* Check that converting from isl_union_map to isl_multi_union_pw_aff and back
9137 * to isl_union_map produces the original isl_union_map.
9138 */
9140{
9141 int i;
9142 isl_union_map *umap1, *umap2;
9144 int equal;
9145
9146 for (i = 0; i < ARRAY_SIZE(umap_mupa_conversion_tests); ++i) {
9147 const char *str;
9149 umap1 = isl_union_map_read_from_str(ctx, str);
9150 umap2 = isl_union_map_copy(umap1);
9153 equal = isl_union_map_is_equal(umap1, umap2);
9154 isl_union_map_free(umap1);
9155 isl_union_map_free(umap2);
9156
9157 if (equal < 0)
9158 return -1;
9159 if (!equal)
9160 isl_die(ctx, isl_error_unknown, "bad conversion",
9161 return -1);
9162 }
9163
9164 return 0;
9165}
9166
9167static int test_conversion(isl_ctx *ctx)
9168{
9169 if (test_ma_conversion(ctx) < 0)
9170 return -1;
9171 if (test_set_conversion(ctx) < 0)
9172 return -1;
9173 if (test_map_conversion(ctx) < 0)
9174 return -1;
9175 if (test_mpa_conversion(ctx) < 0)
9176 return -1;
9177 if (test_union_map_mupa_conversion(ctx) < 0)
9178 return -1;
9179 return 0;
9180}
9181
9182/* Check that isl_basic_map_curry does not modify input.
9183 */
9184static int test_curry(isl_ctx *ctx)
9185{
9186 const char *str;
9187 isl_basic_map *bmap1, *bmap2;
9188 int equal;
9189
9190 str = "{ [A[] -> B[]] -> C[] }";
9191 bmap1 = isl_basic_map_read_from_str(ctx, str);
9193 equal = isl_basic_map_is_equal(bmap1, bmap2);
9194 isl_basic_map_free(bmap1);
9195 isl_basic_map_free(bmap2);
9196
9197 if (equal < 0)
9198 return -1;
9199 if (equal)
9201 "curried map should not be equal to original",
9202 return -1);
9203
9204 return 0;
9205}
9206
9207struct {
9208 const char *ma1;
9209 const char *ma;
9210 const char *res;
9211} pullback_tests[] = {
9212 { "{ B[i,j] -> C[i + 2j] }" , "{ A[a,b] -> B[b,a] }",
9213 "{ A[a,b] -> C[b + 2a] }" },
9214 { "{ B[i] -> C[2i] }", "{ A[a] -> B[(a)/2] }", "{ A[a] -> C[a] }" },
9215 { "{ B[i] -> C[(i)/2] }", "{ A[a] -> B[2a] }", "{ A[a] -> C[a] }" },
9216 { "{ B[i] -> C[(i)/2] }", "{ A[a] -> B[(a)/3] }",
9217 "{ A[a] -> C[(a)/6] }" },
9218 { "{ B[i] -> C[2i] }", "{ A[a] -> B[5a] }", "{ A[a] -> C[10a] }" },
9219 { "{ B[i] -> C[2i] }", "{ A[a] -> B[(a)/3] }",
9220 "{ A[a] -> C[(2a)/3] }" },
9221 { "{ B[i,j] -> C[i + j] }", "{ A[a] -> B[a,a] }", "{ A[a] -> C[2a] }"},
9222 { "{ B[a] -> C[a,a] }", "{ A[i,j] -> B[i + j] }",
9223 "{ A[i,j] -> C[i + j, i + j] }"},
9224 { "{ B[i] -> C[([i/2])] }", "{ B[5] }", "{ C[2] }" },
9225 { "[n] -> { B[i,j] -> C[([i/2]) + 2j] }",
9226 "[n] -> { B[n,[n/3]] }", "[n] -> { C[([n/2]) + 2*[n/3]] }", },
9227 { "{ [i, j] -> [floor((i)/4) + floor((2*i+j)/5)] }",
9228 "{ [i, j] -> [floor((i)/3), j] }",
9229 "{ [i, j] -> [(floor((i)/12) + floor((j + 2*floor((i)/3))/5))] }" },
9231
9232static int test_pullback(isl_ctx *ctx)
9233{
9234 int i;
9235 isl_multi_aff *ma1, *ma2;
9237 int equal;
9238
9239 for (i = 0; i < ARRAY_SIZE(pullback_tests); ++i) {
9244 equal = isl_multi_aff_plain_is_equal(ma1, ma2);
9245 isl_multi_aff_free(ma1);
9246 isl_multi_aff_free(ma2);
9247 if (equal < 0)
9248 return -1;
9249 if (!equal)
9250 isl_die(ctx, isl_error_unknown, "bad pullback",
9251 return -1);
9252 }
9253
9254 return 0;
9255}
9256
9257/* Check that negation is printed correctly and that equal expressions
9258 * are correctly identified.
9259 */
9260static int test_ast(isl_ctx *ctx)
9261{
9262 isl_ast_expr *expr, *expr1, *expr2, *expr3;
9263 char *str;
9264 int ok, equal;
9265
9266 expr1 = isl_ast_expr_from_id(isl_id_alloc(ctx, "A", NULL));
9267 expr2 = isl_ast_expr_from_id(isl_id_alloc(ctx, "B", NULL));
9268 expr = isl_ast_expr_add(expr1, expr2);
9269 expr2 = isl_ast_expr_copy(expr);
9270 expr = isl_ast_expr_neg(expr);
9271 expr2 = isl_ast_expr_neg(expr2);
9272 equal = isl_ast_expr_is_equal(expr, expr2);
9273 str = isl_ast_expr_to_C_str(expr);
9274 ok = str ? !strcmp(str, "-(A + B)") : -1;
9275 free(str);
9276 isl_ast_expr_free(expr);
9277 isl_ast_expr_free(expr2);
9278
9279 if (ok < 0 || equal < 0)
9280 return -1;
9281 if (!equal)
9283 "equal expressions not considered equal", return -1);
9284 if (!ok)
9286 "isl_ast_expr printed incorrectly", return -1);
9287
9288 expr1 = isl_ast_expr_from_id(isl_id_alloc(ctx, "A", NULL));
9289 expr2 = isl_ast_expr_from_id(isl_id_alloc(ctx, "B", NULL));
9290 expr = isl_ast_expr_add(expr1, expr2);
9291 expr3 = isl_ast_expr_from_id(isl_id_alloc(ctx, "C", NULL));
9292 expr = isl_ast_expr_sub(expr3, expr);
9293 str = isl_ast_expr_to_C_str(expr);
9294 ok = str ? !strcmp(str, "C - (A + B)") : -1;
9295 free(str);
9296 isl_ast_expr_free(expr);
9297
9298 if (ok < 0)
9299 return -1;
9300 if (!ok)
9302 "isl_ast_expr printed incorrectly", return -1);
9303
9304 return 0;
9305}
9306
9307/* Check that isl_ast_build_expr_from_set returns a valid expression
9308 * for an empty set. Note that isl_ast_build_expr_from_set getting
9309 * called on an empty set probably indicates a bug in the caller.
9310 */
9311static int test_ast_build(isl_ctx *ctx)
9312{
9313 isl_set *set;
9314 isl_ast_build *build;
9315 isl_ast_expr *expr;
9316
9319
9321 expr = isl_ast_build_expr_from_set(build, set);
9322
9323 isl_ast_expr_free(expr);
9324 isl_ast_build_free(build);
9325
9326 if (!expr)
9327 return -1;
9328
9329 return 0;
9330}
9331
9332/* Internal data structure for before_for and after_for callbacks.
9333 *
9334 * depth is the current depth
9335 * before is the number of times before_for has been called
9336 * after is the number of times after_for has been called
9337 */
9343
9344/* This function is called before each for loop in the AST generated
9345 * from test_ast_gen1.
9346 *
9347 * Increment the number of calls and the depth.
9348 * Check that the space returned by isl_ast_build_get_schedule_space
9349 * matches the target space of the schedule returned by
9350 * isl_ast_build_get_schedule.
9351 * Return an isl_id that is checked by the corresponding call
9352 * to after_for.
9353 */
9355 void *user)
9356{
9357 struct isl_test_codegen_data *data = user;
9358 isl_ctx *ctx;
9359 isl_space *space;
9361 isl_union_set *uset;
9362 isl_set *set;
9363 isl_bool empty;
9364 isl_size n;
9365 char name[] = "d0";
9366
9367 ctx = isl_ast_build_get_ctx(build);
9368
9369 if (data->before >= 3)
9371 "unexpected number of for nodes", return NULL);
9372 if (data->depth < 0 || data->depth >= 2)
9374 "unexpected depth", return NULL);
9375
9376 snprintf(name, sizeof(name), "d%d", data->depth);
9377 data->before++;
9378 data->depth++;
9379
9382 n = isl_union_set_n_set(uset);
9383 if (n != 1) {
9384 isl_union_set_free(uset);
9385 if (n < 0)
9386 return NULL;
9388 "expecting single range space", return NULL);
9389 }
9390
9391 space = isl_ast_build_get_schedule_space(build);
9392 set = isl_union_set_extract_set(uset, space);
9393 isl_union_set_free(uset);
9394 empty = isl_set_is_empty(set);
9396
9397 if (empty < 0)
9398 return NULL;
9399 if (empty)
9401 "spaces don't match", return NULL);
9402
9403 return isl_id_alloc(ctx, name, NULL);
9404}
9405
9406/* This function is called after each for loop in the AST generated
9407 * from test_ast_gen1.
9408 *
9409 * Increment the number of calls and decrement the depth.
9410 * Check that the annotation attached to the node matches
9411 * the isl_id returned by the corresponding call to before_for.
9412 */
9414 __isl_keep isl_ast_build *build, void *user)
9415{
9416 struct isl_test_codegen_data *data = user;
9417 isl_id *id;
9418 const char *name;
9419 int valid;
9420
9421 data->after++;
9422 data->depth--;
9423
9424 if (data->after > data->before)
9426 "mismatch in number of for nodes",
9427 return isl_ast_node_free(node));
9428
9429 id = isl_ast_node_get_annotation(node);
9430 if (!id)
9432 "missing annotation", return isl_ast_node_free(node));
9433
9434 name = isl_id_get_name(id);
9435 valid = name && atoi(name + 1) == data->depth;
9436 isl_id_free(id);
9437
9438 if (!valid)
9440 "wrong annotation", return isl_ast_node_free(node));
9441
9442 return node;
9443}
9444
9445/* This function is called after node in the AST generated
9446 * from test_ast_gen1.
9447 *
9448 * Increment the count in "user" if this is a for node and
9449 * return true to indicate that descendant should also be visited.
9450 */
9452{
9453 int *count = user;
9454
9456 ++*count;
9457
9458 return isl_bool_true;
9459}
9460
9461/* If "node" is a block node, then replace it by its first child.
9462 */
9464 void *user)
9465{
9466 isl_ast_node_list *children;
9467 isl_ast_node *child;
9468
9470 return node;
9471
9472 children = isl_ast_node_block_get_children(node);
9473 child = isl_ast_node_list_get_at(children, 0);
9474 isl_ast_node_list_free(children);
9475 isl_ast_node_free(node);
9476
9477 return child;
9478}
9479
9480/* Check that the before_each_for and after_each_for callbacks
9481 * are called for each for loop in the generated code,
9482 * that they are called in the right order and that the isl_id
9483 * returned from the before_each_for callback is attached to
9484 * the isl_ast_node passed to the corresponding after_each_for call.
9485 *
9486 * Additionally, check the basic functionality of
9487 * isl_ast_node_foreach_descendant_top_down by counting the number
9488 * of for loops in the resulting AST,
9489 * as well as that of isl_ast_node_map_descendant_bottom_up
9490 * by replacing the block node by its first child and
9491 * counting the number of for loops again.
9492 */
9494{
9495 int count = 0;
9496 int modified_count = 0;
9497 const char *str;
9498 isl_set *set;
9500 isl_ast_build *build;
9501 isl_ast_node *tree;
9502 struct isl_test_codegen_data data;
9503
9504 str = "[N] -> { : N >= 10 }";
9506 str = "[N] -> { A[i,j] -> S[8,i,3,j] : 0 <= i,j <= N; "
9507 "B[i,j] -> S[8,j,9,i] : 0 <= i,j <= N }";
9509
9510 data.before = 0;
9511 data.after = 0;
9512 data.depth = 0;
9515 &before_for, &data);
9517 &after_for, &data);
9519 isl_ast_build_free(build);
9520
9522 &count_for, &count) < 0)
9523 tree = isl_ast_node_free(tree);
9524
9526
9528 &modified_count) < 0)
9529 tree = isl_ast_node_free(tree);
9530
9531 if (!tree)
9532 return isl_stat_error;
9533
9534 isl_ast_node_free(tree);
9535
9536 if (data.before != 3 || data.after != 3 || count != 3)
9538 "unexpected number of for nodes",
9539 return isl_stat_error);
9540
9541 if (modified_count != 2)
9543 "unexpected number of for nodes after changes",
9544 return isl_stat_error);
9545
9546 return isl_stat_ok;
9547}
9548
9549/* Check that the AST generator handles domains that are integrally disjoint
9550 * but not rationally disjoint.
9551 */
9552static int test_ast_gen2(isl_ctx *ctx)
9553{
9554 const char *str;
9555 isl_set *set;
9558 isl_ast_build *build;
9559 isl_ast_node *tree;
9560
9561 str = "{ A[i,j] -> [i,j] : 0 <= i,j <= 1 }";
9565
9566 str = "{ [i,j] -> atomic[1] : i + j = 1; [i,j] -> unroll[1] : i = j }";
9568 build = isl_ast_build_set_options(build, options);
9570 isl_ast_build_free(build);
9571 if (!tree)
9572 return -1;
9573 isl_ast_node_free(tree);
9574
9575 return 0;
9576}
9577
9578/* Increment *user on each call.
9579 */
9581 __isl_keep isl_ast_build *build, void *user)
9582{
9583 int *n = user;
9584
9585 (*n)++;
9586
9587 return node;
9588}
9589
9590/* Test that unrolling tries to minimize the number of instances.
9591 * In particular, for the schedule given below, make sure it generates
9592 * 3 nodes (rather than 101).
9593 */
9594static int test_ast_gen3(isl_ctx *ctx)
9595{
9596 const char *str;
9597 isl_set *set;
9600 isl_ast_build *build;
9601 isl_ast_node *tree;
9602 int n_domain = 0;
9603
9604 str = "[n] -> { A[i] -> [i] : 0 <= i <= 100 and n <= i <= n + 2 }";
9607
9608 str = "{ [i] -> unroll[0] }";
9610
9612 build = isl_ast_build_set_options(build, options);
9614 &count_domains, &n_domain);
9616 isl_ast_build_free(build);
9617 if (!tree)
9618 return -1;
9619
9620 isl_ast_node_free(tree);
9621
9622 if (n_domain != 3)
9624 "unexpected number of for nodes", return -1);
9625
9626 return 0;
9627}
9628
9629/* Check that if the ast_build_exploit_nested_bounds options is set,
9630 * we do not get an outer if node in the generated AST,
9631 * while we do get such an outer if node if the options is not set.
9632 */
9633static int test_ast_gen4(isl_ctx *ctx)
9634{
9635 const char *str;
9636 isl_set *set;
9638 isl_ast_build *build;
9639 isl_ast_node *tree;
9641 int enb;
9642
9644 str = "[N,M] -> { A[i,j] -> [i,j] : 0 <= i <= N and 0 <= j <= M }";
9645
9647
9652 isl_ast_build_free(build);
9653 if (!tree)
9654 return -1;
9655
9657 isl_ast_node_free(tree);
9658
9659 if (type == isl_ast_node_if)
9661 "not expecting if node", return -1);
9662
9664
9669 isl_ast_build_free(build);
9670 if (!tree)
9671 return -1;
9672
9674 isl_ast_node_free(tree);
9675
9676 if (type != isl_ast_node_if)
9678 "expecting if node", return -1);
9679
9681
9682 return 0;
9683}
9684
9685/* This function is called for each leaf in the AST generated
9686 * from test_ast_gen5.
9687 *
9688 * We finalize the AST generation by extending the outer schedule
9689 * with a zero-dimensional schedule. If this results in any for loops,
9690 * then this means that we did not pass along enough information
9691 * about the outer schedule to the inner AST generation.
9692 */
9694 void *user)
9695{
9696 isl_union_map *schedule, *extra;
9697 isl_ast_node *tree;
9698
9704 isl_ast_build_free(build);
9705
9706 if (!tree)
9707 return NULL;
9708
9711 "code should not contain any for loop",
9712 return isl_ast_node_free(tree));
9713
9714 return tree;
9715}
9716
9717/* Check that we do not lose any information when going back and
9718 * forth between internal and external schedule.
9719 *
9720 * In particular, we create an AST where we unroll the only
9721 * non-constant dimension in the schedule. We therefore do
9722 * not expect any for loops in the AST. However, older versions
9723 * of isl would not pass along enough information about the outer
9724 * schedule when performing an inner code generation from a create_leaf
9725 * callback, resulting in the inner code generation producing a for loop.
9726 */
9727static int test_ast_gen5(isl_ctx *ctx)
9728{
9729 const char *str;
9730 isl_set *set;
9732 isl_ast_build *build;
9733 isl_ast_node *tree;
9734
9735 str = "{ A[] -> [1, 1, 2]; B[i] -> [1, i, 0] : i >= 1 and i <= 2 }";
9737
9738 str = "{ [a, b, c] -> unroll[1] : exists (e0 = [(a)/4]: "
9739 "4e0 >= -1 + a - b and 4e0 <= -2 + a + b) }";
9741
9744 build = isl_ast_build_set_options(build, options);
9745 build = isl_ast_build_set_create_leaf(build, &create_leaf, NULL);
9747 isl_ast_build_free(build);
9748 isl_ast_node_free(tree);
9749 if (!tree)
9750 return -1;
9751
9752 return 0;
9753}
9754
9755/* Check that the expression
9756 *
9757 * [n] -> { [n/2] : n <= 0 and n % 2 = 0; [0] : n > 0 }
9758 *
9759 * is not combined into
9760 *
9761 * min(n/2, 0)
9762 *
9763 * as this would result in n/2 being evaluated in parts of
9764 * the definition domain where n is not a multiple of 2.
9765 */
9766static int test_ast_expr(isl_ctx *ctx)
9767{
9768 const char *str;
9769 isl_pw_aff *pa;
9770 isl_ast_build *build;
9771 isl_ast_expr *expr;
9772 int min_max;
9773 int is_min;
9774
9777
9778 str = "[n] -> { [n/2] : n <= 0 and n % 2 = 0; [0] : n > 0 }";
9780 build = isl_ast_build_alloc(ctx);
9781 expr = isl_ast_build_expr_from_pw_aff(build, pa);
9782 is_min = isl_ast_expr_get_type(expr) == isl_ast_expr_op &&
9784 isl_ast_build_free(build);
9785 isl_ast_expr_free(expr);
9786
9788
9789 if (!expr)
9790 return -1;
9791 if (is_min)
9793 "expressions should not be combined", return -1);
9794
9795 return 0;
9796}
9797
9798static int test_ast_gen(isl_ctx *ctx)
9799{
9800 if (test_ast_gen1(ctx) < 0)
9801 return -1;
9802 if (test_ast_gen2(ctx) < 0)
9803 return -1;
9804 if (test_ast_gen3(ctx) < 0)
9805 return -1;
9806 if (test_ast_gen4(ctx) < 0)
9807 return -1;
9808 if (test_ast_gen5(ctx) < 0)
9809 return -1;
9810 if (test_ast_expr(ctx) < 0)
9811 return -1;
9812 return 0;
9813}
9814
9815/* Check if dropping output dimensions from an isl_pw_multi_aff
9816 * works properly.
9817 */
9819{
9820 const char *str;
9821 isl_pw_multi_aff *pma1, *pma2;
9822 int equal;
9823
9824 str = "{ [i,j] -> [i+j, 4i-j] }";
9826 str = "{ [i,j] -> [4i-j] }";
9828
9829 pma1 = isl_pw_multi_aff_drop_dims(pma1, isl_dim_out, 0, 1);
9830
9832
9835 if (equal < 0)
9836 return -1;
9837 if (!equal)
9839 "expressions not equal", return -1);
9840
9841 return 0;
9842}
9843
9844/* Check that we can properly parse multi piecewise affine expressions
9845 * where the piecewise affine expressions have different domains.
9846 */
9848{
9849 const char *str;
9850 isl_set *dom, *dom2;
9851 isl_multi_pw_aff *mpa1, *mpa2;
9852 isl_pw_aff *pa;
9853 int equal;
9854 int equal_domain;
9855
9856 mpa1 = isl_multi_pw_aff_read_from_str(ctx, "{ [i] -> [i] }");
9857 dom = isl_set_read_from_str(ctx, "{ [i] : i > 0 }");
9858 mpa1 = isl_multi_pw_aff_intersect_domain(mpa1, dom);
9859 mpa2 = isl_multi_pw_aff_read_from_str(ctx, "{ [i] -> [2i] }");
9860 mpa2 = isl_multi_pw_aff_flat_range_product(mpa1, mpa2);
9861 str = "{ [i] -> [(i : i > 0), 2i] }";
9863
9864 equal = isl_multi_pw_aff_plain_is_equal(mpa1, mpa2);
9865
9866 pa = isl_multi_pw_aff_get_pw_aff(mpa1, 0);
9867 dom = isl_pw_aff_domain(pa);
9868 pa = isl_multi_pw_aff_get_pw_aff(mpa1, 1);
9869 dom2 = isl_pw_aff_domain(pa);
9870 equal_domain = isl_set_is_equal(dom, dom2);
9871
9872 isl_set_free(dom);
9873 isl_set_free(dom2);
9874 isl_multi_pw_aff_free(mpa1);
9875 isl_multi_pw_aff_free(mpa2);
9876
9877 if (equal < 0)
9878 return -1;
9879 if (!equal)
9881 "expressions not equal", return -1);
9882
9883 if (equal_domain < 0)
9884 return -1;
9885 if (equal_domain)
9887 "domains unexpectedly equal", return -1);
9888
9889 return 0;
9890}
9891
9892/* Check that the dimensions in the explicit domain
9893 * of a multi piecewise affine expression are properly
9894 * taken into account.
9895 */
9897{
9898 const char *str;
9899 isl_bool involves1, involves2, involves3, equal;
9900 isl_multi_pw_aff *mpa, *mpa1, *mpa2;
9901
9902 str = "{ A[x,y] -> B[] : x >= y }";
9904 involves1 = isl_multi_pw_aff_involves_dims(mpa, isl_dim_in, 0, 2);
9905 mpa1 = isl_multi_pw_aff_copy(mpa);
9906
9907 mpa = isl_multi_pw_aff_insert_dims(mpa, isl_dim_in, 0, 1);
9908 involves2 = isl_multi_pw_aff_involves_dims(mpa, isl_dim_in, 0, 1);
9909 involves3 = isl_multi_pw_aff_involves_dims(mpa, isl_dim_in, 1, 2);
9910 str = "{ [a,x,y] -> B[] : x >= y }";
9912 equal = isl_multi_pw_aff_plain_is_equal(mpa, mpa2);
9913 isl_multi_pw_aff_free(mpa2);
9914
9915 mpa = isl_multi_pw_aff_drop_dims(mpa, isl_dim_in, 0, 1);
9916 mpa = isl_multi_pw_aff_set_tuple_name(mpa, isl_dim_in, "A");
9917 if (equal >= 0 && equal)
9918 equal = isl_multi_pw_aff_plain_is_equal(mpa, mpa1);
9919 isl_multi_pw_aff_free(mpa1);
9920 isl_multi_pw_aff_free(mpa);
9921
9922 if (involves1 < 0 || involves2 < 0 || involves3 < 0 || equal < 0)
9923 return -1;
9924 if (!equal)
9926 "incorrect result of dimension insertion/removal",
9927 return isl_stat_error);
9928 if (!involves1 || involves2 || !involves3)
9930 "incorrect characterization of involved dimensions",
9931 return isl_stat_error);
9932
9933 return 0;
9934}
9935
9936/* Check that isl_multi_union_pw_aff_multi_val_on_domain
9937 * sets the explicit domain of a zero-dimensional result,
9938 * such that it can be converted to an isl_union_map.
9939 */
9941{
9942 isl_space *space;
9943 isl_union_set *dom;
9944 isl_multi_val *mv;
9946 isl_union_map *umap;
9947
9948 dom = isl_union_set_read_from_str(ctx, "{ A[]; B[] }");
9949 space = isl_union_set_get_space(dom);
9950 mv = isl_multi_val_zero(isl_space_set_from_params(space));
9953 isl_union_map_free(umap);
9954 if (!umap)
9955 return isl_stat_error;
9956
9957 return isl_stat_ok;
9958}
9959
9960/* String descriptions of boxes that
9961 * are used for reconstructing box maps from their lower and upper bounds.
9962 */
9963static const char *multi_pw_aff_box_tests[] = {
9964 "{ A[x, y] -> [] : x + y >= 0 }",
9965 "[N] -> { A[x, y] -> [x] : x + y <= N }",
9966 "[N] -> { A[x, y] -> [x : y] : x + y <= N }",
9967};
9968
9969/* Check that map representations of boxes can be reconstructed
9970 * from their lower and upper bounds.
9971 */
9973{
9974 int i;
9975
9976 for (i = 0; i < ARRAY_SIZE(multi_pw_aff_box_tests); ++i) {
9977 const char *str;
9979 isl_map *map, *box;
9980 isl_multi_pw_aff *min, *max;
9981
9987 box = isl_map_lower_bound_multi_pw_aff(box, min);
9988 box = isl_map_upper_bound_multi_pw_aff(box, max);
9989 equal = isl_map_is_equal(map, box);
9991 isl_map_free(box);
9992 if (equal < 0)
9993 return isl_stat_error;
9994 if (!equal)
9996 "unexpected result", return isl_stat_error);
9997 }
9998
9999 return isl_stat_ok;
10000}
10001
10002/* Perform some tests on multi piecewise affine expressions.
10003 */
10005{
10006 if (test_multi_pw_aff_1(ctx) < 0)
10007 return -1;
10008 if (test_multi_pw_aff_2(ctx) < 0)
10009 return -1;
10010 if (test_multi_pw_aff_3(ctx) < 0)
10011 return -1;
10012 if (test_multi_pw_aff_box(ctx) < 0)
10013 return -1;
10014 return 0;
10015}
10016
10017/* This is a regression test for a bug where isl_basic_map_simplify
10018 * would end up in an infinite loop. In particular, we construct
10019 * an empty basic set that is not obviously empty.
10020 * isl_basic_set_is_empty marks the basic set as empty.
10021 * After projecting out i3, the variable can be dropped completely,
10022 * but isl_basic_map_simplify refrains from doing so if the basic set
10023 * is empty and would end up in an infinite loop if it didn't test
10024 * explicitly for empty basic maps in the outer loop.
10025 */
10026static int test_simplify_1(isl_ctx *ctx)
10027{
10028 const char *str;
10029 isl_basic_set *bset;
10030 int empty;
10031
10032 str = "{ [i0, i1, i2, i3] : i0 >= -2 and 6i2 <= 4 + i0 + 5i1 and "
10033 "i2 <= 22 and 75i2 <= 111 + 13i0 + 60i1 and "
10034 "25i2 >= 38 + 6i0 + 20i1 and i0 <= -1 and i2 >= 20 and "
10035 "i3 >= i2 }";
10036 bset = isl_basic_set_read_from_str(ctx, str);
10037 empty = isl_basic_set_is_empty(bset);
10038 bset = isl_basic_set_project_out(bset, isl_dim_set, 3, 1);
10039 isl_basic_set_free(bset);
10040 if (!bset)
10041 return -1;
10042 if (!empty)
10044 "basic set should be empty", return -1);
10045
10046 return 0;
10047}
10048
10049/* Check that the equality in the set description below
10050 * is simplified away.
10051 */
10052static int test_simplify_2(isl_ctx *ctx)
10053{
10054 const char *str;
10055 isl_basic_set *bset;
10057
10058 str = "{ [a] : exists e0, e1: 32e1 = 31 + 31a + 31e0 }";
10059 bset = isl_basic_set_read_from_str(ctx, str);
10061 isl_basic_set_free(bset);
10062
10063 if (universe < 0)
10064 return -1;
10065 if (!universe)
10067 "equality not simplified away", return -1);
10068 return 0;
10069}
10070
10071/* Some simplification tests.
10072 */
10073static int test_simplify(isl_ctx *ctx)
10074{
10075 if (test_simplify_1(ctx) < 0)
10076 return -1;
10077 if (test_simplify_2(ctx) < 0)
10078 return -1;
10079 return 0;
10080}
10081
10082/* This is a regression test for a bug where isl_tab_basic_map_partial_lexopt
10083 * with gbr context would fail to disable the use of the shifted tableau
10084 * when transferring equalities for the input to the context, resulting
10085 * in invalid sample values.
10086 */
10088{
10089 const char *str;
10090 isl_basic_set *bset;
10091 isl_basic_map *bmap;
10092 isl_map *map;
10093
10094 str = "{ [1, b, c, 1 - c] -> [e] : 2e <= -c and 2e >= -3 + c }";
10095 bmap = isl_basic_map_read_from_str(ctx, str);
10096 str = "{ [a, b, c, d] : c <= 1 and 2d >= 6 - 4b - c }";
10097 bset = isl_basic_set_read_from_str(ctx, str);
10098 map = isl_basic_map_partial_lexmin(bmap, bset, NULL);
10100
10101 if (!map)
10102 return -1;
10103
10104 return 0;
10105}
10106
10107/* Check that the variable compression performed on the existentially
10108 * quantified variables inside isl_basic_set_compute_divs is not confused
10109 * by the implicit equalities among the parameters.
10110 */
10112{
10113 const char *str;
10114 isl_basic_set *bset;
10115 isl_set *set;
10116
10117 str = "[a, b, c, d, e] -> { [] : exists (e0: 2d = b and a <= 124 and "
10118 "b <= 2046 and b >= 0 and b <= 60 + 64a and 2e >= b + 2c and "
10119 "2e >= b and 2e <= 1 + b and 2e <= 1 + b + 2c and "
10120 "32768e0 >= -124 + a and 2097152e0 <= 60 + 64a - b) }";
10121 bset = isl_basic_set_read_from_str(ctx, str);
10124 if (!set)
10125 return -1;
10126
10127 return 0;
10128}
10129
10130/* Check that isl_schedule_get_map is not confused by a schedule tree
10131 * with divergent filter node parameters, as can result from a call
10132 * to isl_schedule_intersect_domain.
10133 */
10135{
10136 const char *str;
10137 isl_union_set *uset;
10138 isl_schedule *sched1, *sched2;
10139 isl_union_map *umap;
10140
10141 uset = isl_union_set_read_from_str(ctx, "{ A[i] }");
10142 sched1 = isl_schedule_from_domain(uset);
10143 uset = isl_union_set_read_from_str(ctx, "{ B[] }");
10144 sched2 = isl_schedule_from_domain(uset);
10145
10146 sched1 = isl_schedule_sequence(sched1, sched2);
10147 str = "[n] -> { A[i] : 0 <= i < n; B[] }";
10148 uset = isl_union_set_read_from_str(ctx, str);
10149 sched1 = isl_schedule_intersect_domain(sched1, uset);
10150 umap = isl_schedule_get_map(sched1);
10151 isl_schedule_free(sched1);
10152 isl_union_map_free(umap);
10153 if (!umap)
10154 return -1;
10155
10156 return 0;
10157}
10158
10159/* Check that a zero-dimensional prefix schedule keeps track
10160 * of the domain and outer filters.
10161 */
10163{
10164 const char *str;
10166 isl_union_set *uset;
10167 isl_union_set_list *filters;
10169 isl_schedule_node *node;
10170
10171 str = "{ S1[i,j] : 0 <= i,j < 10; S2[i,j] : 0 <= i,j < 10 }";
10172 uset = isl_union_set_read_from_str(ctx, str);
10173 node = isl_schedule_node_from_domain(uset);
10174 node = isl_schedule_node_child(node, 0);
10175
10176 str = "{ S1[i,j] : i > j }";
10177 uset = isl_union_set_read_from_str(ctx, str);
10178 filters = isl_union_set_list_from_union_set(uset);
10179 str = "{ S1[i,j] : i <= j; S2[i,j] }";
10180 uset = isl_union_set_read_from_str(ctx, str);
10181 filters = isl_union_set_list_add(filters, uset);
10182 node = isl_schedule_node_insert_sequence(node, filters);
10183
10184 node = isl_schedule_node_grandchild(node, 0, 0);
10186 str = "([] : { S1[i,j] : i > j })";
10188 equal = isl_multi_union_pw_aff_plain_is_equal(mupa, mupa2);
10189 isl_multi_union_pw_aff_free(mupa2);
10190 isl_multi_union_pw_aff_free(mupa);
10192
10193 if (equal < 0)
10194 return -1;
10195 if (!equal)
10196 isl_die(ctx, isl_error_unknown, "unexpected prefix schedule",
10197 return -1);
10198
10199 return 0;
10200}
10201
10202/* Check that the reaching domain elements and the prefix schedule
10203 * at a leaf node are the same before and after grouping.
10204 */
10206{
10207 int equal;
10208 const char *str;
10209 isl_id *id;
10210 isl_union_set *uset;
10212 isl_union_pw_multi_aff *upma1, *upma2;
10213 isl_union_set *domain1, *domain2;
10214 isl_union_map *umap1, *umap2;
10215 isl_schedule_node *node;
10216
10217 str = "{ S1[i,j] : 0 <= i,j < 10; S2[i,j] : 0 <= i,j < 10 }";
10218 uset = isl_union_set_read_from_str(ctx, str);
10219 node = isl_schedule_node_from_domain(uset);
10220 node = isl_schedule_node_child(node, 0);
10221 str = "[{ S1[i,j] -> [i]; S2[i,j] -> [9 - i] }]";
10224 node = isl_schedule_node_child(node, 0);
10225 str = "[{ S1[i,j] -> [j]; S2[i,j] -> [j] }]";
10228 node = isl_schedule_node_child(node, 0);
10231 domain1 = isl_schedule_node_get_domain(node);
10232 id = isl_id_alloc(ctx, "group", NULL);
10233 node = isl_schedule_node_parent(node);
10234 node = isl_schedule_node_group(node, id);
10235 node = isl_schedule_node_child(node, 0);
10238 domain2 = isl_schedule_node_get_domain(node);
10240 if (equal >= 0 && equal)
10241 equal = isl_union_set_is_equal(domain1, domain2);
10242 if (equal >= 0 && equal)
10243 equal = isl_union_map_is_equal(umap1, umap2);
10244 isl_union_map_free(umap1);
10245 isl_union_map_free(umap2);
10246 isl_union_set_free(domain1);
10247 isl_union_set_free(domain2);
10251
10252 if (equal < 0)
10253 return -1;
10254 if (!equal)
10256 "expressions not equal", return -1);
10257
10258 return 0;
10259}
10260
10261/* Check that we can have nested groupings and that the union map
10262 * schedule representation is the same before and after the grouping.
10263 * Note that after the grouping, the union map representation contains
10264 * the domain constraints from the ranges of the expansion nodes,
10265 * while they are missing from the union map representation of
10266 * the tree without expansion nodes.
10267 *
10268 * Also check that the global expansion is as expected.
10269 */
10271{
10272 int equal, equal_expansion;
10273 const char *str;
10274 isl_id *id;
10275 isl_union_set *uset;
10276 isl_union_map *umap1, *umap2;
10277 isl_union_map *expansion1, *expansion2;
10278 isl_union_set_list *filters;
10281 isl_schedule_node *node;
10282
10283 str = "{ S1[i,j] : 0 <= i,j < 10; S2[i,j] : 0 <= i,j < 10; "
10284 "S3[i,j] : 0 <= i,j < 10 }";
10285 uset = isl_union_set_read_from_str(ctx, str);
10286 node = isl_schedule_node_from_domain(uset);
10287 node = isl_schedule_node_child(node, 0);
10288 str = "[{ S1[i,j] -> [i]; S2[i,j] -> [i]; S3[i,j] -> [i] }]";
10291 node = isl_schedule_node_child(node, 0);
10292 str = "{ S1[i,j] }";
10293 uset = isl_union_set_read_from_str(ctx, str);
10294 filters = isl_union_set_list_from_union_set(uset);
10295 str = "{ S2[i,j]; S3[i,j] }";
10296 uset = isl_union_set_read_from_str(ctx, str);
10297 filters = isl_union_set_list_add(filters, uset);
10298 node = isl_schedule_node_insert_sequence(node, filters);
10299 node = isl_schedule_node_grandchild(node, 1, 0);
10300 str = "{ S2[i,j] }";
10301 uset = isl_union_set_read_from_str(ctx, str);
10302 filters = isl_union_set_list_from_union_set(uset);
10303 str = "{ S3[i,j] }";
10304 uset = isl_union_set_read_from_str(ctx, str);
10305 filters = isl_union_set_list_add(filters, uset);
10306 node = isl_schedule_node_insert_sequence(node, filters);
10307
10311 umap1 = isl_union_map_intersect_domain(umap1, uset);
10313
10314 node = isl_schedule_node_grandparent(node);
10315 id = isl_id_alloc(ctx, "group1", NULL);
10316 node = isl_schedule_node_group(node, id);
10317 node = isl_schedule_node_grandchild(node, 1, 0);
10318 id = isl_id_alloc(ctx, "group2", NULL);
10319 node = isl_schedule_node_group(node, id);
10320
10324
10325 node = isl_schedule_node_root(node);
10326 node = isl_schedule_node_child(node, 0);
10327 expansion1 = isl_schedule_node_get_subtree_expansion(node);
10329
10330 str = "{ group1[i] -> S1[i,j] : 0 <= i,j < 10; "
10331 "group1[i] -> S2[i,j] : 0 <= i,j < 10; "
10332 "group1[i] -> S3[i,j] : 0 <= i,j < 10 }";
10333
10334 expansion2 = isl_union_map_read_from_str(ctx, str);
10335
10336 equal = isl_union_map_is_equal(umap1, umap2);
10337 equal_expansion = isl_union_map_is_equal(expansion1, expansion2);
10338
10339 isl_union_map_free(umap1);
10340 isl_union_map_free(umap2);
10341 isl_union_map_free(expansion1);
10342 isl_union_map_free(expansion2);
10343
10344 if (equal < 0 || equal_expansion < 0)
10345 return -1;
10346 if (!equal)
10348 "expressions not equal", return -1);
10349 if (!equal_expansion)
10351 "unexpected expansion", return -1);
10352
10353 return 0;
10354}
10355
10356/* Some tests for the isl_schedule_node_group function.
10357 */
10359{
10360 if (test_schedule_tree_group_1(ctx) < 0)
10361 return -1;
10362 if (test_schedule_tree_group_2(ctx) < 0)
10363 return -1;
10364 return 0;
10365}
10366
10367struct {
10368 const char *set;
10369 const char *dual;
10370} coef_tests[] = {
10371 { "{ rat: [i] : 0 <= i <= 10 }",
10372 "{ rat: coefficients[[cst] -> [a]] : cst >= 0 and 10a + cst >= 0 }" },
10373 { "{ rat: [i] : FALSE }",
10374 "{ rat: coefficients[[cst] -> [a]] }" },
10375 { "{ rat: [i] : }",
10376 "{ rat: coefficients[[cst] -> [0]] : cst >= 0 }" },
10377 { "{ [0:,1,2:3] }",
10378 "{ rat: coefficients[[c_cst] -> [a, b, c]] : "
10379 "a >= 0 and 2c >= -c_cst - b and 3c >= -c_cst - b }" },
10380 { "[M, N] -> { [x = (1 - N):-1, -4x:(M - 4x)] }",
10381 "{ rat: coefficients[[c_cst, c_M = 0:, c_N = 0:] -> [a, b = -c_M:]] :"
10382 "4b >= -c_N + a and 4b >= -c_cst - 2c_N + a }" },
10383 { "{ rat : [x, y] : 1 <= 2x <= 9 and 2 <= 3y <= 16 }",
10384 "{ rat: coefficients[[c_cst] -> [c_x, c_y]] : "
10385 "4c_y >= -6c_cst - 3c_x and 4c_y >= -6c_cst - 27c_x and "
10386 "32c_y >= -6c_cst - 3c_x and 32c_y >= -6c_cst - 27c_x }" },
10387 { "{ [x, y, z] : 3y <= 2x - 2 and y >= -2 + 2x and 2y >= 2 - x }",
10388 "{ rat: coefficients[[cst] -> [a, b, c]] }" },
10390
10391struct {
10392 const char *set;
10393 const char *dual;
10394} sol_tests[] = {
10395 { "{ rat: coefficients[[cst] -> [a]] : cst >= 0 and 10a + cst >= 0 }",
10396 "{ rat: [i] : 0 <= i <= 10 }" },
10397 { "{ rat: coefficients[[cst] -> [a]] : FALSE }",
10398 "{ rat: [i] }" },
10399 { "{ rat: coefficients[[cst] -> [a]] }",
10400 "{ rat: [i] : FALSE }" },
10402
10403/* Test the basic functionality of isl_basic_set_coefficients and
10404 * isl_basic_set_solutions.
10405 */
10406static int test_dual(isl_ctx *ctx)
10407{
10408 int i;
10409
10410 for (i = 0; i < ARRAY_SIZE(coef_tests); ++i) {
10411 int equal;
10412 isl_basic_set *bset1, *bset2;
10413
10416 bset1 = isl_basic_set_coefficients(bset1);
10417 equal = isl_basic_set_is_equal(bset1, bset2);
10418 isl_basic_set_free(bset1);
10419 isl_basic_set_free(bset2);
10420 if (equal < 0)
10421 return -1;
10422 if (!equal)
10424 "incorrect dual", return -1);
10425 }
10426
10427 for (i = 0; i < ARRAY_SIZE(sol_tests); ++i) {
10428 int equal;
10429 isl_basic_set *bset1, *bset2;
10430
10431 bset1 = isl_basic_set_read_from_str(ctx, sol_tests[i].set);
10433 bset1 = isl_basic_set_solutions(bset1);
10434 equal = isl_basic_set_is_equal(bset1, bset2);
10435 isl_basic_set_free(bset1);
10436 isl_basic_set_free(bset2);
10437 if (equal < 0)
10438 return -1;
10439 if (!equal)
10441 "incorrect dual", return -1);
10442 }
10443
10444 return 0;
10445}
10446
10447struct {
10450 const char *domain;
10451 const char *schedule;
10452 const char *sizes;
10453 const char *tile;
10454 const char *point;
10455} tile_tests[] = {
10456 { 0, 0, "[n] -> { S[i,j] : 0 <= i,j < n }",
10457 "[{ S[i,j] -> [i] }, { S[i,j] -> [j] }]",
10458 "{ [32,32] }",
10459 "[{ S[i,j] -> [floor(i/32)] }, { S[i,j] -> [floor(j/32)] }]",
10460 "[{ S[i,j] -> [i] }, { S[i,j] -> [j] }]",
10461 },
10462 { 1, 0, "[n] -> { S[i,j] : 0 <= i,j < n }",
10463 "[{ S[i,j] -> [i] }, { S[i,j] -> [j] }]",
10464 "{ [32,32] }",
10465 "[{ S[i,j] -> [32*floor(i/32)] }, { S[i,j] -> [32*floor(j/32)] }]",
10466 "[{ S[i,j] -> [i] }, { S[i,j] -> [j] }]",
10467 },
10468 { 0, 1, "[n] -> { S[i,j] : 0 <= i,j < n }",
10469 "[{ S[i,j] -> [i] }, { S[i,j] -> [j] }]",
10470 "{ [32,32] }",
10471 "[{ S[i,j] -> [floor(i/32)] }, { S[i,j] -> [floor(j/32)] }]",
10472 "[{ S[i,j] -> [i%32] }, { S[i,j] -> [j%32] }]",
10473 },
10474 { 1, 1, "[n] -> { S[i,j] : 0 <= i,j < n }",
10475 "[{ S[i,j] -> [i] }, { S[i,j] -> [j] }]",
10476 "{ [32,32] }",
10477 "[{ S[i,j] -> [32*floor(i/32)] }, { S[i,j] -> [32*floor(j/32)] }]",
10478 "[{ S[i,j] -> [i%32] }, { S[i,j] -> [j%32] }]",
10479 },
10481
10482/* Basic tiling tests. Create a schedule tree with a domain and a band node,
10483 * tile the band and then check if the tile and point bands have the
10484 * expected partial schedule.
10485 */
10486static int test_tile(isl_ctx *ctx)
10487{
10488 int i;
10489 int scale;
10490 int shift;
10491
10494
10495 for (i = 0; i < ARRAY_SIZE(tile_tests); ++i) {
10496 int opt;
10497 int equal;
10498 const char *str;
10501 isl_schedule_node *node;
10503
10504 opt = tile_tests[i].scale_tile;
10506 opt = tile_tests[i].shift_point;
10508
10509 str = tile_tests[i].domain;
10512 node = isl_schedule_node_child(node, 0);
10513 str = tile_tests[i].schedule;
10516 str = tile_tests[i].sizes;
10518 node = isl_schedule_node_band_tile(node, sizes);
10519
10520 str = tile_tests[i].tile;
10523 equal = isl_multi_union_pw_aff_plain_is_equal(mupa, mupa2);
10524 isl_multi_union_pw_aff_free(mupa);
10525 isl_multi_union_pw_aff_free(mupa2);
10526
10527 node = isl_schedule_node_child(node, 0);
10528
10529 str = tile_tests[i].point;
10532 if (equal >= 0 && equal)
10533 equal = isl_multi_union_pw_aff_plain_is_equal(mupa,
10534 mupa2);
10535 isl_multi_union_pw_aff_free(mupa);
10536 isl_multi_union_pw_aff_free(mupa2);
10537
10539
10540 if (equal < 0)
10541 return -1;
10542 if (!equal)
10544 "unexpected result", return -1);
10545 }
10546
10549
10550 return 0;
10551}
10552
10553/* Check that the domain hash of a space is equal to the hash
10554 * of the domain of the space, both ignoring parameters.
10555 */
10557{
10558 isl_map *map;
10559 isl_space *space;
10560 uint32_t hash1, hash2;
10561
10562 map = isl_map_read_from_str(ctx, "[n] -> { A[B[x] -> C[]] -> D[] }");
10563 space = isl_map_get_space(map);
10565 hash1 = isl_space_get_tuple_domain_hash(space);
10566 space = isl_space_domain(space);
10567 hash2 = isl_space_get_tuple_hash(space);
10568 isl_space_free(space);
10569
10570 if (!space)
10571 return -1;
10572 if (hash1 != hash2)
10574 "domain hash not equal to hash of domain", return -1);
10575
10576 return 0;
10577}
10578
10579/* Check that a universe basic set that is not obviously equal to the universe
10580 * is still recognized as being equal to the universe.
10581 */
10582static int test_universe(isl_ctx *ctx)
10583{
10584 const char *s;
10585 isl_basic_set *bset;
10586 isl_bool is_univ;
10587
10588 s = "{ [] : exists x, y : 3y <= 2x and y >= -3 + 2x and 2y >= 2 - x }";
10589 bset = isl_basic_set_read_from_str(ctx, s);
10590 is_univ = isl_basic_set_is_universe(bset);
10591 isl_basic_set_free(bset);
10592
10593 if (is_univ < 0)
10594 return -1;
10595 if (!is_univ)
10597 "not recognized as universe set", return -1);
10598
10599 return 0;
10600}
10601
10602/* Sets for which chambers are computed and checked.
10603 */
10604const char *chambers_tests[] = {
10605 "[A, B, C] -> { [x, y, z] : x >= 0 and y >= 0 and y <= A - x and "
10606 "z >= 0 and z <= C - y and z <= B - x - y }",
10607};
10608
10609/* Add the domain of "cell" to "cells".
10610 */
10612{
10613 isl_basic_set_list **cells = user;
10614 isl_basic_set *dom;
10615
10616 dom = isl_cell_get_domain(cell);
10617 isl_cell_free(cell);
10618 *cells = isl_basic_set_list_add(*cells, dom);
10619
10620 return *cells ? isl_stat_ok : isl_stat_error;
10621}
10622
10623/* Check that the elements of "list" are pairwise disjoint.
10624 */
10626{
10627 int i, j;
10628 isl_size n;
10629
10630 n = isl_basic_set_list_n_basic_set(list);
10631 if (n < 0)
10632 return isl_stat_error;
10633
10634 for (i = 0; i < n; ++i) {
10635 isl_basic_set *bset_i;
10636
10637 bset_i = isl_basic_set_list_get_basic_set(list, i);
10638 for (j = i + 1; j < n; ++j) {
10639 isl_basic_set *bset_j;
10640 isl_bool disjoint;
10641
10642 bset_j = isl_basic_set_list_get_basic_set(list, j);
10643 disjoint = isl_basic_set_is_disjoint(bset_i, bset_j);
10644 isl_basic_set_free(bset_j);
10645 if (!disjoint)
10646 isl_die(isl_basic_set_list_get_ctx(list),
10647 isl_error_unknown, "not disjoint",
10648 break);
10649 if (disjoint < 0 || !disjoint)
10650 break;
10651 }
10652 isl_basic_set_free(bset_i);
10653 if (j < n)
10654 return isl_stat_error;
10655 }
10656
10657 return isl_stat_ok;
10658}
10659
10660/* Check that the chambers computed by isl_vertices_foreach_disjoint_cell
10661 * are pairwise disjoint.
10662 */
10663static int test_chambers(isl_ctx *ctx)
10664{
10665 int i;
10666
10667 for (i = 0; i < ARRAY_SIZE(chambers_tests); ++i) {
10668 isl_basic_set *bset;
10669 isl_vertices *vertices;
10670 isl_basic_set_list *cells;
10671 isl_stat ok;
10672
10674 vertices = isl_basic_set_compute_vertices(bset);
10675 cells = isl_basic_set_list_alloc(ctx, 0);
10677 &cells) < 0)
10678 cells = isl_basic_set_list_free(cells);
10679 ok = check_pairwise_disjoint(cells);
10680 isl_basic_set_list_free(cells);
10681 isl_vertices_free(vertices);
10682 isl_basic_set_free(bset);
10683
10684 if (ok < 0)
10685 return -1;
10686 }
10687
10688 return 0;
10689}
10690
10691struct {
10692 const char *name;
10693 int (*fn)(isl_ctx *ctx);
10694} tests [] = {
10695 { "universe", &test_universe },
10696 { "domain hash", &test_domain_hash },
10697 { "dual", &test_dual },
10698 { "dependence analysis", &test_flow },
10699 { "val", &test_val },
10700 { "compute divs", &test_compute_divs },
10701 { "partial lexmin", &test_partial_lexmin },
10702 { "simplify", &test_simplify },
10703 { "curry", &test_curry },
10704 { "piecewise multi affine expressions", &test_pw_multi_aff },
10705 { "multi piecewise affine expressions", &test_multi_pw_aff },
10706 { "conversion", &test_conversion },
10707 { "list", &test_list },
10708 { "align parameters", &test_align_parameters },
10709 { "drop unused parameters", &test_drop_unused_parameters },
10710 { "pullback", &test_pullback },
10711 { "AST", &test_ast },
10712 { "AST build", &test_ast_build },
10713 { "AST generation", &test_ast_gen },
10714 { "eliminate", &test_eliminate },
10715 { "deltas_map", &test_deltas_map },
10716 { "residue class", &test_residue_class },
10717 { "div", &test_div },
10718 { "slice", &test_slice },
10719 { "sample", &test_sample },
10720 { "empty projection", &test_empty_projection },
10721 { "output", &test_output },
10722 { "vertices", &test_vertices },
10723 { "chambers", &test_chambers },
10724 { "fixed", &test_fixed },
10725 { "equal", &test_equal },
10726 { "disjoint", &test_disjoint },
10727 { "product", &test_product },
10728 { "dim_max", &test_dim_max },
10729 { "affine", &test_aff },
10730 { "injective", &test_injective },
10731 { "schedule (whole component)", &test_schedule_whole },
10732 { "schedule (incremental)", &test_schedule_incremental },
10733 { "schedule tree", &test_schedule_tree },
10734 { "schedule tree prefix", &test_schedule_tree_prefix },
10735 { "schedule tree grouping", &test_schedule_tree_group },
10736 { "tile", &test_tile },
10737 { "union map", &test_union_map },
10738 { "union_pw", &test_union_pw },
10739 { "locus", &test_locus },
10740 { "eval", &test_eval },
10741 { "parse", &test_parse },
10742 { "single-valued", &test_sv },
10743 { "recession cone", &test_recession_cone },
10744 { "affine hull", &test_affine_hull },
10745 { "simple_hull", &test_simple_hull },
10746 { "coalesce", &test_coalesce },
10747 { "factorize", &test_factorize },
10748 { "subset", &test_subset },
10749 { "subtract", &test_subtract },
10750 { "intersect", &test_intersect },
10751 { "lexmin", &test_lexmin },
10752 { "min", &test_min },
10753 { "set lower bounds", &test_min_mpa },
10754 { "gist", &test_gist },
10755 { "piecewise quasi-polynomials", &test_pwqp },
10756 { "lift", &test_lift },
10757 { "bind parameters", &test_bind },
10758 { "unbind parameters", &test_unbind },
10759 { "bound", &test_bound },
10760 { "get lists", &test_get_list },
10761 { "union", &test_union },
10762 { "split periods", &test_split_periods },
10763 { "lexicographic order", &test_lex },
10764 { "bijectivity", &test_bijective },
10765 { "dataflow analysis", &test_dep },
10766 { "reading", &test_read },
10767 { "bounded", &test_bounded },
10768 { "construction", &test_construction },
10769 { "dimension manipulation", &test_dim },
10770 { "map application", &test_application },
10771 { "convex hull", &test_convex_hull },
10772 { "transitive closure", &test_closure },
10773 { "isl_bool", &test_isl_bool},
10775
10776int main(int argc, char **argv)
10777{
10778 int i;
10779 struct isl_ctx *ctx;
10780 struct isl_options *options;
10781
10782 options = isl_options_new_with_defaults();
10783 assert(options);
10784 argc = isl_options_parse(options, argc, argv, ISL_ARG_ALL);
10785
10786 ctx = isl_ctx_alloc_with_options(&isl_options_args, options);
10787 for (i = 0; i < ARRAY_SIZE(tests); ++i) {
10788 printf("%s\n", tests[i].name);
10789 if (tests[i].fn(ctx) < 0)
10790 goto error;
10791 }
10792 isl_ctx_free(ctx);
10793 return 0;
10794error:
10795 isl_ctx_free(ctx);
10796 return -1;
10797}
__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)
#define __isl_take
Definition ctx.h:23
isl_stat
Definition ctx.h:85
@ isl_stat_error
Definition ctx.h:86
@ isl_stat_ok
Definition ctx.h:87
#define __isl_give
Definition ctx.h:20
#define isl_die(ctx, errno, msg, code)
Definition ctx.h:139
isl_bool isl_bool_ok(int b)
Definition isl_ctx.c:58
@ isl_error_unknown
Definition ctx.h:79
@ isl_error_internal
Definition ctx.h:80
isl_stat isl_stat_non_null(const void *obj)
Definition isl_ctx.c:34
#define isl_alloc_array(ctx, type, n)
Definition ctx.h:133
#define __isl_keep
Definition ctx.h:26
int isl_size
Definition ctx.h:98
isl_bool isl_bool_not(isl_bool b)
Definition isl_ctx.c:44
isl_bool
Definition ctx.h:90
@ isl_bool_false
Definition ctx.h:92
@ isl_bool_true
Definition ctx.h:93
@ isl_bool_error
Definition ctx.h:91
void isl_ctx_free(isl_ctx *ctx)
Definition isl_ctx.c:300
__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:3579
void test_parse_map(isl_ctx *ctx, const char *str)
Definition isl_test.c:66
struct @136277052127235302001362335036236067334354155255 sol_tests[]
static int test_union_map_mupa_conversion(isl_ctx *ctx)
Definition isl_test.c:9139
int sv
Definition isl_test.c:3497
static int test_min_special2(isl_ctx *ctx)
Definition isl_test.c:3036
static int test_conflicting_context_schedule(isl_ctx *ctx)
Definition isl_test.c:4810
static int test_eval(isl_ctx *ctx)
Definition isl_test.c:8453
const char * minuend
Definition isl_test.c:4081
int shift_point
Definition isl_test.c:10449
static int test_closure(isl_ctx *ctx)
Definition isl_test.c:2528
const char * poly
Definition isl_test.c:3811
static int test_un_locus(isl_ctx *ctx)
Definition isl_test.c:8099
static int test_union_map(isl_ctx *ctx)
Definition isl_test.c:7984
static int test_read(isl_ctx *ctx)
Definition isl_test.c:553
static int common_space(void *first, void *second)
Definition isl_test.c:3179
struct @227153107326043146302145062112014100102317066121 convex_hull_tests[]
static int test_ast_gen5(isl_ctx *ctx)
Definition isl_test.c:9727
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:6425
static isl_stat uset_check_equal(__isl_keep isl_union_set *uset, const char *str)
Definition isl_test.c:3264
static int test_convex_hull(isl_ctx *ctx)
Definition isl_test.c:1671
static int test_list(isl_ctx *ctx)
Definition isl_test.c:8926
static int test_bound(isl_ctx *ctx)
Definition isl_test.c:3854
const char * tile
Definition isl_test.c:10453
static struct @312242276265273206050076024022221044217204247150 bind_mupa_tests[]
static int test_bin_upma(isl_ctx *ctx)
Definition isl_test.c:5580
static int test_pwqp(struct isl_ctx *ctx)
Definition isl_test.c:3648
int test_equal(isl_ctx *ctx)
Definition isl_test.c:7676
static isl_stat check_pairwise_disjoint(__isl_keep isl_basic_set_list *list)
Definition isl_test.c:10625
static int test_val(isl_ctx *ctx)
Definition isl_test.c:988
int test_factorize(isl_ctx *ctx)
Definition isl_test.c:4194
static const char * parse_union_pw_multi_aff_fail_tests[]
Definition isl_test.c:208
enum isl_fold type
Definition isl_test.c:3810
struct @217300273003272264354301305257075337216352210333 val_bin_tests[]
static __isl_give isl_id * before_for(__isl_keep isl_ast_build *build, void *user)
Definition isl_test.c:9354
const char * pa
Definition isl_test.c:7116
static int test_deltas_map(isl_ctx *ctx)
Definition isl_test.c:8755
struct @073317244344013303260303174253310074300236206353 mupa_bin_tests[]
static int test_empty_projection(isl_ctx *ctx)
Definition isl_test.c:8656
static int test_dual(isl_ctx *ctx)
Definition isl_test.c:10406
static struct @121334201376000072241342302345242002002112124351 bind_aff_tests[]
static isl_stat test_bind_map_domain(isl_ctx *ctx)
Definition isl_test.c:6877
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:7353
static isl_stat set_check_equal(__isl_keep isl_set *set, const char *str)
Definition isl_test.c:3232
static int test_coalescing_schedule(isl_ctx *ctx)
Definition isl_test.c:4832
static isl_stat test_aff_set_tuple_id(isl_ctx *ctx)
Definition isl_test.c:6673
static isl_stat test_bind_set(isl_ctx *ctx)
Definition isl_test.c:6822
static struct @263260042340030002023204212344055054207256061003 opt_pw_tests[]
int test_coalesce_set(isl_ctx *ctx, const char *str, int check_one)
Definition isl_test.c:1847
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:3001
static isl_stat add_cell(__isl_take isl_cell *cell, void *user)
Definition isl_test.c:10611
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:8000
static isl_stat test_coalesce_special6(isl_ctx *ctx)
Definition isl_test.c:2400
static int test_application(isl_ctx *ctx)
Definition isl_test.c:1327
static int test_min(struct isl_ctx *ctx)
Definition isl_test.c:3125
static int test_ast_gen2(isl_ctx *ctx)
Definition isl_test.c:9552
static int test_lift(isl_ctx *ctx)
Definition isl_test.c:3943
int single_disjunct
Definition isl_test.c:1879
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:7394
static isl_stat test_ast_gen1(isl_ctx *ctx)
Definition isl_test.c:9493
const char * set
Definition isl_test.c:1364
static int test_mupa_ma(isl_ctx *ctx)
Definition isl_test.c:6342
static int test_split_periods(isl_ctx *ctx)
Definition isl_test.c:3737
static isl_stat test_bind_pa(isl_ctx *ctx)
Definition isl_test.c:7131
static int test_ast_gen(isl_ctx *ctx)
Definition isl_test.c:9798
const char * hull
Definition isl_test.c:1493
static isl_stat test_bound_space(isl_ctx *ctx)
Definition isl_test.c:3834
struct @112052067337023134134123200132300000022321127266 tests[]
static int test_lex(struct isl_ctx *ctx)
Definition isl_test.c:2806
const char * condition
Definition isl_test.c:4641
static isl_stat test_coalesce_special8(isl_ctx *ctx)
Definition isl_test.c:2435
static int test_ast_build(isl_ctx *ctx)
Definition isl_test.c:9311
const char * umap_mupa_conversion_tests[]
Definition isl_test.c:9123
struct @135300012331366305032307165220313216350342356305 subtract_domain_tests[]
int test_eliminate(isl_ctx *ctx)
Definition isl_test.c:8736
static struct @016015352272170164072066104344001241103075150127 bind_pa_tests[]
const char * difference
Definition isl_test.c:4083
static int test_skewing_schedule(isl_ctx *ctx)
Definition isl_test.c:4865
static int test_lexmin(struct isl_ctx *ctx)
Definition isl_test.c:2875
struct @234152315152023263103113146365272230152161306351 subset_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:4422
int tight
Definition isl_test.c:3809
static int test_strongly_satisfying_schedule(isl_ctx *ctx)
Definition isl_test.c:4776
static isl_stat test_upma_uset(isl_ctx *ctx)
Definition isl_test.c:5686
int test_fixed(isl_ctx *ctx)
Definition isl_test.c:7733
static int test_disjoint(isl_ctx *ctx)
Definition isl_test.c:7637
static isl_stat test_upma_test(isl_ctx *ctx)
Definition isl_test.c:5508
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:4236
static int test_eval_2(isl_ctx *ctx)
Definition isl_test.c:8343
struct @174057011213107332265220210271111213013313024017 bind_umap_range_tests[]
static int test_bin_upma_fail(isl_ctx *ctx)
Definition isl_test.c:5621
static int test_special_conditional_schedule_constraints_2(isl_ctx *ctx)
Definition isl_test.c:4586
static int test_locus(isl_ctx *ctx)
Definition isl_test.c:8301
static isl_stat test_subset_duplicate_integer_divisions(isl_ctx *ctx)
Definition isl_test.c:3966
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:7577
struct @050155310362100077075031154044213015144052006053 aff_eval_tests[]
static isl_stat test_unbind_set(isl_ctx *ctx)
Definition isl_test.c:7252
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:7714
const char * ma
Definition isl_test.c:7330
int test_product(isl_ctx *ctx)
Definition isl_test.c:7598
static int test_isl_bool(isl_ctx *ctx)
Definition isl_test.c:2784
struct @234372225360351010125242076055167203305366236111 mupa_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:3626
static int test_eval_1(isl_ctx *ctx)
Definition isl_test.c:8315
const char * output_tests[]
Definition isl_test.c:8468
static int test_coalesce_special3(isl_ctx *ctx)
Definition isl_test.c:2309
struct @123161370147266307110215130177302342032352135375 coalesce_tests[]
static int test_gist(struct isl_ctx *ctx)
Definition isl_test.c:1782
struct @275270173251312013201020346130124230036336200035 bind_pma_domain_tests[]
struct @343352217161364004312145033045065131243340231327 mupa_pa_tests[]
const char * map
Definition isl_test.c:1734
static void test_parse_pwaff(isl_ctx *ctx, const char *str)
Definition isl_test.c:104
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:4249
int test_slice(isl_ctx *ctx)
Definition isl_test.c:8679
static int test_min_mpa(isl_ctx *ctx)
Definition isl_test.c:3093
static int test_universe(isl_ctx *ctx)
Definition isl_test.c:10582
struct @016117341140033035307325017250231030001172225320 lexmin_tests[]
static int test_conditional_schedule_constraints(isl_ctx *ctx)
Definition isl_test.c:4718
static isl_stat test_gist_empty(isl_ctx *ctx)
Definition isl_test.c:1715
static struct @250133302144052016047034213024303200342344001123 unbind_multi_aff_tests[]
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
static int test_tile(isl_ctx *ctx)
Definition isl_test.c:10486
struct @031064245322346342056014251357027126016366134020 pwqp_gist_tests[]
static isl_stat test_ma_conversion(isl_ctx *ctx)
Definition isl_test.c:8975
int test_vertices(isl_ctx *ctx)
Definition isl_test.c:7825
static int test_ast_expr(isl_ctx *ctx)
Definition isl_test.c:9766
struct @032104377171373353064050046203260213352306036137 un_locus_tests[]
int equal
Definition isl_test.c:7663
struct @153221355010016326374145353067372356257264351356 mupa_upma_tests[]
static int test_ast(isl_ctx *ctx)
Definition isl_test.c:9260
int test_union_pw(isl_ctx *ctx)
Definition isl_test.c:8018
static isl_stat test_bind_aff(isl_ctx *ctx)
Definition isl_test.c:7087
static int test_un_mpa(isl_ctx *ctx)
Definition isl_test.c:5764
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:4090
static isl_stat test_bind_mupa(isl_ctx *ctx)
Definition isl_test.c:7177
const char * pma
Definition isl_test.c:2962
static int test_mupa_set(isl_ctx *ctx)
Definition isl_test.c:6194
struct @110236216215267062025113222262143012150125310315 bind_map_domain_tests[]
static isl_stat test_coalesce_union(isl_ctx *ctx, const char *str1, const char *str2)
Definition isl_test.c:2253
static int test_ast_gen3(isl_ctx *ctx)
Definition isl_test.c:9594
const char * conditional_validity
Definition isl_test.c:4642
static struct @175201007007107104020277010220303030346261040141 upma_test_tests[]
struct @225231020345174122145152306206242040116330170152 live_range_tests[]
const char * p
Definition isl_test.c:8397
int test_output(isl_ctx *ctx)
Definition isl_test.c:8566
static int test_bin_aff(isl_ctx *ctx)
Definition isl_test.c:5380
struct @306152342120224230045201022302340006115324040221 mpa_bin_tests[]
int scale_tile
Definition isl_test.c:10448
static int test_multi_pw_aff(isl_ctx *ctx)
Definition isl_test.c:10004
static int test_bind(isl_ctx *ctx)
Definition isl_test.c:7204
struct @125356034062032156215334117027034307076106117034 pma_equal_tests[]
static int test_simplify_1(isl_ctx *ctx)
Definition isl_test.c:10026
const char * schedule
Definition isl_test.c:10451
#define ARRAY_SIZE(array)
Definition isl_test.c:47
static int test_get_list(isl_ctx *ctx)
Definition isl_test.c:3925
static int test_schedule_tree_group(isl_ctx *ctx)
Definition isl_test.c:10358
static int test_map_conversion(isl_ctx *ctx)
Definition isl_test.c:9052
static isl_stat test_bind_pma_domain(isl_ctx *ctx)
Definition isl_test.c:6984
static int test_domain_hash(isl_ctx *ctx)
Definition isl_test.c:10556
static int test_schedule_incremental(isl_ctx *ctx)
Definition isl_test.c:5207
static int test_bijective(struct isl_ctx *ctx)
Definition isl_test.c:3552
const char * flow
Definition isl_test.c:4640
static int test_parse_multi(isl_ctx *ctx)
Definition isl_test.c:351
struct @346121156341046050001065107224026155011163173256 sv_tests[]
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:9092
static int test_bin_pw_aff(isl_ctx *ctx)
Definition isl_test.c:5444
static int test_dim_max_2(isl_ctx *ctx)
Definition isl_test.c:7438
const char * f2
Definition isl_test.c:7665
const char * set_conversion_tests[]
Definition isl_test.c:8997
static isl_stat test_intersect_2(isl_ctx *ctx)
Definition isl_test.c:4168
static int test_plain_gist(isl_ctx *ctx)
Definition isl_test.c:1752
int test_drop_unused_parameters(isl_ctx *ctx)
Definition isl_test.c:8873
static isl_stat test_subtract_empty(isl_ctx *ctx)
Definition isl_test.c:4063
static isl_stat test_union_set_contains(isl_ctx *ctx)
Definition isl_test.c:7956
static isl_stat test_multi_pw_aff_box(isl_ctx *ctx)
Definition isl_test.c:9972
static int test_schedule_whole(isl_ctx *ctx)
Definition isl_test.c:5192
struct @320003045101313370267023112313076000262133016064 unbind_set_tests[]
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:3247
int test_sv(isl_ctx *ctx)
Definition isl_test.c:3510
static isl_stat check_bool(isl_ctx *ctx, isl_bool actual, isl_bool expected)
Definition isl_test.c:2769
static isl_stat test_plain_unshifted_simple_hull_special(isl_ctx *ctx)
Definition isl_test.c:1464
struct @326352374276177063217211122037271225223365343330 mupa_set_tests[]
static int test_coalesce_special(struct isl_ctx *ctx)
Definition isl_test.c:2210
static int test_subset(isl_ctx *ctx)
Definition isl_test.c:4035
const char * name
Definition isl_test.c:10692
const char * point
Definition isl_test.c:10454
static isl_stat test_gist_empty_pair(isl_ctx *ctx, const char *map, const char *context)
Definition isl_test.c:1684
static int test_compute_divs(isl_ctx *ctx)
Definition isl_test.c:10111
static isl_stat test_eval_3(isl_ctx *ctx)
Definition isl_test.c:8372
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:2386
const char * context
Definition isl_test.c:1735
static isl_stat collect_must_may(__isl_take isl_map *dep, int must, void *dep_user, void *user)
Definition isl_test.c:3166
static int test_unbind(isl_ctx *ctx)
Definition isl_test.c:7380
static int test_mupa_pma(isl_ctx *ctx)
Definition isl_test.c:6545
int test_special_schedule(isl_ctx *ctx, const char *domain, const char *validity, const char *proximity, const char *expected_sched)
Definition isl_test.c:4445
static __isl_give isl_map * cocoa_fig_1_right_tc(isl_ctx *ctx)
Definition isl_test.c:2523
static int test_output_set(isl_ctx *ctx)
Definition isl_test.c:8485
const char * subtrahend
Definition isl_test.c:4082
static __isl_give isl_ast_node * select_first(__isl_take isl_ast_node *node, void *user)
Definition isl_test.c:9463
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:4144
struct @105221326373240210216336053113147175001126267127 bind_pma_domain_wrapped_tests[]
static isl_stat test_coalesce_intersection(isl_ctx *ctx, const char *s1, const char *s2)
Definition isl_test.c:2349
int test_plain_injective(isl_ctx *ctx, const char *str, int injective)
Definition isl_test.c:5220
static int test_chambers(isl_ctx *ctx)
Definition isl_test.c:10663
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
const char * aff
Definition isl_test.c:7073
static isl_bool count_for(__isl_keep isl_ast_node *node, void *user)
Definition isl_test.c:9451
struct @015267075333042347372041363346316206161075303054 upma_bin_tests[]
int test_dim_max(isl_ctx *ctx)
Definition isl_test.c:7451
const char * obj
Definition isl_test.c:3109
static int test_bounded(isl_ctx *ctx)
Definition isl_test.c:586
const char * lexmin
Definition isl_test.c:2831
struct @277255054242064365360344327310257371007324027162 pw_aff_bin_op[]
static char * get_filename(isl_ctx *ctx, const char *name, const char *suffix)
Definition isl_test.c:49
struct @246277342025272067075065104332037275214221302171 opt_tests[]
struct @061124063161067110073243100231030174062076155272 mupa_un_tests[]
struct @225310166120276347227137376175363010237007305060 upma_bin_fail_tests[]
const char * map2
Definition isl_test.c:366
const char * set1
Definition isl_test.c:3998
static __isl_give isl_map * cocoa_fig_1_right_power(isl_ctx *ctx)
Definition isl_test.c:2511
int outer_band_n
Definition isl_test.c:4643
static int test_union(isl_ctx *ctx)
Definition isl_test.c:3757
struct @230361366346155317003354075102156334256111143174 parse_map_equal_tests[]
static isl_stat test_aff_normalize(isl_ctx *ctx)
Definition isl_test.c:6695
struct @046213276021216247135016337073226265266123046377 upma_uset_tests[]
static int map_check_equal(__isl_keep isl_map *map, const char *str)
Definition isl_test.c:3200
int test_injective(isl_ctx *ctx)
Definition isl_test.c:5240
static int test_bin_locus(isl_ctx *ctx)
Definition isl_test.c:8206
static int test_ast_gen4(isl_ctx *ctx)
Definition isl_test.c:9633
static isl_stat test_pw_max(struct isl_ctx *ctx)
Definition isl_test.c:2975
static int test_curry(isl_ctx *ctx)
Definition isl_test.c:9184
static int test_partial_lexmin(isl_ctx *ctx)
Definition isl_test.c:10087
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:4508
const char * tuple
Definition isl_test.c:6803
void test_convex_hull_case(struct isl_ctx *ctx, const char *name)
Definition isl_test.c:1570
static int test_padded_schedule(isl_ctx *ctx)
Definition isl_test.c:4470
int test_parse(struct isl_ctx *ctx)
Definition isl_test.c:485
struct @365347224236156042276345137037354162060170254355 aff_bin_tests[]
struct @237150141343053203027125264373312344000200200232 unbind_aff_tests[]
const char * sizes
Definition isl_test.c:10452
static int test_mupa_uset(isl_ctx *ctx)
Definition isl_test.c:6255
struct @217276206324134050271014074335325122205326340376 plain_gist_tests[]
static isl_stat test_unbind_aff(isl_ctx *ctx)
Definition isl_test.c:7301
static int test_dep(struct isl_ctx *ctx)
Definition isl_test.c:3278
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:6926
static int test_mupa_upma(isl_ctx *ctx)
Definition isl_test.c:6643
struct @307311126023073361146236001125175247211007332263 val_bin_op[]
struct @073223071055162131251174000110304051102024241067 pw_aff_bin_tests[]
static int test_bin_mpa(isl_ctx *ctx)
Definition isl_test.c:5894
const char * set2
Definition isl_test.c:3999
int subset
Definition isl_test.c:4000
static isl_stat test_output_mpa(isl_ctx *ctx)
Definition isl_test.c:8540
static int test_simplify_2(isl_ctx *ctx)
Definition isl_test.c:10052
static isl_stat test_pwqp_gist(isl_ctx *ctx)
Definition isl_test.c:3594
static int test_flow(isl_ctx *ctx)
Definition isl_test.c:3472
static isl_stat test_coalesce_special4(isl_ctx *ctx)
Definition isl_test.c:2372
static int test_conversion(isl_ctx *ctx)
Definition isl_test.c:9167
struct @341133352173154043211061172152136021073007253337 coef_tests[]
static isl_stat check_single_expr_min(isl_ctx *ctx, const char *s1, const char *s2)
Definition isl_test.c:3064
struct @377335042054304314277065373361216112115061122073 bin_locus_tests[]
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:3215
const char * gist
Definition isl_test.c:1736
const char * ma1
Definition isl_test.c:9208
static isl_stat test_bind_pma_domain_wrapped(isl_ctx *ctx)
Definition isl_test.c:7041
static int test_schedule_tree(isl_ctx *ctx)
Definition isl_test.c:10134
const char * dual
Definition isl_test.c:10369
static int test_schedule_tree_group_2(isl_ctx *ctx)
Definition isl_test.c:10270
static int test_convex_hull_algo(isl_ctx *ctx, int convex)
Definition isl_test.c:1625
const char * cone
Definition isl_test.c:1365
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:5959
int test_schedule(isl_ctx *ctx)
Definition isl_test.c:4879
static int test_bin_mupa(isl_ctx *ctx)
Definition isl_test.c:6089
static struct @216257140162010135245171323044214145146165047335 bin_locus_ma_tests[]
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:8428
static int test_multi_pw_aff_1(isl_ctx *ctx)
Definition isl_test.c:9847
struct @033013227044342070133067222073072061020241124316 coalesce_unbounded_tests[]
struct @174057113116164366203126207022041076172367046214 mupa_ma_tests[]
static isl_stat find_vertex(__isl_take isl_vertex *vertex, void *user)
Definition isl_test.c:7790
int test_aff(isl_ctx *ctx)
Definition isl_test.c:6709
static int test_dim_max_1(isl_ctx *ctx)
Definition isl_test.c:7416
static int test_multi_pw_aff_2(isl_ctx *ctx)
Definition isl_test.c:9896
const char * mupa
Definition isl_test.c:7160
static int test_coalesce(struct isl_ctx *ctx)
Definition isl_test.c:2451
struct @336041326377237040302274063337145151235045104073 pullback_tests[]
static int test_align_parameters(isl_ctx *ctx)
Definition isl_test.c:8858
static int test_simplify(isl_ctx *ctx)
Definition isl_test.c:10073
const char * f
Definition isl_test.c:8396
struct @032326224263051015242172034057017051301131332221 mpa_un_tests[]
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:9413
int bijective
Definition isl_test.c:3535
static isl_stat test_coalesce_special7(isl_ctx *ctx)
Definition isl_test.c:2416
struct @306255212222345361073270334305355037300163072106 bijective_tests[]
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:10205
const char * chambers_tests[]
Definition isl_test.c:10604
struct @212251224320377234215223061215057205173040036122 tile_tests[]
static struct @345352160040353307102050305160332264207213132026 bound_tests[]
static int test_has_schedule(isl_ctx *ctx, const char *domain, const char *validity, const char *proximity)
Definition isl_test.c:4432
static __isl_give isl_map * cocoa_fig_1_right_graph(isl_ctx *ctx)
Definition isl_test.c:2488
struct isl_vertices_test_data vertices_tests[]
static struct @020074134063177147374305013173201056235322265307 umap_bin_tests[]
int test_sample(isl_ctx *ctx)
Definition isl_test.c:8603
static isl_stat test_bin_locus_ma(isl_ctx *ctx)
Definition isl_test.c:8270
const char * mpa_conversion_tests[]
Definition isl_test.c:9080
static int test_set_conversion(isl_ctx *ctx)
Definition isl_test.c:9011
static int test_upa(isl_ctx *ctx)
Definition isl_test.c:5290
const char * id
Definition isl_test.c:7074
static isl_stat test_output_ma(isl_ctx *ctx)
Definition isl_test.c:8512
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 __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:9580
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:1905
const char * str
Definition isl_test.c:1880
static const char * multi_pw_aff_box_tests[]
Definition isl_test.c:9963
static int test_residue_class(isl_ctx *ctx)
Definition isl_test.c:8776
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:4392
static int test_parse_mpa(isl_ctx *ctx)
Definition isl_test.c:240
const char * conversion_tests[]
Definition isl_test.c:9038
static int test_intersect(isl_ctx *ctx)
Definition isl_test.c:4184
static isl_stat test_coalesce_special2(struct isl_ctx *ctx)
Definition isl_test.c:2290
struct @166252077064030177264324146316062043227161027001 mupa_pma_tests[]
const char * f1
Definition isl_test.c:7664
static int map_is_equal(__isl_keep isl_map *map, const char *str)
Definition isl_test.c:3185
static struct @034023122066004347332201145302160211004356015173 bind_set_tests[]
static int test_schedule_tree_prefix(isl_ctx *ctx)
Definition isl_test.c:10162
static __isl_give isl_ast_node * create_leaf(__isl_take isl_ast_build *build, void *user)
Definition isl_test.c:9693
static isl_stat test_bin_union_map(isl_ctx *ctx)
Definition isl_test.c:7924
struct @027213002172344323165175365021062236374012126065 aff_bin_op[]
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:9940
static int test_pullback(isl_ctx *ctx)
Definition isl_test.c:9232
static int test_pw_multi_aff(isl_ctx *ctx)
Definition isl_test.c:9818
static int test_align_parameters_1(isl_ctx *ctx)
Definition isl_test.c:8800
static isl_stat test_align_parameters_2(isl_ctx *ctx)
Definition isl_test.c:8836
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_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:7761
isl_map * must
Definition isl_test.c:3162
isl_map * may
Definition isl_test.c:3163
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