~ubuntu-branches/ubuntu/trusty/cloog/trusty

« back to all changes in this revision

Viewing changes to isl/isl_test.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-10-17 15:54:24 UTC
  • mfrom: (3.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20131017155424-3q1gw7yhddylfkpj
Tags: 0.18.1-1
* New upstream version.
* Add a comment to build-depend on libpod-latex-perl | perl (<< 5.17.0),
  when the documentation is built. Closes: #711681.
* Use dh_autotools-dev to update config.{sub,guess}. Closes: #719957.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <isl_options_private.h>
24
24
#include <isl/vertices.h>
25
25
#include <isl/ast_build.h>
 
26
#include <isl/val.h>
26
27
 
27
28
#define ARRAY_SIZE(array) (sizeof(array)/sizeof(*array))
28
29
 
205
206
                                      "[n] -> { [i] : i <= n }") < 0)
206
207
                return -1;
207
208
 
 
209
        if (test_parse_map_equal(ctx, "{ [*] }", "{ [a] }") < 0)
 
210
                return -1;
 
211
 
 
212
        if (test_parse_map_equal(ctx, "{ [i] : 2*floor(i/2) = i }",
 
213
                                      "{ [i] : exists a : i = 2 a }") < 0)
 
214
                return -1;
 
215
 
 
216
        if (test_parse_map_equal(ctx, "{ [a] -> [b] : a = 5 implies b = 5 }",
 
217
                                      "{ [a] -> [b] : a != 5 or b = 5 }") < 0)
 
218
                return -1;
 
219
 
208
220
        return 0;
209
221
}
210
222
 
319
331
        isl_map_free(map2);
320
332
}
321
333
 
 
334
struct {
 
335
        __isl_give isl_val *(*op)(__isl_take isl_val *v);
 
336
        const char *arg;
 
337
        const char *res;
 
338
} val_un_tests[] = {
 
339
        { &isl_val_neg, "0", "0" },
 
340
        { &isl_val_abs, "0", "0" },
 
341
        { &isl_val_2exp, "0", "1" },
 
342
        { &isl_val_floor, "0", "0" },
 
343
        { &isl_val_ceil, "0", "0" },
 
344
        { &isl_val_neg, "1", "-1" },
 
345
        { &isl_val_neg, "-1", "1" },
 
346
        { &isl_val_neg, "1/2", "-1/2" },
 
347
        { &isl_val_neg, "-1/2", "1/2" },
 
348
        { &isl_val_neg, "infty", "-infty" },
 
349
        { &isl_val_neg, "-infty", "infty" },
 
350
        { &isl_val_neg, "NaN", "NaN" },
 
351
        { &isl_val_abs, "1", "1" },
 
352
        { &isl_val_abs, "-1", "1" },
 
353
        { &isl_val_abs, "1/2", "1/2" },
 
354
        { &isl_val_abs, "-1/2", "1/2" },
 
355
        { &isl_val_abs, "infty", "infty" },
 
356
        { &isl_val_abs, "-infty", "infty" },
 
357
        { &isl_val_abs, "NaN", "NaN" },
 
358
        { &isl_val_floor, "1", "1" },
 
359
        { &isl_val_floor, "-1", "-1" },
 
360
        { &isl_val_floor, "1/2", "0" },
 
361
        { &isl_val_floor, "-1/2", "-1" },
 
362
        { &isl_val_floor, "infty", "infty" },
 
363
        { &isl_val_floor, "-infty", "-infty" },
 
364
        { &isl_val_floor, "NaN", "NaN" },
 
365
        { &isl_val_ceil, "1", "1" },
 
366
        { &isl_val_ceil, "-1", "-1" },
 
367
        { &isl_val_ceil, "1/2", "1" },
 
368
        { &isl_val_ceil, "-1/2", "0" },
 
369
        { &isl_val_ceil, "infty", "infty" },
 
370
        { &isl_val_ceil, "-infty", "-infty" },
 
371
        { &isl_val_ceil, "NaN", "NaN" },
 
372
        { &isl_val_2exp, "-3", "1/8" },
 
373
        { &isl_val_2exp, "-1", "1/2" },
 
374
        { &isl_val_2exp, "1", "2" },
 
375
        { &isl_val_2exp, "2", "4" },
 
376
        { &isl_val_2exp, "3", "8" },
 
377
};
 
378
 
 
379
/* Perform some basic tests of unary operations on isl_val objects.
 
380
 */
 
381
static int test_un_val(isl_ctx *ctx)
 
382
{
 
383
        int i;
 
384
        isl_val *v, *res;
 
385
        __isl_give isl_val *(*fn)(__isl_take isl_val *v);
 
386
        int ok;
 
387
 
 
388
        for (i = 0; i < ARRAY_SIZE(val_un_tests); ++i) {
 
389
                v = isl_val_read_from_str(ctx, val_un_tests[i].arg);
 
390
                res = isl_val_read_from_str(ctx, val_un_tests[i].res);
 
391
                fn = val_un_tests[i].op;
 
392
                v = fn(v);
 
393
                if (isl_val_is_nan(res))
 
394
                        ok = isl_val_is_nan(v);
 
395
                else
 
396
                        ok = isl_val_eq(v, res);
 
397
                isl_val_free(v);
 
398
                isl_val_free(res);
 
399
                if (ok < 0)
 
400
                        return -1;
 
401
                if (!ok)
 
402
                        isl_die(ctx, isl_error_unknown,
 
403
                                "unexpected result", return -1);
 
404
        }
 
405
 
 
406
        return 0;
 
407
}
 
408
 
 
409
struct {
 
410
        __isl_give isl_val *(*fn)(__isl_take isl_val *v1,
 
411
                                __isl_take isl_val *v2);
 
412
} val_bin_op[] = {
 
413
        ['+'] = { &isl_val_add },
 
414
        ['-'] = { &isl_val_sub },
 
415
        ['*'] = { &isl_val_mul },
 
416
        ['/'] = { &isl_val_div },
 
417
        ['g'] = { &isl_val_gcd },
 
418
        ['m'] = { &isl_val_min },
 
419
        ['M'] = { &isl_val_max },
 
420
};
 
421
 
 
422
struct {
 
423
        const char *arg1;
 
424
        unsigned char op;
 
425
        const char *arg2;
 
426
        const char *res;
 
427
} val_bin_tests[] = {
 
428
        { "0", '+', "0", "0" },
 
429
        { "1", '+', "0", "1" },
 
430
        { "1", '+', "1", "2" },
 
431
        { "1", '-', "1", "0" },
 
432
        { "1", '*', "1", "1" },
 
433
        { "1", '/', "1", "1" },
 
434
        { "2", '*', "3", "6" },
 
435
        { "2", '*', "1/2", "1" },
 
436
        { "2", '*', "1/3", "2/3" },
 
437
        { "2/3", '*', "3/5", "2/5" },
 
438
        { "2/3", '*', "7/5", "14/15" },
 
439
        { "2", '/', "1/2", "4" },
 
440
        { "-2", '/', "-1/2", "4" },
 
441
        { "-2", '/', "1/2", "-4" },
 
442
        { "2", '/', "-1/2", "-4" },
 
443
        { "2", '/', "2", "1" },
 
444
        { "2", '/', "3", "2/3" },
 
445
        { "2/3", '/', "5/3", "2/5" },
 
446
        { "2/3", '/', "5/7", "14/15" },
 
447
        { "0", '/', "0", "NaN" },
 
448
        { "42", '/', "0", "NaN" },
 
449
        { "-42", '/', "0", "NaN" },
 
450
        { "infty", '/', "0", "NaN" },
 
451
        { "-infty", '/', "0", "NaN" },
 
452
        { "NaN", '/', "0", "NaN" },
 
453
        { "0", '/', "NaN", "NaN" },
 
454
        { "42", '/', "NaN", "NaN" },
 
455
        { "-42", '/', "NaN", "NaN" },
 
456
        { "infty", '/', "NaN", "NaN" },
 
457
        { "-infty", '/', "NaN", "NaN" },
 
458
        { "NaN", '/', "NaN", "NaN" },
 
459
        { "0", '/', "infty", "0" },
 
460
        { "42", '/', "infty", "0" },
 
461
        { "-42", '/', "infty", "0" },
 
462
        { "infty", '/', "infty", "NaN" },
 
463
        { "-infty", '/', "infty", "NaN" },
 
464
        { "NaN", '/', "infty", "NaN" },
 
465
        { "0", '/', "-infty", "0" },
 
466
        { "42", '/', "-infty", "0" },
 
467
        { "-42", '/', "-infty", "0" },
 
468
        { "infty", '/', "-infty", "NaN" },
 
469
        { "-infty", '/', "-infty", "NaN" },
 
470
        { "NaN", '/', "-infty", "NaN" },
 
471
        { "1", '-', "1/3", "2/3" },
 
472
        { "1/3", '+', "1/2", "5/6" },
 
473
        { "1/2", '+', "1/2", "1" },
 
474
        { "3/4", '-', "1/4", "1/2" },
 
475
        { "1/2", '-', "1/3", "1/6" },
 
476
        { "infty", '+', "42", "infty" },
 
477
        { "infty", '+', "infty", "infty" },
 
478
        { "42", '+', "infty", "infty" },
 
479
        { "infty", '-', "infty", "NaN" },
 
480
        { "infty", '*', "infty", "infty" },
 
481
        { "infty", '*', "-infty", "-infty" },
 
482
        { "-infty", '*', "infty", "-infty" },
 
483
        { "-infty", '*', "-infty", "infty" },
 
484
        { "0", '*', "infty", "NaN" },
 
485
        { "1", '*', "infty", "infty" },
 
486
        { "infty", '*', "0", "NaN" },
 
487
        { "infty", '*', "42", "infty" },
 
488
        { "42", '-', "infty", "-infty" },
 
489
        { "infty", '+', "-infty", "NaN" },
 
490
        { "4", 'g', "6", "2" },
 
491
        { "5", 'g', "6", "1" },
 
492
        { "42", 'm', "3", "3" },
 
493
        { "42", 'M', "3", "42" },
 
494
        { "3", 'm', "42", "3" },
 
495
        { "3", 'M', "42", "42" },
 
496
        { "42", 'm', "infty", "42" },
 
497
        { "42", 'M', "infty", "infty" },
 
498
        { "42", 'm', "-infty", "-infty" },
 
499
        { "42", 'M', "-infty", "42" },
 
500
        { "42", 'm', "NaN", "NaN" },
 
501
        { "42", 'M', "NaN", "NaN" },
 
502
        { "infty", 'm', "-infty", "-infty" },
 
503
        { "infty", 'M', "-infty", "infty" },
 
504
};
 
