Mesa (master): nir/opcodes: Don' t go through doubles when constant-folding iabs
Jason Ekstrand
jekstrand at kemper.freedesktop.org
Mon Jan 26 21:50:34 UTC 2015
Module: Mesa
Branch: master
Commit: dd74369a0a501be7c772c926c62ab1185bf5996f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dd74369a0a501be7c772c926c62ab1185bf5996f
Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date: Mon Jan 26 09:40:25 2015 -0800
nir/opcodes: Don't go through doubles when constant-folding iabs
Previously, we called the abs() function in math.h. However, this involves
unnecessarily going through double. This commit changes it to use integers
directly with a ternary.
Reviewed-by: Connor Abbott <cwabbott0 at gmail.com>
Reviewed-by: Eric Anholt <eric at anholt.net>
---
src/glsl/nir/nir_opcodes.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/glsl/nir/nir_opcodes.py b/src/glsl/nir/nir_opcodes.py
index 0fa8bf5..f54a017 100644
--- a/src/glsl/nir/nir_opcodes.py
+++ b/src/glsl/nir/nir_opcodes.py
@@ -147,7 +147,7 @@ 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("isign", tint, "(src0 == 0) ? 0 : ((src0 > 0) ? 1 : -1)")
-unop("iabs", tint, "abs(src0)")
+unop("iabs", tint, "(src0 < 0) ? -src0 : src0")
unop("fabs", tfloat, "fabsf(src0)")
unop("fsat", tfloat, "(src0 > 1.0f) ? 1.0f : ((src0 <= 0.0f) ? 0.0f : src0)")
unop("frcp", tfloat, "1.0f / src0")
More information about the mesa-commit
mailing list