[Beignet] [PATCH 2/2] GBE: optimize scalar data type conversion.
Song, Ruiling
ruiling.song at intel.com
Wed May 28 23:14:24 PDT 2014
This patch looks good to me.
-----Original Message-----
From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Zhigang Gong
Sent: Thursday, May 29, 2014 9:31 AM
To: beignet at lists.freedesktop.org
Cc: Gong, Zhigang
Subject: [Beignet] [PATCH 2/2] 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 at intel.com>
---
backend/src/backend/gen_insn_selection.cpp | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/backend/src/backend/gen_insn_selection.cpp b/backend/src/backend/gen_insn_selection.cpp
index 19921d4..db20162 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) {
--
1.8.3.2
_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list