[BACKEND] float division is now approximate by default (#446)

This commit is contained in:
Philippe Tillet
2022-01-29 18:29:29 -08:00
committed by GitHub
parent bd52e530a0
commit bef76b142a
9 changed files with 44 additions and 3 deletions

View File

@@ -319,6 +319,13 @@ void generator::visit_binary_operator(ir::binary_operator*x) {
vals_[x][idx] = add(lhs, rhs);
else if(op == ll::Mul)
vals_[x][idx] = mul(lhs, rhs);
else if(op == ll::FDiv && !x->get_fdiv_ieee_rounding() &&
x->get_type()->get_scalar_ty()->is_fp32_ty()){
InlineAsm *ptx = InlineAsm::get(FunctionType::get(f32_ty, {f32_ty, f32_ty}, false),
" div.full.f32 $0, $1, $2;", "=r,r,r", false);
vals_[x][idx] = builder_->CreateCall(ptx, {lhs, rhs});
}
else
vals_[x][idx] = bin_op(op, lhs, rhs);
}