Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/polly/lib/External/isl/isl_local.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2014      Ecole Normale Superieure
3
 *
4
 * Use of this software is governed by the MIT license
5
 *
6
 * Written by Sven Verdoolaege,
7
 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
8
 */
9
10
#include <isl_mat_private.h>
11
#include <isl_seq.h>
12
13
/* Given a matrix "div" representing local variables,
14
 * is the variable at position "pos" marked as not having
15
 * an explicit representation?
16
 * Note that even if this variable is not marked in this way and therefore
17
 * does have an explicit representation, this representation may still
18
 * depend (indirectly) on other local variables that do not
19
 * have an explicit representation.
20
 */
21
isl_bool isl_local_div_is_marked_unknown(__isl_keep isl_mat *div, int pos)
22
80.4k
{
23
80.4k
  if (!div)
24
0
    return isl_bool_error;
25
80.4k
  
if (80.4k
pos < 0 || 80.4k
pos >= div->n_row80.4k
)
26
0
    isl_die(isl_mat_get_ctx(div), isl_error_invalid,
27
80.4k
      "position out of bounds", return isl_bool_error);
28
80.4k
  
return 80.4k
isl_int_is_zero80.4k
(div->row[pos][0]);
29
80.4k
}
30
31
/* Given a matrix "div" representing local variables,
32
 * does the variable at position "pos" have a complete explicit representation?
33
 * Having a complete explicit representation requires not only
34
 * an explicit representation, but also that all local variables
35
 * that appear in this explicit representation in turn have
36
 * a complete explicit representation.
37
 */
38
isl_bool isl_local_div_is_known(__isl_keep isl_mat *div, int pos)
39
670
{
40
670
  isl_bool marked;
41
670
  int i, n, off;
42
670
43
670
  if (!div)
44
0
    return isl_bool_error;
45
670
  
if (670
pos < 0 || 670
pos >= div->n_row670
)
46
0
    isl_die(isl_mat_get_ctx(div), isl_error_invalid,
47
670
      "position out of bounds", return isl_bool_error);
48
670
49
670
  marked = isl_local_div_is_marked_unknown(div, pos);
50
670
  if (
marked < 0 || 670
marked670
)
51
9
    return isl_bool_not(marked);
52
661
53
661
  n = isl_mat_rows(div);
54
661
  off = isl_mat_cols(div) - n;
55
661
56
1.68k
  for (i = n - 1; 
i >= 01.68k
;
--i1.02k
) {
57
1.02k
    isl_bool known;
58
1.02k
59
1.02k
    if (isl_int_is_zero(div->row[pos][off + i]))
60
1.02k
      continue;
61
1
    known = isl_local_div_is_known(div, i);
62
1
    if (
known < 0 || 1
!known1
)
63
0
      return known;
64
1.02k
  }
65
661
66
661
  return isl_bool_true;
67
670
}
68
69
/* Compare two matrices representing local variables, defined over
70
 * the same space.
71
 *
72
 * Return -1 if "div1" is "smaller" than "div2", 1 if "div1" is "greater"
73
 * than "div2" and 0 if they are equal.
74
 *
75
 * The order is fairly arbitrary.  We do "prefer" divs that only involve
76
 * earlier dimensions in the sense that we consider matrices where
77
 * the first differing div involves earlier dimensions to be smaller.
78
 */
79
int isl_local_cmp(__isl_keep isl_mat *div1, __isl_keep isl_mat *div2)
80
6.17k
{
81
6.17k
  int i;
82
6.17k
  int cmp;
83
6.17k
  isl_bool unknown1, unknown2;
84
6.17k
  int last1, last2;
85
6.17k
  int n_col;
86
6.17k
87
6.17k
  if (div1 == div2)
88
0
    return 0;
89
6.17k
  
if (6.17k
!div16.17k
)
90
0
    return -1;
91
6.17k
  
if (6.17k
!div26.17k
)
92
0
    return 1;
93
6.17k
94
6.17k
  
if (6.17k
div1->n_row != div2->n_row6.17k
)
95
141
    return div1->n_row - div2->n_row;
96
6.03k
97
6.03k
  n_col = isl_mat_cols(div1);
98
6.06k
  for (i = 0; 
i < div1->n_row6.06k
;
++i34
) {
99
181
    unknown1 = isl_local_div_is_marked_unknown(div1, i);
100
181
    unknown2 = isl_local_div_is_marked_unknown(div2, i);
101
181
    if (
unknown1 && 181
unknown20
)
102
0
      continue;
103
181
    
if (181
unknown1181
)
104
0
      return 1;
105
181
    
if (181
unknown2181
)
106
0
      return -1;
107
181
    last1 = isl_seq_last_non_zero(div1->row[i] + 1, n_col - 1);
108
181
    last2 = isl_seq_last_non_zero(div2->row[i] + 1, n_col - 1);
109
181
    if (last1 != last2)
110
30
      return last1 - last2;
111
151
    cmp = isl_seq_cmp(div1->row[i], div2->row[i], n_col);
112
151
    if (cmp != 0)
113
117
      return cmp;
114
181
  }
115
6.03k
116
5.88k
  return 0;
117
6.17k
}