diff options
author | Zhigang Gong <zhigang.gong@intel.com> | 2014-05-29 09:26:39 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2014-05-29 14:48:54 +0800 |
commit | 80b2acab298377da1e0f53dcfed8ec758c6aa53d (patch) | |
tree | 10ddb208338ba03e1ccd5ff33f2592cb7f417f55 | |
parent | 1b8042620e32b05334f6bbbd87bde7ee4b4a8a03 (diff) |
GBE: optimize scalar data type conversion.
If the dst is scalar, the register region restrication is relaxed.
we can save one instruction as below:
(12 ) mov.sat(1) g127.24<4>:B g1.3<0,1,0>:D { align1 WE_all };
(14 ) mov(1) g127.28<1>:B g127.24<0,1,4>:D { align1 WE_all };
Optimized to:
(12 ) mov.sat(1) g128.28<4>:B g1.3<0,1,0>:D { align1 WE_all };
No need to create a temporary register g127.24.
Signed-off-by: Zhigang Gong <zhigang.gong@intel.com>
Reviewed-by: "Song, Ruiling" <ruiling.song@intel.com>
-rw-r--r-- | backend/src/backend/gen_insn_selection.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/backend/src/backend/gen_insn_selection.cpp b/backend/src/backend/gen_insn_selection.cpp index 19921d40..db20162d 100644 --- a/backend/src/backend/gen_insn_selection.cpp +++ b/backend/src/backend/gen_insn_selection.cpp @@ -3175,12 +3175,18 @@ namespace gbe GenRegister unpacked; if (dstFamily == FAMILY_WORD) { const uint32_t type = dstType == TYPE_U16 ? GEN_TYPE_UW : GEN_TYPE_W; - unpacked = sel.unpacked_uw(sel.reg(FAMILY_DWORD, sel.isScalarReg(insn.getSrc(0)))); - unpacked = GenRegister::retype(unpacked, type); + if (!sel.isScalarReg(dst.reg())) { + unpacked = sel.unpacked_uw(sel.reg(FAMILY_DWORD, sel.isScalarReg(insn.getSrc(0)))); + unpacked = GenRegister::retype(unpacked, type); + } else + unpacked = GenRegister::retype(sel.unpacked_uw(dst.reg()), type); } else { const uint32_t type = dstType == TYPE_U8 ? GEN_TYPE_UB : GEN_TYPE_B; - unpacked = sel.unpacked_ub(sel.reg(FAMILY_DWORD, sel.isScalarReg(insn.getSrc(0)))); - unpacked = GenRegister::retype(unpacked, type); + if (!sel.isScalarReg(dst.reg())) { + unpacked = sel.unpacked_ub(sel.reg(FAMILY_DWORD, sel.isScalarReg(insn.getSrc(0)))); + unpacked = GenRegister::retype(unpacked, type); + } else + unpacked = GenRegister::retype(sel.unpacked_ub(dst.reg()), type); } if(srcFamily == FAMILY_QWORD) { GenRegister tmp = sel.selReg(sel.reg(FAMILY_DWORD)); @@ -3197,7 +3203,8 @@ namespace gbe sel.MOV(unpacked, src); sel.pop(); } - sel.MOV(dst, unpacked); + if (unpacked.reg() != dst.reg()) + sel.MOV(dst, unpacked); } else if ((dstType == ir::TYPE_S32 || dstType == ir::TYPE_U32) && srcFamily == FAMILY_QWORD) { sel.CONVI64_TO_I(dst, src); } else if (dstType == ir::TYPE_FLOAT && srcFamily == FAMILY_QWORD) { |