Coverage Report

Created: 2017-06-23 12:40

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/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
215k
{
27
215k
  isl_ctx *ctx;
28
215k
  struct PW *pw;
29
215k
30
215k
  if (!dim)
31
0
    return NULL;
32
215k
  ctx = isl_space_get_ctx(dim);
33
215k
  isl_assert(ctx, n >= 0, goto error);
34
215k
  
pw = 215k
isl_alloc215k
(ctx, struct PW,
35
215k
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
36
215k
  if (!pw)
37
0
    goto error;
38
215k
39
215k
  pw->ref = 1;
40
215k
#ifdef HAS_TYPE
41
  pw->type = type;
42
#endif
43
215k
  pw->size = n;
44
215k
  pw->n = 0;
45
215k
  pw->dim = dim;
46
215k
  return pw;
47
0
error:
48
0
  isl_space_free(dim);
49
0
  return NULL;
50
215k
}
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 = 35
isl_alloc35
(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
0
error:
48
0
  isl_space_free(dim);
49
0
  return NULL;
50
35
}
isl_pw_multi_aff_alloc_size
Line
Count
Source
26
21.2k
{
27
21.2k
  isl_ctx *ctx;
28
21.2k
  struct PW *pw;
29
21.2k
30
21.2k
  if (!dim)
31
0
    return NULL;
32
21.2k
  ctx = isl_space_get_ctx(dim);
33
21.2k
  isl_assert(ctx, n >= 0, goto error);
34
21.2k
  
pw = 21.2k
isl_alloc21.2k
(ctx, struct PW,
35
21.2k
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
36
21.2k
  if (!pw)
37
0
    goto error;
38
21.2k
39
21.2k
  pw->ref = 1;
40
21.2k
#ifdef HAS_TYPE
41
  pw->type = type;
42
#endif
43
21.2k
  pw->size = n;
44
21.2k
  pw->n = 0;
45
21.2k
  pw->dim = dim;
46
21.2k
  return pw;
47
0
error:
48
0
  isl_space_free(dim);
49
0
  return NULL;
50
21.2k
}
isl_pw_aff_alloc_size
Line
Count
Source
26
193k
{
27
193k
  isl_ctx *ctx;
28
193k
  struct PW *pw;
29
193k
30
193k
  if (!dim)
31
0
    return NULL;
32
193k
  ctx = isl_space_get_ctx(dim);
33
193k
  isl_assert(ctx, n >= 0, goto error);
34
193k
  
pw = 193k
isl_alloc193k
(ctx, struct PW,
35
193k
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
36
193k
  if (!pw)
37
0
    goto error;
38
193k
39
193k
  pw->ref = 1;
40
193k
#ifdef HAS_TYPE
41
  pw->type = type;
42
#endif
43
193k
  pw->size = n;
44
193k
  pw->n = 0;
45
193k
  pw->dim = dim;
46
193k
  return pw;
47
0
error:
48
0
  isl_space_free(dim);
49
0
  return NULL;
50
193k
}
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 = 104
isl_alloc104
(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
104
#ifdef HAS_TYPE
41
  pw->type = type;
42
#endif
43
104
  pw->size = n;
44
104
  pw->n = 0;
45
104
  pw->dim = dim;
46
104
  return pw;
47
0
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
6.52k
{
60
6.52k
  return FN(PW,alloc_size)(dim, 0);
61
6.52k
}
isl_pw_multi_aff_empty
Line
Count
Source
59
3.20k
{
60
3.20k
  return FN(PW,alloc_size)(dim, 0);
61
3.20k
}
isl_pw_aff_empty
Line
Count
Source
59
3.32k
{
60
3.32k
  return FN(PW,alloc_size)(dim, 0);
61
3.32k
}
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
214k
{
67
214k
  isl_ctx *ctx;
68
214k
  isl_space *el_dim = NULL;
69
214k
70
214k
  if (
!pw || 214k
!set214k
||
!el214k
)
71
0
    goto error;
72
214k
73
214k
  
if (214k
isl_set_plain_is_empty(set) || 214k
FN213k
(EL,EL_IS_ZERO)(el)213k
)
{627
74
627
    isl_set_free(set);
75
627
    FN(EL,free)(el);
76
627
    return pw;
77
627
  }
78
214k
79
213k
  ctx = isl_set_get_ctx(set);
80
213k
#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
213k
  
el_dim = 18
FN213k
(EL,get_space(el));
86
213k
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
87
213k
  
isl_assert213k
(ctx, pw->n < pw->size, goto error);213k
88
213k
89
213k
  pw->p[pw->n].set = set;
90
213k
  pw->p[pw->n].FIELD = el;
91
213k
  pw->n++;
92
213k
  
93
213k
  isl_space_free(el_dim);
94
213k
  return pw;
95
0
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
213k
}
isl_pw_multi_aff_add_piece
Line
Count
Source
66
19.6k
{
67
19.6k
  isl_ctx *ctx;
68
19.6k
  isl_space *el_dim = NULL;
69
19.6k
70
19.6k
  if (
!pw || 19.6k
!set19.6k
||
!el19.6k
)
71
0
    goto error;
72
19.6k
73
19.6k
  
if (19.6k
isl_set_plain_is_empty(set) || 19.6k
FN19.4k
(EL,EL_IS_ZERO)(el)19.4k
)
{259
74
259
    isl_set_free(set);
75
259
    FN(EL,free)(el);
76
259
    return pw;
77
259
  }
78
19.6k
79
19.4k
  ctx = isl_set_get_ctx(set);
80
19.4k
#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
19.4k
  el_dim = FN(EL,get_space(el));
86
19.4k
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
87
19.4k
  
isl_assert19.4k
(ctx, pw->n < pw->size, goto error);19.4k
88
19.4k
89
19.4k
  pw->p[pw->n].set = set;
90
19.4k
  pw->p[pw->n].FIELD = el;
91
19.4k
  pw->n++;
92
19.4k
  
93
19.4k
  isl_space_free(el_dim);
94
19.4k
  return pw;
95
0
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
19.4k
}
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 || 24
!set24
||
!el24
)
71
0
    goto error;
72
24
73
24
  
if (24
isl_set_plain_is_empty(set) || 24
FN18
(EL,EL_IS_ZERO)(el)18
)
{6
74
6
    isl_set_free(set);
75
6
    FN(EL,free)(el);
76
6
    return pw;
77
6
  }
78
24
79
18
  ctx = isl_set_get_ctx(set);
80
18
#ifdef HAS_TYPE
81
18
  if (pw->type != el->type)
82
0
    isl_die(ctx, isl_error_invalid, "fold types don't match",
83
18
      goto error);
84
18
#endif
85
18
  
el_dim = 18
FN18
(EL,get_space(el));
86
18
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
87
18
  
isl_assert18
(ctx, pw->n < pw->size, goto error);18
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
0
error:
96
0
  isl_space_free(el_dim);
97
0
  FN(PW,free)(pw);
98
0
  isl_set_free(set);
99
0
  FN(EL,free)(el);
100
0
  return NULL;
101
18
}
isl_pw_qpolynomial_add_piece
Line
Count
Source
66
151
{
67
151
  isl_ctx *ctx;
68
151
  isl_space *el_dim = NULL;
69
151
70
151
  if (
!pw || 151
!set151
||
!el151
)
71
0
    goto error;
72
151
73
151
  
if (151
isl_set_plain_is_empty(set) || 151
FN107
(EL,EL_IS_ZERO)(el)107
)
{53
74
53
    isl_set_free(set);
75
53
    FN(EL,free)(el);
76
53
    return pw;
77
53
  }
78
151
79
98
  ctx = isl_set_get_ctx(set);
80
98
#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_assert98
(ctx, pw->n < pw->size, goto error);98
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
0
error:
96
0
  isl_space_free(el_dim);
97
0
  FN(PW,free)(pw);
98
0
  isl_set_free(set);
99
0
  FN(EL,free)(el);
100
0
  return NULL;
101
98
}
isl_pw_aff_add_piece
Line
Count
Source
66
194k
{
67
194k
  isl_ctx *ctx;
68
194k
  isl_space *el_dim = NULL;
69
194k
70
194k
  if (
!pw || 194k
!set194k
||
!el194k
)
71
0
    goto error;
72
194k
73
194k
  
if (194k
isl_set_plain_is_empty(set) || 194k
FN194k
(EL,EL_IS_ZERO)(el)194k
)
{309
74
309
    isl_set_free(set);
75
309
    FN(EL,free)(el);
76
309
    return pw;
77
309
  }
78
194k
79
194k
  ctx = isl_set_get_ctx(set);
80
194k
#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
194k
  el_dim = FN(EL,get_space(el));
86
194k
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
87
194k
  
isl_assert194k
(ctx, pw->n < pw->size, goto error);194k
88
194k
89
194k
  pw->p[pw->n].set = set;
90
194k
  pw->p[pw->n].FIELD = el;
91
194k
  pw->n++;
92
194k
  
93
194k
  isl_space_free(el_dim);
94
194k
  return pw;
95
0
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
194k
}
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
86.0k
{
110
86.0k
  PW *pw;
111
86.0k
112
86.0k
  if (
!set || 86.0k
!el86.0k
)
113
0
    goto error;
114
86.0k
115
86.0k
#ifdef HAS_TYPE
116
12
  
pw = 12
FN12
(PW,alloc_size)(
FN12
(EL,get_space)(el), type, 1);
117
12
#else
118
86.0k
  
pw = 86.0k
FN86.0k
(PW,alloc_size)(
FN86.0k
(EL,get_space)(el), 1);
119
86.0k
#endif
120
86.0k
121
86.0k
  return FN(PW,add_piece)(pw, set, el);
122
error:
123
  isl_set_free(set);
124
  FN(EL,free)(el);
125
  return NULL;
126
}
isl_pw_aff_alloc
Line
Count
Source
109
70.2k
{
110
70.2k
  PW *pw;
111
70.2k
112
70.2k
  if (
!set || 70.2k
!el70.2k
)
113
0
    goto error;
114
70.2k
115
70.2k
#ifdef HAS_TYPE
116
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), type, 1);
117
#else
118
70.2k
  
pw = 70.2k
FN70.2k
(PW,alloc_size)(
FN70.2k
(EL,get_space)(el), 1);
119
70.2k
#endif
120
70.2k
121
70.2k
  return FN(PW,add_piece)(pw, set, el);
122
0
error:
123
0
  isl_set_free(set);
124
0
  FN(EL,free)(el);
125
0
  return NULL;
126
70.2k
}
isl_pw_qpolynomial_alloc
Line
Count
Source
109
33
{
110
33
  PW *pw;
111
33
112
33
  if (
!set || 33
!el33
)
113
0
    goto error;
114
33
115
33
#ifdef HAS_TYPE
116
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), type, 1);
117
#else
118
33
  
pw = 33
FN33
(PW,alloc_size)(
FN33
(EL,get_space)(el), 1);
119
33
#endif
120
33
121
33
  return FN(PW,add_piece)(pw, set, el);
122
0
error:
123
0
  isl_set_free(set);
124
0
  FN(EL,free)(el);
125
0
  return NULL;
126
33
}
isl_pw_qpolynomial_fold_alloc
Line
Count
Source
109
12
{
110
12
  PW *pw;
111
12
112
12
  if (
!set || 12
!el12
)
113
0
    goto error;
114
12
115
12
#ifdef HAS_TYPE
116
12
  
pw = 12
FN12
(PW,alloc_size)(
FN12
(EL,get_space)(el), type, 1);
117
12
#else
118
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), 1);
119
#endif
120
12
121
12
  return FN(PW,add_piece)(pw, set, el);
122
0
error:
123
0
  isl_set_free(set);
124
0
  FN(EL,free)(el);
125
0
  return NULL;
126
12
}
isl_pw_multi_aff_alloc
Line
Count
Source
109
15.7k
{
110
15.7k
  PW *pw;
111
15.7k
112
15.7k
  if (
!set || 15.7k
!el15.7k
)
113
0
    goto error;
114
15.7k
115
15.7k
#ifdef HAS_TYPE
116
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), type, 1);
117
#else
118
15.7k
  
pw = 15.7k
FN15.7k
(PW,alloc_size)(
FN15.7k
(EL,get_space)(el), 1);
119
15.7k
#endif
120
15.7k
121
15.7k
  return FN(PW,add_piece)(pw, set, el);
122
0
error:
123
0
  isl_set_free(set);
124
0
  FN(EL,free)(el);
125
0
  return NULL;
126
15.7k
}
127
128
__isl_give PW *FN(PW,dup)(__isl_keep PW *pw)
129
{
130
  int i;
131
  PW *dup;
132
133
  if (!pw)
134
    return NULL;
135
136
#ifdef HAS_TYPE
137
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
138
#else
139
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
140
#endif
141
  if (!dup)
142
    return NULL;
143
144
  for (i = 0; i < pw->n; ++i)
145
    dup = FN(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
146
              FN(EL,copy)(pw->p[i].FIELD));
147
148
  return dup;
149
}
isl_pw_aff_dup
Line
Count
Source
129
42.2k
{
130
42.2k
  int i;
131
42.2k
  PW *dup;
132
42.2k
133
42.2k
  if (!pw)
134
0
    return NULL;
135
42.2k
136
42.2k
#ifdef HAS_TYPE
137
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
138
#else
139
42.2k
  
dup = 42.2k
FN42.2k
(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
140
42.2k
#endif
141
42.2k
  if (!dup)
142
0
    return NULL;
143
42.2k
144
85.8k
  
for (i = 0; 42.2k
i < pw->n85.8k
;
++i43.5k
)
145
43.5k
    
dup = 43.5k
FN43.5k
(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
146
43.5k
              
FN43.5k
(EL,copy)(pw->p[i].
FIELD43.5k
));
147
42.2k
148
42.2k
  return dup;
149
42.2k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_dup
isl_pw_multi_aff_dup
Line
Count
Source
129
553
{
130
553
  int i;
131
553
  PW *dup;
132
553
133
553
  if (!pw)
134
0
    return NULL;
135
553
136
553
#ifdef HAS_TYPE
137
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
138
#else
139
553
  
dup = 553
FN553
(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
140
553
#endif
141
553
  if (!dup)
142
0
    return NULL;
143
553
144
1.10k
  
for (i = 0; 553
i < pw->n1.10k
;
++i554
)
145
554
    
dup = 554
FN554
(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
146
554
              
FN554
(EL,copy)(pw->p[i].
FIELD554
));
147
553
148
553
  return dup;
149
553
}
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
1
#ifdef HAS_TYPE
137
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
138
#else
139
1
  
dup = 1
FN1
(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->n2
;
++i1
)
145
1
    
dup = 1
FN1
(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
146
1
              
FN1
(EL,copy)(pw->p[i].
FIELD1
));
147
1
148
1
  return dup;
149
1
}
150
151
__isl_give PW *FN(PW,cow)(__isl_take PW *pw)
152
{
153
  if (!pw)
154
    return NULL;
155
156
  if (pw->ref == 1)
157
    return pw;
158
  pw->ref--;
159
  return FN(PW,dup)(pw);
160
}
isl_pw_qpolynomial_fold_cow
Line
Count
Source
152
7
{
153
7
  if (!pw)
154
0
    return NULL;
155
7
156
7
  
if (7
pw->ref == 17
)
157
7
    return pw;
158
0
  pw->ref--;
159
0
  return FN(PW,dup)(pw);
160
7
}
isl_pw_multi_aff_cow
Line
Count
Source
152
5.98k
{
153
5.98k
  if (!pw)
154
0
    return NULL;
155
5.98k
156
5.98k
  
if (5.98k
pw->ref == 15.98k
)
157
5.43k
    return pw;
158
553
  pw->ref--;
159
553
  return FN(PW,dup)(pw);
160
5.98k
}
isl_pw_qpolynomial_cow
Line
Count
Source
152
51
{
153
51
  if (!pw)
154
0
    return NULL;
155
51
156
51
  
if (51
pw->ref == 151
)
157
50
    return pw;
158
1
  pw->ref--;
159
1
  return FN(PW,dup)(pw);
160
51
}
isl_pw_aff_cow
Line
Count
Source
152
129k
{
153
129k
  if (!pw)
154
0
    return NULL;
155
129k
156
129k
  
if (129k
pw->ref == 1129k
)
157
87.2k
    return pw;
158
42.2k
  pw->ref--;
159
42.2k
  return FN(PW,dup)(pw);
160
129k
}
161
162
__isl_give PW *FN(PW,copy)(__isl_keep PW *pw)
163
{
164
  if (!pw)
165
    return NULL;
166
167
  pw->ref++;
168
  return pw;
169
}
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
}
isl_pw_aff_copy
Line
Count
Source
163
162k
{
164
162k
  if (!pw)
165
20.2k
    return NULL;
166
162k
167
141k
  pw->ref++;
168
141k
  return pw;
169
162k
}
isl_pw_multi_aff_copy
Line
Count
Source
163
27.8k
{
164
27.8k
  if (!pw)
165
0
    return NULL;
166
27.8k
167
27.8k
  pw->ref++;
168
27.8k
  return pw;
169
27.8k
}
170
171
__isl_null PW *FN(PW,free)(__isl_take PW *pw)
172
{
173
  int i;
174
175
  if (!pw)
176
    return NULL;
177
  if (--pw->ref > 0)
178
    return NULL;
179
180
  for (i = 0; i < pw->n; ++i) {
181
    isl_set_free(pw->p[i].set);
182
    FN(EL,free)(pw->p[i].FIELD);
183
  }
184
  isl_space_free(pw->dim);
185
  free(pw);
186
187
  return NULL;
188
}
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 (37
--pw->ref > 037
)
178
2
    return NULL;
179
37
180
53
  
for (i = 0; 35
i < pw->n53
;
++i18
)
{18
181
18
    isl_set_free(pw->p[i].set);
182
18
    
FN18
(EL,free)(pw->p[i].
FIELD18
);
183
18
  }
184
35
  isl_space_free(pw->dim);
185
35
  free(pw);
186
35
187
35
  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 (113
--pw->ref > 0113
)
178
9
    return NULL;
179
113
180
202
  
for (i = 0; 104
i < pw->n202
;
++i98
)
{98
181
98
    isl_set_free(pw->p[i].set);
182
98
    
FN98
(EL,free)(pw->p[i].
FIELD98
);
183
98
  }
184
104
  isl_space_free(pw->dim);
185
104
  free(pw);
186
104
187
104
  return NULL;
188
113
}
isl_pw_aff_free
Line
Count
Source
172
327k
{
173
327k
  int i;
174
327k
175
327k
  if (!pw)
176
34.0k
    return NULL;
177
293k
  
if (293k
--pw->ref > 0293k
)
178
99.5k
    return NULL;
179
293k
180
388k
  
for (i = 0; 193k
i < pw->n388k
;
++i194k
)
{194k
181
194k
    isl_set_free(pw->p[i].set);
182
194k
    
FN194k
(EL,free)(pw->p[i].
FIELD194k
);
183
194k
  }
184
193k
  isl_space_free(pw->dim);
185
193k
  free(pw);
186
193k
187
193k
  return NULL;
188
293k
}
isl_pw_multi_aff_free
Line
Count
Source
172
48.6k
{
173
48.6k
  int i;
174
48.6k
175
48.6k
  if (!pw)
176
29
    return NULL;
177
48.5k
  
if (48.5k
--pw->ref > 048.5k
)
178
27.3k
    return NULL;
179
48.5k
180
40.6k
  
for (i = 0; 21.2k
i < pw->n40.6k
;
++i19.3k
)
{19.3k
181
19.3k
    isl_set_free(pw->p[i].set);
182
19.3k
    
FN19.3k
(EL,free)(pw->p[i].
FIELD19.3k
);
183
19.3k
  }
184
21.2k
  isl_space_free(pw->dim);
185
21.2k
  free(pw);
186
21.2k
187
21.2k
  return NULL;
188
48.5k
}
189
190
const char *FN(PW,get_dim_name)(__isl_keep PW *pw, enum isl_dim_type type,
191
  unsigned pos)
