Coverage Report

Created: 2017-04-27 19:33

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/polly/lib/External/isl/isl_pw_union_opt.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2011      INRIA Saclay
3
 * Copyright 2012      Ecole Normale Superieure
4
 *
5
 * Use of this software is governed by the MIT license
6
 *
7
 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
8
 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
9
 * 91893 Orsay, France
10
 * and Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
11
 */
12
13
#include <isl_pw_macro.h>
14
15
/* Given a function "cmp" that returns the set of elements where
16
 * "el1" is "better" than "el2", return this set.
17
 */
18
static __isl_give isl_set *FN(PW,better)(__isl_keep EL *el1, __isl_keep EL *el2,
19
  __isl_give isl_set *(*cmp)(__isl_take EL *el1, __isl_take EL *el2))
20
750
{
21
750
  return cmp(
FN750
(EL,copy)(el1),
FN750
(EL,copy)(el2));
22
750
}
isl_aff.c:isl_pw_aff_better
Line
Count
Source
20
79
{
21
79
  return cmp(
FN79
(EL,copy)(el1),
FN79
(EL,copy)(el2));
22
79
}
isl_aff.c:isl_pw_multi_aff_better
Line
Count
Source
20
671
{
21
671
  return cmp(
FN671
(EL,copy)(el1),
FN671
(EL,copy)(el2));
22
671
}
23
24
/* Return a list containing the domains of the pieces of "pw".
25
 */
26
static __isl_give isl_set_list *FN(PW,extract_domains)(__isl_keep PW *pw)
27
1.37k
{
28
1.37k
  int i;
29
1.37k
  isl_ctx *ctx;
30
1.37k
  isl_set_list *list;
31
1.37k
32
1.37k
  if (!pw)
33
0
    return NULL;
34
1.37k
  
ctx = 1.37k
FN1.37k
(PW,get_ctx)(pw);
35
1.37k
  list = isl_set_list_alloc(ctx, pw->n);
36
3.33k
  for (i = 0; 
i < pw->n3.33k
;
++i1.95k
)
37
1.95k
    list = isl_set_list_add(list, isl_set_copy(pw->p[i].set));
38
1.37k
39
1.37k
  return list;
40
1.37k
}
isl_aff.c:isl_pw_aff_extract_domains
Line
Count
Source
27
150
{
28
150
  int i;
29
150
  isl_ctx *ctx;
30
150
  isl_set_list *list;
31
150
32
150
  if (!pw)
33
0
    return NULL;
34
150
  
ctx = 150
FN150
(PW,get_ctx)(pw);
35
150
  list = isl_set_list_alloc(ctx, pw->n);
36
312
  for (i = 0; 
i < pw->n312
;
++i162
)
37
162
    list = isl_set_list_add(list, isl_set_copy(pw->p[i].set));
38
150
39
150
  return list;
40
150
}
isl_aff.c:isl_pw_multi_aff_extract_domains
Line
Count
Source
27
1.22k
{
28
1.22k
  int i;
29
1.22k
  isl_ctx *ctx;
30
1.22k
  isl_set_list *list;
31
1.22k
32
1.22k
  if (!pw)
33
0
    return NULL;
34
1.22k
  
ctx = 1.22k
FN1.22k
(PW,get_ctx)(pw);
35
1.22k
  list = isl_set_list_alloc(ctx, pw->n);
36
3.02k
  for (i = 0; 
i < pw->n3.02k
;
++i1.79k
)
37
1.79k
    list = isl_set_list_add(list, isl_set_copy(pw->p[i].set));
38
1.22k
39
1.22k
  return list;
40
1.22k
}
41
42
/* Given sets B ("set"), C ("better") and A' ("out"), return
43
 *
44
 *  (B \cap C) \cup ((B \setminus C) \setminus A')
45
 */
46
static __isl_give isl_set *FN(PW,better_or_out)(__isl_take isl_set *set,
47
  __isl_take isl_set *better, __isl_take isl_set *out)
