Coverage Report

Created: 2017-06-28 17:40

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/polly/lib/External/isl/isl_map_lexopt_templ.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2010      INRIA Saclay
3
 * Copyright 2012      Ecole Normale Superieure
4
 *
5
 * Use of this software is governed by the MIT license
6
 *
7
 * Written by Sven Verdoolaege,
8
 * INRIA Saclay - Ile-de-France, Parc Club Orsay Universite,
9
 * ZAC des vignes, 4 rue Jacques Monod, 91893 Orsay, France
10
 * and Ecole Normale Superieure, 45 rue d’Ulm, 75230 Paris, France
11
 */
12
13
/* Function for computing the lexicographic optimum of a map
14
 * in the form of either an isl_map or an isl_pw_multi_aff.
15
 */
16
17
24.8k
#define xSF(TYPE,SUFFIX) TYPE ## SUFFIX
18
24.8k
#define SF(TYPE,SUFFIX) xSF(TYPE,SUFFIX)
19
20
/* Compute the lexicographic minimum (or maximum if "flags" includes
21
 * ISL_OPT_MAX) of "bmap" over the domain "dom" and return the result.
22
 * If "empty" is not NULL, then *empty is assigned a set that
23
 * contains those parts of the domain where there is no solution.
24
 * If "flags" includes ISL_OPT_FULL, then "dom" is NULL and the optimum
25
 * should be computed over the domain of "bmap".  "empty" is also NULL
26
 * in this case.
27
 * If "bmap" is marked as rational (ISL_BASIC_MAP_RATIONAL),
28
 * then the rational optimum is computed.  Otherwise, the integral optimum
29
 * is computed.
30
 */
31
static __isl_give TYPE *SF(isl_basic_map_partial_lexopt,SUFFIX)(
32
  __isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
33
  __isl_give isl_set **empty, unsigned flags)
34
5.46k
{
35
5.46k
  return SF(isl_tab_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty,
36
5.46k
                  flags);
37
5.46k
}
isl_map.c:isl_basic_map_partial_lexopt_pw_multi_aff
Line
Count
Source
34
2.87k
{
35
2.87k
  return SF(isl_tab_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty,
36
2.87k
                  flags);
37
2.87k
}
isl_map.c:isl_basic_map_partial_lexopt
Line
Count
Source
34
2.58k
{
35
2.58k
  return SF(isl_tab_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty,
36
2.58k
                  flags);
37
2.58k
}
38
39
__isl_give TYPE *SF(isl_basic_map_partial_lexmax,SUFFIX)(
40
  __isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
41
  __isl_give isl_set **empty)
42
0
{
43
0
  unsigned flags = ISL_OPT_MAX;
44
0
  return SF(isl_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty, flags);
45
0
}
Unexecuted instantiation: isl_basic_map_partial_lexmax_pw_multi_aff
Unexecuted instantiation: isl_basic_map_partial_lexmax
46
47
__isl_give TYPE *SF(isl_basic_map_partial_lexmin,SUFFIX)(
48
  __isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
49
  __isl_give isl_set **empty)
50
1
{
51
1
  unsigned flags = 0;
52
1
  return SF(isl_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty, flags);
53
1
}
Unexecuted instantiation: isl_basic_map_partial_lexmin_pw_multi_aff
isl_basic_map_partial_lexmin
Line
Count
Source
50
1
{
51
1
  unsigned flags = 0;
52
1
  return SF(isl_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty, flags);
53
1
}
54
55
__isl_give TYPE *SF(isl_basic_set_partial_lexmin,SUFFIX)(
56
  __isl_take isl_basic_set *bset, __isl_take isl_basic_set *dom,
57
  __isl_give isl_set **empty)
58
0
{
59
0
  return SF(isl_basic_map_partial_lexmin,SUFFIX)(bset, dom, empty);
60
0
}
Unexecuted instantiation: isl_basic_set_partial_lexmin_pw_multi_aff
Unexecuted instantiation: isl_basic_set_partial_lexmin
61
62
__isl_give TYPE *SF(isl_basic_set_partial_lexmax,SUFFIX)(
63
  __isl_take isl_basic_set *bset, __isl_take isl_basic_set *dom,
64
  __isl_give isl_set **empty)
