Mesa (master): nir: handle double-precision in fabs, frsq and fsqrt

Iago Toral Quiroga itoral at kemper.freedesktop.org
Mon May 23 06:58:44 UTC 2016


Module: Mesa
Branch: master
Commit: 3f73039adec1fb0f35a98c05f5622e74baf93a12
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3f73039adec1fb0f35a98c05f5622e74baf93a12

Author: Iago Toral Quiroga <itoral at igalia.com>
Date:   Fri May 20 09:12:28 2016 +0200

nir: handle double-precision in fabs, frsq and fsqrt

Reviewed-by: Matt Turner <mattst88 at gmail.com>

---

 src/compiler/nir/nir_opcodes.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py
index 8a3a80f..8ecf7b9 100644
--- a/src/compiler/nir/nir_opcodes.py
+++ b/src/compiler/nir/nir_opcodes.py
@@ -153,11 +153,11 @@ 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("isign", tint, "(src0 == 0) ? 0 : ((src0 > 0) ? 1 : -1)")
 unop("iabs", tint, "(src0 < 0) ? -src0 : src0")
-unop("fabs", tfloat, "fabsf(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("frsq", tfloat, "1.0f / sqrtf(src0)")
-unop("fsqrt", tfloat, "sqrtf(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)")
 unop("flog2", tfloat, "log2f(src0)")
 unop_convert("f2i", tint32, tfloat32, "src0") # Float-to-integer conversion.




More information about the mesa-commit mailing list