[Mesa-dev] [PATCH 08/13] i965: do not memcmp to check if brw_regs are equal

Emil Velikov emil.l.velikov at gmail.com
Thu Nov 5 08:17:56 PST 2015


From: Emil Velikov <emil.velikov at collabora.co.uk>

As of last commit one can easily the whole brw_reg as two unsigned
values. Lets use that and avoid the nastylooking memcmp + casts.

XXX: reladdr looks a bit strange. we tend to do dst_reg<>src_reg and in
some cases this might cause someheadaches. should we zero it in the
respective ctors ?

Signed-off-by: Emil Velikov <emil.velikov at collabora.co.uk>
---
 src/mesa/drivers/dri/i965/brw_fs.cpp   |  3 ++-
 src/mesa/drivers/dri/i965/brw_vec4.cpp | 10 ++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 46941ae..0ee6ffc 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -391,7 +391,8 @@ fs_reg::fs_reg(struct brw_reg reg) :
 bool
 fs_reg::equals(const fs_reg &r) const
 {
-   return (memcmp((brw_reg *)this, (brw_reg *)&r, sizeof(brw_reg)) == 0 &&
+   return (v == r.v &&
+           d == r.d &&
            reg_offset == r.reg_offset &&
            subreg_offset == r.subreg_offset &&
            !reladdr && !r.reladdr &&
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index e348f17..db662d3 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -128,7 +128,8 @@ dst_reg::dst_reg(const src_reg &reg) :
 bool
 dst_reg::equals(const dst_reg &r) const
 {
-   return (memcmp((brw_reg *)this, (brw_reg *)&r, sizeof(brw_reg)) == 0 &&
+   return (v == r.v &&
+           d == r.d &&
            reg_offset == r.reg_offset &&
            (reladdr == r.reladdr ||
             (reladdr && r.reladdr && reladdr->equals(*r.reladdr))));
@@ -265,9 +266,10 @@ vec4_visitor::implied_mrf_writes(vec4_instruction *inst)
 bool
 src_reg::equals(const src_reg &r) const
 {
-   return (memcmp((brw_reg *)this, (brw_reg *)&r, sizeof(brw_reg)) == 0 &&
-	   reg_offset == r.reg_offset &&
-	   !reladdr && !r.reladdr);
+   return (v == r.v &&
+           d == r.d &&
+           reg_offset == r.reg_offset &&
+           !reladdr && !r.reladdr);
 }
 
 bool
-- 
2.6.2



More information about the mesa-dev mailing list