Coverage Report

Created: 2018-04-24 22:41

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/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
33.1k
#define xSF(TYPE,SUFFIX) TYPE ## SUFFIX
18
33.1k
#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
7.76k
{
35
7.76k
  return SF(isl_tab_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty,
36
7.76k
                  flags);
37
7.76k
}
isl_map.c:isl_basic_map_partial_lexopt_pw_multi_aff
Line
Count
Source
34
4.15k
{
35
4.15k
  return SF(isl_tab_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty,
36
4.15k
                  flags);
37
4.15k
}
isl_map.c:isl_basic_map_partial_lexopt
Line
Count
Source
34
3.60k
{
35
3.60k
  return SF(isl_tab_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty,
36
3.60k
                  flags);
37
3.60k
}
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
8.97k
{
90
8.97k
  int i;
91
8.97k
  TYPE *res;
92
8.97k
  isl_set *all_empty;
93
8.97k
94
8.97k
  if (ISL_FL_ISSET(flags, ISL_OPT_FULL))
95
8.97k
    
return 3.28k
SF3.28k
(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL,
96
3.28k
                empty, flags);
97
5.68k
98
5.68k
  dom = isl_set_make_disjoint(dom);
99
5.68k
  if (!dom)
100
0
    goto error;
101
5.68k
102
5.68k
  if (isl_set_plain_is_empty(dom)) {
103
2.81k
    isl_space *space = isl_basic_map_get_space(bmap);
104
2.81k
    if (empty)
105
2.81k
      *empty = dom;
106
0
    else
107
0
      isl_set_free(dom);
108
2.81k
    isl_basic_map_free(bmap);
109
2.81k
    return EMPTY(space);
110
2.81k
  }
111
2.87k
112
2.87k
  res = SF(isl_basic_map_partial_lexopt,SUFFIX)(isl_basic_map_copy(bmap),
113
2.87k
      isl_basic_set_copy(dom->p[0]), empty, flags);
114
2.87k
115
2.87k
  if (empty)
116
2.87k
    all_empty = *empty;
117
3.47k
  for (i = 1; i < dom->n; 
++i594
) {
118
594
    TYPE *res_i;
119
594
120
594
    res_i = SF(isl_basic_map_partial_lexopt,SUFFIX)(
121
594
        isl_basic_map_copy(bmap),
122
594
        isl_basic_set_copy(dom->p[i]), empty, flags);
123
594
124
594
    res = ADD(res, res_i);
125
594
    if (empty)
126
594
      all_empty = isl_set_union_disjoint(all_empty, *empty);
127
594
  }
128
2.87k
129
2.87k
  if (empty)
130
2.87k
    *empty = all_empty;
131
2.87k
  isl_set_free(dom);
132
2.87k
  isl_basic_map_free(bmap);
133
2.87k
  return res;
134
2.87k
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.87k
}
isl_map.c:basic_map_partial_lexopt_pw_multi_aff
Line
Count
Source
89
3.14k
{
90
3.14k
  int i;
91
3.14k
  TYPE *res;
92
3.14k
  isl_set *all_empty;
93
3.14k
94
3.14k
  if (ISL_FL_ISSET(flags, ISL_OPT_FULL))
95
3.14k
    
return 2.60k
SF2.60k
(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL,
96
2.60k
                empty, flags);
97
536
98
536
  dom = isl_set_make_disjoint(dom);
99
536
  if (!dom)
100
0
    goto error;
101
536
102
536
  if (isl_set_plain_is_empty(dom)) {
103
262
    isl_space *space = isl_basic_map_get_space(bmap);
104
262
    if (empty)
105
262
      *empty = dom;
106
0
    else
107
0
      isl_set_free(dom);
108
262
    isl_basic_map_free(bmap);
109
262
    return EMPTY(space);
110
262
  }
111
274
112
274
  res = SF(isl_basic_map_partial_lexopt,SUFFIX)(isl_basic_map_copy(bmap),
113
274
      isl_basic_set_copy(dom->p[0]), empty, flags);
114
274
115
274
  if (empty)
116
274
    all_empty = *empty;
117
727
  for (i = 1; i < dom->n; 
++i453
) {
118
453
    TYPE *res_i;
119
453
120
453
    res_i = SF(isl_basic_map_partial_lexopt,SUFFIX)(
121
453
        isl_basic_map_copy(bmap),
122
453
        isl_basic_set_copy(dom->p[i]), empty, flags);
123
453
124
453
    res = ADD(res, res_i);
125
453
    if (empty)
126
453
      all_empty = isl_set_union_disjoint(all_empty, *empty);
127
453
  }
128
274
129
274
  if (empty)
130
274
    *empty = all_empty;
131
274
  isl_set_free(dom);
132
274
  isl_basic_map_free(bmap);
133
274
  return res;
134
274
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
274
}
isl_map.c:basic_map_partial_lexopt
Line
Count
Source
89
5.83k
{
90
5.83k
  int i;
91
5.83k
  TYPE *res;
92
5.83k
  isl_set *all_empty;
93
5.83k
94
5.83k
  if (ISL_FL_ISSET(flags, ISL_OPT_FULL))
95
5.83k
    
return 678
SF678
(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL,
96
678
                empty, flags);
97
5.15k
98
5.15k
  dom = isl_set_make_disjoint(dom);
99
5.15k
  if (!dom)
100
0
    goto error;
101
5.15k
102
5.15k
  if (isl_set_plain_is_empty(dom)) {
103
2.54k
    isl_space *space = isl_basic_map_get_space(bmap);
104
2.54k
    if (empty)
105
2.54k
      *empty = dom;
106
0
    else
107
0
      isl_set_free(dom);
108
2.54k
    isl_basic_map_free(bmap);
109
2.54k
    return EMPTY(space);
110
2.54k
  }
111
2.60k
112
2.60k
  res = SF(isl_basic_map_partial_lexopt,SUFFIX)(isl_basic_map_copy(bmap),
113
2.60k
      isl_basic_set_copy(dom->p[0]), empty, flags);
114
2.60k
115
2.60k
  if (empty)
116
2.60k
    all_empty = *empty;
117
2.74k
  for (i = 1; i < dom->n; 
++i141
) {
118
141
    TYPE *res_i;
119
141
120
141
    res_i = SF(isl_basic_map_partial_lexopt,SUFFIX)(
121
141
        isl_basic_map_copy(bmap),
122
141
        isl_basic_set_copy(dom->p[i]), empty, flags);
123
141
124
141
    res = ADD(res, res_i);
125
141
    if (empty)
126
141
      all_empty = isl_set_union_disjoint(all_empty, *empty);
127
141
  }
128
2.60k
129
2.60k
  if (empty)
130
2.60k
    *empty = all_empty;
131
2.60k
  isl_set_free(dom);
132
2.60k
  isl_basic_map_free(bmap);
133
2.60k
  return res;
134
2.60k
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.60k
}
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
1.00k
{
148
1.00k
  ISL_FL_SET(flags, ISL_OPT_FULL);
149
1.00k
  return SF(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL, NULL, flags);
150
1.00k
}
isl_basic_map_lexopt_pw_multi_aff
Line
Count
Source
147
826
{
148
826
  ISL_FL_SET(flags, ISL_OPT_FULL);
149
826
  return SF(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL, NULL, flags);
150
826
}
isl_basic_map_lexopt
Line
Count
Source
147
180
{
148
180
  ISL_FL_SET(flags, ISL_OPT_FULL);
149
180
  return SF(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL, NULL, flags);
150
180
}
151
152
__isl_give TYPE *SF(isl_basic_map_lexmin,SUFFIX)(__isl_take isl_basic_map *bmap)
153
65
{
154
65
  return SF(isl_basic_map_lexopt,SUFFIX)(bmap, 0);
155
65
}
isl_basic_map_lexmin_pw_multi_aff
Line
Count
Source
153
65
{
154
65
  return SF(isl_basic_map_lexopt,SUFFIX)(bmap, 0);
155
65
}
Unexecuted instantiation: isl_basic_map_lexmin
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
12.0k
{
176
12.0k
  isl_bool aligned;
177
12.0k
178
12.0k
  aligned = isl_map_set_has_equal_params(map, dom);
179
12.0k
  if (aligned < 0)
180
0
    goto error;
181
12.0k
  if (aligned)
182
12.0k
    return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, dom,
183
12.0k
                empty, flags);
