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

daisytuner / sdfglib / 20263852258

16 Dec 2025 09:58AM UTC coverage: 40.086% (-0.2%) from 40.252%
20263852258

push

github

web-flow
Merge pull request #392 from daisytuner/for2map-performance

refactors passes to improve performance

13621 of 43972 branches covered (30.98%)

Branch coverage included in aggregate %.

126 of 173 new or added lines in 14 files covered. (72.83%)

55 existing lines in 8 files now uncovered.

11633 of 19027 relevant lines covered (61.14%)

90.79 hits per line

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

66.4
/src/passes/structured_control_flow/condition_elimination.cpp
1
#include "sdfg/passes/structured_control_flow/condition_elimination.h"
2

3
#include "sdfg/analysis/users.h"
4
#include "sdfg/deepcopy/structured_sdfg_deep_copy.h"
5

6
namespace sdfg {
7
namespace passes {
8

9
bool ConditionElimination::eliminate_condition(
4✔
10
    structured_control_flow::Sequence& parent,
11
    structured_control_flow::IfElse& match_node,
12
    structured_control_flow::Transition& match_transition
13
) {
14
    auto branch = match_node.at(0);
4✔
15
    auto& branch_root = branch.first;
4✔
16
    auto& branch_condition = branch.second;
4✔
17
    auto& loop = static_cast<structured_control_flow::StructuredLoop&>(branch_root.at(0).first);
4!
18

19
    auto loop_indvar = loop.indvar();
4!
20
    auto loop_init = loop.init();
4!
21
    auto loop_condition = loop.condition();
4!
22

23
    // indvar shall not be read afterwards directly since loop init overrides it
24
    analysis::Users& users = this->analysis_manager_.get<analysis::Users>();
4!
25
    analysis::UsersView loop_users(users, branch_root);
4!
26
    if (users.num_reads(loop_indvar->get_name()) > loop_users.reads(loop_indvar->get_name()).size()) {
4!
27
        return false;
1✔
28
    }
29

30
    // If loop condition == true => condition == true && condition == false => loop condition == false
31
    auto loop_iter0_condition = symbolic::subs(loop_condition, loop_indvar, loop_init);
3!
32
    if (symbolic::eq(loop_iter0_condition, branch_condition)) {
3!
33
        // Insert placeholder before if-else
34
        auto& new_child = this->builder_.add_sequence_before(parent, match_node, match_transition.assignments());
3!
35

36
        // Move children of branch to placeholder
37
        this->builder_.move_children(branch_root, new_child);
3!
38

39
        // Remove now empty if-else
40
        this->builder_.remove_child(parent, parent.index(match_node));
3!
41

42
        return true;
3✔
43
    }
44

45
    return false;
×
46
};
4✔
47

48
ConditionElimination::
49
    ConditionElimination(builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager)
4✔
50
    : NonStoppingStructuredSDFGVisitor(builder, analysis_manager) {
4✔
51

52
      };
4✔
53

54

55
bool ConditionElimination::accept(structured_control_flow::Sequence& node) {
12✔
56
    bool applied = false;
12✔
57
    for (size_t i = 0; i < node.size(); i++) {
24✔
58
        auto& current = node.at(i).first;
12✔
59
        if (auto ifelse = dynamic_cast<structured_control_flow::IfElse*>(&current)) {
12!
60
            if (ifelse->size() != 1) {
4!
61
                continue;
×
62
            }
63
            auto branch = ifelse->at(0);
4✔
64
            auto& condition = branch.second;
4✔
65

66
            auto& branch_root = branch.first;
4✔
67
            if (branch_root.size() != 1) {
4!
68
                continue;
×
69
            }
70
            if (!dynamic_cast<structured_control_flow::StructuredLoop*>(&branch_root.at(0).first)) {
4!
71
                continue;
×
72
            }
73

74
            if (this->eliminate_condition(node, *ifelse, node.at(i).second)) {
4!
75
                applied = true;
3✔
76
            }
3✔
77
        }
4!
78
    }
12✔
79

80
    return applied;
12✔
UNCOV
81
};
×
82

83
} // namespace passes
84
} // 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