nir: replace lower_ldexp with has_ldexp

I can be bothered to fix all the backends that don't set lower_ldexp,
and only two backends have ldexp anyway.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33900>
This commit is contained in:
Georg Lehmann 2026-03-20 09:11:54 +01:00 committed by Marge Bot
parent fd556e54f6
commit ec331cc48a
25 changed files with 11 additions and 27 deletions

View file

@ -65,7 +65,8 @@ void ac_nir_set_options(const struct ac_compiler_info *info, bool use_llvm,
options->lower_iadd_sat = info->gfx_level <= GFX8;
options->lower_hadd = true;
options->lower_mul_32x16 = true;
options->lower_bfloat16_conversions = true,
options->lower_bfloat16_conversions = true;
options->has_ldexp = true;
options->has_bfe = true;
options->has_bfm = true;
options->has_bitfield_select = true;

View file

@ -369,7 +369,6 @@ static const nir_shader_compiler_options agx_nir_options = {
.lower_fminmax_signed_zero = true,
.lower_fdph = true,
.lower_ffract = true,
.lower_ldexp = true,
.lower_pack_half_2x16 = true,
.lower_pack_unorm_2x16 = true,
.lower_pack_snorm_2x16 = true,

View file

@ -196,7 +196,6 @@ v3dv_pipeline_get_nir_options(const struct v3d_device_info *devinfo)
.lower_fsqrt = true,
.lower_ifind_msb = true,
.lower_isign = true,
.lower_ldexp = true,
.lower_mul_high = true,
.lower_wpos_pntc = false,
.lower_to_scalar = true,

View file

@ -3164,9 +3164,9 @@ def ldexp(f, exp, bits):
return ('!fmul', ('!fmul', f, pow2_1), pow2_2)
optimizations += [
(('ldexp@16', 'x', 'exp'), ldexp('x', 'exp', 16), 'options->lower_ldexp', TestStatus.UNSUPPORTED), # All test inputs skipped.
(('ldexp@32', 'x', 'exp'), ldexp('x', 'exp', 32), 'options->lower_ldexp', TestStatus.UNSUPPORTED), # All test inputs skipped.
(('ldexp@64', 'x', 'exp'), ldexp('x', 'exp', 64), 'options->lower_ldexp', TestStatus.UNSUPPORTED), # All test inputs skipped.
(('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.
]
# XCOM 2 (OpenGL) open-codes bitfieldReverse()

View file

@ -343,8 +343,6 @@ typedef struct nir_shader_compiler_options {
*/
bool lower_fround_even;
bool lower_ldexp;
bool lower_pack_half_2x16;
bool lower_pack_unorm_2x16;
bool lower_pack_snorm_2x16;
@ -540,6 +538,9 @@ typedef struct nir_shader_compiler_options {
/* Lowers when 32x32->64 bit multiplication is not supported */
bool lower_mul_2x32_64;
/* Indicates that ldexp is supported. */
bool has_ldexp;
/* Indicates that urol and uror are supported */
bool has_rotate8;
bool has_rotate16;

View file

@ -691,7 +691,7 @@ handle_special(struct vtn_builder *b, uint32_t opcode,
case OpenCLstd_Native_tan:
return nir_ftan(nb, srcs[0]);
case OpenCLstd_Ldexp:
if (nb->shader->options->lower_ldexp)
if (!nb->shader->options->has_ldexp)
break;
return nir_ldexp(nb, srcs[0], srcs[1]);
case OpenCLstd_Fma: {

View file

@ -125,7 +125,6 @@ static const nir_shader_compiler_options ir3_base_options = {
.lower_fmod = true,
.lower_fdiv = true,
.lower_isign = true,
.lower_ldexp = true,
.lower_uadd_carry = true,
.lower_usub_borrow = true,
.lower_mul_high = true,

View file

@ -47,7 +47,6 @@ etna_compiler_create(const char *renderer, const struct etna_core_info *info)
.fuse_ffma64 = true,
.lower_uadd_carry = true,
.lower_usub_borrow = true,
.lower_ldexp = true,
.lower_mul_high = true,
.lower_bitops = true,
.lower_flrp32 = true,

View file

@ -144,7 +144,6 @@ static const struct nir_shader_compiler_options gallivm_nir_options = {
.lower_uadd_sat = true,
.lower_usub_sat = true,
.lower_iadd_sat = true,
.lower_ldexp = true,
.lower_pack_snorm_2x16 = true,
.lower_pack_snorm_4x8 = true,
.lower_pack_unorm_2x16 = true,

View file

@ -498,7 +498,6 @@ static const struct nir_shader_compiler_options gallivm_nir_options = {
.lower_uadd_sat = true,
.lower_usub_sat = true,
.lower_iadd_sat = true,
.lower_ldexp = true,
.lower_pack_snorm_2x16 = true,
.lower_pack_snorm_4x8 = true,
.lower_pack_unorm_2x16 = true,

View file

@ -3590,7 +3590,6 @@ nvir_nir_shader_compiler_options(int chipset, uint8_t shader_type)
op.lower_ffract = true;
op.lower_fceil = false; // TODO
op.lower_ftrunc = false;
op.lower_ldexp = true;
op.lower_pack_half_2x16 = true;
op.lower_pack_unorm_2x16 = true;
op.lower_pack_snorm_2x16 = true;

View file

@ -1104,7 +1104,6 @@ bool r600_common_screen_init(struct r600_common_screen *rscreen,
.lower_extract_word = true,
.lower_insert_byte = true,
.lower_insert_word = true,
.lower_ldexp = true,
/* due to a bug in the shader compiler, some loops hang
* if they are not unrolled, see:
* https://bugs.freedesktop.org/show_bug.cgi?id=86720

View file

@ -139,7 +139,6 @@ get_bool_cap(struct svga_winsys_screen *sws, SVGA3dDevCapIndex cap,
.lower_int64_options = nir_lower_imul_2x32_64 | nir_lower_divmod64, \
.lower_fdph = true, \
.lower_flrp64 = true, \
.lower_ldexp = true, \
.lower_uniforms_to_ubo = true, \
.lower_cs_local_index_to_id = true, \
.max_unroll_iterations = 32

View file

@ -590,7 +590,6 @@ v3d_screen_get_compiler_options(struct pipe_screen *pscreen,
.lower_fsqrt = true,
.lower_ifind_msb = true,
.lower_isign = true,
.lower_ldexp = true,
.lower_hadd = true,
.lower_fisnormal = true,
.lower_mul_high = true,

View file

@ -2148,7 +2148,6 @@ static const nir_shader_compiler_options nir_options = {
.lower_fpow = true,
.lower_fsat = true,
.lower_fsqrt = true,
.lower_ldexp = true,
.lower_fneg = true,
.lower_ineg = true,
.lower_to_scalar = true,

View file

@ -1068,7 +1068,6 @@ virgl_create_screen(struct virgl_winsys *vws, const struct pipe_screen_config *c
screen->compiler_options.no_integers = screen->caps.caps.v1.glsl_level < 130;
screen->compiler_options.lower_ffma32 = true;
screen->compiler_options.fuse_ffma32 = false;
screen->compiler_options.lower_ldexp = true;
screen->compiler_options.lower_image_offset_to_range_base = true;
screen->compiler_options.lower_atomic_offset_to_range_base = true;
screen->compiler_options.support_indirect_outputs = BITFIELD_BIT(MESA_SHADER_TESS_CTRL);

View file

@ -1287,7 +1287,7 @@ zink_screen_init_compiler(struct zink_screen *screen)
* effectively unused (no instances in shader-db), it's not worth the
* effort to do so.
* */
.lower_ldexp = true,
.has_ldexp = false,
.lower_mul_high = true,
.lower_to_scalar = true,

View file

@ -54,7 +54,6 @@ static const nir_shader_compiler_options nir_options = {
.lower_fsqrt = true,
.lower_ftrunc = true,
.lower_ifind_msb = true,
.lower_ldexp = true,
.lower_layer_fs_input_to_sysval = true,
.lower_uadd_carry = true,
.lower_uadd_sat = true,

View file

@ -46,7 +46,6 @@ const struct nir_shader_compiler_options brw_scalar_nir_options = {
.lower_insert_word = true,
.lower_isign = true,
.lower_layer_fs_input_to_sysval = true,
.lower_ldexp = true,
.lower_pack_half_2x16 = true,
.lower_pack_snorm_2x16 = true,
.lower_pack_snorm_4x8 = true,

View file

@ -22,7 +22,6 @@
.lower_fisnormal = true, \
.lower_fquantize2f16 = true, \
.lower_isign = true, \
.lower_ldexp = true, \
.lower_bitfield_extract = true, \
.lower_bitfield_insert = true, \
.lower_device_index_to_zero = true, \

View file

@ -629,7 +629,6 @@ static const struct nir_shader_compiler_options draw_nir_options = {
.lower_uadd_sat = true,
.lower_usub_sat = true,
.lower_iadd_sat = true,
.lower_ldexp = true,
.lower_pack_snorm_2x16 = true,
.lower_pack_snorm_4x8 = true,
.lower_pack_unorm_2x16 = true,

View file

@ -100,7 +100,6 @@ nir_options = {
.lower_fmod = true,
.lower_fpow = true,
.lower_scmp = true,
.lower_ldexp = true,
.lower_flrp16 = true,
.lower_flrp32 = true,
.lower_flrp64 = true,

View file

@ -161,7 +161,6 @@ fn nir_options(dev: &nv_device_info) -> nir_shader_compiler_options {
| nir_lower_conv64)
| if dev.sm < 70 { nir_lower_vote_ieq64 } else { 0 }
| if dev.sm < 32 { nir_lower_shift64 } else { 0 },
lower_ldexp: true,
lower_fmod: true,
lower_ffract: true,
lower_fpow: true,

View file

@ -148,6 +148,7 @@ valhal_writes_extended_fifo(uint64_t outputs_written,
.lower_uadd_carry = true, \
.lower_usub_borrow = true, \
\
.has_ldexp = true, \
.has_isub = true, \
.vectorize_vec2_16bit = true, \
.fuse_ffma16 = true, \

View file

@ -62,7 +62,6 @@ static const nir_shader_compiler_options midgard_nir_options = {
.lower_extract_word = true,
.lower_insert_byte = true,
.lower_insert_word = true,
.lower_ldexp = true,
.lower_pack_half_2x16 = true,
.lower_pack_unorm_2x16 = true,