65
0
{
66
0
  return SF(isl_basic_map_partial_lexmax,SUFFIX)(bset, dom, empty);
67
0
}
Unexecuted instantiation: isl_basic_set_partial_lexmax_pw_multi_aff
Unexecuted instantiation: isl_basic_set_partial_lexmax
68
69
/* Given a basic map "bmap", compute the lexicographically minimal
70
 * (or maximal) image element for each domain element in dom.
71
 * If empty is not NULL, then set *empty to those elements in dom
72
 * that do not have an image element.
73
 * If "flags" includes ISL_OPT_FULL, then "dom" is NULL and the optimum
74
 * should be computed over the domain of "bmap".  "empty" is also NULL
75
 * in this case.
76
 *
77
 * We first make sure the basic sets in dom are disjoint and then
78
 * simply collect the results over each of the basic sets separately.
79
 * We could probably improve the efficiency a bit by moving the union
80
 * domain down into the parametric integer programming.
81
 *
82
 * If a full optimum is being computed (i.e., "flags" includes ISL_OPT_FULL),
83
 * then no domain is given and there is then also no need to consider
84
 * the disjuncts of the domain.
85
 */
86
static __isl_give TYPE *SF(basic_map_partial_lexopt,SUFFIX)(
87
  __isl_take isl_basic_map *bmap, __isl_take isl_set *dom,
88
  __isl_give isl_set **empty, unsigned flags)
