• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

daisytuner / sdfglib / 19406662809

16 Nov 2025 01:54PM UTC coverage: 62.092% (-0.4%) from 62.447%
19406662809

push

github

web-flow
Merge pull request #347 from daisytuner/symbolic-range-analysis

extends symbol promotion with checks for effective range of scalars

174 of 355 new or added lines in 10 files covered. (49.01%)

13 existing lines in 4 files now uncovered.

11048 of 17793 relevant lines covered (62.09%)

112.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/src/symbolic/assumptions.cpp
1
#include "sdfg/symbolic/assumptions.h"
2

3
#include "sdfg/types/pointer.h"
4
#include "sdfg/types/scalar.h"
5

6
namespace sdfg {
7
namespace symbolic {
8

9
Assumption::Assumption()
48✔
10
    : symbol_(symbolic::symbol("")), lower_bound_deprecated_(SymEngine::NegInf),
48✔
11
      upper_bound_deprecated_(SymEngine::Inf), lower_bounds_(), upper_bounds_(), tight_lower_bound_(SymEngine::null),
48✔
12
      tight_upper_bound_(SymEngine::null), constant_(false), map_(SymEngine::null) {
48✔
13

14
      };
48✔
15

16
Assumption::Assumption(const Symbol symbol)
1,234✔
17
    : symbol_(symbol), lower_bound_deprecated_(SymEngine::NegInf), upper_bound_deprecated_(SymEngine::Inf),
1,234✔
18
      lower_bounds_(), upper_bounds_(), tight_lower_bound_(SymEngine::null), tight_upper_bound_(SymEngine::null),
1,234✔
19
      constant_(false), map_(SymEngine::null) {
1,234✔
20

21
      };
1,234✔
22

23
Assumption::Assumption(const Assumption& a)
10,883✔
24
    : symbol_(a.symbol_), lower_bound_deprecated_(a.lower_bound_deprecated_),
10,883✔
25
      upper_bound_deprecated_(a.upper_bound_deprecated_), lower_bounds_(a.lower_bounds_),
10,883✔
26
      upper_bounds_(a.upper_bounds_), tight_lower_bound_(a.tight_lower_bound_),
10,883✔
27
      tight_upper_bound_(a.tight_upper_bound_), constant_(a.constant_), map_(a.map_) {
10,883✔
28

29
      };
10,883✔
30

31
Assumption& Assumption::operator=(const Assumption& a) {
1,378✔
32
    this->symbol_ = a.symbol_;
1,378✔
33
    this->lower_bound_deprecated_ = a.lower_bound_deprecated_;
1,378✔
34
    this->upper_bound_deprecated_ = a.upper_bound_deprecated_;
1,378✔
35
    this->lower_bounds_ = a.lower_bounds_;
1,378✔
36
    this->upper_bounds_ = a.upper_bounds_;
1,378✔
37
    this->tight_lower_bound_ = a.tight_lower_bound_;
1,378✔
38
    this->tight_upper_bound_ = a.tight_upper_bound_;
1,378✔
39
    this->constant_ = a.constant_;
1,378✔
40
    this->map_ = a.map_;
1,378✔
41
    return *this;
1,378✔
42
};
43

44
const Symbol Assumption::symbol() const { return this->symbol_; };
2✔
45

46
const Expression Assumption::lower_bound_deprecated() const { return this->lower_bound_deprecated_; }
6,579✔
47

48
void Assumption::lower_bound_deprecated(const Expression lower_bound) { this->lower_bound_deprecated_ = lower_bound; }
2,903✔
49

50
const Expression Assumption::upper_bound_deprecated() const { return this->upper_bound_deprecated_; }
5,895✔
51

52
void Assumption::upper_bound_deprecated(const Expression upper_bound) { this->upper_bound_deprecated_ = upper_bound; }
2,788✔
53

54
const Expression Assumption::lower_bound() const {
36✔
55
    Expression lb;
36✔
56
    if (this->lower_bounds_.empty()) {
36✔
57
        lb = SymEngine::NegInf;
1✔
58
    } else {
1✔
59
        lb = SymEngine::max(std::vector<Expression>(this->lower_bounds_.begin(), this->lower_bounds_.end()));
35✔
60
    }
61
    if (this->tight_lower_bound_.is_null()) {
36✔
62
        return lb;
26✔
63
    } else if (eq(lb, SymEngine::NegInf)) {
10✔
UNCOV
64
        return this->tight_lower_bound_;
×
65
    } else {
66
        return max(this->tight_lower_bound_, lb);
10✔
67
    }
68
}
36✔
69

70
const ExpressionSet& Assumption::lower_bounds() const { return this->lower_bounds_; }
3,310✔
71

72
void Assumption::add_lower_bound(const Expression lb) { this->lower_bounds_.insert(lb); }
6,733✔
73

74
bool Assumption::contains_lower_bound(const Expression lb) { return this->lower_bounds_.contains(lb); }
×
75

76
bool Assumption::remove_lower_bound(const Expression lb) { return this->lower_bounds_.erase(lb) > 0; }
×
77

78
const Expression Assumption::upper_bound() const {
38✔
79
    Expression ub;
38✔
80
    if (this->upper_bounds_.empty()) {
38✔
81
        ub = SymEngine::Inf;
8✔
82
    } else {
8✔
83
        ub = SymEngine::min(std::vector<Expression>(this->upper_bounds_.begin(), this->upper_bounds_.end()));
30✔
84
    }
85
    if (this->tight_upper_bound_.is_null()) {
38✔
86
        return ub;
28✔
87
    } else if (eq(ub, SymEngine::Inf)) {
10✔
UNCOV
88
        return this->tight_upper_bound_;
×
89
    } else {
90
        return min(this->tight_upper_bound_, ub);
10✔
91
    }
92
}
38✔
93

94
const ExpressionSet& Assumption::upper_bounds() const { return this->upper_bounds_; }
3,313✔
95

96
void Assumption::add_upper_bound(const Expression ub) { this->upper_bounds_.insert(ub); }
6,528✔
97

98
bool Assumption::contains_upper_bound(const Expression ub) { return this->upper_bounds_.contains(ub); }
×
99

100
bool Assumption::remove_upper_bound(const Expression ub) { return this->upper_bounds_.erase(ub) > 0; }
×
101

102
const Expression Assumption::tight_lower_bound() const { return this->tight_lower_bound_; }
3,796✔
103

104
void Assumption::tight_lower_bound(const Expression tight_lb) { this->tight_lower_bound_ = tight_lb; }
843✔
105

106
const Expression Assumption::tight_upper_bound() const { return this->tight_upper_bound_; }
3,670✔
107

108
void Assumption::tight_upper_bound(const Expression tight_ub) { this->tight_upper_bound_ = tight_ub; }
702✔
109

110
bool Assumption::constant() const { return constant_; };
2,445✔
111

112
void Assumption::constant(bool constant) { constant_ = constant; };
1,594✔
113

114
const Expression Assumption::map() const { return map_; };
3,361✔
115

116
void Assumption::map(const Expression map) { map_ = map; };
1,230✔
117

118
Assumption Assumption::create(const Symbol symbol, const types::IType& type) {
975✔
119
    if (auto scalar_type = dynamic_cast<const types::Scalar*>(&type)) {
975✔
120
        auto assum = Assumption(symbol);
705✔
121

122
        types::PrimitiveType primitive_type = scalar_type->primitive_type();
705✔
123
        switch (primitive_type) {
705✔
124
            case types::PrimitiveType::Bool: {
125
                assum.add_lower_bound(zero());
2✔
126
                assum.add_upper_bound(one());
2✔
127
                assum.lower_bound_deprecated(zero());
2✔
128
                assum.upper_bound_deprecated(one());
2✔
129
                break;
2✔
130
            }
131
            case types::PrimitiveType::UInt8: {
132
                assum.add_lower_bound(integer(std::numeric_limits<uint8_t>::min()));
36✔
133
                assum.add_upper_bound(integer(std::numeric_limits<uint8_t>::max()));
36✔
134
                assum.lower_bound_deprecated(integer(std::numeric_limits<uint8_t>::min()));
36✔
135
                assum.upper_bound_deprecated(integer(std::numeric_limits<uint8_t>::max()));
36✔
136
                break;
36✔
137
            }
138
            case types::PrimitiveType::UInt16: {
139
                assum.add_lower_bound(integer(std::numeric_limits<uint16_t>::min()));
2✔
140
                assum.add_upper_bound(integer(std::numeric_limits<uint16_t>::max()));
2✔
141
                assum.lower_bound_deprecated(integer(std::numeric_limits<uint16_t>::min()));
2✔
142
                assum.upper_bound_deprecated(integer(std::numeric_limits<uint16_t>::max()));
2✔
143
                break;
2✔
144
            }
145
            case types::PrimitiveType::UInt32: {
146
                assum.add_lower_bound(integer(std::numeric_limits<uint32_t>::min()));
100✔
147
                assum.add_upper_bound(integer(std::numeric_limits<uint32_t>::max()));
100✔
148
                assum.lower_bound_deprecated(integer(std::numeric_limits<uint32_t>::min()));
100✔
149
                assum.upper_bound_deprecated(integer(std::numeric_limits<uint32_t>::max()));
100✔
150
                break;
100✔
151
            }
152
            case types::PrimitiveType::UInt64: {
153
                assum.add_lower_bound(integer(std::numeric_limits<uint64_t>::min()));
267✔
154
                assum.add_upper_bound(SymEngine::Inf);
267✔
155
                assum.lower_bound_deprecated(integer(std::numeric_limits<uint64_t>::min()));
267✔
156
                assum.upper_bound_deprecated(SymEngine::Inf);
267✔
157
                break;
267✔
158
            }
159
            case types::PrimitiveType::UInt128: {
160
                assum.add_lower_bound(integer(0));
×
161
                assum.add_upper_bound(SymEngine::Inf);
×
162
                assum.lower_bound_deprecated(integer(0));
×
163
                assum.upper_bound_deprecated(SymEngine::Inf);
×
164
                break;
×
165
            }
166
            case types::PrimitiveType::Int8: {
167
                assum.add_lower_bound(integer(std::numeric_limits<int8_t>::min()));
7✔
168
                assum.add_upper_bound(integer(std::numeric_limits<int8_t>::max()));
7✔
169
                assum.lower_bound_deprecated(integer(std::numeric_limits<int8_t>::min()));
7✔
170
                assum.upper_bound_deprecated(integer(std::numeric_limits<int8_t>::max()));
7✔
171
                break;
7✔
172
            }
173
            case types::PrimitiveType::Int16: {
174
                assum.add_lower_bound(integer(std::numeric_limits<int16_t>::min()));
4✔
175
                assum.add_upper_bound(integer(std::numeric_limits<int16_t>::max()));
4✔
176
                assum.lower_bound_deprecated(integer(std::numeric_limits<int16_t>::min()));
4✔
177
                assum.upper_bound_deprecated(integer(std::numeric_limits<int16_t>::max()));
4✔
178
                break;
4✔
179
            }
180
            case types::PrimitiveType::Int32: {
181
                assum.add_lower_bound(integer(std::numeric_limits<int32_t>::min()));
199✔
182
                assum.add_upper_bound(integer(std::numeric_limits<int32_t>::max()));
199✔
183
                assum.lower_bound_deprecated(integer(std::numeric_limits<int32_t>::min()));
199✔
184
                assum.upper_bound_deprecated(integer(std::numeric_limits<int32_t>::max()));
199✔
185
                break;
199✔
186
            }
187
            case types::PrimitiveType::Int64: {
188
                assum.add_lower_bound(integer(std::numeric_limits<int64_t>::min()));
88✔
189
                assum.add_upper_bound(integer(std::numeric_limits<int64_t>::max()));
88✔
190
                assum.lower_bound_deprecated(integer(std::numeric_limits<int64_t>::min()));
88✔
191
                assum.upper_bound_deprecated(integer(std::numeric_limits<int64_t>::max()));
88✔
192
                break;
88✔
193
            }
194
            case types::PrimitiveType::Int128: {
195
                assum.add_lower_bound(SymEngine::NegInf);
×
196
                assum.add_upper_bound(SymEngine::Inf);
×
197
                assum.lower_bound_deprecated(SymEngine::NegInf);
×
198
                assum.upper_bound_deprecated(SymEngine::Inf);
×
199
                break;
×
200
            }
201
            default: {
202
                throw std::runtime_error("Unsupported type");
×
203
            }
204
        };
205
        return assum;
705✔
206
    } else if (auto ptr_type = dynamic_cast<const types::Pointer*>(&type)) {
975✔
207
        auto assum = Assumption(symbol);
270✔
208
        assum.add_lower_bound(integer(std::numeric_limits<uint64_t>::min()));
270✔
209
        assum.add_upper_bound(SymEngine::Inf);
270✔
210
        assum.lower_bound_deprecated(integer(std::numeric_limits<uint64_t>::min()));
270✔
211
        assum.upper_bound_deprecated(SymEngine::Inf);
270✔
212

213
        return assum;
270✔
214
    } else {
270✔
215
        throw std::runtime_error("Unsupported type");
×
216
    }
217
};
975✔
218

219
} // namespace symbolic
220
} // namespace sdfg
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc