Mesa (master): gallivm: Use GALLIVM_NAN_RETURN_OTHER_SECOND_NONNAN for norm clamping

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue May 4 00:36:48 UTC 2021


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

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Wed Apr 28 15:34:13 2021 -0700

gallivm: Use GALLIVM_NAN_RETURN_OTHER_SECOND_NONNAN for norm clamping

Since the second source is always a constant that is known to be a
number, this should have the same performance as
GALLIVM_NAN_BEHAVIOR_UNDEFINED.

A lofty goal is to eventually remove GALLIVM_NAN_BEHAVIOR_UNDEFINED.
There's still a lot of (mostly implicit) users, and I don't feel like
tackling that right now. :)

Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10532>

---

 src/gallium/auxiliary/gallivm/lp_bld_arit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
index cdbe52c8603..a3152c242a4 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
@@ -524,7 +524,7 @@ lp_build_add(struct lp_build_context *bld,
 
    /* clamp to ceiling of 1.0 */
    if(bld->type.norm && (bld->type.floating || bld->type.fixed))
-      res = lp_build_min_simple(bld, res, bld->one, GALLIVM_NAN_BEHAVIOR_UNDEFINED);
+      res = lp_build_min_simple(bld, res, bld->one, GALLIVM_NAN_RETURN_OTHER_SECOND_NONNAN);
 
    if (type.norm && !type.floating && !type.fixed) {
       if (!type.sign) {
@@ -859,7 +859,7 @@ lp_build_sub(struct lp_build_context *bld,
          res = LLVMBuildSub(builder, a, b, "");
 
    if(bld->type.norm && (bld->type.floating || bld->type.fixed))
-      res = lp_build_max_simple(bld, res, bld->zero, GALLIVM_NAN_BEHAVIOR_UNDEFINED);
+      res = lp_build_max_simple(bld, res, bld->zero, GALLIVM_NAN_RETURN_OTHER_SECOND_NONNAN);
 
    return res;
 }



More information about the mesa-commit mailing list