48
750
{
49
750
  isl_set *set_better, *set_out;
50
750
51
750
  set_better = isl_set_intersect(isl_set_copy(set), isl_set_copy(better));
52
750
  set_out = isl_set_subtract(isl_set_subtract(set, better), out);
53
750
54
750
  return isl_set_union(set_better, set_out);
55
750
}
isl_aff.c:isl_pw_multi_aff_better_or_out
Line
Count
Source
48
671
{
49
671
  isl_set *set_better, *set_out;
50
671
51
671
  set_better = isl_set_intersect(isl_set_copy(set), isl_set_copy(better));
52
671
  set_out = isl_set_subtract(isl_set_subtract(set, better), out);
53
671
54
671
  return isl_set_union(set_better, set_out);
55
671
}
isl_aff.c:isl_pw_aff_better_or_out
Line
Count
Source
48
79
{
49
79
  isl_set *set_better, *set_out;
50
79
51
79
  set_better = isl_set_intersect(isl_set_copy(set), isl_set_copy(better));
52
79
  set_out = isl_set_subtract(isl_set_subtract(set, better), out);
53
79
54
79
  return isl_set_union(set_better, set_out);
55
79
}
56
57
/* Given sets A ("set"), C ("better") and B' ("out"), return
58
 *
59
 *  (A \setminus C) \cup ((A \cap C) \setminus B')
60
 */
61
static __isl_give isl_set *FN(PW,worse_or_out)(__isl_take isl_set *set,
62
  __isl_take isl_set *better, __isl_take isl_set *out)
63
750
{
64
750
  isl_set *set_worse, *set_out;
65
750
66
750
  set_worse = isl_set_subtract(isl_set_copy(set), isl_set_copy(better));
67
750
  set_out = isl_set_subtract(isl_set_intersect(set, better), out);
68
750
69
750
  return isl_set_union(set_worse, set_out);
70
750
}
isl_aff.c:isl_pw_aff_worse_or_out
Line
Count
Source
63
79
{
64
79
  isl_set *set_worse, *set_out;
65
79
66
79
  set_worse = isl_set_subtract(isl_set_copy(set), isl_set_copy(better));
67
79
  set_out = isl_set_subtract(isl_set_intersect(set, better), out);
68
79
69
79
  return isl_set_union(set_worse, set_out);
70
79
}
isl_aff.c:isl_pw_multi_aff_worse_or_out
Line
Count
Source
63
671
{
64
671
  isl_set *set_worse, *set_out;
65
671
66
671
  set_worse = isl_set_subtract(isl_set_copy(set), isl_set_copy(better));
67
671
  set_out = isl_set_subtract(isl_set_intersect(set, better), out);
68
671
69
671
  return isl_set_union(set_worse, set_out);
70
671
}
71
72
/* Given two piecewise expressions "pw1" and "pw2", replace their domains
73
 * by the sets in "list1" and "list2" and combine the results into
74
 * a single piecewise expression.
75
 * The pieces of "pw1" and "pw2" are assumed to have been sorted
76
 * according to the function value expressions.
77
 * The pieces of the result are also sorted in this way.
78
 *
79
 * Run through the pieces of "pw1" and "pw2" in order until they
80
 * have both been exhausted, picking the piece from "pw1" or "pw2"
81
 * depending on which should come first, together with the corresponding
82
 * domain from "list1" or "list2".  In cases where the next pieces
83
 * in both "pw1" and "pw2" have the same function value expression,
84
 * construct only a single piece in the result with as domain
85
 * the union of the domains in "list1" and "list2".
86
 */
87
static __isl_give PW *FN(PW,merge)(__isl_take PW *pw1, __isl_take PW *pw2,
88
  __isl_take isl_set_list *list1, __isl_take isl_set_list *list2)
