From: Junyan He Date: Wed, 7 May 2014 10:03:04 +0000 (+0800) Subject: correct jump distance of hsw's jmpi. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=91c1afb4691ccffff9c5de85ef4251d39b18165b;p=contrib%2Fbeignet.git correct jump distance of hsw's jmpi. 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 Reviewed-by: Junyan He --- 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.