505
 
 
506
/* Perform some basic tests of binary operations on isl_val objects.
 
507
 */
 
508
static int test_bin_val(isl_ctx *ctx)
 
509
{
 
510
        int i;
 
511
        isl_val *v1, *v2, *res;
 
512
        __isl_give isl_val *(*fn)(__isl_take isl_val *v1,
 
513
                                __isl_take isl_val *v2);
 
514
        int ok;
 
515
 
 
516
        for (i = 0; i < ARRAY_SIZE(val_bin_tests); ++i) {
 
517
                v1 = isl_val_read_from_str(ctx, val_bin_tests[i].arg1);
 
518
                v2 = isl_val_read_from_str(ctx, val_bin_tests[i].arg2);
 
519
                res = isl_val_read_from_str(ctx, val_bin_tests[i].res);
 
520
                fn = val_bin_op[val_bin_tests[i].op].fn;
 
521
                v1 = fn(v1, v2);
 
522
                if (isl_val_is_nan(res))
 
523
                        ok = isl_val_is_nan(v1);
 
524
                else
 
525
                        ok = isl_val_eq(v1, res);
 
526
                isl_val_free(v1);
 
527
                isl_val_free(res);
 
528
                if (ok < 0)
 
529
                        return -1;
 
530
                if (!ok)
 
531
                        isl_die(ctx, isl_error_unknown,
 
532
                                "unexpected result", return -1);
 
533
        }
 
534
 
 
535
        return 0;
 
536
}
 
537
 
 
538
/* Perform some basic tests on isl_val objects.
 
539
 */
 
540
static int test_val(isl_ctx *ctx)
 
541
{
 
542
        if (test_un_val(ctx) < 0)
 
543
                return -1;
 
544
        if (test_bin_val(ctx) < 0)
 
545
                return -1;
 
546
        return 0;
 
547
}
 
548
 
322
549
static int test_div(isl_ctx *ctx)
323
550
{
324
551
        unsigned n;
716
943
{
717
944
        const char *str;
718
945
        isl_set *set;
719
 
        isl_basic_set *bset;
 
946
        isl_basic_set *bset, *bset2;
720
947
        int n;
 
948
        int subset;
721
949
 
722
950
        test_affine_hull_case(ctx, "affine2");
723
951
        test_affine_hull_case(ctx, "affine");
735
963
                isl_die(ctx, isl_error_unknown, "not expecting any divs",
736
964
                        return -1);
737
965
 
 
966
        /* Check that isl_map_affine_hull is not confused by
 
967
         * the reordering of divs in isl_map_align_divs.
 
968
         */
 
969
        str = "{ [a, b, c, 0] : exists (e0 = [(b)/32], e1 = [(c)/32]: "
 
970
                                "32e0 = b and 32e1 = c); "
 
971
                "[a, 0, c, 0] : exists (e0 = [(c)/32]: 32e0 = c) }";
 
972
        set = isl_set_read_from_str(ctx, str);
 
973
        bset = isl_set_affine_hull(set);
 
974
        isl_basic_set_free(bset);
 
975
        if (!bset)
 
976
                return -1;
 
977
 
 
978
        str = "{ [a] : exists e0, e1, e2: 32e1 = 31 + 31a + 31e0 and "
 
979
                        "32e2 = 31 + 31e0 }";
 
980
        set = isl_set_read_from_str(ctx, str);
 
981
        bset = isl_set_affine_hull(set);
 
982
        str = "{ [a] : exists e : a = 32 e }";
 
983
        bset2 = isl_basic_set_read_from_str(ctx, str);
 
984
        subset = isl_basic_set_is_subset(bset, bset2);
 
985
        isl_basic_set_free(bset);
 
986
        isl_basic_set_free(bset2);
 
987
        if (subset < 0)
 
988
                return -1;
 
989
        if (!subset)
 
990
                isl_die(ctx, isl_error_unknown, "not as accurate as expected",
 
991
                        return -1);
 
992
 
738
993
        return 0;
739
994
}
740
995
 
838
1093
        fclose(input);
839
1094
}
840
1095
 
841
 
void test_gist(struct isl_ctx *ctx)
 
1096
static int test_gist(struct isl_ctx *ctx)
842
1097
{
843
1098
        const char *str;
844
1099
        isl_basic_set *bset1, *bset2;
 
1100
        isl_map *map1, *map2;
845
1101
 
846
1102
        test_gist_case(ctx, "gist1");
847
1103
 
867
1123
        bset1 = isl_basic_set_gist(bset1, bset2);
868
1124
        assert(bset1 && bset1->n_div == 0);
869
1125
        isl_basic_set_free(bset1);
 
1126
 
 
1127
        /* Check that the integer divisions of the second disjunct
 
1128
         * do not spread to the first disjunct.
 
1129
         */
 
1130
        str = "[t1] -> { S_0[] -> A[o0] : (exists (e0 = [(-t1 + o0)/16]: "
 
1131
                "16e0 = -t1 + o0 and o0 >= 0 and o0 <= 15 and t1 >= 0)) or "
 
1132
                "(exists (e0 = [(-1 + t1)/16], "
 
1133
                        "e1 = [(-16 + t1 - 16e0)/4294967296]: "
 
1134
                        "4294967296e1 = -16 + t1 - o0 - 16e0 and "
 
1135
                        "16e0 <= -1 + t1 and 16e0 >= -16 + t1 and o0 >= 0 and "
 
1136
                        "o0 <= 4294967295 and t1 <= -1)) }";
 
1137
        map1 = isl_map_read_from_str(ctx, str);
 
1138
        str = "[t1] -> { S_0[] -> A[o0] : t1 >= 0 and t1 <= 4294967295 }";
 
1139
        map2 = isl_map_read_from_str(ctx, str);
 
1140
        map1 = isl_map_gist(map1, map2);
 
1141
        if (!map1)
 
1142
                return -1;
 
1143
        if (map1->n != 1)
 
1144
                isl_die(ctx, isl_error_unknown, "expecting single disjunct",
 
1145
                        isl_map_free(map1); return -1);
 
1146
        if (isl_basic_map_dim(map1->p[0], isl_dim_div) != 1)
 
1147
                isl_die(ctx, isl_error_unknown, "expecting single div",
 
1148
                        isl_map_free(map1); return -1);
 
1149
        isl_map_free(map1);
 
1150
 
 
1151
        return 0;
870
1152
}
871
1153
 
872
1154
int test_coalesce_set(isl_ctx *ctx, const char *str, int check_one)
927
1209
        return r;
928
1210
}
929
1211
 
930
 
int test_coalesce(struct isl_ctx *ctx)
931
 
