ac/llvm: add option to clamp division by zero
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Tue, 11 Aug 2020 16:52:24 +0000 (18:52 +0200)
committerPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Wed, 2 Sep 2020 09:53:16 +0000 (11:53 +0200)
commit32f46a55c8229b2a8d67d895be18651a81f8e6ff
tree2cf21b96a0a0a0b0428fc318e18a04dddaa7b0bd
parentf8c0e20152b7f3f0b8d881648083a271ca528c28
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>
src/amd/llvm/ac_nir_to_llvm.c
src/amd/llvm/ac_shader_abi.h