184
0
  if (!isl_space_has_named_params(map->dim) ||
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
12.0k
{
176
12.0k
  isl_bool aligned;
177
12.0k
178
12.0k
  aligned = isl_map_set_has_equal_params(map, dom);
179
12.0k
  if (aligned < 0)
180
0
    goto error;
181
12.0k
  if (aligned)
182
12.0k
    return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, dom,
183
12.0k
                empty, flags);
184
0
  if (!isl_space_has_named_params(map->dim) ||
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
2.14k
{
206
2.14k
  ISL_FL_SET(flags, ISL_OPT_FULL);
207
2.14k
  return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, NULL, NULL,
208
2.14k
              flags);
209
2.14k
}
isl_map_lexopt_pw_multi_aff
Line
Count
Source
205
1.07k
{
206
1.07k
  ISL_FL_SET(flags, ISL_OPT_FULL);
207
1.07k
  return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, NULL, NULL,
208
1.07k
              flags);
209
1.07k
}
isl_map_lexopt
Line
Count
Source
205
1.06k
{
206
1.06k
  ISL_FL_SET(flags, ISL_OPT_FULL);
207
1.06k
  return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, NULL, NULL,
208
1.06k
              flags);
209
1.06k
}
210
211
__isl_give TYPE *SF(isl_map_lexmin,SUFFIX)(__isl_take isl_map *map)
212
1.32k
{
213
1.32k
  return SF(isl_map_lexopt,SUFFIX)(map, 0);
214
1.32k
}
isl_map_lexmin_pw_multi_aff
Line
Count
Source
212
540
{
213
540
  return SF(isl_map_lexopt,SUFFIX)(map, 0);
214
540
}
isl_map_lexmin
Line
Count
Source
212
785
{
213
785
  return SF(isl_map_lexopt,SUFFIX)(map, 0);
214
785
}
215
216
__isl_give TYPE *SF(isl_map_lexmax,SUFFIX)(__isl_take isl_map *map)
217
819
{
218
819
  return SF(isl_map_lexopt,SUFFIX)(map, ISL_OPT_MAX);
219
819
}
isl_map_lexmax_pw_multi_aff
Line
Count
Source
217
539
{
218
539
  return SF(isl_map_lexopt,SUFFIX)(map, ISL_OPT_MAX);
219
539
}
isl_map_lexmax
Line
Count
Source
217
280
{
218
280
  return SF(isl_map_lexopt,SUFFIX)(map, ISL_OPT_MAX);
219
280
}
220
221
__isl_give TYPE *SF(isl_set_lexmin,SUFFIX)(__isl_take isl_set *set)
222
675
{
223
675
  return SF(isl_map_lexmin,SUFFIX)(set);
224
675
}
isl_set_lexmin_pw_multi_aff
Line
Count
Source
222
540
{
223
540
  return SF(isl_map_lexmin,SUFFIX)(set);
224
540
}
isl_set_lexmin
Line
Count
Source
222
135
{
223
135
  return SF(isl_map_lexmin,SUFFIX)(set);
224
135
}
225
226
__isl_give TYPE *SF(isl_set_lexmax,SUFFIX)(__isl_take isl_set *set)
227
540
{
228
540
  return SF(isl_map_lexmax,SUFFIX)(set);
229
540
}
isl_set_lexmax_pw_multi_aff
Line
Count
Source
227
539
{
228
539
  return SF(isl_map_lexmax,SUFFIX)(set);
229
539
}
isl_set_lexmax
Line
Count
Source
227
1
{
228
1
  return SF(isl_map_lexmax,SUFFIX)(set);
229
1
}