Signed-off-by: Zhigang Gong <[email protected]>
---
backend/src/backend/gen_insn_selection.cpp | 2 +-
backend/src/ir/function.hpp | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/backend/src/backend/gen_insn_selection.cpp
b/backend/src/backend/gen_insn_selection.cpp
index ab00269..57dbec9 100644
--- a/backend/src/backend/gen_insn_selection.cpp
+++ b/backend/src/backend/gen_insn_selection.cpp
@@ -1154,7 +1154,7 @@ namespace gbe
SelectionInstruction *insn = this->appendInsn(SEL_OP_JMPI, 0, 1);
insn->src(0) = src;
insn->index = index.value();
- insn->extra.longjmp = abs(index - origin) > 800;
+ insn->extra.longjmp = ctx.getFunction().getDistance(origin, index) > 8000;
return insn->extra.longjmp ? 2 : 1;
}
diff --git a/backend/src/ir/function.hpp b/backend/src/ir/function.hpp
index b5f4ba2..b924332 100644
--- a/backend/src/ir/function.hpp
+++ b/backend/src/ir/function.hpp
@@ -487,6 +487,23 @@ namespace ir {
Register getSurfaceBaseReg(uint8_t bti) const;
void appendSurface(uint8_t bti, Register reg);
/*! Output the control flow graph to .dot file */
+ /*! Get instruction distance between two BBs */
+ INLINE uint32_t getDistance(LabelIndex b0, LabelIndex b1) const {
+ int start, end;
+ if (b0.value() < b1.value()) {
+ start = b0.value();
+ end = b1.value() - 1;
+ } else {
+ start = b1.value();
+ end = b0.value() - 1;
+ }
+ uint32_t insnNum = 0;
+ for(int i = start; i <= end; i++) {
+ BasicBlock &bb = getBlock(LabelIndex(i));
+ insnNum += bb.size();
+ }
+ return insnNum;
+ }
void outputCFG();
private:
friend class Context; //!< Can freely modify a function
--
1.9.1
_______________________________________________
Beignet mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/beignet