192
{
193
  return pw ? isl_space_get_dim_name(pw->dim, type, pos) : NULL;
194
}
Unexecuted instantiation: isl_pw_qpolynomial_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_aff_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
{
199
  return pw ? isl_space_has_dim_id(pw->dim, type, pos) : isl_bool_error;
200
}
Unexecuted instantiation: isl_pw_aff_has_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_has_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_has_dim_id
Unexecuted instantiation: isl_pw_multi_aff_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
{
205
  return pw ? isl_space_get_dim_id(pw->dim, type, pos) : NULL;
206
}
Unexecuted instantiation: isl_pw_multi_aff_get_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_get_dim_id
isl_pw_aff_get_dim_id
Line
Count
Source
204
9
{
205
9
  return pw ? isl_space_get_dim_id(pw->dim, type, pos) : NULL;
206
9
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_get_dim_id
207
208
isl_bool FN(PW,has_tuple_name)(__isl_keep PW *pw, enum isl_dim_type type)
209
{
210
  return pw ? isl_space_has_tuple_name(pw->dim, type) : isl_bool_error;
211
}
Unexecuted instantiation: isl_pw_multi_aff_has_tuple_name
Unexecuted instantiation: isl_pw_qpolynomial_has_tuple_name
Unexecuted instantiation: isl_pw_qpolynomial_fold_has_tuple_name
Unexecuted instantiation: isl_pw_aff_has_tuple_name
212
213
const char *FN(PW,get_tuple_name)(__isl_keep PW *pw, enum isl_dim_type type)
214
{
215
  return pw ? isl_space_get_tuple_name(pw->dim, type) : NULL;
216
}
Unexecuted instantiation: isl_pw_multi_aff_get_tuple_name
Unexecuted instantiation: isl_pw_qpolynomial_fold_get_tuple_name
Unexecuted instantiation: isl_pw_aff_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
{
220
  return pw ? isl_space_has_tuple_id(pw->dim, type) : isl_bool_error;
221
}
Unexecuted instantiation: isl_pw_qpolynomial_has_tuple_id
Unexecuted instantiation: isl_pw_aff_has_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_has_tuple_id
Unexecuted instantiation: isl_pw_multi_aff_has_tuple_id
222
223
__isl_give isl_id *FN(PW,get_tuple_id)(__isl_keep PW *pw, enum isl_dim_type type)
224
{
225
  return pw ? isl_space_get_tuple_id(pw->dim, type) : NULL;
226
}
Unexecuted instantiation: isl_pw_qpolynomial_get_tuple_id
Unexecuted instantiation: isl_pw_aff_get_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_get_tuple_id
Unexecuted instantiation: isl_pw_multi_aff_get_tuple_id
227
228
isl_bool FN(PW,IS_ZERO)(__isl_keep PW *pw)
229
{
230
  if (!pw)
231
    return isl_bool_error;
232
233
  return pw->n == 0;
234
}
isl_pw_multi_aff_is_empty
Line
Count
Source
229
18.1k
{
230
18.1k
  if (!pw)
231
0
    return isl_bool_error;
232
18.1k
233
18.1k
  return pw->n == 0;
234
18.1k
}
isl_pw_aff_is_empty
Line
Count
Source
229
33.1k
{
230
33.1k
  if (!pw)
231
0
    return isl_bool_error;
232
33.1k
233
33.1k
  return pw->n == 0;
234
33.1k
}
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
}
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
}
235
236
#ifndef NO_REALIGN
237
__isl_give PW *FN(PW,realign_domain)(__isl_take PW *pw,
238
  __isl_take isl_reordering *exp)
239
{
240
  int i;
241
242
  pw = FN(PW,cow)(pw);
243
  if (!pw || !exp)
244
    goto error;
245
246
  for (i = 0; i < pw->n; ++i) {
247
    pw->p[i].set = isl_set_realign(pw->p[i].set,
248
                isl_reordering_copy(exp));
249
    if (!pw->p[i].set)
250
      goto error;
251
    pw->p[i].FIELD = FN(EL,realign_domain)(pw->p[i].FIELD,
252
                isl_reordering_copy(exp));
253
    if (!pw->p[i].FIELD)
254
      goto error;
255
  }
256
257
  pw = FN(PW,reset_domain_space)(pw, isl_space_copy(exp->dim));
258
259
  isl_reordering_free(exp);
260
  return pw;
261
error:
262
  isl_reordering_free(exp);
263
  FN(PW,free)(pw);
264
  return NULL;
265
}
isl_pw_aff_realign_domain
Line
Count
Source
239
8.08k
{
240
8.08k
  int i;
241
8.08k
242
8.08k
  pw = FN(PW,cow)(pw);
243
8.08k
  if (
!pw || 8.08k
!exp8.08k
)
244
0
    goto error;
245
8.08k
246
16.6k
  
for (i = 0; 8.08k
i < pw->n16.6k
;
++i8.51k
)
{8.51k
247
8.51k
    pw->p[i].set = isl_set_realign(pw->p[i].set,
248
8.51k
                isl_reordering_copy(exp));
249
8.51k
    if (!pw->p[i].set)
250
0
      goto error;
251
8.51k
    
pw->p[i].8.51k
FIELD8.51k
=
FN8.51k
(EL,realign_domain)(pw->p[i].
FIELD8.51k
,
252
8.51k
                isl_reordering_copy(exp));
253
8.51k
    if (
!pw->p[i].8.51k
FIELD8.51k
)
254
0
      goto error;
255
8.51k
  }
256
8.08k
257
8.08k
  
pw = 8.08k
FN8.08k
(PW,reset_domain_space)(pw, isl_space_copy(exp->dim));
258
8.08k
259
8.08k
  isl_reordering_free(exp);
260
8.08k
  return pw;
261
0
error:
262
0
  isl_reordering_free(exp);
263
0
  FN(PW,free)(pw);
264
0
  return NULL;
265
8.08k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_realign_domain
Unexecuted instantiation: isl_pw_multi_aff_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
{
271
  isl_ctx *ctx;
272
  isl_bool equal_params;
273
274
  if (!pw || !model)
275
    goto error;
276
277
  ctx = isl_space_get_ctx(model);
278
  if (!isl_space_has_named_params(model))
279
    isl_die(ctx, isl_error_invalid,
280
      "model has unnamed parameters", goto error);
281
  if (!isl_space_has_named_params(pw->dim))
282
    isl_die(ctx, isl_error_invalid,
283
      "input has unnamed parameters", goto error);
284
  equal_params = isl_space_has_equal_params(pw->dim, model);
285
  if (equal_params < 0)
286
    goto error;
287
  if (!equal_params) {
288
    isl_reordering *exp;
289
290
    model = isl_space_drop_dims(model, isl_dim_in,
291
          0, isl_space_dim(model, isl_dim_in));
292
    model = isl_space_drop_dims(model, isl_dim_out,
293
          0, isl_space_dim(model, isl_dim_out));
294
    exp = isl_parameter_alignment_reordering(pw->dim, model);
295
    exp = isl_reordering_extend_space(exp,
296
          FN(PW,get_domain_space)(pw));
297
    pw = FN(PW,realign_domain)(pw, exp);
298
  }
299
300
  isl_space_free(model);
301
  return pw;
302
error:
303
  isl_space_free(model);
304
  FN(PW,free)(pw);
305
  return NULL;
306
}
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 || 5
!model5
)
275
0
    goto error;
276
5
277
5
  ctx = isl_space_get_ctx(model);
278
5
  if (!isl_space_has_named_params(model))
279
0
    isl_die(ctx, isl_error_invalid,
280
5
      "model has unnamed parameters", goto error);
281
5
  
if (5
!isl_space_has_named_params(pw->dim)5
)
282
0
    isl_die(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 (5
!equal_params5
)
{0
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
0
error:
303
0
  isl_space_free(model);
304
0
  FN(PW,free)(pw);
305
0
  return NULL;
306
5
}
isl_pw_aff_align_params
Line
Count
Source
270
15.0k
{
271
15.0k
  isl_ctx *ctx;
272
15.0k
  isl_bool equal_params;
273
15.0k
274
15.0k
  if (
!pw || 15.0k
!model15.0k
)
275
0
    goto error;
276
15.0k
277
15.0k
  ctx = isl_space_get_ctx(model);
278
15.0k
  if (!isl_space_has_named_params(model))
279
0
    isl_die(ctx, isl_error_invalid,
280
15.0k
      "model has unnamed parameters", goto error);
281
15.0k
  
if (15.0k
!isl_space_has_named_params(pw->dim)15.0k
)
282
0
    isl_die(ctx, isl_error_invalid,
283
15.0k
      "input has unnamed parameters", goto error);
284
15.0k
  equal_params = isl_space_has_equal_params(pw->dim, model);
285
15.0k
  if (equal_params < 0)
286
0
    goto error;
287
15.0k
  
if (15.0k
!equal_params15.0k
)
{7.92k
288
7.92k
    isl_reordering *exp;
289
7.92k
290
7.92k
    model = isl_space_drop_dims(model, isl_dim_in,
291
7.92k
          0, isl_space_dim(model, isl_dim_in));
292
7.92k
    model = isl_space_drop_dims(model, isl_dim_out,
293
7.92k
          0, isl_space_dim(model, isl_dim_out));
294
7.92k
    exp = isl_parameter_alignment_reordering(pw->dim, model);
295
7.92k
    exp = isl_reordering_extend_space(exp,
296
7.92k
          FN(PW,get_domain_space)(pw));
297
7.92k
    pw = FN(PW,realign_domain)(pw, exp);
298
7.92k
  }
299
15.0k
300
15.0k
  isl_space_free(model);
301
15.0k
  return pw;
302
0
error:
303
0
  isl_space_free(model);
304
0
  FN(PW,free)(pw);
305
0
  return NULL;
306
15.0k
}
isl_pw_multi_aff_align_params
Line
Count
Source
270
13.2k
{
271
13.2k
  isl_ctx *ctx;
272
13.2k
  isl_bool equal_params;
273
13.2k
274
13.2k
  if (
!pw || 13.2k
!model13.2k
)
275
0
    goto error;
276
13.2k
277
13.2k
  ctx = isl_space_get_ctx(model);
278
13.2k
  if (!isl_space_has_named_params(model))
279
0
    isl_die(ctx, isl_error_invalid,
280
13.2k
      "model has unnamed parameters", goto error);
281
13.2k
  
if (13.2k
!isl_space_has_named_params(pw->dim)13.2k
)
282
0
    isl_die(ctx, isl_error_invalid,
283
13.2k
      "input has unnamed parameters", goto error);
284
13.2k
  equal_params = isl_space_has_equal_params(pw->dim, model);
285
13.2k
  if (equal_params < 0)
286
0
    goto error;
287
13.2k
  
if (13.2k
!equal_params13.2k
)
{0
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
13.2k
300
13.2k
  isl_space_free(model);
301
13.2k
  return pw;
302
0
error:
303
0
  isl_space_free(model);
304
0
  FN(PW,free)(pw);
305
0
  return NULL;
306
13.2k
}
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
{
312
  isl_ctx *ctx;
313
  isl_bool equal_params;
314
315
  if (!pw1 || !pw2)
316
    goto error;
317
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
318
  if (equal_params < 0)
319
    goto error;
320
  if (equal_params)
321
    return fn(pw1, pw2);
322
  ctx = FN(PW,get_ctx)(pw1);
323
  if (!isl_space_has_named_params(pw1->dim) ||
324
      !isl_space_has_named_params(pw2->dim))
325
    isl_die(ctx, isl_error_invalid,
326
      "unaligned unnamed parameters", goto error);
327
  pw1 = FN(PW,align_params)(pw1, FN(PW,get_space)(pw2));
328
  pw2 = FN(PW,align_params)(pw2, FN(PW,get_space)(pw1));
329
  return fn(pw1, pw2);
330
error:
331
  FN(PW,free)(pw1);
332
  FN(PW,free)(pw2);
333
  return NULL;
334
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_align_params_pw_pw_and
isl_aff.c:isl_pw_multi_aff_align_params_pw_pw_and
Line
Count
Source
311
4.36k
{
312
4.36k
  isl_ctx *ctx;
313
4.36k
  isl_bool equal_params;
314
4.36k
315
4.36k
  if (
!pw1 || 4.36k
!pw24.34k
)
316
14
    goto error;
317
4.34k
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
318
4.34k
  if (equal_params < 0)
319
0
    goto error;
320
4.34k
  
if (4.34k
equal_params4.34k
)
321
4.34k
    return fn(pw1, pw2);
322
0
  
ctx = 0
FN0
(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 = 0
FN0
(PW,align_params)(pw1,
FN0
(PW,get_space)(pw2));
328
0
  pw2 = 
FN0
(PW,align_params)(pw2,
FN0
(PW,get_space)(pw1));
329
0
  return fn(pw1, pw2);
330
14
error:
331
14
  FN(PW,free)(pw1);
332
14
  FN(PW,free)(pw2);
333
14
  return NULL;
334
0
}
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 || 26
!pw226
)
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 (26
equal_params26
)
321
26
    return fn(pw1, pw2);
322
0
  
ctx = 0
FN0
(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 = 0
FN0
(PW,align_params)(pw1,
FN0
(PW,get_space)(pw2));
328
0
  pw2 = 
FN0
(PW,align_params)(pw2,
FN0
(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
0
}
isl_aff.c:isl_pw_aff_align_params_pw_pw_and
Line
Count
Source
311
73.0k
{
312
73.0k
  isl_ctx *ctx;
313
73.0k
  isl_bool equal_params;
314
73.0k
315
73.0k
  if (
!pw1 || 73.0k
!pw273.0k
)
316
1
    goto error;
317
73.0k
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
318
73.0k
  if (equal_params < 0)
319
0
    goto error;
320
73.0k
  
if (73.0k
equal_params73.0k
)
321
70.0k
    return fn(pw1, pw2);
322
3.00k
  
ctx = 3.00k
FN3.00k
(PW,get_ctx)(pw1);
323
3.00k
  if (!isl_space_has_named_params(pw1->dim) ||
324
3.00k
      !isl_space_has_named_params(pw2->dim))
325
0
    isl_die(ctx, isl_error_invalid,
326
3.00k
      "unaligned unnamed parameters", goto error);
327
3.00k
  
pw1 = 3.00k
FN3.00k
(PW,align_params)(pw1,
FN3.00k
(PW,get_space)(pw2));
328
3.00k
  pw2 = 
FN3.00k
(PW,align_params)(pw2,
FN3.00k
(PW,get_space)(pw1));
329
3.00k
  return fn(pw1, pw2);
330
1
error:
331
1
  FN(PW,free)(pw1);
332
1
  FN(PW,free)(pw2);
333
1
  return NULL;
334
3.00k
}
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
{
340
  isl_ctx *ctx;
341
  isl_bool aligned;
342
343
  if (!pw || !set)
344
    goto error;
345
  aligned = isl_set_space_has_equal_params(set, pw->dim);
346
  if (aligned < 0)
347
    goto error;
348
  if (aligned)
349
    return fn(pw, set);
350
  ctx = FN(PW,get_ctx)(pw);
351
  if (!isl_space_has_named_params(pw->dim) ||
352
      !isl_space_has_named_params(set->dim))
353
    isl_die(ctx, isl_error_invalid,
354
      "unaligned unnamed parameters", goto error);
355
  pw = FN(PW,align_params)(pw, isl_set_get_space(set));
356
  set = isl_set_align_params(set, FN(PW,get_space)(pw));
357
  return fn(pw, set);
358
error:
359
  FN(PW,free)(pw);
360
  isl_set_free(set);
361
  return NULL;
362
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_align_params_pw_set_and
isl_aff.c:isl_pw_multi_aff_align_params_pw_set_and
Line
Count
Source
339
2.74k
{
340
2.74k
  isl_ctx *ctx;
341
2.74k
  isl_bool aligned;
342
2.74k
343
2.74k
  if (
!pw || 2.74k
!set2.74k
)
344
0
    goto error;
345
2.74k
  aligned = isl_set_space_has_equal_params(set, pw->dim);
346
2.74k
  if (aligned < 0)
347
0
    goto error;
348
2.74k
  
if (2.74k
aligned2.74k
)
349
2.74k
    return fn(pw, set);
350
0
  
ctx = 0
FN0
(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 = 0
FN0
(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
0
}
isl_aff.c:isl_pw_aff_align_params_pw_set_and
Line
Count
Source
339
38.7k
{
340
38.7k
  isl_ctx *ctx;
341
38.7k
  isl_bool aligned;
342
38.7k
343
38.7k
  if (
!pw || 38.7k
!set38.7k
)
344
0
    goto error;
345
38.7k
  aligned = isl_set_space_has_equal_params(set, pw->dim);
346
38.7k
  if (aligned < 0)
347
0
    goto error;
348
38.7k
  
if (38.7k
aligned38.7k
)
349
38.7k
    return fn(pw, set);
350
2
  
ctx = 2
FN2
(PW,get_ctx)(pw);
351
2
  if (!isl_space_has_named_params(pw->dim) ||
352
2
      !isl_space_has_named_params(set->dim))
353
0
    isl_die(ctx, isl_error_invalid,
354
2
      "unaligned unnamed parameters", goto error);
355
2
  
pw = 2
FN2
(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
0
error:
359
0
  FN(PW,free)(pw);
360
0
  isl_set_free(set);
361
0
  return NULL;
362
2
}
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 || 39
!set39
)
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 (39
aligned39
)
349
39
    return fn(pw, set);
350
0
  
ctx = 0
FN0
(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 = 0
FN0
(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
0
}
363
#endif
364
365
static __isl_give PW *FN(PW,union_add_aligned)(__isl_take PW *pw1,
366
  __isl_take PW *pw2)
367
{
368
  int i, j, n;
369
  struct PW *res;
370
  isl_ctx *ctx;
371
  isl_set *set;
372
373
  if (!pw1 || !pw2)
374
    goto error;
375
376
  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
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
383
384
  if (FN(PW,IS_ZERO)(pw1)) {
385
    FN(PW,free)(pw1);
386
    return pw2;
387
  }
388
389
  if (FN(PW,IS_ZERO)(pw2)) {
390
    FN(PW,free)(pw2);
391
    return pw1;
392
  }
393
394
  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
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), n);
399
#endif
400
401
  for (i = 0; i < pw1->n; ++i) {
402
    set = isl_set_copy(pw1->p[i].set);
403
    for (j = 0; j < pw2->n; ++j) {
404
      struct isl_set *common;
405
      EL *sum;
406
      common = isl_set_intersect(isl_set_copy(pw1->p[i].set),
407
            isl_set_copy(pw2->p[j].set));
408
      if (isl_set_plain_is_empty(common)) {
409
        isl_set_free(common);
410
        continue;
411
      }
412
      set = isl_set_subtract(set,
413
          isl_set_copy(pw2->p[j].set));
414
415
      sum = FN(EL,add_on_domain)(common,
416
               FN(EL,copy)(pw1->p[i].FIELD),
417
               FN(EL,copy)(pw2->p[j].FIELD));
418
419
      res = FN(PW,add_piece)(res, common, sum);
420
    }
421
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw1->p[i].FIELD));
422
  }
423
424
  for (j = 0; j < pw2->n; ++j) {
425
    set = isl_set_copy(pw2->p[j].set);
426
    for (i = 0; i < pw1->n; ++i)
427
      set = isl_set_subtract(set,
428
          isl_set_copy(pw1->p[i].set));
429
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw2->p[j].FIELD));
430
  }
431
432
  FN(PW,free)(pw1);
433
  FN(PW,free)(pw2);
434
435
  return res;
436
error:
437
  FN(PW,free)(pw1);
438
  FN(PW,free)(pw2);
439
  return NULL;
440
}
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 || 24
!pw224
)
374
0
    goto error;
375
24
376
24
  ctx = isl_space_get_ctx(pw1->dim);
377
24
#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 (24
FN24
(PW,IS_ZERO)(pw1)24
)
{0
385
0
    FN(PW,free)(pw1);
386
0
    return pw2;
387
0
  }
388
24
389
24
  
if (24
FN24
(PW,IS_ZERO)(pw2)24
)
{0
390
0
    FN(PW,free)(pw2);
391
0
    return pw1;
392
0
  }
393
24
394
24
  n = (pw1->n + 1) * (pw2->n + 1);
395
24
#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->n49
;
++i25
)
{25
402
25
    set = isl_set_copy(pw1->p[i].set);
403
52
    for (j = 0; 
j < pw2->n52
;
++j27
)
{27
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)27
)
{5
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
               
FN22
(EL,copy)(pw1->p[i].
FIELD22
),
417
22
               
FN22
(EL,copy)(pw2->p[j].
FIELD22
));
418
22
419
22
      res = FN(PW,add_piece)(res, common, sum);