{
 
1212
/* Inputs for coalescing tests.
 
1213
 * "str" is a string representation of the input set.
 
1214
 * "single_disjunct" is set if we expect the result to consist of
 
1215
 *      a single disjunct.
 
1216
 */
 
1217
struct {
 
1218
        int single_disjunct;
932
1219
        const char *str;
933
 
        struct isl_set *set, *set2;
934
 
        struct isl_map *map, *map2;
935
 
 
936
 
        set = isl_set_read_from_str(ctx,
937
 
                "{[x,y]: x >= 0 & x <= 10 & y >= 0 & y <= 10 or "
938
 
                       "y >= x & x >= 2 & 5 >= y }");
939
 
        set = isl_set_coalesce(set);
940
 
        assert(set && set->n == 1);
941
 
        isl_set_free(set);
942
 
 
943
 
        set = isl_set_read_from_str(ctx,
944
 
                "{[x,y]: y >= 0 & 2x + y <= 30 & y <= 10 & x >= 0 or "
945
 
                       "x + y >= 10 & y <= x & x + y <= 20 & y >= 0}");
946
 
        set = isl_set_coalesce(set);
947
 
        assert(set && set->n == 1);
948
 
        isl_set_free(set);
949
 
 
950
 
        set = isl_set_read_from_str(ctx,
951
 
                "{[x,y]: y >= 0 & 2x + y <= 30 & y <= 10 & x >= 0 or "
952
 
                       "x + y >= 10 & y <= x & x + y <= 19 & y >= 0}");
953
 
        set = isl_set_coalesce(set);
954
 
        assert(set && set->n == 2);
955
 
        isl_set_free(set);
956
 
 
957
 
        set = isl_set_read_from_str(ctx,
958
 
                "{[x,y]: y >= 0 & x <= 5 & y <= x or "
959
 
                       "y >= 0 & x >= 6 & x <= 10 & y <= x}");
960
 
        set = isl_set_coalesce(set);
961
 
        assert(set && set->n == 1);
962
 
        isl_set_free(set);
963
 
 
964
 
        set = isl_set_read_from_str(ctx,
965
 
                "{[x,y]: y >= 0 & x <= 5 & y <= x or "
966
 
                       "y >= 0 & x >= 7 & x <= 10 & y <= x}");
967
 
        set = isl_set_coalesce(set);
968
 
        assert(set && set->n == 2);
969
 
        isl_set_free(set);
970
 
 
971
 
        set = isl_set_read_from_str(ctx,
972
 
                "{[x,y]: y >= 0 & x <= 5 & y <= x or "
973
 
                       "y >= 0 & x >= 6 & x <= 10 & y + 1 <= x}");
974
 
        set = isl_set_coalesce(set);
975
 
        assert(set && set->n == 2);
976
 
        isl_set_free(set);
977
 
 
978
 
        set = isl_set_read_from_str(ctx,
979
 
                "{[x,y]: y >= 0 & x <= 5 & y <= x or "
980
 
                       "y >= 0 & x = 6 & y <= 6}");
981
 
        set = isl_set_coalesce(set);
982
 
        assert(set && set->n == 1);
983
 
        isl_set_free(set);
984
 
 
985
 
        set = isl_set_read_from_str(ctx,
986
 
                "{[x,y]: y >= 0 & x <= 5 & y <= x or "
987
 
                       "y >= 0 & x = 7 & y <= 6}");
988
 
        set = isl_set_coalesce(set);
989
 
        assert(set && set->n == 2);
990
 
        isl_set_free(set);
991
 
 
992
 
        set = isl_set_read_from_str(ctx,
993
 
                "{[x,y]: y >= 0 & x <= 5 & y <= x or "
994
 
                       "y >= 0 & x = 6 & y <= 5}");
995
 
        set = isl_set_coalesce(set);
996
 
        assert(set && set->n == 1);
997
 
        set2 = isl_set_read_from_str(ctx,
998
 
                "{[x,y]: y >= 0 & x <= 5 & y <= x or "
999
 
                       "y >= 0 & x = 6 & y <= 5}");
1000
 
        assert(isl_set_is_equal(set, set2));
1001
 
        isl_set_free(set);
1002
 
        isl_set_free(set2);
1003
 
 
1004
 
        set = isl_set_read_from_str(ctx,
1005
 
                "{[x,y]: y >= 0 & x <= 5 & y <= x or "
1006
 
                       "y >= 0 & x = 6 & y <= 7}");
1007
 
        set = isl_set_coalesce(set);
1008
 
        assert(set && set->n == 2);
1009
 
        isl_set_free(set);
1010
 
 
1011
 
        set = isl_set_read_from_str(ctx,
1012
 
                "[n] -> { [i] : i = 1 and n >= 2 or 2 <= i and i <= n }");
1013
 
        set = isl_set_coalesce(set);
1014
 
        assert(set && set->n == 1);
1015
 
        set2 = isl_set_read_from_str(ctx,
1016
 
                "[n] -> { [i] : i = 1 and n >= 2 or 2 <= i and i <= n }");
1017
 
        assert(isl_set_is_equal(set, set2));
1018
 
        isl_set_free(set);
1019
 
        isl_set_free(set2);
1020
 
 
1021
 
        set = isl_set_read_from_str(ctx,
1022
 
                "{[x,y] : x >= 0 and y >= 0 or 0 <= y and y <= 5 and x = -1}");
1023
 
        set = isl_set_coalesce(set);
1024
 
        set2 = isl_set_read_from_str(ctx,
1025
 
                "{[x,y] : x >= 0 and y >= 0 or 0 <= y and y <= 5 and x = -1}");
1026
 
        assert(isl_set_is_equal(set, set2));
1027
 
        isl_set_free(set);
1028
 
        isl_set_free(set2);
1029
 
 
1030
 
        set = isl_set_read_from_str(ctx,
1031
 
                "[n] -> { [i] : 1 <= i and i <= n - 1 or "
1032
 
                                "2 <= i and i <= n }");
1033
 
        set = isl_set_coalesce(set);
1034
 
        assert(set && set->n == 1);
1035
 
        set2 = isl_set_read_from_str(ctx,
1036
 
                "[n] -> { [i] : 1 <= i and i <= n - 1 or "
1037
 
                                "2 <= i and i <= n }");
1038
 
        assert(isl_set_is_equal(set, set2));
1039
 
        isl_set_free(set);
1040
 
        isl_set_free(set2);
1041
 
 
1042
 
        map = isl_map_read_from_str(ctx,
1043
 
                "[n] -> { [i0] -> [o0] : exists (e0 = [(i0)/4], e1 = [(o0)/4], "
1044
 
                "e2 = [(n)/2], e3 = [(-2 + i0)/4], e4 = [(-2 + o0)/4], "
1045
 
                "e5 = [(-2n + i0)/4]: 2e2 = n and 4e3 = -2 + i0 and "
1046
 
                "4e4 = -2 + o0 and i0 >= 8 + 2n and o0 >= 2 + i0 and "
1047
 
                "o0 <= 56 + 2n and o0 <= -12 + 4n and i0 <= 57 + 2n and "
1048
 
                "i0 <= -11 + 4n and o0 >= 6 + 2n and 4e0 <= i0 and "
1049
 
                "4e0 >= -3 + i0 and 4e1 <= o0 and 4e1 >= -3 + o0 and "
1050
 
                "4e5 <= -2n + i0 and 4e5 >= -3 - 2n + i0);"
1051
 
                "[i0] -> [o0] : exists (e0 = [(i0)/4], e1 = [(o0)/4], "
1052
 
                "e2 = [(n)/2], e3 = [(-2 + i0)/4], e4 = [(-2 + o0)/4], "
1053
 
                "e5 = [(-2n + i0)/4]: 2e2 = n and 4e3 = -2 + i0 and "
1054
 
                "4e4 = -2 + o0 and 2e0 >= 3 + n and e0 <= -4 + n and "
1055
 
                "2e0 <= 27 + n and e1 <= -4 + n and 2e1 <= 27 + n and "
1056
 
                "2e1 >= 2 + n and e1 >= 1 + e0 and i0 >= 7 + 2n and "
1057
 
                "i0 <= -11 + 4n and i0 <= 57 + 2n and 4e0 <= -2 + i0 and "
1058
 
                "4e0 >= -3 + i0 and o0 >= 6 + 2n and o0 <= -11 + 4n and "
1059
 
                "o0 <= 57 + 2n and 4e1 <= -2 + o0 and 4e1 >= -3 + o0 and "
1060
 
                "4e5 <= -2n + i0 and 4e5 >= -3 - 2n + i0 ) }");
1061
 
        map = isl_map_coalesce(map);
1062
 
        map2 = isl_map_read_from_str(ctx,
1063
 
                "[n] -> { [i0] -> [o0] : exists (e0 = [(i0)/4], e1 = [(o0)/4], "
1064
 
                "e2 = [(n)/2], e3 = [(-2 + i0)/4], e4 = [(-2 + o0)/4], "
1065
 
                "e5 = [(-2n + i0)/4]: 2e2 = n and 4e3 = -2 + i0 and "
1066
 
                "4e4 = -2 + o0 and i0 >= 8 + 2n and o0 >= 2 + i0 and "
1067
 
                "o0 <= 56 + 2n and o0 <= -12 + 4n and i0 <= 57 + 2n and "
1068
 
                "i0 <= -11 + 4n and o0 >= 6 + 2n and 4e0 <= i0 and "
1069
 
                "4e0 >= -3 + i0 and 4e1 <= o0 and 4e1 >= -3 + o0 and "
1070
 
                "4e5 <= -2n + i0 and 4e5 >= -3 - 2n + i0);"
1071
 
                "[i0] -> [o0] : exists (e0 = [(i0)/4], e1 = [(o0)/4], "
1072
 
                "e2 = [(n)/2], e3 = [(-2 + i0)/4], e4 = [(-2 + o0)/4], "
1073
 
                "e5 = [(-2n + i0)/4]: 2e2 = n and 4e3 = -2 + i0 and "
1074
 
                "4e4 = -2 + o0 and 2e0 >= 3 + n and e0 <= -4 + n and "
1075
 
                "2e0 <= 27 + n and e1 <= -4 + n and 2e1 <= 27 + n and "
1076
 
                "2e1 >= 2 + n and e1 >= 1 + e0 and i0 >= 7 + 2n and "
1077
 
                "i0 <= -11 + 4n and i0 <= 57 + 2n and 4e0 <= -2 + i0 and "
1078
 
                "4e0 >= -3 + i0 and o0 >= 6 + 2n and o0 <= -11 + 4n and "
1079
 
                "o0 <= 57 + 2n and 4e1 <= -2 + o0 and 4e1 >= -3 + o0 and "
1080
 
                "4e5 <= -2n + i0 and 4e5 >= -3 - 2n + i0 ) }");
1081
 
        assert(isl_map_is_equal(map, map2));
1082
 
        isl_map_free(map);
1083
 
        isl_map_free(map2);
1084
 
 
1085
 
        str = "[n, m] -> { [] -> [o0, o2, o3] : (o3 = 1 and o0 >= 1 + m and "
 
1220
} coalesce_tests[] = {
 
1221
        { 1, "{[x,y]: x >= 0 & x <= 10 & y >= 0 & y <= 10 or "
 
1222
                       "y >= x & x >= 2 & 5 >= y }" },
 
1223
        { 1, "{[x,y]: y >= 0 & 2x + y <= 30 & y <= 10 & x >= 0 or "
 
1224
                       "x + y >= 10 & y <= x & x + y <= 20 & y >= 0}" },
 
1225
        { 0, "{[x,y]: y >= 0 & 2x + y <= 30 & y <= 10 & x >= 0 or "
 
1226
                       "x + y >= 10 & y <= x & x + y <= 19 & y >= 0}" },
 
1227
        { 1, "{[x,y]: y >= 0 & x <= 5 & y <= x or "
 
1228
                       "y >= 0 & x >= 6 & x <= 10 & y <= x}" },
 
1229
        { 0, "{[x,y]: y >= 0 & x <= 5 & y <= x or "
 
1230
                       "y >= 0 & x >= 7 & x <= 10 & y <= x}" },
 
1231
        { 0, "{[x,y]: y >= 0 & x <= 5 & y <= x or "
 
1232
                       "y >= 0 & x >= 6 & x <= 10 & y + 1 <= x}" },
 
1233
        { 1, "{[x,y]: y >= 0 & x <= 5 & y <= x or y >= 0 & x = 6 & y <= 6}" },
 
1234
        { 0, "{[x,y]: y >= 0 & x <= 5 & y <= x or y >= 0 & x = 7 & y <= 6}" },
 
1235
        { 1, "{[x,y]: y >= 0 & x <= 5 & y <= x or y >= 0 & x = 6 & y <= 5}" },
 
1236
        { 0, "{[x,y]: y >= 0 & x <= 5 & y <= x or y >= 0 & x = 6 & y <= 7}" },
 
1237
        { 1, "[n] -> { [i] : i = 1 and n >= 2 or 2 <= i and i <= n }" },
 
1238
        { 0, "{[x,y] : x >= 0 and y >= 0 or 0 <= y and y <= 5 and x = -1}" },
 
1239
        { 1, "[n] -> { [i] : 1 <= i and i <= n - 1 or 2 <= i and i <= n }" },
 
1240
        { 0, "[n] -> { [[i0] -> [o0]] : exists (e0 = [(i0)/4], e1 = [(o0)/4], "
 
1241
                "e2 = [(n)/2], e3 = [(-2 + i0)/4], e4 = [(-2 + o0)/4], "
 
1242
                "e5 = [(-2n + i0)/4]: 2e2 = n and 4e3 = -2 + i0 and "
 
1243
                "4e4 = -2 + o0 and i0 >= 8 + 2n and o0 >= 2 + i0 and "
 
1244
                "o0 <= 56 + 2n and o0 <= -12 + 4n and i0 <= 57 + 2n and "
 
1245
                "i0 <= -11 + 4n and o0 >= 6 + 2n and 4e0 <= i0 and "
 
1246
                "4e0 >= -3 + i0 and 4e1 <= o0 and 4e1 >= -3 + o0 and "
 
1247
                "4e5 <= -2n + i0 and 4e5 >= -3 - 2n + i0);"
 
1248
                "[[i0] -> [o0]] : exists (e0 = [(i0)/4], e1 = [(o0)/4], "
 
1249
                "e2 = [(n)/2], e3 = [(-2 + i0)/4], e4 = [(-2 + o0)/4], "
 
1250
                "e5 = [(-2n + i0)/4]: 2e2 = n and 4e3 = -2 + i0 and "
 
1251
                "4e4 = -2 + o0 and 2e0 >= 3 + n and e0 <= -4 + n and "
 
1252
                "2e0 <= 27 + n and e1 <= -4 + n and 2e1 <= 27 + n and "
 
1253
                "2e1 >= 2 + n and e1 >= 1 + e0 and i0 >= 7 + 2n and "
 
1254
                "i0 <= -11 + 4n and i0 <= 57 + 2n and 4e0 <= -2 + i0 and "
 
1255
                "4e0 >= -3 + i0 and o0 >= 6 + 2n and o0 <= -11 + 4n and "
 
1256
                "o0 <= 57 + 2n and 4e1 <= -2 + o0 and 4e1 >= -3 + o0 and "
 
1257
                "4e5 <= -2n + i0 and 4e5 >= -3 - 2n + i0 ) }" },
 
1258
        { 0, "[n, m] -> { [o0, o2, o3] : (o3 = 1 and o0 >= 1 + m and "
1086
1259
              "o0 <= n + m and o2 <= m and o0 >= 2 + n and o2 >= 3) or "
1087
1260
              "(o0 >= 2 + n and o0 >= 1 + m and o0 <= n + m and n >= 1 and "
1088
 
              "o3 <= -1 + o2 and o3 >= 1 - m + o2 and o3 >= 2 and o3 <= n) }";
1089
 
        map = isl_map_read_from_str(ctx, str);
1090
 
        map = isl_map_coalesce(map);
1091
 
        map2 = isl_map_read_from_str(ctx, str);
1092
 
        assert(isl_map_is_equal(map, map2));
1093
 
        isl_map_free(map);
1094
 
        isl_map_free(map2);
1095
 
 
1096
 
        str = "[M, N] -> { [i0, i1, i2, i3, i4, i5, i6] -> "
1097
 
          "[o0, o1, o2, o3, o4, o5, o6] : "
 
1261
              "o3 <= -1 + o2 and o3 >= 1 - m + o2 and o3 >= 2 and o3 <= n) }" },
 
1262
        { 0, "[M, N] -> { [[i0, i1, i2, i3, i4, i5, i6] -> "
 
1263
          "[o0, o1, o2, o3, o4, o5, o6]] : "
1098
1264
          "(o6 <= -4 + 2M - 2N + i0 + i1 - i2 + i6 - o0 - o1 + o2 and "
1099
1265
          "o3 <= -2 + i3 and o6 >= 2 + i0 + i3 + i6 - o0 - o3 and "
1100
1266
          "o6 >= 2 - M + N + i3 + i4 + i6 - o3 - o4 and o0 <= -1 + i0 and "
1107
1273
          "(N >= 2 and o3 <= -1 + i3 and o0 <= -1 + i0 and "
1108
1274
          "o6 >= i3 + i6 - o3 and M >= 0 and "
1109
1275
          "2o6 >= 1 + i0 + i3 + 2i6 - o0 - o3 and "
1110
 
          "o6 >= 1 - M + i0 + i6 - o0 and N >= 2M and o6 >= i0 + i6 - o0) }";
1111
 
        map = isl_map_read_from_str(ctx, str);
1112
 
        map = isl_map_coalesce(map);
1113
 
        map2 = isl_map_read_from_str(ctx, str);
1114
 
        assert(isl_map_is_equal(map, map2));
1115
 
        isl_map_free(map);
1116
 
        isl_map_free(map2);
1117
 
 
1118
 
        str = "[M, N] -> { [] -> [o0] : (o0 = 0 and M >= 1 and N >= 2) or "
 
1276
          "o6 >= 1 - M + i0 + i6 - o0 and N >= 2M and o6 >= i0 + i6 - o0) }" },
 
1277
        { 0, "[M, N] -> { [o0] : (o0 = 0 and M >= 1 and N >= 2) or "
1119
1278
                "(o0 = 0 and M >= 1 and N >= 2M and N >= 2 + M) or "
1120
1279
                "(o0 = 0 and M >= 2 and N >= 3) or "
1121
 
                "(M = 0 and o0 = 0 and N >= 3) }";
1122
 
        map = isl_map_read_from_str(ctx, str);
1123
 
        map = isl_map_coalesce(map);
1124
 
        map2 = isl_map_read_from_str(ctx, str);
1125
 
        assert(isl_map_is_equal(map, map2));
1126
 
        isl_map_free(map);
1127
 
        isl_map_free(map2);
1128
 
 
1129
 
        str = "{ [i0, i1, i2, i3] : (i1 = 10i0 and i0 >= 1 and 10i0 <= 100 and "
1130
 
                "i3 <= 9 + 10 i2 and i3 >= 1 + 10i2 and i3 >= 0) or "
1131
 
                "(i1 <= 9 + 10i0 and i1 >= 1 + 10i0 and i2 >= 0 and "
1132
 
                "i0 >= 0 and i1 <= 100 and i3 <= 9 + 10i2 and i3 >= 1 + 10i2) }";
1133
 
        map = isl_map_read_from_str(ctx, str);
1134
 
        map = isl_map_coalesce(map);
1135
 
        map2 = isl_map_read_from_str(ctx, str);
1136
 
        assert(isl_map_is_equal(map, map2));
1137
 
        isl_map_free(map);
1138
 
        isl_map_free(map2);
1139
 
 
1140
 
        test_coalesce_set(ctx,
1141
 
                "[M] -> { [i1] : (i1 >= 2 and i1 <= M) or "
1142
 
                                "(i1 = M and M >= 1) }", 0);
1143
 
        test_coalesce_set(ctx,
1144
 
                "{[x,y] : x,y >= 0; [x,y] : 10 <= x <= 20 and y >= -1 }", 0);
1145
 
        test_coalesce_set(ctx,
1146
 
                "{ [x, y] : (x >= 1 and y >= 1 and x <= 2 and y <= 2) or "
1147
 
                "(y = 3 and x = 1) }", 1);
1148
 
        test_coalesce_set(ctx,
1149
 
                "[M] -> { [i0, i1, i2, i3, i4] : (i1 >= 3 and i4 >= 2 + i2 and "
 
1280
                "(M = 0 and o0 = 0 and N >= 3) }" },
 
1281
        { 0, "{ [i0, i1, i2, i3] : (i1 = 10i0 and i0 >= 1 and 10i0 <= 100 and "
 
1282
            "i3 <= 9 + 10 i2 and i3 >= 1 + 10i2 and i3 >= 0) or "
 
1283
            "(i1 <= 9 + 10i0 and i1 >= 1 + 10i0 and i2 >= 0 and "
 
1284
            "i0 >= 0 and i1 <= 100 and i3 <= 9 + 10i2 and i3 >= 1 + 10i2) }" },
 
1285
        { 0, "[M] -> { [i1] : (i1 >= 2 and i1 <= M) or (i1 = M and M >= 1) }" },
 
1286
        { 0, "{[x,y] : x,y >= 0; [x,y] : 10 <= x <= 20 and y >= -1 }" },
 
1287
        { 1, "{ [x, y] : (x >= 1 and y >= 1 and x <= 2 and y <= 2) or "
 
1288
                "(y = 3 and x = 1) }" },
 
1289
        { 1, "[M] -> { [i0, i1, i2, i3, i4] : (i1 >= 3 and i4 >= 2 + i2 and "
1150
1290
                "i2 >= 2 and i0 >= 2 and i3 >= 1 + i2 and i0 <= M and "
1151
1291
                "i1 <= M and i3 <= M and i4 <= M) or "
1152
1292
                "(i1 >= 2 and i4 >= 1 + i2 and i2 >= 2 and i0 >= 2 and "
1153
1293
                "i3 >= 1 + i2 and i0 <= M and i1 <= -1 + M and i3 <= M and "
1154
 
                "i4 <= -1 + M) }", 1);
1155
 
        test_coalesce_set(ctx,
1156
 
                "{ [x, y] : (x >= 0 and y >= 0 and x <= 10 and y <= 10) or "
1157
 
                "(x >= 1 and y >= 1 and x <= 11 and y <= 11) }", 1);
1158
 
        if (test_coalesce_unbounded_wrapping(ctx) < 0)
1159
 
                return -1;
1160
 
        if (test_coalesce_set(ctx, "{[x,0] : x >= 0; [x,1] : x <= 20}", 0) < 0)
1161
 
                return -1;
1162
 
        if (test_coalesce_set(ctx, "{ [x, 1 - x] : 0 <= x <= 1; [0,0] }", 1) < 0)
1163
 
                return -1;
1164
 
        if (test_coalesce_set(ctx, "{ [0,0]; [i,i] : 1 <= i <= 10 }", 1) < 0)
1165
 
                return -1;
1166
 
        if (test_coalesce_set(ctx, "{ [0,0]; [i,j] : 1 <= i,j <= 10 }", 0) < 0)
1167
 
                return -1;
1168
 
        if (test_coalesce_set(ctx, "{ [0,0]; [i,2i] : 1 <= i <= 10 }", 1) < 0)
1169
 
                return -1;
1170
 
        if (test_coalesce_set(ctx, "{ [0,0]; [i,2i] : 2 <= i <= 10 }", 0) < 0)
1171
 
                return -1;
1172
 
        if (test_coalesce_set(ctx, "{ [1,0]; [i,2i] : 1 <= i <= 10 }", 0) < 0)
1173
 
                return -1;
1174
 
        if (test_coalesce_set(ctx, "{ [0,1]; [i,2i] : 1 <= i <= 10 }", 0) < 0)
1175
 
                return -1;
1176
 
        if (test_coalesce_set(ctx, "{ [a, b] : exists e : 2e = a and "
1177
 
                    "a >= 0 and (a <= 3 or (b <= 0 and b >= -4 + a)) }", 0) < 0)
1178
 
                return -1;
1179
 
        if (test_coalesce_set(ctx,
1180
 
                "{ [i, j, i', j'] : i <= 2 and j <= 2 and "
 
1294
                "i4 <= -1 + M) }" },
 
1295
        { 1, "{ [x, y] : (x >= 0 and y >= 0 and x <= 10 and y <= 10) or "
 
1296
                "(x >= 1 and y >= 1 and x <= 11 and y <= 11) }" },
 
1297
        { 0, "{[x,0] : x >= 0; [x,1] : x <= 20}" },
 
1298
        { 1, "{ [x, 1 - x] : 0 <= x <= 1; [0,0] }" },
 
1299
        { 1, "{ [0,0]; [i,i] : 1 <= i <= 10 }" },
 
1300
        { 0, "{ [0,0]; [i,j] : 1 <= i,j <= 10 }" },
 
1301
        { 1, "{ [0,0]; [i,2i] : 1 <= i <= 10 }" },
 
1302
        { 0, "{ [0,0]; [i,2i] : 2 <= i <= 10 }" },
 
1303
        { 0, "{ [1,0]; [i,2i] : 1 <= i <= 10 }" },
 
1304
        { 0, "{ [0,1]; [i,2i] : 1 <= i <= 10 }" },
 
1305
        { 0, "{ [a, b] : exists e : 2e = a and "
 
1306
                    "a >= 0 and (a <= 3 or (b <= 0 and b >= -4 + a)) }" },
 
1307
        { 0, "{ [i, j, i', j'] : i <= 2 and j <= 2 and "
1181
1308
                        "j' >= -1 + 2i + j - 2i' and i' <= -1 + i and "
1182
1309
                        "j >= 1 and j' <= i + j - i' and i >= 1; "
1183
 
                "[1, 1, 1, 1] }", 0) < 0)
1184
 
                return -1;
1185
 
        if (test_coalesce_set(ctx, "{ [i,j] : exists a,b : i = 2a and j = 3b; "
1186
 
                                     "[i,j] : exists a : j = 3a }", 1) < 0)
1187
 
                return -1;
 
1310
                "[1, 1, 1, 1] }" },
 
1311
        { 1, "{ [i,j] : exists a,b : i = 2a and j = 3b; "
 
1312
                 "[i,j] : exists a : j = 3a }" },
 
1313
        { 1, "{ [a, b, c] : (c <= 7 - b and b <= 1 and b >= 0 and "
 
1314
                        "c >= 3 + b and b <= 3 + 8a and b >= -26 + 8a and "
 
1315
                        "a >= 3) or "
 
1316
                    "(b <= 1 and c <= 7 and b >= 0 and c >= 4 + b and "
 
1317
                        "b <= 3 + 8a and b >= -26 + 8a and a >= 3) }" },
 
1318
        { 1, "{ [a, 0, c] : c >= 1 and c <= 29 and c >= -1 + 8a and "
 
1319
                                "c <= 6 + 8a and a >= 3; "
 
1320
                "[a, -1, c] : c >= 1 and c <= 30 and c >= 8a and "
 
1321
                                "c <= 7 + 8a and a >= 3 and a <= 4 }" },
 
1322
        { 1, "{ [x,y] : 0 <= x <= 2 and y >= 0 and x + 2y <= 4; "
 
1323
                "[x,0] : 3 <= x <= 4 }" },
 
1324
        { 1, "{ [x,y] : 0 <= x <= 3 and y >= 0 and x + 3y <= 6; "
 
1325
                "[x,0] : 4 <= x <= 5 }" },
 
1326
        { 0, "{ [x,y] : 0 <= x <= 2 and y >= 0 and x + 2y <= 4; "
 
1327
                "[x,0] : 3 <= x <= 5 }" },
 
1328
        { 0, "{ [x,y] : 0 <= x <= 2 and y >= 0 and x + y <= 4; "
 
1329
                "[x,0] : 3 <= x <= 4 }" },
 
1330
        { 1 , "{ [i0, i1] : i0 <= 122 and i0 >= 1 and 128i1 >= -249 + i0 and "
 
1331
                        "i1 <= 0; "
 
1332
                "[i0, 0] : i0 >= 123 and i0 <= 124 }" },
 
1333
};
 
1334
 
 
1335
/* Test the functionality of isl_set_coalesce.
 
1336
 * That is, check that the output is always equal to the input
 
1337
 * and in some cases that the result consists of a single disjunct.
 
1338
 */
 
1339
static int test_coalesce(struct isl_ctx *ctx)
 
1340
{
 
1341
        int i;
 
1342
 
 
1343
        for (i = 0; i < ARRAY_SIZE(coalesce_tests); ++i) {
 
1344
                const char *str = coalesce_tests[i].str;
 
1345
                int check_one = coalesce_tests[i].single_disjunct;
 
1346
                if (test_coalesce_set(ctx, str, check_one) < 0)
 
1347
                        return -1;
 
1348
        }
 
1349
 
 
1350
        if (test_coalesce_unbounded_wrapping(ctx) < 0)
 
1351
                return -1;
 
1352
 
1188
1353
        return 0;
1189
1354
}
1190
1355
 
1438
1603
        isl_map_free(map);
1439
1604
}
1440
1605
 
