[Beignet] [PATCH 1/3] Fix two argument lowering bug.

Yang Rong rong.r.yang at intel.com
Sun May 10 23:02:52 PDT 2015


1. When there are a mismatch AddImm/Load, may be a indirect load, should return false.
2. Can't remove load in REMOVE_INSN, because load's use is not empty. Force remove it.

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

diff --git a/backend/src/ir/lowering.cpp b/backend/src/ir/lowering.cpp
index 73b1dd2..0e36907 100644
--- a/backend/src/ir/lowering.cpp
+++ b/backend/src/ir/lowering.cpp
@@ -259,11 +259,12 @@ namespace ir {
         replaced = true;
       }
 
-      if (replaced)
+      if (replaced) {
         dead.insert(load);
+        load->remove();
+      }
     }
 
-    REMOVE_INSN(load)
     REMOVE_INSN(add)
     REMOVE_INSN(loadImm)
   }
@@ -298,6 +299,7 @@ namespace ir {
   {
     const FunctionArgument &arg = fn->getArg(argID);
     LoadAddImmSeq tmpSeq;
+    bool match = true;
 
     // Inspect all uses of the function argument pointer
     const UseSet &useSet = dag->getUse(&arg);
@@ -345,7 +347,8 @@ namespace ir {
         if (matchLoad(insn, add, loadImm, offset, argID, loadAddImm)) {
           tmpSeq.push_back(loadAddImm);
           continue;
-        }
+        } else
+          match = false;
       }
     }
 
@@ -353,7 +356,7 @@ namespace ir {
     // direct load definitions we found
     for (const auto &loadImmSeq : tmpSeq)
       seq.push_back(loadImmSeq);
-    return true;
+    return match;
   }
 
   ArgUse FunctionArgumentLowerer::getArgUse(uint32_t argID)
-- 
1.8.3.2



More information about the Beignet mailing list