420
22
    }
421
25
    res = 
FN25
(PW,add_piece)(res, set,
FN25
(EL,copy)(pw1->p[i].
FIELD25
));
422
25
  }
423
24
424
49
  for (j = 0; 
j < pw2->n49
;
++j25
)
{25
425
25
    set = isl_set_copy(pw2->p[j].set);
426
52
    for (i = 0; 
i < pw1->n52
;
++i27
)
427
27
      set = isl_set_subtract(set,
428
27
          isl_set_copy(pw1->p[i].set));
429
25
    res = 
FN25
(PW,add_piece)(res, set,
FN25
(EL,copy)(pw2->p[j].
FIELD25
));
430
25
  }
431
24
432
24
  FN(PW,free)(pw1);
433
24
  FN(PW,free)(pw2);
434
24
435
24
  return res;
436
0
error:
437
0
  FN(PW,free)(pw1);
438
0
  FN(PW,free)(pw2);
439
0
  return NULL;
440
24
}
isl_aff.c:isl_pw_aff_union_add_aligned
Line
Count
Source
367
2.78k
{
368
2.78k
  int i, j, n;
369
2.78k
  struct PW *res;
370
2.78k
  isl_ctx *ctx;
371
2.78k
  isl_set *set;
372
2.78k
373
2.78k
  if (
!pw1 || 2.78k
!pw22.78k
)
374
0
    goto error;
375
2.78k
376
2.78k
  ctx = isl_space_get_ctx(pw1->dim);
377
2.78k
#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
2.78k
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
383
2.78k
384
2.78k
  
if (2.78k
FN2.78k
(PW,IS_ZERO)(pw1)2.78k
)
{2.73k
385
2.73k
    FN(PW,free)(pw1);
386
2.73k
    return pw2;
387
2.73k
  }
388
2.78k
389
53
  
if (53
FN53
(PW,IS_ZERO)(pw2)53
)
{0
390
0
    FN(PW,free)(pw2);
391
0
    return pw1;
392
0
  }
393
53
394
53
  n = (pw1->n + 1) * (pw2->n + 1);
395
53
#ifdef HAS_TYPE
396
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->type, n);
397
#else
398
53
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), n);
399
53
#endif
400
53
401
106
  for (i = 0; 
i < pw1->n106
;
++i53
)
{53
402
53
    set = isl_set_copy(pw1->p[i].set);
403
106
    for (j = 0; 
j < pw2->n106
;
++j53
)
{53
404
53
      struct isl_set *common;
405
53
      EL *sum;
406
53
      common = isl_set_intersect(isl_set_copy(pw1->p[i].set),
407
53
            isl_set_copy(pw2->p[j].set));
408
53
      if (
isl_set_plain_is_empty(common)53
)
{53
409
53
        isl_set_free(common);
410
53
        continue;
411
53
      }
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
               
FN0
(EL,copy)(pw1->p[i].
FIELD0
),
417
0
               
FN0
(EL,copy)(pw2->p[j].
FIELD0
));
418
0
419
0
      res = FN(PW,add_piece)(res, common, sum);
420
0
    }
421
53
    res = 
FN53
(PW,add_piece)(res, set,
FN53
(EL,copy)(pw1->p[i].
FIELD53
));
422
53
  }
423
53
424
106
  for (j = 0; 
j < pw2->n106
;
++j53
)
{53
425
53
    set = isl_set_copy(pw2->p[j].set);
426
106
    for (i = 0; 
i < pw1->n106
;
++i53
)
427
53
      set = isl_set_subtract(set,
428
53
          isl_set_copy(pw1->p[i].set));
429
53
    res = 
FN53
(PW,add_piece)(res, set,
FN53
(EL,copy)(pw2->p[j].
FIELD53
));
430
53
  }
431
53
432
53
  FN(PW,free)(pw1);
433
53
  FN(PW,free)(pw2);
434
53
435
53
  return res;
436
0
error:
437
0
  FN(PW,free)(pw1);
438
0
  FN(PW,free)(pw2);
439
0
  return NULL;
440
53
}
isl_aff.c:isl_pw_multi_aff_union_add_aligned
Line
Count
Source
367
796
{
368
796
  int i, j, n;
369
796
  struct PW *res;
370
796
  isl_ctx *ctx;
371
796
  isl_set *set;
372
796
373
796
  if (
!pw1 || 796
!pw2796
)
374
0
    goto error;
375
796
376
796
  ctx = isl_space_get_ctx(pw1->dim);
377
796
#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
796
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
383
796
384
796
  
if (796
FN796
(PW,IS_ZERO)(pw1)796
)
{71
385
71
    FN(PW,free)(pw1);
386
71
    return pw2;
387
71
  }
388
796
389
725
  
if (725
FN725
(PW,IS_ZERO)(pw2)725
)
{669
390
669
    FN(PW,free)(pw2);
391
669
    return pw1;
392
669
  }
393
725
394
56
  n = (pw1->n + 1) * (pw2->n + 1);
395
56
#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->n160
;
++i104
)
{104
402
104
    set = isl_set_copy(pw1->p[i].set);
403
208
    for (j = 0; 
j < pw2->n208
;
++j104
)
{104
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)104
)
{102
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
               
FN2
(EL,copy)(pw1->p[i].
FIELD2
),
417
2
               
FN2
(EL,copy)(pw2->p[j].
FIELD2
));
418
2
419
2
      res = FN(PW,add_piece)(res, common, sum);
420
2
    }
421
104
    res = 
FN104
(PW,add_piece)(res, set,
FN104
(EL,copy)(pw1->p[i].
FIELD104
));
422
104
  }
423
56
424
112
  for (j = 0; 
j < pw2->n112
;
++j56
)
{56
425
56
    set = isl_set_copy(pw2->p[j].set);
426
160
    for (i = 0; 
i < pw1->n160
;
++i104
)
427
104
      set = isl_set_subtract(set,
428
104
          isl_set_copy(pw1->p[i].set));
429
56
    res = 
FN56
(PW,add_piece)(res, set,
FN56
(EL,copy)(pw2->p[j].
FIELD56
));
430
56
  }
431
56
432
56
  FN(PW,free)(pw1);
433
56
  FN(PW,free)(pw2);
434
56
435
56
  return res;
436
0
error:
437
0
  FN(PW,free)(pw1);
438
0
  FN(PW,free)(pw2);
439
0
  return NULL;
440
725
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_union_add_aligned
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
{
447
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
448
            &FN(PW,union_add_aligned));
449
}
isl_aff.c:isl_pw_aff_union_add_
Line
Count
Source
446
2.78k
{
447
2.78k
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
448
2.78k
            &FN(PW,union_add_aligned));
449
2.78k
}
isl_aff.c:isl_pw_multi_aff_union_add_
Line
Count
Source
446
796
{
447
796
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
448
796
            &FN(PW,union_add_aligned));
449
796
}
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
{
458
  int i;
459
  isl_ctx *ctx;
460
  PW *res;
461
462
  if (!pw)
463
    return NULL;
464
  if (pw->n + n <= pw->size)
465
    return pw;
466
  ctx = FN(PW,get_ctx)(pw);
467
  n += pw->n;
468
  if (pw->ref == 1) {
469
    res = isl_realloc(ctx, pw, struct PW,
470
          sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
471
    if (!res)
472
      return FN(PW,free)(pw);
473
    res->size = n;
474
    return res;
475
  }
476
#ifdef HAS_TYPE
477
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, n);
478
#else
479
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), n);
480
#endif
481
  if (!res)
482
    return FN(PW,free)(pw);
483
  for (i = 0; i < pw->n; ++i)
484
    res = FN(PW,add_piece)(res, isl_set_copy(pw->p[i].set),
485
              FN(EL,copy)(pw->p[i].FIELD));
486
  FN(PW,free)(pw);
487
  return res;
488
}
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 (1
pw->n + n <= pw->size1
)
465
0
    return pw;
466
1
  
ctx = 1
FN1
(PW,get_ctx)(pw);
467
1
  n += pw->n;
468
1
  if (
pw->ref == 11
)
{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 0
FN0
(PW,free)(pw);
473
1
    res->size = n;
474
1
    return res;
475
1
  }
476
1
#ifdef HAS_TYPE
477
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, n);
478
#else
479
0
  
res = 0
FN0
(PW,alloc_size)(isl_space_copy(pw->dim), n);
480
0
#endif
481
0
  if (!res)
482
0
    
return 0
FN0
(PW,free)(pw);
483
0
  
for (i = 0; 0
i < pw->n0
;
++i0
)
484
0
    
res = 0
FN0
(PW,add_piece)(res, isl_set_copy(pw->p[i].set),
485
0
              
FN0
(EL,copy)(pw->p[i].
FIELD0
));
486
0
  FN(PW,free)(pw);
487
0
  return res;
488
0
}
isl_aff.c:isl_pw_multi_aff_grow
Line
Count
Source
457
99
{
458
99
  int i;
459
99
  isl_ctx *ctx;
460
99
  PW *res;
461
99
462
99
  if (!pw)
463
0
    return NULL;
464
99
  
if (99
pw->n + n <= pw->size99
)
465
0
    return pw;
466
99
  
ctx = 99
FN99
(PW,get_ctx)(pw);
467
99
  n += pw->n;
468
99
  if (
pw->ref == 199
)
{99
469
99
    res = isl_realloc(ctx, pw, struct PW,
470
99
          sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
471
99
    if (!res)
472
0
      
return 0
FN0
(PW,free)(pw);
473
99
    res->size = n;
474
99
    return res;
475
99
  }
476
99
#ifdef HAS_TYPE
477
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, n);
478
#else
479
0
  
res = 0
FN0
(PW,alloc_size)(isl_space_copy(pw->dim), n);
480
0
#endif
481
0
  if (!res)
482
0
    
return 0
FN0
(PW,free)(pw);
483
0
  
for (i = 0; 0
i < pw->n0
;
++i0
)
484
0
    
res = 0
FN0
(PW,add_piece)(res, isl_set_copy(pw->p[i].set),
485
0
              
FN0
(EL,copy)(pw->p[i].
FIELD0
));
486
0
  FN(PW,free)(pw);
487
0
  return res;
488
0
}
isl_aff.c:isl_pw_aff_grow
Line
Count
Source
457
193
{
458
193
  int i;
459
193
  isl_ctx *ctx;
460
193
  PW *res;
461
193
462
193
  if (!pw)
463
0
    return NULL;
464
193
  
if (193
pw->n + n <= pw->size193
)
465
0
    return pw;
466
193
  
ctx = 193
FN193
(PW,get_ctx)(pw);
467
193
  n += pw->n;
468
193
  if (
pw->ref == 1193
)
{193
469
193
    res = isl_realloc(ctx, pw, struct PW,
470
193
          sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
471
193
    if (!res)
472
0
      
return 0
FN0
(PW,free)(pw);
473
193
    res->size = n;
474
193
    return res;
475
193
  }
476
193
#ifdef HAS_TYPE
477
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, n);
478
#else
479
0
  
res = 0
FN0
(PW,alloc_size)(isl_space_copy(pw->dim), n);
480
0
#endif
481
0
  if (!res)
482
0
    
return 0
FN0
(PW,free)(pw);
483
0
  
for (i = 0; 0
i < pw->n0
;
++i0
)
484
0
    
res = 0
FN0
(PW,add_piece)(res, isl_set_copy(pw->p[i].set),
485
0
              
FN0
(EL,copy)(pw->p[i].
FIELD0
));
486
0
  FN(PW,free)(pw);
487
0
  return res;
488
0
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_grow
489
490
static __isl_give PW *FN(PW,add_disjoint_aligned)(__isl_take PW *pw1,
491
  __isl_take PW *pw2)
492
{
493
  int i;
494
  isl_ctx *ctx;
495
496
  if (!pw1 || !pw2)
497
    goto error;
498
499
  if (pw1->size < pw1->n + pw2->n && pw1->n < pw2->n)
500
    return FN(PW,add_disjoint_aligned)(pw2, pw1);
501
502
  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
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
509
510
  if (FN(PW,IS_ZERO)(pw1)) {
511
    FN(PW,free)(pw1);
512
    return pw2;
513
  }
514
515
  if (FN(PW,IS_ZERO)(pw2)) {
516
    FN(PW,free)(pw2);
517
    return pw1;
518
  }
519
520
  pw1 = FN(PW,grow)(pw1, pw2->n);
521
  if (!pw1)
522
    goto error;
523
524
  for (i = 0; i < pw2->n; ++i)
525
    pw1 = FN(PW,add_piece)(pw1,
526
        isl_set_copy(pw2->p[i].set),
527
        FN(EL,copy)(pw2->p[i].FIELD));
528
529
  FN(PW,free)(pw2);
530
531
  return pw1;
532
error:
533
  FN(PW,free)(pw1);
534
  FN(PW,free)(pw2);
535
  return NULL;
536
}
isl_aff.c:isl_pw_aff_add_disjoint_aligned
Line
Count
Source
492
1.44k
{
493
1.44k
  int i;
494
1.44k
  isl_ctx *ctx;
495
1.44k
496
1.44k
  if (
!pw1 || 1.44k
!pw21.44k
)
497
0
    goto error;
498
1.44k
499
1.44k
  
if (1.44k
pw1->size < pw1->n + pw2->n && 1.44k
pw1->n < pw2->n782
)
500
589
    
return 589
FN589
(PW,add_disjoint_aligned)(pw2, pw1);
501
1.44k
502
851
  ctx = isl_space_get_ctx(pw1->dim);
503
851
#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
851
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
509
851
510
851
  
if (851
FN851
(PW,IS_ZERO)(pw1)851
)
{47
511
47
    FN(PW,free)(pw1);
512
47
    return pw2;
513
47
  }
514
851
515
804
  
if (804
FN804
(PW,IS_ZERO)(pw2)804
)
{611
516
611
    FN(PW,free)(pw2);
517
611
    return pw1;
518
611
  }
519
804
520
193
  
pw1 = 193
FN193
(PW,grow)(pw1, pw2->n);
521
193
  if (!pw1)
522
0
    goto error;
523
193
524
386
  
for (i = 0; 193
i < pw2->n386
;
++i193
)
525
193
    
pw1 = 193
FN193
(PW,add_piece)(pw1,
526
193
        isl_set_copy(pw2->p[i].set),
527
193
        
FN193
(EL,copy)(pw2->p[i].
FIELD193
));
528
193
529
193
  FN(PW,free)(pw2);
530
193
531
193
  return pw1;
532
0
error:
533
0
  FN(PW,free)(pw1);
534
0
  FN(PW,free)(pw2);
535
0
  return NULL;
536
193
}
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 || 3
!pw23
)
497
0
    goto error;
