mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-29 02:00:37 +02:00
nir: check inf/nan/sz preserve per-instruction
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27281>
This commit is contained in:
parent
750bd9757e
commit
08df0c7dde
3 changed files with 15 additions and 7 deletions
|
|
@ -231,7 +231,7 @@ nir_atan(nir_builder *b, nir_def *y_over_x)
|
|||
* !isnan(y_over_x) ? ... : y_over_x;
|
||||
*/
|
||||
if (b->exact ||
|
||||
nir_is_float_control_signed_zero_inf_nan_preserve(b->shader->info.float_controls_execution_mode, bit_size)) {
|
||||
nir_is_float_control_signed_zero_inf_nan_preserve(b->fp_fast_math, bit_size)) {
|
||||
const bool exact = b->exact;
|
||||
|
||||
b->exact = true;
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ get_signed_inf(nir_builder *b, nir_def *zero)
|
|||
static nir_def *
|
||||
get_signed_zero(nir_builder *b, nir_def *src)
|
||||
{
|
||||
uint32_t exec_mode = b->shader->info.float_controls_execution_mode;
|
||||
uint32_t exec_mode = b->fp_fast_math;
|
||||
|
||||
nir_def *zero;
|
||||
if (nir_is_float_control_signed_zero_preserve(exec_mode, 64)) {
|
||||
|
|
@ -104,7 +104,7 @@ get_signed_zero(nir_builder *b, nir_def *src)
|
|||
static nir_def *
|
||||
preserve_nan(nir_builder *b, nir_def *src, nir_def *res)
|
||||
{
|
||||
uint32_t exec_mode = b->shader->info.float_controls_execution_mode;
|
||||
uint32_t exec_mode = b->fp_fast_math;
|
||||
|
||||
if (nir_is_float_control_nan_preserve(exec_mode, 64)) {
|
||||
nir_def *is_nan = nir_fneu(b, src, src);
|
||||
|
|
@ -316,15 +316,20 @@ lower_sqrt_rsq(nir_builder *b, nir_def *src, bool sqrt)
|
|||
res = nir_ffma(b, y_1, r_1, y_1);
|
||||
}
|
||||
|
||||
uint32_t exec_mode = b->shader->info.float_controls_execution_mode;
|
||||
uint32_t exec_mode = b->fp_fast_math;
|
||||
if (sqrt) {
|
||||
/* Here, the special cases we need to handle are
|
||||
* 0 -> 0 and
|
||||
* 0 -> 0 (sign preserving)
|
||||
* +inf -> +inf
|
||||
* -inf -> NaN
|
||||
* NaN -> NaN
|
||||
*/
|
||||
/* Denorm flushing/preserving isn't part of the per-instruction bits, so
|
||||
* check the execution mode for it.
|
||||
*/
|
||||
uint32_t shader_exec_mode = b->shader->info.float_controls_execution_mode;
|
||||
nir_def *src_flushed = src;
|
||||
if (!nir_is_denorm_preserve(exec_mode, 64)) {
|
||||
if (!nir_is_denorm_preserve(shader_exec_mode, 64)) {
|
||||
src_flushed = nir_bcsel(b,
|
||||
nir_flt_imm(b, nir_fabs(b, src), DBL_MIN),
|
||||
get_signed_zero(b, src),
|
||||
|
|
@ -778,6 +783,9 @@ lower_doubles_instr(nir_builder *b, nir_instr *instr, void *_data)
|
|||
const nir_lower_doubles_options options = data->options;
|
||||
nir_alu_instr *alu = nir_instr_as_alu(instr);
|
||||
|
||||
/* Easier to set it here than pass it around all over ther place. */
|
||||
b->fp_fast_math = alu->fp_fast_math;
|
||||
|
||||
nir_def *soft_def =
|
||||
lower_doubles_instr_to_soft(b, alu, data->softfp64, options);
|
||||
if (soft_def)
|
||||
|
|
|
|||
|
|
@ -846,7 +846,7 @@ nir_algebraic_instr(nir_builder *build, nir_instr *instr,
|
|||
const unsigned execution_mode =
|
||||
build->shader->info.float_controls_execution_mode;
|
||||
const bool ignore_inexact =
|
||||
nir_is_float_control_signed_zero_inf_nan_preserve(execution_mode, bit_size) ||
|
||||
nir_is_float_control_signed_zero_inf_nan_preserve(alu->fp_fast_math, bit_size) ||
|
||||
nir_is_denorm_flush_to_zero(execution_mode, bit_size);
|
||||
|
||||
int xform_idx = *util_dynarray_element(states, uint16_t,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue