Skip to content

Commit f128222

Browse files
committed
add comments in inst combine pass
1 parent 817b4ac commit f128222

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

godel-script/godel-frontend/src/ir/inst_combine.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,26 @@ void inst_combine_pass::scan(souffle_rule_impl* b) {
143143
//
144144
for(const auto& i : variable_reference_graph) {
145145
const auto& name = i.first;
146-
if (i.second.size()!=1) {
146+
// if alias variables' count > 1, even if there's a circle, still skip it.
147+
if (i.second.size() != 1) {
147148
continue;
148149
}
150+
// alias variable's name
149151
const auto& to = i.second.begin()->first;
150152
if (!variable_reference_graph.count(to)) {
151153
continue;
152154
}
153-
if (variable_reference_graph.at(to).size()!=1) {
155+
// this variable's alias count should be 1
156+
if (variable_reference_graph.at(to).size() != 1) {
154157
continue;
155158
}
159+
// get `to`'s alias variable's name, this name should be equal to `name`
156160
const auto& from = variable_reference_graph.at(to).begin()->first;
157-
if (from==name && to.find("ssa_temp")==0 && from.find("ssa_temp")==0) {
161+
// means there's a circle like this:
162+
// `to` <--> `from`(aka `name`)
163+
// after clear(), `to`'s alias count should be 0:
164+
// `to` <--- `from`(aka `name`)
165+
if (from == name && to.find("ssa_temp") == 0 && from.find("ssa_temp") == 0) {
158166
variable_reference_graph.at(to).clear();
159167
}
160168
}

0 commit comments

Comments
 (0)