[CODEGEN] removed buggy (and mostly useless) optimization in peephole pass (#449)

This commit is contained in:
Philippe Tillet
2022-02-05 21:37:23 -08:00
committed by GitHub
parent 137bb67fad
commit 69ff52ea1f

View File

@@ -227,22 +227,22 @@ bool peephole::rewrite_cvt_layout(ir::instruction *value, ir::builder& builder){
ir::instruction* op = dynamic_cast<ir::instruction*>(cvt->get_operand(0)); ir::instruction* op = dynamic_cast<ir::instruction*>(cvt->get_operand(0));
if(!op) if(!op)
return false; return false;
// convert(elementwise(x, y)) = elementwise(convert(x), convert(y)) // // convert(elementwise(x, y)) = elementwise(convert(x), convert(y))
if(op->get_id() == ir::INST_BINOP){ // if(op->get_id() == ir::INST_BINOP){
for(size_t i = 0; i < op->get_num_operands(); i++){ // for(size_t i = 0; i < op->get_num_operands(); i++){
ir::value* arg_i = op->get_operand(i); // ir::value* arg_i = op->get_operand(i);
builder.set_insert_point(op); // builder.set_insert_point(op);
// create new layout transform // // create new layout transform
ir::instruction* new_arg_i = cvt->clone(); // ir::instruction* new_arg_i = cvt->clone();
layouts_->copy(new_arg_i, op); // layouts_->copy(new_arg_i, op);
builder.insert(new_arg_i); // builder.insert(new_arg_i);
// set the right args // // set the right args
new_arg_i->replace_uses_of_with(new_arg_i->get_operand(0), arg_i); // new_arg_i->replace_uses_of_with(new_arg_i->get_operand(0), arg_i);
op->replace_uses_of_with(arg_i, new_arg_i); // op->replace_uses_of_with(arg_i, new_arg_i);
} // }
cvt->replace_all_uses_with(op); // cvt->replace_all_uses_with(op);
return true; // return true;
} // }
auto cvt_op = dynamic_cast<ir::cvt_layout_inst*>(op); auto cvt_op = dynamic_cast<ir::cvt_layout_inst*>(op);
if(!cvt_op) if(!cvt_op)
return false; return false;