aco/isel: Add documentation for (u)int64->f16 conversion
authorTony Wasserka <tony.wasserka@gmx.de>
Fri, 12 Mar 2021 10:13:51 +0000 (11:13 +0100)
committerMarge Bot <eric+marge@anholt.net>
Fri, 26 Mar 2021 14:39:23 +0000 (14:39 +0000)
The upper 32 bits are truncated before converting, which still produces
correct results since they never meaningfully contribute to the result.

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9597>

src/amd/compiler/aco_instruction_selection.cpp

index 89b1202..b0264b3 100644 (file)
@@ -2450,6 +2450,11 @@ void visit_alu_instr(isel_context *ctx, nir_alu_instr *instr)
             src = convert_int(ctx, bld, src, input_size, target_size, true);
          }
       } else if (input_size == 64) {
+         /* Truncate down to 32 bits; if any of the upper bits are relevant,
+          * the value does not fall into the single-precision float range
+          * anyway. SPIR-V does not mandate any specific behavior for such
+          * large inputs.
+          */
          src = convert_int(ctx, bld, src, 64, 32, false);
       }
 
@@ -2525,6 +2530,11 @@ void visit_alu_instr(isel_context *ctx, nir_alu_instr *instr)
             src = convert_int(ctx, bld, src, input_size, target_size, false);
          }
       } else if (input_size == 64) {
+         /* Truncate down to 32 bits; if any of the upper bits are non-zero,
+          * the value does not fall into the single-precision float range
+          * anyway. SPIR-V does not mandate any specific behavior for such
+          * large inputs.
+          */
          src = convert_int(ctx, bld, src, 64, 32, false);
       }