[Beignet] [PATCH V2] Multiple register's hstride in suboffset.

Yang Rong rong.r.yang at intel.com
Mon Jan 27 19:03:15 PST 2014


When register's hstride is not 0 or 1, suboffset will get wrong element.
Also change some offsets that already multiple hstride by hard code.

Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
 backend/src/backend/gen_context.cpp  | 26 +++++++++++++-------------
 backend/src/backend/gen_encoder.cpp  |  4 ++--
 backend/src/backend/gen_register.hpp |  2 +-
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/backend/src/backend/gen_context.cpp b/backend/src/backend/gen_context.cpp
index 893de34..9cbe60b 100644
--- a/backend/src/backend/gen_context.cpp
+++ b/backend/src/backend/gen_context.cpp
@@ -208,7 +208,7 @@ namespace gbe
           p->curr.chooseNib(i);
           p->MOV(xdst, xsrc);
           xdst = GenRegister::suboffset(xdst, 4);
-          xsrc = GenRegister::suboffset(xsrc, 8);
+          xsrc = GenRegister::suboffset(xsrc, 4);
         }
         p->pop();
         break;
@@ -1207,10 +1207,10 @@ namespace gbe
     p->curr.predicate = GEN_PREDICATE_NONE;
     p->curr.execWidth = 8;
     p->MOV(dest, src);
-    p->MOV(GenRegister::suboffset(dest, 4), GenRegister::suboffset(src, 8));
+    p->MOV(GenRegister::suboffset(dest, 4), GenRegister::suboffset(src, 4));
     if (execWidth == 16) {
-      p->MOV(GenRegister::suboffset(dest, 8), GenRegister::suboffset(src, 16));
-      p->MOV(GenRegister::suboffset(dest, 12), GenRegister::suboffset(src, 24));
+      p->MOV(GenRegister::suboffset(dest, 8), GenRegister::suboffset(src, 8));
+      p->MOV(GenRegister::suboffset(dest, 12), GenRegister::suboffset(src, 12));
     }
     p->pop();
   }
@@ -1222,13 +1222,13 @@ namespace gbe
     p->curr.execWidth = 8;
     p->MOV(dest, src);
     p->curr.nibControl = 1;
-    p->MOV(GenRegister::suboffset(dest, 8), GenRegister::suboffset(src, 4));
+    p->MOV(GenRegister::suboffset(dest, 4), GenRegister::suboffset(src, 4));
     if (execWidth == 16) {
       p->curr.quarterControl = 1;
       p->curr.nibControl = 0;
-      p->MOV(GenRegister::suboffset(dest, 16), GenRegister::suboffset(src, 8));
+      p->MOV(GenRegister::suboffset(dest, 8), GenRegister::suboffset(src, 8));
       p->curr.nibControl = 1;
-      p->MOV(GenRegister::suboffset(dest, 24), GenRegister::suboffset(src, 12));
+      p->MOV(GenRegister::suboffset(dest, 12), GenRegister::suboffset(src, 12));
     }
     p->pop();
   }
@@ -1240,10 +1240,10 @@ namespace gbe
     p->curr.predicate = GEN_PREDICATE_NONE;
     p->curr.execWidth = 8;
     p->MOV(dest, src);
-    p->MOV(GenRegister::suboffset(dest, 4), GenRegister::suboffset(src, 8));
+    p->MOV(GenRegister::suboffset(dest, 4), GenRegister::suboffset(src, 4));
     if (execWidth == 16) {
-      p->MOV(GenRegister::suboffset(dest, 8), GenRegister::suboffset(src, 16));
-      p->MOV(GenRegister::suboffset(dest, 12), GenRegister::suboffset(src, 24));
+      p->MOV(GenRegister::suboffset(dest, 8), GenRegister::suboffset(src, 8));
+      p->MOV(GenRegister::suboffset(dest, 12), GenRegister::suboffset(src, 12));
     }
     p->pop();
   }
@@ -1255,13 +1255,13 @@ namespace gbe
     p->curr.execWidth = 8;
     p->MOV(dest, src);
     p->curr.nibControl = 1;
-    p->MOV(GenRegister::suboffset(dest, 8), GenRegister::suboffset(src, 4));
+    p->MOV(GenRegister::suboffset(dest, 4), GenRegister::suboffset(src, 4));
     if (execWidth == 16) {
       p->curr.quarterControl = 1;
       p->curr.nibControl = 0;
-      p->MOV(GenRegister::suboffset(dest, 16), GenRegister::suboffset(src, 8));
+      p->MOV(GenRegister::suboffset(dest, 8), GenRegister::suboffset(src, 8));
       p->curr.nibControl = 1;
-      p->MOV(GenRegister::suboffset(dest, 24), GenRegister::suboffset(src, 12));
+      p->MOV(GenRegister::suboffset(dest, 12), GenRegister::suboffset(src, 12));
     }
     p->pop();
   }
diff --git a/backend/src/backend/gen_encoder.cpp b/backend/src/backend/gen_encoder.cpp
index c372e36..61393a3 100644
--- a/backend/src/backend/gen_encoder.cpp
+++ b/backend/src/backend/gen_encoder.cpp
@@ -908,7 +908,7 @@ namespace gbe
       curr.execWidth = 8;
       curr.predicate = GEN_PREDICATE_NONE;
       MOV(r0, src0);
-      MOV(GenRegister::suboffset(r0, 8), GenRegister::suboffset(src0, 4));
+      MOV(GenRegister::suboffset(r0, 4), GenRegister::suboffset(src0, 4));
       curr.predicate = GEN_PREDICATE_NORMAL;
       curr.quarterControl = 0;
       curr.nibControl = 0;
@@ -921,7 +921,7 @@ namespace gbe
         curr.execWidth = 8;
         curr.predicate = GEN_PREDICATE_NONE;
         MOV(r0, GenRegister::suboffset(src0, 8));
-        MOV(GenRegister::suboffset(r0, 8), GenRegister::suboffset(src0, 12));
+        MOV(GenRegister::suboffset(r0, 4), GenRegister::suboffset(src0, 12));
         curr.predicate = GEN_PREDICATE_NORMAL;
         curr.quarterControl = 1;
         curr.nibControl = 0;
diff --git a/backend/src/backend/gen_register.hpp b/backend/src/backend/gen_register.hpp
index 57c78d9..8794318 100644
--- a/backend/src/backend/gen_register.hpp
+++ b/backend/src/backend/gen_register.hpp
@@ -763,7 +763,7 @@ namespace gbe
 
     static INLINE GenRegister suboffset(GenRegister reg, uint32_t delta) {
       if (reg.hstride != GEN_HORIZONTAL_STRIDE_0) {
-        reg.subnr += delta * typeSize(reg.type);
+        reg.subnr += delta * typeSize(reg.type) * hstride_size(reg);
         reg.nr += reg.subnr / 32;
         reg.subnr %= 32;
       }
-- 
1.8.3.2



More information about the Beignet mailing list