498
3
499
3
  
if (3
pw1->size < pw1->n + pw2->n && 3
pw1->n < pw2->n2
)
500
1
    
return 1
FN1
(PW,add_disjoint_aligned)(pw2, pw1);
501
3
502
2
  ctx = isl_space_get_ctx(pw1->dim);
503
2
#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 (2
FN2
(PW,IS_ZERO)(pw1)2
)
{0
511
0
    FN(PW,free)(pw1);
512
0
    return pw2;
513
0
  }
514
2
515
2
  
if (2
FN2
(PW,IS_ZERO)(pw2)2
)
{1
516
1
    FN(PW,free)(pw2);
517
1
    return pw1;
518
1
  }
519
2
520
1
  
pw1 = 1
FN1
(PW,grow)(pw1, pw2->n);
521
1
  if (!pw1)
522
0
    goto error;
523
1
524
2
  
for (i = 0; 1
i < pw2->n2
;
++i1
)
525
1
    
pw1 = 1
FN1
(PW,add_piece)(pw1,
526
1
        isl_set_copy(pw2->p[i].set),
527
1
        
FN1
(EL,copy)(pw2->p[i].
FIELD1
));
528
1
529
1
  FN(PW,free)(pw2);
530
1
531
1
  return pw1;
532
0
error:
533
0
  FN(PW,free)(pw1);
534
0
  FN(PW,free)(pw2);
535
0
  return NULL;
536
1
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_add_disjoint_aligned
isl_aff.c:isl_pw_multi_aff_add_disjoint_aligned
Line
Count
Source
492
4.39k
{
493
4.39k
  int i;
494
4.39k
  isl_ctx *ctx;
495
4.39k
496
4.39k
  if (
!pw1 || 4.39k
!pw24.39k
)
497
0
    goto error;
498
4.39k
499
4.39k
  
if (4.39k
pw1->size < pw1->n + pw2->n && 4.39k
pw1->n < pw2->n2.24k
)
500
2.14k
    
return 2.14k
FN2.14k
(PW,add_disjoint_aligned)(pw2, pw1);
501
4.39k
502
2.24k
  ctx = isl_space_get_ctx(pw1->dim);
503
2.24k
#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.24k
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
509
2.24k
510
2.24k
  
if (2.24k
FN2.24k
(PW,IS_ZERO)(pw1)2.24k
)
{0
511
0
    FN(PW,free)(pw1);
512
0
    return pw2;
513
0
  }
514
2.24k
515
2.24k
  
if (2.24k
FN2.24k
(PW,IS_ZERO)(pw2)2.24k
)
{2.14k
516
2.14k
    FN(PW,free)(pw2);
517
2.14k
    return pw1;
518
2.14k
  }
519
2.24k
520
99
  
pw1 = 99
FN99
(PW,grow)(pw1, pw2->n);
521
99
  if (!pw1)
522
0
    goto error;
523
99
524
198
  
for (i = 0; 99
i < pw2->n198
;
++i99
)
525
99
    
pw1 = 99
FN99
(PW,add_piece)(pw1,
526
99
        isl_set_copy(pw2->p[i].set),
527
99
        
FN99
(EL,copy)(pw2->p[i].
FIELD99
));
528
99
529
99
  FN(PW,free)(pw2);
530
99
531
99
  return pw1;
532
0
error:
533
0
  FN(PW,free)(pw1);
534
0
  FN(PW,free)(pw2);
535
0
  return NULL;
536
99
}
537
538
__isl_give PW *FN(PW,add_disjoint)(__isl_take PW *pw1, __isl_take PW *pw2)
539
{
540
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
541
            &FN(PW,add_disjoint_aligned));
542
}
isl_pw_aff_add_disjoint
Line
Count
Source
539
851
{
540
851
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
541
851
            &FN(PW,add_disjoint_aligned));
542
851
}
isl_pw_multi_aff_add_disjoint
Line
Count
Source
539
2.24k
{
540
2.24k
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
541
2.24k
            &FN(PW,add_disjoint_aligned));