1441
 
void test_lexmin(struct isl_ctx *ctx)
 
1606
static int test_lexmin(struct isl_ctx *ctx)
1442
1607
{
 
1608
        int equal;
1443
1609
        const char *str;
1444
1610
        isl_basic_map *bmap;
1445
1611
        isl_map *map, *map2;
1521
1687
        assert(isl_map_is_equal(map, map2));
1522
1688
        isl_map_free(map);
1523
1689
        isl_map_free(map2);
 
1690
 
 
1691
        /* Check that empty pieces are properly combined. */
 
1692
        str = "[K, N] -> { [x, y] -> [a, b] : K+2<=N<=K+4 and x>=4 and "
 
1693
                "2N-6<=x<K+N and N-1<=a<=K+N-1 and N+b-6<=a<=2N-4 and "
 
1694
                "b<=2N-3K+a and 3b<=4N-K+1 and b>=N and a>=x+1 }";
 
1695
        map = isl_map_read_from_str(ctx, str);
 
1696
        map = isl_map_lexmin(map);
 
1697
        str = "[K, N] -> { [x, y] -> [1 + x, N] : x >= -6 + 2N and "
 
1698
                "x <= -5 + 2N and x >= -1 + 3K - N and x <= -2 + K + N and "
 
1699
                "x >= 4 }";
 
1700
        map2 = isl_map_read_from_str(ctx, str);
 
1701
        assert(isl_map_is_equal(map, map2));
 
1702
        isl_map_free(map);
 
1703
        isl_map_free(map2);
 
1704
 
 
1705
        str = "[i] -> { [i', j] : j = i - 8i' and i' >= 0 and i' <= 7 and "
 
1706
                                " 8i' <= i and 8i' >= -7 + i }";
 
1707
        set = isl_set_read_from_str(ctx, str);
 
1708
        pma = isl_set_lexmin_pw_multi_aff(isl_set_copy(set));
 
1709
        set2 = isl_set_from_pw_multi_aff(pma);
 
1710
        equal = isl_set_is_equal(set, set2);
 
1711
        isl_set_free(set);
 
1712
        isl_set_free(set2);
 
1713
        if (equal < 0)
 
1714
                return -1;
 
1715
        if (!equal)
 
1716
                isl_die(ctx, isl_error_unknown,
 
1717
                        "unexpected difference between set and "
 
1718
                        "piecewise affine expression", return -1);
 
1719
 
 
1720
        return 0;
1524
1721
}
1525
1722
 
