[Beignet] [V2 PATCH 4/6] correct jump distance of hsw's jmpi.

junyan.he at inbox.com junyan.he at inbox.com
Wed May 7 03:03:04 PDT 2014


From: Junyan He <junyan.he at linux.intel.com>

Gen5+ bspec: the jump distance is in number of eight-byte units.
Gen7.5+: the offset is in unit of 8bits for JMPI, 64bits for other flow control instructions.
So need multiple all jump distance with 8 in jmpi.

Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
 backend/src/backend/gen_encoder.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/backend/src/backend/gen_encoder.cpp b/backend/src/backend/gen_encoder.cpp
index 059ea94..ceaa199 100644
--- a/backend/src/backend/gen_encoder.cpp
+++ b/backend/src/backend/gen_encoder.cpp
@@ -1106,14 +1106,15 @@ namespace gbe
                insn.header.opcode == GEN_OPCODE_BRC);
 
     if (insn.header.opcode != GEN_OPCODE_JMPI || (jumpDistance > -32769 && jumpDistance < 32768))  {
-          int offset = 0;
            if (insn.header.opcode == GEN_OPCODE_IF) {
              this->setSrc1(&insn, GenRegister::immd(jumpDistance));
              return;
            }
-           else if (insn.header.opcode == GEN_OPCODE_JMPI)
-             offset = -2;
-          this->setSrc1(&insn, GenRegister::immd(jumpDistance + offset));
+           else if (insn.header.opcode == GEN_OPCODE_JMPI) {
+             jumpDistance = (jumpDistance - 2)* jump_width;
+           }
+
+           this->setSrc1(&insn, GenRegister::immd(jumpDistance));
     } else if ( insn.header.predicate_control == GEN_PREDICATE_NONE ) {
       // For the conditional jump distance out of S15 range, we need to use an
       // inverted jmp followed by a add ip, ip, distance to implement.
-- 
1.8.3.2



More information about the Beignet mailing list