89
6.52k
{
90
6.52k
  int i;
91
6.52k
  TYPE *res;
92
6.52k
  isl_set *all_empty;
93
6.52k
94
6.52k
  if (ISL_FL_ISSET(flags, ISL_OPT_FULL))
95
2.13k
    
return 2.13k
SF2.13k
(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL,
96
2.13k
                empty, flags);
97
6.52k
98
4.38k
  dom = isl_set_make_disjoint(dom);
99
4.38k
  if (!dom)
100
0
    goto error;
101
4.38k
102
4.38k
  
if (4.38k
isl_set_plain_is_empty(dom)4.38k
)
{2.16k
103
2.16k
    isl_space *space = isl_basic_map_get_space(bmap);
104
2.16k
    if (empty)
105
2.16k
      *empty = dom;
106
2.16k
    else
107
0
      isl_set_free(dom);
108
2.16k
    isl_basic_map_free(bmap);
109
2.16k
    return EMPTY(space);
110
2.16k
  }
111
4.38k
112
2.21k
  
res = 2.21k
SF2.21k
(isl_basic_map_partial_lexopt,SUFFIX)(isl_basic_map_copy(bmap),
113
2.21k
      isl_basic_set_copy(dom->p[0]), empty, flags);
114
2.21k
115
2.21k
  if (empty)
116
2.21k
    all_empty = *empty;
117
3.11k
  for (i = 1; 
i < dom->n3.11k
;
++i894
)
{894
118
894
    TYPE *res_i;
119
894
120
894
    res_i = SF(isl_basic_map_partial_lexopt,SUFFIX)(
121
894
        isl_basic_map_copy(bmap),
122
894
        isl_basic_set_copy(dom->p[i]), empty, flags);
123
894
124
894
    res = ADD(res, res_i);
125
894
    if (empty)
126
894
      all_empty = isl_set_union_disjoint(all_empty, *empty);
127
894
  }
128
2.21k
129
2.21k
  if (empty)
130
2.21k
    *empty = all_empty;
131
2.21k
  isl_set_free(dom);
132
2.21k
  isl_basic_map_free(bmap);
133
2.21k
  return res;
134
0
error:
135
0
  if (empty)
136
0
    *empty = NULL;
137
0
  isl_set_free(dom);
138
0
  isl_basic_map_free(bmap);
139
0
  return NULL;
140
4.38k
}
isl_map.c:basic_map_partial_lexopt_pw_multi_aff
Line
Count
Source
89
2.30k
{
90
2.30k
  int i;
91
2.30k
  TYPE *res;
92
2.30k
  isl_set *all_empty;
93
2.30k
94
2.30k
  if (ISL_FL_ISSET(flags, ISL_OPT_FULL))
95
1.74k
    
return 1.74k
SF1.74k
(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL,
96
1.74k
                empty, flags);
97
2.30k
98
556
  dom = isl_set_make_disjoint(dom);
99
556
  if (!dom)
100
0
    goto error;
101
556
102
556
  
if (556
isl_set_plain_is_empty(dom)556
)
{278
103
278
    isl_space *space = isl_basic_map_get_space(bmap);
104
278
    if (empty)
105
278
      *empty = dom;
106
278
    else
107
0
      isl_set_free(dom);
108
278
    isl_basic_map_free(bmap);
109
278
    return EMPTY(space);
110
278
  }
111
556
112
278
  
res = 278
SF278
(isl_basic_map_partial_lexopt,SUFFIX)(isl_basic_map_copy(bmap),
113
278
      isl_basic_set_copy(dom->p[0]), empty, flags);
114
278
115
278
  if (empty)
116
278
    all_empty = *empty;
117
1.06k
  for (i = 1; 
i < dom->n1.06k
;
++i790
)
{790
118
790
    TYPE *res_i;
119
790
120
790
    res_i = SF(isl_basic_map_partial_lexopt,SUFFIX)(
121
790
        isl_basic_map_copy(bmap),
122
790
        isl_basic_set_copy(dom->p[i]), empty, flags);
123
790
124
790
    res = ADD(res, res_i);
125
790
    if (empty)
126
790
      all_empty = isl_set_union_disjoint(all_empty, *empty);
127
790
  }
128
278
129
278
  if (empty)
130
278
    *empty = all_empty;
131
278
  isl_set_free(dom);
132
278
  isl_basic_map_free(bmap);
133
278
  return res;
134
0
error:
135
0
  if (empty)
136
0
    *empty = NULL;
137
0
  isl_set_free(dom);
138
0
  isl_basic_map_free(bmap);
139
0
  return NULL;
140
556
}
isl_map.c:basic_map_partial_lexopt
Line
Count
Source
89
4.22k
{
90
4.22k
  int i;
91
4.22k
  TYPE *res;
92
4.22k
  isl_set *all_empty;
93
4.22k
94
4.22k
  if (ISL_FL_ISSET(flags, ISL_OPT_FULL))
95
391
    
return 391
SF391
(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL,
96
391
                empty, flags);
97
4.22k
98
3.83k
  dom = isl_set_make_disjoint(dom);
99
3.83k
  if (!dom)
100
0
    goto error;
101
3.83k
102
3.83k
  
if (3.83k
isl_set_plain_is_empty(dom)3.83k
)
{1.89k
103
1.89k
    isl_space *space = isl_basic_map_get_space(bmap);
104
1.89k
    if (empty)
105
1.89k
      *empty = dom;
106
1.89k
    else
107
0
      isl_set_free(dom);
108
1.89k
    isl_basic_map_free(bmap);
109
1.89k
    return EMPTY(space);
110
1.89k
  }
111
3.83k
112
1.94k
  
res = 1.94k
SF1.94k
(isl_basic_map_partial_lexopt,SUFFIX)(isl_basic_map_copy(bmap),
113
1.94k
      isl_basic_set_copy(dom->p[0]), empty, flags);
114
1.94k
115
1.94k
  if (empty)
116
1.94k
    all_empty = *empty;
117
2.04k
  for (i = 1; 
i < dom->n2.04k
;
++i104
)
{104
118
104
    TYPE *res_i;
119
104
120
104
    res_i = SF(isl_basic_map_partial_lexopt,SUFFIX)(
121
104
        isl_basic_map_copy(bmap),
122
104
        isl_basic_set_copy(dom->p[i]), empty, flags);
123
104
124
104
    res = ADD(res, res_i);
125
104
    if (empty)
126
104
      all_empty = isl_set_union_disjoint(all_empty, *empty);
127
104
  }
128
1.94k
129
1.94k
  if (empty)
130
1.94k
    *empty = all_empty;
131
1.94k
  isl_set_free(dom);
132
1.94k
  isl_basic_map_free(bmap);
133
1.94k
  return res;
134
0
error:
135
0
  if (empty)
136
0
    *empty = NULL;
137
0
  isl_set_free(dom);
138
0
  isl_basic_map_free(bmap);
139
0
  return NULL;
140
3.83k
}
141
142
/* Compute the lexicographic minimum (or maximum if "flags" includes
143
 * ISL_OPT_MAX) of "bmap" over its domain.
144
 */
