Coverage Report

Created: 2017-11-23 03:11

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