Coverage Report

Created: 2017-11-23 03:11

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/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
1.65k
{
21
1.65k
  return cmp(FN(EL,copy)(el1), FN(EL,copy)(el2));
22
1.65k
}
isl_aff.c:isl_pw_aff_better
Line
Count
Source
20
368
{
21
368
  return cmp(FN(EL,copy)(el1), FN(EL,copy)(el2));
22
368
}
isl_aff.c:isl_pw_multi_aff_better
Line
Count
Source
20
1.28k
{
21
1.28k
  return cmp(FN(EL,copy)(el1), FN(EL,copy)(el2));
22
1.28k
}
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
3.41k
{
28
3.41k
  int i;
29
3.41k
  isl_ctx *ctx;
30
3.41k
  isl_set_list *list;
31
3.41k
32
3.41k
  if (!pw)
33
0
    return NULL;
34
3.41k
  ctx = FN(PW,get_ctx)(pw);
35
3.41k
  list = isl_set_list_alloc(ctx, pw->n);
36
8.13k
  for (i = 0; i < pw->n; 
++i4.72k
)
37
4.72k
    list = isl_set_list_add(list, isl_set_copy(pw->p[i].set));
38
3.41k
39
3.41k
  return list;
40
3.41k
}
isl_aff.c:isl_pw_aff_extract_domains
Line
Count
Source
27
718
{
28
718
  int i;
29
718
  isl_ctx *ctx;
30
718
  isl_set_list *list;
31
718
32
718
  if (!pw)
33
0
    return NULL;
34
718
  ctx = FN(PW,get_ctx)(pw);
35
718
  list = isl_set_list_alloc(ctx, pw->n);
36
1.47k
  for (i = 0; i < pw->n; 
++i757
)
37
757
    list = isl_set_list_add(list, isl_set_copy(pw->p[i].set));
38
718
39
718
  return list;
40
718
}
isl_aff.c:isl_pw_multi_aff_extract_domains
Line
Count
Source
27
2.69k
{
28
2.69k
  int i;
29
2.69k
  isl_ctx *ctx;
30
2.69k
  isl_set_list *list;
31
2.69k
32
2.69k
  if (!pw)
33
0
    return NULL;
34
2.69k
  ctx = FN(PW,get_ctx)(pw);
35
2.69k
  list = isl_set_list_alloc(ctx, pw->n);
36
6.66k
  for (i = 0; i < pw->n; 
++i3.97k
)
37
3.97k
    list = isl_set_list_add(list, isl_set_copy(pw->p[i].set));
38
2.69k
39
2.69k
  return list;
40
2.69k
}
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
1.65k
{
49
1.65k
  isl_set *set_better, *set_out;
50
1.65k
51
1.65k
  set_better = isl_set_intersect(isl_set_copy(set), isl_set_copy(better));
52
1.65k
  set_out = isl_set_subtract(isl_set_subtract(set, better), out);
53
1.65k
54
1.65k
  return isl_set_union(set_better, set_out);
55
1.65k
}
isl_aff.c:isl_pw_aff_better_or_out
Line
Count
Source
48
368
{
49
368
  isl_set *set_better, *set_out;
50
368
51
368
  set_better = isl_set_intersect(isl_set_copy(set), isl_set_copy(better));
52
368
  set_out = isl_set_subtract(isl_set_subtract(set, better), out);
53
368
54
368
  return isl_set_union(set_better, set_out);
55
368
}
isl_aff.c:isl_pw_multi_aff_better_or_out
Line
Count
Source
48
1.28k
{
49
1.28k
  isl_set *set_better, *set_out;
50
1.28k
51
1.28k
  set_better = isl_set_intersect(isl_set_copy(set), isl_set_copy(better));
52
1.28k
  set_out = isl_set_subtract(isl_set_subtract(set, better), out);
53
1.28k
54
1.28k
  return isl_set_union(set_better, set_out);
55
1.28k
}
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
1.65k
{
64
1.65k
  isl_set *set_worse, *set_out;
65
1.65k
66
1.65k
  set_worse = isl_set_subtract(isl_set_copy(set), isl_set_copy(better));
67
1.65k
  set_out = isl_set_subtract(isl_set_intersect(set, better), out);
68
1.65k
69
1.65k
  return isl_set_union(set_worse, set_out);
70
1.65k
}
isl_aff.c:isl_pw_aff_worse_or_out
Line
Count
Source
63
368
{
64
368
  isl_set *set_worse, *set_out;
65
368
66
368
  set_worse = isl_set_subtract(isl_set_copy(set), isl_set_copy(better));
67
368
  set_out = isl_set_subtract(isl_set_intersect(set, better), out);
68
368
69
368
  return isl_set_union(set_worse, set_out);
70
368
}
isl_aff.c:isl_pw_multi_aff_worse_or_out
Line
Count
Source
63
1.28k
{
64
1.28k
  isl_set *set_worse, *set_out;
65
1.28k
66
1.28k
  set_worse = isl_set_subtract(isl_set_copy(set), isl_set_copy(better));
67
1.28k
  set_out = isl_set_subtract(isl_set_intersect(set, better), out);
68
1.28k
69
1.28k
  return isl_set_union(set_worse, set_out);
70
1.28k
}
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
1.70k
{
90
1.70k
  int i, j;
91
1.70k
  PW *res;
92
1.70k
93
1.70k
  if (!pw1 || !pw2)
94
0
    goto error;
95
1.70k
96
1.70k
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->n + pw2->n);
97
1.70k
98
1.70k
  i = 0; j = 0;
99
5.83k
  while (i < pw1->n || 
j < pw2->n2.43k
) {
100
4.12k
    int cmp;
101
4.12k
    isl_set *set;
102
4.12k
    EL *el;
103
4.12k
104
4.12k
    if (i < pw1->n && 
j < pw2->n3.40k
)
105
2.56k
      cmp = FN(EL,plain_cmp)(pw1->p[i].FIELD,
106
2.56k
            pw2->p[j].FIELD);
107
1.56k
    else
108
1.56k
      cmp = i < pw1->n ? 
-1839
:
1726
;
109
4.12k
110
4.12k
    if (cmp < 0) {
111
2.32k
      set = isl_set_list_get_set(list1, i);
112
2.32k
      el = FN(EL,copy)(pw1->p[i].FIELD);
113
2.32k
      ++i;
114
2.32k
    } else 
if (1.80k
cmp > 01.80k
) {
115
1.20k
      set = isl_set_list_get_set(list2, j);
116
1.20k
      el = FN(EL,copy)(pw2->p[j].FIELD);
117
1.20k
      ++j;
118
1.20k
    } else {
119
601
      set = isl_set_union(isl_set_list_get_set(list1, i),
120
601
              isl_set_list_get_set(list2, j));
121
601
      el = FN(EL,copy)(pw1->p[i].FIELD);
122
1.80k
      ++i;
123
1.80k
      ++j;
124
1.80k
    }
125
4.12k
    res = FN(PW,add_piece)(res, set, el);
126
4.12k
  }
127
1.70k
128
1.70k
  isl_set_list_free(list1);
129
1.70k
  isl_set_list_free(list2);
130
1.70k
  FN(PW,free)(pw1);
131
1.70k
  FN(PW,free)(pw2);
132
1.70k
  return res;
133
1.70k
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
1.70k
}
isl_aff.c:isl_pw_aff_merge
Line
Count
Source
89
359
{
90
359
  int i, j;
91
359
  PW *res;
92
359
93
359
  if (!pw1 || !pw2)
94
0
    goto error;
95
359
96
359
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->n + pw2->n);
97
359
98
359
  i = 0; j = 0;
99
1.10k
  while (i < pw1->n || 
j < pw2->n539
) {
100
743
    int cmp;
101
743
    isl_set *set;
102
743
    EL *el;
103
743
104
743
    if (i < pw1->n && 
j < pw2->n563
)
105
387
      cmp = FN(EL,plain_cmp)(pw1->p[i].FIELD,
106
387
            pw2->p[j].FIELD);
107
356
    else
108
356
      cmp = i < pw1->n ? 
-1176
:
1180
;
109
743
110
743
    if (cmp < 0) {
111
384
      set = isl_set_list_get_set(list1, i);
112
384
      el = FN(EL,copy)(pw1->p[i].FIELD);
113
384
      ++i;
114
384
    } else 
if (359
cmp > 0359
) {
115
345
      set = isl_set_list_get_set(list2, j);
116
345
      el = FN(EL,copy)(pw2->p[j].FIELD);
117
345
      ++j;
118
345
    } else {
119
14
      set = isl_set_union(isl_set_list_get_set(list1, i),
120
14
              isl_set_list_get_set(list2, j));
121
14
      el = FN(EL,copy)(pw1->p[i].FIELD);
122
359
      ++i;
123
359
      ++j;
124
359
    }
125
743
    res = FN(PW,add_piece)(res, set, el);
126
743
  }
127
359
128
359
  isl_set_list_free(list1);
129
359
  isl_set_list_free(list2);
130
359
  FN(PW,free)(pw1);
131
359
  FN(PW,free)(pw2);
132
359
  return res;
133
359
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
359
}
isl_aff.c:isl_pw_multi_aff_merge
Line
Count
Source
89
1.34k
{
90
1.34k
  int i, j;
91
1.34k
  PW *res;
92
1.34k
93
1.34k
  if (!pw1 || !pw2)
94
0
    goto error;
95
1.34k
96
1.34k
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->n + pw2->n);
97
1.34k
98
1.34k
  i = 0; j = 0;
99
4.73k
  while (i < pw1->n || 
j < pw2->n1.89k
) {
100
3.38k
    int cmp;
101
3.38k
    isl_set *set;
102
3.38k
    EL *el;
103
3.38k
104
3.38k
    if (i < pw1->n && 
j < pw2->n2.83k
)
105
2.17k
      cmp = FN(EL,plain_cmp)(pw1->p[i].FIELD,
106
2.17k
            pw2->p[j].FIELD);
107
1.20k
    else
108
1.20k
      cmp = i < pw1->n ? 
-1663
:
1546
;
109
3.38k
110
3.38k
    if (cmp < 0) {
111
1.94k
      set = isl_set_list_get_set(list1, i);
112
1.94k
      el = FN(EL,copy)(pw1->p[i].FIELD);
113
1.94k
      ++i;
114
1.94k
    } else 
if (1.44k
cmp > 01.44k
) {
115
857
      set = isl_set_list_get_set(list2, j);
116
857
      el = FN(EL,copy)(pw2->p[j].FIELD);
117
857
      ++j;
118
857
    } else {
119
587
      set = isl_set_union(isl_set_list_get_set(list1, i),
120
587
              isl_set_list_get_set(list2, j));
121
587
      el = FN(EL,copy)(pw1->p[i].FIELD);
122
1.44k
      ++i;
123
1.44k
      ++j;
124
1.44k
    }
125
3.38k
    res = FN(PW,add_piece)(res, set, el);
126
3.38k
  }
127
1.34k
128
1.34k
  isl_set_list_free(list1);
129
1.34k
  isl_set_list_free(list2);
130
1.34k
  FN(PW,free)(pw1);
131
1.34k
  FN(PW,free)(pw2);
132
1.34k
  return res;
