[Beignet] [PATCH 1/2] GBE: Fix two bugs in loop preheader.

Ruiling Song ruiling.song at intel.com
Tue Jun 21 01:02:38 UTC 2016


Loop preheader requires the preheader has only one successor,
in fact, we don't need that strict requirement, just use predecessor
is OK. So it could fit into more situations.

We may re-assign LabelIndex during sortLabels, so, we need to fix
the LabelIndex for loop preheader.

Signed-off-by: Ruiling Song <ruiling.song at intel.com>
---
 backend/src/ir/function.cpp           | 2 ++
 backend/src/llvm/llvm_gen_backend.cpp | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/backend/src/ir/function.cpp b/backend/src/ir/function.cpp
index 4112f06..fddafc7 100644
--- a/backend/src/ir/function.cpp
+++ b/backend/src/ir/function.cpp
@@ -120,6 +120,8 @@ namespace ir {
       for (auto &y : x->bbs)
         y = labelMap[y];
 
+      x->preheader = labelMap[x->preheader];
+
       for (auto &z : x->exits) {
         z.first = labelMap[z.first];
         z.second = labelMap[z.second];
diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
index 0b44f24..0ac28de 100644
--- a/backend/src/llvm/llvm_gen_backend.cpp
+++ b/backend/src/llvm/llvm_gen_backend.cpp
@@ -2747,7 +2747,7 @@ namespace gbe
         GBE_ASSERT(labelMap.find(b) != labelMap.end());
         loopBBs.push_back(labelMap[b]);
       }
-      BasicBlock *preheader = loop.first->getLoopPreheader();
+      BasicBlock *preheader = loop.first->getLoopPredecessor();
       ir::LabelIndex preheaderBB(0);
       if (preheader) {
         preheaderBB = labelMap[preheader];
-- 
2.4.1



More information about the Beignet mailing list