diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index fd118a4666c..aa9999034cf 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -1507,7 +1507,7 @@ optimizations.extend([ # Vulkan allows us to use any rounding mode, so choose rtz because it's simple. # Avoid some NaNs being converted to Inf if the lsb are cut off. - (('f2bf', a), ('bcsel', ('fneu(preserve_nan_inf)', a, a), -1, ('unpack_32_2x16_split_y', a)), 'options->lower_bfloat16_conversions', TestStatus.UNSUPPORTED), # all test inputs skipped + (('f2bf', a), ('bcsel', ('fneu(preserve_nan_inf)', a, a), -1, ('unpack_32_2x16_split_y', a)), 'options->lower_bfloat16_conversions'), (('bf2f', a), ('pack_32_2x16', ('vec2', 0, a)), 'options->lower_bfloat16_conversions'), ]) @@ -3195,9 +3195,9 @@ def ldexp(f, exp, bits): return ('!fmul', ('!fmul', f, pow2_1), pow2_2) optimizations += [ - (('ldexp@16', 'x', 'exp'), ldexp('x', 'exp', 16), '!options->has_ldexp', TestStatus.UNSUPPORTED), # All test inputs skipped. - (('ldexp@32', 'x', 'exp'), ldexp('x', 'exp', 32), '!options->has_ldexp', TestStatus.UNSUPPORTED), # All test inputs skipped. - (('ldexp@64', 'x', 'exp'), ldexp('x', 'exp', 64), '!options->has_ldexp', TestStatus.UNSUPPORTED), # All test inputs skipped. + (('ldexp@16', 'x', 'exp'), ldexp('x', 'exp', 16), '!options->has_ldexp'), + (('ldexp@32', 'x', 'exp'), ldexp('x', 'exp', 32), '!options->has_ldexp'), + (('ldexp@64', 'x', 'exp'), ldexp('x', 'exp', 64), '!options->has_ldexp'), (('fexp2(contract)', ('i2f', 'a@8')), ('ldexp', 1.0, ('i2i32', a)), 'options->has_ldexp'), (('fexp2(contract)', ('i2f', 'a@16')), ('ldexp', 1.0, ('i2i32', a)), 'options->has_ldexp'), (('fexp2(contract)', ('i2f', 'a@32')), ('ldexp', 1.0, a), 'options->has_ldexp'), diff --git a/src/compiler/nir/tests/nir_algebraic_pattern_test.cpp b/src/compiler/nir/tests/nir_algebraic_pattern_test.cpp index 92dc1878b47..199a073d4db 100644 --- a/src/compiler/nir/tests/nir_algebraic_pattern_test.cpp +++ b/src/compiler/nir/tests/nir_algebraic_pattern_test.cpp @@ -237,11 +237,14 @@ nir_algebraic_pattern_test::skip_test(nir_alu_instr *alu, uint32_t bit_size, nir_const_value tmp, int32_t src_index) { /* Always pass the test for signed zero/nan/inf sources if they are not preserved. */ - if (bit_size >= 16) { + const nir_op_info *info = &nir_op_infos[alu->op]; + nir_alu_type type = src_index >= 0 ? info->input_types[src_index] : info->output_type; + if (bit_size >= 16 && nir_alu_type_get_base_type(type) == nir_type_float) { double val = nir_const_value_as_float(tmp, bit_size); - if ((!exact || !(fp_math_ctrl & nir_fp_preserve_nan)) && isnan(val)) + unsigned ctrl = fp_math_ctrl | ~info->valid_fp_math_ctrl; + if ((!exact || !(ctrl & nir_fp_preserve_nan)) && isnan(val)) return true; - if ((!exact || !(fp_math_ctrl & nir_fp_preserve_inf)) && isinf(val)) + if ((!exact || !(ctrl & nir_fp_preserve_inf)) && isinf(val)) return true; }