133
1.34k
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
1.34k
}
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
1.96k
{
186
1.96k
  int i, j;
187
1.96k
  PW *res = NULL;
188
1.96k
  isl_ctx *ctx;
189
1.96k
  isl_set *set = NULL;
190
1.96k
  isl_set_list *list1 = NULL, *list2 = NULL;
191
1.96k
192
1.96k
  if (!pw1 || !pw2)
193
0
    goto error;
194
1.96k
195
1.96k
  ctx = isl_space_get_ctx(pw1->dim);
196
1.96k
  if (!isl_space_is_equal(pw1->dim, pw2->dim))
197
1.96k
    
isl_die0
(ctx, isl_error_invalid,
198
1.96k
      "arguments should live in the same space", goto error);
199
1.96k
200
1.96k
  if (FN(PW,is_empty)(pw1)) {
201
247
    FN(PW,free)(pw1);
202
247
    return pw2;
203
247
  }
204
1.72k
205
1.72k
  if (FN(PW,is_empty)(pw2)) {
206
16
    FN(PW,free)(pw2);
207
16
    return pw1;
208
16
  }
209
1.70k
210
1.70k
  pw1 = FN(PW,sort)(pw1);
211
1.70k
  pw2 = FN(PW,sort)(pw2);
212
1.70k
  if (!pw1 || !pw2)
213
0
    goto error;
214
1.70k
215
1.70k
  list1 = FN(PW,extract_domains)(pw1);
216
1.70k
  list2 = FN(PW,extract_domains)(pw2);
217
1.70k
218
4.63k
  for (i = 0; i < pw1->n; 
++i2.92k
) {
219
6.07k
    for (j = 0; j < pw2->n; 
++j3.15k
) {
220
3.15k
      isl_bool disjoint;
221
3.15k
      isl_set *better, *set_i, *set_j;
222
3.15k
223
3.15k
      disjoint = isl_set_is_disjoint(pw1->p[i].set,
224
3.15k
              pw2->p[j].set);
225
3.15k
      if (disjoint < 0)
226
0
        goto error;
227
3.15k
      if (disjoint)
228
1.50k
        continue;
229
1.65k
      better = FN(PW,better)(pw2->p[j].FIELD,
230
1.65k
            pw1->p[i].FIELD, cmp);
231
1.65k
      set_i = isl_set_list_get_set(list1, i);
232
1.65k
      set_j = isl_set_copy(pw2->p[j].set);
233
1.65k
      set_i = FN(PW,worse_or_out)(set_i,
234
1.65k
            isl_set_copy(better), set_j);
235
1.65k
      list1 = isl_set_list_set_set(list1, i, set_i);
236
1.65k
      set_i = isl_set_copy(pw1->p[i].set);
237
1.65k
      set_j = isl_set_list_get_set(list2, j);
238
1.65k
      set_j = FN(PW,better_or_out)(set_j, better, set_i);
239
3.15k
      list2 = isl_set_list_set_set(list2, j, set_j);
240
3.15k
    }
241
2.92k
  }
242
1.70k
243
1.70k
  res = FN(PW,merge)(pw1, pw2, list1, list2);
244
1.70k
245
1.70k
  return res;
246
1.70k
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
1.96k
}
isl_aff.c:isl_pw_aff_union_opt_cmp
Line
Count
Source
185
359
{
186
359
  int i, j;
187
359
  PW *res = NULL;
188
359
  isl_ctx *ctx;
189
359
  isl_set *set = NULL;
190
359
  isl_set_list *list1 = NULL, *list2 = NULL;
191
359
192
359
  if (!pw1 || !pw2)
193
0
    goto error;
194
359
195
359
  ctx = isl_space_get_ctx(pw1->dim);
196
359
  if (!isl_space_is_equal(pw1->dim, pw2->dim))
197
359
    
isl_die0
(ctx, isl_error_invalid,
198
359
      "arguments should live in the same space", goto error);
199
359
200
359
  if (FN(PW,is_empty)(pw1)) {
201
0
    FN(PW,free)(pw1);
202
0
    return pw2;
203
0
  }
204
359
205
359
  if (FN(PW,is_empty)(pw2)) {
206
0
    FN(PW,free)(pw2);
207
0
    return pw1;
208
0
  }
209
359
210
359
  pw1 = FN(PW,sort)(pw1);
211
359
  pw2 = FN(PW,sort)(pw2);
212
359
  if (!pw1 || !pw2)
213
0
    goto error;
214
359
215
359
  list1 = FN(PW,extract_domains)(pw1);
216
359
  list2 = FN(PW,extract_domains)(pw2);
217
359
218
757
  for (i = 0; i < pw1->n; 
++i398
) {
219
796
    for (j = 0; j < pw2->n; 
++j398
) {
220
398
      isl_bool disjoint;
221
398
      isl_set *better, *set_i, *set_j;
222
398
223
398
      disjoint = isl_set_is_disjoint(pw1->p[i].set,
224
398
              pw2->p[j].set);
225
398
      if (disjoint < 0)
226
0
        goto error;
227
398
      if (disjoint)
228
30
        continue;
229
368
      better = FN(PW,better)(pw2->p[j].FIELD,
230
368
            pw1->p[i].FIELD, cmp);
231
368
      set_i = isl_set_list_get_set(list1, i);
232
368
      set_j = isl_set_copy(pw2->p[j].set);
233
368
      set_i = FN(PW,worse_or_out)(set_i,
234
368
            isl_set_copy(better), set_j);
235
368
      list1 = isl_set_list_set_set(list1, i, set_i);
236
368
      set_i = isl_set_copy(pw1->p[i].set);
237
368
      set_j = isl_set_list_get_set(list2, j);
238
368
      set_j = FN(PW,better_or_out)(set_j, better, set_i);
239
398
      list2 = isl_set_list_set_set(list2, j, set_j);
240
398
    }
241
398
  }
242
359
243
359
  res = FN(PW,merge)(pw1, pw2, list1, list2);
244
359
245
359
  return res;
246
359
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
359
}
isl_aff.c:isl_pw_multi_aff_union_opt_cmp
Line
Count
Source
185
1.60k
{
186
1.60k
  int i, j;
187
1.60k
  PW *res = NULL;
188
1.60k
  isl_ctx *ctx;
189
1.60k
  isl_set *set = NULL;
190
1.60k
  isl_set_list *list1 = NULL, *list2 = NULL;
191
1.60k
192
1.60k
  if (!pw1 || !pw2)
193
0
    goto error;
194
1.60k
195
1.60k
  ctx = isl_space_get_ctx(pw1->dim);
196
1.60k
  if (!isl_space_is_equal(pw1->dim, pw2->dim))
197
1.60k
    
isl_die0
(ctx, isl_error_invalid,
198
1.60k
      "arguments should live in the same space", goto error);
199
1.60k
200
1.60k
  if (FN(PW,is_empty)(pw1)) {
201
247
    FN(PW,free)(pw1);
202
247
    return pw2;
203
247
  }
204
1.36k
205
1.36k
  if (FN(PW,is_empty)(pw2)) {
206
16
    FN(PW,free)(pw2);
207
16
    return pw1;
208
16
  }
209
1.34k
210
1.34k
  pw1 = FN(PW,sort)(pw1);
211
1.34k
  pw2 = FN(PW,sort)(pw2);
212
1.34k
  if (!pw1 || !pw2)
213
0
    goto error;
214
1.34k
215
1.34k
  list1 = FN(PW,extract_domains)(pw1);
216
1.34k
  list2 = FN(PW,extract_domains)(pw2);
217
1.34k
218
3.87k
  for (i = 0; i < pw1->n; 
++i2.52k
) {
219
5.28k
    for (j = 0; j < pw2->n; 
++j2.75k
) {
220
2.75k
      isl_bool disjoint;
221
2.75k
      isl_set *better, *set_i, *set_j;
222
2.75k
223
2.75k
      disjoint = isl_set_is_disjoint(pw1->p[i].set,
224
2.75k
              pw2->p[j].set);
225
2.75k
      if (disjoint < 0)
226
0
        goto error;
227
2.75k
      if (disjoint)
228
1.47k
        continue;
229
1.28k
      better = FN(PW,better)(pw2->p[j].FIELD,
230
1.28k
            pw1->p[i].FIELD, cmp);
231
1.28k
      set_i = isl_set_list_get_set(list1, i);
232
1.28k
      set_j = isl_set_copy(pw2->p[j].set);
233
1.28k
      set_i = FN(PW,worse_or_out)(set_i,
234
1.28k
            isl_set_copy(better), set_j);
235
1.28k
      list1 = isl_set_list_set_set(list1, i, set_i);
236
1.28k
      set_i = isl_set_copy(pw1->p[i].set);
237
1.28k
      set_j = isl_set_list_get_set(list2, j);
238
1.28k
      set_j = FN(PW,better_or_out)(set_j, better, set_i);
239
2.75k
      list2 = isl_set_list_set_set(list2, j, set_j);
240
2.75k
    }
241
2.52k
  }
242
1.34k
243
1.34k
  res = FN(PW,merge)(pw1, pw2, list1, list2);
244
1.34k
245
1.34k
  return res;
246
1.34k
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
1.60k
}