542
2.24k
}
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
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_add_disjoint
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
{
558
  int i, j, n;
559
  PW *res = NULL;
560
561
  if (!pw1 || !pw2)
562
    goto error;
563
564
  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
  res = FN(PW,alloc_size)(isl_space_copy(space), n);
569
#endif
570
571
  for (i = 0; i < pw1->n; ++i) {
572
    for (j = 0; j < pw2->n; ++j) {
573
      isl_set *common;
574
      EL *res_ij;
575
      int empty;
576
577
      common = isl_set_intersect(
578
          isl_set_copy(pw1->p[i].set),
579
          isl_set_copy(pw2->p[j].set));
580
      empty = isl_set_plain_is_empty(common);
581
      if (empty < 0 || empty) {
582
        isl_set_free(common);
583
        if (empty < 0)
584
          goto error;
585
        continue;
586
      }
587
588
      res_ij = fn(FN(EL,copy)(pw1->p[i].FIELD),
589
            FN(EL,copy)(pw2->p[j].FIELD));
590
      res_ij = FN(EL,gist)(res_ij, isl_set_copy(common));
591
592
      res = FN(PW,add_piece)(res, common, res_ij);
593
    }
594
  }
595
596
  isl_space_free(space);
597
  FN(PW,free)(pw1);
598
  FN(PW,free)(pw2);
599
  return res;
600
error:
601
  isl_space_free(space);
602
  FN(PW,free)(pw1);
603
  FN(PW,free)(pw2);
604
  FN(PW,free)(res);
605
  return NULL;
606
}
isl_aff.c:isl_pw_multi_aff_on_shared_domain_in
Line
Count
Source
557
154
{
558
154
  int i, j, n;
559
154
  PW *res = NULL;
560
154
561
154
  if (
!pw1 || 154
!pw2154
)
562
0
    goto error;
563
154
564
154
  n = pw1->n * pw2->n;
565
154
#ifdef HAS_TYPE
566
  res = FN(PW,alloc_size)(isl_space_copy(space), pw1->type, n);
567
#else
568
154
  res = FN(PW,alloc_size)(isl_space_copy(space), n);
569
154
#endif
570
154
571
308
  for (i = 0; 
i < pw1->n308
;
++i154
)
{154
572
311
    for (j = 0; 
j < pw2->n311
;
++j157
)
{157
573
157
      isl_set *common;
574
157
      EL *res_ij;
575
157
      int empty;
576
157
577
157
      common = isl_set_intersect(
578
157
          isl_set_copy(pw1->p[i].set),
579
157
          isl_set_copy(pw2->p[j].set));
580
157
      empty = isl_set_plain_is_empty(common);
581
157
      if (
empty < 0 || 157
empty157
)
{0
582
0
        isl_set_free(common);
583
0
        if (empty < 0)
584
0
          goto error;
585
0
        continue;
586
0
      }
587
157
588
157
      
res_ij = fn(157
FN157
(EL,copy)(pw1->p[i].
FIELD157
),
589
157
            
FN157
(EL,copy)(pw2->p[j].
FIELD157
));
590
157
      res_ij = FN(EL,gist)(res_ij, isl_set_copy(common));
591
157
592
157
      res = FN(PW,add_piece)(res, common, res_ij);
593
157
    }
594
154
  }
595
154
596
154
  isl_space_free(space);
597
154
  FN(PW,free)(pw1);
598
154
  FN(PW,free)(pw2);
599
154
  return res;
600
0
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
154
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_on_shared_domain_in
isl_aff.c:isl_pw_aff_on_shared_domain_in
Line
Count
Source
557
69.0k
{
558
69.0k
  int i, j, n;
559
69.0k
  PW *res = NULL;
560
69.0k
561
69.0k
  if (
!pw1 || 69.0k
!pw269.0k
)
562
0
    goto error;
563
69.0k
564
69.0k
  n = pw1->n * pw2->n;
565
69.0k
#ifdef HAS_TYPE
566
  res = FN(PW,alloc_size)(isl_space_copy(space), pw1->type, n);
567
#else
568
69.0k
  res = FN(PW,alloc_size)(isl_space_copy(space), n);
569
69.0k
#endif
570
69.0k
571
140k
  for (i = 0; 
i < pw1->n140k
;
++i71.2k
)
{71.2k
572
145k
    for (j = 0; 
j < pw2->n145k
;
++j74.4k
)
{74.4k
573
74.4k
      isl_set *common;
574
74.4k
      EL *res_ij;
575
74.4k
      int empty;
576
74.4k
577
74.4k
      common = isl_set_intersect(
578
74.4k
          isl_set_copy(pw1->p[i].set),
579
74.4k
          isl_set_copy(pw2->p[j].set));
580
74.4k
      empty = isl_set_plain_is_empty(common);
581
74.4k
      if (
empty < 0 || 74.4k
empty74.4k
)
{2.96k
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
74.4k
588
71.4k
      
res_ij = fn(71.4k
FN71.4k
(EL,copy)(pw1->p[i].
FIELD71.4k
),
589
71.4k
            
FN71.4k
(EL,copy)(pw2->p[j].
FIELD71.4k
));
590
71.4k
      res_ij = FN(EL,gist)(res_ij, isl_set_copy(common));
591
71.4k
592
71.4k
      res = FN(PW,add_piece)(res, common, res_ij);
593
71.4k
    }
594
71.2k
  }
595
69.0k
596
69.0k
  isl_space_free(space);
597
69.0k
  FN(PW,free)(pw1);
598
69.0k
  FN(PW,free)(pw2);
599
69.0k
  return res;
600
0
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
69.0k
}
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
{
622
  isl_space *space;
623
624
  if (!pw1 || !pw2)
625
    goto error;
626
627
  space = isl_space_copy(pw1->dim);
628
  return FN(PW,on_shared_domain_in)(pw1, pw2, space, fn);
629
error:
630
  FN(PW,free)(pw1);
631
  FN(PW,free)(pw2);
632
  return NULL;
633
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_on_shared_domain
isl_aff.c:isl_pw_aff_on_shared_domain
Line
Count
Source
621
69.0k
{
622
69.0k
  isl_space *space;
623
69.0k
624
69.0k
  if (
!pw1 || 69.0k
!pw269.0k
)
625
0
    goto error;
626
69.0k
627
69.0k
  space = isl_space_copy(pw1->dim);
628
69.0k
  return FN(PW,on_shared_domain_in)(pw1, pw2, space, fn);
629
0
error:
630
0
  FN(PW,free)(pw1);
631
0
  FN(PW,free)(pw2);
632
0
  return NULL;
633
69.0k
}
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 || 1
!pw21
)
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
0
error:
630
0
  FN(PW,free)(pw1);
631
0
  FN(PW,free)(pw2);
632
0
  return NULL;
633
1
}
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
{
638
  int i;
639
640
  if (!pw)
641
    return NULL;
642
643
  if (FN(PW,IS_ZERO)(pw))
644
    return pw;
645
646
  pw = FN(PW,cow)(pw);
647
  if (!pw)
648
    return NULL;
649
650
  for (i = 0; i < pw->n; ++i) {
651
    pw->p[i].FIELD = FN(EL,neg)(pw->p[i].FIELD);
652
    if (!pw->p[i].FIELD)
653
      return FN(PW,free)(pw);
654
  }
655
656
  return pw;
657
}
Unexecuted instantiation: isl_pw_multi_aff_neg
isl_pw_aff_neg
Line
Count
Source
637
21.9k
{
638
21.9k
  int i;
639
21.9k
640
21.9k
  if (!pw)
641
0
    return NULL;
642
21.9k
643
21.9k
  
if (21.9k
FN21.9k
(PW,IS_ZERO)(pw)21.9k
)
644
0
    return pw;
645
21.9k
646
21.9k
  
pw = 21.9k
FN21.9k
(PW,cow)(pw);
647
21.9k
  if (!pw)
648
0
    return NULL;
649
21.9k
650
44.6k
  
for (i = 0; 21.9k
i < pw->n44.6k
;
++i22.7k
)
{22.7k
651
22.7k
    pw->p[i].
FIELD22.7k
=
FN22.7k
(EL,neg)(pw->p[i].
FIELD22.7k
);
652
22.7k
    if (
!pw->p[i].22.7k
FIELD22.7k
)
653
0
      
return 0
FN0
(PW,free)(pw);
654
22.7k
  }
655
21.9k
656
21.9k
  return pw;
657
21.9k
}
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 (11
FN11
(PW,IS_ZERO)(pw)11
)
644
0
    return pw;
645
11
646
11
  
pw = 11
FN11
(PW,cow)(pw);
647
11
  if (!pw)
648
0
    return NULL;
649
11
650
23
  
for (i = 0; 11
i < pw->n23
;
++i12
)
{12
651
12
    pw->p[i].
FIELD12
=
FN12
(EL,neg)(pw->p[i].
FIELD12
);
652
12
    if (
!pw->p[i].12
FIELD12
)
653
0
      
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
{
663
  return FN(PW,add)(pw1, FN(PW,neg)(pw2));
664
}
isl_pw_aff_sub
Line
Count
Source
662
6.59k
{
663
6.59k
  return 
FN6.59k
(PW,add)(pw1,
FN6.59k
(PW,neg)(pw2));
664
6.59k
}
isl_pw_qpolynomial_sub
Line
Count
Source
662
9
{
663
9
  return 
FN9
(PW,add)(pw1,
FN9
(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
{
670
  int i;
671
  int found = 0;
672
  isl_ctx *ctx;
673
  isl_space *pnt_dim = NULL;
674
  isl_val *v;
675
676
  if (!pw || !pnt)
677
    goto error;
678
  ctx = isl_point_get_ctx(pnt);
679
  pnt_dim = isl_point_get_space(pnt);
680
  isl_assert(ctx, isl_space_is_domain_internal(pnt_dim, pw->dim),
681
        goto error);
682
683
  for (i = 0; i < pw->n; ++i) {
684
    found = isl_set_contains_point(pw->p[i].set, pnt);
685
    if (found < 0)
686
      goto error;
687
    if (found)
688
      break;
689
  }
690
  if (found)
691
    v = FN(EL,eval)(FN(EL,copy)(pw->p[i].FIELD),
692
              isl_point_copy(pnt));
693
  else
694
    v = isl_val_zero(ctx);
695
  FN(PW,free)(pw);
696
  isl_space_free(pnt_dim);
697
  isl_point_free(pnt);
698
  return v;
699
error:
700
  FN(PW,free)(pw);
701
  isl_space_free(pnt_dim);
702
  isl_point_free(pnt);
703
  return NULL;
704
}
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 || 1
!pnt1
)
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; 1
i < pw->n1
;
++i0
)
{1
684
1
    found = isl_set_contains_point(pw->p[i].set, pnt);
685
1
    if (found < 0)
686
0
      goto error;
687
1
    
if (1
found1
)
688
1
      break;
689
1
  }
690
1
  
if (1
found1
)
691
1
    
v = 1
FN1
(EL,eval)(
FN1
(EL,copy)(pw->p[i].
FIELD1
),
692
1
              isl_point_copy(pnt));
693
1
  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
0
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
705
#endif
706
707
/* Return the parameter domain of "pw".
708
 */
709
__isl_give isl_set *FN(PW,params)(__isl_take PW *pw)
710
{
711
  return isl_set_params(FN(PW,domain)(pw));
712
}
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
{
716
  int i;
717
  isl_set *dom;
718
719
  if (!pw)
720
    return NULL;
721
722
  dom = isl_set_empty(FN(PW,get_domain_space)(pw));
723
  for (i = 0; i < pw->n; ++i)
724
    dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
725
726
  FN(PW,free)(pw);
727
728
  return dom;
729
}
isl_pw_multi_aff_domain
Line
Count
Source
715
84
{
716
84
  int i;
717
84
  isl_set *dom;
718
84
719
84
  if (!pw)
720
0
    return NULL;
721
84
722
84
  
dom = isl_set_empty(84
FN84
(PW,get_domain_space)(pw));
723
168
  for (i = 0; 
i < pw->n168
;
++i84
)
724
84
    dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
725
84
726
84
  FN(PW,free)(pw);
727
84
728
84
  return dom;
729
84
}
isl_pw_aff_domain
Line
Count
Source
715
46.3k
{
716
46.3k
  int i;
717
46.3k
  isl_set *dom;
718
46.3k
719
46.3k
  if (!pw)
720
0
    return NULL;
721
46.3k
722
46.3k
  
dom = isl_set_empty(46.3k
FN46.3k
(PW,get_domain_space)(pw));
723
94.3k
  for (i = 0; 
i < pw->n94.3k
;
++i47.9k
)
724
47.9k
    dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
725
46.3k
726
46.3k
  FN(PW,free)(pw);
727
46.3k
728
46.3k
  return dom;
729
46.3k
}
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(1
FN1
(PW,get_domain_space)(pw));
723
2
  for (i = 0; 
i < pw->n2
;
++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
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_domain
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
{
739
  isl_basic_set *aff;
740
  int empty = isl_set_plain_is_empty(pw->p[i].set);
741
742
  if (empty < 0)
743
    return -1;
744
  if (empty) {
745
    isl_set_free(pw->p[i].set);
746
    FN(EL,free)(pw->p[i].FIELD);
747
    if (i != pw->n - 1)
748
      pw->p[i] = pw->p[pw->n - 1];
749
    pw->n--;
750
751
    return 0;
752
  }
753
754
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
755
  pw->p[i].FIELD = FN(EL,substitute_equalities)(pw->p[i].FIELD, aff);
756
  if (!pw->p[i].FIELD)
757
    return -1;
758
759
  return 0;
760
}
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 (35
empty35
)
{0
745
0
    isl_set_free(pw->p[i].set);
746
0
    
FN0
(EL,free)(pw->p[i].
FIELD0
);
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].
FIELD35
=
FN35
(EL,substitute_equalities)(pw->p[i].
FIELD35
, aff);
756
35
  if (
!pw->p[i].35
FIELD35
)
757
0
    return -1;
758
35
759
35
  return 0;
760
35
}
isl_aff.c:isl_pw_multi_aff_exploit_equalities_and_remove_if_empty
Line
Count
Source
738
1.42k
{
739
1.42k
  isl_basic_set *aff;
740
1.42k
  int empty = isl_set_plain_is_empty(pw->p[i].set);
741
1.42k
742
1.42k
  if (empty < 0)
743
0
    return -1;
744
1.42k
  
if (1.42k
empty1.42k
)
{1
745
1
    isl_set_free(pw->p[i].set);
746
1
    
FN1
(EL,free)(pw->p[i].
FIELD1
);
747
1
    if (i != pw->n - 1)
748
0
      pw->p[i] = pw->p[pw->n - 1];
749
1
    pw->n--;
750
1
751
1
    return 0;
752
1
  }
753
1.42k
754
1.42k
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
755
1.42k
  pw->p[i].
FIELD1.42k
=
FN1.42k
(EL,substitute_equalities)(pw->p[i].
FIELD1.42k
, aff);
756
1.42k
  if (
!pw->p[i].1.42k
FIELD1.42k
)
757
0
    return -1;
758
1.42k
759
1.42k
  return 0;
760
1.42k
}
isl_aff.c:isl_pw_aff_exploit_equalities_and_remove_if_empty
Line
Count
Source
738
33.0k
{
739
33.0k
  isl_basic_set *aff;
740
33.0k
  int empty = isl_set_plain_is_empty(pw->p[i].set);
741
33.0k
742
33.0k
  if (empty < 0)
743
0
    return -1;
744
33.0k
  
if (33.0k
empty33.0k
)
{20
745
20
    isl_set_free(pw->p[i].set);
746
20
    
FN20
(EL,free)(pw->p[i].
FIELD20
);
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
33.0k
754
33.0k
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
755
33.0k
  pw->p[i].
FIELD33.0k
=
FN33.0k
(EL,substitute_equalities)(pw->p[i].
FIELD33.0k
, aff);
756
33.0k
  if (
!pw->p[i].33.0k
FIELD33.0k
)
757
0
    return -1;
758
33.0k
759
33.0k
  return 0;
760
33.0k
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_exploit_equalities_and_remove_if_empty
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
{
767
  isl_space *space;
768
769
  if (!pw)
770
    return NULL;
771
  if (!isl_space_is_set(pw->dim))
772
    isl_die(FN(PW,get_ctx)(pw), isl_error_invalid,
773
      "not living in a set space", return FN(PW,free)(pw));
774
775
  space = FN(PW,get_space)(pw);
776
  space = isl_space_from_range(space);
777
  pw = FN(PW,reset_space)(pw, space);
778
779
  return pw;
780
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_from_range
Unexecuted instantiation: isl_pw_aff_from_range
Unexecuted instantiation: isl_pw_qpolynomial_from_range
Unexecuted instantiation: isl_pw_multi_aff_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
{
788
  int i;
789
790
  if (!pw)
791
    return NULL;
792
793
  if (type == isl_dim_out)
794
    isl_die(FN(PW,get_ctx)(pw), isl_error_invalid,
795
      "cannot fix output dimension", return FN(PW,free)(pw));
796
797
  if (pw->n == 0)
798
    return pw;
799
800
  if (type == isl_dim_in)
801
    type = isl_dim_set;
802
803
  pw = FN(PW,cow)(pw);
804
  if (!pw)
805
    return FN(PW,free)(pw);
806
807
  for (i = pw->n - 1; i >= 0; --i) {
808
    pw->p[i].set = isl_set_fix_si(pw->p[i].set, type, pos, value);
809
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
810
      return FN(PW,free)(pw);
811
  }
812
813
  return pw;
814
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_fix_si
Unexecuted instantiation: isl_pw_multi_aff_fix_si
Unexecuted instantiation: isl_pw_aff_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
{
825
  int i;
826
827
  if (!pw || !set)
828
    goto error;
829
830
  if (pw->n == 0) {
831
    isl_set_free(set);
832
    return pw;
833
  }
834
835
  pw = FN(PW,cow)(pw);
836
  if (!pw)
837
    goto error;
838
839
  for (i = pw->n - 1; i >= 0; --i) {
840
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
841
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
842
      goto error;
843
  }
844
  
845
  isl_set_free(set);
846
  return pw;
847
error:
848
  isl_set_free(set);
849
  FN(PW,free)(pw);
850
  return NULL;
851
}
isl_polynomial.c:isl_pw_qpolynomial_restrict_domain_aligned
Line
Count
Source
824
35
{
825
35
  int i;
826
35
827
35
  if (
!pw || 35
!set35
)
828
0
    goto error;
829
35
830
35
  
if (35
pw->n == 035
)
{1
831
1
    isl_set_free(set);
832
1
    return pw;
833
1
  }
834
35
835
34
  
pw = 34
FN34
(PW,cow)(pw);
836
34
  if (!pw)
837
0
    goto error;
838
34
839
68
  
for (i = pw->n - 1; 34
i >= 068
;
--i34
)
{34
840
34
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
841
34
    if (
FN34
(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 034
)
842
0
      goto error;
843
34
  }
844
34
  
845
34
  isl_set_free(set);
846
34
  return pw;
847
0
error:
848
0
  isl_set_free(set);
849
0
  FN(PW,free)(pw);
850
0
  return NULL;
851
34
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_restrict_domain_aligned
isl_aff.c:isl_pw_multi_aff_restrict_domain_aligned
Line
Count
Source
824
1.42k
{
825
1.42k
  int i;
826
1.42k
827
1.42k
  if (
!pw || 1.42k
!set1.42k
)
828
0
    goto error;
829
1.42k
830
1.42k
  
if (1.42k
pw->n == 01.42k
)
{0
831
0
    isl_set_free(set);
832
0
    return pw;
833
0
  }
834
1.42k
835
1.42k
  
pw = 1.42k
FN1.42k
(PW,cow)(pw);
836
1.42k
  if (!pw)
837
0
    goto error;
838
1.42k
839
2.84k
  
for (i = pw->n - 1; 1.42k
i >= 02.84k
;
--i1.42k
)
{1.42k
840
1.42k
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
841
1.42k
    if (
FN1.42k
(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 01.42k
)
842
0
      goto error;
843
1.42k
  }
844
1.42k
  
845
1.42k
  isl_set_free(set);
846
1.42k
  return pw;
847
0
error:
848
0
  isl_set_free(set);
849
0
  FN(PW,free)(pw);
850
0
  return NULL;
851
1.42k
}
isl_aff.c:isl_pw_aff_restrict_domain_aligned
Line
Count
Source
824
31.8k
{
825
31.8k
  int i;
826
31.8k
827
31.8k
  if (
!pw || 31.8k
!set31.8k
)
828
0
    goto error;
829
31.8k
830
31.8k
  
if (31.8k
pw->n == 031.8k
)
{0
831
0
    isl_set_free(set);
832
0
    return pw;
833
0
  }
834
31.8k
835
31.8k
  
pw = 31.8k
FN31.8k
(PW,cow)(pw);
836
31.8k
  if (!pw)
837
0
    goto error;
838
31.8k
839
64.9k
  
for (i = pw->n - 1; 31.8k
i >= 064.9k
;
--i33.0k
)
{33.0k
840
33.0k
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
841
33.0k
    if (
FN33.0k
(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 033.0k
)
842
0
      goto error;
843
33.0k
  }
844
31.8k
  
845
31.8k
  isl_set_free(set);
846
31.8k
  return pw;
847
0
error:
848
0
  isl_set_free(set);
849
0
  FN(PW,free)(pw);
850
0
  return NULL;
851
31.8k
}
852
853
static __isl_give PW *FN(PW,intersect_domain_aligned)(__isl_take PW *pw,
854
  __isl_take isl_set *set)
855
{
856
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
857
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_intersect_domain_aligned
isl_aff.c:isl_pw_multi_aff_intersect_domain_aligned
Line
Count
Source
855
1.41k
{
856
1.41k
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
857
1.41k
}
isl_aff.c:isl_pw_aff_intersect_domain_aligned
Line
Count
Source
855
31.8k
{
856
31.8k
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
857
31.8k
}
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
{
862
  return FN(PW,align_params_pw_set_and)(pw, context,
863
          &FN(PW,intersect_domain_aligned));
864
}
isl_pw_multi_aff_intersect_domain
Line
Count
Source
861
1.41k
{
862
1.41k
  return FN(PW,align_params_pw_set_and)(pw, context,
863
1.41k
          &FN(PW,intersect_domain_aligned));
864
1.41k
}
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
}
isl_pw_aff_intersect_domain
Line
Count
Source
861
31.8k
{
862
31.8k
  return FN(PW,align_params_pw_set_and)(pw, context,
863
31.8k
          &FN(PW,intersect_domain_aligned));
864
31.8k
}
865
866
static __isl_give PW *FN(PW,intersect_params_aligned)(__isl_take PW *pw,
867
  __isl_take isl_set *set)
868
{
869
  return FN(PW,restrict_domain_aligned)(pw, set,
870
          &isl_set_intersect_params);
871
}
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_intersect_params_aligned
Unexecuted instantiation: isl_aff.c:isl_pw_multi_aff_intersect_params_aligned
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_intersect_params_aligned
Unexecuted instantiation: isl_aff.c:isl_pw_aff_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
{
878
  return FN(PW,align_params_pw_set_and)(pw, context,
879
          &FN(PW,intersect_params_aligned));
880
}
Unexecuted instantiation: isl_pw_qpolynomial_intersect_params
Unexecuted instantiation: isl_pw_qpolynomial_fold_intersect_params
Unexecuted instantiation: isl_pw_multi_aff_intersect_params
Unexecuted instantiation: isl_pw_aff_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
{
888
  return FN(PW,restrict_domain_aligned)(pw, domain, &isl_set_subtract);
889
}
Unexecuted instantiation: isl_aff.c:isl_pw_aff_subtract_domain_aligned
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_subtract_domain_aligned
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_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
}
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
{
896
  return FN(PW,align_params_pw_set_and)(pw, domain,
897
          &FN(PW,subtract_domain_aligned));
898
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_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_subtract_domain
Unexecuted instantiation: isl_pw_aff_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
{
911
  int i;
912
  isl_space *space;
913
914
  for (i = 0; i < pw->n - 1; ++i) {
915
    isl_set_free(pw->p[i].set);
916
    FN(EL,free)(pw->p[i].FIELD);
917
  }
918
  pw->p[0].FIELD = pw->p[pw->n - 1].FIELD;
919
  pw->p[0].set = pw->p[pw->n - 1].set;
920
  pw->n = 1;
921
922
  space = isl_set_get_space(context);
923
  pw->p[0].FIELD = fn_el(pw->p[0].FIELD, context);
924
  context = isl_set_universe(space);
925
  isl_set_free(pw->p[0].set);
926
  pw->p[0].set = context;
927
928
  if (!pw->p[0].FIELD || !pw->p[0].set)
929
    return FN(PW,free)(pw);
930
931
  return pw;
932
}
isl_aff.c:isl_pw_aff_gist_last
Line
Count
Source
910
4.07k
{
911
4.07k
  int i;
912
4.07k
  isl_space *space;
913
4.07k
914
4.07k
  for (i = 0; 
i < pw->n - 14.07k
;
++i0
)
{0
915
0
    isl_set_free(pw->p[i].set);
916
0
    
FN0
(EL,free)(pw->p[i].
FIELD0
);
917
0
  }
918
4.07k
  pw->p[0].
FIELD4.07k
= pw->p[pw->n - 1].
FIELD4.07k
;
919
4.07k
  pw->p[0].set = pw->p[pw->n - 1].set;
920
4.07k
  pw->n = 1;
921
4.07k
922
4.07k
  space = isl_set_get_space(context);
923
4.07k
  pw->p[0].
FIELD4.07k
= fn_el(pw->p[0].
FIELD4.07k
, context);
924
4.07k
  context = isl_set_universe(space);
925
4.07k
  isl_set_free(pw->p[0].set);
926
4.07k
  pw->p[0].set = context;
927
4.07k
928
4.07k
  if (
!pw->p[0].4.07k
FIELD4.07k
||
!pw->p[0].set4.07k
)
929
0
    
return 0
FN0
(PW,free)(pw);
930
4.07k
931
4.07k
  return pw;
932
4.07k
}
isl_aff.c:isl_pw_multi_aff_gist_last
Line
Count
Source
910
1.16k
{
911
1.16k
  int i;
912
1.16k
  isl_space *space;
913
1.16k
914
1.16k
  for (i = 0; 
i < pw->n - 11.16k
;
++i0
)
{0
915
0
    isl_set_free(pw->p[i].set);
916
0
    
FN0
(EL,free)(pw->p[i].
FIELD0
);
917
0
  }
918
1.16k
  pw->p[0].
FIELD1.16k
= pw->p[pw->n - 1].
FIELD1.16k
;
919
1.16k
  pw->p[0].set = pw->p[pw->n - 1].set;
920
1.16k
  pw->n = 1;
921
1.16k
922
1.16k
  space = isl_set_get_space(context);
923
1.16k
  pw->p[0].
FIELD1.16k
= fn_el(pw->p[0].
FIELD1.16k
, context);
924
1.16k
  context = isl_set_universe(space);
925
1.16k
  isl_set_free(pw->p[0].set);
926
1.16k
  pw->p[0].set = context;
927
1.16k
928
1.16k
  if (
!pw->p[0].1.16k
FIELD1.16k
||
!pw->p[0].set1.16k
)
929
0
    
return 0
FN0
(PW,free)(pw);
930
1.16k
931
1.16k
  return pw;
932
1.16k
}
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 - 11
;
++i0
)
{0
915
0
    isl_set_free(pw->p[i].set);
916
0
    
FN0
(EL,free)(pw->p[i].
FIELD0
);
917
0
  }
918
1
  pw->p[0].
FIELD1
= pw->p[pw->n - 1].
FIELD1
;
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].
FIELD1
= fn_el(pw->p[0].
FIELD1
, 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].1
FIELD1
||
!pw->p[0].set1
)
929
0
    
return 0
FN0
(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
{
948
  int i;
949
  int is_universe;
950
  isl_bool aligned;
951
  isl_basic_set *hull = NULL;
952
953
  if (!pw || !context)
954
    goto error;
955
956
  if (pw->n == 0) {
957
    isl_set_free(context);
958
    return pw;
959
  }
960
961
  is_universe = isl_set_plain_is_universe(context);
962
  if (is_universe < 0)
963
    goto error;
964
  if (is_universe) {
965
    isl_set_free(context);
966
    return pw;
967
  }
968
969
  aligned = isl_set_space_has_equal_params(context, pw->dim);
970
  if (aligned < 0)
971
    goto error;
972
  if (!aligned) {
973
    pw = FN(PW,align_params)(pw, isl_set_get_space(context));
974
    context = isl_set_align_params(context, FN(PW,get_space)(pw));
975
  }
976
977
  pw = FN(PW,cow)(pw);
978
  if (!pw)
979
    goto error;
980
981
  if (pw->n == 1) {
982
    int equal;
983
984
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
985
    if (equal < 0)
986
      goto error;
987
    if (equal)
988
      return FN(PW,gist_last)(pw, context, fn_el);
989
  }
990
991
  context = isl_set_compute_divs(context);
992
  hull = isl_set_simple_hull(isl_set_copy(context));
993
994
  for (i = pw->n - 1; i >= 0; --i) {
995
    isl_set *set_i;
996
    int empty;
997
998
    if (i == pw->n - 1) {
999
      int equal;
1000
      equal = isl_set_plain_is_equal(pw->p[i].set, context);
1001
      if (equal < 0)
1002
        goto error;
1003
      if (equal) {
1004
        isl_basic_set_free(hull);
1005
        return FN(PW,gist_last)(pw, context, fn_el);
1006
      }
1007
    }
1008
    set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
1009
             isl_set_copy(context));
1010
    empty = isl_set_plain_is_empty(set_i);
1011
    pw->p[i].FIELD = fn_el(pw->p[i].FIELD, set_i);
1012
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1013
    if (empty < 0 || !pw->p[i].FIELD || !pw->p[i].set)
1014
      goto error;
1015
    if (empty) {
1016
      isl_set_free(pw->p[i].set);
1017
      FN(EL,free)(pw->p[i].FIELD);
1018
      if (i != pw->n - 1)
1019
        pw->p[i] = pw->p[pw->n - 1];
1020
      pw->n--;
1021
    }
1022
  }
1023
1024
  isl_basic_set_free(hull);
1025
  isl_set_free(context);
1026
1027
  return pw;
1028
error:
1029
  FN(PW,free)(pw);
1030
  isl_basic_set_free(hull);
1031
  isl_set_free(context);
1032
  return NULL;
1033
}
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 || 4
!context4
)
954
0
    goto error;
955
4
956
4
  
if (4
pw->n == 04
)
{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 (4
is_universe4
)
{0
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 (4
!aligned4
)
{0
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 (4
pw->n == 14
)
{4
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 (4
equal4
)
988
1
      
return 1
FN1
(PW,gist_last)(pw, context, fn_el);
989
4
  }
990
4
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 >= 06
;
--i3
)
{3
995
3
    isl_set *set_i;
996
3
    int empty;
997
3
998
3
    if (
i == pw->n - 13
)
{3
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 (3
equal3
)
{0
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].
FIELD3
= fn_el(pw->p[i].
FIELD3
, set_i);
1012
3
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1013
3
    if (
empty < 0 || 3
!pw->p[i].3
FIELD3
||
!pw->p[i].set3
)
1014
0
      goto error;
1015
3
    
if (3
empty3
)
{0
1016
0
      isl_set_free(pw->p[i].set);
1017
0
      
FN0
(EL,free)(pw->p[i].
FIELD0
);
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
0
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
3
}
isl_aff.c:isl_pw_aff_gist_aligned
Line
Count
Source
947
6.86k
{
948
6.86k
  int i;
949
6.86k
  int is_universe;
950
6.86k
  isl_bool aligned;
951
6.86k
  isl_basic_set *hull = NULL;
952
6.86k
953
6.86k
  if (
!pw || 6.86k
!context6.86k
)
954
0
    goto error;
955
6.86k
956
6.86k
  
if (6.86k
pw->n == 06.86k
)
{0
957
0
    isl_set_free(context);
958
0
    return pw;
959
0
  }
960
6.86k
961
6.86k
  is_universe = isl_set_plain_is_universe(context);
962
6.86k
  if (is_universe < 0)
963
0
    goto error;
964
6.86k
  
if (6.86k
is_universe6.86k
)
{962
965
962
    isl_set_free(context);
966
962
    return pw;
967
962
  }
968
6.86k
969
5.90k
  aligned = isl_set_space_has_equal_params(context, pw->dim);
970
5.90k
  if (aligned < 0)
971
0
    goto error;
972
5.90k
  
if (5.90k
!aligned5.90k
)
{0
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
5.90k
977
5.90k
  pw = FN(PW,cow)(pw);
978
5.90k
  if (!pw)
979
0
    goto error;
980
5.90k
981
5.90k
  
if (5.90k
pw->n == 15.90k
)
{5.87k
982
5.87k
    int equal;
983
5.87k
984
5.87k
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
985
5.87k
    if (equal < 0)
986
0
      goto error;
987
5.87k
    
if (5.87k
equal5.87k
)
988
4.07k
      
return 4.07k
FN4.07k
(PW,gist_last)(pw, context, fn_el);
989
5.87k
  }
990
5.90k
991
1.83k
  context = isl_set_compute_divs(context);
992
1.83k
  hull = isl_set_simple_hull(isl_set_copy(context));
993
1.83k
994
3.70k
  for (i = pw->n - 1; 
i >= 03.70k
;
--i1.86k
)
{1.86k
995
1.86k
    isl_set *set_i;
996
1.86k
    int empty;
997
1.86k
998
1.86k
    if (
i == pw->n - 11.86k
)
{1.83k
999
1.83k
      int equal;
1000
1.83k
      equal = isl_set_plain_is_equal(pw->p[i].set, context);
1001
1.83k
      if (equal < 0)
1002
0
        goto error;
1003
1.83k
      
if (1.83k
equal1.83k
)
{0
1004
0
        isl_basic_set_free(hull);
1005
0
        return FN(PW,gist_last)(pw, context, fn_el);
1006
0
      }
1007
1.83k
    }
1008
1.86k
    set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
1009
1.86k
             isl_set_copy(context));
1010
1.86k
    empty = isl_set_plain_is_empty(set_i);
1011
1.86k
    pw->p[i].
FIELD1.86k
= fn_el(pw->p[i].
FIELD1.86k
, set_i);
1012
1.86k
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1013
1.86k
    if (
empty < 0 || 1.86k
!pw->p[i].1.86k
FIELD1.86k
||
!pw->p[i].set1.86k
)
1014
0
      goto error;
1015
1.86k
    
if (1.86k
empty1.86k
)
{0
1016
0
      isl_set_free(pw->p[i].set);
1017
0
      
FN0
(EL,free)(pw->p[i].
FIELD0
);
1018
0
      if (i != pw->n - 1)
1019
0
        pw->p[i] = pw->p[pw->n - 1];
1020
0
      pw->n--;
1021
0
    }
1022
1.86k
  }
1023
1.83k
1024
1.83k
  isl_basic_set_free(hull);
1025
1.83k
  isl_set_free(context);
1026
1.83k
1027
1.83k
  return pw;
1028
0
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
1.83k
}
isl_aff.c:isl_pw_multi_aff_gist_aligned
Line
Count
Source
947
1.32k
{
948
1.32k
  int i;
949
1.32k
  int is_universe;
950
1.32k
  isl_bool aligned;
951
1.32k
  isl_basic_set *hull = NULL;
952
1.32k
953
1.32k
  if (
!pw || 1.32k
!context1.32k
)
954
0
    goto error;
955
1.32k
956
1.32k
  
if (1.32k
pw->n == 01.32k
)
{0
957
0
    isl_set_free(context);
958
0
    return pw;
959
0
  }
960
1.32k
961
1.32k
  is_universe = isl_set_plain_is_universe(context);
962
1.32k
  if (is_universe < 0)
963
0
    goto error;
964
1.32k
  
if (1.32k
is_universe1.32k
)
{70
965
70
    isl_set_free(context);
966
70
    return pw;
967
70
  }
968
1.32k
969
1.25k
  aligned = isl_set_space_has_equal_params(context, pw->dim);
970
1.25k
  if (aligned < 0)
971
0
    goto error;
972
1.25k
  
if (1.25k
!aligned1.25k
)
{0
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
1.25k
977
1.25k
  pw = FN(PW,cow)(pw);
978
1.25k
  if (!pw)
979
0
    goto error;
980
1.25k
981
1.25k
  
if (1.25k
pw->n == 11.25k
)
{1.25k
982
1.25k
    int equal;
983
1.25k
984
1.25k
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
985
1.25k
    if (equal < 0)
986
0
      goto error;
987
1.25k
    
if (1.25k
equal1.25k
)
988
1.16k
      
return 1.16k
FN1.16k
(PW,gist_last)(pw, context, fn_el);
989
1.25k
  }
990
1.25k
991
90
  context = isl_set_compute_divs(context);
992
90
  hull = isl_set_simple_hull(isl_set_copy(context));
993
90
994
180
  for (i = pw->n - 1; 
i >= 0180
;
--i90
)
{90
995
90
    isl_set *set_i;
996
90
    int empty;
997
90
998
90
    if (
i == pw->n - 190
)
{90
999
90
      int equal;
1000
90
      equal = isl_set_plain_is_equal(pw->p[i].set, context);
1001
90
      if (equal < 0)
1002
0
        goto error;
1003
90
      
if (90
equal90
)
{0
1004
0
        isl_basic_set_free(hull);
1005
0
        return FN(PW,gist_last)(pw, context, fn_el);
1006
0
      }
1007
90
    }
1008
90
    set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
1009
90
             isl_set_copy(context));
1010
90
    empty = isl_set_plain_is_empty(set_i);
1011
90
    pw->p[i].
FIELD90
= fn_el(pw->p[i].
FIELD90
, set_i);
1012
90
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1013
90
    if (
empty < 0 || 90
!pw->p[i].90
FIELD90
||
!pw->p[i].set90
)
1014
0
      goto error;
1015
90
    
if (90
empty90
)
{0
1016
0
      isl_set_free(pw->p[i].set);
1017
0
      
FN0
(EL,free)(pw->p[i].
FIELD0
);
1018
0
      if (i != pw->n - 1)
1019
0
        pw->p[i] = pw->p[pw->n - 1];
1020
0
      pw->n--;
1021
0
    }
1022
90
  }
1023
90
1024
90
  isl_basic_set_free(hull);
1025
90
  isl_set_free(context);
1026
90
1027
90
  return pw;
1028
0
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
90
}
1034
1035
static __isl_give PW *FN(PW,gist_domain_aligned)(__isl_take PW *pw,
1036
  __isl_take isl_set *set)
1037
{
1038
  return FN(PW,gist_aligned)(pw, set, &FN(EL,gist),
1039
          &isl_set_gist_basic_set);
1040
}
isl_polynomial.c:isl_pw_qpolynomial_gist_domain_aligned
Line
Count
Source
1037
4
{
1038
4
  return 
FN4
(PW,gist_aligned)(pw, set, &
FN4
(EL,gist),
1039
4
          &isl_set_gist_basic_set);
1040
4
}
isl_aff.c:isl_pw_multi_aff_gist_domain_aligned
Line
Count
Source
1037
1.32k
{
1038
1.32k
  return 
FN1.32k
(PW,gist_aligned)(pw, set, &
FN1.32k
(EL,gist),
1039
1.32k
          &isl_set_gist_basic_set);
1040
1.32k
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_gist_domain_aligned
isl_aff.c:isl_pw_aff_gist_domain_aligned
Line
Count
Source
1037
6.86k
{
1038
6.86k
  return 
FN6.86k
(PW,gist_aligned)(pw, set, &
FN6.86k
(EL,gist),
1039
6.86k
          &isl_set_gist_basic_set);
1040
6.86k
}
1041
1042
__isl_give PW *FN(PW,gist)(__isl_take PW *pw, __isl_take isl_set *context)
1043
{
1044
  return FN(PW,align_params_pw_set_and)(pw, context,
1045
            &FN(PW,gist_domain_aligned));
1046
}
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
}
isl_pw_multi_aff_gist
Line
Count
Source
1043
1.32k
{
1044
1.32k
  return FN(PW,align_params_pw_set_and)(pw, context,
1045
1.32k
            &FN(PW,gist_domain_aligned));
1046
1.32k
}
isl_pw_aff_gist
Line
Count
Source
1043
6.86k
{
1044
6.86k
  return FN(PW,align_params_pw_set_and)(pw, context,
1045
6.86k
            &FN(PW,gist_domain_aligned));
1046
6.86k
}
1047
1048
static __isl_give PW *FN(PW,gist_params_aligned)(__isl_take PW *pw,
1049
  __isl_take isl_set *set)
1050
{
1051
  return FN(PW,gist_aligned)(pw, set, &FN(EL,gist_params),
1052
          &isl_set_gist_params_basic_set);
1053
}
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_gist_params_aligned
Unexecuted instantiation: isl_aff.c:isl_pw_multi_aff_gist_params_aligned
Unexecuted instantiation: isl_aff.c:isl_pw_aff_gist_params_aligned
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_gist_params_aligned
1054
1055
__isl_give PW *FN(PW,gist_params)(__isl_take PW *pw,
1056
  __isl_take isl_set *context)
1057
{
1058
  return FN(PW,align_params_pw_set_and)(pw, context,
1059
            &FN(PW,gist_params_aligned));
1060
}
Unexecuted instantiation: isl_pw_aff_gist_params
Unexecuted instantiation: isl_pw_qpolynomial_gist_params
Unexecuted instantiation: isl_pw_qpolynomial_fold_gist_params
Unexecuted instantiation: isl_pw_multi_aff_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
{
1070
  struct FN(PW,piece) const *pc1 = p1;
1071
  struct FN(PW,piece) const *pc2 = p2;
1072
1073
  return FN(EL,plain_cmp)(pc1->FIELD, pc2->FIELD);
1074
}
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 
FN1
(EL,plain_cmp)(pc1->
FIELD1
, pc2->
FIELD1
);
1074
1
}
isl_aff.c:isl_pw_aff_sort_field_cmp
Line
Count
Source
1069
538
{
1070
538
  struct FN(PW,piece) const *pc1 = p1;
1071
538
  struct FN(PW,piece) const *pc2 = p2;
1072
538
1073
538
  return 
FN538
(EL,plain_cmp)(pc1->
FIELD538
, pc2->
FIELD538
);
1074
538
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_sort_field_cmp
isl_aff.c:isl_pw_multi_aff_sort_field_cmp
Line
Count
Source
1069
1.69k
{
1070
1.69k
  struct FN(PW,piece) const *pc1 = p1;
1071
1.69k
  struct FN(PW,piece) const *pc2 = p2;
1072
1.69k
1073
1.69k
  return 
FN1.69k
(EL,plain_cmp)(pc1->
FIELD1.69k
, pc2->
FIELD1.69k
);
1074
1.69k
}
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
{
1087
  int i, j;
1088
  isl_set *set;
1089
1090
  if (!pw)
1091
    return NULL;
1092
  if (pw->n <= 1)
1093
    return pw;
1094
  if (isl_sort(pw->p, pw->n, sizeof(pw->p[0]),
1095
        &FN(PW,sort_field_cmp), NULL) < 0)
1096
    return FN(PW,free)(pw);
1097
  for (i = pw->n - 1; i >= 1; --i) {
1098
    if (!FN(EL,plain_is_equal)(pw->p[i - 1].FIELD, pw->p[i].FIELD))
1099
      continue;
1100
    set = isl_set_union(isl_set_copy(pw->p[i - 1].set),
1101
            isl_set_copy(pw->p[i].set));
1102
    if (!set)
1103
      return FN(PW,free)(pw);
1104
    isl_set_free(pw->p[i].set);
1105
    FN(EL,free)(pw->p[i].FIELD);
1106
    isl_set_free(pw->p[i - 1].set);
1107
    pw->p[i - 1].set = set;
1108
    for (j = i + 1; j < pw->n; ++j)
1109
      pw->p[j - 1] = pw->p[j];
1110
    pw->n--;
1111
  }
1112
1113
  return pw;
1114
}
isl_pw_multi_aff_sort
Line
Count
Source
1086
3.19k
{
1087
3.19k
  int i, j;
1088
3.19k
  isl_set *set;
1089
3.19k
1090
3.19k
  if (!pw)
1091
0
    return NULL;
1092
3.19k
  
if (3.19k
pw->n <= 13.19k
)
1093
2.76k
    return pw;
1094
433
  
if (433
isl_sort(pw->p, pw->n, sizeof(pw->p[0]),433
1095
433
        &FN(PW,sort_field_cmp), NULL) < 0)
1096
0
    
return 0
FN0
(PW,free)(pw);
1097
1.48k
  
for (i = pw->n - 1; 433
i >= 11.48k
;
--i1.04k
)
{1.04k
1098
1.04k
    if (
!1.04k
FN1.04k
(EL,plain_is_equal)(pw->p[i - 1].
FIELD1.04k
, pw->p[i].
FIELD1.04k
))
1099
999
      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 0
FN0
(PW,free)(pw);
1104
48
    isl_set_free(pw->p[i].set);
1105
48
    
FN48
(EL,free)(pw->p[i].
FIELD48
);
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->n49
;
++j1
)
1109
1
      pw->p[j - 1] = pw->p[j];
1110
48
    pw->n--;
1111
48
  }
1112
433
1113
433
  return pw;
1114
433
}
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 (7
pw->n <= 17
)
1093
6
    return pw;
1094
1
  
if (1
isl_sort(pw->p, pw->n, sizeof(pw->p[0]),1
1095
1
        &FN(PW,sort_field_cmp), NULL) < 0)
1096
0
    
return 0
FN0
(PW,free)(pw);
1097
2
  
for (i = pw->n - 1; 1
i >= 12
;
--i1
)
{1
1098
1
    if (
!1
FN1
(EL,plain_is_equal)(pw->p[i - 1].
FIELD1
, pw->p[i].
FIELD1
))
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 0
FN0
(PW,free)(pw);
1104
0
    isl_set_free(pw->p[i].set);
1105
0
    
FN0
(EL,free)(pw->p[i].
FIELD0
);
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->n0
;
++j0
)
1109
0
      pw->p[j - 1] = pw->p[j];
1110
0
    pw->n--;
1111
0
  }
1112
1
1113
1
  return pw;
1114
1
}
isl_pw_aff_sort
Line
Count
Source
1086
18.1k
{
1087
18.1k
  int i, j;
1088
18.1k
  isl_set *set;
1089
18.1k
1090
18.1k
  if (!pw)
1091
1
    return NULL;
1092
18.1k
  
if (18.1k
pw->n <= 118.1k
)
1093
17.8k
    return pw;
1094
280
  
if (280
isl_sort(pw->p, pw->n, sizeof(pw->p[0]),280
1095
280
        &FN(PW,sort_field_cmp), NULL) < 0)
1096
0
    
return 0
FN0
(PW,free)(pw);
1097
687
  
for (i = pw->n - 1; 280
i >= 1687
;
--i407
)
{407
1098
407
    if (
!407
FN407
(EL,plain_is_equal)(pw->p[i - 1].
FIELD407
, pw->p[i].
FIELD407
))
1099
400
      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 0
FN0
(PW,free)(pw);
1104
7
    isl_set_free(pw->p[i].set);
1105
7
    
FN7
(EL,free)(pw->p[i].
FIELD7
);
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->n19
;
++j12
)
1109
12
      pw->p[j - 1] = pw->p[j];
1110
7
    pw->n--;
1111
7
  }
1112
280
1113
280
  return pw;
1114
280
}
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 (2
pw->n <= 12
)
1093
2
    return pw;
1094
0
  
if (0
isl_sort(pw->p, pw->n, sizeof(pw->p[0]),0
1095
0
        &FN(PW,sort_field_cmp), NULL) < 0)
1096
0
    
return 0
FN0
(PW,free)(pw);
1097
0
  
for (i = pw->n - 1; 0
i >= 10
;
--i0
)
{0
1098
0
    if (
!0
FN0
(EL,plain_is_equal)(pw->p[i - 1].
FIELD0
, pw->p[i].
FIELD0
))
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 0
FN0
(PW,free)(pw);
1104
0
    isl_set_free(pw->p[i].set);
1105
0
    
FN0
(EL,free)(pw->p[i].
FIELD0
);
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->n0
;
++j0
)
1109
0
      pw->p[j - 1] = pw->p[j];
1110
0
    pw->n--;
1111
0
  }
1112
0
1113
0
  return pw;
1114
0
}
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
{
1125
  int i;
1126
1127
  pw = FN(PW,sort)(pw);
1128
  if (!pw)
1129
    return NULL;
1130
1131
  for (i = 0; i < pw->n; ++i) {
1132
    pw->p[i].set = isl_set_coalesce(pw->p[i].set);
1133
    if (!pw->p[i].set)
1134
      goto error;
1135
  }
1136
1137
  return pw;
1138
error:
1139
  FN(PW,free)(pw);
1140
  return NULL;
1141
}
isl_pw_aff_coalesce
Line
Count
Source
1124
17.3k
{
1125
17.3k
  int i;
1126
17.3k
1127
17.3k
  pw = FN(PW,sort)(pw);
1128
17.3k
  if (!pw)
1129
1
    return NULL;
1130
17.3k
1131
35.0k
  
for (i = 0; 17.3k
i < pw->n35.0k
;
++i17.7k
)
{17.7k
1132
17.7k
    pw->p[i].set = isl_set_coalesce(pw->p[i].set);
1133
17.7k
    if (!pw->p[i].set)
1134
0
      goto error;
1135
17.7k
  }
1136
17.3k
1137
17.3k
  return pw;
1138
0
error:
1139
0
  FN(PW,free)(pw);
1140
0
  return NULL;
1141
17.3k
}
isl_pw_multi_aff_coalesce
Line
Count
Source
1124
896
{
1125
896
  int i;
1126
896
1127
896
  pw = FN(PW,sort)(pw);
1128
896
  if (!pw)
1129
0
    return NULL;
1130
896
1131
1.85k
  
for (i = 0; 896
i < pw->n1.85k
;
++i959
)
{959
1132
959
    pw->p[i].set = isl_set_coalesce(pw->p[i].set);
1133
959
    if (!pw->p[i].set)
1134
0
      goto error;
1135
959
  }
1136
896
1137
896
  return pw;
1138
0
error:
1139
0
  FN(PW,free)(pw);
1140
0
  return NULL;
1141
896
}
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->n3
;
++i2
)
{2
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
0
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
{
1145
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1146
}
isl_pw_multi_aff_get_ctx
Line
Count
Source
1144
2.29k
{
1145
2.29k
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1146
2.29k
}
isl_pw_qpolynomial_get_ctx
Line
Count
Source
1144
1
{
1145
1
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1146
1
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_get_ctx
isl_pw_aff_get_ctx
Line
Count
Source
1144
19.8k
{
1145
19.8k
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1146
19.8k
}
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
{
1152
  int i;
1153
  enum isl_dim_type set_type;
1154
1155
  if (!pw)
1156
    return isl_bool_error;
1157
  if (pw->n == 0 || n == 0)
1158
    return isl_bool_false;
1159
1160
  set_type = type == isl_dim_in ? isl_dim_set : type;
1161
1162
  for (i = 0; i < pw->n; ++i) {
1163
    isl_bool involves = FN(EL,involves_dims)(pw->p[i].FIELD,
1164
              type, first, n);
1165
    if (involves < 0 || involves)
1166
      return involves;
1167
    involves = isl_set_involves_dims(pw->p[i].set,
1168
              set_type, first, n);
1169
    if (involves < 0 || involves)
1170
      return involves;
1171
  }
1172
  return isl_bool_false;
1173
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_involves_dims
Unexecuted instantiation: isl_pw_qpolynomial_involves_dims
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 (91
pw->n == 0 || 91
n == 091
)
1158
0
    return isl_bool_false;
1159
91
1160
91
  
set_type = type == isl_dim_in ? 91
isl_dim_set91
:
type0
;
1161
91
1162
182
  for (i = 0; 
i < pw->n182
;
++i91
)
{91
1163
91
    isl_bool involves = 
FN91
(EL,involves_dims)(pw->p[i].
FIELD91
,
1164
91
              type, first, n);
1165
91
    if (
involves < 0 || 91
involves91
)
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 || 91
involves91
)
1170
0
      return involves;
1171
91
  }
1172
91
  return isl_bool_false;
1173
91
}
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
{
1179
  int i;
1180
  enum isl_dim_type set_type;
1181
1182
  pw = FN(PW,cow)(pw);
1183
  if (!pw)
1184
    return NULL;
1185
1186
  set_type = type == isl_dim_in ? isl_dim_set : type;
1187
1188
  pw->dim = isl_space_set_dim_name(pw->dim, type, pos, s);
1189
  if (!pw->dim)
1190
    goto error;
1191
1192
  for (i = 0; i < pw->n; ++i) {
1193
    pw->p[i].set = isl_set_set_dim_name(pw->p[i].set,
1194
              set_type, pos, s);
1195
    if (!pw->p[i].set)
1196
      goto error;
1197
    pw->p[i].FIELD = FN(EL,set_dim_name)(pw->p[i].FIELD, type, pos, s);
1198
    if (!pw->p[i].FIELD)
1199
      goto error;
1200
  }
1201
1202
  return pw;
1203
error:
1204
  FN(PW,free)(pw);
1205
  return NULL;
1206
}
Unexecuted instantiation: isl_pw_multi_aff_set_dim_name
Unexecuted instantiation: isl_pw_aff_set_dim_name
Unexecuted instantiation: isl_pw_qpolynomial_set_dim_name
Unexecuted instantiation: isl_pw_qpolynomial_fold_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
{
1212
  int i;
1213
  enum isl_dim_type set_type;
1214
1215
  if (!pw)
1216
    return NULL;
1217
  if (n == 0 && !isl_space_get_tuple_name(pw->dim, type))
1218
    return pw;
1219
1220
  set_type = type == isl_dim_in ? isl_dim_set : type;
1221
1222
  pw = FN(PW,cow)(pw);
1223
  if (!pw)
1224
    return NULL;
1225
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1226
  if (!pw->dim)
1227
    goto error;
1228
  for (i = 0; i < pw->n; ++i) {
1229
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1230
    if (!pw->p[i].FIELD)
1231
      goto error;
1232
    if (type == isl_dim_out)
1233
      continue;
1234
    pw->p[i].set = isl_set_drop(pw->p[i].set, set_type, first, n);
1235
    if (!pw->p[i].set)
1236
      goto error;
1237
  }
1238
1239
  return pw;
1240
error:
1241
  FN(PW,free)(pw);
1242
  return NULL;
1243
}
Unexecuted instantiation: isl_pw_qpolynomial_drop_dims
isl_pw_multi_aff_drop_dims
Line
Count
Source
1211
488
{
1212
488
  int i;
1213
488
  enum isl_dim_type set_type;
1214
488
1215
488
  if (!pw)
1216
0
    return NULL;
1217
488
  
if (488
n == 0 && 488
!isl_space_get_tuple_name(pw->dim, type)0
)
1218
0
    return pw;
1219
488
1220
488
  
set_type = type == isl_dim_in ? 488
isl_dim_set0
:
type488
;
1221
488
1222
488
  pw = FN(PW,cow)(pw);
1223
488
  if (!pw)
1224
0
    return NULL;
1225
488
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1226
488
  if (!pw->dim)
1227
0
    goto error;
1228
976
  
for (i = 0; 488
i < pw->n976
;
++i488
)
{488
1229
488
    pw->p[i].
FIELD488
=
FN488
(EL,drop_dims)(pw->p[i].
FIELD488
, type, first, n);
1230
488
    if (
!pw->p[i].488
FIELD488
)
1231
0
      goto error;
1232
488
    
if (488
type == isl_dim_out488
)
1233
488
      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
0
  }
1238
488
1239
488
  return pw;
1240
0
error:
1241
0
  FN(PW,free)(pw);
1242
0
  return NULL;
1243
488
}
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 (91
n == 0 && 91
!isl_space_get_tuple_name(pw->dim, type)0
)
1218
0
    return pw;
1219
91
1220
91
  
set_type = type == isl_dim_in ? 91
isl_dim_set91
:
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->n182
;
++i91
)
{91
1229
91
    pw->p[i].
FIELD91
=
FN91
(EL,drop_dims)(pw->p[i].
FIELD91
, type, first, n);
1230
91
    if (
!pw->p[i].91
FIELD91
)
1231
0
      goto error;
1232
91
    
if (91
type == isl_dim_out91
)
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
0
error:
1241
0
  FN(PW,free)(pw);
1242
0
  return NULL;
1243
91
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_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
{
1253
  int i;
1254
  enum isl_dim_type set_type;
1255
1256
  if (!pw)
1257
    return NULL;
1258
  if (n == 0 && !isl_space_get_tuple_name(pw->dim, type))
1259
    return pw;
1260
1261
  set_type = type == isl_dim_in ? isl_dim_set : type;
1262
1263
  pw = FN(PW,cow)(pw);
1264
  if (!pw)
1265
    return NULL;
1266
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1267
  if (!pw->dim)
1268
    goto error;
1269
  for (i = 0; i < pw->n; ++i) {
1270
    pw->p[i].set = isl_set_project_out(pw->p[i].set,
1271
              set_type, first, n);
1272
    if (!pw->p[i].set)
1273
      goto error;
1274
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1275
    if (!pw->p[i].FIELD)
1276
      goto error;
1277
  }
1278
1279
  return pw;
1280
error:
1281
  FN(PW,free)(pw);
1282
  return NULL;
1283
}
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 (1
n == 0 && 1
!isl_space_get_tuple_name(pw->dim, type)1
)
1259
0
    return pw;
1260
1
1261
1
  
set_type = type == isl_dim_in ? 1
isl_dim_set1
:
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->n2
;
++i1
)
{1
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].1
FIELD1
=
FN1
(EL,drop_dims)(pw->p[i].
FIELD1
, type, first, n);
1275
1
    if (
!pw->p[i].1
FIELD1
)
1276
0
      goto error;
1277
1
  }
1278
1
1279
1
  return pw;
1280
0
error:
1281
0
  FN(PW,free)(pw);
1282
0
  return NULL;
1283
1
}
Unexecuted instantiation: isl_pw_aff_project_out
Unexecuted instantiation: isl_pw_qpolynomial_project_out
isl_pw_multi_aff_project_out
Line
Count
Source
1252
31
{
1253
31
  int i;
1254
31
  enum isl_dim_type set_type;
1255
31
1256
31
  if (!pw)
1257
0
    return NULL;
1258
31
  
if (31
n == 0 && 31
!isl_space_get_tuple_name(pw->dim, type)0
)
1259
0
    return pw;
1260
31
1261
31
  
set_type = type == isl_dim_in ? 31
isl_dim_set31
:
type0
;
1262
31
1263
31
  pw = FN(PW,cow)(pw);
1264
31
  if (!pw)
1265
0
    return NULL;
1266
31
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1267
31
  if (!pw->dim)
1268
0
    goto error;
1269
93
  
for (i = 0; 31
i < pw->n93
;
++i62
)
{62
1270
62
    pw->p[i].set = isl_set_project_out(pw->p[i].set,
1271
62
              set_type, first, n);
1272
62
    if (!pw->p[i].set)
1273
0
      goto error;
1274
62
    
pw->p[i].62
FIELD62
=
FN62
(EL,drop_dims)(pw->p[i].
FIELD62
, type, first, n);
1275
62
    if (
!pw->p[i].62
FIELD62
)
1276
0
      goto error;
1277
62
  }
1278
31
1279
31
  return pw;
1280
0
error:
1281
0
  FN(PW,free)(pw);
1282
0
  return NULL;
1283
31
}
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
{
1289
  isl_space *space;
1290
  unsigned n;
1291
1292
  n = FN(PW,dim)(pw, isl_dim_in);
1293
  pw = FN(PW,project_out)(pw, isl_dim_in, 0, n);
1294
  space = FN(PW,get_domain_space)(pw);
1295
  space = isl_space_params(space);
1296
  pw = FN(PW,reset_domain_space)(pw, space);
1297
  return pw;
1298
}
Unexecuted instantiation: isl_pw_qpolynomial_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_multi_aff_project_domain_on_params
Unexecuted instantiation: isl_pw_aff_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
{
1305
  int i;
1306
  enum isl_dim_type set_type;
1307
1308
  if (!pw)
1309
    return NULL;
1310
  if (n == 0 && !isl_space_is_named_or_nested(pw->dim, type))
1311
    return pw;
1312
1313
  set_type = type == isl_dim_in ? isl_dim_set : type;
1314
1315
  pw = FN(PW,cow)(pw);
1316
  if (!pw)
1317
    return NULL;
1318
1319
  pw->dim = isl_space_insert_dims(pw->dim, type, first, n);
1320
  if (!pw->dim)
1321
    goto error;
1322
1323
  for (i = 0; i < pw->n; ++i) {
1324
    pw->p[i].set = isl_set_insert_dims(pw->p[i].set,
1325
                  set_type, first, n);
1326
    if (!pw->p[i].set)
1327
      goto error;
1328
    pw->p[i].FIELD = FN(EL,insert_dims)(pw->p[i].FIELD,
1329
                type, first, n);
1330
    if (!pw->p[i].FIELD)
1331
      goto error;
1332
  }
1333
1334
  return pw;
1335
error:
1336
  FN(PW,free)(pw);
1337
  return NULL;
1338
}
isl_pw_aff_insert_dims
Line
Count
Source
1304
3.10k
{
1305
3.10k
  int i;
1306
3.10k
  enum isl_dim_type set_type;
1307
3.10k
1308
3.10k
  if (!pw)
1309
0
    return NULL;
1310
3.10k
  
if (3.10k
n == 0 && 3.10k
!isl_space_is_named_or_nested(pw->dim, type)0
)
1311
0
    return pw;
1312
3.10k
1313
3.10k
  
set_type = type == isl_dim_in ? 3.10k
isl_dim_set3.10k
:
type0
;
1314
3.10k
1315
3.10k
  pw = FN(PW,cow)(pw);
1316
3.10k
  if (!pw)
1317
0
    return NULL;
1318
3.10k
1319
3.10k
  pw->dim = isl_space_insert_dims(pw->dim, type, first, n);
1320
3.10k
  if (!pw->dim)
1321
0
    goto error;
1322
3.10k
1323
6.20k
  
for (i = 0; 3.10k
i < pw->n6.20k
;
++i3.10k
)
{3.10k
1324
3.10k
    pw->p[i].set = isl_set_insert_dims(pw->p[i].set,
1325
3.10k
                  set_type, first, n);
1326
3.10k
    if (!pw->p[i].set)
1327
0
      goto error;
1328
3.10k
    
pw->p[i].3.10k
FIELD3.10k
=
FN3.10k
(EL,insert_dims)(pw->p[i].
FIELD3.10k
,
1329
3.10k
                type, first, n);
1330
3.10k
    if (
!pw->p[i].3.10k
FIELD3.10k
)
1331
0
      goto error;
1332
3.10k
  }
1333
3.10k
1334
3.10k
  return pw;
1335
0
error:
1336
0
  FN(PW,free)(pw);
1337
0
  return NULL;
1338
3.10k
}
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
{
1344
  int i;
1345
1346
  if (!pw)
1347
    return NULL;
1348
1349
  if (type == isl_dim_in)
1350
    type = isl_dim_set;
1351
1352
  pw = FN(PW,cow)(pw);
1353
  if (!pw)
1354
    return NULL;
1355
  for (i = 0; i < pw->n; ++i) {
1356
    pw->p[i].set = isl_set_fix(pw->p[i].set, type, pos, v);
1357
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
1358
      return FN(PW,free)(pw);
1359
  }
1360
1361
  return pw;
1362
}
Unexecuted instantiation: isl_pw_multi_aff_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 (1
type == isl_dim_in1
)
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->n2
;
++i1
)
{1
1356
1
    pw->p[i].set = isl_set_fix(pw->p[i].set, type, pos, v);
1357
1
    if (
FN1
(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 01
)
1358
0
      
return 0
FN0
(PW,free)(pw);
1359
1
  }
1360
1
1361
1
  return pw;
1362
1
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_fix_dim
Unexecuted instantiation: isl_pw_aff_fix_dim
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
{
1370
  if (!v)
1371
    return FN(PW,free)(pw);
1372
  if (!isl_val_is_int(v))
1373
    isl_die(FN(PW,get_ctx)(pw), isl_error_invalid,
1374
      "expecting integer value", goto error);
1375
1376
  pw = FN(PW,fix_dim)(pw, type, pos, v->n);
1377
  isl_val_free(v);
1378
1379
  return pw;
1380
error:
1381
  isl_val_free(v);
1382
  return FN(PW,free)(pw);
1383
}
Unexecuted instantiation: isl_pw_aff_fix_val
isl_pw_qpolynomial_fix_val
Line
Count
Source
1369
1
{
1370
1
  if (!v)
1371
0
    
return 0
FN0
(PW,free)(pw);
1372
1
  
if (1
!isl_val_is_int(v)1
)
1373
0
    isl_die(FN(PW,get_ctx)(pw), isl_error_invalid,
1374
1
      "expecting integer value", goto error);
1375
1
1376
1
  
pw = 1
FN1
(PW,fix_dim)(pw, type, pos, v->n);
1377
1
  isl_val_free(v);
1378
1
1379
1
  return pw;
1380
0
error:
1381
0
  isl_val_free(v);
1382
0
  return FN(PW,free)(pw);
1383
1
}
Unexecuted instantiation: isl_pw_multi_aff_fix_val
Unexecuted instantiation: isl_pw_qpolynomial_fold_fix_val
1384
1385
unsigned FN(PW,dim)(__isl_keep PW *pw, enum isl_dim_type type)
1386
{
1387
  return pw ? isl_space_dim(pw->dim, type) : 0;
1388
}
isl_pw_aff_dim
Line
Count
Source
1386
3.10k
{
1387
3.10k
  return pw ? 
isl_space_dim(pw->dim, type)3.10k
:
00
;
1388
3.10k
}
isl_pw_multi_aff_dim
Line
Count
Source
1386
14.0k
{
1387
14.0k
  return pw ? 
isl_space_dim(pw->dim, type)14.0k
:
00
;
1388
14.0k
}
isl_pw_qpolynomial_fold_dim
Line
Count
Source
1386
3
{
1387
3
  return pw ? 
isl_space_dim(pw->dim, type)3
:
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
{
1393
  int i;
1394
1395
  if (!pw)
1396
    return NULL;
1397
  if (n == 0)
1398
    return pw;
1399
1400
  if (type == isl_dim_in)
1401
    type = isl_dim_set;
1402
1403
  pw = FN(PW,cow)(pw);
1404
  if (!pw)
1405
    return NULL;
1406
  if (!pw->dim)
1407
    goto error;
1408
  for (i = 0; i < pw->n; ++i) {
1409
    pw->p[i].set = isl_set_split_dims(pw->p[i].set, type, first, n);
1410
    if (!pw->p[i].set)
1411
      goto error;
1412
  }
1413
1414
  return pw;
1415
error:
1416
  FN(PW,free)(pw);
1417
  return NULL;
1418
}
Unexecuted instantiation: isl_pw_aff_split_dims
Unexecuted instantiation: isl_pw_qpolynomial_split_dims
Unexecuted instantiation: isl_pw_multi_aff_split_dims
Unexecuted instantiation: isl_pw_qpolynomial_fold_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
{
1428
  int i;
1429
  isl_val *opt;
1430
1431
  if (!pw)
1432
    return NULL;
1433
1434
  if (pw->n == 0) {
1435
    opt = isl_val_zero(FN(PW,get_ctx)(pw));
1436
    FN(PW,free)(pw);
1437
    return opt;
1438
  }
1439
1440
  opt = FN(EL,opt_on_domain)(FN(EL,copy)(pw->p[0].FIELD),
1441
          isl_set_copy(pw->p[0].set), max);
1442
  for (i = 1; i < pw->n; ++i) {
1443
    isl_val *opt_i;
1444
    opt_i = FN(EL,opt_on_domain)(FN(EL,copy)(pw->p[i].FIELD),
1445
            isl_set_copy(pw->p[i].set), max);
1446
    if (max)
1447
      opt = isl_val_max(opt, opt_i);
1448
    else
1449
      opt = isl_val_min(opt, opt_i);
1450
  }
1451
1452
  FN(PW,free)(pw);
1453
  return opt;
1454
}
Unexecuted instantiation: isl_pw_qpolynomial_opt
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 (7
pw->n == 07
)
{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 = 7
FN7
(EL,opt_on_domain)(
FN7
(EL,copy)(pw->p[0].
FIELD7
),
1441
7
          isl_set_copy(pw->p[0].set), max);
1442
7
  for (i = 1; 
i < pw->n7
;
++i0
)
{0
1443
0
    isl_val *opt_i;
1444
0
    opt_i = 
FN0
(EL,opt_on_domain)(
FN0
(EL,copy)(pw->p[i].
FIELD0
),
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
}
1455
1456
__isl_give isl_val *FN(PW,max)(__isl_take PW *pw)
1457
{
1458
  return FN(PW,opt)(pw, 1);
1459
}
Unexecuted instantiation: isl_pw_qpolynomial_max
isl_pw_qpolynomial_fold_max
Line
Count
Source
1457
2
{
1458
2
  return FN(PW,opt)(pw, 1);
1459
2
}
1460
1461
__isl_give isl_val *FN(PW,min)(__isl_take PW *pw)
1462
{
1463
  return FN(PW,opt)(pw, 0);
1464
}
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
{
1469
  return pw ? isl_space_copy(pw->dim) : NULL;
1470
}
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_aff_get_space
Line
Count
Source
1468
91.3k
{
1469
91.3k
  return pw ? isl_space_copy(pw->dim) : NULL;
1470
91.3k
}
isl_pw_multi_aff_get_space
Line
Count
Source
1468
38.7k
{
1469
38.7k
  return pw ? isl_space_copy(pw->dim) : NULL;
1470
38.7k
}
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
{
1474
  return pw ? isl_space_domain(isl_space_copy(pw->dim)) : NULL;
1475
}
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
}
isl_pw_multi_aff_get_domain_space
Line
Count
Source
1473
119
{
1474
119
  return pw ? isl_space_domain(isl_space_copy(pw->dim)) : NULL;
1475
119
}
isl_pw_aff_get_domain_space
Line
Count
Source
1473
93.3k
{
1474
93.3k
  return pw ? isl_space_domain(isl_space_copy(pw->dim)) : NULL;
1475
93.3k
}
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
{
1484
  if (!pw)
1485
    return -1;
1486
  return isl_space_find_dim_by_name(pw->dim, type, name);
1487
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_find_dim_by_name
Unexecuted instantiation: isl_pw_multi_aff_find_dim_by_name
Unexecuted instantiation: isl_pw_qpolynomial_find_dim_by_name
Unexecuted instantiation: isl_pw_aff_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
{
1497
  int i;
1498
1499
  pw = FN(PW,cow)(pw);
1500
  if (!pw || !space || !domain)
1501
    goto error;
1502
1503
  for (i = 0; i < pw->n; ++i) {
1504
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1505
             isl_space_copy(domain));
1506
    if (!pw->p[i].set)
1507
      goto error;
1508
    pw->p[i].FIELD = FN(EL,reset_space_and_domain)(pw->p[i].FIELD,
1509
            isl_space_copy(space), isl_space_copy(domain));
1510
    if (!pw->p[i].FIELD)
1511
      goto error;
1512
  }
1513
1514
  isl_space_free(domain);
1515
1516
  isl_space_free(pw->dim);
1517
  pw->dim = space;
1518
1519
  return pw;
1520
error:
1521
  isl_space_free(domain);
1522
  isl_space_free(space);
1523
  FN(PW,free)(pw);
1524
  return NULL;
1525
}
isl_aff.c:isl_pw_aff_reset_space_and_domain
Line
Count
Source
1496
36.4k
{
1497
36.4k
  int i;
1498
36.4k
1499
36.4k
  pw = FN(PW,cow)(pw);
1500
36.4k
  if (
!pw || 36.4k
!space36.4k
||
!domain36.4k
)
1501
0
    goto error;
1502
36.4k
1503
73.4k
  
for (i = 0; 36.4k
i < pw->n73.4k
;
++i36.9k
)
{36.9k
1504
36.9k
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1505
36.9k
             isl_space_copy(domain));
1506
36.9k
    if (!pw->p[i].set)
1507
0
      goto error;
1508
36.9k
    
pw->p[i].36.9k
FIELD36.9k
=
FN36.9k
(EL,reset_space_and_domain)(pw->p[i].
FIELD36.9k
,
1509
36.9k
            isl_space_copy(space), isl_space_copy(domain));
1510
36.9k
    if (
!pw->p[i].36.9k
FIELD36.9k
)
1511
0
      goto error;
1512
36.9k
  }
1513
36.4k
1514
36.4k
  isl_space_free(domain);
1515
36.4k
1516
36.4k
  isl_space_free(pw->dim);
1517
36.4k
  pw->dim = space;
1518
36.4k
1519
36.4k
  return pw;
1520
0
error:
1521
0
  isl_space_free(domain);
1522
0
  isl_space_free(space);
1523
0
  FN(PW,free)(pw);
1524
0
  return NULL;
1525
36.4k
}
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_reset_space_and_domain
isl_aff.c:isl_pw_multi_aff_reset_space_and_domain
Line
Count
Source
1496
1.44k
{
1497
1.44k
  int i;
1498
1.44k
1499
1.44k
  pw = FN(PW,cow)(pw);
1500
1.44k
  if (
!pw || 1.44k
!space1.44k
||
!domain1.44k
)
1501
0
    goto error;
1502
1.44k
1503
2.92k
  
for (i = 0; 1.44k
i < pw->n2.92k
;
++i1.48k
)
{1.48k
1504
1.48k
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1505
1.48k
             isl_space_copy(domain));
1506
1.48k
    if (!pw->p[i].set)
1507
0
      goto error;
1508
1.48k
    
pw->p[i].1.48k
FIELD1.48k
=
FN1.48k
(EL,reset_space_and_domain)(pw->p[i].
FIELD1.48k
,
1509
1.48k
            isl_space_copy(space), isl_space_copy(domain));
1510
1.48k
    if (
!pw->p[i].1.48k
FIELD1.48k
)
1511
0
      goto error;
1512
1.48k
  }
1513
1.44k
1514
1.44k
  isl_space_free(domain);
1515
1.44k
1516
1.44k
  isl_space_free(pw->dim);
1517
1.44k
  pw->dim = space;
1518
1.44k
1519
1.44k
  return pw;
1520
0
error:
1521
0
  isl_space_free(domain);
1522
0
  isl_space_free(space);
1523
0
  FN(PW,free)(pw);
1524
0
  return NULL;
1525
1.44k
}
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 || 4
!space4
||
!domain4
)
1501
0
    goto error;
1502
4
1503
7
  
for (i = 0; 4
i < pw->n7
;
++i3
)
{3
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].3
FIELD3
=
FN3
(EL,reset_space_and_domain)(pw->p[i].
FIELD3
,
1509
3
            isl_space_copy(space), isl_space_copy(domain));
1510
3
    if (
!pw->p[i].3
FIELD3
)
1511
0
      goto error;
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
0
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
}
1526
1527
__isl_give PW *FN(PW,reset_domain_space)(__isl_take PW *pw,
1528
  __isl_take isl_space *domain)
