From 38b719d6244e831effe93a5d10e932aad2100984 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Fri, 20 May 2016 09:38:20 +0200 Subject: [PATCH] nir: handle double-precision in fsign, fsat, fnot and frcp I think these are not strictly necessary since the floats in them should be automatically promoted to doubles when operated with double sources, but it makes things more explicit at least. Reviewed-by: Matt Turner --- src/compiler/nir/nir_opcodes.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py index 8ecf7b96a1b..15066c2b580 100644 --- a/src/compiler/nir/nir_opcodes.py +++ b/src/compiler/nir/nir_opcodes.py @@ -149,13 +149,18 @@ unop("imov", tint, "src0") unop("ineg", tint, "-src0") unop("fneg", tfloat, "-src0") unop("inot", tint, "~src0") # invert every bit of the integer -unop("fnot", tfloat, "(src0 == 0.0f) ? 1.0f : 0.0f") -unop("fsign", tfloat, "(src0 == 0.0f) ? 0.0f : ((src0 > 0.0f) ? 1.0f : -1.0f)") +unop("fnot", tfloat, ("bit_size == 64 ? ((src0 == 0.0) ? 1.0 : 0.0f) : " + + "((src0 == 0.0f) ? 1.0f : 0.0f)")) +unop("fsign", tfloat, ("bit_size == 64 ? " + + "((src0 == 0.0) ? 0.0 : ((src0 > 0.0) ? 1.0 : -1.0)) : " + + "((src0 == 0.0f) ? 0.0f : ((src0 > 0.0f) ? 1.0f : -1.0f))")) unop("isign", tint, "(src0 == 0) ? 0 : ((src0 > 0) ? 1 : -1)") unop("iabs", tint, "(src0 < 0) ? -src0 : src0") unop("fabs", tfloat, "bit_size == 64 ? fabs(src0) : fabsf(src0)") -unop("fsat", tfloat, "(src0 > 1.0f) ? 1.0f : ((src0 <= 0.0f) ? 0.0f : src0)") -unop("frcp", tfloat, "1.0f / src0") +unop("fsat", tfloat, ("bit_size == 64 ? " + + "((src0 > 1.0) ? 1.0 : ((src0 <= 0.0) ? 0.0 : src0)) : " + + "((src0 > 1.0f) ? 1.0f : ((src0 <= 0.0f) ? 0.0f : src0))")) +unop("frcp", tfloat, "bit_size == 64 ? 1.0 / src0 : 1.0f / src0") unop("frsq", tfloat, "bit_size == 64 ? 1.0 / sqrt(src0) : 1.0f / sqrtf(src0)") unop("fsqrt", tfloat, "bit_size == 64 ? sqrt(src0) : sqrtf(src0)") unop("fexp2", tfloat, "exp2f(src0)") -- 2.30.2