this fix basic test in conformance tests failed for vec8 of char 
because
         of overflow. And it fix many test items failed in opencv because of
         offset error

        (1)modify the size of searchInsnArray to 32, it is the max size for char
           And add check for overflow if too many insn
        (2)Make sure the start insn is the first insn of searched array
           because if it is not the first, the offset maybe invalid. And
           it is complex to modify offset without error

Signed-off-by: rander.wang <rander.w...@intel.com>
---
 backend/src/llvm/llvm_loadstore_optimization.cpp | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/backend/src/llvm/llvm_loadstore_optimization.cpp 
b/backend/src/llvm/llvm_loadstore_optimization.cpp
index c91c1a0..b18ddf5 100644
--- a/backend/src/llvm/llvm_loadstore_optimization.cpp
+++ b/backend/src/llvm/llvm_loadstore_optimization.cpp
@@ -197,7 +197,6 @@ namespace gbe {
                             const BasicBlock::iterator &start,
                             unsigned maxVecSize,
                             bool isLoad) {
-
     if(!isSimpleLoadStore(&*start)) return false;
 
     unsigned targetAddrSpace = getAddressSpace(&*start);
@@ -212,8 +211,8 @@ namespace gbe {
     bool ready = false;
     int elementSize;
 
-    SmallVector<mergedInfo *, 16> searchInsnArray;
-    mergedInfo meInfoArray[16];
+    SmallVector<mergedInfo *, 32> searchInsnArray;
+    mergedInfo meInfoArray[32];
     int indx = 0;
     meInfoArray[indx++].init(&*start, 0);
 
@@ -229,6 +228,8 @@ namespace gbe {
             meInfoArray[indx].init(&*I, distance);
             searchInsnArray.push_back(&meInfoArray[indx]);
             indx++;
+            if(indx >= 32)
+              break;
           }
       } else if((isLoad && isa<StoreInst>(*J))) {
         // simple stop to keep read/write order
@@ -237,6 +238,8 @@ namespace gbe {
         if (addrSpace != targetAddrSpace) {
           reordered = true;
         } else {
+          indx = 0;
+          searchInsnArray.clear();
           break;
         }
       } else if ((!isLoad && isa<LoadInst>(*J))) {
@@ -245,11 +248,11 @@ namespace gbe {
         if (addrSpace != targetAddrSpace) {
           reordered = true;
         } else {
+          indx = 0;
+          searchInsnArray.clear();
           break;
         }
       }
-
-      if(merged.size() >= maxVecSize) break;
     }
 
     if(indx > 1)
@@ -275,8 +278,15 @@ namespace gbe {
 
         if(j > 0 && ready)
         {
+          if (searchInsnArray[i]->mInsn != &*start)
+            break;
+
           for(unsigned k = 0; k < j+1; k++)
+          {
             merged.push_back(searchInsnArray[i+k]->mInsn);
+            if (k >= maxVecSize)
+              break;
+          }
 
           break;
         }
-- 
2.7.4

_______________________________________________
Beignet mailing list
Beignet@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/beignet

Reply via email to