145
__isl_give TYPE *SF(isl_basic_map_lexopt,SUFFIX)(
146
  __isl_take isl_basic_map *bmap, unsigned flags)
147
210
{
148
210
  ISL_FL_SET(flags, ISL_OPT_FULL);
149
210
  return SF(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL, NULL, flags);
150
210
}
isl_basic_map_lexopt
Line
Count
Source
147
148
{
148
148
  ISL_FL_SET(flags, ISL_OPT_FULL);
149
148
  return SF(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL, NULL, flags);
150
148
}
isl_basic_map_lexopt_pw_multi_aff
Line
Count
Source
147
62
{
148
62
  ISL_FL_SET(flags, ISL_OPT_FULL);
149
62
  return SF(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL, NULL, flags);
150
62
}
151
152
__isl_give TYPE *SF(isl_basic_map_lexmin,SUFFIX)(__isl_take isl_basic_map *bmap)
153
62
{
154
62
  return SF(isl_basic_map_lexopt,SUFFIX)(bmap, 0);
155
62
}
Unexecuted instantiation: isl_basic_map_lexmin
isl_basic_map_lexmin_pw_multi_aff
Line
Count
Source
153
62
{
154
62
  return SF(isl_basic_map_lexopt,SUFFIX)(bmap, 0);
155
62
}
156
157
static __isl_give TYPE *SF(isl_map_partial_lexopt_aligned,SUFFIX)(
158
  __isl_take isl_map *map, __isl_take isl_set *dom,
159
  __isl_give isl_set **empty, unsigned flags);
160
/* This function is currently only used when TYPE is defined as isl_map. */
161
static __isl_give TYPE *SF(isl_map_partial_lexopt,SUFFIX)(
162
  __isl_take isl_map *map, __isl_take isl_set *dom,
163
  __isl_give isl_set **empty, unsigned flags)
164
  __attribute__ ((unused));
165
166
/* Given a map "map", compute the lexicographically minimal
167
 * (or maximal) image element for each domain element in dom.
168
 * Set *empty to those elements in dom that do not have an image element.
169
 *
170
 * Align parameters if needed and then call isl_map_partial_lexopt_aligned.
171
 */
172
static __isl_give TYPE *SF(isl_map_partial_lexopt,SUFFIX)(
173
  __isl_take isl_map *map, __isl_take isl_set *dom,
174
  __isl_give isl_set **empty, unsigned flags)
175
9.90k
{
176
9.90k
  isl_bool aligned;
177
9.90k
178
9.90k
  aligned = isl_map_set_has_equal_params(map, dom);
179
9.90k
  if (aligned < 0)
180
0
    goto error;
181
9.90k
  
if (9.90k
aligned9.90k
)
182
9.90k
    
return 9.90k
SF9.90k
(isl_map_partial_lexopt_aligned,SUFFIX)(map, dom,
183
9.90k
                empty, flags);
184
0
  
if (0
!isl_space_has_named_params(map->dim) ||0
185
0
      !isl_space_has_named_params(dom->dim))
186
0
    isl_die(map->ctx, isl_error_invalid,
187
0
      "unaligned unnamed parameters", goto error);
188
0
  map = isl_map_align_params(map, isl_map_get_space(dom));
189
0
  dom = isl_map_align_params(dom, isl_map_get_space(map));
190
0
  return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, dom, empty,
191
0
              flags);
192
0
error:
193
0
  if (empty)
194
0
    *empty = NULL;
195
0
  isl_set_free(dom);
196
0
  isl_map_free(map);
197
0
  return NULL;
