Coverage Report

Created: 2018-02-20 12:54

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/polly/lib/External/isl/isl_pw_templ.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2010-2011 INRIA Saclay
3
 * Copyright 2011      Sven Verdoolaege
4
 * Copyright 2012-2014 Ecole Normale Superieure
5
 *
6
 * Use of this software is governed by the MIT license
7
 *
8
 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
9
 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
10
 * 91893 Orsay, France
11
 * and Ecole Normale Superieure, 45 rue d’Ulm, 75230 Paris, France
12
 */
13
14
#include <isl/aff.h>
15
#include <isl_sort.h>
16
#include <isl_val_private.h>
17
18
#include <isl_pw_macro.h>
19
20
#ifdef HAS_TYPE
21
__isl_give PW *FN(PW,alloc_size)(__isl_take isl_space *dim,
22
  enum isl_fold type, int n)
23
#else
24
__isl_give PW *FN(PW,alloc_size)(__isl_take isl_space *dim, int n)
25
#endif
26
262k
{
27
262k
  isl_ctx *ctx;
28
262k
  struct PW *pw;
29
262k
30
262k
  if (!dim)
31
0
    return NULL;
32
262k
  ctx = isl_space_get_ctx(dim);
33
262k
  isl_assert(ctx, n >= 0, goto error);
34
262k
  pw = isl_alloc(ctx, struct PW,
35
262k
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
36
262k
  if (!pw)
37
0
    goto error;
38
262k
39
262k
  pw->ref = 1;
40
#ifdef HAS_TYPE
41
  pw->type = type;
42
#endif
43
  pw->size = n;
44
262k
  pw->n = 0;
45
262k
  pw->dim = dim;
46
262k
  return pw;
47
262k
error:
48
0
  isl_space_free(dim);
49
0
  return NULL;
50
262k
}
isl_pw_aff_alloc_size
Line
Count
Source
26
229k
{
27
229k
  isl_ctx *ctx;
28
229k
  struct PW *pw;
29
229k
30
229k
  if (!dim)
31
0
    return NULL;
32
229k
  ctx = isl_space_get_ctx(dim);
33
229k
  isl_assert(ctx, n >= 0, goto error);
34
229k
  pw = isl_alloc(ctx, struct PW,
35
229k
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
36
229k
  if (!pw)
37
0
    goto error;
38
229k
39
229k
  pw->ref = 1;
40
#ifdef HAS_TYPE
41
  pw->type = type;
42
#endif
43
  pw->size = n;
44
229k
  pw->n = 0;
45
229k
  pw->dim = dim;
46
229k
  return pw;
47
229k
error:
48
0
  isl_space_free(dim);
49
0
  return NULL;
50
229k
}
isl_pw_multi_aff_alloc_size
Line
Count
Source
26
32.7k
{
27
32.7k
  isl_ctx *ctx;
28
32.7k
  struct PW *pw;
29
32.7k
30
32.7k
  if (!dim)
31
0
    return NULL;
32
32.7k
  ctx = isl_space_get_ctx(dim);
33
32.7k
  isl_assert(ctx, n >= 0, goto error);
34
32.7k
  pw = isl_alloc(ctx, struct PW,
35
32.7k
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
36
32.7k
  if (!pw)
37
0
    goto error;
38
32.7k
39
32.7k
  pw->ref = 1;
40
#ifdef HAS_TYPE
41
  pw->type = type;
42
#endif
43
  pw->size = n;
44
32.7k
  pw->n = 0;
45
32.7k
  pw->dim = dim;
46
32.7k
  return pw;
47
32.7k
error:
48
0
  isl_space_free(dim);
49
0
  return NULL;
50
32.7k
}
isl_pw_qpolynomial_fold_alloc_size
Line
Count
Source
26
35
{
27
35
  isl_ctx *ctx;
28
35
  struct PW *pw;
29
35
30
35
  if (!dim)
31
0
    return NULL;
32
35
  ctx = isl_space_get_ctx(dim);
33
35
  isl_assert(ctx, n >= 0, goto error);
34
35
  pw = isl_alloc(ctx, struct PW,
35
35
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
36
35
  if (!pw)
37
0
    goto error;
38
35
39
35
  pw->ref = 1;
40
35
#ifdef HAS_TYPE
41
35
  pw->type = type;
42
35
#endif
43
35
  pw->size = n;
44
35
  pw->n = 0;
45
35
  pw->dim = dim;
46
35
  return pw;
47
35
error:
48
0
  isl_space_free(dim);
49
0
  return NULL;
50
35
}
isl_pw_qpolynomial_alloc_size
Line
Count
Source
26
104
{
27
104
  isl_ctx *ctx;
28
104
  struct PW *pw;
29
104
30
104
  if (!dim)
31
0
    return NULL;
32
104
  ctx = isl_space_get_ctx(dim);
33
104
  isl_assert(ctx, n >= 0, goto error);
34
104
  pw = isl_alloc(ctx, struct PW,
35
104
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
36
104
  if (!pw)
37
0
    goto error;
38
104
39
104
  pw->ref = 1;
40
#ifdef HAS_TYPE
41
  pw->type = type;
42
#endif
43
  pw->size = n;
44
104
  pw->n = 0;
45
104
  pw->dim = dim;
46
104
  return pw;
47
104
error:
48
0
  isl_space_free(dim);
49
0
  return NULL;
50
104
}
51
52
#ifdef HAS_TYPE
53
__isl_give PW *FN(PW,ZERO)(__isl_take isl_space *dim, enum isl_fold type)
54
16
{
55
16
  return FN(PW,alloc_size)(dim, type, 0);
56
16
}
57
#else
58
__isl_give PW *FN(PW,ZERO)(__isl_take isl_space *dim)
59
7.80k
{
60
7.80k
  return FN(PW,alloc_size)(dim, 0);
61
7.80k
}
isl_pw_aff_empty
Line
Count
Source
59
3.04k
{
60
3.04k
  return FN(PW,alloc_size)(dim, 0);
61
3.04k
}
isl_pw_multi_aff_empty
Line
Count
Source
59
4.75k
{
60
4.75k
  return FN(PW,alloc_size)(dim, 0);
61
4.75k
}
isl_pw_qpolynomial_zero
Line
Count
Source
59
2
{
60
2
  return FN(PW,alloc_size)(dim, 0);
61
2
}
62
#endif
63
64
__isl_give PW *FN(PW,add_piece)(__isl_take PW *pw,
65
  __isl_take isl_set *set, __isl_take EL *el)
66
261k
{
67
261k
  isl_ctx *ctx;
68
261k
  isl_space *el_dim = NULL;
69
261k
70
261k
  if (!pw || !set || !el)
71
0
    goto error;
72
261k
73
261k
  if (isl_set_plain_is_empty(set) || 
FN261k
(EL,EL_IS_ZERO)(el)261k
) {
74
725
    isl_set_free(set);
75
725
    FN(EL,free)(el);
76
725
    return pw;
77
725
  }
78
261k
79
261k
  ctx = isl_set_get_ctx(set);
80
#ifdef HAS_TYPE
81
18
  if (pw->type != el->type)
82
0
    isl_die(ctx, isl_error_invalid, "fold types don't match",
83
      goto error);
84
#endif
85
261k
  
el_dim = 18
FN(EL,get_space(el));
86
261k
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
87
261k
  isl_assert(ctx, pw->n < pw->size, goto error);
88
261k
89
261k
  pw->p[pw->n].set = set;
90
261k
  pw->p[pw->n].FIELD = el;
91
261k
  pw->n++;
92
261k
  
93
261k
  isl_space_free(el_dim);
94
261k
  return pw;
95
261k
error:
96
0
  isl_space_free(el_dim);
97
0
  FN(PW,free)(pw);
98
0
  isl_set_free(set);
99
0
  FN(EL,free)(el);
100
0
  return NULL;
101
261k
}
isl_pw_aff_add_piece
Line
Count
Source
66
231k
{
67
231k
  isl_ctx *ctx;
68
231k
  isl_space *el_dim = NULL;
69
231k
70
231k
  if (!pw || !set || !el)
71
0
    goto error;
72
231k
73
231k
  if (isl_set_plain_is_empty(set) || 
FN230k
(EL,EL_IS_ZERO)(el)230k
) {
74
361
    isl_set_free(set);
75
361
    FN(EL,free)(el);
76
361
    return pw;
77
361
  }
78
230k
79
230k
  ctx = isl_set_get_ctx(set);
80
#ifdef HAS_TYPE
81
  if (pw->type != el->type)
82
    isl_die(ctx, isl_error_invalid, "fold types don't match",
83
      goto error);
84
#endif
85
230k
  el_dim = FN(EL,get_space(el));
86
230k
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
87
230k
  isl_assert(ctx, pw->n < pw->size, goto error);
88
230k
89
230k
  pw->p[pw->n].set = set;
90
230k
  pw->p[pw->n].FIELD = el;
91
230k
  pw->n++;
92
230k
  
93
230k
  isl_space_free(el_dim);
94
230k
  return pw;
95
230k
error:
96
0
  isl_space_free(el_dim);
97
0
  FN(PW,free)(pw);
98
0
  isl_set_free(set);
99
0
  FN(EL,free)(el);
100
0
  return NULL;
101
230k
}
isl_pw_multi_aff_add_piece
Line
Count
Source
66
30.3k
{
67
30.3k
  isl_ctx *ctx;
68
30.3k
  isl_space *el_dim = NULL;
69
30.3k
70
30.3k
  if (!pw || !set || !el)
71
0
    goto error;
72
30.3k
73
30.3k
  if (isl_set_plain_is_empty(set) || 
FN30.0k
(EL,EL_IS_ZERO)(el)30.0k
) {
74
305
    isl_set_free(set);
75
305
    FN(EL,free)(el);
76
305
    return pw;
77
305
  }
78
30.0k
79
30.0k
  ctx = isl_set_get_ctx(set);
80
#ifdef HAS_TYPE
81
  if (pw->type != el->type)
82
    isl_die(ctx, isl_error_invalid, "fold types don't match",
83
      goto error);
84
#endif
85
30.0k
  el_dim = FN(EL,get_space(el));
86
30.0k
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
87
30.0k
  isl_assert(ctx, pw->n < pw->size, goto error);
88
30.0k
89
30.0k
  pw->p[pw->n].set = set;
90
30.0k
  pw->p[pw->n].FIELD = el;
91
30.0k
  pw->n++;
92
30.0k
  
93
30.0k
  isl_space_free(el_dim);
94
30.0k
  return pw;
95
30.0k
error:
96
0
  isl_space_free(el_dim);
97
0
  FN(PW,free)(pw);
98
0
  isl_set_free(set);
99
0
  FN(EL,free)(el);
100
0
  return NULL;
101
30.0k
}
isl_pw_qpolynomial_fold_add_piece
Line
Count
Source
66
24
{
67
24
  isl_ctx *ctx;
68
24
  isl_space *el_dim = NULL;
69
24
70
24
  if (!pw || !set || !el)
71
0
    goto error;
72
24
73
24
  if (isl_set_plain_is_empty(set) || 
FN18
(EL,EL_IS_ZERO)(el)18
) {
74
6
    isl_set_free(set);
75
6
    FN(EL,free)(el);
76
6
    return pw;
77
6
  }
78
18
79
18
  ctx = isl_set_get_ctx(set);
80
18
#ifdef HAS_TYPE
81
18
  if (pw->type != el->type)
82
18
    
isl_die0
(ctx, isl_error_invalid, "fold types don't match",
83
18
      goto error);
84
18
#endif
85
18
  el_dim = FN(EL,get_space(el));
86
18
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
87
18
  isl_assert(ctx, pw->n < pw->size, goto error);
88
18
89
18
  pw->p[pw->n].set = set;
90
18
  pw->p[pw->n].FIELD = el;
91
18
  pw->n++;
92
18
  
93
18
  isl_space_free(el_dim);
94
18
  return pw;
95
18
error:
96
0
  isl_space_free(el_dim);
97
0
  FN(PW,free)(pw);
98
0
  isl_set_free(set);
99
0
  FN(EL,free)(el);
100
0
  return NULL;
101
18
}
isl_pw_qpolynomial_add_piece
Line
Count
Source
66
151
{
67
151
  isl_ctx *ctx;
68
151
  isl_space *el_dim = NULL;
69
151
70
151
  if (!pw || !set || !el)
71
0
    goto error;
72
151
73
151
  if (isl_set_plain_is_empty(set) || 
FN107
(EL,EL_IS_ZERO)(el)107
) {
74
53
    isl_set_free(set);
75
53
    FN(EL,free)(el);
76
53
    return pw;
77
53
  }
78
98
79
98
  ctx = isl_set_get_ctx(set);
80
#ifdef HAS_TYPE
81
  if (pw->type != el->type)
82
    isl_die(ctx, isl_error_invalid, "fold types don't match",
83
      goto error);
84
#endif
85
98
  el_dim = FN(EL,get_space(el));
86
98
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
87
98
  isl_assert(ctx, pw->n < pw->size, goto error);
88
98
89
98
  pw->p[pw->n].set = set;
90
98
  pw->p[pw->n].FIELD = el;
91
98
  pw->n++;
92
98
  
93
98
  isl_space_free(el_dim);
94
98
  return pw;
95
98
error:
96
0
  isl_space_free(el_dim);
97
0
  FN(PW,free)(pw);
98
0
  isl_set_free(set);
99
0
  FN(EL,free)(el);
100
0
  return NULL;
101
98
}
102
103
/* Does the space of "set" correspond to that of the domain of "el".
104
 */
105
static isl_bool FN(PW,compatible_domain)(__isl_keep EL *el,
106
  __isl_keep isl_set *set)
107
0
{
108
0
  isl_bool ok;
109
0
  isl_space *el_space, *set_space;
110
0
111
0
  if (!set || !el)
112
0
    return isl_bool_error;
113
0
  set_space = isl_set_get_space(set);
114
0
  el_space = FN(EL,get_space)(el);
115
0
  ok = isl_space_is_domain_internal(set_space, el_space);
116
0
  isl_space_free(el_space);
117
0
  isl_space_free(set_space);
118
0
  return ok;
119
0
}
Unexecuted instantiation: isl_aff.c:isl_pw_aff_compatible_domain
Unexecuted instantiation: isl_aff.c:isl_pw_multi_aff_compatible_domain
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_compatible_domain
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_compatible_domain
120
121
/* Check that the space of "set" corresponds to that of the domain of "el".
122
 */
123
static isl_stat FN(PW,check_compatible_domain)(__isl_keep EL *el,
124
  __isl_keep isl_set *set)
125
0
{
126
0
  isl_bool ok;
127
0
128
0
  ok = FN(PW,compatible_domain)(el, set);
129
0
  if (ok < 0)
130
0
    return isl_stat_error;
131
0
  if (!ok)
132
0
    isl_die(isl_set_get_ctx(set), isl_error_invalid,
133
0
      "incompatible spaces", return isl_stat_error);
134
0
135
0
  return isl_stat_ok;
136
0
}
Unexecuted instantiation: isl_aff.c:isl_pw_aff_check_compatible_domain
Unexecuted instantiation: isl_aff.c:isl_pw_multi_aff_check_compatible_domain
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_check_compatible_domain
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_check_compatible_domain
137
138
#ifdef HAS_TYPE
139
__isl_give PW *FN(PW,alloc)(enum isl_fold type,
140
  __isl_take isl_set *set, __isl_take EL *el)
141
#else
142
__isl_give PW *FN(PW,alloc)(__isl_take isl_set *set, __isl_take EL *el)
143
#endif
144
100k
{
145
100k
  PW *pw;
146
100k
147
100k
  if (!set || !el)
148
0
    goto error;
149
12
150
#ifdef HAS_TYPE
151
12
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), type, 1);
152
#else
153
100k
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), 1);
154
#endif
155
156
100k
  return FN(PW,add_piece)(pw, set, el);
157
100k
error:
158
0
  isl_set_free(set);
159
0
  FN(EL,free)(el);
160
0
  return NULL;
161
100k
}
isl_pw_aff_alloc
Line
Count
Source
144
76.7k
{
145
76.7k
  PW *pw;
146
76.7k
147
76.7k
  if (!set || !el)
148
0
    goto error;
149
76.7k
150
#ifdef HAS_TYPE
151
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), type, 1);
152
#else
153
76.7k
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), 1);
154
76.7k
#endif
155
76.7k
156
76.7k
  return FN(PW,add_piece)(pw, set, el);
157
76.7k
error:
158
0
  isl_set_free(set);
159
0
  FN(EL,free)(el);
160
0
  return NULL;
161
76.7k
}
isl_pw_multi_aff_alloc
Line
Count
Source
144
24.1k
{
145
24.1k
  PW *pw;
146
24.1k
147
24.1k
  if (!set || !el)
148
0
    goto error;
149
24.1k
150
#ifdef HAS_TYPE
151
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), type, 1);
152
#else
153
24.1k
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), 1);
154
24.1k
#endif
155
24.1k
156
24.1k
  return FN(PW,add_piece)(pw, set, el);
157
24.1k
error:
158
0
  isl_set_free(set);
159
0
  FN(EL,free)(el);
160
0
  return NULL;
161
24.1k
}
isl_pw_qpolynomial_fold_alloc
Line
Count
Source
144
12
{
145
12
  PW *pw;
146
12
147
12
  if (!set || !el)
148
0
    goto error;
149
12
150
12
#ifdef HAS_TYPE
151
12
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), type, 1);
152
#else
153
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), 1);
154
#endif
155
156
12
  return FN(PW,add_piece)(pw, set, el);
157
12
error:
158
0
  isl_set_free(set);
159
0
  FN(EL,free)(el);
160
0
  return NULL;
161
12
}
isl_pw_qpolynomial_alloc
Line
Count
Source
144
33
{
145
33
  PW *pw;
146
33
147
33
  if (!set || !el)
148
0
    goto error;
149
33
150
#ifdef HAS_TYPE
151
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), type, 1);
152
#else
153
33
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), 1);
154
33
#endif
155
33
156
33
  return FN(PW,add_piece)(pw, set, el);
157
33
error:
158
0
  isl_set_free(set);
159
0
  FN(EL,free)(el);
160
0
  return NULL;