89
689
{
90
689
  int i, j;
91
689
  PW *res;
92
689
93
689
  if (
!pw1 || 689
!pw2689
)
94
0
    goto error;
95
689
96
689
  
res = 689
FN689
(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->n + pw2->n);
97
689
98
689
  i = 0; j = 0;
99
2.35k
  while (
i < pw1->n || 2.35k
j < pw2->n932
)
{1.66k
100
1.66k
    int cmp;
101
1.66k
    isl_set *set;
102
1.66k
    EL *el;
103
1.66k
104
1.66k
    if (
i < pw1->n && 1.66k
j < pw2->n1.42k
)
105
1.04k
      
cmp = 1.04k
FN1.04k
(EL,plain_cmp)(pw1->p[i].
FIELD1.04k
,
106
1.04k
            pw2->p[j].FIELD);
107
1.66k
    else
108
621
      
cmp = i < pw1->n ? 621
-1378
:
1243
;
109
1.66k
110
1.66k
    if (
cmp < 01.66k
)
{934
111
934
      set = isl_set_list_get_set(list1, i);
112
934
      el = 
FN934
(EL,copy)(pw1->p[i].
FIELD934
);
113
934
      ++i;
114
731
    } else 
if (731
cmp > 0731
)
{442
115
442
      set = isl_set_list_get_set(list2, j);
116
442
      el = 
FN442
(EL,copy)(pw2->p[j].
FIELD442
);
117
442
      ++j;
118
289
    } else {
119
289
      set = isl_set_union(isl_set_list_get_set(list1, i),
120
289
              isl_set_list_get_set(list2, j));
121
289
      el = 
FN289
(EL,copy)(pw1->p[i].
FIELD289
);
122
289
      ++i;
123
289
      ++j;
124
289
    }
125
1.66k
    res = FN(PW,add_piece)(res, set, el);
126
1.66k
  }
127
689
128
689
  isl_set_list_free(list1);
129
689
  isl_set_list_free(list2);
130
689
  FN(PW,free)(pw1);
131
689
  FN(PW,free)(pw2);
132
689
  return res;
133
0
error:
134
0
  isl_set_list_free(list1);
135
0
  isl_set_list_free(list2);
136
0
  FN(PW,free)(pw1);
137
0
  FN(PW,free)(pw2);
138
0
  return NULL;
139
689
}
isl_aff.c:isl_pw_aff_merge
Line
Count
Source
89
75
{
90
75
  int i, j;
91
75
  PW *res;
92
75
93
75
  if (
!pw1 || 75
!pw275
)
94
0
    goto error;
95
75
96
75
  
res = 75
FN75
(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->n + pw2->n);
97
75
98
75
  i = 0; j = 0;
99
234
  while (
i < pw1->n || 234
j < pw2->n109
)
{159
100
159
    int cmp;
101
159
    isl_set *set;
102
159
    EL *el;
103
159
104
159
    if (
i < pw1->n && 159
j < pw2->n125
)
105
83
      
cmp = 83
FN83
(EL,plain_cmp)(pw1->p[i].
FIELD83
,
106
83
            pw2->p[j].FIELD);
107
159
    else
108
76
      
cmp = i < pw1->n ? 76
-142
:
134
;
109
159
110
159
    if (
cmp < 0159
)
{84
111
84
      set = isl_set_list_get_set(list1, i);
112
84
      el = 
FN84
(EL,copy)(pw1->p[i].
FIELD84
);
113
84
      ++i;
114
75
    } else 
if (75
cmp > 075
)
{72
115
72
      set = isl_set_list_get_set(list2, j);
116
72
      el = 
FN72
(EL,copy)(pw2->p[j].
FIELD72
);
117
72
      ++j;
118
3
    } else {
119
3
      set = isl_set_union(isl_set_list_get_set(list1, i),
120
3
              isl_set_list_get_set(list2, j));
121
3
      el = 
FN3
(EL,copy)(pw1->p[i].
FIELD3
);
122
3
      ++i;
123
3
      ++j;
124
3
    }
125
159
    res = FN(PW,add_piece)(res, set, el);
126
159
  }
127
75
128
75
  isl_set_list_free(list1);
129
75
  isl_set_list_free(list2);
130
75
  FN(PW,free)(pw1);
131
75
  FN(PW,free)(pw2);
132
75
  return res;
133
0
error:
134
0
  isl_set_list_free(list1);
135
0
  isl_set_list_free(list2);
136
0
  FN(PW,free)(pw1);
137
0
  FN(PW,free)(pw2);
138
0
  return NULL;
139
75
}
isl_aff.c:isl_pw_multi_aff_merge
Line
Count
Source
89
614
{
90
614
  int i, j;
91
614
  PW *res;
92
614
93
614
  if (
!pw1 || 614
!pw2614
)
94
0
    goto error;
95
614
96
614
  
res = 614
FN614
(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->n + pw2->n);
97
614
98
614
  i = 0; j = 0;
99
2.12k
  while (
i < pw1->n || 2.12k
j < pw2->n823
)
{1.50k
100
1.50k
    int cmp;
101
1.50k
    isl_set *set;
102
1.50k
    EL *el;
103
1.50k
104
1.50k
    if (
i < pw1->n && 1.50k
j < pw2->n1.29k
)
105
961
      
cmp = 961
FN961
(EL,plain_cmp)(pw1->p[i].
FIELD961
,
106
961
            pw2->p[j].FIELD);
107
1.50k
    else
108
545
      
cmp = i < pw1->n ? 545
-1336
:
1209
;
109
1.50k
110
1.50k
    if (
cmp < 01.50k
)
{850
111
850
      set = isl_set_list_get_set(list1, i);
112
850
      el = 
FN850
(EL,copy)(pw1->p[i].
FIELD850
);
113
850
      ++i;
114
656
    } else 
if (656
cmp > 0656
)
{370
115
370
      set = isl_set_list_get_set(list2, j);
116
370
      el = 
FN370
(EL,copy)(pw2->p[j].
FIELD370
);
117
370
      ++j;
118
286
    } else {
119
286
      set = isl_set_union(isl_set_list_get_set(list1, i),
120
286
              isl_set_list_get_set(list2, j));
121
286
      el = 
FN286
(EL,copy)(pw1->p[i].
FIELD286
);
122
286
      ++i;
123
286
      ++j;
124
286
    }
125
1.50k
    res = FN(PW,add_piece)(res, set, el);
126
1.50k
  }
127
614
128
614
  isl_set_list_free(list1);
129
614
  isl_set_list_free(list2);
130
614
  FN(PW,free)(pw1);
131
614
  FN(PW,free)(pw2);
132
614
  return res;
133
0
error:
134
0
  isl_set_list_free(list1);
135
0
  isl_set_list_free(list2);
136
0
  FN(PW,free)(pw1);
137
0
  FN(PW,free)(pw2);
138
0
  return NULL;
139
614
}
140
141
/* Given a function "cmp" that returns the set of elements where
142
 * "el1" is "better" than "el2", return a piecewise
143
 * expression defined on the union of the definition domains
144
 * of "pw1" and "pw2" that maps to the "best" of "pw1" and
145
 * "pw2" on each cell.  If only one of the two input functions
146
 * is defined on a given cell, then it is considered the best.
147
 *
148
 * Run through all pairs of pieces in "pw1" and "pw2".
149
 * If the domains of these pieces intersect, then the intersection
150
 * needs to be distributed over the two pieces based on "cmp".
151
 * Let C be the set where the piece from "pw2" is better (according to "cmp")
152
 * than the piece from "pw1".  Let A be the domain of the piece from "pw1" and
153
 * B the domain of the piece from "pw2".
154
 *
155
 * The elements in C need to be removed from A, except for those parts
156
 * that lie outside of B.  That is,
157
 *
158
 *  A <- (A \setminus C) \cup ((A \cap C) \setminus B')
159
 *
160
 * Conversely, the elements in B need to be restricted to C, except
161
 * for those parts that lie outside of A.  That is
162
 *
163
 *  B <- (B \cap C) \cup ((B \setminus C) \setminus A')
164
 *
165
 * Since all pairs of pieces are considered, the domains are updated
166
 * several times.  A and B refer to these updated domains
167
 * (kept track of in "list1" and "list2"), while A' and B' refer
168
 * to the original domains of the pieces.  It is safe to use these
169
 * original domains because the difference between, say, A' and A is
170
 * the domains of pw2-pieces that have been removed before and
171
 * those domains are disjoint from B.  A' is used instead of A
172
 * because the continued updating of A may result in this domain
173
 * getting broken up into more disjuncts.
174
 *
175
 * After the updated domains have been computed, the result is constructed
176
 * from "pw1", "pw2", "list1" and "list2".  If there are any pieces
177
 * in "pw1" and "pw2" with the same function value expression, then
178
 * they are combined into a single piece in the result.
179
 * In order to be able to do this efficiently, the pieces of "pw1" and
180
 * "pw2" are first sorted according to their function value expressions.
181
 */
