Coverage Report

Created: 2017-03-28 09:59

/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
13.6k
#define xSF(TYPE,SUFFIX) TYPE ## SUFFIX
18
13.6k
#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
3.04k
{
35
3.04k
  return SF(isl_tab_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty,
36
3.04k
                  flags);
37
3.04k
}
isl_map.c:isl_basic_map_partial_lexopt_pw_multi_aff
Line
Count
Source
34
1.76k
{
35
1.76k
  return SF(isl_tab_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty,
36
1.76k
                  flags);
37
1.76k
}
isl_map.c:isl_basic_map_partial_lexopt
Line
Count
Source
34
1.27k
{
35
1.27k
  return SF(isl_tab_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty,
36
1.27k
                  flags);
37
1.27k
}
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
3.59k
{
90
3.59k
  int i;
91
3.59k
  TYPE *res;
92
3.59k
  isl_set *all_empty;
93
3.59k
94
3.59k
  if (ISL_FL_ISSET(flags, ISL_OPT_FULL))
95
1.56k
    
return 1.56k
SF1.56k
(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL,
96
1.56k
                empty, flags);
97
3.59k
98
2.02k
  dom = isl_set_make_disjoint(dom);
99
2.02k
  if (!dom)
100
0
    goto error;
101
2.02k
102
2.02k
  
if (2.02k
isl_set_plain_is_empty(dom)2.02k
)
{1.00k
103
1.00k
    isl_space *space = isl_basic_map_get_space(bmap);
104
1.00k
    if (empty)
105
1.00k
      *empty = dom;
106
1.00k
    else
107
0
      isl_set_free(dom);
108
1.00k
    isl_basic_map_free(bmap);
109
1.00k
    return EMPTY(space);
110
1.00k
  }
111
2.02k
112
1.02k
  
res = 1.02k
SF1.02k
(isl_basic_map_partial_lexopt,SUFFIX)(isl_basic_map_copy(bmap),
113
1.02k
      isl_basic_set_copy(dom->p[0]), empty, flags);
114
1.02k
115
1.02k
  if (empty)
116
1.02k
    all_empty = *empty;
117
1.41k
  for (i = 1; 
i < dom->n1.41k
;
++i389
)
{389
118
389
    TYPE *res_i;
119
389
120
389
    res_i = SF(isl_basic_map_partial_lexopt,SUFFIX)(
121
389
        isl_basic_map_copy(bmap),
122
389
        isl_basic_set_copy(dom->p[i]), empty, flags);
123
389
124
389
    res = ADD(res, res_i);
125
389
    if (empty)
126
389
      all_empty = isl_set_union_disjoint(all_empty, *empty);
127
389
  }
128
1.02k
129
1.02k
  if (empty)
130
1.02k
    *empty = all_empty;
131
1.02k
  isl_set_free(dom);
132
1.02k
  isl_basic_map_free(bmap);
133
1.02k
  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
2.02k
}
isl_map.c:basic_map_partial_lexopt_pw_multi_aff
Line
Count
Source
89
1.55k
{
90
1.55k
  int i;
91
1.55k
  TYPE *res;
92
1.55k
  isl_set *all_empty;
93
1.55k
94
1.55k
  if (ISL_FL_ISSET(flags, ISL_OPT_FULL))
95
1.27k
    
return 1.27k
SF1.27k
(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL,
96
1.27k
                empty, flags);
97
1.55k
98
278
  dom = isl_set_make_disjoint(dom);
99
278
  if (!dom)
100
0
    goto error;
101
278
102
278
  
if (278
isl_set_plain_is_empty(dom)278
)
{139
103
139
    isl_space *space = isl_basic_map_get_space(bmap);
104
139
    if (empty)
105
139
      *empty = dom;
106
139
    else
107
0
      isl_set_free(dom);
108
139
    isl_basic_map_free(bmap);
109
139
    return EMPTY(space);
110
139
  }
111
278
112
139
  
res = 139
SF139
(isl_basic_map_partial_lexopt,SUFFIX)(isl_basic_map_copy(bmap),
113
139
      isl_basic_set_copy(dom->p[0]), empty, flags);
114
139
115
139
  if (empty)
116
139
    all_empty = *empty;
117
471
  for (i = 1; 
i < dom->n471
;
++i332
)
{332
118
332
    TYPE *res_i;
119
332
120
332
    res_i = SF(isl_basic_map_partial_lexopt,SUFFIX)(
121
332
        isl_basic_map_copy(bmap),
122
332
        isl_basic_set_copy(dom->p[i]), empty, flags);
123
332
124
332
    res = ADD(res, res_i);
125
332
    if (empty)
126
332
      all_empty = isl_set_union_disjoint(all_empty, *empty);
127
332
  }
128
139
129
139
  if (empty)
130
139
    *empty = all_empty;
131
139
  isl_set_free(dom);
132
139
  isl_basic_map_free(bmap);
133
139
  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
278
}
isl_map.c:basic_map_partial_lexopt
Line
Count
Source
89
2.03k
{
90
2.03k
  int i;
91
2.03k
  TYPE *res;
92
2.03k
  isl_set *all_empty;
93
2.03k
94
2.03k
  if (ISL_FL_ISSET(flags, ISL_OPT_FULL))
95
293
    
return 293
SF293
(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL,
96
293
                empty, flags);
97
2.03k
98
1.74k
  dom = isl_set_make_disjoint(dom);
99
1.74k
  if (!dom)
100
0
    goto error;
101
1.74k
102
1.74k
  
if (1.74k
isl_set_plain_is_empty(dom)1.74k
)
{862
103
862
    isl_space *space = isl_basic_map_get_space(bmap);
104
862
    if (empty)
105
862
      *empty = dom;
106
862
    else
107
0
      isl_set_free(dom);
108
862
    isl_basic_map_free(bmap);
109
862
    return EMPTY(space);
110
862
  }
111
1.74k
112
884
  
res = 884
SF884
(isl_basic_map_partial_lexopt,SUFFIX)(isl_basic_map_copy(bmap),
113
884
      isl_basic_set_copy(dom->p[0]), empty, flags);
114
884
115
884
  if (empty)
116
884
    all_empty = *empty;
117
941
  for (i = 1; 
i < dom->n941
;
++i57
)
{57
118
57
    TYPE *res_i;
119
57
120
57
    res_i = SF(isl_basic_map_partial_lexopt,SUFFIX)(
121
57
        isl_basic_map_copy(bmap),
122
57
        isl_basic_set_copy(dom->p[i]), empty, flags);
123
57
124
57
    res = ADD(res, res_i);
125
57
    if (empty)
126
57
      all_empty = isl_set_union_disjoint(all_empty, *empty);
127
57
  }
128
884
129
884
  if (empty)
130
884
    *empty = all_empty;
131
884
  isl_set_free(dom);
132
884
  isl_basic_map_free(bmap);
133
884
  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
1.74k
}
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
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
}
isl_basic_map_lexopt
Line
Count
Source
147
44
{
148
44
  ISL_FL_SET(flags, ISL_OPT_FULL);
149
44
  return SF(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL, NULL, flags);
150
44
}
isl_basic_map_lexopt_pw_multi_aff
Line
Count
Source
147
18
{
148
18
  ISL_FL_SET(flags, ISL_OPT_FULL);
149
18
  return SF(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL, NULL, flags);
150
18
}
151
152
__isl_give TYPE *SF(isl_basic_map_lexmin,SUFFIX)(__isl_take isl_basic_map *bmap)
153
18
{
154
18
  return SF(isl_basic_map_lexopt,SUFFIX)(bmap, 0);
155
18
}
Unexecuted instantiation: isl_basic_map_lexmin
isl_basic_map_lexmin_pw_multi_aff
Line
Count
Source
153
18
{
154
18
  return SF(isl_basic_map_lexopt,SUFFIX)(bmap, 0);
155
18
}
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
4.37k
{
176
4.37k
  isl_bool aligned;
177
4.37k
178
4.37k
  aligned = isl_map_set_has_equal_params(map, dom);
179
4.37k
  if (aligned < 0)
180
0
    goto error;
181
4.37k
  
if (4.37k
aligned4.37k
)
182
4.37k
    
return 4.37k
SF4.37k
(isl_map_partial_lexopt_aligned,SUFFIX)(map, dom,
183
4.37k
                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
4.37k
{
176
4.37k
  isl_bool aligned;
177
4.37k
178
4.37k
  aligned = isl_map_set_has_equal_params(map, dom);
179
4.37k
  if (aligned < 0)
180
0
    goto error;
181
4.37k
  
if (4.37k
aligned4.37k
)
182
4.37k
    
return 4.37k
SF4.37k
(isl_map_partial_lexopt_aligned,SUFFIX)(map, dom,
183
4.37k
                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.17k
{
206
1.17k
  ISL_FL_SET(flags, ISL_OPT_FULL);
207
1.17k
  return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, NULL, NULL,
208
1.17k
              flags);
209
1.17k
}
isl_map_lexopt
Line
Count
Source
205
390
{
206
390
  ISL_FL_SET(flags, ISL_OPT_FULL);
207
390
  return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, NULL, NULL,
208
390
              flags);
209
390
}
isl_map_lexopt_pw_multi_aff
Line
Count
Source
205
783
{
206
783
  ISL_FL_SET(flags, ISL_OPT_FULL);
207
783
  return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, NULL, NULL,
208
783
              flags);
209
783
}
210
211
__isl_give TYPE *SF(isl_map_lexmin,SUFFIX)(__isl_take isl_map *map)
212
736
{
213
736
  return SF(isl_map_lexopt,SUFFIX)(map, 0);
214
736
}
isl_map_lexmin_pw_multi_aff
Line
Count
Source
212
392
{
213
392
  return SF(isl_map_lexopt,SUFFIX)(map, 0);
214
392
}
isl_map_lexmin
Line
Count
Source
212
344
{
213
344
  return SF(isl_map_lexopt,SUFFIX)(map, 0);
214
344
}
215
216
__isl_give TYPE *SF(isl_map_lexmax,SUFFIX)(__isl_take isl_map *map)
217
437
{
218
437
  return 
SF437
(isl_map_lexopt,SUFFIX)(map,
ISL_OPT_MAX437
);
219
437
}
isl_map_lexmax_pw_multi_aff
Line
Count
Source
217
391
{
218
391
  return 
SF391
(isl_map_lexopt,SUFFIX)(map,
ISL_OPT_MAX391
);
219
391
}
isl_map_lexmax
Line
Count
Source
217
46
{
218
46
  return 
SF46
(isl_map_lexopt,SUFFIX)(map,
ISL_OPT_MAX46
);
219
46
}
220
221
__isl_give TYPE *SF(isl_set_lexmin,SUFFIX)(__isl_take isl_set *set)
222
454
{
223
454
  return SF(isl_map_lexmin,SUFFIX)(set);
224
454
}
isl_set_lexmin
Line
Count
Source
222
62
{
223
62
  return SF(isl_map_lexmin,SUFFIX)(set);
224
62
}
isl_set_lexmin_pw_multi_aff
Line
Count
Source
222
392
{
223
392
  return SF(isl_map_lexmin,SUFFIX)(set);
224
392
}
225
226
__isl_give TYPE *SF(isl_set_lexmax,SUFFIX)(__isl_take isl_set *set)
227
392
{
228
392
  return SF(isl_map_lexmax,SUFFIX)(set);
229
392
}
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
391
{
228
391
  return SF(isl_map_lexmax,SUFFIX)(set);
229
391
}