1526
1723
struct must_may {
1842
2039
        test_bijective_case(ctx, "[N,M]->{[i,j] -> [x,y] : 2x=i & y =j}", 1);
1843
2040
}
1844
2041
 
1845
 
void test_pwqp(struct isl_ctx *ctx)
 
2042
static int test_pwqp(struct isl_ctx *ctx)
1846
2043
{
1847
2044
        const char *str;
1848
2045
        isl_set *set;
1849
2046
        isl_pw_qpolynomial *pwqp1, *pwqp2;
 
2047
        int equal;
1850
2048
 
1851
2049
        str = "{ [i,j,k] -> 1 + 9 * [i/5] + 7 * [j/11] + 4 * [k/13] }";
1852
2050
        pwqp1 = isl_pw_qpolynomial_read_from_str(ctx, str);
1934
2132
        pwqp1 = isl_pw_qpolynomial_sub(pwqp1, pwqp2);
1935
2133
        assert(isl_pw_qpolynomial_is_zero(pwqp1));
1936
2134
        isl_pw_qpolynomial_free(pwqp1);
 
2135
 
 
2136
        str = "{ [a,b,a] -> (([(2*[a/3]+b)/5]) * ([(2*[a/3]+b)/5])) }";
 
2137
        pwqp2 = isl_pw_qpolynomial_read_from_str(ctx, str);
 
2138
        str = "{ [a,b,c] -> (([(2*[a/3]+b)/5]) * ([(2*[c/3]+b)/5])) }";
 
2139
        pwqp1 = isl_pw_qpolynomial_read_from_str(ctx, str);
 
2140
        set = isl_set_read_from_str(ctx, "{ [a,b,a] }");
 
2141
        pwqp1 = isl_pw_qpolynomial_intersect_domain(pwqp1, set);
 
2142
        equal = isl_pw_qpolynomial_plain_is_equal(pwqp1, pwqp2);
 
2143
        isl_pw_qpolynomial_free(pwqp1);
 
2144
        isl_pw_qpolynomial_free(pwqp2);
 
2145
        if (equal < 0)
 
2146
                return -1;
 
2147
        if (!equal)
 
2148
                isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
 
2149
 
 
2150
        str = "{ [a,b,c] -> (([(2*[a/3]+1)/5]) * ([(2*[c/3]+1)/5])) : b = 1 }";
 
2151
        pwqp2 = isl_pw_qpolynomial_read_from_str(ctx, str);
 
2152
        str = "{ [a,b,c] -> (([(2*[a/3]+b)/5]) * ([(2*[c/3]+b)/5])) }";
 
2153
        pwqp1 = isl_pw_qpolynomial_read_from_str(ctx, str);
 
2154
        pwqp1 = isl_pw_qpolynomial_fix_val(pwqp1, isl_dim_set, 1,
 
2155
                                                isl_val_one(ctx));
 
2156
        equal = isl_pw_qpolynomial_plain_is_equal(pwqp1, pwqp2);
 
2157
        isl_pw_qpolynomial_free(pwqp1);
 
2158
        isl_pw_qpolynomial_free(pwqp2);
 
2159
        if (equal < 0)
 
2160
                return -1;
 
2161
        if (!equal)
 
2162
                isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
 
2163
 
 
2164
        return 0;
1937
2165
}
1938
2166
 
