[Mesa-dev] [PATCH 3/5] i965/vs: Add src_reg::negative_equals method
Ian Romanick
idr at freedesktop.org
Wed Apr 8 16:38:29 PDT 2015
From: Ian Romanick <ian.d.romanick at intel.com>
This method is similar to the existing ::equals method. Instead of
testing that two src_regs are equal to each other, it tests that one is
the negation of the other.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/mesa/drivers/dri/i965/brw_ir_vec4.h | 1 +
src/mesa/drivers/dri/i965/brw_vec4.cpp | 43 +++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/src/mesa/drivers/dri/i965/brw_ir_vec4.h b/src/mesa/drivers/dri/i965/brw_ir_vec4.h
index d3bd64d..449795a 100644
--- a/src/mesa/drivers/dri/i965/brw_ir_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_ir_vec4.h
@@ -49,6 +49,7 @@ public:
src_reg(struct brw_reg reg);
bool equals(const src_reg &r) const;
+ bool negative_equals(const src_reg &r) const;
src_reg(class vec4_visitor *v, const struct glsl_type *type);
src_reg(class vec4_visitor *v, const struct glsl_type *type, int size);
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index ef2fd40..d5286c2 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -328,6 +328,49 @@ src_reg::equals(const src_reg &r) const
}
bool
+src_reg::negative_equals(const src_reg &r) const
+{
+ if (file != r.file)
+ return false;
+
+ if (file == IMM) {
+ if (!(reg == r.reg &&
+ reg_offset == r.reg_offset &&
+ type == r.type &&
+ negate == r.negate &&
+ abs == r.abs &&
+ swizzle == r.swizzle &&
+ !reladdr && !r.reladdr))
+ return false;
+
+ switch (fixed_hw_reg.type) {
+ case BRW_REGISTER_TYPE_F:
+ return memcmp(&fixed_hw_reg, &r.fixed_hw_reg,
+ sizeof(fixed_hw_reg) - sizeof(fixed_hw_reg.dw1)) == 0 &&
+ fixed_hw_reg.dw1.f == -r.fixed_hw_reg.dw1.f;
+
+ case BRW_REGISTER_TYPE_D:
+ return memcmp(&fixed_hw_reg, &r.fixed_hw_reg,
+ sizeof(fixed_hw_reg) - sizeof(fixed_hw_reg.dw1)) == 0 &&
+ fixed_hw_reg.dw1.d == -r.fixed_hw_reg.dw1.d;
+
+ default:
+ return false;
+ }
+ } else {
+ return reg == r.reg &&
+ reg_offset == r.reg_offset &&
+ type == r.type &&
+ negate != r.negate &&
+ abs == r.abs &&
+ swizzle == r.swizzle &&
+ !reladdr && !r.reladdr &&
+ memcmp(&fixed_hw_reg, &r.fixed_hw_reg,
+ sizeof(fixed_hw_reg)) == 0;
+ }
+}
+
+bool
vec4_visitor::opt_vector_float()
{
bool progress = false;
--
2.1.0
More information about the mesa-dev
mailing list