Skip to content

Commit 2eba11b

Browse files
alexreinkingsoufianekhiat
authored andcommitted
Implement strict float intrinsics for D3D12
1 parent 1c99661 commit 2eba11b

File tree

1 file changed

+0
-61
lines changed

1 file changed

+0
-61
lines changed

src/CodeGen_D3D12Compute_Dev.cpp

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -582,67 +582,6 @@ void CodeGen_D3D12Compute_Dev::CodeGen_D3D12Compute_C::visit(const Call *op) {
582582
// HLSL's round intrinsic has the correct semantics for our rounding.
583583
Expr equiv = Call::make(op->type, "round", op->args, Call::PureExtern);
584584
equiv.accept(this);
585-
} else if (op->is_strict_float_intrinsic()) {
586-
// Emit strict float intrinsics as HLSL 'precise'-qualified temporaries.
587-
// The 'precise' qualifier prevents the HLSL compiler from reordering or
588-
// fusing these operations (e.g. forming FMAs, reassociating additions).
589-
// We use a "precise:" cache key prefix so that strict and non-strict
590-
// evaluations of the same sub-expression don't share a variable.
591-
string rhs;
592-
if (op->is_intrinsic(Call::strict_fma)) {
593-
string a = print_expr(op->args[0]);
594-
string b = print_expr(op->args[1]);
595-
string c = print_expr(op->args[2]);
596-
rhs = "mad(" + a + ", " + b + ", " + c + ")";
597-
} else if (op->is_intrinsic(Call::strict_add)) {
598-
string a = print_expr(op->args[0]);
599-
string b = print_expr(op->args[1]);
600-
rhs = a + " + " + b;
601-
} else if (op->is_intrinsic(Call::strict_sub)) {
602-
string a = print_expr(op->args[0]);
603-
string b = print_expr(op->args[1]);
604-
rhs = a + " - " + b;
605-
} else if (op->is_intrinsic(Call::strict_mul)) {
606-
string a = print_expr(op->args[0]);
607-
string b = print_expr(op->args[1]);
608-
rhs = a + " * " + b;
609-
} else if (op->is_intrinsic(Call::strict_div)) {
610-
string a = print_expr(op->args[0]);
611-
string b = print_expr(op->args[1]);
612-
rhs = a + " / " + b;
613-
} else if (op->is_intrinsic(Call::strict_min)) {
614-
string a = print_expr(op->args[0]);
615-
string b = print_expr(op->args[1]);
616-
rhs = "min(" + a + ", " + b + ")";
617-
} else if (op->is_intrinsic(Call::strict_max)) {
618-
string a = print_expr(op->args[0]);
619-
string b = print_expr(op->args[1]);
620-
rhs = "max(" + a + ", " + b + ")";
621-
} else if (op->is_intrinsic(Call::strict_lt)) {
622-
string a = print_expr(op->args[0]);
623-
string b = print_expr(op->args[1]);
624-
rhs = a + " < " + b;
625-
} else if (op->is_intrinsic(Call::strict_le)) {
626-
string a = print_expr(op->args[0]);
627-
string b = print_expr(op->args[1]);
628-
rhs = a + " <= " + b;
629-
} else if (op->is_intrinsic(Call::strict_eq)) {
630-
string a = print_expr(op->args[0]);
631-
string b = print_expr(op->args[1]);
632-
rhs = a + " == " + b;
633-
} else {
634-
internal_assert(op->is_intrinsic(Call::strict_cast));
635-
rhs = "(" + print_type(op->type) + ")(" + print_expr(op->args[0]) + ")";
636-
}
637-
const string key = "precise:" + rhs;
638-
const auto it = cache.find(key);
639-
if (it == cache.end()) {
640-
id = unique_name('_');
641-
stream << get_indent() << "precise " << print_type(op->type) << " " << id << " = " << rhs << ";\n";
642-
cache[key] = id;
643-
} else {
644-
id = it->second;
645-
}
646585
} else {
647586
CodeGen_GPU_C::visit(op);
648587
}

0 commit comments

Comments
 (0)