[CODEGEN] Fixed nasty bug in coalesce pass (#303)

This commit is contained in:
Philippe Tillet
2021-09-23 17:05:11 -07:00
committed by GitHub
parent d253eb8719
commit ec2e7b8f48

View File

@@ -62,8 +62,8 @@ void coalesce::run(ir::module &mod) {
if(ir::value* op = i->get_operand(1)) if(ir::value* op = i->get_operand(1))
if(op->get_type()->is_block_ty()) if(op->get_type()->is_block_ty())
if(layout_->get(op)->to_mma()){ if(layout_->get(op)->to_mma()){
builder.set_insert_point(i);
ir::instruction* new_op = ir::cvt_layout_inst::create(op); ir::instruction* new_op = ir::cvt_layout_inst::create(op);
builder.set_insert_point(i);
builder.insert(new_op); builder.insert(new_op);
i->replace_uses_of_with(op, new_op); i->replace_uses_of_with(op, new_op);
} }
@@ -79,6 +79,10 @@ void coalesce::run(ir::module &mod) {
new_x->replace_uses_of_with(new_x, x); new_x->replace_uses_of_with(new_x, x);
// new_x->replace_uses_of_with(new_x, new_x); // new_x->replace_uses_of_with(new_x, new_x);
} }
}
for(ir::function *fn: mod.get_function_list())
for(ir::basic_block *block: fn->blocks())
for(ir::instruction* i: block->get_inst_list()){
// re-arrange scanline to promote memory coalescing // re-arrange scanline to promote memory coalescing
if(auto x = dynamic_cast<ir::store_inst*>(i)){ if(auto x = dynamic_cast<ir::store_inst*>(i)){
ir::value* ptr = x->get_pointer_operand(); ir::value* ptr = x->get_pointer_operand();