ac/llvm: fix 16-bit fmed3 on GFX8 and older gens
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 26 Feb 2020 14:09:40 +0000 (15:09 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 27 Feb 2020 07:04:30 +0000 (08:04 +0100)
16-bit med3 is only supported on GFX9+.

Fixes dEQP-VK.spirv_assembly.instruction.amd_trinary_minmax.mid3.f16.*.

Fixes: d6a07732c9c ("ac: use llvm.amdgcn.fmed3 intrinsic for nir_op_fmed3")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3962>

src/amd/llvm/ac_llvm_build.c

index db7964d6aa9315e1cf2c509b9c84f301672f87c4..116abf942c23adc2a88d96441e6f2d50d6ed9650 100644 (file)
@@ -2725,8 +2725,10 @@ LLVMValueRef ac_build_fmed3(struct ac_llvm_context *ctx, LLVMValueRef src0,
 {
        LLVMValueRef result;
 
-       if (bitsize == 64) {
-               /* Lower 64-bit fmed because LLVM doesn't expose an intrinsic. */
+       if (bitsize == 64 || (bitsize == 16 && ctx->chip_class <= GFX8)) {
+               /* Lower 64-bit fmed because LLVM doesn't expose an intrinsic,
+                * or lower 16-bit fmed because it's only supported on GFX9+.
+                */
                LLVMValueRef min1, min2, max1;
 
                min1 = ac_build_fmin(ctx, src0, src1);