Mesa (master): nir: Remove series of unnecessary conversions
Matt Turner
mattst88 at kemper.freedesktop.org
Tue Aug 29 22:21:06 UTC 2017
Module: Mesa
Branch: master
Commit: 50e4099edff93b666325e4ba7e607eafc29d2e92
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=50e4099edff93b666325e4ba7e607eafc29d2e92
Author: Matt Turner <mattst88 at gmail.com>
Date: Fri Aug 25 20:15:24 2017 -0700
nir: Remove series of unnecessary conversions
Clang warns:
warning: absolute value function 'fabsf' given an argument of type
'const float64_t' (aka 'const double') but has parameter of type 'float'
which may cause truncation of value [-Wabsolute-value]
float64_t dst = bit_size == 64 ? fabs(src0) : fabsf(src0);
The type of the ternary expression will be the common type of fabs() and
fabsf(): double. So fabsf(src0) will be implicitly converted to double.
We may as well just convert src0 to double before a call to fabs() and
remove the needless complexity, à la
float64_t dst = fabs(src0);
Reviewed-by: Emil Velikov <emil.velikov at collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>
---
src/compiler/nir/nir_opcodes.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py
index 39c01a702f..06ae820c3e 100644
--- a/src/compiler/nir/nir_opcodes.py
+++ b/src/compiler/nir/nir_opcodes.py
@@ -156,7 +156,7 @@ unop("fsign", tfloat, ("bit_size == 64 ? " +
"((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("fabs", tfloat, "fabs(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))"))
More information about the mesa-commit
mailing list