161
33
}
162
163
__isl_give PW *FN(PW,dup)(__isl_keep PW *pw)
164
60.9k
{
165
60.9k
  int i;
166
60.9k
  PW *dup;
167
60.9k
168
60.9k
  if (!pw)
169
0
    return NULL;
170
0
171
#ifdef HAS_TYPE
172
0
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
173
#else
174
60.9k
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
175
#endif
176
60.9k
  if (!dup)
177
0
    return NULL;
178
60.9k
179
123k
  
for (i = 0; 60.9k
i < pw->n;
++i62.8k
)
180
62.8k
    dup = FN(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
181
62.8k
              FN(EL,copy)(pw->p[i].FIELD));
182
60.9k
183
60.9k
  return dup;
184
60.9k
}
isl_pw_aff_dup
Line
Count
Source
164
59.5k
{
165
59.5k
  int i;
166
59.5k
  PW *dup;
167
59.5k
168
59.5k
  if (!pw)
169
0
    return NULL;
170
59.5k
171
#ifdef HAS_TYPE
172
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
173
#else
174
59.5k
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
175
59.5k
#endif
176
59.5k
  if (!dup)
177
0
    return NULL;
178
59.5k
179
121k
  
for (i = 0; 59.5k
i < pw->n;
++i61.4k
)
180
61.4k
    dup = FN(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
181
61.4k
              FN(EL,copy)(pw->p[i].FIELD));
182
59.5k
183
59.5k
  return dup;
184
59.5k
}
isl_pw_multi_aff_dup
Line
Count
Source
164
1.34k
{
165
1.34k
  int i;
166
1.34k
  PW *dup;
167
1.34k
168
1.34k
  if (!pw)
169
0
    return NULL;
170
1.34k
171
#ifdef HAS_TYPE
172
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
173
#else
174
1.34k
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
175
1.34k
#endif
176
1.34k
  if (!dup)
177
0
    return NULL;
178
1.34k
179
2.72k
  
for (i = 0; 1.34k
i < pw->n;
++i1.37k
)
180
1.37k
    dup = FN(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
181
1.37k
              FN(EL,copy)(pw->p[i].FIELD));
182
1.34k
183
1.34k
  return dup;
184
1.34k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_dup
isl_pw_qpolynomial_dup
Line
Count
Source
164
1
{
165
1
  int i;
166
1
  PW *dup;
167
1
168
1
  if (!pw)
169
0
    return NULL;
170
1
171
#ifdef HAS_TYPE
172
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
173
#else
174
1
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
175
1
#endif
176
1
  if (!dup)
177
0
    return NULL;
178
1
179
2
  
for (i = 0; 1
i < pw->n;
++i1
)
180
1
    dup = FN(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
181
1
              FN(EL,copy)(pw->p[i].FIELD));
182
1
183
1
  return dup;
184
1
}
185
186
__isl_give PW *FN(PW,cow)(__isl_take PW *pw)
187
186k
{
188
186k
  if (!pw)
189
0
    return NULL;
190
186k
191
186k
  if (pw->ref == 1)
192
125k
    return pw;
193
60.9k
  pw->ref--;
194
60.9k
  return FN(PW,dup)(pw);
195
60.9k
}
isl_pw_aff_cow
Line
Count
Source
187
175k
{
188
175k
  if (!pw)
189
0
    return NULL;
190
175k
191
175k
  if (pw->ref == 1)
192
116k
    return pw;
193
59.5k
  pw->ref--;
194
59.5k
  return FN(PW,dup)(pw);
195
59.5k
}
isl_pw_multi_aff_cow
Line
Count
Source
187
10.3k
{
188
10.3k
  if (!pw)
189
0
    return NULL;
190
10.3k
191
10.3k
  if (pw->ref == 1)
192
9.03k
    return pw;
193
1.34k
  pw->ref--;
194
1.34k
  return FN(PW,dup)(pw);
195
1.34k
}
isl_pw_qpolynomial_fold_cow
Line
Count
Source
187
7
{
188
7
  if (!pw)
189
0
    return NULL;
190
7
191
7
  if (pw->ref == 1)
192
7
    return pw;
193
0
  pw->ref--;
194
0
  return FN(PW,dup)(pw);
195
0
}
isl_pw_qpolynomial_cow
Line
Count
Source
187
51
{
188
51
  if (!pw)
189
0
    return NULL;
190
51
191
51
  if (pw->ref == 1)
192
50
    return pw;
193
1
  pw->ref--;
194
1
  return FN(PW,dup)(pw);
195
1
}
196
197
__isl_give PW *FN(PW,copy)(__isl_keep PW *pw)
198
453k
{
199
453k
  if (!pw)
200
46.1k
    return NULL;
201
407k
202
407k
  pw->ref++;
203
407k
  return pw;
204
407k
}
isl_pw_aff_copy
Line
Count
Source
198
412k
{
199
412k
  if (!pw)
200
46.1k
    return NULL;
201
366k
202
366k
  pw->ref++;
203
366k
  return pw;
204
366k
}
isl_pw_multi_aff_copy
Line
Count
Source
198
41.3k
{
199
41.3k
  if (!pw)
200
0
    return NULL;
201
41.3k
202
41.3k
  pw->ref++;
203
41.3k
  return pw;
204
41.3k
}
isl_pw_qpolynomial_fold_copy
Line
Count
Source
198
2
{
199
2
  if (!pw)
200
0
    return NULL;
201
2
202
2
  pw->ref++;
203
2
  return pw;
204
2
}
isl_pw_qpolynomial_copy
Line
Count
Source
198
10
{
199
10
  if (!pw)
200
0
    return NULL;
201
10
202
10
  pw->ref++;
203
10
  return pw;
204
10
}
205
206
__isl_null PW *FN(PW,free)(__isl_take PW *pw)
207
655k
{
208
655k
  int i;
209
655k
210
655k
  if (!pw)
211
46.6k
    return NULL;
212
608k
  if (--pw->ref > 0)
213
346k
    return NULL;
214
261k
215
522k
  
for (i = 0; 261k
i < pw->n;
++i260k
) {
216
260k
    isl_set_free(pw->p[i].set);
217
260k
    FN(EL,free)(pw->p[i].FIELD);
218
260k
  }
219
261k
  isl_space_free(pw->dim);
220
261k
  free(pw);
221
261k
222
261k
  return NULL;
223
261k
}
isl_pw_aff_free
Line
Count
Source
207
582k
{
208
582k
  int i;
209
582k
210
582k
  if (!pw)
211
46.6k
    return NULL;
212
535k
  if (--pw->ref > 0)
213
306k
    return NULL;
214
228k
215
459k
  
for (i = 0; 228k
i < pw->n;
++i230k
) {
216
230k
    isl_set_free(pw->p[i].set);
217
230k
    FN(EL,free)(pw->p[i].FIELD);
218
230k
  }
219
228k
  isl_space_free(pw->dim);
220
228k
  free(pw);
221
228k
222
228k
  return NULL;
223
228k
}
isl_pw_multi_aff_free
Line
Count
Source
207
72.7k
{
208
72.7k
  int i;
209
72.7k
210
72.7k
  if (!pw)
211
0
    return NULL;
212
72.7k
  if (--pw->ref > 0)
213
40.0k
    return NULL;
214
32.6k
215
62.6k
  
for (i = 0; 32.6k
i < pw->n;
++i29.9k
) {
216
29.9k
    isl_set_free(pw->p[i].set);
217
29.9k
    FN(EL,free)(pw->p[i].FIELD);
218
29.9k
  }
219
32.6k
  isl_space_free(pw->dim);
220
32.6k
  free(pw);
221
32.6k
222
32.6k
  return NULL;
223
32.6k
}
isl_pw_qpolynomial_fold_free
Line
Count
Source
207
37
{
208
37
  int i;
209
37
210
37
  if (!pw)
211
0
    return NULL;
212
37
  if (--pw->ref > 0)
213
2
    return NULL;
214
35
215
53
  
for (i = 0; 35
i < pw->n;
++i18
) {
216
18
    isl_set_free(pw->p[i].set);
217
18
    FN(EL,free)(pw->p[i].FIELD);
218
18
  }
219
35
  isl_space_free(pw->dim);
220
35
  free(pw);
221
35
222
35
  return NULL;
223
35
}
isl_pw_qpolynomial_free
Line
Count
Source
207
113
{
208
113
  int i;
209
113
210
113
  if (!pw)
211
0
    return NULL;
212
113
  if (--pw->ref > 0)
213
9
    return NULL;
214
104
215
202
  
for (i = 0; 104
i < pw->n;
++i98
) {
216
98
    isl_set_free(pw->p[i].set);
217
98
    FN(EL,free)(pw->p[i].FIELD);
218
98
  }
219
104
  isl_space_free(pw->dim);
220
104
  free(pw);
221
104
222
104
  return NULL;
223
104
}
224
225
const char *FN(PW,get_dim_name)(__isl_keep PW *pw, enum isl_dim_type type,
226
  unsigned pos)
227
0
{
228
0
  return pw ? isl_space_get_dim_name(pw->dim, type, pos) : NULL;
229
0
}
Unexecuted instantiation: isl_pw_aff_get_dim_name
Unexecuted instantiation: isl_pw_multi_aff_get_dim_name
Unexecuted instantiation: isl_pw_qpolynomial_fold_get_dim_name
Unexecuted instantiation: isl_pw_qpolynomial_get_dim_name
230
231
isl_bool FN(PW,has_dim_id)(__isl_keep PW *pw, enum isl_dim_type type,
232
  unsigned pos)
233
0
{
234
0
  return pw ? isl_space_has_dim_id(pw->dim, type, pos) : isl_bool_error;
235
0
}
Unexecuted instantiation: isl_pw_aff_has_dim_id
Unexecuted instantiation: isl_pw_multi_aff_has_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_has_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_has_dim_id
236
237
__isl_give isl_id *FN(PW,get_dim_id)(__isl_keep PW *pw, enum isl_dim_type type,
238
  unsigned pos)
239
16
{
240
16
  return pw ? isl_space_get_dim_id(pw->dim, type, pos) : NULL;
241
16
}
isl_pw_aff_get_dim_id
Line
Count
Source
239
16
{
240
16
  return pw ? isl_space_get_dim_id(pw->dim, type, pos) : NULL;
241
16
}
Unexecuted instantiation: isl_pw_multi_aff_get_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_get_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_get_dim_id
242
243
isl_bool FN(PW,has_tuple_name)(__isl_keep PW *pw, enum isl_dim_type type)
244
0
{
245
0
  return pw ? isl_space_has_tuple_name(pw->dim, type) : isl_bool_error;
246
0
}
Unexecuted instantiation: isl_pw_aff_has_tuple_name
Unexecuted instantiation: isl_pw_multi_aff_has_tuple_name
Unexecuted instantiation: isl_pw_qpolynomial_fold_has_tuple_name
Unexecuted instantiation: isl_pw_qpolynomial_has_tuple_name
247
248
const char *FN(PW,get_tuple_name)(__isl_keep PW *pw, enum isl_dim_type type)
249
0
{
250
0
  return pw ? isl_space_get_tuple_name(pw->dim, type) : NULL;
251
0
}
Unexecuted instantiation: isl_pw_aff_get_tuple_name
Unexecuted instantiation: isl_pw_multi_aff_get_tuple_name
Unexecuted instantiation: isl_pw_qpolynomial_fold_get_tuple_name
Unexecuted instantiation: isl_pw_qpolynomial_get_tuple_name
252
253
isl_bool FN(PW,has_tuple_id)(__isl_keep PW *pw, enum isl_dim_type type)
254
0
{
255
0
  return pw ? isl_space_has_tuple_id(pw->dim, type) : isl_bool_error;
256
0
}
Unexecuted instantiation: isl_pw_aff_has_tuple_id
Unexecuted instantiation: isl_pw_multi_aff_has_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_has_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_has_tuple_id
257
258
__isl_give isl_id *FN(PW,get_tuple_id)(__isl_keep PW *pw, enum isl_dim_type type)
259
342
{
260
342
  return pw ? isl_space_get_tuple_id(pw->dim, type) : NULL;
261
342
}
Unexecuted instantiation: isl_pw_aff_get_tuple_id
isl_pw_multi_aff_get_tuple_id
Line
Count
Source
259
342
{
260
342
  return pw ? isl_space_get_tuple_id(pw->dim, type) : NULL;
261
342
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_get_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_get_tuple_id
262
263
isl_bool FN(PW,IS_ZERO)(__isl_keep PW *pw)
264
64.3k
{
265
64.3k
  if (!pw)
266
0
    return isl_bool_error;
267
64.3k
268
64.3k
  return pw->n == 0;
269
64.3k
}
isl_pw_aff_is_empty
Line
Count
Source
264
38.6k
{
265
38.6k
  if (!pw)
266
0
    return isl_bool_error;
267
38.6k
268
38.6k
  return pw->n == 0;
269
38.6k
}
isl_pw_multi_aff_is_empty
Line
Count
Source
264
25.5k
{
265
25.5k
  if (!pw)
266
0
    return isl_bool_error;
267
25.5k
268
25.5k
  return pw->n == 0;
269
25.5k
}
isl_pw_qpolynomial_fold_is_zero
Line
Count
Source
264
26
{
265
26
  if (!pw)
266
0
    return isl_bool_error;
267
26
268
26
  return pw->n == 0;
269
26
}
isl_pw_qpolynomial_is_zero
Line
Count
Source
264
102
{
265
102
  if (!pw)
266
0
    return isl_bool_error;
267
102
268
102
  return pw->n == 0;
269
102
}
270
271
#ifndef NO_REALIGN
272
__isl_give PW *FN(PW,realign_domain)(__isl_take PW *pw,
273
  __isl_take isl_reordering *exp)
274
9.36k
{
275
9.36k
  int i;
276
9.36k
277
9.36k
  pw = FN(PW,cow)(pw);
278
9.36k
  if (!pw || !exp)
279
0
    goto error;
280
9.36k
281
19.1k
  
for (i = 0; 9.36k
i < pw->n;
++i9.80k
) {
282
9.80k
    pw->p[i].set = isl_set_realign(pw->p[i].set,
283
9.80k
                isl_reordering_copy(exp));
284
9.80k
    if (!pw->p[i].set)
285
0
      goto error;
286
9.80k
    pw->p[i].FIELD = FN(EL,realign_domain)(pw->p[i].FIELD,
287
9.80k
                isl_reordering_copy(exp));
288
9.80k
    if (!pw->p[i].FIELD)
289
9.80k
      
goto error0
;
290
9.80k
  }
291
9.36k
292
9.36k
  pw = FN(PW,reset_domain_space)(pw, isl_space_copy(exp->dim));
293
9.36k
294
9.36k
  isl_reordering_free(exp);
295
9.36k
  return pw;
296
9.36k
error:
297
0
  isl_reordering_free(exp);
298
0
  FN(PW,free)(pw);
299
0
  return NULL;
300
9.36k
}
isl_pw_aff_realign_domain
Line
Count
Source
274
9.36k
{
275
9.36k
  int i;
276
9.36k
277
9.36k
  pw = FN(PW,cow)(pw);
278
9.36k
  if (!pw || !exp)
279
0
    goto error;
280
9.36k
281
19.1k
  
for (i = 0; 9.36k
i < pw->n;
++i9.80k
) {
282
9.80k
    pw->p[i].set = isl_set_realign(pw->p[i].set,
283
9.80k
                isl_reordering_copy(exp));
284
9.80k
    if (!pw->p[i].set)
285
0
      goto error;
286
9.80k
    pw->p[i].FIELD = FN(EL,realign_domain)(pw->p[i].FIELD,
287
9.80k
                isl_reordering_copy(exp));
288
9.80k
    if (!pw->p[i].FIELD)
289
9.80k
      
goto error0
;
290
9.80k
  }
291
9.36k
292
9.36k
  pw = FN(PW,reset_domain_space)(pw, isl_space_copy(exp->dim));
293
9.36k
294
9.36k
  isl_reordering_free(exp);
295
9.36k
  return pw;
296
9.36k
error:
297
0
  isl_reordering_free(exp);
298
0
  FN(PW,free)(pw);
299
0
  return NULL;
300
9.36k
}
Unexecuted instantiation: isl_pw_multi_aff_realign_domain
Unexecuted instantiation: isl_pw_qpolynomial_fold_realign_domain
Unexecuted instantiation: isl_pw_qpolynomial_realign_domain
301
302
/* Align the parameters of "pw" to those of "model".
303
 */
304
__isl_give PW *FN(PW,align_params)(__isl_take PW *pw, __isl_take isl_space *model)
305
39.8k
{
306
39.8k
  isl_ctx *ctx;
307
39.8k
  isl_bool equal_params;
308
39.8k
309
39.8k
  if (!pw || !model)
310
0
    goto error;
311
39.8k
312
39.8k
  ctx = isl_space_get_ctx(model);
313
39.8k
  if (!isl_space_has_named_params(model))
314
39.8k
    
isl_die0
(ctx, isl_error_invalid,
315
39.8k
      "model has unnamed parameters", goto error);
316
39.8k
  if (!isl_space_has_named_params(pw->dim))
317
39.8k
    
isl_die0
(ctx, isl_error_invalid,
318
39.8k
      "input has unnamed parameters", goto error);
319
39.8k
  equal_params = isl_space_has_equal_params(pw->dim, model);
320
39.8k
  if (equal_params < 0)
321
0
    goto error;
322
39.8k
  if (!equal_params) {
323
9.07k
    isl_reordering *exp;
324
9.07k
325
9.07k
    model = isl_space_drop_dims(model, isl_dim_in,
326
9.07k
          0, isl_space_dim(model, isl_dim_in));
327
9.07k
    model = isl_space_drop_dims(model, isl_dim_out,
328
9.07k
          0, isl_space_dim(model, isl_dim_out));
329
9.07k
    exp = isl_parameter_alignment_reordering(pw->dim, model);
330
9.07k
    exp = isl_reordering_extend_space(exp,
331
9.07k
          FN(PW,get_domain_space)(pw));
332
9.07k
    pw = FN(PW,realign_domain)(pw, exp);
333
9.07k
  }
334
39.8k
335
39.8k
  isl_space_free(model);
336
39.8k
  return pw;
337
39.8k
error:
338
0
  isl_space_free(model);
339
0
  FN(PW,free)(pw);
340
0
  return NULL;
341
39.8k
}
isl_pw_aff_align_params
Line
Count
Source
305
20.7k
{
306
20.7k
  isl_ctx *ctx;
307
20.7k
  isl_bool equal_params;
308
20.7k
309
20.7k
  if (!pw || !model)
310
0
    goto error;
311
20.7k
312
20.7k
  ctx = isl_space_get_ctx(model);
313
20.7k
  if (!isl_space_has_named_params(model))
314
20.7k
    
isl_die0
(ctx, isl_error_invalid,
315
20.7k
      "model has unnamed parameters", goto error);
316
20.7k
  if (!isl_space_has_named_params(pw->dim))
317
20.7k
    
isl_die0
(ctx, isl_error_invalid,
318
20.7k
      "input has unnamed parameters", goto error);
319
20.7k
  equal_params = isl_space_has_equal_params(pw->dim, model);
320
20.7k
  if (equal_params < 0)
321
0
    goto error;
322
20.7k
  if (!equal_params) {
323
9.07k
    isl_reordering *exp;
324
9.07k
325
9.07k
    model = isl_space_drop_dims(model, isl_dim_in,
326
9.07k
          0, isl_space_dim(model, isl_dim_in));
327
9.07k
    model = isl_space_drop_dims(model, isl_dim_out,
328
9.07k
          0, isl_space_dim(model, isl_dim_out));
329
9.07k
    exp = isl_parameter_alignment_reordering(pw->dim, model);
330
9.07k
    exp = isl_reordering_extend_space(exp,
331
9.07k
          FN(PW,get_domain_space)(pw));
332
9.07k
    pw = FN(PW,realign_domain)(pw, exp);
333
9.07k
  }
334
20.7k
335
20.7k
  isl_space_free(model);
336
20.7k
  return pw;
337
20.7k
error:
338
0
  isl_space_free(model);
339
0
  FN(PW,free)(pw);
340
0
  return NULL;
341
20.7k
}
isl_pw_multi_aff_align_params
Line
Count
Source
305
19.1k
{
306
19.1k
  isl_ctx *ctx;
307
19.1k
  isl_bool equal_params;
308
19.1k
309
19.1k
  if (!pw || !model)
310
0
    goto error;
311
19.1k
312
19.1k
  ctx = isl_space_get_ctx(model);
313
19.1k
  if (!isl_space_has_named_params(model))
314
19.1k
    
isl_die0
(ctx, isl_error_invalid,
315
19.1k
      "model has unnamed parameters", goto error);
316
19.1k
  if (!isl_space_has_named_params(pw->dim))
317
19.1k
    
isl_die0
(ctx, isl_error_invalid,
318
19.1k
      "input has unnamed parameters", goto error);
319
19.1k
  equal_params = isl_space_has_equal_params(pw->dim, model);
320
19.1k
  if (equal_params < 0)
321
0
    goto error;
322
19.1k
  if (!equal_params) {
323
0
    isl_reordering *exp;
324
0
325
0
    model = isl_space_drop_dims(model, isl_dim_in,
326
0
          0, isl_space_dim(model, isl_dim_in));
327
0
    model = isl_space_drop_dims(model, isl_dim_out,
328
0
          0, isl_space_dim(model, isl_dim_out));
329
0
    exp = isl_parameter_alignment_reordering(pw->dim, model);
330
0
    exp = isl_reordering_extend_space(exp,
331
0
          FN(PW,get_domain_space)(pw));
332
0
    pw = FN(PW,realign_domain)(pw, exp);
333
0
  }
334
19.1k
335
19.1k
  isl_space_free(model);
336
19.1k
  return pw;
337
19.1k
error:
338
0
  isl_space_free(model);
339
0
  FN(PW,free)(pw);
340
0
  return NULL;
341
19.1k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_align_params
isl_pw_qpolynomial_align_params
Line
Count
Source
305
5
{
306
5
  isl_ctx *ctx;
307
5
  isl_bool equal_params;
308
5
309
5
  if (!pw || !model)
310
0
    goto error;
311
5
312
5
  ctx = isl_space_get_ctx(model);
313
5
  if (!isl_space_has_named_params(model))
314
5
    
isl_die0
(ctx, isl_error_invalid,
315
5
      "model has unnamed parameters", goto error);
316
5
  if (!isl_space_has_named_params(pw->dim))
317
5
    
isl_die0
(ctx, isl_error_invalid,
318
5
      "input has unnamed parameters", goto error);
319
5
  equal_params = isl_space_has_equal_params(pw->dim, model);
320
5
  if (equal_params < 0)
321
0
    goto error;
322
5
  if (!equal_params) {
323
0
    isl_reordering *exp;
324
0
325
0
    model = isl_space_drop_dims(model, isl_dim_in,
326
0
          0, isl_space_dim(model, isl_dim_in));
327
0
    model = isl_space_drop_dims(model, isl_dim_out,
328
0
          0, isl_space_dim(model, isl_dim_out));
329
0
    exp = isl_parameter_alignment_reordering(pw->dim, model);
330
0
    exp = isl_reordering_extend_space(exp,
331
0
          FN(PW,get_domain_space)(pw));
332
0
    pw = FN(PW,realign_domain)(pw, exp);
333
0
  }
334
5
335
5
  isl_space_free(model);
336
5
  return pw;
337
5
error:
338
0
  isl_space_free(model);
339
0
  FN(PW,free)(pw);
340
0
  return NULL;
341
5
}
342
343
static __isl_give PW *FN(PW,align_params_pw_pw_and)(__isl_take PW *pw1,
344
  __isl_take PW *pw2,
345
  __isl_give PW *(*fn)(__isl_take PW *pw1, __isl_take PW *pw2))
346
85.4k
{
347
85.4k
  isl_ctx *ctx;
348
85.4k
  isl_bool equal_params;
349
85.4k
350
85.4k
  if (!pw1 || 
!pw285.4k
)
351
1
    goto error;
352
85.4k
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
353
85.4k
  if (equal_params < 0)
354
0
    goto error;
355
85.4k
  if (equal_params)
356
81.9k
    return fn(pw1, pw2);
357
3.44k
  ctx = FN(PW,get_ctx)(pw1);
358
3.44k
  if (!isl_space_has_named_params(pw1->dim) ||
359
3.44k
      !isl_space_has_named_params(pw2->dim))
360
3.44k
    
isl_die0
(ctx, isl_error_invalid,
361
3.44k
      "unaligned unnamed parameters", goto error);
362
3.44k
  pw1 = FN(PW,align_params)(pw1, FN(PW,get_space)(pw2));
363
3.44k
  pw2 = FN(PW,align_params)(pw2, FN(PW,get_space)(pw1));
364
3.44k
  return fn(pw1, pw2);
365
3.44k
error:
366
1
  FN(PW,free)(pw1);
367
1
  FN(PW,free)(pw2);
368
1
  return NULL;
369
3.44k
}
isl_aff.c:isl_pw_aff_align_params_pw_pw_and
Line
Count
Source
346
79.0k
{
347
79.0k
  isl_ctx *ctx;
348
79.0k
  isl_bool equal_params;
349
79.0k
350
79.0k
  if (!pw1 || 
!pw279.0k
)
351
1
    goto error;
352
79.0k
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
353
79.0k
  if (equal_params < 0)
354
0
    goto error;
355
79.0k
  if (equal_params)
356
75.6k
    return fn(pw1, pw2);
357
3.44k
  ctx = FN(PW,get_ctx)(pw1);
358
3.44k
  if (!isl_space_has_named_params(pw1->dim) ||
359
3.44k
      !isl_space_has_named_params(pw2->dim))
360
3.44k
    
isl_die0
(ctx, isl_error_invalid,
361
3.44k
      "unaligned unnamed parameters", goto error);
362
3.44k
  pw1 = FN(PW,align_params)(pw1, FN(PW,get_space)(pw2));
363
3.44k
  pw2 = FN(PW,align_params)(pw2, FN(PW,get_space)(pw1));
364
3.44k
  return fn(pw1, pw2);
365
3.44k
error:
366
1
  FN(PW,free)(pw1);
367
1
  FN(PW,free)(pw2);
368
1
  return NULL;
369
3.44k
}
isl_aff.c:isl_pw_multi_aff_align_params_pw_pw_and
Line
Count
Source
346
6.31k
{
347
6.31k
  isl_ctx *ctx;
348
6.31k
  isl_bool equal_params;
349
6.31k
350
6.31k
  if (!pw1 || !pw2)
351
0
    goto error;
352
6.31k
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
353
6.31k
  if (equal_params < 0)
354
0
    goto error;
355
6.31k
  if (equal_params)
356
6.31k
    return fn(pw1, pw2);
357
0
  ctx = FN(PW,get_ctx)(pw1);
358
0
  if (!isl_space_has_named_params(pw1->dim) ||
359
0
      !isl_space_has_named_params(pw2->dim))
360
0
    isl_die(ctx, isl_error_invalid,
361
0
      "unaligned unnamed parameters", goto error);
362
0
  pw1 = FN(PW,align_params)(pw1, FN(PW,get_space)(pw2));
363
0
  pw2 = FN(PW,align_params)(pw2, FN(PW,get_space)(pw1));
364
0
  return fn(pw1, pw2);
365
0
error:
366
0
  FN(PW,free)(pw1);
367
0
  FN(PW,free)(pw2);
368
0
  return NULL;
369
0
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_align_params_pw_pw_and
isl_polynomial.c:isl_pw_qpolynomial_align_params_pw_pw_and
Line
Count
Source
346
26
{
347
26
  isl_ctx *ctx;
348
26
  isl_bool equal_params;
349
26
350
26
  if (!pw1 || !pw2)
351
0
    goto error;
352
26
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
353
26
  if (equal_params < 0)
354
0
    goto error;
355
26
  if (equal_params)
356
26
    return fn(pw1, pw2);
357
0
  ctx = FN(PW,get_ctx)(pw1);
358
0
  if (!isl_space_has_named_params(pw1->dim) ||
359
0
      !isl_space_has_named_params(pw2->dim))
360
0
    isl_die(ctx, isl_error_invalid,
361
0
      "unaligned unnamed parameters", goto error);
362
0
  pw1 = FN(PW,align_params)(pw1, FN(PW,get_space)(pw2));
363
0
  pw2 = FN(PW,align_params)(pw2, FN(PW,get_space)(pw1));
364
0
  return fn(pw1, pw2);
365
0
error:
366
0
  FN(PW,free)(pw1);
367
0
  FN(PW,free)(pw2);
368
0
  return NULL;
369
0
}
370
371
static __isl_give PW *FN(PW,align_params_pw_set_and)(__isl_take PW *pw,
372
  __isl_take isl_set *set,
373
  __isl_give PW *(*fn)(__isl_take PW *pw, __isl_take isl_set *set))
374
50.9k
{
375
50.9k
  isl_ctx *ctx;
376
50.9k
  isl_bool aligned;
377
50.9k
378
50.9k
  if (!pw || !set)
379
0
    goto error;
380
50.9k
  aligned = isl_set_space_has_equal_params(set, pw->dim);
381
50.9k
  if (aligned < 0)
382
0
    goto error;
383
50.9k
  if (aligned)
384
50.9k
    return fn(pw, set);
385
2
  ctx = FN(PW,get_ctx)(pw);
386
2
  if (!isl_space_has_named_params(pw->dim) ||
387
2
      !isl_space_has_named_params(set->dim))
388
2
    
isl_die0
(ctx, isl_error_invalid,
389
2
      "unaligned unnamed parameters", goto error);
390
2
  pw = FN(PW,align_params)(pw, isl_set_get_space(set));
391
2
  set = isl_set_align_params(set, FN(PW,get_space)(pw));
392
2
  return fn(pw, set);
393
2
error:
394
0
  FN(PW,free)(pw);
395
0
  isl_set_free(set);
396
0
  return NULL;
397
2
}
isl_aff.c:isl_pw_aff_align_params_pw_set_and
Line
Count
Source
374
45.7k
{
375
45.7k
  isl_ctx *ctx;
376
45.7k
  isl_bool aligned;
377
45.7k
378
45.7k
  if (!pw || !set)
379
0
    goto error;
380
45.7k
  aligned = isl_set_space_has_equal_params(set, pw->dim);
381
45.7k
  if (aligned < 0)
382
0
    goto error;
383
45.7k
  if (aligned)
384
45.7k
    return fn(pw, set);
385
2
  ctx = FN(PW,get_ctx)(pw);
386
2
  if (!isl_space_has_named_params(pw->dim) ||
387
2
      !isl_space_has_named_params(set->dim))
388
2
    
isl_die0
(ctx, isl_error_invalid,
389
2
      "unaligned unnamed parameters", goto error);
390
2
  pw = FN(PW,align_params)(pw, isl_set_get_space(set));
391
2
  set = isl_set_align_params(set, FN(PW,get_space)(pw));
392
2
  return fn(pw, set);
393
2
error:
394
0
  FN(PW,free)(pw);
395
0
  isl_set_free(set);
396
0
  return NULL;
397
2
}
isl_aff.c:isl_pw_multi_aff_align_params_pw_set_and
Line
Count
Source
374
5.07k
{
375
5.07k
  isl_ctx *ctx;
376
5.07k
  isl_bool aligned;
377
5.07k
378
5.07k
  if (!pw || !set)
379
0
    goto error;
380
5.07k
  aligned = isl_set_space_has_equal_params(set, pw->dim);
381
5.07k
  if (aligned < 0)
382
0
    goto error;
383
5.07k
  if (aligned)
384
5.07k
    return fn(pw, set);
385
0
  ctx = FN(PW,get_ctx)(pw);
386
0
  if (!isl_space_has_named_params(pw->dim) ||
387
0
      !isl_space_has_named_params(set->dim))
388
0
    isl_die(ctx, isl_error_invalid,
389
0
      "unaligned unnamed parameters", goto error);
390
0
  pw = FN(PW,align_params)(pw, isl_set_get_space(set));
391
0
  set = isl_set_align_params(set, FN(PW,get_space)(pw));
392
0
  return fn(pw, set);
393
0
error:
394
0
  FN(PW,free)(pw);
395
0
  isl_set_free(set);
396
0
  return NULL;
397
0
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_align_params_pw_set_and
isl_polynomial.c:isl_pw_qpolynomial_align_params_pw_set_and
Line
Count
Source
374
39
{
375
39
  isl_ctx *ctx;
376
39
  isl_bool aligned;
377
39
378
39
  if (!pw || !set)
379
0
    goto error;
380
39
  aligned = isl_set_space_has_equal_params(set, pw->dim);
381
39
  if (aligned < 0)
382
0
    goto error;
383
39
  if (aligned)
384
39
    return fn(pw, set);
385
0
  ctx = FN(PW,get_ctx)(pw);
386
0
  if (!isl_space_has_named_params(pw->dim) ||
387
0
      !isl_space_has_named_params(set->dim))
388
0
    isl_die(ctx, isl_error_invalid,
389
0
      "unaligned unnamed parameters", goto error);
390
0
  pw = FN(PW,align_params)(pw, isl_set_get_space(set));
391
0
  set = isl_set_align_params(set, FN(PW,get_space)(pw));
392
0
  return fn(pw, set);
393
0
error:
394
0
  FN(PW,free)(pw);
395
0
  isl_set_free(set);
396
0
  return NULL;
397
0
}
398
#endif
399
400
static __isl_give PW *FN(PW,union_add_aligned)(__isl_take PW *pw1,
401
  __isl_take PW *pw2)
402
3.67k
{
403
3.67k
  int i, j, n;
404
3.67k
  struct PW *res;
405
3.67k
  isl_ctx *ctx;
406
3.67k
  isl_set *set;
407
3.67k
408
3.67k
  if (!pw1 || !pw2)
409
0
    goto error;
410
3.67k
411
3.67k
  ctx = isl_space_get_ctx(pw1->dim);
412
#ifdef HAS_TYPE
413
0
  if (pw1->type != pw2->type)
414
0
    isl_die(ctx, isl_error_invalid,
415
      "fold types don't match", goto error);
416
#endif
417
3.67k
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
418
0
419
3.67k
  if (FN(PW,IS_ZERO)(pw1)) {
420
3.16k
    FN(PW,free)(pw1);
421
3.16k
    return pw2;
422
3.16k
  }
423
507
424
507
  if (FN(PW,IS_ZERO)(pw2)) {
425
381
    FN(PW,free)(pw2);
426
381
    return pw1;
427
381
  }
428
126
429
126
  n = (pw1->n + 1) * (pw2->n + 1);
430
#ifdef HAS_TYPE
431
0
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->type, n);
432
#else
433
126
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), n);
434
#endif
435
436
286
  for (i = 0; i < pw1->n; 
++i160
) {
437
160
    set = isl_set_copy(pw1->p[i].set);
438
322
    for (j = 0; j < pw2->n; 
++j162
) {
439
162
      struct isl_set *common;
440
162
      EL *sum;
441
162
      common = isl_set_intersect(isl_set_copy(pw1->p[i].set),
442
162
            isl_set_copy(pw2->p[j].set));
443
162
      if (isl_set_plain_is_empty(common)) {
444
138
        isl_set_free(common);
445
138
        continue;
446
138
      }
447
24
      set = isl_set_subtract(set,
448
24
          isl_set_copy(pw2->p[j].set));
449
24
450
24
      sum = FN(EL,add_on_domain)(common,
451
24
               FN(EL,copy)(pw1->p[i].FIELD),
452
24
               FN(EL,copy)(pw2->p[j].FIELD));
453
24
454
24
      res = FN(PW,add_piece)(res, common, sum);
455
24
    }
456
160
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw1->p[i].FIELD));
457
160
  }
458
126
459
253
  for (j = 0; j < pw2->n; 
++j127
) {
460
127
    set = isl_set_copy(pw2->p[j].set);
461
289
    for (i = 0; i < pw1->n; 
++i162
)
462
162
      set = isl_set_subtract(set,
463
162
          isl_set_copy(pw1->p[i].set));
464
127
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw2->p[j].FIELD));
465
127
  }