182
static __isl_give PW *FN(PW,union_opt_cmp)(
183
  __isl_take PW *pw1, __isl_take PW *pw2,
184
  __isl_give isl_set *(*cmp)(__isl_take EL *el1, __isl_take EL *el2))
185
936
{
186
936
  int i, j;
187
936
  PW *res = NULL;
188
936
  isl_ctx *ctx;
189
936
  isl_set *set = NULL;
190
936
  isl_set_list *list1 = NULL, *list2 = NULL;
191
936
192
936
  if (
!pw1 || 936
!pw2936
)
193
0
    goto error;
194
936
195
936
  ctx = isl_space_get_ctx(pw1->dim);
196
936
  if (!isl_space_is_equal(pw1->dim, pw2->dim))
197
0
    isl_die(ctx, isl_error_invalid,
198
936
      "arguments should live in the same space", goto error);
199
936
200
936
  
if (936
FN936
(PW,is_empty)(pw1)936
)
{244
201
244
    FN(PW,free)(pw1);
202
244
    return pw2;
203
244
  }
204
936
205
692
  
if (692
FN692
(PW,is_empty)(pw2)692
)
{3
206
3
    FN(PW,free)(pw2);
207
3
    return pw1;
208
3
  }
209
692
210
689
  
pw1 = 689
FN689
(PW,sort)(pw1);
211
689
  pw2 = FN(PW,sort)(pw2);
212
689
  if (
!pw1 || 689
!pw2689
)
213
0
    goto error;
214
689
215
689
  
list1 = 689
FN689
(PW,extract_domains)(pw1);
216
689
  list2 = FN(PW,extract_domains)(pw2);
217
689
218
1.91k
  for (i = 0; 
i < pw1->n1.91k
;
++i1.22k
)
{1.22k
219
2.80k
    for (j = 0; 
j < pw2->n2.80k
;
++j1.58k
)
{1.58k
220
1.58k
      isl_bool disjoint;
221
1.58k
      isl_set *better, *set_i, *set_j;
222
1.58k
223
1.58k
      disjoint = isl_set_is_disjoint(pw1->p[i].set,
224
1.58k
              pw2->p[j].set);
225
1.58k
      if (disjoint < 0)
226
0
        goto error;
227
1.58k
      
if (1.58k
disjoint1.58k
)
228
833
        continue;
229
750
      
better = 750
FN750
(PW,better)(pw2->p[j].
FIELD750
,
230
750
            pw1->p[i].FIELD, cmp);
231
750
      set_i = isl_set_list_get_set(list1, i);
232
750
      set_j = isl_set_copy(pw2->p[j].set);
233
750
      set_i = FN(PW,worse_or_out)(set_i,
234
750
            isl_set_copy(better), set_j);
235
750
      list1 = isl_set_list_set_set(list1, i, set_i);
236
750
      set_i = isl_set_copy(pw1->p[i].set);
237
750
      set_j = isl_set_list_get_set(list2, j);
238
750
      set_j = FN(PW,better_or_out)(set_j, better, set_i);
239
750
      list2 = isl_set_list_set_set(list2, j, set_j);
240
750
    }
241
1.22k
  }
242
689
243
689
  
res = 689
FN689
(PW,merge)(pw1, pw2, list1, list2);
244
689
245
689
  return res;
246
0
error:
247
0
  isl_set_list_free(list1);
248
0
  isl_set_list_free(list2);
249
0
  FN(PW,free)(pw1);
250
0
  FN(PW,free)(pw2);
251
0
  isl_set_free(set);
252
0
  return FN(PW,free)(res);
253
689
}
isl_aff.c:isl_pw_aff_union_opt_cmp
Line
Count
Source
185
75
{
186
75
  int i, j;
187
75
  PW *res = NULL;
188
75
  isl_ctx *ctx;
189
75
  isl_set *set = NULL;
190
75
  isl_set_list *list1 = NULL, *list2 = NULL;
191
75
192
75
  if (
!pw1 || 75
!pw275
)
193
0
    goto error;
194
75
195
75
  ctx = isl_space_get_ctx(pw1->dim);
196
75
  if (!isl_space_is_equal(pw1->dim, pw2->dim))
197
0
    isl_die(ctx, isl_error_invalid,
198
75
      "arguments should live in the same space", goto error);
199
75
200
75
  
if (75
FN75
(PW,is_empty)(pw1)75
)
{0
201
0
    FN(PW,free)(pw1);
202
0
    return pw2;
203
0
  }
204
75
205
75
  
if (75
FN75
(PW,is_empty)(pw2)75
)
{0
206
0
    FN(PW,free)(pw2);
207
0
    return pw1;
208
0
  }
209
75
210
75
  
pw1 = 75
FN75
(PW,sort)(pw1);
211
75
  pw2 = FN(PW,sort)(pw2);
212
75
  if (
!pw1 || 75
!pw275
)
213
0
    goto error;
214
75
215
75
  
list1 = 75
FN75
(PW,extract_domains)(pw1);
216
75
  list2 = FN(PW,extract_domains)(pw2);
217
75
218
162
  for (i = 0; 
i < pw1->n162
;
++i87
)
{87
219
174
    for (j = 0; 
j < pw2->n174
;
++j87
)
{87
220
87
      isl_bool disjoint;
221
87
      isl_set *better, *set_i, *set_j;
222
87
223
87
      disjoint = isl_set_is_disjoint(pw1->p[i].set,
224
87
              pw2->p[j].set);
225
87
      if (disjoint < 0)
226
0
        goto error;
227
87
      
if (87
disjoint87
)
228
8
        continue;
229
79
      
better = 79
FN79
(PW,better)(pw2->p[j].
FIELD79
,
230
79
            pw1->p[i].FIELD, cmp);
231
79
      set_i = isl_set_list_get_set(list1, i);
232
79
      set_j = isl_set_copy(pw2->p[j].set);
233
79
      set_i = FN(PW,worse_or_out)(set_i,
234
79
            isl_set_copy(better), set_j);
235
79
      list1 = isl_set_list_set_set(list1, i, set_i);
236
79
      set_i = isl_set_copy(pw1->p[i].set);
237
79
      set_j = isl_set_list_get_set(list2, j);
238
79
      set_j = FN(PW,better_or_out)(set_j, better, set_i);
239
79
      list2 = isl_set_list_set_set(list2, j, set_j);
240
79
    }
241
87
  }
242
75
243
75
  
res = 75
FN75
(PW,merge)(pw1, pw2, list1, list2);
244
75
245
75
  return res;
246
0
error:
247
0
  isl_set_list_free(list1);
248
0
  isl_set_list_free(list2);
249
0
  FN(PW,free)(pw1);
250
0
  FN(PW,free)(pw2);
251
0
  isl_set_free(set);
252
0
  return FN(PW,free)(res);
253
75
}
isl_aff.c:isl_pw_multi_aff_union_opt_cmp
Line
Count
Source
185
861
{
186
861
  int i, j;
187
861
  PW *res = NULL;
188
861
  isl_ctx *ctx;
189
861
  isl_set *set = NULL;
190
861
  isl_set_list *list1 = NULL, *list2 = NULL;
191
861
192
861
  if (
!pw1 || 861
!pw2861
)
193
0
    goto error;
194
861
195
861
  ctx = isl_space_get_ctx(pw1->dim);
196
861
  if (!isl_space_is_equal(pw1->dim, pw2->dim))
197
0
    isl_die(ctx, isl_error_invalid,
198
861
      "arguments should live in the same space", goto error);
199
861
200
861
  
if (861
FN861
(PW,is_empty)(pw1)861
)
{244
201
244
    FN(PW,free)(pw1);
202
244
    return pw2;
203
244
  }
204
861
205
617
  
if (617
FN617
(PW,is_empty)(pw2)617
)
{3
206
3
    FN(PW,free)(pw2);
207
3
    return pw1;
208
3
  }
209
617
210
614
  
pw1 = 614
FN614
(PW,sort)(pw1);
211
614
  pw2 = FN(PW,sort)(pw2);
212
614
  if (
!pw1 || 614
!pw2614
)
213
0
    goto error;
214
614
215
614
  
list1 = 614
FN614
(PW,extract_domains)(pw1);
216
614
  list2 = FN(PW,extract_domains)(pw2);
217
614
218
1.75k
  for (i = 0; 
i < pw1->n1.75k
;
++i1.13k
)
{1.13k
219
2.63k
    for (j = 0; 
j < pw2->n2.63k
;
++j1.49k
)
{1.49k
220
1.49k
      isl_bool disjoint;
221
1.49k
      isl_set *better, *set_i, *set_j;
222
1.49k
223
1.49k
      disjoint = isl_set_is_disjoint(pw1->p[i].set,
224
1.49k
              pw2->p[j].set);
225
1.49k
      if (disjoint < 0)
226
0
        goto error;
227
1.49k
      
if (1.49k
disjoint1.49k
)
228
825
        continue;
229
671
      
better = 671
FN671
(PW,better)(pw2->p[j].
FIELD671
,
230
671
            pw1->p[i].FIELD, cmp);
231
671
      set_i = isl_set_list_get_set(list1, i);
232
671
      set_j = isl_set_copy(pw2->p[j].set);
233
671
      set_i = FN(PW,worse_or_out)(set_i,
234
671
            isl_set_copy(better), set_j);
235
671
      list1 = isl_set_list_set_set(list1, i, set_i);
236
671
      set_i = isl_set_copy(pw1->p[i].set);
237
671
      set_j = isl_set_list_get_set(list2, j);
238
671
      set_j = FN(PW,better_or_out)(set_j, better, set_i);
239
671
      list2 = isl_set_list_set_set(list2, j, set_j);
240
671
    }
241
1.13k
  }
242
614
243
614
  
res = 614
FN614
(PW,merge)(pw1, pw2, list1, list2);
244
614
245
614
  return res;
246
0
error:
247
0
  isl_set_list_free(list1);
248
0
  isl_set_list_free(list2);
249
0
  FN(PW,free)(pw1);
250
0
  FN(PW,free)(pw2);
251
0
  isl_set_free(set);
252
0
  return FN(PW,free)(res);
253
614
}