39
__isl_give PW *FN(PW,ZERO)(__isl_take isl_dim *dim, enum isl_fold type)
39
__isl_give PW *FN(PW,ZERO)(__isl_take isl_space *dim, enum isl_fold type)
41
return FN(PW,alloc_)(dim, type, 0);
41
return FN(PW,alloc_size)(dim, type, 0);
44
__isl_give PW *FN(PW,ZERO)(__isl_take isl_dim *dim)
44
__isl_give PW *FN(PW,ZERO)(__isl_take isl_space *dim)
46
return FN(PW,alloc_)(dim, 0);
46
return FN(PW,alloc_size)(dim, 0);
167
167
isl_set_free(pw->p[i].set);
168
168
FN(EL,free)(pw->p[i].FIELD);
170
isl_dim_free(pw->dim);
170
isl_space_free(pw->dim);
176
const char *FN(PW,get_dim_name)(__isl_keep PW *pw, enum isl_dim_type type,
179
return pw ? isl_space_get_dim_name(pw->dim, type, pos) : NULL;
182
int FN(PW,has_dim_id)(__isl_keep PW *pw, enum isl_dim_type type, unsigned pos)
184
return pw ? isl_space_has_dim_id(pw->dim, type, pos) : -1;
187
__isl_give isl_id *FN(PW,get_dim_id)(__isl_keep PW *pw, enum isl_dim_type type,
190
return pw ? isl_space_get_dim_id(pw->dim, type, pos) : NULL;
193
const char *FN(PW,get_tuple_name)(__isl_keep PW *pw, enum isl_dim_type type)
195
return pw ? isl_space_get_tuple_name(pw->dim, type) : NULL;
198
int FN(PW,has_tuple_id)(__isl_keep PW *pw, enum isl_dim_type type)
200
return pw ? isl_space_has_tuple_id(pw->dim, type) : -1;
203
__isl_give isl_id *FN(PW,get_tuple_id)(__isl_keep PW *pw, enum isl_dim_type type)
205
return pw ? isl_space_get_tuple_id(pw->dim, type) : NULL;
176
208
int FN(PW,IS_ZERO)(__isl_keep PW *pw)
181
213
return pw->n == 0;
184
__isl_give PW *FN(PW,add)(__isl_take PW *pw1, __isl_take PW *pw2)
217
__isl_give PW *FN(PW,realign_domain)(__isl_take PW *pw,
218
__isl_take isl_reordering *exp)
226
for (i = 0; i < pw->n; ++i) {
227
pw->p[i].set = isl_set_realign(pw->p[i].set,
228
isl_reordering_copy(exp));
231
pw->p[i].FIELD = FN(EL,realign_domain)(pw->p[i].FIELD,
232
isl_reordering_copy(exp));
237
pw = FN(PW,reset_domain_space)(pw, isl_space_copy(exp->dim));
239
isl_reordering_free(exp);
242
isl_reordering_free(exp);
247
/* Align the parameters of "pw" to those of "model".
249
__isl_give PW *FN(PW,align_params)(__isl_take PW *pw, __isl_take isl_space *model)
256
ctx = isl_space_get_ctx(model);
257
if (!isl_space_has_named_params(model))
258
isl_die(ctx, isl_error_invalid,
259
"model has unnamed parameters", goto error);
260
if (!isl_space_has_named_params(pw->dim))
261
isl_die(ctx, isl_error_invalid,
262
"input has unnamed parameters", goto error);
263
if (!isl_space_match(pw->dim, isl_dim_param, model, isl_dim_param)) {
266
model = isl_space_drop_dims(model, isl_dim_in,
267
0, isl_space_dim(model, isl_dim_in));
268
model = isl_space_drop_dims(model, isl_dim_out,
269
0, isl_space_dim(model, isl_dim_out));
270
exp = isl_parameter_alignment_reordering(pw->dim, model);
271
exp = isl_reordering_extend_space(exp,
272
FN(PW,get_domain_space)(pw));
273
pw = FN(PW,realign_domain)(pw, exp);
276
isl_space_free(model);
279
isl_space_free(model);
284
static __isl_give PW *FN(PW,align_params_pw_pw_and)(__isl_take PW *pw1,
286
__isl_give PW *(*fn)(__isl_take PW *pw1, __isl_take PW *pw2))
292
if (isl_space_match(pw1->dim, isl_dim_param, pw2->dim, isl_dim_param))
294
ctx = FN(PW,get_ctx)(pw1);
295
if (!isl_space_has_named_params(pw1->dim) ||
296
!isl_space_has_named_params(pw2->dim))
297
isl_die(ctx, isl_error_invalid,
298
"unaligned unnamed parameters", goto error);
299
pw1 = FN(PW,align_params)(pw1, FN(PW,get_space)(pw2));
300
pw2 = FN(PW,align_params)(pw2, FN(PW,get_space)(pw1));
308
static __isl_give PW *FN(PW,align_params_pw_set_and)(__isl_take PW *pw,
309
__isl_take isl_set *set,
310
__isl_give PW *(*fn)(__isl_take PW *pw, __isl_take isl_set *set))
316
if (isl_space_match(pw->dim, isl_dim_param, set->dim, isl_dim_param))
318
ctx = FN(PW,get_ctx)(pw);
319
if (!isl_space_has_named_params(pw->dim) ||
320
!isl_space_has_named_params(set->dim))
321
isl_die(ctx, isl_error_invalid,
322
"unaligned unnamed parameters", goto error);
323
pw = FN(PW,align_params)(pw, isl_set_get_space(set));
324
set = isl_set_align_params(set, FN(PW,get_space)(pw));
333
static __isl_give PW *FN(PW,union_add_aligned)(__isl_take PW *pw1,
260
__isl_give PW *FN(PW,add_disjoint)(__isl_take PW *pw1, __isl_take PW *pw2)
410
/* Private version of "union_add". For isl_pw_qpolynomial and
411
* isl_pw_qpolynomial_fold, we prefer to simply call it "add".
413
static __isl_give PW *FN(PW,union_add_)(__isl_take PW *pw1, __isl_take PW *pw2)
415
return FN(PW,align_params_pw_pw_and)(pw1, pw2,
416
&FN(PW,union_add_aligned));
419
/* Make sure "pw" has room for at least "n" more pieces.
421
* If there is only one reference to pw, we extend it in place.
422
* Otherwise, we create a new PW and copy the pieces.
424
static __isl_give PW *FN(PW,grow)(__isl_take PW *pw, int n)
432
if (pw->n + n <= pw->size)
434
ctx = FN(PW,get_ctx)(pw);
437
res = isl_realloc(ctx, pw, struct PW,
438
sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
440
return FN(PW,free)(pw);
445
res = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, n);
447
res = FN(PW,alloc_size)(isl_space_copy(pw->dim), n);
450
return FN(PW,free)(pw);
451
for (i = 0; i < pw->n; ++i)
452
res = FN(PW,add_piece)(res, isl_set_copy(pw->p[i].set),
453
FN(EL,copy)(pw->p[i].FIELD));
458
static __isl_give PW *FN(PW,add_disjoint_aligned)(__isl_take PW *pw1,
266
464
if (!pw1 || !pw2)
269
ctx = isl_dim_get_ctx(pw1->dim);
467
if (pw1->size < pw1->n + pw2->n && pw1->n < pw2->n)
468
return FN(PW,add_disjoint_aligned)(pw2, pw1);
470
ctx = isl_space_get_ctx(pw1->dim);
271
472
if (pw1->type != pw2->type)
272
473
isl_die(ctx, isl_error_invalid,
273
474
"fold types don't match", goto error);
275
isl_assert(ctx, isl_dim_equal(pw1->dim, pw2->dim), goto error);
476
isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
277
478
if (FN(PW,IS_ZERO)(pw1)) {
278
479
FN(PW,free)(pw1);
288
res = FN(PW,alloc_)(isl_dim_copy(pw1->dim), pw1->type, pw1->n + pw2->n);
290
res = FN(PW,alloc_)(isl_dim_copy(pw1->dim), pw1->n + pw2->n);
293
for (i = 0; i < pw1->n; ++i)
294
res = FN(PW,add_piece)(res,
295
isl_set_copy(pw1->p[i].set),
296
FN(EL,copy)(pw1->p[i].FIELD));
488
pw1 = FN(PW,grow)(pw1, pw2->n);
298
492
for (i = 0; i < pw2->n; ++i)
299
res = FN(PW,add_piece)(res,
493
pw1 = FN(PW,add_piece)(pw1,
300
494
isl_set_copy(pw2->p[i].set),
301
495
FN(EL,copy)(pw2->p[i].FIELD));
506
__isl_give PW *FN(PW,add_disjoint)(__isl_take PW *pw1, __isl_take PW *pw2)
508
return FN(PW,align_params_pw_pw_and)(pw1, pw2,
509
&FN(PW,add_disjoint_aligned));
512
/* This function is currently only used from isl_aff.c
514
static __isl_give PW *FN(PW,on_shared_domain)(__isl_take PW *pw1,
516
__isl_give EL *(*fn)(__isl_take EL *el1, __isl_take EL *el2))
517
__attribute__ ((unused));
519
/* Apply "fn" to pairs of elements from pw1 and pw2 on shared domains.
521
static __isl_give PW *FN(PW,on_shared_domain)(__isl_take PW *pw1,
523
__isl_give EL *(*fn)(__isl_take EL *el1, __isl_take EL *el2))
533
res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->type, n);
535
res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), n);
538
for (i = 0; i < pw1->n; ++i) {
539
for (j = 0; j < pw2->n; ++j) {
542
common = isl_set_intersect(
543
isl_set_copy(pw1->p[i].set),
544
isl_set_copy(pw2->p[j].set));
545
if (isl_set_plain_is_empty(common)) {
546
isl_set_free(common);
550
res_ij = fn(FN(EL,copy)(pw1->p[i].FIELD),
551
FN(EL,copy)(pw2->p[j].FIELD));
553
res = FN(PW,add_piece)(res, common, res_ij);
308
561
FN(PW,free)(pw1);
441
__isl_give PW *FN(PW,gist)(__isl_take PW *pw, __isl_take isl_set *context)
703
static __isl_give PW *FN(PW,intersect_domain_aligned)(__isl_take PW *pw,
704
__isl_take isl_set *set)
706
return FN(PW,intersect_aligned)(pw, set, &isl_set_intersect);
709
__isl_give PW *FN(PW,intersect_domain)(__isl_take PW *pw,
710
__isl_take isl_set *context)
712
return FN(PW,align_params_pw_set_and)(pw, context,
713
&FN(PW,intersect_domain_aligned));
716
static __isl_give PW *FN(PW,intersect_params_aligned)(__isl_take PW *pw,
717
__isl_take isl_set *set)
719
return FN(PW,intersect_aligned)(pw, set, &isl_set_intersect_params);
722
/* Intersect the domain of "pw" with the parameter domain "context".
724
__isl_give PW *FN(PW,intersect_params)(__isl_take PW *pw,
725
__isl_take isl_set *context)
727
return FN(PW,align_params_pw_set_and)(pw, context,
728
&FN(PW,intersect_params_aligned));
731
static __isl_give PW *FN(PW,gist_aligned)(__isl_take PW *pw,
732
__isl_take isl_set *context,
733
__isl_give EL *(*fn_el)(__isl_take EL *el,
734
__isl_take isl_set *set),
735
__isl_give isl_set *(*fn_dom)(__isl_take isl_set *set,
736
__isl_take isl_basic_set *bset))
444
739
isl_basic_set *hull = NULL;
792
static __isl_give PW *FN(PW,gist_domain_aligned)(__isl_take PW *pw,
793
__isl_take isl_set *set)
795
return FN(PW,gist_aligned)(pw, set, &FN(EL,gist),
796
&isl_set_gist_basic_set);
799
__isl_give PW *FN(PW,gist)(__isl_take PW *pw, __isl_take isl_set *context)
801
return FN(PW,align_params_pw_set_and)(pw, context,
802
&FN(PW,gist_domain_aligned));
805
static __isl_give PW *FN(PW,gist_params_aligned)(__isl_take PW *pw,
806
__isl_take isl_set *set)
808
return FN(PW,gist_aligned)(pw, set, &FN(EL,gist_params),
809
&isl_set_gist_params_basic_set);
812
__isl_give PW *FN(PW,gist_params)(__isl_take PW *pw,
813
__isl_take isl_set *context)
815
return FN(PW,align_params_pw_set_and)(pw, context,
816
&FN(PW,gist_params_aligned));
492
819
__isl_give PW *FN(PW,coalesce)(__isl_take PW *pw)
534
861
unsigned first, unsigned n)
864
enum isl_dim_type set_type;
540
868
if (pw->n == 0 || n == 0)
871
set_type = type == isl_dim_in ? isl_dim_set : type;
542
873
for (i = 0; i < pw->n; ++i) {
543
874
int involves = FN(EL,involves_dims)(pw->p[i].FIELD,
545
876
if (involves < 0 || involves)
547
involves = isl_set_involves_dims(pw->p[i].set, type, first, n);
878
involves = isl_set_involves_dims(pw->p[i].set,
548
880
if (involves < 0 || involves)
556
888
enum isl_dim_type type, unsigned pos, const char *s)
891
enum isl_dim_type set_type;
560
893
pw = FN(PW,cow)(pw);
564
pw->dim = isl_dim_set_name(pw->dim, type, pos, s);
897
set_type = type == isl_dim_in ? isl_dim_set : type;
899
pw->dim = isl_space_set_dim_name(pw->dim, type, pos, s);
568
903
for (i = 0; i < pw->n; ++i) {
569
pw->p[i].set = isl_set_set_dim_name(pw->p[i].set, type, pos, s);
904
pw->p[i].set = isl_set_set_dim_name(pw->p[i].set,
570
906
if (!pw->p[i].set)
572
908
pw->p[i].FIELD = FN(EL,set_dim_name)(pw->p[i].FIELD, type, pos, s);
585
921
enum isl_dim_type type, unsigned first, unsigned n)
591
if (n == 0 && !isl_dim_get_tuple_name(pw->dim, type))
597
pw->dim = isl_dim_drop(pw->dim, type, first, n);
600
for (i = 0; i < pw->n; ++i) {
601
pw->p[i].set = isl_set_drop(pw->p[i].set, type, first, n);
604
pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
924
enum isl_dim_type set_type;
928
if (n == 0 && !isl_space_get_tuple_name(pw->dim, type))
931
set_type = type == isl_dim_in ? isl_dim_set : type;
936
pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
939
for (i = 0; i < pw->n; ++i) {
940
pw->p[i].set = isl_set_drop(pw->p[i].set, set_type, first, n);
943
pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
954
/* This function is very similar to drop_dims.
955
* The only difference is that the cells may still involve
956
* the specified dimensions. They are removed using
957
* isl_set_project_out instead of isl_set_drop.
959
__isl_give PW *FN(PW,project_out)(__isl_take PW *pw,
960
enum isl_dim_type type, unsigned first, unsigned n)
963
enum isl_dim_type set_type;
967
if (n == 0 && !isl_space_get_tuple_name(pw->dim, type))
970
set_type = type == isl_dim_in ? isl_dim_set : type;
975
pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
978
for (i = 0; i < pw->n; ++i) {
979
pw->p[i].set = isl_set_project_out(pw->p[i].set,
983
pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
994
/* Project the domain of pw onto its parameter space.
996
__isl_give PW *FN(PW,project_domain_on_params)(__isl_take PW *pw)
1001
n = FN(PW,dim)(pw, isl_dim_in);
1002
pw = FN(PW,project_out)(pw, isl_dim_in, 0, n);
1003
space = FN(PW,get_domain_space)(pw);
1004
space = isl_space_params(space);
1005
pw = FN(PW,reset_domain_space)(pw, space);
618
1012
unsigned first, unsigned n)
1015
enum isl_dim_type set_type;
624
if (n == 0 && !isl_dim_is_named_or_nested(pw->dim, type))
1019
if (n == 0 && !isl_space_is_named_or_nested(pw->dim, type))
1022
set_type = type == isl_dim_in ? isl_dim_set : type;
627
1024
pw = FN(PW,cow)(pw);
631
pw->dim = isl_dim_insert(pw->dim, type, first, n);
1028
pw->dim = isl_space_insert_dims(pw->dim, type, first, n);
635
1032
for (i = 0; i < pw->n; ++i) {
636
pw->p[i].set = isl_set_insert(pw->p[i].set, type, first, n);
1033
pw->p[i].set = isl_set_insert_dims(pw->p[i].set,
1034
set_type, first, n);
637
1035
if (!pw->p[i].set)
639
1037
pw->p[i].FIELD = FN(EL,insert_dims)(pw->p[i].FIELD,
754
__isl_give isl_dim *FN(PW,get_dim)(__isl_keep PW *pw)
756
return pw ? isl_dim_copy(pw->dim) : NULL;
1158
__isl_give isl_space *FN(PW,get_space)(__isl_keep PW *pw)
1160
return pw ? isl_space_copy(pw->dim) : NULL;
1163
__isl_give isl_space *FN(PW,get_domain_space)(__isl_keep PW *pw)
1165
return pw ? isl_space_domain(isl_space_copy(pw->dim)) : NULL;
759
1168
#ifndef NO_RESET_DIM
760
__isl_give PW *FN(PW,reset_dim)(__isl_take PW *pw, __isl_take isl_dim *dim)
1169
/* Reset the space of "pw". Since we don't know if the elements
1170
* represent the spaces themselves or their domains, we pass along
1171
* both when we call their reset_space_and_domain.
1173
static __isl_give PW *FN(PW,reset_space_and_domain)(__isl_take PW *pw,
1174
__isl_take isl_space *space, __isl_take isl_space *domain)
764
1178
pw = FN(PW,cow)(pw);
1179
if (!pw || !space || !domain)
768
1182
for (i = 0; i < pw->n; ++i) {
769
pw->p[i].set = isl_set_reset_dim(pw->p[i].set,
1183
pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1184
isl_space_copy(domain));
771
1185
if (!pw->p[i].set)
773
pw->p[i].FIELD = FN(EL,reset_dim)(pw->p[i].FIELD,
1187
pw->p[i].FIELD = FN(EL,reset_space_and_domain)(pw->p[i].FIELD,
1188
isl_space_copy(space), isl_space_copy(domain));
775
1189
if (!pw->p[i].FIELD)
778
isl_dim_free(pw->dim);
1193
isl_space_free(domain);
1195
isl_space_free(pw->dim);
1200
isl_space_free(domain);
1201
isl_space_free(space);
784
1202
FN(PW,free)(pw);
1206
__isl_give PW *FN(PW,reset_domain_space)(__isl_take PW *pw,
1207
__isl_take isl_space *domain)
1211
space = isl_space_extend_domain_with_range(isl_space_copy(domain),
1212
FN(PW,get_space)(pw));
1213
return FN(PW,reset_space_and_domain)(pw, space, domain);
1216
__isl_give PW *FN(PW,reset_space)(__isl_take PW *pw, __isl_take isl_space *dim)
1220
domain = isl_space_domain(isl_space_copy(dim));
1221
return FN(PW,reset_space_and_domain)(pw, dim, domain);
1224
__isl_give PW *FN(PW,set_tuple_id)(__isl_keep PW *pw, enum isl_dim_type type,
1225
__isl_take isl_id *id)
1229
pw = FN(PW,cow)(pw);
1231
return isl_id_free(id);
1233
space = FN(PW,get_space)(pw);
1234
space = isl_space_set_tuple_id(space, type, id);
1236
return FN(PW,reset_space)(pw, space);
1239
__isl_give PW *FN(PW,set_dim_id)(__isl_take PW *pw,
1240
enum isl_dim_type type, unsigned pos, __isl_take isl_id *id)
1242
pw = FN(PW,cow)(pw);
1244
return isl_id_free(id);
1245
pw->dim = isl_space_set_dim_id(pw->dim, type, pos, id);
1246
return FN(PW,reset_space)(pw, isl_space_copy(pw->dim));
789
int FN(PW,has_equal_dim)(__isl_keep PW *pw1, __isl_keep PW *pw2)
1250
int FN(PW,has_equal_space)(__isl_keep PW *pw1, __isl_keep PW *pw2)
791
1252
if (!pw1 || !pw2)
794
return isl_dim_equal(pw1->dim, pw2->dim);
1255
return isl_space_is_equal(pw1->dim, pw2->dim);
797
1258
#ifndef NO_MORPH
798
__isl_give PW *FN(PW,morph)(__isl_take PW *pw, __isl_take isl_morph *morph)
1259
__isl_give PW *FN(PW,morph_domain)(__isl_take PW *pw,
1260
__isl_take isl_morph *morph)
942
pw->dim = isl_dim_move(pw->dim, dst_type, dst_pos, src_type, src_pos, n);
1404
pw->dim = isl_space_move_dims(pw->dim, dst_type, dst_pos, src_type, src_pos, n);
946
1408
for (i = 0; i < pw->n; ++i) {
1409
pw->p[i].FIELD = FN(EL,move_dims)(pw->p[i].FIELD,
1410
dst_type, dst_pos, src_type, src_pos, n);
1411
if (!pw->p[i].FIELD)
1415
if (dst_type == isl_dim_in)
1416
dst_type = isl_dim_set;
1417
if (src_type == isl_dim_in)
1418
src_type = isl_dim_set;
1420
for (i = 0; i < pw->n; ++i) {
947
1421
pw->p[i].set = isl_set_move_dims(pw->p[i].set,
948
1422
dst_type, dst_pos,
949
1423
src_type, src_pos, n);
950
1424
if (!pw->p[i].set)
952
pw->p[i].FIELD = FN(EL,move_dims)(pw->p[i].FIELD,
953
dst_type, dst_pos, src_type, src_pos, n);
966
__isl_give PW *FN(PW,realign)(__isl_take PW *pw, __isl_take isl_reordering *exp)
974
for (i = 0; i < pw->n; ++i) {
975
pw->p[i].set = isl_set_realign(pw->p[i].set,
976
isl_reordering_copy(exp));
979
pw->p[i].FIELD = FN(EL,realign)(pw->p[i].FIELD,
980
isl_reordering_copy(exp));
985
pw = FN(PW,reset_dim)(pw, isl_dim_copy(exp->dim));
987
isl_reordering_free(exp);
990
isl_reordering_free(exp);
995
/* Align the parameters of "pw" to those of "model".
997
__isl_give PW *FN(PW,align_params)(__isl_take PW *pw, __isl_take isl_dim *model)
1004
ctx = isl_dim_get_ctx(model);
1005
if (!isl_dim_has_named_params(model))
1006
isl_die(ctx, isl_error_invalid,
1007
"model has unnamed parameters", goto error);
1008
if (!isl_dim_has_named_params(pw->dim))
1009
isl_die(ctx, isl_error_invalid,
1010
"input has unnamed parameters", goto error);
1011
if (!isl_dim_match(pw->dim, isl_dim_param, model, isl_dim_param)) {
1012
isl_reordering *exp;
1014
model = isl_dim_drop(model, isl_dim_in,
1015
0, isl_dim_size(model, isl_dim_in));
1016
model = isl_dim_drop(model, isl_dim_out,
1017
0, isl_dim_size(model, isl_dim_out));
1018
exp = isl_parameter_alignment_reordering(pw->dim, model);
1019
exp = isl_reordering_extend_dim(exp, FN(PW,get_dim)(pw));
1020
pw = FN(PW,realign)(pw, exp);
1023
isl_dim_free(model);
1026
isl_dim_free(model);
1027
1430
FN(PW,free)(pw);
1073
1476
return FN(PW,mul_isl_int)(pw, v);
1479
static int FN(PW,qsort_set_cmp)(const void *p1, const void *p2)
1481
const isl_set *set1 = *(const isl_set **)p1;
1482
const isl_set *set2 = *(const isl_set **)p2;
1484
return isl_set_plain_cmp(set1, set2);
1487
/* We normalize in place, but if anything goes wrong we need
1488
* to return NULL, so we need to make sure we don't change the
1489
* meaning of any possible other copies of map.
1491
__isl_give PW *FN(PW,normalize)(__isl_take PW *pw)
1498
for (i = 0; i < pw->n; ++i) {
1499
set = isl_set_normalize(isl_set_copy(pw->p[i].set));
1501
return FN(PW,free)(pw);
1502
isl_set_free(pw->p[i].set);
1505
qsort(pw->p, pw->n, sizeof(pw->p[0]), &FN(PW,qsort_set_cmp));
1506
for (i = pw->n - 1; i >= 1; --i) {
1507
if (!isl_set_plain_is_equal(pw->p[i - 1].set, pw->p[i].set))
1509
if (!FN(EL,plain_is_equal)(pw->p[i - 1].FIELD, pw->p[i].FIELD))
1511
set = isl_set_union(isl_set_copy(pw->p[i - 1].set),
1512
isl_set_copy(pw->p[i].set));
1514
return FN(PW,free)(pw);
1515
isl_set_free(pw->p[i].set);
1516
FN(EL,free)(pw->p[i].FIELD);
1517
isl_set_free(pw->p[i - 1].set);
1518
pw->p[i - 1].set = set;
1519
for (j = i + 1; j < pw->n; ++j)
1520
pw->p[j - 1] = pw->p[j];
1527
/* Is pw1 obviously equal to pw2?
1528
* That is, do they have obviously identical cells and obviously identical
1529
* elements on each cell?
1531
int FN(PW,plain_is_equal)(__isl_keep PW *pw1, __isl_keep PW *pw2)
1541
if (!isl_space_is_equal(pw1->dim, pw2->dim))
1544
pw1 = FN(PW,copy)(pw1);
1545
pw2 = FN(PW,copy)(pw2);
1546
pw1 = FN(PW,normalize)(pw1);
1547
pw2 = FN(PW,normalize)(pw2);
1551
equal = pw1->n == pw2->n;
1552
for (i = 0; equal && i < pw1->n; ++i) {
1553
equal = isl_set_plain_is_equal(pw1->p[i].set, pw2->p[i].set);
1558
equal = FN(EL,plain_is_equal)(pw1->p[i].FIELD, pw2->p[i].FIELD);