198
0
}
isl_map.c:isl_map_partial_lexopt
Line
Count
Source
175
9.90k
{
176
9.90k
  isl_bool aligned;
177
9.90k
178
9.90k
  aligned = isl_map_set_has_equal_params(map, dom);
179
9.90k
  if (aligned < 0)
180
0
    goto error;
181
9.90k
  
if (9.90k
aligned9.90k
)
182
9.90k
    
return 9.90k
SF9.90k
(isl_map_partial_lexopt_aligned,SUFFIX)(map, dom,
183
9.90k
                empty, flags);
184
0
  
if (0
!isl_space_has_named_params(map->dim) ||0
185
0
      !isl_space_has_named_params(dom->dim))
186
0
    isl_die(map->ctx, isl_error_invalid,
187
0
      "unaligned unnamed parameters", goto error);
188
0
  map = isl_map_align_params(map, isl_map_get_space(dom));
189
0
  dom = isl_map_align_params(dom, isl_map_get_space(map));
190
0
  return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, dom, empty,
191
0
              flags);
192
0
error:
193
0
  if (empty)
194
0
    *empty = NULL;
195
0
  isl_set_free(dom);
196
0
  isl_map_free(map);
197
0
  return NULL;
198
0
}
Unexecuted instantiation: isl_map.c:isl_map_partial_lexopt_pw_multi_aff
199
200
/* Compute the lexicographic minimum (or maximum if "flags" includes
201
 * ISL_OPT_MAX) of "map" over its domain.
202
 */
203
__isl_give TYPE *SF(isl_map_lexopt,SUFFIX)(__isl_take isl_map *map,
204
  unsigned flags)
205
1.45k
{
206
1.45k
  ISL_FL_SET(flags, ISL_OPT_FULL);
207
1.45k
  return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, NULL, NULL,
208
1.45k
              flags);
209
1.45k
}
isl_map_lexopt
Line
Count
Source
205
555
{
206
555
  ISL_FL_SET(flags, ISL_OPT_FULL);
207
555
  return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, NULL, NULL,
208
555
              flags);
209
555
}
isl_map_lexopt_pw_multi_aff
Line
Count
Source
205
903
{
206
903
  ISL_FL_SET(flags, ISL_OPT_FULL);
207
903
  return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, NULL, NULL,
208
903
              flags);
209
903
}
210
211
__isl_give TYPE *SF(isl_map_lexmin,SUFFIX)(__isl_take isl_map *map)
212
895
{
213
895
  return SF(isl_map_lexopt,SUFFIX)(map, 0);
214
895
}
isl_map_lexmin_pw_multi_aff
Line
Count
Source
212
452
{
213
452
  return SF(isl_map_lexopt,SUFFIX)(map, 0);
214
452
}
isl_map_lexmin
Line
Count
Source
212
443
{
213
443
  return SF(isl_map_lexopt,SUFFIX)(map, 0);
214
443
}
215
216
__isl_give TYPE *SF(isl_map_lexmax,SUFFIX)(__isl_take isl_map *map)
217
563
{
218
563
  return 
SF563
(isl_map_lexopt,SUFFIX)(map,
ISL_OPT_MAX563
);
219
563
}
isl_map_lexmax_pw_multi_aff
Line
Count
Source
217
451
{
218
451
  return 
SF451
(isl_map_lexopt,SUFFIX)(map,
ISL_OPT_MAX451
);
219
451
}
isl_map_lexmax
Line
Count
Source
217
112
{
218
112
  return 
SF112
(isl_map_lexopt,SUFFIX)(map,
ISL_OPT_MAX112
);
219
112
}
220
221
__isl_give TYPE *SF(isl_set_lexmin,SUFFIX)(__isl_take isl_set *set)
222
574
{
223
574
  return SF(isl_map_lexmin,SUFFIX)(set);
224
574
}
isl_set_lexmin
Line
Count
Source
222
122
{
223
122
  return SF(isl_map_lexmin,SUFFIX)(set);
224
122
}
isl_set_lexmin_pw_multi_aff
Line
Count
Source
222
452
{
223
452
  return SF(isl_map_lexmin,SUFFIX)(set);
224
452
}
225
226
__isl_give TYPE *SF(isl_set_lexmax,SUFFIX)(__isl_take isl_set *set)
227
452
{
228
452
  return SF(isl_map_lexmax,SUFFIX)(set);
229
452
}
isl_set_lexmax
Line
Count
Source
227
1
{
228
1
  return SF(isl_map_lexmax,SUFFIX)(set);
229
1
}
isl_set_lexmax_pw_multi_aff
Line
Count
Source
227
451
{
228
451
  return SF(isl_map_lexmax,SUFFIX)(set);
229
451
}