1939
2167
void test_split_periods(isl_ctx *ctx)
2335
2563
        return 0;
2336
2564
}
2337
2565
 
 
2566
/* Check that the schedule map is properly padded, even after being
 
2567
 * reconstructed from the band forest.
 
2568
 */
 
2569
static int test_padded_schedule(isl_ctx *ctx)
 
2570
{
 
2571
        const char *str;
 
2572
        isl_union_set *D;
 
2573
        isl_union_map *validity, *proximity;
 
2574
        isl_schedule *sched;
 
2575
        isl_union_map *map1, *map2;
 
2576
        isl_band_list *list;
 
2577
        int equal;
 
2578
 
 
2579
        str = "[N] -> { S0[i] : 0 <= i <= N; S1[i, j] : 0 <= i, j <= N }";
 
2580
        D = isl_union_set_read_from_str(ctx, str);
 
2581
        validity = isl_union_map_empty(isl_union_set_get_space(D));
 
2582
        proximity = isl_union_map_copy(validity);
 
2583
        sched = isl_union_set_compute_schedule(D, validity, proximity);
 
2584
        map1 = isl_schedule_get_map(sched);
 
2585
        list = isl_schedule_get_band_forest(sched);
 
2586
        isl_band_list_free(list);
 
2587
        map2 = isl_schedule_get_map(sched);
 
2588
        isl_schedule_free(sched);
 
2589
        equal = isl_union_map_is_equal(map1, map2);
 
2590
        isl_union_map_free(map1);
 
2591
        isl_union_map_free(map2);
 
2592
 
 
2593
        if (equal < 0)
 
2594
                return -1;
 
2595
        if (!equal)
 
2596
                isl_die(ctx, isl_error_unknown,
 
2597
                        "reconstructed schedule map not the same as original",
 
2598
                        return -1);
 
2599
 
 
2600
        return 0;
 
2601
}
 
2602
 
2338
2603
int test_schedule(isl_ctx *ctx)
2339
2604
{
2340
2605
        const char *D, *W, *R, *V, *P, *S;
2595
2860
        if (test_has_schedule(ctx, D, V, P) < 0)
2596
2861
                return -1;
2597
2862
 
 
2863
        if (test_padded_schedule(ctx) < 0)
 
2864
                return -1;
 
2865
 
 
2866
        /* Check that check for progress is not confused by rational
 
2867
         * solution.
 
2868
         */
 
2869
        D = "[N] -> { S0[i, j] : i >= 0 and i <= N and j >= 0 and j <= N }";
 
2870
        V = "[N] -> { S0[i0, -1 + N] -> S0[2 + i0, 0] : i0 >= 0 and "
 
2871
                                                        "i0 <= -2 + N; "
 
2872
                        "S0[i0, i1] -> S0[i0, 1 + i1] : i0 >= 0 and "
 
2873
                                "i0 <= N and i1 >= 0 and i1 <= -1 + N }";
 
2874
        P = "{}";
 
2875
        ctx->opt->schedule_algorithm = ISL_SCHEDULE_ALGORITHM_FEAUTRIER;
 
2876
        if (test_has_schedule(ctx, D, V, P) < 0)
 
2877
                return -1;
 
2878
        ctx->opt->schedule_algorithm = ISL_SCHEDULE_ALGORITHM_ISL;
 
2879
 
2598
2880
        return 0;
2599
2881
}
2600
2882
 
2802
3084
        if (!equal)
2803
3085
                isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
2804
3086
 
 
3087
        /* Check that solutions are properly merged. */
 
3088
        str = "[n] -> { [a, b, c] : c >= -4a - 2b and "
 
3089
                                "c <= -1 + n - 4a - 2b and c >= -2b and "
 
3090
                                "4a >= -4 + n and c >= 0 }";
 
3091
        set = isl_set_read_from_str(ctx, str);
 
3092
        pwaff = isl_set_dim_min(set, 2);
 
3093
        set1 = isl_set_from_pw_aff(pwaff);
 
3094
        str = "[n] -> { [(0)] : n >= 1 }";
 
3095
        set2 = isl_set_read_from_str(ctx, str);
 
3096
        equal = isl_set_is_equal(set1, set2);
 
3097
        isl_set_free(set1);
 
3098
        isl_set_free(set2);
 
3099
 
 
3100
        if (equal < 0)
 
3101
                return -1;
 
3102
        if (!equal)
 
3103
                isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
 
3104
 
 
3105
        return 0;
 
3106
}
 
3107
 
 
3108
/* Is "pma" obviously equal to the isl_pw_multi_aff represented by "str"?
 
3109
 */
 
3110
static int pw_multi_aff_plain_is_equal(__isl_keep isl_pw_multi_aff *pma,
 
3111
        const char *str)
 
3112
{
 
3113
        isl_ctx *ctx;
 
3114
        isl_pw_multi_aff *pma2;
 
3115
        int equal;
 
3116
 
 
3117
        if (!pma)
 
3118
                return -1;
 
3119
 
 
3120
        ctx = isl_pw_multi_aff_get_ctx(pma);
 
3121
        pma2 = isl_pw_multi_aff_read_from_str(ctx, str);
 
3122
        equal = isl_pw_multi_aff_plain_is_equal(pma, pma2);
 
3123
        isl_pw_multi_aff_free(pma2);
 
3124
 
 
3125
        return equal;
 
3126
}
 
