[CODEGEN] Fixed bug that caused conditional operator to not always
properly mask load operations Also includes minor improvement to benchmarking infrastructure
This commit is contained in:
@@ -1616,20 +1616,22 @@ void generator::visit_make_range(ir::make_range* x) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void generator::visit_undef_value(ir::undef_value *ud) {
|
||||
vals_[ud][{}] = llvm::UndefValue::get(cvt(ud->get_type()));
|
||||
void generator::visit_undef_value(ir::undef_value *x) {
|
||||
Type* ty = cvt(x->get_type()->get_scalar_ty());
|
||||
for(indices_t idx: idxs_.at(x))
|
||||
vals_[x][idx] = llvm::UndefValue::get(ty);
|
||||
}
|
||||
|
||||
void generator::visit_constant_int(ir::constant_int *cst){
|
||||
Type *ty = cvt(cst->get_type()->get_scalar_ty());
|
||||
vals_[cst][{}] = ConstantInt::get(ty, cst->get_value());
|
||||
void generator::visit_constant_int(ir::constant_int *x){
|
||||
Type *ty = cvt(x->get_type()->get_scalar_ty());
|
||||
for(indices_t idx: idxs_.at(x))
|
||||
vals_[x][idx] = ConstantInt::get(ty, x->get_value());
|
||||
}
|
||||
|
||||
void generator::visit_constant_fp(ir::constant_fp *cst){
|
||||
Type *ty = cvt(cst->get_type()->get_scalar_ty());
|
||||
vals_[cst][{}] = ConstantFP::get(ty, cst->get_value());
|
||||
void generator::visit_constant_fp(ir::constant_fp *x){
|
||||
Type *ty = cvt(x->get_type()->get_scalar_ty());
|
||||
for(indices_t idx: idxs_.at(x))
|
||||
vals_[x][idx] = ConstantFP::get(ty, x->get_value());
|
||||
}
|
||||
|
||||
void generator::visit_alloc_const(ir::alloc_const *alloc) {
|
||||
|
@@ -193,6 +193,22 @@ bool peephole::rewrite_gep_ptr_min_off_plus_off(ir::instruction *value, ir::buil
|
||||
return false;
|
||||
}
|
||||
|
||||
bool peephole::rewrite_select_masked_load(ir::instruction *value, ir::builder& builder){
|
||||
auto select = dynamic_cast<ir::select_inst*>(value);
|
||||
if(!select)
|
||||
return false;
|
||||
auto if_value = dynamic_cast<ir::masked_load_inst*>(select->get_if_value_op());
|
||||
if(!if_value)
|
||||
return false;
|
||||
if(select->get_pred_op() != if_value->get_mask_operand())
|
||||
return false;
|
||||
builder.set_insert_point(select);
|
||||
ir::value* new_load = builder.create_masked_load(if_value->get_pointer_operand(),
|
||||
if_value->get_mask_operand(),
|
||||
select->get_else_value_op());
|
||||
select->replace_all_uses_with(new_load);
|
||||
return true;
|
||||
}
|
||||
|
||||
void peephole::run(ir::module &mod) {
|
||||
ir::builder &builder = mod.get_builder();
|
||||
@@ -230,6 +246,7 @@ void peephole::run(ir::module &mod) {
|
||||
// was_modified = was_modified || rewrite_trans_phi(i, builder);
|
||||
was_modified = was_modified || rewrite_unit_red(i, builder);
|
||||
was_modified = was_modified || rewrite_gep_ptr_min_off_plus_off(i, builder);
|
||||
was_modified = was_modified || rewrite_select_masked_load(i, builder);
|
||||
if(tgt_->as_nvidia()->sm() >= 80)
|
||||
was_modified = was_modified || rewrite_load_to_shared(i, builder);
|
||||
if(was_modified)
|
||||
|
Reference in New Issue
Block a user