ac/llvm: add option to clamp division by zero

Replace div(x) by min(div(x), FLT_MAX)) to avoid getting a NaN result
when x is 0.

A cheaper alternative would be to use legacy mult instructions but they're
not exposed by LLVM.

Cc: mesa-stable
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6259>
This commit is contained in:
Pierre-Eric Pelloux-Prayer
2020-08-11 18:52:24 +02:00
parent f8c0e20152
commit 32f46a55c8
2 changed files with 10 additions and 1 deletions

View File

@@ -192,6 +192,9 @@ struct ac_shader_abi {
/* Whether undef values must be converted to zero */
bool convert_undef_to_zero;
/* Clamp div by 0 (so it won't produce NaN) */
bool clamp_div_by_zero;
};
#endif /* AC_SHADER_ABI_H */