File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
godel-script/godel-frontend/src/ir Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ void inst_combine_pass::visit_store(lir::store* s) {
1212 //
1313 // (
1414 // ssa_temp_0 = a,
15- // b = ssa_temp_1 ,
15+ // ssa_temp_1 = b ,
1616 // call(ssa_temp_2, ssa_temp_0, ssa_temp_1)
1717 // )
1818 //
@@ -86,6 +86,37 @@ void inst_combine_pass::visit_compare(lir::compare* c) {
8686 }
8787}
8888
89+ void inst_combine_pass::visit_call (lir::call* c) {
90+ if (c->get_func_kind () != lir::call::kind::key_cmp) {
91+ return ;
92+ }
93+ if (c->get_function_name () != " key_eq" ) {
94+ return ;
95+ }
96+
97+ const auto & left = c->get_arguments ()[0 ];
98+ const auto & right = c->get_arguments ()[1 ];
99+
100+ // record this case:
101+ //
102+ // a.key_eq(b.getParent())
103+ // -->
104+ // (
105+ // getParent(ssa_temp_0, b),
106+ // a = ssa_temp_0
107+ // )
108+ //
109+ // and optimize this case to:
110+ //
111+ // getParent(a, b)
112+ //
113+ if (left.kind ==lir::inst_value_kind::variable &&
114+ right.kind ==lir::inst_value_kind::variable) {
115+ variable_reference_graph[left.content ].insert ({right.content , c});
116+ variable_reference_graph[right.content ].insert ({left.content , c});
117+ }
118+ }
119+
89120bool inst_combine_pass::run () {
90121 for (auto impl : ctx->rule_impls ) {
91122 run_on_single_impl (impl);
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ class inst_combine_pass: public pass {
2020private:
2121 void visit_store (lir::store*) override ;
2222 void visit_compare (lir::compare*) override ;
23+ void visit_call (lir::call*) override ;
2324
2425private:
2526 void scan (souffle_rule_impl*);
You can’t perform that action at this time.
0 commit comments