diff options
author | rander <rander.wang@intel.com> | 2017-07-04 09:48:21 +0800 |
---|---|---|
committer | Yang Rong <rong.r.yang@intel.com> | 2017-07-06 18:02:28 +0800 |
commit | f410c205bbeb28125fef4c3605fe15ef9285007d (patch) | |
tree | 848197710b7819e9baef21e6ae7859dc9efcf078 | |
parent | 01389c558d5e966a9052e34c540b48180d02a436 (diff) |
backend: improve add zero pattern
remove the negation check for adding zero.
it also can be applied this optimization
V2: refine the function name for zeroAdd
Signed-off-by: rander.wang <rander.wang@intel.com>
Reviewed-by: Yang Rong <rong.r.yang@intel.com>
-rw-r--r-- | backend/src/backend/gen_insn_selection_optimize.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/backend/src/backend/gen_insn_selection_optimize.cpp b/backend/src/backend/gen_insn_selection_optimize.cpp index 1020b7f6..2ab2a7f9 100644 --- a/backend/src/backend/gen_insn_selection_optimize.cpp +++ b/backend/src/backend/gen_insn_selection_optimize.cpp @@ -103,7 +103,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; @@ -291,7 +291,7 @@ namespace gbe if (insn.opcode == SEL_OP_MOV) addToReplaceInfoMap(insn); - doNegAddOptimization(insn); + doZeroAddedOptimization(insn); } cleanReplaceInfoMap(); } @@ -303,12 +303,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); } } |