466
126
467
126
  FN(PW,free)(pw1);
468
126
  FN(PW,free)(pw2);
469
126
470
126
  return res;
471
126
error:
472
0
  FN(PW,free)(pw1);
473
0
  FN(PW,free)(pw2);
474
0
  return NULL;
475
126
}
isl_aff.c:isl_pw_aff_union_add_aligned
Line
Count
Source
402
3.09k
{
403
3.09k
  int i, j, n;
404
3.09k
  struct PW *res;
405
3.09k
  isl_ctx *ctx;
406
3.09k
  isl_set *set;
407
3.09k
408
3.09k
  if (!pw1 || !pw2)
409
0
    goto error;
410
3.09k
411
3.09k
  ctx = isl_space_get_ctx(pw1->dim);
412
#ifdef HAS_TYPE
413
  if (pw1->type != pw2->type)
414
    isl_die(ctx, isl_error_invalid,
415
      "fold types don't match", goto error);
416
#endif
417
3.09k
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
418
3.09k
419
3.09k
  if (FN(PW,IS_ZERO)(pw1)) {
420
3.04k
    FN(PW,free)(pw1);
421
3.04k
    return pw2;
422
3.04k
  }
423
55
424
55
  if (FN(PW,IS_ZERO)(pw2)) {
425
0
    FN(PW,free)(pw2);
426
0
    return pw1;
427
0
  }
428
55
429
55
  n = (pw1->n + 1) * (pw2->n + 1);
430
#ifdef HAS_TYPE
431
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->type, n);
432
#else
433
55
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), n);
434
55
#endif
435
55
436
110
  for (i = 0; i < pw1->n; 
++i55
) {
437
55
    set = isl_set_copy(pw1->p[i].set);
438
110
    for (j = 0; j < pw2->n; 
++j55
) {
439
55
      struct isl_set *common;
440
55
      EL *sum;
441
55
      common = isl_set_intersect(isl_set_copy(pw1->p[i].set),
442
55
            isl_set_copy(pw2->p[j].set));
443
55
      if (isl_set_plain_is_empty(common)) {
444
55
        isl_set_free(common);
445
55
        continue;
446
55
      }
447
0
      set = isl_set_subtract(set,
448
0
          isl_set_copy(pw2->p[j].set));
449
0
450
0
      sum = FN(EL,add_on_domain)(common,
451
0
               FN(EL,copy)(pw1->p[i].FIELD),
452
0
               FN(EL,copy)(pw2->p[j].FIELD));
453
0
454
0
      res = FN(PW,add_piece)(res, common, sum);
455
0
    }
456
55
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw1->p[i].FIELD));
457
55
  }
458
55
459
110
  for (j = 0; j < pw2->n; 
++j55
) {
460
55
    set = isl_set_copy(pw2->p[j].set);
461
110
    for (i = 0; i < pw1->n; 
++i55
)
462
55
      set = isl_set_subtract(set,
463
55
          isl_set_copy(pw1->p[i].set));
464
55
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw2->p[j].FIELD));
465
55
  }
466
55
467
55
  FN(PW,free)(pw1);
468
55
  FN(PW,free)(pw2);
469
55
470
55
  return res;
471
55
error:
472
0
  FN(PW,free)(pw1);
473
0
  FN(PW,free)(pw2);
474
0
  return NULL;
475
55
}
isl_aff.c:isl_pw_multi_aff_union_add_aligned
Line
Count
Source
402
553
{
403
553
  int i, j, n;
404
553
  struct PW *res;
405
553
  isl_ctx *ctx;
406
553
  isl_set *set;
407
553
408
553
  if (!pw1 || !pw2)
409
0
    goto error;
410
553
411
553
  ctx = isl_space_get_ctx(pw1->dim);
412
#ifdef HAS_TYPE
413
  if (pw1->type != pw2->type)
414
    isl_die(ctx, isl_error_invalid,
415
      "fold types don't match", goto error);
416
#endif
417
553
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
418
553
419
553
  if (FN(PW,IS_ZERO)(pw1)) {
420
125
    FN(PW,free)(pw1);
421
125
    return pw2;
422
125
  }
423
428
424
428
  if (FN(PW,IS_ZERO)(pw2)) {
425
381
    FN(PW,free)(pw2);
426
381
    return pw1;
427
381
  }
428
47
429
47
  n = (pw1->n + 1) * (pw2->n + 1);
430
#ifdef HAS_TYPE
431
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->type, n);
432
#else
433
47
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), n);
434
47
#endif
435
47
436
127
  for (i = 0; i < pw1->n; 
++i80
) {
437
80
    set = isl_set_copy(pw1->p[i].set);
438
160
    for (j = 0; j < pw2->n; 
++j80
) {
439
80
      struct isl_set *common;
440
80
      EL *sum;
441
80
      common = isl_set_intersect(isl_set_copy(pw1->p[i].set),
442
80
            isl_set_copy(pw2->p[j].set));
443
80
      if (isl_set_plain_is_empty(common)) {
444
78
        isl_set_free(common);
445
78
        continue;
446
78
      }
447
2
      set = isl_set_subtract(set,
448
2
          isl_set_copy(pw2->p[j].set));
449
2
450
2
      sum = FN(EL,add_on_domain)(common,
451
2
               FN(EL,copy)(pw1->p[i].FIELD),
452
2
               FN(EL,copy)(pw2->p[j].FIELD));
453
2
454
2
      res = FN(PW,add_piece)(res, common, sum);
455
2
    }
456
80
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw1->p[i].FIELD));
457
80
  }
458
47
459
94
  for (j = 0; j < pw2->n; 
++j47
) {
460
47
    set = isl_set_copy(pw2->p[j].set);
461
127
    for (i = 0; i < pw1->n; 
++i80
)
462
80
      set = isl_set_subtract(set,
463
80
          isl_set_copy(pw1->p[i].set));
464
47
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw2->p[j].FIELD));
465
47
  }
466
47
467
47
  FN(PW,free)(pw1);
468
47
  FN(PW,free)(pw2);
469
47
470
47
  return res;
471
47
error:
472
0
  FN(PW,free)(pw1);
473
0
  FN(PW,free)(pw2);
474
0
  return NULL;
475
47
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_union_add_aligned
isl_polynomial.c:isl_pw_qpolynomial_union_add_aligned
Line
Count
Source
402
24
{
403
24
  int i, j, n;
404
24
  struct PW *res;
405
24
  isl_ctx *ctx;
406
24
  isl_set *set;
407
24
408
24
  if (!pw1 || !pw2)
409
0
    goto error;
410
24
411
24
  ctx = isl_space_get_ctx(pw1->dim);
412
#ifdef HAS_TYPE
413
  if (pw1->type != pw2->type)
414
    isl_die(ctx, isl_error_invalid,
415
      "fold types don't match", goto error);
416
#endif
417
24
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
418
24
419
24
  if (FN(PW,IS_ZERO)(pw1)) {
420
0
    FN(PW,free)(pw1);
421
0
    return pw2;
422
0
  }
423
24
424
24
  if (FN(PW,IS_ZERO)(pw2)) {
425
0
    FN(PW,free)(pw2);
426
0
    return pw1;
427
0
  }
428
24
429
24
  n = (pw1->n + 1) * (pw2->n + 1);
430
#ifdef HAS_TYPE
431
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->type, n);
432
#else
433
24
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), n);
434
24
#endif
435
24
436
49
  for (i = 0; i < pw1->n; 
++i25
) {
437
25
    set = isl_set_copy(pw1->p[i].set);
438
52
    for (j = 0; j < pw2->n; 
++j27
) {
439
27
      struct isl_set *common;
440
27
      EL *sum;
441
27
      common = isl_set_intersect(isl_set_copy(pw1->p[i].set),
442
27
            isl_set_copy(pw2->p[j].set));
443
27
      if (isl_set_plain_is_empty(common)) {
444
5
        isl_set_free(common);
445
5
        continue;
446
5
      }
447
22
      set = isl_set_subtract(set,
448
22
          isl_set_copy(pw2->p[j].set));
449
22
450
22
      sum = FN(EL,add_on_domain)(common,
451
22
               FN(EL,copy)(pw1->p[i].FIELD),
452
22
               FN(EL,copy)(pw2->p[j].FIELD));
453
22
454
22
      res = FN(PW,add_piece)(res, common, sum);
455
22
    }
456
25
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw1->p[i].FIELD));
457
25
  }
458
24
459
49
  for (j = 0; j < pw2->n; 
++j25
) {
460
25
    set = isl_set_copy(pw2->p[j].set);
461
52
    for (i = 0; i < pw1->n; 
++i27
)
462
27
      set = isl_set_subtract(set,
463
27
          isl_set_copy(pw1->p[i].set));
464
25
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw2->p[j].FIELD));
465
25
  }
466
24
467
24
  FN(PW,free)(pw1);
468
24
  FN(PW,free)(pw2);
469
24
470
24
  return res;
471
24
error:
472
0
  FN(PW,free)(pw1);
473
0
  FN(PW,free)(pw2);
474
0
  return NULL;
475
24
}
476
477
/* Private version of "union_add".  For isl_pw_qpolynomial and
478
 * isl_pw_qpolynomial_fold, we prefer to simply call it "add".
479
 */
480
static __isl_give PW *FN(PW,union_add_)(__isl_take PW *pw1, __isl_take PW *pw2)
481
3.67k
{
482
3.67k
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
483
3.67k
            &FN(PW,union_add_aligned));
484
3.67k
}
isl_aff.c:isl_pw_aff_union_add_
Line
Count
Source
481
3.09k
{
482
3.09k
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
483
3.09k
            &FN(PW,union_add_aligned));
484
3.09k
}
isl_aff.c:isl_pw_multi_aff_union_add_
Line
Count
Source
481
553
{
482
553
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
483
553
            &FN(PW,union_add_aligned));
484
553
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_union_add_
isl_polynomial.c:isl_pw_qpolynomial_union_add_
Line
Count
Source
481
24
{
482
24
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
483
24
            &FN(PW,union_add_aligned));
484
24
}
485
486
/* Make sure "pw" has room for at least "n" more pieces.
487
 *
488
 * If there is only one reference to pw, we extend it in place.
489
 * Otherwise, we create a new PW and copy the pieces.
490
 */
491
static __isl_give PW *FN(PW,grow)(__isl_take PW *pw, int n)
492
444
{
493
444
  int i;
494
444
  isl_ctx *ctx;
495
444
  PW *res;
496
444
497
444
  if (!pw)
498
0
    return NULL;
499
444
  if (pw->n + n <= pw->size)
500
0
    return pw;
501
444
  ctx = FN(PW,get_ctx)(pw);
502
444
  n += pw->n;
503
444
  if (pw->ref == 1) {
504
444
    res = isl_realloc(ctx, pw, struct PW,
505
444
          sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
506
444
    if (!res)
507
0
      return FN(PW,free)(pw);
508
444
    res->size = n;
509
444
    return res;
510
444
  }
511
#ifdef HAS_TYPE
512
0
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, n);
513
#else
514
0
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), n);
515
#endif
516
0
  if (!res)
517
0
    return FN(PW,free)(pw);
518
0
  for (i = 0; i < pw->n; ++i)
519
0
    res = FN(PW,add_piece)(res, isl_set_copy(pw->p[i].set),
520
0
              FN(EL,copy)(pw->p[i].FIELD));
521
0
  FN(PW,free)(pw);
522
0
  return res;
523
0
}
isl_aff.c:isl_pw_aff_grow
Line
Count
Source
492
348
{
493
348
  int i;
494
348
  isl_ctx *ctx;
495
348
  PW *res;
496
348
497
348
  if (!pw)
498
0
    return NULL;
499
348
  if (pw->n + n <= pw->size)
500
0
    return pw;
501
348
  ctx = FN(PW,get_ctx)(pw);
502
348
  n += pw->n;
503
348
  if (pw->ref == 1) {
504
348
    res = isl_realloc(ctx, pw, struct PW,
505
348
          sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
506
348
    if (!res)
507
0
      return FN(PW,free)(pw);
508
348
    res->size = n;
509
348
    return res;
510
348
  }
511
#ifdef HAS_TYPE
512
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, n);
513
#else
514
0
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), n);
515
0
#endif
516
0
  if (!res)
517
0
    return FN(PW,free)(pw);
518
0
  for (i = 0; i < pw->n; ++i)
519
0
    res = FN(PW,add_piece)(res, isl_set_copy(pw->p[i].set),
520
0
              FN(EL,copy)(pw->p[i].FIELD));
521
0
  FN(PW,free)(pw);
522
0
  return res;
523
0
}
isl_aff.c:isl_pw_multi_aff_grow
Line
Count
Source
492
95
{
493
95
  int i;
494
95
  isl_ctx *ctx;
495
95
  PW *res;
496
95
497
95
  if (!pw)
498
0
    return NULL;
499
95
  if (pw->n + n <= pw->size)
500
0
    return pw;
501
95
  ctx = FN(PW,get_ctx)(pw);
502
95
  n += pw->n;
503
95
  if (pw->ref == 1) {
504
95
    res = isl_realloc(ctx, pw, struct PW,
505
95
          sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
506
95
    if (!res)
507
0
      return FN(PW,free)(pw);
508
95
    res->size = n;
509
95
    return res;
510
95
  }
511
#ifdef HAS_TYPE
512
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, n);
513
#else
514
0
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), n);
515
0
#endif
516
0
  if (!res)
517
0
    return FN(PW,free)(pw);
518
0
  for (i = 0; i < pw->n; ++i)
519
0
    res = FN(PW,add_piece)(res, isl_set_copy(pw->p[i].set),
520
0
              FN(EL,copy)(pw->p[i].FIELD));
521
0
  FN(PW,free)(pw);
522
0
  return res;
523
0
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_grow
isl_polynomial.c:isl_pw_qpolynomial_grow
Line
Count
Source
492
1
{
493
1
  int i;
494
1
  isl_ctx *ctx;
495
1
  PW *res;
496
1
497
1
  if (!pw)
498
0
    return NULL;
499
1
  if (pw->n + n <= pw->size)
500
0
    return pw;
501
1
  ctx = FN(PW,get_ctx)(pw);
502
1
  n += pw->n;
503
1
  if (pw->ref == 1) {
504
1
    res = isl_realloc(ctx, pw, struct PW,
505
1
          sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
506
1
    if (!res)
507
0
      return FN(PW,free)(pw);
508
1
    res->size = n;
509
1
    return res;
510
1
  }
511
#ifdef HAS_TYPE
512
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, n);
513
#else
514
0
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), n);
515
0
#endif
516
0
  if (!res)
517
0
    return FN(PW,free)(pw);
518
0
  for (i = 0; i < pw->n; ++i)
519
0
    res = FN(PW,add_piece)(res, isl_set_copy(pw->p[i].set),
520
0
              FN(EL,copy)(pw->p[i].FIELD));
521
0
  FN(PW,free)(pw);
522
0
  return res;
523
0
}
524
525
static __isl_give PW *FN(PW,add_disjoint_aligned)(__isl_take PW *pw1,
526
  __isl_take PW *pw2)
527
8.47k
{
528
8.47k
  int i;
529
8.47k
  isl_ctx *ctx;
530
8.47k
531
8.47k
  if (!pw1 || !pw2)
532
0
    goto error;
533
8.47k
534
8.47k
  if (pw1->size < pw1->n + pw2->n && 
pw1->n < pw2->n4.35k
)
535
3.90k
    return FN(PW,add_disjoint_aligned)(pw2, pw1);
536
4.56k
537
4.56k
  ctx = isl_space_get_ctx(pw1->dim);
538
#ifdef HAS_TYPE
539
0
  if (pw1->type != pw2->type)
540
0
    isl_die(ctx, isl_error_invalid,
541
      "fold types don't match", goto error);
542
#endif
543
4.56k
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
544
0
545
4.56k
  if (FN(PW,IS_ZERO)(pw1)) {
546
191
    FN(PW,free)(pw1);
547
191
    return pw2;
548
191
  }
549
4.37k
550
4.37k
  if (FN(PW,IS_ZERO)(pw2)) {
551
3.93k
    FN(PW,free)(pw2);
552
3.93k
    return pw1;
553
3.93k
  }
554
444
555
444
  pw1 = FN(PW,grow)(pw1, pw2->n);
556
444
  if (!pw1)
557
0
    goto error;
558
444
559
888
  
for (i = 0; 444
i < pw2->n;
++i444
)
560
444
    pw1 = FN(PW,add_piece)(pw1,
561
444
        isl_set_copy(pw2->p[i].set),
562
444
        FN(EL,copy)(pw2->p[i].FIELD));
563
444
564
444
  FN(PW,free)(pw2);
565
444
566
444
  return pw1;
567
444
error:
568
0
  FN(PW,free)(pw1);
569
0
  FN(PW,free)(pw2);
570
0
  return NULL;
571
444
}
isl_aff.c:isl_pw_aff_add_disjoint_aligned
Line
Count
Source
527
565
{
528
565
  int i;
529
565
  isl_ctx *ctx;
530
565
531
565
  if (!pw1 || !pw2)
532
0
    goto error;
533
565
534
565
  if (pw1->size < pw1->n + pw2->n && 
pw1->n < pw2->n350
)
535
2
    return FN(PW,add_disjoint_aligned)(pw2, pw1);
536
563
537
563
  ctx = isl_space_get_ctx(pw1->dim);
538
#ifdef HAS_TYPE
539
  if (pw1->type != pw2->type)
540
    isl_die(ctx, isl_error_invalid,
541
      "fold types don't match", goto error);
542
#endif
543
563
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
544
563
545
563
  if (FN(PW,IS_ZERO)(pw1)) {
546
191
    FN(PW,free)(pw1);
547
191
    return pw2;
548
191
  }
549
372
550
372
  if (FN(PW,IS_ZERO)(pw2)) {
551
24
    FN(PW,free)(pw2);
552
24
    return pw1;
553
24
  }
554
348
555
348
  pw1 = FN(PW,grow)(pw1, pw2->n);
556
348
  if (!pw1)
557
0
    goto error;
558
348
559
696
  
for (i = 0; 348
i < pw2->n;
++i348
)
560
348
    pw1 = FN(PW,add_piece)(pw1,
561
348
        isl_set_copy(pw2->p[i].set),
562
348
        FN(EL,copy)(pw2->p[i].FIELD));
563
348
564
348
  FN(PW,free)(pw2);
565
348
566
348
  return pw1;
567
348
error:
568
0
  FN(PW,free)(pw1);
569
0
  FN(PW,free)(pw2);
570
0
  return NULL;
571
348
}
isl_aff.c:isl_pw_multi_aff_add_disjoint_aligned
Line
Count
Source
527
7.90k
{
528
7.90k
  int i;
529
7.90k
  isl_ctx *ctx;
530
7.90k
531
7.90k
  if (!pw1 || !pw2)
532
0
    goto error;
533
7.90k
534
7.90k
  if (pw1->size < pw1->n + pw2->n && 
pw1->n < pw2->n4.00k
)
535
3.90k
    return FN(PW,add_disjoint_aligned)(pw2, pw1);
536
4.00k
537
4.00k
  ctx = isl_space_get_ctx(pw1->dim);
538
#ifdef HAS_TYPE
539
  if (pw1->type != pw2->type)
540
    isl_die(ctx, isl_error_invalid,
541
      "fold types don't match", goto error);
542
#endif
543
4.00k
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
544
4.00k
545
4.00k
  if (FN(PW,IS_ZERO)(pw1)) {
546
0
    FN(PW,free)(pw1);
547
0
    return pw2;
548
0
  }
549
4.00k
550
4.00k
  if (FN(PW,IS_ZERO)(pw2)) {
551
3.90k
    FN(PW,free)(pw2);
552
3.90k
    return pw1;
553
3.90k
  }
554
95
555
95
  pw1 = FN(PW,grow)(pw1, pw2->n);
556
95
  if (!pw1)
557
0
    goto error;
558
95
559
190
  
for (i = 0; 95
i < pw2->n;
++i95
)
560
95
    pw1 = FN(PW,add_piece)(pw1,
561
95
        isl_set_copy(pw2->p[i].set),
562
95
        FN(EL,copy)(pw2->p[i].FIELD));
563
95
564
95
  FN(PW,free)(pw2);
565
95
566
95
  return pw1;
567
95
error:
568
0
  FN(PW,free)(pw1);
569
0
  FN(PW,free)(pw2);
570
0
  return NULL;
571
95
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_add_disjoint_aligned
isl_polynomial.c:isl_pw_qpolynomial_add_disjoint_aligned
Line
Count
Source
527
3
{
528
3
  int i;
529
3
  isl_ctx *ctx;
530
3
531
3
  if (!pw1 || !pw2)
532
0
    goto error;
533
3
534
3
  if (pw1->size < pw1->n + pw2->n && 
pw1->n < pw2->n2
)
535
1
    return FN(PW,add_disjoint_aligned)(pw2, pw1);
536
2
537
2
  ctx = isl_space_get_ctx(pw1->dim);
538
#ifdef HAS_TYPE
539
  if (pw1->type != pw2->type)
540
    isl_die(ctx, isl_error_invalid,
541
      "fold types don't match", goto error);
542
#endif
543
2
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
544
2
545
2
  if (FN(PW,IS_ZERO)(pw1)) {
546
0
    FN(PW,free)(pw1);
547
0
    return pw2;
548
0
  }
549
2
550
2
  if (FN(PW,IS_ZERO)(pw2)) {
551
1
    FN(PW,free)(pw2);
552
1
    return pw1;
553
1
  }
554
1
555
1
  pw1 = FN(PW,grow)(pw1, pw2->n);
556
1
  if (!pw1)
557
0
    goto error;
558
1
559
2
  
for (i = 0; 1
i < pw2->n;
++i1
)
560
1
    pw1 = FN(PW,add_piece)(pw1,
561
1
        isl_set_copy(pw2->p[i].set),
562
1
        FN(EL,copy)(pw2->p[i].FIELD));
563
1
564
1
  FN(PW,free)(pw2);
565
1
566
1
  return pw1;
567
1
error:
568
0
  FN(PW,free)(pw1);
569
0
  FN(PW,free)(pw2);
570
0
  return NULL;
571
1
}
572
573
__isl_give PW *FN(PW,add_disjoint)(__isl_take PW *pw1, __isl_take PW *pw2)
574
4.56k
{
575
4.56k
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
576
4.56k
            &FN(PW,add_disjoint_aligned));
577
4.56k
}
isl_pw_aff_add_disjoint
Line
Count
Source
574
563
{
575
563
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
576
563
            &FN(PW,add_disjoint_aligned));
577
563
}
isl_pw_multi_aff_add_disjoint
Line
Count
Source
574
4.00k
{
575
4.00k
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
576
4.00k
            &FN(PW,add_disjoint_aligned));
577
4.00k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_add_disjoint
isl_pw_qpolynomial_add_disjoint
Line
Count
Source
574
2
{
575
2
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
576
2
            &FN(PW,add_disjoint_aligned));
577
2
}
578
579
/* This function is currently only used from isl_aff.c
580
 */
581
static __isl_give PW *FN(PW,on_shared_domain_in)(__isl_take PW *pw1,
582
  __isl_take PW *pw2, __isl_take isl_space *space,
583
  __isl_give EL *(*fn)(__isl_take EL *el1, __isl_take EL *el2))
