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

daisytuner / sdfglib / 15512041711

07 Jun 2025 09:59PM UTC coverage: 57.416% (+0.1%) from 57.315%
15512041711

push

github

web-flow
Merge pull request #44 from daisytuner/StructuredLoops

Add Structured Loops

51 of 102 new or added lines in 20 files covered. (50.0%)

10 existing lines in 8 files now uncovered.

7618 of 13268 relevant lines covered (57.42%)

116.01 hits per line

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

0.0
/src/passes/structured_control_flow/common_assignment_elimination.cpp
1
#include "sdfg/passes/structured_control_flow/common_assignment_elimination.h"
2

3
#include "sdfg/structured_control_flow/structured_loop.h"
4

5
namespace sdfg {
6
namespace passes {
7

8
CommonAssignmentElimination::CommonAssignmentElimination()
×
9
    : Pass() {
×
10

11
      };
×
12

13
std::string CommonAssignmentElimination::name() { return "CommonAssignmentElimination"; };
×
14

15
bool CommonAssignmentElimination::run_pass(builder::StructuredSDFGBuilder& builder,
×
16
                                           analysis::AnalysisManager& analysis_manager) {
17
    bool applied = false;
×
18

19
    // Traverse structured SDFG
20
    std::list<structured_control_flow::ControlFlowNode*> queue = {&builder.subject().root()};
×
21
    while (!queue.empty()) {
×
22
        auto current = queue.front();
×
23
        queue.pop_front();
×
24

25
        // Add children to queue
26
        if (auto sequence_stmt = dynamic_cast<structured_control_flow::Sequence*>(current)) {
×
27
            for (size_t i = 0; i < sequence_stmt->size(); i++) {
×
28
                auto child = sequence_stmt->at(i);
×
29
                if (auto if_else_stmt =
×
30
                        dynamic_cast<structured_control_flow::IfElse*>(&child.first)) {
×
31
                    if (if_else_stmt->size() < 2) {
×
32
                        continue;
×
33
                    }
34
                    auto& first_branch = if_else_stmt->at(0).first;
×
35
                    if (first_branch.size() == 0) {
×
36
                        continue;
×
37
                    }
38
                    auto& last_transition = first_branch.at(first_branch.size() - 1).second;
×
39
                    if (last_transition.assignments().size() == 0) {
×
40
                        continue;
×
41
                    }
42

43
                    // Check waw dependencies
44
                    for (auto& entry : last_transition.assignments()) {
×
45
                        auto& first_assign = entry.first;
×
46
                        auto& first_assignment = entry.second;
×
47
                        if (child.second.assignments().find(first_assign) !=
×
48
                            child.second.assignments().end()) {
×
49
                            continue;
×
50
                        }
51

52
                        // Check if all branches end with same assignment
53
                        bool all_branches_same = true;
×
54
                        for (size_t j = 1; j < if_else_stmt->size(); j++) {
×
55
                            auto& branch = if_else_stmt->at(j).first;
×
56
                            if (branch.size() == 0) {
×
57
                                all_branches_same = false;
×
58
                                break;
×
59
                            }
60

61
                            auto& transition = branch.at(branch.size() - 1).second;
×
62
                            if (transition.assignments().find(first_assign) ==
×
63
                                transition.assignments().end()) {
×
64
                                all_branches_same = false;
×
65
                                break;
×
66
                            }
67
                            if (!symbolic::eq(first_assignment,
×
68
                                              transition.assignments().at(first_assign))) {
×
69
                                all_branches_same = false;
×
70
                                break;
×
71
                            }
72
                        }
×
73

74
                        if (!all_branches_same) {
×
75
                            continue;
×
76
                        }
77

78
                        child.second.assignments().insert({first_assign, first_assignment});
×
79
                        applied = true;
×
80
                    }
81
                }
×
82
            }
×
83

84
            for (size_t i = 0; i < sequence_stmt->size(); i++) {
×
85
                queue.push_back(&sequence_stmt->at(i).first);
×
86
            }
×
87
        } else if (auto if_else_stmt = dynamic_cast<structured_control_flow::IfElse*>(current)) {
×
88
            for (size_t i = 0; i < if_else_stmt->size(); i++) {
×
89
                queue.push_back(&if_else_stmt->at(i).first);
×
90
            }
×
91
        } else if (auto loop_stmt = dynamic_cast<structured_control_flow::While*>(current)) {
×
92
            queue.push_back(&loop_stmt->root());
×
NEW
93
        } else if (auto sloop_stmt =
×
NEW
94
                       dynamic_cast<structured_control_flow::StructuredLoop*>(current)) {
×
NEW
95
            queue.push_back(&sloop_stmt->root());
×
UNCOV
96
        }
×
97
    }
98

99
    return applied;
×
100
};
×
101

102
}  // namespace passes
103
}  // 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