diff --git a/.pick_status.json b/.pick_status.json index 4ec532e9e31..6e70ca0bcd2 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -463,7 +463,7 @@ "description": "nir/lower_int64: Fix float16 to int64 conversions.", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "936c58c8fcceee086d3c492712595555afe82266" }, diff --git a/src/compiler/nir/nir_lower_int64.c b/src/compiler/nir/nir_lower_int64.c index da393c807c6..26a8b30279a 100644 --- a/src/compiler/nir/nir_lower_int64.c +++ b/src/compiler/nir/nir_lower_int64.c @@ -765,10 +765,15 @@ lower_f2(nir_builder *b, nir_ssa_def *x, bool dst_is_signed) if (dst_is_signed) x = nir_fabs(b, x); - nir_ssa_def *div = nir_imm_floatN_t(b, 1ULL << 32, x->bit_size); - nir_ssa_def *res_hi = nir_f2u32(b, nir_fdiv(b, x, div)); - nir_ssa_def *res_lo = nir_f2u32(b, nir_frem(b, x, div)); - nir_ssa_def *res = nir_pack_64_2x32_split(b, res_lo, res_hi); + nir_ssa_def *res; + if (x->bit_size < 32) { + res = nir_pack_64_2x32_split(b, nir_f2u32(b, x), nir_imm_int(b, 0)); + } else { + nir_ssa_def *div = nir_imm_floatN_t(b, 1ULL << 32, x->bit_size); + nir_ssa_def *res_hi = nir_f2u32(b, nir_fdiv(b, x, div)); + nir_ssa_def *res_lo = nir_f2u32(b, nir_frem(b, x, div)); + res = nir_pack_64_2x32_split(b, res_lo, res_hi); + } if (dst_is_signed) res = nir_bcsel(b, nir_flt(b, x_sign, nir_imm_floatN_t(b, 0, x->bit_size)),