1529
{
1530
  isl_space *space;
1531
1532
  space = isl_space_extend_domain_with_range(isl_space_copy(domain),
1533
               FN(PW,get_space)(pw));
1534
  return FN(PW,reset_space_and_domain)(pw, space, domain);
1535
}
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_multi_aff_reset_domain_space
isl_pw_aff_reset_domain_space
Line
Count
Source
1529
28.9k
{
1530
28.9k
  isl_space *space;
1531
28.9k
1532
28.9k
  space = isl_space_extend_domain_with_range(isl_space_copy(domain),
1533
28.9k
               FN(PW,get_space)(pw));
1534
28.9k
  return FN(PW,reset_space_and_domain)(pw, space, domain);
1535
28.9k
}
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
{
1539
  isl_space *domain;
1540
1541
  domain = isl_space_domain(isl_space_copy(dim));
1542
  return FN(PW,reset_space_and_domain)(pw, dim, domain);
1543
}
isl_pw_aff_reset_space
Line
Count
Source
1538
7.52k
{
1539
7.52k
  isl_space *domain;
1540
7.52k
1541
7.52k
  domain = isl_space_domain(isl_space_copy(dim));
1542
7.52k
  return FN(PW,reset_space_and_domain)(pw, dim, domain);
1543
7.52k
}
Unexecuted instantiation: isl_pw_qpolynomial_reset_space
isl_pw_multi_aff_reset_space
Line
Count
Source
1538
1.44k
{
1539
1.44k
  isl_space *domain;
1540
1.44k
1541
1.44k
  domain = isl_space_domain(isl_space_copy(dim));
1542
1.44k
  return FN(PW,reset_space_and_domain)(pw, dim, domain);
1543
1.44k
}
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
}
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
{
1548
  isl_space *space;
1549
1550
  pw = FN(PW,cow)(pw);
1551
  if (!pw)
1552
    goto error;
1553
1554
  space = FN(PW,get_space)(pw);
1555
  space = isl_space_set_tuple_id(space, type, id);
1556
1557
  return FN(PW,reset_space)(pw, space);
1558
error:
1559
  isl_id_free(id);
1560
  return FN(PW,free)(pw);
1561
}
isl_pw_aff_set_tuple_id
Line
Count
Source
1547
493
{
1548
493
  isl_space *space;
1549
493
1550
493
  pw = FN(PW,cow)(pw);
1551
493
  if (!pw)
1552
0
    goto error;
1553
493
1554
493
  
space = 493
FN493
(PW,get_space)(pw);
1555
493
  space = isl_space_set_tuple_id(space, type, id);
1556
493
1557
493
  return FN(PW,reset_space)(pw, space);
1558
0
error:
1559
0
  isl_id_free(id);
1560
0
  return FN(PW,free)(pw);
1561
493
}
Unexecuted instantiation: isl_pw_qpolynomial_set_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_set_tuple_id
Unexecuted instantiation: isl_pw_multi_aff_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
{
1567
  isl_space *space;
1568
1569
  if (!pw)
1570
    return NULL;
1571
  if (!FN(PW,has_tuple_id)(pw, type))
1572
    return pw;
1573
1574
  pw = FN(PW,cow)(pw);
1575
  if (!pw)
1576
    return NULL;
1577
1578
  space = FN(PW,get_space)(pw);
1579
  space = isl_space_reset_tuple_id(space, type);
1580
1581
  return FN(PW,reset_space)(pw, space);
1582
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_reset_tuple_id
Unexecuted instantiation: isl_pw_multi_aff_reset_tuple_id
Unexecuted instantiation: isl_pw_aff_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
{
1587
  pw = FN(PW,cow)(pw);
1588
  if (!pw)
1589
    goto error;
1590
  pw->dim = isl_space_set_dim_id(pw->dim, type, pos, id);
1591
  return FN(PW,reset_space)(pw, isl_space_copy(pw->dim));
1592
error:
1593
  isl_id_free(id);
1594
  return FN(PW,free)(pw);
1595
}
Unexecuted instantiation: isl_pw_aff_set_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_set_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_set_dim_id
Unexecuted instantiation: isl_pw_multi_aff_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
{
1603
  isl_space *space;
1604
1605
  space = FN(PW,get_space)(pw);
1606
  space = isl_space_reset_user(space);
1607
1608
  return FN(PW,reset_space)(pw, space);
1609
}
Unexecuted instantiation: isl_pw_multi_aff_reset_user
Unexecuted instantiation: isl_pw_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
{
1613
  if (!pw1 || !pw2)
1614
    return isl_bool_error;
1615
1616
  return isl_space_is_equal(pw1->dim, pw2->dim);
1617
}
Unexecuted instantiation: isl_pw_multi_aff_has_equal_space
Unexecuted instantiation: isl_pw_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 || 4
!pw24
)
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
{
1623
  int i;
1624
  isl_ctx *ctx;
1625
1626
  if (!pw || !morph)
1627
    goto error;
1628
1629
  ctx = isl_space_get_ctx(pw->dim);
1630
  isl_assert(ctx, isl_space_is_domain_internal(morph->dom->dim, pw->dim),
1631
    goto error);
1632
1633
  pw = FN(PW,cow)(pw);
1634
  if (!pw)
1635
    goto error;
1636
  pw->dim = isl_space_extend_domain_with_range(
1637
      isl_space_copy(morph->ran->dim), pw->dim);
1638
  if (!pw->dim)
1639
    goto error;
1640
1641
  for (i = 0; i < pw->n; ++i) {
1642
    pw->p[i].set = isl_morph_set(isl_morph_copy(morph), pw->p[i].set);
1643
    if (!pw->p[i].set)
1644
      goto error;
1645
    pw->p[i].FIELD = FN(EL,morph_domain)(pw->p[i].FIELD,
1646
            isl_morph_copy(morph));
1647
    if (!pw->p[i].FIELD)
1648
      goto error;
1649
  }
1650
1651
  isl_morph_free(morph);
1652
1653
  return pw;
1654
error:
1655
  FN(PW,free)(pw);
1656
  isl_morph_free(morph);
1657
  return NULL;
1658
}
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 || 2
!morph2
)
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 = 2
FN2
(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->n3
;
++i1
)
{1
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].1
FIELD1
=
FN1
(EL,morph_domain)(pw->p[i].
FIELD1
,
1646
1
            isl_morph_copy(morph));
