[Mesa-dev] [PATCH] i965: Fix brw_regs_equal() for NaN and positive/negative zero.

Kenneth Graunke kenneth at whitecape.org
Tue May 17 23:56:47 UTC 2016


We'd like the comparisons to mean "the exact same bits".  Comparing
doubles won't do that for NaN values or positive vs. negative zero.

Cc: Matt Turner <mattst88 at gmail.com>
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_reg.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_reg.h b/src/mesa/drivers/dri/i965/brw_reg.h
index 71e1024..b0ef94e 100644
--- a/src/mesa/drivers/dri/i965/brw_reg.h
+++ b/src/mesa/drivers/dri/i965/brw_reg.h
@@ -260,6 +260,7 @@ struct brw_reg {
       };
 
       double df;
+      uint64_t u64;
       float f;
       int   d;
       unsigned ud;
@@ -270,7 +271,7 @@ static inline bool
 brw_regs_equal(const struct brw_reg *a, const struct brw_reg *b)
 {
    const bool df = a->type == BRW_REGISTER_TYPE_DF && a->file == IMM;
-   return a->bits == b->bits && (df ? a->df == b->df : a->ud == b->ud);
+   return a->bits == b->bits && (df ? a->u64 == b->u64 : a->ud == b->ud);
 }
 
 struct brw_indirect {
-- 
2.8.2



More information about the mesa-dev mailing list