[V3] backend: improve add zero pattern

Submitted by rander on July 7, 2017, 2:09 a.m.

Details

Message ID 1499393372-22635-1-git-send-email-rander.wang@intel.com
State New
Headers show
Series "backend: improve add zero pattern" ( rev: 3 ) in Beignet

Not browsing as part of any series.

Commit Message

rander July 7, 2017, 2:09 a.m.
remove the negation check for adding zero.
	it also can be applied this optimization

	V2: refine the function name for zeroAdd
	V3: refine the build

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

Patch hide | download patch | download mbox

diff --git a/backend/src/backend/gen_insn_selection_optimize.cpp b/backend/src/backend/gen_insn_selection_optimize.cpp
index af5ecc2..fafb6be 100644
--- a/backend/src/backend/gen_insn_selection_optimize.cpp
+++ b/backend/src/backend/gen_insn_selection_optimize.cpp
@@ -101,7 +101,7 @@  namespace gbe
     void doReplacement(ReplaceInfo* info);
     bool CanBeReplaced(const ReplaceInfo* info, const SelectionInstruction& insn, const GenRegister& var);
     void cleanReplaceInfoMap();
-    void doNegAddOptimization(SelectionInstruction &insn);
+    void doZeroAddedOptimization(SelectionInstruction &insn);
 
     SelectionBlock &bb;
     const ir::Liveness::LiveOut& liveout;
@@ -289,7 +289,7 @@  namespace gbe
       if (insn.opcode == SEL_OP_MOV)
         addToReplaceInfoMap(insn);
 
-      doNegAddOptimization(insn);
+      doZeroAddedOptimization(insn);
     }
     cleanReplaceInfoMap();
   }
@@ -301,12 +301,12 @@  namespace gbe
      Also it can be used for the same like instruction sequence.
      Do it just like a:  mov b, -b, so it is a Mov operation like LocalCopyPropagation
   */
-  void SelBasicBlockOptimizer::doNegAddOptimization(SelectionInstruction &insn) {
+  void SelBasicBlockOptimizer::doZeroAddedOptimization(SelectionInstruction &insn) {
     if (insn.opcode == SEL_OP_ADD) {
       GenRegister src0 = insn.src(0);
       GenRegister src1 = insn.src(1);
-      if ((src0.negation && src1.file == GEN_IMMEDIATE_VALUE && src1.value.f == 0.0f) ||
-          (src1.negation && src0.file == GEN_IMMEDIATE_VALUE && src0.value.f == 0.0f))
+      if ((src1.file == GEN_IMMEDIATE_VALUE && src1.value.f == 0.0f) ||
+          (src0.file == GEN_IMMEDIATE_VALUE && src0.value.f == 0.0f))
         addToReplaceInfoMap(insn);
     }
   }