1647
1
    if (
!pw->p[i].1
FIELD1
)
1648
0
      goto error;
1649
1
  }
1650
2
1651
2
  isl_morph_free(morph);
1652
2
1653
2
  return pw;
1654
0
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
{
1663
  return pw ? pw->n : 0;
1664
}
Unexecuted instantiation: isl_pw_qpolynomial_n_piece
isl_pw_aff_n_piece
Line
Count
Source
1662
6.67k
{
1663
6.67k
  return pw ? 
pw->n6.67k
:
00
;
1664
6.67k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_n_piece
Unexecuted instantiation: isl_pw_multi_aff_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
{
1670
  int i;
1671
1672
  if (!pw)
1673
    return isl_stat_error;
1674
1675
  for (i = 0; i < pw->n; ++i)
1676
    if (fn(isl_set_copy(pw->p[i].set),
1677
        FN(EL,copy)(pw->p[i].FIELD), user) < 0)
1678
      return isl_stat_error;
1679
1680
  return isl_stat_ok;
1681
}
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->n3
;
++i2
)
1676
2
    
if (2
fn(isl_set_copy(pw->p[i].set),2
1677
2
        
FN2
(EL,copy)(pw->p[i].
FIELD2
), user) < 0)
1678
0
      return isl_stat_error;
1679
1
1680
1
  return isl_stat_ok;
1681
1
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_foreach_piece
isl_pw_aff_foreach_piece
Line
Count
Source
1669
7.74k
{
1670
7.74k
  int i;
1671
7.74k
1672
7.74k
  if (!pw)
1673
0
    return isl_stat_error;
1674
7.74k
1675
13.6k
  
for (i = 0; 7.74k
i < pw->n13.6k
;
++i5.93k
)
1676
8.00k
    
if (8.00k
fn(isl_set_copy(pw->p[i].set),8.00k
1677
8.00k
        
FN8.00k
(EL,copy)(pw->p[i].
FIELD8.00k
), user) < 0)
1678
2.06k
      return isl_stat_error;
1679
7.74k
1680
5.67k
  return isl_stat_ok;
1681
7.74k
}
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->n4
;
++i2
)
1676
2
    
if (2
fn(isl_set_copy(pw->p[i].set),2
1677
2
        
FN2
(EL,copy)(pw->p[i].
FIELD2
), user) < 0)
1678
0
      return isl_stat_error;
1679
2
1680
2
  return isl_stat_ok;
1681
2
}
1682
1683
#ifndef NO_LIFT
1684
static isl_bool any_divs(__isl_keep isl_set *set)
1685
{
1686
  int i;
1687
1688
  if (!set)
1689
    return isl_bool_error;
1690
1691
  for (i = 0; i < set->n; ++i)
1692
    if (set->p[i]->n_div > 0)
1693
      return isl_bool_true;
1694
1695
  return isl_bool_false;
1696
}
Unexecuted instantiation: isl_polynomial.c:any_divs
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->n3
;
++i1
)
1692
2
    
if (2
set->p[i]->n_div > 02
)
1693
1
      return isl_bool_true;
1694
2
1695
1
  return isl_bool_false;
1696
2
}
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
{
1703
  int i;
1704
1705
  if (!set || !el)
1706
    goto error;
1707
1708
  for (i = 0; i < set->n; ++i) {
1709
    isl_set *lift;
1710
    EL *copy;
1711
1712
    lift = isl_set_from_basic_set(isl_basic_set_copy(set->p[i]));
1713
    lift = isl_set_lift(lift);
1714
1715
    copy = FN(EL,copy)(el);
1716
    copy = FN(EL,lift)(copy, isl_set_get_space(lift));
1717
1718
    if (fn(lift, copy, user) < 0)
1719
      goto error;
1720
  }
1721
1722
  isl_set_free(set);
1723
  FN(EL,free)(el);
1724
1725
  return isl_stat_ok;
1726
error:
1727
  isl_set_free(set);
1728
  FN(EL,free)(el);
1729
  return isl_stat_error;
1730
}
Unexecuted instantiation: isl_polynomial.c:foreach_lifted_subset
isl_fold.c:foreach_lifted_subset
Line
Count
Source
1702
1
{
1703
1
  int i;
1704
1
1705
1
  if (
!set || 1
!el1
)
1706
0
    goto error;
1707
1
1708
2
  
for (i = 0; 1
i < set->n2
;
++i1
)
{1
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
0
error:
1727
0
  isl_set_free(set);
1728
0
  FN(EL,free)(el);
1729
0
  return isl_stat_error;
1730
1
}
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
{
1736
  int i;
1737
1738
  if (!pw)
1739
    return isl_stat_error;
1740
1741
  for (i = 0; i < pw->n; ++i) {
1742
    isl_bool any;
1743
    isl_set *set;
1744
    EL *el;
1745
1746
    any = any_divs(pw->p[i].set);
1747
    if (any < 0)
1748
      return isl_stat_error;
1749
    set = isl_set_copy(pw->p[i].set);
1750
    el = FN(EL,copy)(pw->p[i].FIELD);
1751
    if (!any) {
1752
      if (fn(set, el, user) < 0)
1753
        return isl_stat_error;
1754
      continue;
1755
    }
1756
    if (foreach_lifted_subset(set, el, fn, user) < 0)
1757
      return isl_stat_error;
1758
  }
1759
1760
  return isl_stat_ok;
1761
}
isl_pw_qpolynomial_fold_foreach_lifted_piece
Line
Count
Source