584
  __attribute__ ((unused));
585
586
/* Apply "fn" to pairs of elements from pw1 and pw2 on shared domains.
587
 * The result of "fn" (and therefore also of this function) lives in "space".
588
 */
589
static __isl_give PW *FN(PW,on_shared_domain_in)(__isl_take PW *pw1,
590
  __isl_take PW *pw2, __isl_take isl_space *space,
591
  __isl_give EL *(*fn)(__isl_take EL *el1, __isl_take EL *el2))
592
75.1k
{
593
75.1k
  int i, j, n;
594
75.1k
  PW *res = NULL;
595
75.1k
596
75.1k
  if (!pw1 || !pw2)
597
0
    goto error;
598
75.1k
599
75.1k
  n = pw1->n * pw2->n;
600
#ifdef HAS_TYPE
601
  res = FN(PW,alloc_size)(isl_space_copy(space), pw1->type, n);
602
#else
603
75.1k
  res = FN(PW,alloc_size)(isl_space_copy(space), n);
604
75.1k
#endif
605
75.1k
606
152k
  for (i = 0; i < pw1->n; 
++i77.4k
) {
607
158k
    for (j = 0; j < pw2->n; 
++j80.6k
) {
608
80.6k
      isl_set *common;
609
80.6k
      EL *res_ij;
610
80.6k
      int empty;
611
80.6k
612
80.6k
      common = isl_set_intersect(
613
80.6k
          isl_set_copy(pw1->p[i].set),
614
80.6k
          isl_set_copy(pw2->p[j].set));
615
80.6k
      empty = isl_set_plain_is_empty(common);
616
80.6k
      if (empty < 0 || empty) {
617
2.96k
        isl_set_free(common);
618
2.96k
        if (empty < 0)
619
0
          goto error;
620
2.96k
        continue;
621
2.96k
      }
622
77.6k
623
77.6k
      res_ij = fn(FN(EL,copy)(pw1->p[i].FIELD),
624
77.6k
            FN(EL,copy)(pw2->p[j].FIELD));
625
77.6k
      res_ij = FN(EL,gist)(res_ij, isl_set_copy(common));
626
77.6k
627
77.6k
      res = FN(PW,add_piece)(res, common, res_ij);
628
77.6k
    }
629
77.4k
  }
630
75.1k
631
75.1k
  isl_space_free(space);
632
75.1k
  FN(PW,free)(pw1);
633
75.1k
  FN(PW,free)(pw2);
634
75.1k
  return res;
635
75.1k
error:
636
0
  isl_space_free(space);
637
0
  FN(PW,free)(pw1);
638
0
  FN(PW,free)(pw2);
639
0
  FN(PW,free)(res);
640
0
  return NULL;
641
75.1k
}
isl_aff.c:isl_pw_aff_on_shared_domain_in
Line
Count
Source
592
74.9k
{
593
74.9k
  int i, j, n;
594
74.9k
  PW *res = NULL;
595
74.9k
596
74.9k
  if (!pw1 || !pw2)
597
0
    goto error;
598
74.9k
599
74.9k
  n = pw1->n * pw2->n;
600
#ifdef HAS_TYPE
601
  res = FN(PW,alloc_size)(isl_space_copy(space), pw1->type, n);
602
#else
603
74.9k
  res = FN(PW,alloc_size)(isl_space_copy(space), n);
604
74.9k
#endif
605
74.9k
606
152k
  for (i = 0; i < pw1->n; 
++i77.2k
) {
607
157k
    for (j = 0; j < pw2->n; 
++j80.4k
) {
608
80.4k
      isl_set *common;
609
80.4k
      EL *res_ij;
610
80.4k
      int empty;
611
80.4k
612
80.4k
      common = isl_set_intersect(
613
80.4k
          isl_set_copy(pw1->p[i].set),
614
80.4k
          isl_set_copy(pw2->p[j].set));
615
80.4k
      empty = isl_set_plain_is_empty(common);
616
80.4k
      if (empty < 0 || empty) {
617
2.96k
        isl_set_free(common);
618
2.96k
        if (empty < 0)
619
0
          goto error;
620
2.96k
        continue;
621
2.96k
      }
622
77.4k
623
77.4k
      res_ij = fn(FN(EL,copy)(pw1->p[i].FIELD),
624
77.4k
            FN(EL,copy)(pw2->p[j].FIELD));
625
77.4k
      res_ij = FN(EL,gist)(res_ij, isl_set_copy(common));
626
77.4k
627
77.4k
      res = FN(PW,add_piece)(res, common, res_ij);
628
77.4k
    }
629
77.2k
  }
630
74.9k
631
74.9k
  isl_space_free(space);
632
74.9k
  FN(PW,free)(pw1);
633
74.9k
  FN(PW,free)(pw2);
634
74.9k
  return res;
635
74.9k
error:
636
0
  isl_space_free(space);
637
0
  FN(PW,free)(pw1);
638
0
  FN(PW,free)(pw2);
639
0
  FN(PW,free)(res);
640
0
  return NULL;
641
74.9k
}
isl_aff.c:isl_pw_multi_aff_on_shared_domain_in
Line
Count
Source
592
168
{
593
168
  int i, j, n;
594
168
  PW *res = NULL;
595
168
596
168
  if (!pw1 || !pw2)
597
0
    goto error;
598
168
599
168
  n = pw1->n * pw2->n;
600
#ifdef HAS_TYPE
601
  res = FN(PW,alloc_size)(isl_space_copy(space), pw1->type, n);
602
#else
603
168
  res = FN(PW,alloc_size)(isl_space_copy(space), n);
604
168
#endif
605
168
606
336
  for (i = 0; i < pw1->n; 
++i168
) {
607
339
    for (j = 0; j < pw2->n; 
++j171
) {
608
171
      isl_set *common;
609
171
      EL *res_ij;
610
171
      int empty;
611
171
612
171
      common = isl_set_intersect(
613
171
          isl_set_copy(pw1->p[i].set),
614
171
          isl_set_copy(pw2->p[j].set));
615
171
      empty = isl_set_plain_is_empty(common);
616
171
      if (empty < 0 || empty) {
617
0
        isl_set_free(common);
618
0
        if (empty < 0)
619
0
          goto error;
620
0
        continue;
621
0
      }
622
171
623
171
      res_ij = fn(FN(EL,copy)(pw1->p[i].FIELD),
624
171
            FN(EL,copy)(pw2->p[j].FIELD));
625
171
      res_ij = FN(EL,gist)(res_ij, isl_set_copy(common));
626
171
627
171
      res = FN(PW,add_piece)(res, common, res_ij);
628
171
    }
629
168
  }
630
168
631
168
  isl_space_free(space);
632
168
  FN(PW,free)(pw1);
633
168
  FN(PW,free)(pw2);
634
168
  return res;
635
168
error:
636
0
  isl_space_free(space);
637
0
  FN(PW,free)(pw1);
638
0
  FN(PW,free)(pw2);
639
0
  FN(PW,free)(res);
640
0
  return NULL;
641
168
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_on_shared_domain_in
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_on_shared_domain_in
642
643
/* This function is currently only used from isl_aff.c
644
 */
645
static __isl_give PW *FN(PW,on_shared_domain)(__isl_take PW *pw1,
646
  __isl_take PW *pw2,
647
  __isl_give EL *(*fn)(__isl_take EL *el1, __isl_take EL *el2))
648
  __attribute__ ((unused));
649
650
/* Apply "fn" to pairs of elements from pw1 and pw2 on shared domains.
651
 * The result of "fn" is assumed to live in the same space as "pw1" and "pw2".
652
 */
653
static __isl_give PW *FN(PW,on_shared_domain)(__isl_take PW *pw1,
654
  __isl_take PW *pw2,
655
  __isl_give EL *(*fn)(__isl_take EL *el1, __isl_take EL *el2))
656
74.9k
{
657
74.9k
  isl_space *space;
658
74.9k
659
74.9k
  if (!pw1 || !pw2)
660
0
    goto error;
661
74.9k
662
74.9k
  space = isl_space_copy(pw1->dim);
663
74.9k
  return FN(PW,on_shared_domain_in)(pw1, pw2, space, fn);
664
74.9k
error:
665
0
  FN(PW,free)(pw1);
666
0
  FN(PW,free)(pw2);
667
0
  return NULL;
668
74.9k
}
isl_aff.c:isl_pw_aff_on_shared_domain
Line
Count
Source
656
74.9k
{
657
74.9k
  isl_space *space;
658
74.9k
659
74.9k
  if (!pw1 || !pw2)
660
0
    goto error;
661
74.9k
662
74.9k
  space = isl_space_copy(pw1->dim);
663
74.9k
  return FN(PW,on_shared_domain_in)(pw1, pw2, space, fn);
664
74.9k
error:
665
0
  FN(PW,free)(pw1);
666
0
  FN(PW,free)(pw2);
667
0
  return NULL;
668
74.9k
}
isl_aff.c:isl_pw_multi_aff_on_shared_domain
Line
Count
Source
656
1
{
657
1
  isl_space *space;
658
1
659
1
  if (!pw1 || !pw2)
660
0
    goto error;
661
1
662
1
  space = isl_space_copy(pw1->dim);
663
1
  return FN(PW,on_shared_domain_in)(pw1, pw2, space, fn);
664
1
error:
665
0
  FN(PW,free)(pw1);
666
0
  FN(PW,free)(pw2);
667
0
  return NULL;
668
1
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_on_shared_domain
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_on_shared_domain
669
670
#ifndef NO_NEG
671
__isl_give PW *FN(PW,neg)(__isl_take PW *pw)
672
23.3k
{
673
23.3k
  int i;
674
23.3k
675
23.3k
  if (!pw)
676
0
    return NULL;
677
23.3k
678
23.3k
  if (FN(PW,IS_ZERO)(pw))
679
0
    return pw;
680
23.3k
681
23.3k
  pw = FN(PW,cow)(pw);
682
23.3k
  if (!pw)
683
0
    return NULL;
684
23.3k
685
47.4k
  
for (i = 0; 23.3k
i < pw->n;
++i24.1k
) {
686
24.1k
    pw->p[i].FIELD = FN(EL,neg)(pw->p[i].FIELD);
687
24.1k
    if (!pw->p[i].FIELD)
688
24.1k
      
return 0
FN0
(PW,free)(pw);
689
24.1k
  }
690
23.3k
691
23.3k
  return pw;
692
23.3k
}
isl_pw_aff_neg
Line
Count
Source
672
23.3k
{
673
23.3k
  int i;
674
23.3k
675
23.3k
  if (!pw)
676
0
    return NULL;
677
23.3k
678
23.3k
  if (FN(PW,IS_ZERO)(pw))
679
0
    return pw;
680
23.3k
681
23.3k
  pw = FN(PW,cow)(pw);
682
23.3k
  if (!pw)
683
0
    return NULL;
684
23.3k
685
47.4k
  
for (i = 0; 23.3k
i < pw->n;
++i24.0k
) {
686
24.0k
    pw->p[i].FIELD = FN(EL,neg)(pw->p[i].FIELD);
687
24.0k
    if (!pw->p[i].FIELD)
688
24.0k
      
return 0
FN0
(PW,free)(pw);
689
24.0k
  }
690
23.3k
691
23.3k
  return pw;
692
23.3k
}
Unexecuted instantiation: isl_pw_multi_aff_neg
isl_pw_qpolynomial_neg
Line
Count
Source
672
11
{
673
11
  int i;
674
11
675
11
  if (!pw)
676
0
    return NULL;
677
11
678
11
  if (FN(PW,IS_ZERO)(pw))
679
0
    return pw;
680
11
681
11
  pw = FN(PW,cow)(pw);
682
11
  if (!pw)
683
0
    return NULL;
684
11
685
23
  
for (i = 0; 11
i < pw->n;
++i12
) {
686
12
    pw->p[i].FIELD = FN(EL,neg)(pw->p[i].FIELD);
687
12
    if (!pw->p[i].FIELD)
688
12
      
return 0
FN0
(PW,free)(pw);
689
12
  }
690
11
691
11
  return pw;
692
11
}
693
#endif
694
695
#ifndef NO_SUB
696
__isl_give PW *FN(PW,sub)(__isl_take PW *pw1, __isl_take PW *pw2)
697
6.87k
{
698
6.87k
  return FN(PW,add)(pw1, FN(PW,neg)(pw2));
699
6.87k
}
isl_pw_aff_sub
Line
Count
Source
697
6.86k
{
698
6.86k
  return FN(PW,add)(pw1, FN(PW,neg)(pw2));
699
6.86k
}
isl_pw_qpolynomial_sub
Line
Count
Source
697
9
{
698
9
  return FN(PW,add)(pw1, FN(PW,neg)(pw2));
699
9
}
700
#endif
701
702
#ifndef NO_EVAL
703
__isl_give isl_val *FN(PW,eval)(__isl_take PW *pw, __isl_take isl_point *pnt)
704
1
{
705
1
  int i;
706
1
  int found = 0;
707
1
  isl_ctx *ctx;
708
1
  isl_space *pnt_dim = NULL;
709
1
  isl_val *v;
710
1
711
1
  if (!pw || !pnt)
712
0
    goto error;
713
1
  ctx = isl_point_get_ctx(pnt);
714
1
  pnt_dim = isl_point_get_space(pnt);
715
1
  isl_assert(ctx, isl_space_is_domain_internal(pnt_dim, pw->dim),
716
1
        goto error);
717
1
718
1
  for (i = 0; i < pw->n; 
++i0
) {
719
1
    found = isl_set_contains_point(pw->p[i].set, pnt);
720
1
    if (found < 0)
721
0
      goto error;
722
1
    if (found)
723
1
      break;
724
1
  }
725
1
  if (found)
726
1
    v = FN(EL,eval)(FN(EL,copy)(pw->p[i].FIELD),
727
1
              isl_point_copy(pnt));
728
0
  else
729
0
    v = isl_val_zero(ctx);
730
1
  FN(PW,free)(pw);
731
1
  isl_space_free(pnt_dim);
732
1
  isl_point_free(pnt);
733
1
  return v;
734
1
error:
735
0
  FN(PW,free)(pw);
736
0
  isl_space_free(pnt_dim);
737
0
  isl_point_free(pnt);
738
0
  return NULL;
739
1
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_eval
isl_pw_qpolynomial_eval
Line
Count
Source
704
1
{
705
1
  int i;
706
1
  int found = 0;
707
1
  isl_ctx *ctx;
708
1
  isl_space *pnt_dim = NULL;
709
1
  isl_val *v;
710
1
711
1
  if (!pw || !pnt)
712
0
    goto error;
713
1
  ctx = isl_point_get_ctx(pnt);
714
1
  pnt_dim = isl_point_get_space(pnt);
715
1
  isl_assert(ctx, isl_space_is_domain_internal(pnt_dim, pw->dim),
716
1
        goto error);
717
1
718
1
  for (i = 0; i < pw->n; 
++i0
) {
719
1
    found = isl_set_contains_point(pw->p[i].set, pnt);
720
1
    if (found < 0)
721
0
      goto error;
722
1
    if (found)
723
1
      break;
724
1
  }
725
1
  if (found)
726
1
    v = FN(EL,eval)(FN(EL,copy)(pw->p[i].FIELD),
727
1
              isl_point_copy(pnt));
728
0
  else
729
0
    v = isl_val_zero(ctx);
730
1
  FN(PW,free)(pw);
731
1
  isl_space_free(pnt_dim);
732
1
  isl_point_free(pnt);
733
1
  return v;
734
1
error:
735
0
  FN(PW,free)(pw);
736
0
  isl_space_free(pnt_dim);
737
0
  isl_point_free(pnt);
738
0
  return NULL;
739
1
}
740
#endif
741
742
/* Return the parameter domain of "pw".
743
 */
744
__isl_give isl_set *FN(PW,params)(__isl_take PW *pw)
745
0
{
746
0
  return isl_set_params(FN(PW,domain)(pw));
747
0
}
Unexecuted instantiation: isl_pw_aff_params
Unexecuted instantiation: isl_pw_multi_aff_params
Unexecuted instantiation: isl_pw_qpolynomial_fold_params
Unexecuted instantiation: isl_pw_qpolynomial_params
748
749
__isl_give isl_set *FN(PW,domain)(__isl_take PW *pw)
750
54.1k
{
751
54.1k
  int i;
752
54.1k
  isl_set *dom;
753
54.1k
754
54.1k
  if (!pw)
755
0
    return NULL;
756
54.1k
757
54.1k
  dom = isl_set_empty(FN(PW,get_domain_space)(pw));
758
109k
  for (i = 0; i < pw->n; 
++i55.7k
)
759
55.7k
    dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
760
54.1k
761
54.1k
  FN(PW,free)(pw);
762
54.1k
763
54.1k
  return dom;
764
54.1k
}
isl_pw_aff_domain
Line
Count
Source
750
53.2k
{
751
53.2k
  int i;
752
53.2k
  isl_set *dom;
753
53.2k
754
53.2k
  if (!pw)
755
0
    return NULL;
756
53.2k
757
53.2k
  dom = isl_set_empty(FN(PW,get_domain_space)(pw));
758
107k
  for (i = 0; i < pw->n; 
++i54.7k
)
759
54.7k
    dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
760
53.2k
761
53.2k
  FN(PW,free)(pw);
762
53.2k
763
53.2k
  return dom;
764
53.2k
}
isl_pw_multi_aff_domain
Line
Count
Source
750
906
{
751
906
  int i;
752
906
  isl_set *dom;
753
906
754
906
  if (!pw)
755
0
    return NULL;
756
906
757
906
  dom = isl_set_empty(FN(PW,get_domain_space)(pw));
758
1.83k
  for (i = 0; i < pw->n; 
++i930
)
759
930
    dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
760
906
761
906
  FN(PW,free)(pw);
762
906
763
906
  return dom;
764
906
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_domain
isl_pw_qpolynomial_domain
Line
Count
Source
750
1
{
751
1
  int i;
752
1
  isl_set *dom;
753
1
754
1
  if (!pw)
755
0
    return NULL;
756
1
757
1
  dom = isl_set_empty(FN(PW,get_domain_space)(pw));
758
2
  for (i = 0; i < pw->n; 
++i1
)
759
1
    dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
760
1
761
1
  FN(PW,free)(pw);
762
1
763
1
  return dom;
764
1
}
765
766
/* Exploit the equalities in the domain of piece "i" of "pw"
767
 * to simplify the associated function.
768
 * If the domain of piece "i" is empty, then remove it entirely,
769
 * replacing it with the final piece.
770
 */
771
static int FN(PW,exploit_equalities_and_remove_if_empty)(__isl_keep PW *pw,
772
  int i)
773
38.5k
{
774
38.5k
  isl_basic_set *aff;
775
38.5k
  int empty = isl_set_plain_is_empty(pw->p[i].set);
776
38.5k
777
38.5k
  if (empty < 0)
778
0
    return -1;
779
38.5k
  if (empty) {
780
25
    isl_set_free(pw->p[i].set);
781
25
    FN(EL,free)(pw->p[i].FIELD);
782
25
    if (i != pw->n - 1)
783
0
      pw->p[i] = pw->p[pw->n - 1];
784
25
    pw->n--;
785
25
786
25
    return 0;
787
25
  }
788
38.5k
789
38.5k
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
790
38.5k
  pw->p[i].FIELD = FN(EL,substitute_equalities)(pw->p[i].FIELD, aff);
791
38.5k
  if (!pw->p[i].FIELD)
792
38.5k
    
return -10
;
793
38.5k
794
38.5k
  return 0;
795
38.5k
}
isl_aff.c:isl_pw_aff_exploit_equalities_and_remove_if_empty
Line
Count
Source
773
35.5k
{
774
35.5k
  isl_basic_set *aff;
775
35.5k
  int empty = isl_set_plain_is_empty(pw->p[i].set);
776
35.5k
777
35.5k
  if (empty < 0)
778
0
    return -1;
779
35.5k
  if (empty) {
780
20
    isl_set_free(pw->p[i].set);
781
20
    FN(EL,free)(pw->p[i].FIELD);
782
20
    if (i != pw->n - 1)
783
0
      pw->p[i] = pw->p[pw->n - 1];
784
20
    pw->n--;
785
20
786
20
    return 0;
787
20
  }
788
35.5k
789
35.5k
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
790
35.5k
  pw->p[i].FIELD = FN(EL,substitute_equalities)(pw->p[i].FIELD, aff);
791
35.5k
  if (!pw->p[i].FIELD)
792
35.5k
    
return -10
;
793
35.5k
794
35.5k
  return 0;
795
35.5k
}
isl_aff.c:isl_pw_multi_aff_exploit_equalities_and_remove_if_empty
Line
Count
Source
773
2.95k
{
774
2.95k
  isl_basic_set *aff;
775
2.95k
  int empty = isl_set_plain_is_empty(pw->p[i].set);
776
2.95k
777
2.95k
  if (empty < 0)
778
0
    return -1;
779
2.95k
  if (empty) {
780
5
    isl_set_free(pw->p[i].set);
781
5
    FN(EL,free)(pw->p[i].FIELD);
782
5
    if (i != pw->n - 1)
783
0
      pw->p[i] = pw->p[pw->n - 1];
784
5
    pw->n--;
785
5
786
5
    return 0;
787
5
  }
788
2.95k
789
2.95k
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
790
2.95k
  pw->p[i].FIELD = FN(EL,substitute_equalities)(pw->p[i].FIELD, aff);
791
2.95k
  if (!pw->p[i].FIELD)
792
2.95k
    
return -10
;
793
2.95k
794
2.95k
  return 0;
795
2.95k
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_exploit_equalities_and_remove_if_empty
isl_polynomial.c:isl_pw_qpolynomial_exploit_equalities_and_remove_if_empty
Line
Count
Source
773
35
{
774
35
  isl_basic_set *aff;
775
35
  int empty = isl_set_plain_is_empty(pw->p[i].set);
776
35
777
35
  if (empty < 0)
778
0
    return -1;
779
35
  if (empty) {
780
0
    isl_set_free(pw->p[i].set);
781
0
    FN(EL,free)(pw->p[i].FIELD);
782
0
    if (i != pw->n - 1)
783
0
      pw->p[i] = pw->p[pw->n - 1];
784
0
    pw->n--;
785
0
786
0
    return 0;
787
0
  }
788
35
789
35
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
790
35
  pw->p[i].FIELD = FN(EL,substitute_equalities)(pw->p[i].FIELD, aff);
791
35
  if (!pw->p[i].FIELD)
792
35
    
return -10
;
793
35
794
35
  return 0;
795
35
}
796
797
/* Convert a piecewise expression defined over a parameter domain
798
 * into one that is defined over a zero-dimensional set.
799
 */
800
__isl_give PW *FN(PW,from_range)(__isl_take PW *pw)
801
4
{
802
4
  isl_space *space;
803
4
804
4
  if (!pw)
805
0
    return NULL;
806
4
  if (!isl_space_is_set(pw->dim))
807
4
    
isl_die0
(FN(PW,get_ctx)(pw), isl_error_invalid,
808
4
      "not living in a set space", return FN(PW,free)(pw));
809
4
810
4
  space = FN(PW,get_space)(pw);
811
4
  space = isl_space_from_range(space);
812
4
  pw = FN(PW,reset_space)(pw, space);
813
4
814
4
  return pw;
815
4
}
isl_pw_aff_from_range
Line
Count
Source
801
4
{
802
4
  isl_space *space;
803
4
804
4
  if (!pw)
805
0
    return NULL;
806
4
  if (!isl_space_is_set(pw->dim))
807
4
    
isl_die0
(FN(PW,get_ctx)(pw), isl_error_invalid,
808
4
      "not living in a set space", return FN(PW,free)(pw));
809
4
810
4
  space = FN(PW,get_space)(pw);
811
4
  space = isl_space_from_range(space);
812
4
  pw = FN(PW,reset_space)(pw, space);
813
4
814
4
  return pw;
815
4
}
Unexecuted instantiation: isl_pw_multi_aff_from_range
Unexecuted instantiation: isl_pw_qpolynomial_fold_from_range
Unexecuted instantiation: isl_pw_qpolynomial_from_range
816
817
/* Fix the value of the given parameter or domain dimension of "pw"
818
 * to be equal to "value".
819
 */
820
__isl_give PW *FN(PW,fix_si)(__isl_take PW *pw, enum isl_dim_type type,
821
  unsigned pos, int value)
822
0
{
823
0
  int i;
824
0
825
0
  if (!pw)
826
0
    return NULL;
827
0
828
0
  if (type == isl_dim_out)
829
0
    isl_die(FN(PW,get_ctx)(pw), isl_error_invalid,
830
0
      "cannot fix output dimension", return FN(PW,free)(pw));
831
0
832
0
  if (pw->n == 0)
833
0
    return pw;
834
0
835
0
  if (type == isl_dim_in)
836
0
    type = isl_dim_set;
837
0
838
0
  pw = FN(PW,cow)(pw);
839
0
  if (!pw)
840
0
    return FN(PW,free)(pw);
841
0
842
0
  for (i = pw->n - 1; i >= 0; --i) {
843
0
    pw->p[i].set = isl_set_fix_si(pw->p[i].set, type, pos, value);
844
0
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
845
0
      return FN(PW,free)(pw);
846
0
  }
847
0
848
0
  return pw;
849
0
}
Unexecuted instantiation: isl_pw_aff_fix_si
Unexecuted instantiation: isl_pw_multi_aff_fix_si
Unexecuted instantiation: isl_pw_qpolynomial_fold_fix_si
Unexecuted instantiation: isl_pw_qpolynomial_fix_si
850
851
/* Restrict the domain of "pw" by combining each cell
852
 * with "set" through a call to "fn", where "fn" may be
853
 * isl_set_intersect, isl_set_intersect_params or isl_set_subtract.
854
 */
855
static __isl_give PW *FN(PW,restrict_domain_aligned)(__isl_take PW *pw,
856
  __isl_take isl_set *set,
857
  __isl_give isl_set *(*fn)(__isl_take isl_set *set1,
858
            __isl_take isl_set *set2))
859
37.2k
{
860
37.2k
  int i;
861
37.2k
862
37.2k
  if (!pw || !set)
863
0
    goto error;
864
37.2k
865
37.2k
  if (pw->n == 0) {
866
3
    isl_set_free(set);
867
3
    return pw;
868
3
  }
869
37.2k
870
37.2k
  pw = FN(PW,cow)(pw);
871
37.2k
  if (!pw)
872
0
    goto error;
873
37.2k
874
75.8k
  
for (i = pw->n - 1; 37.2k
i >= 0;
--i38.5k
) {
875
38.5k
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
876
38.5k
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
877
0
      goto error;
878
38.5k
  }
879
37.2k
  
880
37.2k
  isl_set_free(set);
881
37.2k
  return pw;
882
37.2k
error:
883
0
  isl_set_free(set);
884
0
  FN(PW,free)(pw);
885
0
  return NULL;
886
37.2k
}
isl_aff.c:isl_pw_aff_restrict_domain_aligned
Line
Count
Source
859
34.3k
{
860
34.3k
  int i;
861
34.3k
862
34.3k
  if (!pw || !set)
863
0
    goto error;
864
34.3k
865
34.3k
  if (pw->n == 0) {
866
0
    isl_set_free(set);
867
0
    return pw;
868
0
  }
869
34.3k
870
34.3k
  pw = FN(PW,cow)(pw);
871
34.3k
  if (!pw)
872
0
    goto error;
873
34.3k
874
69.8k
  
for (i = pw->n - 1; 34.3k
i >= 0;
--i35.5k
) {
875
35.5k
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
876
35.5k
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
877
0
      goto error;
878
35.5k
  }
879
34.3k
  
880
34.3k
  isl_set_free(set);
881
34.3k
  return pw;
882
34.3k
error:
883
0
  isl_set_free(set);
884
0
  FN(PW,free)(pw);
885
0
  return NULL;
886
34.3k
}
isl_aff.c:isl_pw_multi_aff_restrict_domain_aligned
Line
Count
Source
859
2.92k
{
860
2.92k
  int i;
861
2.92k
862
2.92k
  if (!pw || !set)
863
0
    goto error;
864
2.92k
865
2.92k
  if (pw->n == 0) {
866
2
    isl_set_free(set);
867
2
    return pw;
868
2
  }
869
2.92k
870
2.92k
  pw = FN(PW,cow)(pw);
871
2.92k
  if (!pw)
872
0
    goto error;
873
2.92k
874
5.88k
  
for (i = pw->n - 1; 2.92k
i >= 0;
--i2.95k
) {
875
2.95k
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
876
2.95k
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
877
0
      goto error;
878
2.95k
  }
879
2.92k
  
880
2.92k
  isl_set_free(set);
881
2.92k
  return pw;
882
2.92k
error:
883
0
  isl_set_free(set);
884
0
  FN(PW,free)(pw);
885
0
  return NULL;
886
2.92k
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_restrict_domain_aligned
isl_polynomial.c:isl_pw_qpolynomial_restrict_domain_aligned
Line
Count
Source
859
35
{
860
35
  int i;
861
35
862
35
  if (!pw || !set)
863
0
    goto error;
864
35
865
35
  if (pw->n == 0) {
866
1
    isl_set_free(set);
867
1
    return pw;
868
1
  }
869
34
870
34
  pw = FN(PW,cow)(pw);
871
34
  if (!pw)
872
0
    goto error;
873
34
874
68
  
for (i = pw->n - 1; 34
i >= 0;
--i34
) {
875
34
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
876
34
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
877
0
      goto error;
878
34
  }
879
34
  
880
34
  isl_set_free(set);
881
34
  return pw;
882
34
error:
883
0
  isl_set_free(set);
884
0
  FN(PW,free)(pw);
885
0
  return NULL;
886
34
}
887
888
static __isl_give PW *FN(PW,intersect_domain_aligned)(__isl_take PW *pw,
889
  __isl_take isl_set *set)
890
36.6k
{
891
36.6k
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
892
36.6k
}
isl_aff.c:isl_pw_aff_intersect_domain_aligned
Line
Count
Source
890
34.3k
{
891
34.3k
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
892
34.3k
}
isl_aff.c:isl_pw_multi_aff_intersect_domain_aligned
Line
Count
Source
890
2.25k
{
891
2.25k
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
892
2.25k
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_intersect_domain_aligned
isl_polynomial.c:isl_pw_qpolynomial_intersect_domain_aligned
Line
Count
Source
890
35
{
891
35
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
892
35
}
893
894
__isl_give PW *FN(PW,intersect_domain)(__isl_take PW *pw,
895
  __isl_take isl_set *context)
896
36.6k
{
897
36.6k
  return FN(PW,align_params_pw_set_and)(pw, context,
898
36.6k
          &FN(PW,intersect_domain_aligned));
899
36.6k
}
isl_pw_aff_intersect_domain
Line
Count
Source
896
34.3k
{
897
34.3k
  return FN(PW,align_params_pw_set_and)(pw, context,
898
34.3k
          &FN(PW,intersect_domain_aligned));
899
34.3k
}
isl_pw_multi_aff_intersect_domain
Line
Count
Source
896
2.25k
{
897
2.25k
  return FN(PW,align_params_pw_set_and)(pw, context,
898
2.25k
          &FN(PW,intersect_domain_aligned));
899
2.25k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_intersect_domain
isl_pw_qpolynomial_intersect_domain
Line
Count
Source
896
35
{
897
35
  return FN(PW,align_params_pw_set_and)(pw, context,
898
35
          &FN(PW,intersect_domain_aligned));
899
35
}
900
901
static __isl_give PW *FN(PW,intersect_params_aligned)(__isl_take PW *pw,
902
  __isl_take isl_set *set)
903
674
{
904
674
  return FN(PW,restrict_domain_aligned)(pw, set,
905
674
          &isl_set_intersect_params);
906
674
}
Unexecuted instantiation: isl_aff.c:isl_pw_aff_intersect_params_aligned
isl_aff.c:isl_pw_multi_aff_intersect_params_aligned
Line
Count
Source
903
674
{
904
674
  return FN(PW,restrict_domain_aligned)(pw, set,
905
674
          &isl_set_intersect_params);
906
674
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_intersect_params_aligned
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_intersect_params_aligned
907
908
/* Intersect the domain of "pw" with the parameter domain "context".
909
 */
910
__isl_give PW *FN(PW,intersect_params)(__isl_take PW *pw,
911
  __isl_take isl_set *context)
912
674
{
913
674
  return FN(PW,align_params_pw_set_and)(pw, context,
914
674
          &FN(PW,intersect_params_aligned));
915
674
}
Unexecuted instantiation: isl_pw_aff_intersect_params
isl_pw_multi_aff_intersect_params
Line
Count
Source
912
674
{
913
674
  return FN(PW,align_params_pw_set_and)(pw, context,
914
674
          &FN(PW,intersect_params_aligned));
915
674
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_intersect_params
Unexecuted instantiation: isl_pw_qpolynomial_intersect_params
916
917
/* Subtract "domain' from the domain of "pw", assuming their
918
 * parameters have been aligned.
919
 */
920
static __isl_give PW *FN(PW,subtract_domain_aligned)(__isl_take PW *pw,
921
  __isl_take isl_set *domain)
922
3
{
923
3
  return FN(PW,restrict_domain_aligned)(pw, domain, &isl_set_subtract);
924
3
}
Unexecuted instantiation: isl_aff.c:isl_pw_aff_subtract_domain_aligned
isl_aff.c:isl_pw_multi_aff_subtract_domain_aligned
Line
Count
Source
922
3
{
923
3
  return FN(PW,restrict_domain_aligned)(pw, domain, &isl_set_subtract);
924
3
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_subtract_domain_aligned
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_subtract_domain_aligned
925
926
/* Subtract "domain' from the domain of "pw".
927
 */
928
__isl_give PW *FN(PW,subtract_domain)(__isl_take PW *pw,
929
  __isl_take isl_set *domain)
930
3
{
931
3
  return FN(PW,align_params_pw_set_and)(pw, domain,
932
3
          &FN(PW,subtract_domain_aligned));
933
3
}
Unexecuted instantiation: isl_pw_aff_subtract_domain
isl_pw_multi_aff_subtract_domain
Line
Count
Source
930
3
{
931
3
  return FN(PW,align_params_pw_set_and)(pw, domain,
932
3
          &FN(PW,subtract_domain_aligned));
933
3
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_subtract_domain
Unexecuted instantiation: isl_pw_qpolynomial_subtract_domain
934
935
/* Compute the gist of "pw" with respect to the domain constraints
936
 * of "context" for the case where the domain of the last element
937
 * of "pw" is equal to "context".
938
 * Call "fn_el" to compute the gist of this element, replace
939
 * its domain by the universe and drop all other elements
940
 * as their domains are necessarily disjoint from "context".
941
 */
942
static __isl_give PW *FN(PW,gist_last)(__isl_take PW *pw,
943
  __isl_take isl_set *context,
944
  __isl_give EL *(*fn_el)(__isl_take EL *el, __isl_take isl_set *set))
945
10.2k
{
946
10.2k
  int i;
947
10.2k
  isl_space *space;
948
10.2k
949
10.2k
  for (i = 0; i < pw->n - 1; 
++i0
) {
950
0
    isl_set_free(pw->p[i].set);
951
0
    FN(EL,free)(pw->p[i].FIELD);
952
0
  }
953
10.2k
  pw->p[0].FIELD = pw->p[pw->n - 1].FIELD;
954
10.2k
  pw->p[0].set = pw->p[pw->n - 1].set;
955
10.2k
  pw->n = 1;
956
10.2k
957
10.2k
  space = isl_set_get_space(context);
958
10.2k
  pw->p[0].FIELD = fn_el(pw->p[0].FIELD, context);
959
10.2k
  context = isl_set_universe(space);
960
10.2k
  isl_set_free(pw->p[0].set);
961
10.2k
  pw->p[0].set = context;
962
10.2k
963
10.2k
  if (!pw->p[0].FIELD || !pw->p[0].set)
964
0
    return FN(PW,free)(pw);
965
10.2k
966
10.2k
  return pw;
967
10.2k
}
isl_aff.c:isl_pw_aff_gist_last
Line
Count
Source
945
8.27k
{
946
8.27k
  int i;
947
8.27k
  isl_space *space;
948
8.27k
949
8.27k
  for (i = 0; i < pw->n - 1; 
++i0
) {
950
0
    isl_set_free(pw->p[i].set);
951
0
    FN(EL,free)(pw->p[i].FIELD);
952
0
  }
953
8.27k
  pw->p[0].FIELD = pw->p[pw->n - 1].FIELD;
954
8.27k
  pw->p[0].set = pw->p[pw->n - 1].set;
955
8.27k
  pw->n = 1;
956
8.27k
957
8.27k
  space = isl_set_get_space(context);
958
8.27k
  pw->p[0].FIELD = fn_el(pw->p[0].FIELD, context);
959
8.27k
  context = isl_set_universe(space);
960
8.27k
  isl_set_free(pw->p[0].set);
961
8.27k
  pw->p[0].set = context;
962
8.27k
963
8.27k
  if (!pw->p[0].FIELD || !pw->p[0].set)
964
0
    return FN(PW,free)(pw);
965
8.27k
966
8.27k
  return pw;
967
8.27k
}
isl_aff.c:isl_pw_multi_aff_gist_last
Line
Count
Source
945
1.96k
{
946
1.96k
  int i;
947
1.96k
  isl_space *space;
948
1.96k
949
1.96k
  for (i = 0; i < pw->n - 1; 
++i0
) {
950
0
    isl_set_free(pw->p[i].set);
951
0
    FN(EL,free)(pw->p[i].FIELD);
952
0
  }
953
1.96k
  pw->p[0].FIELD = pw->p[pw->n - 1].FIELD;
954
1.96k
  pw->p[0].set = pw->p[pw->n - 1].set;
955
1.96k
  pw->n = 1;
956
1.96k
957
1.96k
  space = isl_set_get_space(context);
958
1.96k
  pw->p[0].FIELD = fn_el(pw->p[0].FIELD, context);
959
1.96k
  context = isl_set_universe(space);
960
1.96k
  isl_set_free(pw->p[0].set);
961
1.96k
  pw->p[0].set = context;
962
1.96k
963
1.96k
  if (!pw->p[0].FIELD || !pw->p[0].set)
964
0
    return FN(PW,free)(pw);
965
1.96k
966
1.96k
  return pw;
967
1.96k
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_gist_last
isl_polynomial.c:isl_pw_qpolynomial_gist_last
Line
Count
Source
945
1
{
946
1
  int i;
947
1
  isl_space *space;
948
1
949
1
  for (i = 0; i < pw->n - 1; 
++i0
) {
950
0
    isl_set_free(pw->p[i].set);
951
0
    FN(EL,free)(pw->p[i].FIELD);
952
0
  }
953
1
  pw->p[0].FIELD = pw->p[pw->n - 1].FIELD;
954
1
  pw->p[0].set = pw->p[pw->n - 1].set;
955
1
  pw->n = 1;
956
1
957
1
  space = isl_set_get_space(context);
958
1
  pw->p[0].FIELD = fn_el(pw->p[0].FIELD, context);
959
1
  context = isl_set_universe(space);
960
1
  isl_set_free(pw->p[0].set);
961
1
  pw->p[0].set = context;
962
1
963
1
  if (!pw->p[0].FIELD || !pw->p[0].set)
964
0
    return FN(PW,free)(pw);
965
1
966
1
  return pw;
967
1
}
968
969
/* Compute the gist of "pw" with respect to the domain constraints
970
 * of "context".  Call "fn_el" to compute the gist of the elements
971
 * and "fn_dom" to compute the gist of the domains.
972
 *
973
 * If the piecewise expression is empty or the context is the universe,
974
 * then nothing can be simplified.
975
 */
976
static __isl_give PW *FN(PW,gist_aligned)(__isl_take PW *pw,
977
  __isl_take isl_set *context,
978
  __isl_give EL *(*fn_el)(__isl_take EL *el,
979
            __isl_take isl_set *set),
980
  __isl_give isl_set *(*fn_dom)(__isl_take isl_set *set,
981
            __isl_take isl_basic_set *bset))
982
13.6k
{
983
13.6k
  int i;
984
13.6k
  int is_universe;
985
13.6k
  isl_bool aligned;
986
13.6k
  isl_basic_set *hull = NULL;
987
13.6k
988
13.6k
  if (!pw || !context)
989
0
    goto error;
990
13.6k
991
13.6k
  if (pw->n == 0) {
992
0
    isl_set_free(context);
993
0
    return pw;
994
0
  }
995
13.6k
996
13.6k
  is_universe = isl_set_plain_is_universe(context);
997
13.6k
  if (is_universe < 0)
998
0
    goto error;
999
13.6k
  if (is_universe) {
1000
1.13k
    isl_set_free(context);
1001
1.13k
    return pw;
1002
1.13k
  }
1003
12.4k
1004
12.4k
  aligned = isl_set_space_has_equal_params(context, pw->dim);
1005
12.4k
  if (aligned < 0)
1006
0
    goto error;
1007
12.4k
  if (!aligned) {
1008
0
    pw = FN(PW,align_params)(pw, isl_set_get_space(context));
1009
0
    context = isl_set_align_params(context, FN(PW,get_space)(pw));
1010
0
  }
1011
12.4k
1012
12.4k
  pw = FN(PW,cow)(pw);
1013
12.4k
  if (!pw)
1014
0
    goto error;
1015
12.4k
1016
12.4k
  if (pw->n == 1) {
1017
12.4k
    int equal;
1018
12.4k
1019
12.4k
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
1020
12.4k
    if (equal < 0)
1021
0
      goto error;
1022
12.4k
    if (equal)
1023
10.2k
      return FN(PW,gist_last)(pw, context, fn_el);
1024
2.24k
  }
1025
2.24k
1026
2.24k
  context = isl_set_compute_divs(context);
1027
2.24k
  hull = isl_set_simple_hull(isl_set_copy(context));
1028
2.24k
1029
4.53k
  for (i = pw->n - 1; i >= 0; 
--i2.28k
) {
1030
2.28k
    isl_set *set_i;
1031
2.28k
    int empty;
1032
2.28k
1033
2.28k
    if (i == pw->n - 1) {
1034
2.24k
      int equal;
1035
2.24k
      equal = isl_set_plain_is_equal(pw->p[i].set, context);
1036
2.24k
      if (equal < 0)
1037
0
        goto error;
1038
2.24k
      if (equal) {
1039
0
        isl_basic_set_free(hull);
1040
0
        return FN(PW,gist_last)(pw, context, fn_el);
1041
0
      }
1042
2.28k
    }
1043
2.28k
    set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
1044
2.28k
             isl_set_copy(context));
1045
2.28k
    empty = isl_set_plain_is_empty(set_i);
1046
2.28k
    pw->p[i].FIELD = fn_el(pw->p[i].FIELD, set_i);
1047
2.28k
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1048
2.28k
    if (empty < 0 || !pw->p[i].FIELD || !pw->p[i].set)
1049
0
      goto error;
1050
2.28k
    if (empty) {
1051
2
      isl_set_free(pw->p[i].set);
1052
2
      FN(EL,free)(pw->p[i].FIELD);
1053
2
      if (i != pw->n - 1)
1054
0
        pw->p[i] = pw->p[pw->n - 1];
1055
2
      pw->n--;
1056
2
    }
1057
2.28k
  }
1058
2.24k
1059
2.24k
  isl_basic_set_free(hull);
1060
2.24k
  isl_set_free(context);
1061
2.24k
1062
2.24k
  return pw;
1063
2.24k
error:
1064
0
  FN(PW,free)(pw);
1065
0
  isl_basic_set_free(hull);
1066
0
  isl_set_free(context);
1067
0
  return NULL;
1068
2.24k
}
isl_aff.c:isl_pw_aff_gist_aligned
Line
Count
Source
982
11.4k
{
983
11.4k
  int i;
984
11.4k
  int is_universe;
985
11.4k
  isl_bool aligned;
986
11.4k
  isl_basic_set *hull = NULL;
987
11.4k
988
11.4k
  if (!pw || !context)
989
0
    goto error;
990
11.4k
991
11.4k
  if (pw->n == 0) {
992
0
    isl_set_free(context);
993
0
    return pw;
994
0
  }
995
11.4k
996
11.4k
  is_universe = isl_set_plain_is_universe(context);
997
11.4k
  if (is_universe < 0)
998
0
    goto error;
999
11.4k
  if (is_universe) {
1000
1.05k
    isl_set_free(context);
1001
1.05k
    return pw;
1002
1.05k
  }
1003
10.4k
1004
10.4k
  aligned = isl_set_space_has_equal_params(context, pw->dim);
1005
10.4k
  if (aligned < 0)
1006
0
    goto error;
1007
10.4k
  if (!aligned) {
1008
0
    pw = FN(PW,align_params)(pw, isl_set_get_space(context));
1009
0
    context = isl_set_align_params(context, FN(PW,get_space)(pw));
1010
0
  }
1011
10.4k
1012
10.4k
  pw = FN(PW,cow)(pw);
1013
10.4k
  if (!pw)
1014
0
    goto error;
1015
10.4k
1016
10.4k
  if (pw->n == 1) {
1017
10.3k
    int equal;
1018
10.3k
1019
10.3k
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
1020
10.3k
    if (equal < 0)
1021
0
      goto error;
1022
10.3k
    if (equal)
1023
8.27k
      return FN(PW,gist_last)(pw, context, fn_el);
1024
2.13k
  }
1025
2.13k
1026
2.13k
  context = isl_set_compute_divs(context);
1027
2.13k
  hull = isl_set_simple_hull(isl_set_copy(context));
1028
2.13k
1029
4.31k
  for (i = pw->n - 1; i >= 0; 
--i2.17k
) {
1030
2.17k
    isl_set *set_i;
1031
2.17k
    int empty;
1032
2.17k
1033
2.17k
    if (i == pw->n - 1) {
1034
2.13k
      int equal;
1035
2.13k
      equal = isl_set_plain_is_equal(pw->p[i].set, context);
1036
2.13k
      if (equal < 0)
1037
0
        goto error;
1038
2.13k
      if (equal) {
1039
0
        isl_basic_set_free(hull);
1040
0
        return FN(PW,gist_last)(pw, context, fn_el);
1041
0
      }
1042
2.17k
    }
1043
2.17k
    set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
1044
2.17k
             isl_set_copy(context));
1045
2.17k
    empty = isl_set_plain_is_empty(set_i);
1046
2.17k
    pw->p[i].FIELD = fn_el(pw->p[i].FIELD, set_i);
1047
2.17k
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1048
2.17k
    if (empty < 0 || !pw->p[i].FIELD || !pw->p[i].set)
1049
0
      goto error;
1050
2.17k
    if (empty) {
1051
0
      isl_set_free(pw->p[i].set);
1052
0
      FN(EL,free)(pw->p[i].FIELD);
1053
0
      if (i != pw->n - 1)
1054
0
        pw->p[i] = pw->p[pw->n - 1];
1055
0
      pw->n--;
1056
0
    }
1057
2.17k
  }
1058
2.13k
1059
2.13k
  isl_basic_set_free(hull);
1060
2.13k
  isl_set_free(context);
1061
2.13k
1062
2.13k
  return pw;
1063
2.13k
error:
1064
0
  FN(PW,free)(pw);
1065
0
  isl_basic_set_free(hull);
1066
0
  isl_set_free(context);
1067
0
  return NULL;
1068
2.13k
}
isl_aff.c:isl_pw_multi_aff_gist_aligned
Line
Count
Source
982
2.15k
{
983
2.15k
  int i;
984
2.15k
  int is_universe;
985
2.15k
  isl_bool aligned;
986
2.15k
  isl_basic_set *hull = NULL;
987
2.15k
988
2.15k
  if (!pw || !context)
989
0
    goto error;
990
2.15k
991
2.15k
  if (pw->n == 0) {
992
0
    isl_set_free(context);
993
0
    return pw;
994
0
  }
995
2.15k
996
2.15k
  is_universe = isl_set_plain_is_universe(context);
997
2.15k
  if (is_universe < 0)
998
0
    goto error;
999
2.15k
  if (is_universe) {
1000
76
    isl_set_free(context);
1001
76
    return pw;
1002
76
  }
1003
2.07k
1004
2.07k
  aligned = isl_set_space_has_equal_params(context, pw->dim);
1005
2.07k
  if (aligned < 0)
1006
0
    goto error;
1007
2.07k
  if (!aligned) {
1008
0
    pw = FN(PW,align_params)(pw, isl_set_get_space(context));
1009
0
    context = isl_set_align_params(context, FN(PW,get_space)(pw));
1010
0
  }
1011
2.07k
1012
2.07k
  pw = FN(PW,cow)(pw);
1013
2.07k
  if (!pw)
1014
0
    goto error;
1015
2.07k
1016
2.07k
  if (pw->n == 1) {
1017
2.07k
    int equal;
1018
2.07k
1019
2.07k
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
1020
2.07k
    if (equal < 0)
1021
0
      goto error;
1022
2.07k
    if (equal)
1023
1.96k
      return FN(PW,gist_last)(pw, context, fn_el);
1024
107
  }
1025
107
1026
107
  context = isl_set_compute_divs(context);
1027
107
  hull = isl_set_simple_hull(isl_set_copy(context));
1028
107
1029
214
  for (i = pw->n - 1; i >= 0; 
--i107
) {
1030
107
    isl_set *set_i;
1031
107
    int empty;
1032
107
1033
107
    if (i == pw->n - 1) {
1034
107
      int equal;
1035
107
      equal = isl_set_plain_is_equal(pw->p[i].set, context);
1036
107
      if (equal < 0)
1037
0
        goto error;
1038
107
      if (equal) {
1039
0
        isl_basic_set_free(hull);
1040
0
        return FN(PW,gist_last)(pw, context, fn_el);
1041
0
      }
1042
107
    }
1043
107
    set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
1044
107
             isl_set_copy(context));
1045
107
    empty = isl_set_plain_is_empty(set_i);
1046
107
    pw->p[i].FIELD = fn_el(pw->p[i].FIELD, set_i);
1047
107
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1048
107
    if (empty < 0 || !pw->p[i].FIELD || !pw->p[i].set)
1049
0
      goto error;
1050
107
    if (empty) {
1051
2
      isl_set_free(pw->p[i].set);
1052
2
      FN(EL,free)(pw->p[i].FIELD);
1053
2
      if (i != pw->n - 1)
1054
0
        pw->p[i] = pw->p[pw->n - 1];
1055
2
      pw->n--;
1056
2
    }
1057
107
  }
1058
107
1059
107
  isl_basic_set_free(hull);
1060
107
  isl_set_free(context);
1061
107
1062
107
  return pw;
1063
107
error:
1064
0
  FN(PW,free)(pw);
1065
0
  isl_basic_set_free(hull);
1066
0
  isl_set_free(context);
1067
0
  return NULL;
1068
107
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_gist_aligned
isl_polynomial.c:isl_pw_qpolynomial_gist_aligned
Line
Count
Source
982
4
{
983
4
  int i;
984
4
  int is_universe;
985
4
  isl_bool aligned;
986
4
  isl_basic_set *hull = NULL;
987
4
988
4
  if (!pw || !context)
989
0
    goto error;
990
4
991
4
  if (pw->n == 0) {
992
0
    isl_set_free(context);
993
0
    return pw;
994
0
  }
995
4
996
4
  is_universe = isl_set_plain_is_universe(context);
997
4
  if (is_universe < 0)
998
0
    goto error;
999
4
  if (is_universe) {
1000
0
    isl_set_free(context);
1001
0
    return pw;
1002
0
  }
1003
4
1004
4
  aligned = isl_set_space_has_equal_params(context, pw->dim);
1005
4
  if (aligned < 0)
1006
0
    goto error;
1007
4
  if (!aligned) {
1008
0
    pw = FN(PW,align_params)(pw, isl_set_get_space(context));
1009
0
    context = isl_set_align_params(context, FN(PW,get_space)(pw));
1010
0
  }
1011
4
1012
4
  pw = FN(PW,cow)(pw);
1013
4
  if (!pw)
1014
0
    goto error;
1015
4
1016
4
  if (pw->n == 1) {
1017
4
    int equal;
1018
4
1019
4
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
1020
4
    if (equal < 0)
1021
0
      goto error;
1022
4
    if (equal)
1023
1
      return FN(PW,gist_last)(pw, context, fn_el);
1024
3
  }
1025
3
1026
3
  context = isl_set_compute_divs(context);
1027
3
  hull = isl_set_simple_hull(isl_set_copy(context));
1028
3
1029
6
  for (i = pw->n - 1; i >= 0; 
--i3
) {
1030
3
    isl_set *set_i;
1031
3
    int empty;
1032
3
1033
3
    if (i == pw->n - 1) {
1034
3
      int equal;
1035
3
      equal = isl_set_plain_is_equal(pw->p[i].set, context);
1036
3
      if (equal < 0)
1037
0
        goto error;
1038
3
      if (equal) {
1039
0
        isl_basic_set_free(hull);
1040
0
        return FN(PW,gist_last)(pw, context, fn_el);
1041
0
      }
1042
3
    }
1043
3
    set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
1044
3
             isl_set_copy(context));
1045
3
    empty = isl_set_plain_is_empty(set_i);
1046
3
    pw->p[i].FIELD = fn_el(pw->p[i].FIELD, set_i);
1047
3
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1048
3
    if (empty < 0 || !pw->p[i].FIELD || !pw->p[i].set)
1049
0
      goto error;
1050
3
    if (empty) {
1051
0
      isl_set_free(pw->p[i].set);
1052
0
      FN(EL,free)(pw->p[i].FIELD);
1053
0
      if (i != pw->n - 1)
1054
0
        pw->p[i] = pw->p[pw->n - 1];
1055
0
      pw->n--;
1056
0
    }
1057
3
  }
1058
3
1059
3
  isl_basic_set_free(hull);
1060
3
  isl_set_free(context);
1061
3
1062
3
  return pw;
1063
3
error:
1064
0
  FN(PW,free)(pw);
1065
0
  isl_basic_set_free(hull);
1066
0
  isl_set_free(context);
1067
0
  return NULL;
1068
3
}
1069
1070
static __isl_give PW *FN(PW,gist_domain_aligned)(__isl_take PW *pw,
1071
  __isl_take isl_set *set)
1072
13.6k
{
1073
13.6k
  return FN(PW,gist_aligned)(pw, set, &FN(EL,gist),
1074
13.6k
          &isl_set_gist_basic_set);
1075
13.6k
}
isl_aff.c:isl_pw_aff_gist_domain_aligned
Line
Count
Source
1072
11.4k
{
1073
11.4k
  return FN(PW,gist_aligned)(pw, set, &FN(EL,gist),
1074
11.4k
          &isl_set_gist_basic_set);
1075
11.4k
}
isl_aff.c:isl_pw_multi_aff_gist_domain_aligned
Line
Count
Source
1072
2.15k
{
1073
2.15k
  return FN(PW,gist_aligned)(pw, set, &FN(EL,gist),
1074
2.15k
          &isl_set_gist_basic_set);
1075
2.15k
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_gist_domain_aligned
isl_polynomial.c:isl_pw_qpolynomial_gist_domain_aligned
Line
Count
Source
1072
4
{
1073
4
  return FN(PW,gist_aligned)(pw, set, &FN(EL,gist),
1074
4
          &isl_set_gist_basic_set);
1075
4
}
1076
1077
__isl_give PW *FN(PW,gist)(__isl_take PW *pw, __isl_take isl_set *context)
1078
13.6k
{
1079
13.6k
  return FN(PW,align_params_pw_set_and)(pw, context,
1080
13.6k
            &FN(PW,gist_domain_aligned));
1081
13.6k
}
isl_pw_aff_gist
Line
Count
Source
1078
11.4k
{
1079
11.4k
  return FN(PW,align_params_pw_set_and)(pw, context,
1080
11.4k
            &FN(PW,gist_domain_aligned));
1081
11.4k
}
isl_pw_multi_aff_gist
Line
Count
Source
1078
2.15k
{
1079
2.15k
  return FN(PW,align_params_pw_set_and)(pw, context,
1080
2.15k
            &FN(PW,gist_domain_aligned));
1081
2.15k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_gist
isl_pw_qpolynomial_gist
Line
Count
Source
1078
4
{
1079
4
  return FN(PW,align_params_pw_set_and)(pw, context,
1080
4
            &FN(PW,gist_domain_aligned));
1081
4
}
1082
1083
static __isl_give PW *FN(PW,gist_params_aligned)(__isl_take PW *pw,
1084
  __isl_take isl_set *set)
1085
0
{
1086
0
  return FN(PW,gist_aligned)(pw, set, &FN(EL,gist_params),
1087
0
          &isl_set_gist_params_basic_set);
1088
0
}
Unexecuted instantiation: isl_aff.c:isl_pw_aff_gist_params_aligned
Unexecuted instantiation: isl_aff.c:isl_pw_multi_aff_gist_params_aligned
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_gist_params_aligned
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_gist_params_aligned
1089
1090
__isl_give PW *FN(PW,gist_params)(__isl_take PW *pw,
1091
  __isl_take isl_set *context)
1092
0
{
1093
0
  return FN(PW,align_params_pw_set_and)(pw, context,
1094
0
            &FN(PW,gist_params_aligned));
1095
0
}
Unexecuted instantiation: isl_pw_aff_gist_params
Unexecuted instantiation: isl_pw_multi_aff_gist_params
Unexecuted instantiation: isl_pw_qpolynomial_fold_gist_params
Unexecuted instantiation: isl_pw_qpolynomial_gist_params
1096
1097
/* Return -1 if the piece "p1" should be sorted before "p2"
1098
 * and 1 if it should be sorted after "p2".
1099
 * Return 0 if they do not need to be sorted in a specific order.
1100
 *
1101
 * The two pieces are compared on the basis of their function value expressions.
1102
 */
1103
static int FN(PW,sort_field_cmp)(const void *p1, const void *p2, void *arg)
1104
2.36k
{
1105
2.36k
  struct FN(PW,piece) const *pc1 = p1;
1106
2.36k
  struct FN(PW,piece) const *pc2 = p2;
1107
2.36k
1108
2.36k
  return FN(EL,plain_cmp)(pc1->FIELD, pc2->FIELD);
1109
2.36k
}
isl_aff.c:isl_pw_aff_sort_field_cmp
Line
Count
Source
1104
552
{
1105
552
  struct FN(PW,piece) const *pc1 = p1;
1106
552
  struct FN(PW,piece) const *pc2 = p2;
1107
552
1108
552
  return FN(EL,plain_cmp)(pc1->FIELD, pc2->FIELD);
1109
552
}
isl_aff.c:isl_pw_multi_aff_sort_field_cmp
Line
Count
Source
1104
1.81k
{
1105
1.81k
  struct FN(PW,piece) const *pc1 = p1;
1106
1.81k
  struct FN(PW,piece) const *pc2 = p2;
1107
1.81k
1108
1.81k
  return FN(EL,plain_cmp)(pc1->FIELD, pc2->FIELD);
1109
1.81k
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_sort_field_cmp
isl_polynomial.c:isl_pw_qpolynomial_sort_field_cmp
Line
Count
Source
1104
1
{
1105
1
  struct FN(PW,piece) const *pc1 = p1;
1106
1
  struct FN(PW,piece) const *pc2 = p2;
1107
1
1108
1
  return FN(EL,plain_cmp)(pc1->FIELD, pc2->FIELD);
1109
1
}
1110
1111
/* Sort the pieces of "pw" according to their function value
1112
 * expressions and then combine pairs of adjacent pieces with
1113
 * the same such expression.
1114
 *
1115
 * The sorting is performed in place because it does not
1116
 * change the meaning of "pw", but care needs to be
1117
 * taken not to change any possible other copies of "pw"
1118
 * in case anything goes wrong.
1119
 */
1120
__isl_give PW *FN(PW,sort)(__isl_take PW *pw)
1121
28.6k
{
1122
28.6k
  int i, j;
1123
28.6k
  isl_set *set;
1124
28.6k
1125
28.6k
  if (!pw)
1126
1
    return NULL;
1127
28.6k
  if (pw->n <= 1)
1128
27.5k
    return pw;
1129
1.02k
  if (isl_sort(pw->p, pw->n, sizeof(pw->p[0]),
1130
1.02k
        &FN(PW,sort_field_cmp), NULL) < 0)
1131
0
    return FN(PW,free)(pw);
1132
2.75k
  
for (i = pw->n - 1; 1.02k
i >= 1;
--i1.73k
) {
1133
1.73k
    if (!FN(EL,plain_is_equal)(pw->p[i - 1].FIELD, pw->p[i].FIELD))
1134
1.68k
      continue;
1135
46
    set = isl_set_union(isl_set_copy(pw->p[i - 1].set),
1136
46
            isl_set_copy(pw->p[i].set));
1137
46
    if (!set)
1138
0
      return FN(PW,free)(pw);
1139
46
    isl_set_free(pw->p[i].set);
1140
46
    FN(EL,free)(pw->p[i].FIELD);
1141
46
    isl_set_free(pw->p[i - 1].set);
1142
46
    pw->p[i - 1].set = set;
1143
59
    for (j = i + 1; j < pw->n; 
++j13
)
1144
13
      pw->p[j - 1] = pw->p[j];
1145
46
    pw->n--;
1146
46
  }
1147
1.02k
1148
1.02k
  return pw;
1149
1.02k
}
isl_pw_aff_sort
Line
Count
Source
1121
24.3k
{
1122
24.3k
  int i, j;
1123
24.3k
  isl_set *set;
1124
24.3k
1125
24.3k
  if (!pw)
1126
1
    return NULL;
1127
24.3k
  if (pw->n <= 1)
1128
24.0k
    return pw;
1129
294
  if (isl_sort(pw->p, pw->n, sizeof(pw->p[0]),
1130
294
        &FN(PW,sort_field_cmp), NULL) < 0)
1131
0
    return FN(PW,free)(pw);
1132
715
  
for (i = pw->n - 1; 294
i >= 1;
--i421
) {
1133
421
    if (!FN(EL,plain_is_equal)(pw->p[i - 1].FIELD, pw->p[i].FIELD))
1134
414
      continue;
1135
7
    set = isl_set_union(isl_set_copy(pw->p[i - 1].set),
1136
7
            isl_set_copy(pw->p[i].set));
1137
7
    if (!set)
1138
0
      return FN(PW,free)(pw);
1139
7
    isl_set_free(pw->p[i].set);
1140
7
    FN(EL,free)(pw->p[i].FIELD);
1141
7
    isl_set_free(pw->p[i - 1].set);
1142
7
    pw->p[i - 1].set = set;
1143
19
    for (j = i + 1; j < pw->n; 
++j12
)
1144
12
      pw->p[j - 1] = pw->p[j];
1145
7
    pw->n--;
1146
7
  }
1147
294
1148
294
  return pw;
1149
294
}
isl_pw_multi_aff_sort
Line
Count
Source
1121
4.28k
{
1122
4.28k
  int i, j;
1123
4.28k
  isl_set *set;
1124
4.28k
1125
4.28k
  if (!pw)
1126
0
    return NULL;
1127
4.28k
  if (pw->n <= 1)
1128
3.54k
    return pw;
1129
732
  if (isl_sort(pw->p, pw->n, sizeof(pw->p[0]),
1130
732
        &FN(PW,sort_field_cmp), NULL) < 0)
1131
0
    return FN(PW,free)(pw);
1132
2.04k
  
for (i = pw->n - 1; 732
i >= 1;
--i1.31k
) {
1133
1.31k
    if (!FN(EL,plain_is_equal)(pw->p[i - 1].FIELD, pw->p[i].FIELD))
1134
1.27k
      continue;
1135
39
    set = isl_set_union(isl_set_copy(pw->p[i - 1].set),
1136
39
            isl_set_copy(pw->p[i].set));
1137
39
    if (!set)
1138
0
      return FN(PW,free)(pw);
1139
39
    isl_set_free(pw->p[i].set);
1140
39
    FN(EL,free)(pw->p[i].FIELD);
1141
39
    isl_set_free(pw->p[i - 1].set);
1142
39
    pw->p[i - 1].set = set;
1143
40
    for (j = i + 1; j < pw->n; 
++j1
)
1144
1
      pw->p[j - 1] = pw->p[j];
1145
39
    pw->n--;
1146
39
  }
1147
732
1148
732
  return pw;
1149
732
}
isl_pw_qpolynomial_fold_sort
Line
Count
Source
1121
2
{
1122
2
  int i, j;
1123
2
  isl_set *set;
1124
2
1125
2
  if (!pw)
1126
0
    return NULL;
1127
2
  if (pw->n <= 1)
1128
2
    return pw;
1129
0
  if (isl_sort(pw->p, pw->n, sizeof(pw->p[0]),
1130
0
        &FN(PW,sort_field_cmp), NULL) < 0)
1131
0
    return FN(PW,free)(pw);
1132
0
  for (i = pw->n - 1; i >= 1; --i) {
1133
0
    if (!FN(EL,plain_is_equal)(pw->p[i - 1].FIELD, pw->p[i].FIELD))
1134
0
      continue;
1135
0
    set = isl_set_union(isl_set_copy(pw->p[i - 1].set),
1136
0
            isl_set_copy(pw->p[i].set));
1137
0
    if (!set)
1138
0
      return FN(PW,free)(pw);
1139
0
    isl_set_free(pw->p[i].set);
1140
0
    FN(EL,free)(pw->p[i].FIELD);
1141
0
    isl_set_free(pw->p[i - 1].set);
1142
0
    pw->p[i - 1].set = set;
1143
0
    for (j = i + 1; j < pw->n; ++j)
1144
0
      pw->p[j - 1] = pw->p[j];
1145
0
    pw->n--;
1146
0
  }
1147
0
1148
0
  return pw;
1149
0
}
isl_pw_qpolynomial_sort
Line
Count
Source
1121
7
{
1122
7
  int i, j;
1123
7
  isl_set *set;
1124
7
1125
7
  if (!pw)
1126
0
    return NULL;
1127
7
  if (pw->n <= 1)
1128
6
    return pw;
1129
1
  if (isl_sort(pw->p, pw->n, sizeof(pw->p[0]),
1130
1
        &FN(PW,sort_field_cmp), NULL) < 0)
1131
0
    return FN(PW,free)(pw);
1132
2
  
for (i = pw->n - 1; 1
i >= 1;
--i1
) {
1133
1
    if (!FN(EL,plain_is_equal)(pw->p[i - 1].FIELD, pw->p[i].FIELD))
1134
1
      continue;
1135
0
    set = isl_set_union(isl_set_copy(pw->p[i - 1].set),
1136
0
            isl_set_copy(pw->p[i].set));
1137
0
    if (!set)
1138
0
      return FN(PW,free)(pw);
1139
0
    isl_set_free(pw->p[i].set);
1140
0
    FN(EL,free)(pw->p[i].FIELD);
1141
0
    isl_set_free(pw->p[i - 1].set);
1142
0
    pw->p[i - 1].set = set;
1143
0
    for (j = i + 1; j < pw->n; ++j)
1144
0
      pw->p[j - 1] = pw->p[j];
1145
0
    pw->n--;
1146
0
  }
1147
1
1148
1
  return pw;
1149
1
}
1150
1151
/* Coalesce the domains of "pw".
1152
 *
1153
 * Prior to the actual coalescing, first sort the pieces such that
1154
 * pieces with the same function value expression are combined
1155
 * into a single piece, the combined domain of which can then
1156
 * be coalesced.
1157
 */
1158
__isl_give PW *FN(PW,coalesce)(__isl_take PW *pw)
1159
24.4k
{
1160
24.4k
  int i;
1161
24.4k
1162
24.4k
  pw = FN(PW,sort)(pw);
1163
24.4k
  if (!pw)
1164
1
    return NULL;
1165
24.4k
1166
49.3k
  
for (i = 0; 24.4k
i < pw->n;
++i24.8k
) {
1167
24.8k
    pw->p[i].set = isl_set_coalesce(pw->p[i].set);
1168
24.8k
    if (!pw->p[i].set)
1169
0
      goto error;
1170
24.8k
  }
1171
24.4k
1172
24.4k
  return pw;
1173
24.4k
error:
1174
0
  FN(PW,free)(pw);
1175
0
  return NULL;
1176
24.4k
}
isl_pw_aff_coalesce
Line
Count
Source
1159
23.3k
{
1160
23.3k
  int i;
1161
23.3k
1162
23.3k
  pw = FN(PW,sort)(pw);
1163
23.3k
  if (!pw)
1164
1
    return NULL;
1165
23.3k
1166
47.1k
  
for (i = 0; 23.3k
i < pw->n;
++i23.7k
) {
1167
23.7k
    pw->p[i].set = isl_set_coalesce(pw->p[i].set);
1168
23.7k
    if (!pw->p[i].set)
1169
0
      goto error;
1170
23.7k
  }
1171
23.3k
1172
23.3k
  return pw;
1173
23.3k
error:
1174
0
  FN(PW,free)(pw);
1175
0
  return NULL;
1176
23.3k
}
isl_pw_multi_aff_coalesce
Line
Count
Source
1159
1.06k
{
1160
1.06k
  int i;
1161
1.06k
1162
1.06k
  pw = FN(PW,sort)(pw);
1163
1.06k
  if (!pw)
1164
0
    return NULL;
1165
1.06k
1166
2.19k
  
for (i = 0; 1.06k
i < pw->n;
++i1.12k
) {
1167
1.12k
    pw->p[i].set = isl_set_coalesce(pw->p[i].set);
1168
1.12k
    if (!pw->p[i].set)
1169
0
      goto error;
1170
1.12k
  }
1171
1.06k
1172
1.06k
  return pw;
1173
1.06k
error:
1174
0
  FN(PW,free)(pw);
1175
0
  return NULL;
1176
1.06k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_coalesce
isl_pw_qpolynomial_coalesce
Line
Count
Source
1159
1
{
1160
1
  int i;
1161
1
1162
1
  pw = FN(PW,sort)(pw);
1163
1
  if (!pw)
1164
0
    return NULL;
1165
1
1166
3
  
for (i = 0; 1
i < pw->n;
++i2
) {
1167
2
    pw->p[i].set = isl_set_coalesce(pw->p[i].set);
1168
2
    if (!pw->p[i].set)
1169
0
      goto error;
1170
2
  }
1171
1
1172
1
  return pw;
1173
1
error:
1174
0
  FN(PW,free)(pw);
1175
0
  return NULL;
1176
1
}
1177
1178
isl_ctx *FN(PW,get_ctx)(__isl_keep PW *pw)
1179
24.2k
{
1180
24.2k
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1181
24.2k
}
isl_pw_aff_get_ctx
Line
Count
Source
1179
20.9k
{
1180
20.9k
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1181
20.9k
}
isl_pw_multi_aff_get_ctx
Line
Count
Source
1179
3.30k
{
1180
3.30k
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1181
3.30k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_get_ctx
isl_pw_qpolynomial_get_ctx
Line
Count
Source
1179
1
{
1180
1
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1181
1
}
1182
1183
#ifndef NO_INVOLVES_DIMS
1184
isl_bool FN(PW,involves_dims)(__isl_keep PW *pw, enum isl_dim_type type,
1185
  unsigned first, unsigned n)
1186
91
{
1187
91
  int i;
1188
91
  enum isl_dim_type set_type;
1189
91
1190
91
  if (!pw)
1191
0
    return isl_bool_error;
1192
91
  if (pw->n == 0 || n == 0)
1193
0
    return isl_bool_false;
1194
91
1195
91
  set_type = type == isl_dim_in ? isl_dim_set : 
type0
;
1196
91
1197
182
  for (i = 0; i < pw->n; 
++i91
) {
1198
91
    isl_bool involves = FN(EL,involves_dims)(pw->p[i].FIELD,
1199
91
              type, first, n);
1200
91
    if (involves < 0 || involves)
1201
0
      return involves;
1202
91
    involves = isl_set_involves_dims(pw->p[i].set,
1203
91
              set_type, first, n);
1204
91
    if (involves < 0 || involves)
1205
0
      return involves;
1206
91
  }
1207
91
  return isl_bool_false;
1208
91
}
isl_pw_aff_involves_dims
Line
Count
Source
1186
91
{
1187
91
  int i;
1188
91
  enum isl_dim_type set_type;
1189
91
1190
91
  if (!pw)
1191
0
    return isl_bool_error;
1192
91
  if (pw->n == 0 || n == 0)
1193
0
    return isl_bool_false;
1194
91
1195
91
  set_type = type == isl_dim_in ? isl_dim_set : 
type0
;
1196
91
1197
182
  for (i = 0; i < pw->n; 
++i91
) {
1198
91
    isl_bool involves = FN(EL,involves_dims)(pw->p[i].FIELD,
1199
91
              type, first, n);
1200
91
    if (involves < 0 || involves)
1201
0
      return involves;
1202
91
    involves = isl_set_involves_dims(pw->p[i].set,
1203
91
              set_type, first, n);
1204
91
    if (involves < 0 || involves)
1205
0
      return involves;
1206
91
  }
1207
91
  return isl_bool_false;
1208
91
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_involves_dims
Unexecuted instantiation: isl_pw_qpolynomial_involves_dims
1209
#endif
1210
1211
__isl_give PW *FN(PW,set_dim_name)(__isl_take PW *pw,
1212
  enum isl_dim_type type, unsigned pos, const char *s)
1213
0
{
1214
0
  int i;
1215
0
  enum isl_dim_type set_type;
1216
0
1217
0
  pw = FN(PW,cow)(pw);
1218
0
  if (!pw)
1219
0
    return NULL;
1220
0
1221
0
  set_type = type == isl_dim_in ? isl_dim_set : type;
1222
0
1223
0
  pw->dim = isl_space_set_dim_name(pw->dim, type, pos, s);
1224
0
  if (!pw->dim)
1225
0
    goto error;
1226
0
1227
0
  for (i = 0; i < pw->n; ++i) {
1228
0
    pw->p[i].set = isl_set_set_dim_name(pw->p[i].set,
1229
0
              set_type, pos, s);
1230
0
    if (!pw->p[i].set)
1231
0
      goto error;
1232
0
    pw->p[i].FIELD = FN(EL,set_dim_name)(pw->p[i].FIELD, type, pos, s);
1233
0
    if (!pw->p[i].FIELD)
1234
0
      goto error;
1235
0
  }
1236
0
1237
0
  return pw;
1238
0
error:
1239
0
  FN(PW,free)(pw);
1240
0
  return NULL;
1241
0
}
Unexecuted instantiation: isl_pw_aff_set_dim_name
Unexecuted instantiation: isl_pw_multi_aff_set_dim_name
Unexecuted instantiation: isl_pw_qpolynomial_fold_set_dim_name
Unexecuted instantiation: isl_pw_qpolynomial_set_dim_name
1242
1243
#ifndef NO_DROP_DIMS
1244
__isl_give PW *FN(PW,drop_dims)(__isl_take PW *pw,
1245
  enum isl_dim_type type, unsigned first, unsigned n)
1246
699
{
1247
699
  int i;
1248
699
  enum isl_dim_type set_type;
1249
699
1250
699
  if (!pw)
1251
0
    return NULL;
1252
699
  if (n == 0 && 
!isl_space_get_tuple_name(pw->dim, type)0
)
1253
0
    return pw;
1254
699
1255
699
  set_type = type == isl_dim_in ? 
isl_dim_set91
:
type608
;
1256
699
1257
699
  pw = FN(PW,cow)(pw);
1258
699
  if (!pw)
1259
0
    return NULL;
1260
699
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1261
699
  if (!pw->dim)
1262
0
    goto error;
1263
1.39k
  
for (i = 0; 699
i < pw->n;
++i699
) {
1264
699
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1265
699
    if (!pw->p[i].FIELD)
1266
699
      
goto error0
;
1267
699
    if (type == isl_dim_out)
1268
608
      continue;
1269
91
    pw->p[i].set = isl_set_drop(pw->p[i].set, set_type, first, n);
1270
91
    if (!pw->p[i].set)
1271
0
      goto error;
1272
91
  }
1273
699
1274
699
  return pw;
1275
699
error:
1276
0
  FN(PW,free)(pw);
1277
0
  return NULL;
1278
699
}
isl_pw_aff_drop_dims
Line
Count
Source
1246
91
{
1247
91
  int i;
1248
91
  enum isl_dim_type set_type;
1249
91
1250
91
  if (!pw)
1251
0
    return NULL;
1252
91
  if (n == 0 && 
!isl_space_get_tuple_name(pw->dim, type)0
)
1253
0
    return pw;
1254
91
1255
91
  set_type = type == isl_dim_in ? isl_dim_set : 
type0
;
1256
91
1257
91
  pw = FN(PW,cow)(pw);
1258
91
  if (!pw)
1259
0
    return NULL;
1260
91
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1261
91
  if (!pw->dim)
1262
0
    goto error;
1263
182
  
for (i = 0; 91
i < pw->n;
++i91
) {
1264
91
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1265
91
    if (!pw->p[i].FIELD)
1266
91
      
goto error0
;
1267
91
    if (type == isl_dim_out)
1268
0
      continue;
1269
91
    pw->p[i].set = isl_set_drop(pw->p[i].set, set_type, first, n);
1270
91
    if (!pw->p[i].set)
1271
0
      goto error;
1272
91
  }
1273
91
1274
91
  return pw;
1275
91
error:
1276
0
  FN(PW,free)(pw);
1277
0
  return NULL;
1278
91
}
isl_pw_multi_aff_drop_dims
Line
Count
Source
1246
608
{
1247
608
  int i;
1248
608
  enum isl_dim_type set_type;
1249
608
1250
608
  if (!pw)
1251
0
    return NULL;
1252
608
  if (n == 0 && 
!isl_space_get_tuple_name(pw->dim, type)0
)
1253
0
    return pw;
1254
608
1255
608
  set_type = type == isl_dim_in ? 
isl_dim_set0
: type;
1256
608
1257
608
  pw = FN(PW,cow)(pw);
1258
608
  if (!pw)
1259
0
    return NULL;
1260
608
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1261
608
  if (!pw->dim)
1262
0
    goto error;
1263
1.21k
  
for (i = 0; 608
i < pw->n;
++i608
) {
1264
608
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1265
608
    if (!pw->p[i].FIELD)
1266
608
      
goto error0
;
1267
608
    if (type == isl_dim_out)
1268
608
      continue;
1269
0
    pw->p[i].set = isl_set_drop(pw->p[i].set, set_type, first, n);
1270
0
    if (!pw->p[i].set)
1271
0
      goto error;
1272
0
  }
1273
608
1274
608
  return pw;
1275
608
error:
1276
0
  FN(PW,free)(pw);
1277
0
  return NULL;
1278
608
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_drop_dims
Unexecuted instantiation: isl_pw_qpolynomial_drop_dims
1279
1280
/* This function is very similar to drop_dims.
1281
 * The only difference is that the cells may still involve
1282
 * the specified dimensions.  They are removed using
1283
 * isl_set_project_out instead of isl_set_drop.
1284
 */
1285
__isl_give PW *FN(PW,project_out)(__isl_take PW *pw,
1286
  enum isl_dim_type type, unsigned first, unsigned n)
1287
182
{
1288
182
  int i;
1289
182
  enum isl_dim_type set_type;
1290
182
1291
182
  if (!pw)
1292
0
    return NULL;
1293
182
  if (n == 0 && 
!isl_space_get_tuple_name(pw->dim, type)1
)
1294
0
    return pw;
1295
182
1296
182
  set_type = type == isl_dim_in ? isl_dim_set : 
type0
;
1297
182
1298
182
  pw = FN(PW,cow)(pw);
1299
182
  if (!pw)
1300
0
    return NULL;
1301
182
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1302
182
  if (!pw->dim)
1303
0
    goto error;
1304
539
  
for (i = 0; 182
i < pw->n;
++i357
) {
1305
357
    pw->p[i].set = isl_set_project_out(pw->p[i].set,
1306
357
              set_type, first, n);
1307
357
    if (!pw->p[i].set)
1308
0
      goto error;
1309
357
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1310
357
    if (!pw->p[i].FIELD)
1311
357
      
goto error0
;
1312
357
  }
1313
182
1314
182
  return pw;
1315
182
error:
1316
0
  FN(PW,free)(pw);
1317
0
  return NULL;
1318
182
}
Unexecuted instantiation: isl_pw_aff_project_out
isl_pw_multi_aff_project_out
Line
Count
Source
1287
181
{
1288
181
  int i;
1289
181
  enum isl_dim_type set_type;
1290
181
1291
181
  if (!pw)
1292
0
    return NULL;
1293
181
  if (n == 0 && 
!isl_space_get_tuple_name(pw->dim, type)0
)
1294
0
    return pw;
1295
181
1296
181
  set_type = type == isl_dim_in ? isl_dim_set : 
type0
;
1297
181
1298
181
  pw = FN(PW,cow)(pw);
1299
181
  if (!pw)
1300
0
    return NULL;
1301
181
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1302
181
  if (!pw->dim)
1303
0
    goto error;
1304
537
  
for (i = 0; 181
i < pw->n;
++i356
) {
1305
356
    pw->p[i].set = isl_set_project_out(pw->p[i].set,
1306
356
              set_type, first, n);
1307
356
    if (!pw->p[i].set)
1308
0
      goto error;
1309
356
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1310
356
    if (!pw->p[i].FIELD)
1311
356
      
goto error0
;
1312
356
  }
1313
181
1314
181
  return pw;
1315
181
error:
1316
0
  FN(PW,free)(pw);
1317
0
  return NULL;
1318
181
}
isl_pw_qpolynomial_fold_project_out
Line
Count
Source
1287
1
{
1288
1
  int i;
1289
1
  enum isl_dim_type set_type;
1290
1
1291
1
  if (!pw)
1292
0
    return NULL;
1293
1
  if (n == 0 && !isl_space_get_tuple_name(pw->dim, type))
1294
0
    return pw;
1295
1
1296
1
  set_type = type == isl_dim_in ? isl_dim_set : 
type0
;
1297
1
1298
1
  pw = FN(PW,cow)(pw);
1299
1
  if (!pw)
1300
0
    return NULL;
1301
1
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1302
1
  if (!pw->dim)
1303
0
    goto error;
1304
2
  
for (i = 0; 1
i < pw->n;
++i1
) {
1305
1
    pw->p[i].set = isl_set_project_out(pw->p[i].set,
1306
1
              set_type, first, n);
1307
1
    if (!pw->p[i].set)
1308
0
      goto error;
1309
1
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1310
1
    if (!pw->p[i].FIELD)
1311
1
      
goto error0
;
1312
1
  }
1313
1
1314
1
  return pw;
1315
1
error:
1316
0
  FN(PW,free)(pw);
1317
0
  return NULL;
1318
1
}
Unexecuted instantiation: isl_pw_qpolynomial_project_out
1319
1320
/* Project the domain of pw onto its parameter space.
1321
 */
1322
__isl_give PW *FN(PW,project_domain_on_params)(__isl_take PW *pw)
1323
1
{
1324
1
  isl_space *space;
1325
1
  unsigned n;
1326
1
1327
1
  n = FN(PW,dim)(pw, isl_dim_in);
1328
1
  pw = FN(PW,project_out)(pw, isl_dim_in, 0, n);
1329
1
  space = FN(PW,get_domain_space)(pw);
1330
1
  space = isl_space_params(space);
1331
1
  pw = FN(PW,reset_domain_space)(pw, space);
1332
1
  return pw;
1333
1
}
Unexecuted instantiation: isl_pw_aff_project_domain_on_params
Unexecuted instantiation: isl_pw_multi_aff_project_domain_on_params
isl_pw_qpolynomial_fold_project_domain_on_params
Line
Count
Source
1323
1
{
1324
1
  isl_space *space;
1325
1
  unsigned n;
1326
1
1327
1
  n = FN(PW,dim)(pw, isl_dim_in);
1328
1
  pw = FN(PW,project_out)(pw, isl_dim_in, 0, n);
1329
1
  space = FN(PW,get_domain_space)(pw);
1330
1
  space = isl_space_params(space);
1331
1
  pw = FN(PW,reset_domain_space)(pw, space);
1332
1
  return pw;
1333
1
}
Unexecuted instantiation: isl_pw_qpolynomial_project_domain_on_params
1334
#endif
1335
1336
#ifndef NO_INSERT_DIMS
1337
__isl_give PW *FN(PW,insert_dims)(__isl_take PW *pw, enum isl_dim_type type,
1338
  unsigned first, unsigned n)
1339
3.39k
{
1340
3.39k
  int i;
1341
3.39k
  enum isl_dim_type set_type;
1342
3.39k
1343
3.39k
  if (!pw)
1344
0
    return NULL;
1345
3.39k
  if (n == 0 && 
!isl_space_is_named_or_nested(pw->dim, type)2
)
1346
2
    return pw;
1347
3.39k
1348
3.39k
  set_type = type == isl_dim_in ? isl_dim_set : 
type0
;
1349
3.39k
1350
3.39k
  pw = FN(PW,cow)(pw);
1351
3.39k
  if (!pw)
1352
0
    return NULL;
1353
3.39k
1354
3.39k
  pw->dim = isl_space_insert_dims(pw->dim, type, first, n);
1355
3.39k
  if (!pw->dim)
1356
0
    goto error;
1357
3.39k
1358
6.79k
  
for (i = 0; 3.39k
i < pw->n;
++i3.39k
) {
1359
3.39k
    pw->p[i].set = isl_set_insert_dims(pw->p[i].set,
1360
3.39k
                  set_type, first, n);
1361
3.39k
    if (!pw->p[i].set)
1362
0
      goto error;
1363
3.39k
    pw->p[i].FIELD = FN(EL,insert_dims)(pw->p[i].FIELD,
1364
3.39k
                type, first, n);
1365
3.39k
    if (!pw->p[i].FIELD)
1366
3.39k
      
goto error0
;
1367
3.39k
  }
1368
3.39k
1369
3.39k
  return pw;
1370
3.39k
error:
1371
0
  FN(PW,free)(pw);
1372
0
  return NULL;
1373
3.39k
}
isl_pw_aff_insert_dims
Line
Count
Source
1339
3.39k
{
1340
3.39k
  int i;
1341
3.39k
  enum isl_dim_type set_type;
1342
3.39k
1343
3.39k
  if (!pw)
1344
0
    return NULL;
1345
3.39k
  if (n == 0 && 
!isl_space_is_named_or_nested(pw->dim, type)2
)
1346
2
    return pw;
1347
3.39k
1348
3.39k
  set_type = type == isl_dim_in ? isl_dim_set : 
type0
;
1349
3.39k
1350
3.39k
  pw = FN(PW,cow)(pw);
1351
3.39k
  if (!pw)
1352
0
    return NULL;
1353
3.39k
1354
3.39k
  pw->dim = isl_space_insert_dims(pw->dim, type, first, n);
1355
3.39k
  if (!pw->dim)
1356
0
    goto error;
1357
3.39k
1358
6.79k
  
for (i = 0; 3.39k
i < pw->n;
++i3.39k
) {
1359
3.39k
    pw->p[i].set = isl_set_insert_dims(pw->p[i].set,
1360
3.39k
                  set_type, first, n);
1361
3.39k
    if (!pw->p[i].set)
1362
0
      goto error;
1363
3.39k
    pw->p[i].FIELD = FN(EL,insert_dims)(pw->p[i].FIELD,
1364
3.39k
                type, first, n);
1365
3.39k
    if (!pw->p[i].FIELD)
1366
3.39k
      
goto error0
;
1367
3.39k
  }
1368
3.39k
1369
3.39k
  return pw;
1370
3.39k
error:
1371
0
  FN(PW,free)(pw);
1372
0
  return NULL;
1373
3.39k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_insert_dims
Unexecuted instantiation: isl_pw_qpolynomial_insert_dims
1374
#endif
1375
1376
__isl_give PW *FN(PW,fix_dim)(__isl_take PW *pw,
1377
  enum isl_dim_type type, unsigned pos, isl_int v)
1378
1
{
1379
1
  int i;
1380
1
1381
1
  if (!pw)
1382
0
    return NULL;
1383
1
1384
1
  if (type == isl_dim_in)
1385
0
    type = isl_dim_set;
1386
1
1387
1
  pw = FN(PW,cow)(pw);
1388
1
  if (!pw)
1389
0
    return NULL;
1390
2
  
for (i = 0; 1
i < pw->n;
++i1
) {
1391
1
    pw->p[i].set = isl_set_fix(pw->p[i].set, type, pos, v);
1392
1
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
1393
0
      return FN(PW,free)(pw);
1394
1
  }
1395
1
1396
1
  return pw;
1397
1
}
Unexecuted instantiation: isl_pw_aff_fix_dim
Unexecuted instantiation: isl_pw_multi_aff_fix_dim
Unexecuted instantiation: isl_pw_qpolynomial_fold_fix_dim
isl_pw_qpolynomial_fix_dim
Line
Count
Source
1378
1
{
1379
1
  int i;
1380
1
1381
1
  if (!pw)
1382
0
    return NULL;
1383
1
1384
1
  if (type == isl_dim_in)
1385
0
    type = isl_dim_set;
1386
1
1387
1
  pw = FN(PW,cow)(pw);
1388
1
  if (!pw)
1389
0
    return NULL;
1390
2
  
for (i = 0; 1
i < pw->n;
++i1
) {
1391
1
    pw->p[i].set = isl_set_fix(pw->p[i].set, type, pos, v);
1392
1
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
1393
0
      return FN(PW,free)(pw);
1394
1
  }
1395
1
1396
1
  return pw;
1397
1
}
1398
1399
/* Fix the value of the variable at position "pos" of type "type" of "pw"
1400
 * to be equal to "v".
1401
 */
1402
__isl_give PW *FN(PW,fix_val)(__isl_take PW *pw,
1403
  enum isl_dim_type type, unsigned pos, __isl_take isl_val *v)
1404
1
{
1405
1
  if (!v)
1406
0
    return FN(PW,free)(pw);
1407
1
  if (!isl_val_is_int(v))
1408
1
    
isl_die0
(FN(PW,get_ctx)(pw), isl_error_invalid,
1409
1
      "expecting integer value", goto error);
1410
1
1411
1
  pw = FN(PW,fix_dim)(pw, type, pos, v->n);
1412
1
  isl_val_free(v);
1413
1
1414
1
  return pw;
1415
1
error:
1416
0
  isl_val_free(v);
1417
0
  return FN(PW,free)(pw);
1418
1
}
Unexecuted instantiation: isl_pw_aff_fix_val
Unexecuted instantiation: isl_pw_multi_aff_fix_val
Unexecuted instantiation: isl_pw_qpolynomial_fold_fix_val
isl_pw_qpolynomial_fix_val
Line
Count
Source
1404
1
{
1405
1
  if (!v)
1406
0
    return FN(PW,free)(pw);
1407
1
  if (!isl_val_is_int(v))
1408
1
    
isl_die0
(FN(PW,get_ctx)(pw), isl_error_invalid,
1409
1
      "expecting integer value", goto error);
1410
1
1411
1
  pw = FN(PW,fix_dim)(pw, type, pos, v->n);
1412
1
  isl_val_free(v);
1413
1
1414
1
  return pw;
1415
1
error:
1416
0
  isl_val_free(v);
1417
0
  return FN(PW,free)(pw);
1418
1
}
1419
1420
unsigned FN(PW,dim)(__isl_keep PW *pw, enum isl_dim_type type)
1421
25.4k
{
1422
25.4k
  return pw ? isl_space_dim(pw->dim, type) : 
00
;
1423
25.4k
}
isl_pw_aff_dim
Line
Count
Source
1421
3.39k
{
1422
3.39k
  return pw ? isl_space_dim(pw->dim, type) : 
00
;
1423
3.39k
}
isl_pw_multi_aff_dim
Line
Count
Source
1421
22.0k
{
1422
22.0k
  return pw ? isl_space_dim(pw->dim, type) : 
00
;
1423
22.0k
}
isl_pw_qpolynomial_fold_dim
Line
Count
Source
1421
3
{
1422
3
  return pw ? isl_space_dim(pw->dim, type) : 
00
;
1423
3
}
Unexecuted instantiation: isl_pw_qpolynomial_dim
1424
1425
__isl_give PW *FN(PW,split_dims)(__isl_take PW *pw,
1426
  enum isl_dim_type type, unsigned first, unsigned n)
1427
0
{
1428
0
  int i;
1429
0
1430
0
  if (!pw)
1431
0
    return NULL;
1432
0
  if (n == 0)
1433
0
    return pw;
1434
0
1435
0
  if (type == isl_dim_in)
1436
0
    type = isl_dim_set;
1437
0
1438
0
  pw = FN(PW,cow)(pw);
1439
0
  if (!pw)
1440
0
    return NULL;
1441
0
  if (!pw->dim)
1442
0
    goto error;
1443
0
  for (i = 0; i < pw->n; ++i) {
1444
0
    pw->p[i].set = isl_set_split_dims(pw->p[i].set, type, first, n);
1445
0
    if (!pw->p[i].set)
1446
0
      goto error;
1447
0
  }
1448
0
1449
0
  return pw;
1450
0
error:
1451
0
  FN(PW,free)(pw);
1452
0
  return NULL;
1453
0
}
Unexecuted instantiation: isl_pw_aff_split_dims
Unexecuted instantiation: isl_pw_multi_aff_split_dims
Unexecuted instantiation: isl_pw_qpolynomial_fold_split_dims
Unexecuted instantiation: isl_pw_qpolynomial_split_dims
1454
1455
#ifndef NO_OPT
1456
/* Compute the maximal value attained by the piecewise quasipolynomial
1457
 * on its domain or zero if the domain is empty.
1458
 * In the worst case, the domain is scanned completely,
1459
 * so the domain is assumed to be bounded.
1460
 */
1461
__isl_give isl_val *FN(PW,opt)(__isl_take PW *pw, int max)
1462
7
{
1463
7
  int i;
1464
7
  isl_val *opt;
1465
7
1466
7
  if (!pw)
1467
0
    return NULL;
1468
7
1469
7
  if (pw->n == 0) {
1470
0
    opt = isl_val_zero(FN(PW,get_ctx)(pw));
1471
0
    FN(PW,free)(pw);
1472
0
    return opt;
1473
0
  }
1474
7
1475
7
  opt = FN(EL,opt_on_domain)(FN(EL,copy)(pw->p[0].FIELD),
1476
7
          isl_set_copy(pw->p[0].set), max);
1477
7
  for (i = 1; i < pw->n; 
++i0
) {
1478
0
    isl_val *opt_i;
1479
0
    opt_i = FN(EL,opt_on_domain)(FN(EL,copy)(pw->p[i].FIELD),
1480
0
            isl_set_copy(pw->p[i].set), max);
1481
0
    if (max)
1482
0
      opt = isl_val_max(opt, opt_i);
1483
0
    else
1484
0
      opt = isl_val_min(opt, opt_i);
1485
0
  }
1486
7
1487
7
  FN(PW,free)(pw);
1488
7
  return opt;
1489
7
}
isl_pw_qpolynomial_fold_opt
Line
Count
Source
1462
7
{
1463
7
  int i;
1464
7
  isl_val *opt;
1465
7
1466
7
  if (!pw)
1467
0
    return NULL;
1468
7
1469
7
  if (pw->n == 0) {
1470
0
    opt = isl_val_zero(FN(PW,get_ctx)(pw));
1471
0
    FN(PW,free)(pw);
1472
0
    return opt;
1473
0
  }
1474
7
1475
7
  opt = FN(EL,opt_on_domain)(FN(EL,copy)(pw->p[0].FIELD),
1476
7
          isl_set_copy(pw->p[0].set), max);
1477
7
  for (i = 1; i < pw->n; 
++i0
) {
1478
0
    isl_val *opt_i;
1479
0
    opt_i = FN(EL,opt_on_domain)(FN(EL,copy)(pw->p[i].FIELD),
1480
0
            isl_set_copy(pw->p[i].set), max);
1481
0
    if (max)
1482
0
      opt = isl_val_max(opt, opt_i);
1483
0
    else
1484
0
      opt = isl_val_min(opt, opt_i);
1485
0
  }
1486
7
1487
7
  FN(PW,free)(pw);
1488
7
  return opt;
1489
7
}
Unexecuted instantiation: isl_pw_qpolynomial_opt
1490
1491
__isl_give isl_val *FN(PW,max)(__isl_take PW *pw)
1492
2
{
1493
2
  return FN(PW,opt)(pw, 1);
1494
2
}
isl_pw_qpolynomial_fold_max
Line
Count
Source
1492
2
{
1493
2
  return FN(PW,opt)(pw, 1);
1494
2
}
Unexecuted instantiation: isl_pw_qpolynomial_max
1495
1496
__isl_give isl_val *FN(PW,min)(__isl_take PW *pw)
1497
5
{
1498
5
  return FN(PW,opt)(pw, 0);
1499
5
}
isl_pw_qpolynomial_fold_min
Line
Count
Source
1497
5
{
1498
5
  return FN(PW,opt)(pw, 0);
1499
5
}
Unexecuted instantiation: isl_pw_qpolynomial_min
1500
#endif
1501
1502
/* Return the space of "pw".
1503
 */
1504
__isl_keep isl_space *FN(PW,peek_space)(__isl_keep PW *pw)
1505
199k
{
1506
199k
  return pw ? pw->dim : NULL;
1507
199k
}
isl_pw_aff_peek_space
Line
Count
Source
1505
141k
{
1506
141k
  return pw ? pw->dim : NULL;
1507
141k
}
isl_pw_multi_aff_peek_space
Line
Count
Source
1505
57.9k
{
1506
57.9k
  return pw ? pw->dim : NULL;
1507
57.9k
}
isl_pw_qpolynomial_fold_peek_space
Line
Count
Source
1505
1
{
1506
1
  return pw ? pw->dim : NULL;
1507
1
}
isl_pw_qpolynomial_peek_space
Line
Count
Source
1505
9
{
1506
9
  return pw ? pw->dim : NULL;
1507
9
}
1508
1509
__isl_give isl_space *FN(PW,get_space)(__isl_keep PW *pw)
1510
199k
{
1511
199k
  return isl_space_copy(FN(PW,peek_space)(pw));
1512
199k
}
isl_pw_aff_get_space
Line
Count
Source
1510
141k
{
1511
141k
  return isl_space_copy(FN(PW,peek_space)(pw));
1512
141k
}
isl_pw_multi_aff_get_space
Line
Count
Source
1510
57.9k
{
1511
57.9k
  return isl_space_copy(FN(PW,peek_space)(pw));
1512
57.9k
}
isl_pw_qpolynomial_fold_get_space
Line
Count
Source
1510
1
{
1511
1
  return isl_space_copy(FN(PW,peek_space)(pw));
1512
1
}
isl_pw_qpolynomial_get_space
Line
Count
Source
1510
9
{
1511
9
  return isl_space_copy(FN(PW,peek_space)(pw));
1512
9
}
1513
1514
__isl_give isl_space *FN(PW,get_domain_space)(__isl_keep PW *pw)
1515
105k
{
1516
105k
  return pw ? isl_space_domain(isl_space_copy(pw->dim)) : NULL;
1517
105k
}
isl_pw_aff_get_domain_space
Line
Count
Source
1515
105k
{
1516
105k
  return pw ? isl_space_domain(isl_space_copy(pw->dim)) : NULL;
1517
105k
}
isl_pw_multi_aff_get_domain_space
Line
Count
Source
1515
944
{
1516
944
  return pw ? isl_space_domain(isl_space_copy(pw->dim)) : NULL;
1517
944
}
isl_pw_qpolynomial_fold_get_domain_space
Line
Count
Source
1515
5
{
1516
5
  return pw ? isl_space_domain(isl_space_copy(pw->dim)) : NULL;
1517
5
}
isl_pw_qpolynomial_get_domain_space
Line
Count
Source
1515
2
{
1516
2
  return pw ? isl_space_domain(isl_space_copy(pw->dim)) : NULL;
1517
2
}
1518
1519
/* Return the position of the dimension of the given type and name
1520
 * in "pw".
1521
 * Return -1 if no such dimension can be found.
1522
 */
1523
int FN(PW,find_dim_by_name)(__isl_keep PW *pw,
1524
  enum isl_dim_type type, const char *name)
1525
0
{
1526
0
  if (!pw)
1527
0
    return -1;
1528
0
  return isl_space_find_dim_by_name(pw->dim, type, name);
1529
0
}
Unexecuted instantiation: isl_pw_aff_find_dim_by_name
Unexecuted instantiation: isl_pw_multi_aff_find_dim_by_name
Unexecuted instantiation: isl_pw_qpolynomial_fold_find_dim_by_name
Unexecuted instantiation: isl_pw_qpolynomial_find_dim_by_name
1530
1531
#ifndef NO_RESET_DIM
1532
/* Reset the space of "pw".  Since we don't know if the elements
1533
 * represent the spaces themselves or their domains, we pass along
1534
 * both when we call their reset_space_and_domain.
1535
 */
1536
static __isl_give PW *FN(PW,reset_space_and_domain)(__isl_take PW *pw,
1537
  __isl_take isl_space *space, __isl_take isl_space *domain)
1538
69.1k
{
1539
69.1k
  int i;
1540
69.1k
1541
69.1k
  pw = FN(PW,cow)(pw);
1542
69.1k
  if (!pw || !space || !domain)
1543
0
    goto error;
1544
69.1k
1545
138k
  
for (i = 0; 69.1k
i < pw->n;
++i69.7k
) {
1546
69.7k
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1547
69.7k
             isl_space_copy(domain));
1548
69.7k
    if (!pw->p[i].set)
1549
0
      goto error;
1550
69.7k
    pw->p[i].FIELD = FN(EL,reset_space_and_domain)(pw->p[i].FIELD,
1551
69.7k
            isl_space_copy(space), isl_space_copy(domain));
1552
69.7k
    if (!pw->p[i].FIELD)
1553
69.7k
      
goto error0
;
1554
69.7k
  }
1555
69.1k
1556
69.1k
  isl_space_free(domain);
1557
69.1k
1558
69.1k
  isl_space_free(pw->dim);
1559
69.1k
  pw->dim = space;
1560
69.1k
1561
69.1k
  return pw;
1562
69.1k
error:
1563
0
  isl_space_free(domain);
1564
0
  isl_space_free(space);
1565
0
  FN(PW,free)(pw);
1566
0
  return NULL;
1567
69.1k
}
isl_aff.c:isl_pw_aff_reset_space_and_domain
Line
Count
Source
1538
66.6k
{
1539
66.6k
  int i;
1540
66.6k
1541
66.6k
  pw = FN(PW,cow)(pw);
1542
66.6k
  if (!pw || !space || !domain)
1543
0
    goto error;
1544
66.6k
1545
133k
  
for (i = 0; 66.6k
i < pw->n;
++i67.1k
) {
1546
67.1k
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1547
67.1k
             isl_space_copy(domain));
1548
67.1k
    if (!pw->p[i].set)
1549
0
      goto error;
1550
67.1k
    pw->p[i].FIELD = FN(EL,reset_space_and_domain)(pw->p[i].FIELD,
1551
67.1k
            isl_space_copy(space), isl_space_copy(domain));
1552
67.1k
    if (!pw->p[i].FIELD)
1553
67.1k
      
goto error0
;
1554
67.1k
  }
1555
66.6k
1556
66.6k
  isl_space_free(domain);
1557
66.6k
1558
66.6k
  isl_space_free(pw->dim);
1559
66.6k
  pw->dim = space;
1560
66.6k
1561
66.6k
  return pw;
1562
66.6k
error:
1563
0
  isl_space_free(domain);
1564
0
  isl_space_free(space);
1565
0
  FN(PW,free)(pw);
1566
0
  return NULL;
1567
66.6k
}
isl_aff.c:isl_pw_multi_aff_reset_space_and_domain
Line
Count
Source
1538
2.42k
{
1539
2.42k
  int i;
1540
2.42k
1541
2.42k
  pw = FN(PW,cow)(pw);
1542
2.42k
  if (!pw || !space || !domain)
1543
0
    goto error;
1544
2.42k
1545
5.02k
  
for (i = 0; 2.42k
i < pw->n;
++i2.60k
) {
1546
2.60k
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1547
2.60k
             isl_space_copy(domain));
1548
2.60k
    if (!pw->p[i].set)
1549
0
      goto error;
1550
2.60k
    pw->p[i].FIELD = FN(EL,reset_space_and_domain)(pw->p[i].FIELD,
1551
2.60k
            isl_space_copy(space), isl_space_copy(domain));
1552
2.60k
    if (!pw->p[i].FIELD)
1553
2.60k
      
goto error0
;
1554
2.60k
  }
1555
2.42k
1556
2.42k
  isl_space_free(domain);
1557
2.42k
1558
2.42k
  isl_space_free(pw->dim);
1559
2.42k
  pw->dim = space;
1560
2.42k
1561
2.42k
  return pw;
1562
2.42k
error:
1563
0
  isl_space_free(domain);
1564
0
  isl_space_free(space);
1565
0
  FN(PW,free)(pw);
1566
0
  return NULL;
1567
2.42k
}
isl_fold.c:isl_pw_qpolynomial_fold_reset_space_and_domain
Line
Count
Source
1538
4
{
1539
4
  int i;
1540
4
1541
4
  pw = FN(PW,cow)(pw);
1542
4
  if (!pw || !space || !domain)
1543
0
    goto error;
1544
4
1545
7
  
for (i = 0; 4
i < pw->n;
++i3
) {
1546
3
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1547
3
             isl_space_copy(domain));
1548
3
    if (!pw->p[i].set)
1549
0
      goto error;
1550
3
    pw->p[i].FIELD = FN(EL,reset_space_and_domain)(pw->p[i].FIELD,
1551
3
            isl_space_copy(space), isl_space_copy(domain));
1552
3
    if (!pw->p[i].FIELD)
1553
3
      
goto error0
;
1554
3
  }
1555
4
1556
4
  isl_space_free(domain);
1557
4
1558
4
  isl_space_free(pw->dim);
1559
4
  pw->dim = space;
1560
4
1561
4
  return pw;
1562
4
error:
1563
0
  isl_space_free(domain);
1564
0
  isl_space_free(space);
1565
0
  FN(PW,free)(pw);
1566
0
  return NULL;
1567
4
}
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_reset_space_and_domain
1568
1569
__isl_give PW *FN(PW,reset_domain_space)(__isl_take PW *pw,
1570
  __isl_take isl_space *domain)
1571
54.1k
{
1572
54.1k
  isl_space *space;
1573
54.1k
1574
54.1k
  space = isl_space_extend_domain_with_range(isl_space_copy(domain),
1575
54.1k
               FN(PW,get_space)(pw));
1576
54.1k
  return FN(PW,reset_space_and_domain)(pw, space, domain);
1577
54.1k
}
isl_pw_aff_reset_domain_space
Line
Count
Source
1571
54.1k
{
1572
54.1k
  isl_space *space;
1573
54.1k
1574
54.1k
  space = isl_space_extend_domain_with_range(isl_space_copy(domain),
1575
54.1k
               FN(PW,get_space)(pw));
1576
54.1k
  return FN(PW,reset_space_and_domain)(pw, space, domain);
1577
54.1k
}
Unexecuted instantiation: isl_pw_multi_aff_reset_domain_space
isl_pw_qpolynomial_fold_reset_domain_space
Line
Count
Source
1571
1
{
1572
1
  isl_space *space;
1573
1
1574
1
  space = isl_space_extend_domain_with_range(isl_space_copy(domain),
1575
1
               FN(PW,get_space)(pw));
1576
1
  return FN(PW,reset_space_and_domain)(pw, space, domain);
1577
1
}
Unexecuted instantiation: isl_pw_qpolynomial_reset_domain_space
1578
1579
__isl_give PW *FN(PW,reset_space)(__isl_take PW *pw, __isl_take isl_space *dim)
1580
14.9k
{
1581
14.9k
  isl_space *domain;
1582
14.9k
1583
14.9k
  domain = isl_space_domain(isl_space_copy(dim));
1584
14.9k
  return FN(PW,reset_space_and_domain)(pw, dim, domain);
1585
14.9k
}
isl_pw_aff_reset_space
Line
Count
Source
1580
12.5k
{
1581
12.5k
  isl_space *domain;
1582
12.5k
1583
12.5k
  domain = isl_space_domain(isl_space_copy(dim));
1584
12.5k
  return FN(PW,reset_space_and_domain)(pw, dim, domain);
1585
12.5k
}
isl_pw_multi_aff_reset_space
Line
Count
Source
1580
2.42k
{
1581
2.42k
  isl_space *domain;
1582
2.42k
1583
2.42k
  domain = isl_space_domain(isl_space_copy(dim));
1584
2.42k
  return FN(PW,reset_space_and_domain)(pw, dim, domain);
1585
2.42k
}
isl_pw_qpolynomial_fold_reset_space
Line
Count
Source
1580
3
{
1581
3
  isl_space *domain;
1582
3
1583
3
  domain = isl_space_domain(isl_space_copy(dim));
1584
3
  return FN(PW,reset_space_and_domain)(pw, dim, domain);
1585
3
}
Unexecuted instantiation: isl_pw_qpolynomial_reset_space
1586
1587
__isl_give PW *FN(PW,set_tuple_id)(__isl_take PW *pw, enum isl_dim_type type,
1588
  __isl_take isl_id *id)
1589
542
{
1590
542
  isl_space *space;
1591
542
1592
542
  pw = FN(PW,cow)(pw);
1593
542
  if (!pw)
1594
0
    goto error;
1595
542
1596
542
  space = FN(PW,get_space)(pw);
1597
542
  space = isl_space_set_tuple_id(space, type, id);
1598
542
1599
542
  return FN(PW,reset_space)(pw, space);
1600
542
error:
1601
0
  isl_id_free(id);
1602
0
  return FN(PW,free)(pw);
1603
542
}
isl_pw_aff_set_tuple_id
Line
Count
Source
1589
542
{
1590
542
  isl_space *space;
1591
542
1592
542
  pw = FN(PW,cow)(pw);
1593
542
  if (!pw)
1594
0
    goto error;
1595
542
1596
542
  space = FN(PW,get_space)(pw);
1597
542
  space = isl_space_set_tuple_id(space, type, id);
1598
542
1599
542
  return FN(PW,reset_space)(pw, space);
1600
542
error:
1601
0
  isl_id_free(id);
1602
0
  return FN(PW,free)(pw);
1603
542
}
Unexecuted instantiation: isl_pw_multi_aff_set_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_set_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_set_tuple_id
1604
1605
/* Drop the id on the specified tuple.
1606
 */
1607
__isl_give PW *FN(PW,reset_tuple_id)(__isl_take PW *pw, enum isl_dim_type type)
1608
0
{
1609
0
  isl_space *space;
1610
0
1611
0
  if (!pw)
1612
0
    return NULL;
1613
0
  if (!FN(PW,has_tuple_id)(pw, type))
1614
0
    return pw;
1615
0
1616
0
  pw = FN(PW,cow)(pw);
1617
0
  if (!pw)
1618
0
    return NULL;
1619
0
1620
0
  space = FN(PW,get_space)(pw);
1621
0
  space = isl_space_reset_tuple_id(space, type);
1622
0
1623
0
  return FN(PW,reset_space)(pw, space);
1624
0
}
Unexecuted instantiation: isl_pw_aff_reset_tuple_id
Unexecuted instantiation: isl_pw_multi_aff_reset_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_reset_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_reset_tuple_id
1625
1626
__isl_give PW *FN(PW,set_dim_id)(__isl_take PW *pw,
1627
  enum isl_dim_type type, unsigned pos, __isl_take isl_id *id)
1628
0
{
1629
0
  pw = FN(PW,cow)(pw);
1630
0
  if (!pw)
1631
0
    goto error;
1632
0
  pw->dim = isl_space_set_dim_id(pw->dim, type, pos, id);
1633
0
  return FN(PW,reset_space)(pw, isl_space_copy(pw->dim));
1634
0
error:
1635
0
  isl_id_free(id);
1636
0
  return FN(PW,free)(pw);
1637
0
}
Unexecuted instantiation: isl_pw_aff_set_dim_id
Unexecuted instantiation: isl_pw_multi_aff_set_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_set_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_set_dim_id
1638
#endif
1639
1640
/* Reset the user pointer on all identifiers of parameters and tuples
1641
 * of the space of "pw".
1642
 */
1643
__isl_give PW *FN(PW,reset_user)(__isl_take PW *pw)
1644
0
{
1645
0
  isl_space *space;
1646
0
1647
0
  space = FN(PW,get_space)(pw);
1648
0
  space = isl_space_reset_user(space);
1649
0
1650
0
  return FN(PW,reset_space)(pw, space);
1651
0
}
Unexecuted instantiation: isl_pw_aff_reset_user
Unexecuted instantiation: isl_pw_multi_aff_reset_user
Unexecuted instantiation: isl_pw_qpolynomial_fold_reset_user
Unexecuted instantiation: isl_pw_qpolynomial_reset_user
1652
1653
isl_bool FN(PW,has_equal_space)(__isl_keep PW *pw1, __isl_keep PW *pw2)
1654
4
{
1655
4
  if (!pw1 || !pw2)
1656
0
    return isl_bool_error;
1657
4
1658
4
  return isl_space_is_equal(pw1->dim, pw2->dim);
1659
4
}
Unexecuted instantiation: isl_pw_aff_has_equal_space
Unexecuted instantiation: isl_pw_multi_aff_has_equal_space
Unexecuted instantiation: isl_pw_qpolynomial_fold_has_equal_space
isl_pw_qpolynomial_has_equal_space
Line
Count
Source
1654
4
{
1655
4
  if (!pw1 || !pw2)
1656
0
    return isl_bool_error;
1657
4
1658
4
  return isl_space_is_equal(pw1->dim, pw2->dim);
1659
4
}
1660
1661
#ifndef NO_MORPH
1662
__isl_give PW *FN(PW,morph_domain)(__isl_take PW *pw,
1663
  __isl_take isl_morph *morph)
1664
2
{
1665
2
  int i;
1666
2
  isl_ctx *ctx;
1667
2
1668
2
  if (!pw || !morph)
1669
0
    goto error;
1670
2
1671
2
  ctx = isl_space_get_ctx(pw->dim);
1672
2
  isl_assert(ctx, isl_space_is_domain_internal(morph->dom->dim, pw->dim),
1673
2
    goto error);
1674
2
1675
2
  pw = FN(PW,cow)(pw);
1676
2
  if (!pw)
1677
0
    goto error;
1678
2
  pw->dim = isl_space_extend_domain_with_range(
1679
2
      isl_space_copy(morph->ran->dim), pw->dim);
1680
2
  if (!pw->dim)
1681
0
    goto error;
1682
2
1683
3
  
for (i = 0; 2
i < pw->n;
++i1
) {
1684
1
    pw->p[i].set = isl_morph_set(isl_morph_copy(morph), pw->p[i].set);
1685
1
    if (!pw->p[i].set)
1686
0
      goto error;
1687
1
    pw->p[i].FIELD = FN(EL,morph_domain)(pw->p[i].FIELD,
1688
1
            isl_morph_copy(morph));
1689
1
    if (!pw->p[i].FIELD)
1690
1
      
goto error0
;
1691
1
  }
1692
2
1693
2
  isl_morph_free(morph);
1694
2
1695
2
  return pw;
1696
2
error:
1697
0
  FN(PW,free)(pw);
1698
0
  isl_morph_free(morph);
1699
0
  return NULL;
1700
2
}
isl_pw_qpolynomial_fold_morph_domain
Line
Count
Source
1664
2
{
1665
2
  int i;
1666
2
  isl_ctx *ctx;
1667
2
1668
2
  if (!pw || !morph)
1669
0
    goto error;
1670
2
1671
2
  ctx = isl_space_get_ctx(pw->dim);
1672
2
  isl_assert(ctx, isl_space_is_domain_internal(morph->dom->dim, pw->dim),
1673
2
    goto error);
1674
2
1675
2
  pw = FN(PW,cow)(pw);
1676
2
  if (!pw)
1677
0
    goto error;
1678
2
  pw->dim = isl_space_extend_domain_with_range(
1679
2
      isl_space_copy(morph->ran->dim), pw->dim);
1680
2
  if (!pw->dim)
1681
0
    goto error;
1682
2
1683
3
  
for (i = 0; 2
i < pw->n;
++i1
) {
1684
1
    pw->p[i].set = isl_morph_set(isl_morph_copy(morph), pw->p[i].set);
1685
1
    if (!pw->p[i].set)
1686
0
      goto error;
1687
1
    pw->p[i].FIELD = FN(EL,morph_domain)(pw->p[i].FIELD,
1688
1
            isl_morph_copy(morph));
1689
1
    if (!pw->p[i].FIELD)
1690
1
      
goto error0
;
1691
1
  }
1692
2
1693
2
  isl_morph_free(morph);
1694
2
1695
2
  return pw;
1696
2
error:
1697
0
  FN(PW,free)(pw);
1698
0
  isl_morph_free(morph);
1699
0
  return NULL;
1700
2
}
Unexecuted instantiation: isl_pw_qpolynomial_morph_domain
1701
#endif
1702
1703
int FN(PW,n_piece)(__isl_keep PW *pw)
1704
11.0k
{
1705
11.0k
  return pw ? pw->n : 
00
;
1706
11.0k
}
isl_pw_aff_n_piece
Line
Count
Source
1704
11.0k
{
1705
11.0k
  return pw ? pw->n : 
00
;
1706
11.0k
}
Unexecuted instantiation: isl_pw_multi_aff_n_piece
Unexecuted instantiation: isl_pw_qpolynomial_fold_n_piece
Unexecuted instantiation: isl_pw_qpolynomial_n_piece
1707
1708
isl_stat FN(PW,foreach_piece)(__isl_keep PW *pw,
1709
  isl_stat (*fn)(__isl_take isl_set *set, __isl_take EL *el, void *user),
1710
  void *user)
1711
12.2k
{
1712
12.2k
  int i;
1713
12.2k
1714
12.2k
  if (!pw)
1715
0
    return isl_stat_error;
1716
12.2k
1717
21.1k
  
for (i = 0; 12.2k
i < pw->n;
++i8.85k
)
1718
12.5k
    if (fn(isl_set_copy(pw->p[i].set),
1719
12.5k
        FN(EL,copy)(pw->p[i].FIELD), user) < 0)
1720
3.69k
      return isl_stat_error;
1721
12.2k
1722
12.2k
  
return isl_stat_ok8.59k
;
1723
12.2k
}
isl_pw_aff_foreach_piece
Line
Count
Source
1711
12.2k
{
1712
12.2k
  int i;
1713
12.2k
1714
12.2k
  if (!pw)
1715
0
    return isl_stat_error;
1716
12.2k
1717
21.1k
  
for (i = 0; 12.2k
i < pw->n;
++i8.85k
)
1718
12.5k
    if (fn(isl_set_copy(pw->p[i].set),
1719
12.5k
        FN(EL,copy)(pw->p[i].FIELD), user) < 0)
1720
3.69k
      return isl_stat_error;
1721
12.2k
1722
12.2k
  
return isl_stat_ok8.59k
;
1723
12.2k
}
isl_pw_multi_aff_foreach_piece
Line
Count
Source
1711
2
{
1712
2
  int i;
1713
2
1714
2
  if (!pw)
1715
0
    return isl_stat_error;
1716
2
1717
4
  
for (i = 0; 2
i < pw->n;
++i2
)
1718
2
    if (fn(isl_set_copy(pw->p[i].set),
1719
2
        FN(EL,copy)(pw->p[i].FIELD), user) < 0)
1720
0
      return isl_stat_error;
1721
2
1722
2
  return isl_stat_ok;
1723
2
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_foreach_piece
isl_pw_qpolynomial_foreach_piece
Line
Count
Source
1711
1
{
1712
1
  int i;
1713
1
1714
1
  if (!pw)
1715
0
    return isl_stat_error;
1716
1
1717
3
  
for (i = 0; 1
i < pw->n;
++i2
)
1718
2
    if (fn(isl_set_copy(pw->p[i].set),
1719
2
        FN(EL,copy)(pw->p[i].FIELD), user) < 0)
1720
0
      return isl_stat_error;
1721
1
1722
1
  return isl_stat_ok;
1723
1
}
1724
1725
#ifndef NO_LIFT
1726
static isl_bool any_divs(__isl_keep isl_set *set)
1727
2
{
1728
2
  int i;
1729
2
1730
2
  if (!set)
1731
0
    return isl_bool_error;
1732
2
1733
3
  
for (i = 0; 2
i < set->n;
++i1
)
1734
2
    if (set->p[i]->n_div > 0)
1735
1
      return isl_bool_true;
1736
2
1737
2
  
return isl_bool_false1
;
1738
2
}
isl_fold.c:any_divs
Line
Count
Source
1727
2
{
1728
2
  int i;
1729
2
1730
2
  if (!set)
1731
0
    return isl_bool_error;
1732
2
1733
3
  
for (i = 0; 2
i < set->n;
++i1
)
1734
2
    if (set->p[i]->n_div > 0)
1735
1
      return isl_bool_true;
1736
2
1737
2
  
return isl_bool_false1
;
1738
2
}
Unexecuted instantiation: isl_polynomial.c:any_divs
1739
1740
static isl_stat foreach_lifted_subset(__isl_take isl_set *set,
1741
  __isl_take EL *el,
1742
  isl_stat (*fn)(__isl_take isl_set *set, __isl_take EL *el,
1743
    void *user), void *user)
1744
1
{
1745
1
  int i;
1746
1
1747
1
  if (!set || !el)
1748
0
    goto error;
1749
1
1750
2
  
for (i = 0; 1
i < set->n;
++i1
) {
1751
1
    isl_set *lift;
1752
1
    EL *copy;
1753
1
1754
1
    lift = isl_set_from_basic_set(isl_basic_set_copy(set->p[i]));
1755
1
    lift = isl_set_lift(lift);
1756
1
1757
1
    copy = FN(EL,copy)(el);
1758
1
    copy = FN(EL,lift)(copy, isl_set_get_space(lift));
1759
1
1760
1
    if (fn(lift, copy, user) < 0)
1761
0
      goto error;
1762
1
  }
1763
1
1764
1
  isl_set_free(set);
1765
1
  FN(EL,free)(el);
1766
1
1767
1
  return isl_stat_ok;
1768
1
error:
1769
0
  isl_set_free(set);
1770
0
  FN(EL,free)(el);
1771
0
  return isl_stat_error;
1772
1
}
isl_fold.c:foreach_lifted_subset
Line
Count
Source
1744
1
{
1745
1
  int i;
1746
1
1747
1
  if (!set || !el)
1748
0
    goto error;
1749
1
1750
2
  
for (i = 0; 1
i < set->n;
++i1
) {
1751
1
    isl_set *lift;
1752
1
    EL *copy;
1753
1
1754
1
    lift = isl_set_from_basic_set(isl_basic_set_copy(set->p[i]));
1755
1
    lift = isl_set_lift(lift);
1756
1
1757
1
    copy = FN(EL,copy)(el);
1758
1
    copy = FN(EL,lift)(copy, isl_set_get_space(lift));
1759
1
1760
1
    if (fn(lift, copy, user) < 0)
1761
0
      goto error;
1762
1
  }
1763
1
1764
1
  isl_set_free(set);
1765
1
  FN(EL,free)(el);
1766
1
1767
1
  return isl_stat_ok;
1768
1
error:
1769
0
  isl_set_free(set);
1770
0
  FN(EL,free)(el);
1771
0
  return isl_stat_error;
1772
1
}
Unexecuted instantiation: isl_polynomial.c:foreach_lifted_subset
1773
1774
isl_stat FN(PW,foreach_lifted_piece)(__isl_keep PW *pw,
1775
  isl_stat (*fn)(__isl_take isl_set *set, __isl_take EL *el,
1776
        void *user), void *user)
1777
2
{
1778
2
  int i;
1779
2
1780
2
  if (!pw)
1781
0
    return isl_stat_error;
1782
2
1783
4
  
for (i = 0; 2
i < pw->n;
++i2
) {
1784
2
    isl_bool any;
1785
2
    isl_set *set;
1786
2
    EL *el;
1787
2
1788
2
    any = any_divs(pw->p[i].set);
1789
2
    if (any < 0)
1790
0
      return isl_stat_error;
1791
2
    set = isl_set_copy(pw->p[i].set);
1792
2
    el = FN(EL,copy)(pw->p[i].FIELD);
1793
2
    if (!any) {
1794
1
      if (fn(set, el, user) < 0)
1795
0
        return isl_stat_error;
1796
1
      continue;
1797
1
    }
1798
1
    if (foreach_lifted_subset(set, el, fn, user) < 0)
1799
0
      return isl_stat_error;
1800
1
  }
1801
2
1802
2
  return isl_stat_ok;
1803
2
}
isl_pw_qpolynomial_fold_foreach_lifted_piece
Line
Count
Source
1777
2
{
1778
2
  int i;
1779
2
1780
2
  if (!pw)
1781
0
    return isl_stat_error;
1782
2
1783
4
  
for (i = 0; 2
i < pw->n;
++i2
) {
1784
2
    isl_bool any;
1785
2
    isl_set *set;
1786
2
    EL *el;
1787
2
1788
2
    any = any_divs(pw->p[i].set);
1789
2
    if (any < 0)
1790
0
      return isl_stat_error;
1791
2
    set = isl_set_copy(pw->p[i].set);
1792
2
    el = FN(EL,copy)(pw->p[i].FIELD);
1793
2
    if (!any) {
1794
1
      if (fn(set, el, user) < 0)
1795
0
        return isl_stat_error;
1796
1
      continue;
1797
1
    }
1798
1
    if (foreach_lifted_subset(set, el, fn, user) < 0)
1799
0
      return isl_stat_error;
1800
1
  }
1801
2
1802
2
  return isl_stat_ok;
1803
2
}
Unexecuted instantiation: isl_pw_qpolynomial_foreach_lifted_piece
1804
#endif
1805
1806
#ifndef NO_MOVE_DIMS
1807
__isl_give PW *FN(PW,move_dims)(__isl_take PW *pw,
1808
  enum isl_dim_type dst_type, unsigned dst_pos,
1809
  enum isl_dim_type src_type, unsigned src_pos, unsigned n)
1810
1
{
1811
1
  int i;
1812
1
1813
1
  pw = FN(PW,cow)(pw);
1814
1
  if (!pw)
1815
0
    return NULL;
1816
1
1817
1
  pw->dim = isl_space_move_dims(pw->dim, dst_type, dst_pos, src_type, src_pos, n);
1818
1
  if (!pw->dim)
1819
0
    goto error;
1820
1
1821
2
  
for (i = 0; 1
i < pw->n;
++i1
) {
1822
1
    pw->p[i].FIELD = FN(EL,move_dims)(pw->p[i].FIELD,
1823
1
          dst_type, dst_pos, src_type, src_pos, n);
1824
1
    if (!pw->p[i].FIELD)
1825
1
      
goto error0
;
1826
1
  }
1827
1
1828
1
  if (dst_type == isl_dim_in)
1829
0
    dst_type = isl_dim_set;
1830
1
  if (src_type == isl_dim_in)
1831
1
    src_type = isl_dim_set;
1832
1
1833
2
  for (i = 0; i < pw->n; 
++i1
) {
1834
1
    pw->p[i].set = isl_set_move_dims(pw->p[i].set,
1835
1
            dst_type, dst_pos,
1836
1
            src_type, src_pos, n);
1837
1
    if (!pw->p[i].set)
1838
0
      goto error;
1839
1
  }
1840
1
1841
1
  return pw;
1842
1
error:
1843
0
  FN(PW,free)(pw);
1844
0
  return NULL;
1845
1
}
Unexecuted instantiation: isl_pw_aff_move_dims
Unexecuted instantiation: isl_pw_multi_aff_move_dims
Unexecuted instantiation: isl_pw_qpolynomial_fold_move_dims
isl_pw_qpolynomial_move_dims
Line
Count
Source
1810
1
{
1811
1
  int i;
1812
1
1813
1
  pw = FN(PW,cow)(pw);
1814
1
  if (!pw)
1815
0
    return NULL;
1816
1