From c06dff600b7db7931bdd827c0b661afae516029f Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Sun, 13 Nov 2022 11:28:16 +0100 Subject: [PATCH] r600/sfn: Fix f2u32 and remove backend lowring of f2u64 and f2i64 The two conversion ops are now handled in nir_lower_int64, but the fixup for the input to f2u32 has to be handled there and not in f2u64. Fixes: 29da9856826fa6a4b5117c43c78b4301a49bc6dd nir/lower_int64: Enable lowering of 64-bit float to 64-bit integer conversions. Signed-off-by: Gert Wollny Part-of: (cherry picked from commit fee004215755ee56a427e2ea96a5ab6dfa1ce823) --- .pick_status.json | 2 +- .../drivers/r600/sfn/sfn_nir_lower_64bit.cpp | 22 ++-------------------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index e171636..99afff6 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2056,7 +2056,7 @@ "description": "r600/sfn: Fix f2u32 and remove backend lowring of f2u64 and f2i64", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "29da9856826fa6a4b5117c43c78b4301a49bc6dd" }, diff --git a/src/gallium/drivers/r600/sfn/sfn_nir_lower_64bit.cpp b/src/gallium/drivers/r600/sfn/sfn_nir_lower_64bit.cpp index 6d7b07c..9828802 100644 --- a/src/gallium/drivers/r600/sfn/sfn_nir_lower_64bit.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_nir_lower_64bit.cpp @@ -219,6 +219,7 @@ class LowerSplit64op : public NirLowerInstruction { * rounds, we have to remove the fractional part in the hi bits * For values > UINT_MAX the result is undefined */ auto src = nir_ssa_for_alu_src(b, alu, 0); + src = nir_fsub(b, src, nir_ffract(b, src)); auto gt0 = nir_flt(b, nir_imm_double(b, 0.0), src); auto highval = nir_fmul_imm(b, src, 1.0 / 65536.0); auto fract = nir_ffract(b, highval); @@ -229,26 +230,7 @@ class LowerSplit64op : public NirLowerInstruction { gt0, nir_ior(b, nir_ishl_imm(b, high, 16), low), nir_imm_int(b, 0)); - } - case nir_op_f2i64: { - auto src = nir_ssa_for_alu_src(b, alu, 0); - auto gt0 = nir_flt(b, nir_imm_double(b, 0.0), src); - auto abs_src = nir_fabs(b, src); - auto value = nir_f2u64(b, abs_src); - return nir_bcsel(b, gt0, value, nir_isub(b, nir_imm_zero(b, 1, 64), value)); - } - case nir_op_f2u64: { - auto src = nir_ssa_for_alu_src(b, alu, 0); - auto gt0 = nir_flt(b, nir_imm_double(b, 0.0), src); - auto highval = nir_fmul_imm(b, src, 1.0 / (65536.0 * 65536.0)); - auto fract = nir_ffract(b, highval); - auto high = nir_f2u32(b, nir_fsub(b, highval, fract)); - auto low = nir_f2u32(b, nir_fmul_imm(b, fract, 65536.0 * 65536.0)); - return nir_bcsel(b, - gt0, - nir_pack_64_2x32_split(b, low, high), - nir_imm_zero(b, 1, 64)); - } + } case nir_op_u2f64: { auto src = nir_ssa_for_alu_src(b, alu, 0); auto low = nir_unpack_64_2x32_split_x(b, src); -- 2.7.4