3127
 
 
3128
/* Check that "pma" is obviously equal to the isl_pw_multi_aff
 
3129
 * represented by "str".
 
3130
 */
 
3131
static int pw_multi_aff_check_plain_equal(__isl_keep isl_pw_multi_aff *pma,
 
3132
        const char *str)
 
3133
{
 
3134
        int equal;
 
3135
 
 
3136
        equal = pw_multi_aff_plain_is_equal(pma, str);
 
3137
        if (equal < 0)
 
3138
                return -1;
 
3139
        if (!equal)
 
3140
                isl_die(isl_pw_multi_aff_get_ctx(pma), isl_error_unknown,
 
3141
                        "result not as expected", return -1);
 
3142
        return 0;
 
3143
}
 
3144
 
 
3145
/* Basic test for isl_pw_multi_aff_product.
 
3146
 *
 
3147
 * Check that multiple pieces are properly handled.
 
3148
 */
 
3149
static int test_product_pma(isl_ctx *ctx)
 
3150
{
 
3151
        int equal;
 
3152
        const char *str;
 
3153
        isl_pw_multi_aff *pma1, *pma2;
 
3154
 
 
3155
        str = "{ A[i] -> B[1] : i < 0; A[i] -> B[2] : i >= 0 }";
 
3156
        pma1 = isl_pw_multi_aff_read_from_str(ctx, str);
 
3157
        str = "{ C[] -> D[] }";
 
3158
        pma2 = isl_pw_multi_aff_read_from_str(ctx, str);
 
3159
        pma1 = isl_pw_multi_aff_product(pma1, pma2);
 
3160
        str = "{ [A[i] -> C[]] -> [B[(1)] -> D[]] : i < 0;"
 
3161
                "[A[i] -> C[]] -> [B[(2)] -> D[]] : i >= 0 }";
 
3162
        equal = pw_multi_aff_check_plain_equal(pma1, str);
 
3163
        isl_pw_multi_aff_free(pma1);
 
3164
        if (equal < 0)
 
3165
                return -1;
 
3166
 
2805
3167
        return 0;
2806
3168
}
2807
3169
 
2835
3197
        if (!ok)
2836
3198
                isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
2837
3199
 
 
3200
        if (test_product_pma(ctx) < 0)
 
3201
                return -1;
 
3202
 
2838
3203
        return 0;
2839
3204
}
2840
3205
 
3303
3668
        return 0;
3304
3669
}
3305
3670
 
 
3671
/* Check that isl_basic_map_curry does not modify input.
 
3672
 */
 
3673
static int test_curry(isl_ctx *ctx)
 
3674
{
 
3675
        const char *str;
 
3676
        isl_basic_map *bmap1, *bmap2;
 
3677
        int equal;
 
3678
 
 
3679
        str = "{ [A[] -> B[]] -> C[] }";
 
3680
        bmap1 = isl_basic_map_read_from_str(ctx, str);
 
3681
        bmap2 = isl_basic_map_curry(isl_basic_map_copy(bmap1));
 
3682
        equal = isl_basic_map_is_equal(bmap1, bmap2);
 
3683
        isl_basic_map_free(bmap1);
 
3684
        isl_basic_map_free(bmap2);
 
3685
 
 
3686
        if (equal < 0)
 
3687
                return -1;
 
3688
        if (equal)
 
3689
                isl_die(ctx, isl_error_unknown,
 
3690
                        "curried map should not be equal to original",
 
3691
                        return -1);
 
3692
 
 
3693
        return 0;
 
3694
}
 
3695
 
3306
3696
struct {
3307
3697
        const char *set;
3308
3698
        const char *ma;
3333
3723
          "{ A[i,j] : j = [(i)/6] and exists a : i = 3 a }" },
3334
3724
};
3335
3725
 
3336
 
int test_preimage(isl_ctx *ctx)
 
3726
static int test_preimage_basic_set(isl_ctx *ctx)
3337
3727
{
3338
3728
        int i;
3339
3729
        isl_basic_set *bset1, *bset2;
3359
3749
}
3360
3750
 
3361
3751
struct {
 
3752
        const char *map;
 
3753
        const char *ma;
 
3754
        const char *res;
 
3755
} preimage_domain_tests[] = {
 
3756
        { "{ B[i,j] -> C[2i + 3j] : 0 <= i < 10 and 0 <= j < 100 }",
 
3757
          "{ A[j,i] -> B[i,j] }",
 
3758
          "{ A[j,i] -> C[2i + 3j] : 0 <= i < 10 and 0 <= j < 100 }" },
 
3759
        { "{ B[i] -> C[i]; D[i] -> E[i] }",
 
3760
          "{ A[i] -> B[i + 1] }",
 
3761
          "{ A[i] -> C[i + 1] }" },
 
3762
        { "{ B[i] -> C[i]; B[i] -> E[i] }",
 
3763
          "{ A[i] -> B[i + 1] }",
 
3764
          "{ A[i] -> C[i + 1]; A[i] -> E[i + 1] }" },
 
3765
        { "{ B[i] -> C[([i/2])] }",
 
3766
          "{ A[i] -> B[2i] }",
 
3767
          "{ A[i] -> C[i] }" },
 
3768
        { "{ B[i,j] -> C[([i/2]), ([(i+j)/3])] }",
 
3769
          "{ A[i] -> B[([i/5]), ([i/7])] }",
 
3770
          "{ A[i] -> C[([([i/5])/2]), ([(([i/5])+([i/7]))/3])] }" },
 
3771
        { "[N] -> { B[i] -> C[([N/2]), i, ([N/3])] }",
 
3772
          "[N] -> { A[] -> B[([N/5])] }",
 
3773
          "[N] -> { A[] -> C[([N/2]), ([N/5]), ([N/3])] }" },
 
3774
        { "{ B[i] -> C[i] : exists a : i = 5 a }",
 
3775
          "{ A[i] -> B[2i] }",
 
3776
          "{ A[i] -> C[2i] : exists a : 2i = 5 a }" },
 
3777
        { "{ B[i] -> C[i] : exists a : i = 2 a; "
 
3778
            "B[i] -> D[i] : exists a : i = 2 a + 1 }",
 
3779
          "{ A[i] -> B[2i] }",
 
3780
          "{ A[i] -> C[2i] }" },
 
3781
};
 
3782
 
 
3783
static int test_preimage_union_map(isl_ctx *ctx)
 
3784
{
 
3785
        int i;
 
3786
        isl_union_map *umap1, *umap2;
 
3787
        isl_multi_aff *ma;
 
3788
        int equal;
 
3789
 
 
3790
        for (i = 0; i < ARRAY_SIZE(preimage_domain_tests); ++i) {
 
3791
                umap1 = isl_union_map_read_from_str(ctx,
 
3792
                                                preimage_domain_tests[i].map);
 
3793
                ma = isl_multi_aff_read_from_str(ctx,
 
3794
                                                preimage_domain_tests[i].ma);
 
3795
                umap2 = isl_union_map_read_from_str(ctx,
 
3796
                                                preimage_domain_tests[i].res);
 
3797
                umap1 = isl_union_map_preimage_domain_multi_aff(umap1, ma);
 
3798
                equal = isl_union_map_is_equal(umap1, umap2);
 
3799
                isl_union_map_free(umap1);
 
3800
                isl_union_map_free(umap2);
 
3801
                if (equal < 0)
 
3802
                        return -1;
 
3803
                if (!equal)
 
3804
                        isl_die(ctx, isl_error_unknown, "bad preimage",
 
3805
                                return -1);
 
3806
        }
 
3807
 
 
3808
        return 0;
 
3809
}
 
3810
 
 
3811
static int test_preimage(isl_ctx *ctx)
 
3812
{
 
3813
        if (test_preimage_basic_set(ctx) < 0)
 
3814
                return -1;
 
3815
        if (test_preimage_union_map(ctx) < 0)
 
3816
                return -1;
 
3817
 
 
3818
        return 0;
 
3819
}
 
3820
 
 
3821
struct {
3362
3822
        const char *ma1;
3363
3823
        const char *ma;
3364
3824
        const char *res;
3737
4197
        return 0;
3738
4198
}
3739
4199
 
 
4200
/* This function is called for each leaf in the AST generated
 
4201
 * from test_ast_gen5.
 
4202
 *
 
4203
 * We finalize the AST generation by extending the outer schedule
 
4204
 * with a zero-dimensional schedule.  If this results in any for loops,
 
4205
 * then this means that we did not pass along enough information
 
4206
 * about the outer schedule to the inner AST generation.
 
4207
 */
 
4208
static __isl_give isl_ast_node *create_leaf(__isl_take isl_ast_build *build,
 
4209
        void *user)
 
4210
{
 
4211
        isl_union_map *schedule, *extra;
 
4212
        isl_ast_node *tree;
 
4213
 
 
4214
        schedule = isl_ast_build_get_schedule(build);
 
4215
        extra = isl_union_map_copy(schedule);
 
4216
        extra = isl_union_map_from_domain(isl_union_map_domain(extra));
 
4217
        schedule = isl_union_map_range_product(schedule, extra);
 
4218
        tree = isl_ast_build_ast_from_schedule(build, schedule);
 
4219
        isl_ast_build_free(build);
 
4220
 
 
4221
        if (!tree)
 
4222
                return NULL;
 
4223
 
 
4224
        if (isl_ast_node_get_type(tree) == isl_ast_node_for)
 
4225
                isl_die(isl_ast_node_get_ctx(tree), isl_error_unknown,
 
4226
                        "code should not contain any for loop",
 
4227
                        return isl_ast_node_free(tree));
 
4228
 
 
4229
        return tree;
 
4230
}
 
4231
 
 
4232
/* Check that we do not lose any information when going back and
 
4233
 * forth between internal and external schedule.
 
4234
 *
 
4235
 * In particular, we create an AST where we unroll the only
 
4236
 * non-constant dimension in the schedule.  We therefore do
 
4237
 * not expect any for loops in the AST.  However, older versions
 
4238
 * of isl would not pass along enough information about the outer
 
4239
 * schedule when performing an inner code generation from a create_leaf
 
4240
 * callback, resulting in the inner code generation producing a for loop.
 
4241
 */
 
4242
static int test_ast_gen5(isl_ctx *ctx)
 
4243
{
 
4244
        const char *str;
 
4245
        isl_set *set;
 
4246
        isl_union_map *schedule, *options;
 
4247
        isl_ast_build *build;
 
4248
        isl_ast_node *tree;
 
4249
 
 
4250
        str = "{ A[] -> [1, 1, 2]; B[i] -> [1, i, 0] : i >= 1 and i <= 2 }";
 
4251
        schedule = isl_union_map_read_from_str(ctx, str);
 
4252
 
 
4253
        str = "{ [a, b, c] -> unroll[1] : exists (e0 = [(a)/4]: "
 
4254
                                "4e0 >= -1 + a - b and 4e0 <= -2 + a + b) }";
 
4255
        options = isl_union_map_read_from_str(ctx, str);
 
4256
 
 
4257
        set = isl_set_universe(isl_space_params_alloc(ctx, 0));
 
4258
        build = isl_ast_build_from_context(set);
 
4259
        build = isl_ast_build_set_options(build, options);
 
4260
        build = isl_ast_build_set_create_leaf(build, &create_leaf, NULL);
 
4261
        tree = isl_ast_build_ast_from_schedule(build, schedule);
 
4262
        isl_ast_build_free(build);
 
4263
        isl_ast_node_free(tree);
 
4264
        if (!tree)
 
4265
                return -1;
 
4266
 
 
4267
        return 0;
 
4268
}
 
4269
 
3740
4270
static int test_ast_gen(isl_ctx *ctx)
3741
4271
{
3742
4272
        if (test_ast_gen1(ctx) < 0)
3747
4277
                return -1;
3748
4278
        if (test_ast_gen4(ctx) < 0)
3749
4279
                return -1;
 
4280
        if (test_ast_gen5(ctx) < 0)
 
4281
                return -1;
 
4282
        return 0;
 
4283
}
 
4284
 
 
4285
/* Check if dropping output dimensions from an isl_pw_multi_aff
 
4286
 * works properly.
 
4287
 */
 
4288
static int test_pw_multi_aff(isl_ctx *ctx)
 
4289
{
 
4290
        const char *str;
 
4291
        isl_pw_multi_aff *pma1, *pma2;
 
4292
        int equal;
 
4293
 
 
4294
        str = "{ [i,j] -> [i+j, 4i-j] }";
 
4295
        pma1 = isl_pw_multi_aff_read_from_str(ctx, str);
 
4296
        str = "{ [i,j] -> [4i-j] }";
 
4297
        pma2 = isl_pw_multi_aff_read_from_str(ctx, str);
 
4298
 
 
4299
        pma1 = isl_pw_multi_aff_drop_dims(pma1, isl_dim_out, 0, 1);
 
4300
 
 
4301
        equal = isl_pw_multi_aff_plain_is_equal(pma1, pma2);
 
4302
 
 
4303
        isl_pw_multi_aff_free(pma1);
 
4304
        isl_pw_multi_aff_free(pma2);
 
4305
        if (equal < 0)
 
4306
                return -1;
 
4307
        if (!equal)
 
4308
                isl_die(ctx, isl_error_unknown,
 
4309
                        "expressions not equal", return -1);
 
4310
 
 
4311
        return 0;
 
4312
}
 
4313
 
 
4314
/* This is a regression test for a bug where isl_basic_map_simplify
 
4315
 * would end up in an infinite loop.  In particular, we construct
 
4316
 * an empty basic set that is not obviously empty.
 
4317
 * isl_basic_set_is_empty marks the basic set as empty.
 
4318
 * After projecting out i3, the variable can be dropped completely,
 
4319
 * but isl_basic_map_simplify refrains from doing so if the basic set
 
4320
 * is empty and would end up in an infinite loop if it didn't test
 
4321
 * explicitly for empty basic maps in the outer loop.
 
4322
 */
 
4323
static int test_simplify(isl_ctx *ctx)
 
4324
{
 
4325
        const char *str;
 
4326
        isl_basic_set *bset;
 
4327
        int empty;
 
4328
 
 
4329
        str = "{ [i0, i1, i2, i3] : i0 >= -2 and 6i2 <= 4 + i0 + 5i1 and "
 
4330
                "i2 <= 22 and 75i2 <= 111 + 13i0 + 60i1 and "
 
4331
                "25i2 >= 38 + 6i0 + 20i1 and i0 <= -1 and i2 >= 20 and "
 
4332
                "i3 >= i2 }";
 
4333
        bset = isl_basic_set_read_from_str(ctx, str);
 
4334
        empty = isl_basic_set_is_empty(bset);
 
4335
        bset = isl_basic_set_project_out(bset, isl_dim_set, 3, 1);
 
4336
        isl_basic_set_free(bset);
 
4337
        if (!bset)
 
4338
                return -1;
 
4339
        if (!empty)
 
4340
                isl_die(ctx, isl_error_unknown,
 
4341
                        "basic set should be empty", return -1);
 
4342
 
 
4343
        return 0;
 
4344
}
 
4345
 
 
4346
/* This is a regression test for a bug where isl_tab_basic_map_partial_lexopt
 
4347
 * with gbr context would fail to disable the use of the shifted tableau
 
4348
 * when transferring equalities for the input to the context, resulting
 
4349
 * in invalid sample values.
 
4350
 */
 
4351
static int test_partial_lexmin(isl_ctx *ctx)
 
4352
{
 
4353
        const char *str;
 
4354
        isl_basic_set *bset;
 
4355
        isl_basic_map *bmap;
 
4356
        isl_map *map;
 
4357
 
 
4358
        str = "{ [1, b, c, 1 - c] -> [e] : 2e <= -c and 2e >= -3 + c }";
 
4359
        bmap = isl_basic_map_read_from_str(ctx, str);
 
4360
        str = "{ [a, b, c, d] : c <= 1 and 2d >= 6 - 4b - c }";
 
4361
        bset = isl_basic_set_read_from_str(ctx, str);
 
4362
        map = isl_basic_map_partial_lexmin(bmap, bset, NULL);
 
4363
        isl_map_free(map);
 
4364
 
 
4365
        if (!map)
 
4366
                return -1;
 
4367
 
 
4368
        return 0;
 
4369
}
 
4370
 
 
4371
/* Check that the variable compression performed on the existentially
 
4372
 * quantified variables inside isl_basic_set_compute_divs is not confused
 
4373
 * by the implicit equalities among the parameters.
 
4374
 */
 
4375
static int test_compute_divs(isl_ctx *ctx)
 
4376
{
 
4377
        const char *str;
 
4378
        isl_basic_set *bset;
 
4379
        isl_set *set;
 
4380
 
 
4381
        str = "[a, b, c, d, e] -> { [] : exists (e0: 2d = b and a <= 124 and "
 
4382
                "b <= 2046 and b >= 0 and b <= 60 + 64a and 2e >= b + 2c and "
 
4383
                "2e >= b and 2e <= 1 + b and 2e <= 1 + b + 2c and "
 
4384
                "32768e0 >= -124 + a and 2097152e0 <= 60 + 64a - b) }";
 
4385
        bset = isl_basic_set_read_from_str(ctx, str);
 
4386
        set = isl_basic_set_compute_divs(bset);
 
4387
        isl_set_free(set);
 
4388
        if (!set)
 
4389
                return -1;
 
4390
 
3750
4391
        return 0;
3751
4392
}
3752
4393
 
3754
4395
        const char *name;
3755
4396
        int (*fn)(isl_ctx *ctx);
3756
4397
} tests [] = {
 
4398
        { "val", &test_val },
 
4399
        { "compute divs", &test_compute_divs },
 
4400
        { "partial lexmin", &test_partial_lexmin },
 
4401
        { "simplify", &test_simplify },
 
4402
        { "curry", &test_curry },
 
4403
        { "piecewise multi affine expressions", &test_pw_multi_aff },
3757
4404
        { "conversion", &test_conversion },
3758
4405
        { "list", &test_list },
3759
4406
        { "align parameters", &test_align_parameters },
3784
4431
        { "factorize", &test_factorize },
3785
4432
        { "subset", &test_subset },
3786
4433
        { "subtract", &test_subtract },
 
4434
        { "lexmin", &test_lexmin },
 
4435
        { "gist", &test_gist },
 
4436
        { "piecewise quasi-polynomials", &test_pwqp },
3787
4437
};
3788
4438
 
3789
4439
int main()
3804
4454
        test_bound(ctx);
3805
4455
        test_union(ctx);
3806
4456
        test_split_periods(ctx);
3807
 
        test_pwqp(ctx);
3808
4457
        test_lex(ctx);
3809
4458
        test_bijective(ctx);
3810
4459
        test_dep(ctx);
3814
4463
        test_dim(ctx);
3815
4464
        test_application(ctx);
3816
4465
        test_convex_hull(ctx);
3817
 
        test_gist(ctx);
3818
4466
        test_closure(ctx);
3819
 
        test_lexmin(ctx);
3820
4467
        isl_ctx_free(ctx);
3821
4468
        return 0;
3822
4469
error: