[Beignet] [PATCH] Backend: for BDW and after, According to BSpec no need to split CMP when src is DW DF
rander
rander.wang at intel.com
Mon Feb 27 02:35:18 UTC 2017
Signed-off-by: rander <rander.wang at intel.com>
---
backend/src/backend/gen8_encoder.cpp | 30 ++++++++++++++++++++++++++++++
backend/src/backend/gen8_encoder.hpp | 1 +
backend/src/backend/gen_encoder.cpp | 10 +++++-----
backend/src/backend/gen_encoder.hpp | 1 +
4 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/backend/src/backend/gen8_encoder.cpp b/backend/src/backend/gen8_encoder.cpp
index a33fbac..31ae6d1 100644
--- a/backend/src/backend/gen8_encoder.cpp
+++ b/backend/src/backend/gen8_encoder.cpp
@@ -37,7 +37,13 @@ static const uint32_t untypedRWMask[] = {
namespace gbe
{
+ extern bool compactAlu2(GenEncoder *p, uint32_t opcode, GenRegister dst, GenRegister src0, GenRegister src1, uint32_t condition, bool split);
extern bool compactAlu3(GenEncoder *p, uint32_t opcode, GenRegister dst, GenRegister src0, GenRegister src1, GenRegister src2);
+ extern bool isSrcDstDiffSpan(GenRegister dst, GenRegister src);
+ extern bool isCrossMoreThan2(GenRegister reg);
+ extern bool isVectorOfLongs(GenRegister reg);
+ bool isVectorOfBytes(GenRegister reg);
+
void Gen8Encoder::setHeader(GenNativeInstruction *insn) {
Gen8NativeInstruction *gen8_insn = &insn->gen8_insn;
if (this->curr.execWidth == 8)
@@ -883,4 +889,28 @@ namespace gbe
msg_length,
response_length);
}
+
+ /* for BDW and after, no need to split CMP when src is DW DF*/
+ bool Gen8Encoder::needToSplitCmp(GenEncoder *p, GenRegister src0, GenRegister src1, GenRegister dst) {
+ if (p->curr.execWidth != 16) return false;
+ if (isVectorOfLongs(dst) == true) return true;
+ if (isCrossMoreThan2(dst) == true) return true;
+
+ if (src0.hstride == GEN_HORIZONTAL_STRIDE_0 &&
+ src1.hstride == GEN_HORIZONTAL_STRIDE_0)
+ return false;
+
+ if (isVectorOfBytes(src0) == true) return true;
+ if (isVectorOfBytes(src1) == true) return true;
+
+ if (isVectorOfLongs(src0) == true) return true;
+ if (isVectorOfLongs(src1) == true) return true;
+ if (isCrossMoreThan2(src0) == true) return true;
+ if (isCrossMoreThan2(src1) == true) return true;
+
+ if (isSrcDstDiffSpan(dst, src0) == true) return true;
+ if (isSrcDstDiffSpan(dst, src1) == true) return true;
+
+ return false;
+ }
} /* End of the name space. */
diff --git a/backend/src/backend/gen8_encoder.hpp b/backend/src/backend/gen8_encoder.hpp
index fa62a8d..c1df3b1 100644
--- a/backend/src/backend/gen8_encoder.hpp
+++ b/backend/src/backend/gen8_encoder.hpp
@@ -83,6 +83,7 @@ namespace gbe
virtual void OBREADA64(GenRegister dst, GenRegister header, uint32_t bti, uint32_t elemSize);
/*! A64 OBlock write */
virtual void OBWRITEA64(GenRegister header, uint32_t bti, uint32_t elemSize);
+ virtual bool needToSplitCmp(GenEncoder *p, GenRegister src0, GenRegister src1, GenRegister dst);
};
}
#endif /* __GBE_GEN8_ENCODER_HPP__ */
diff --git a/backend/src/backend/gen_encoder.cpp b/backend/src/backend/gen_encoder.cpp
index 03ce0e2..fbc443b 100644
--- a/backend/src/backend/gen_encoder.cpp
+++ b/backend/src/backend/gen_encoder.cpp
@@ -59,7 +59,7 @@ namespace gbe
//////////////////////////////////////////////////////////////////////////
// Some helper functions to encode
//////////////////////////////////////////////////////////////////////////
- INLINE bool isVectorOfBytes(GenRegister reg) {
+ bool isVectorOfBytes(GenRegister reg) {
if (reg.hstride != GEN_HORIZONTAL_STRIDE_0 &&
(reg.type == GEN_TYPE_UB || reg.type == GEN_TYPE_B))
return true;
@@ -67,7 +67,7 @@ namespace gbe
return false;
}
- INLINE bool isVectorOfLongs(GenRegister reg) {
+ bool isVectorOfLongs(GenRegister reg) {
if (reg.hstride != GEN_HORIZONTAL_STRIDE_0 &&
(reg.type == GEN_TYPE_UL || reg.type == GEN_TYPE_L))
return true;
@@ -75,7 +75,7 @@ namespace gbe
return false;
}
- INLINE bool isCrossMoreThan2(GenRegister reg) {
+ bool isCrossMoreThan2(GenRegister reg) {
if (reg.hstride == GEN_HORIZONTAL_STRIDE_0)
return false;
@@ -87,7 +87,7 @@ namespace gbe
return false;
}
- INLINE bool isSrcDstDiffSpan(GenRegister dst, GenRegister src) {
+ bool isSrcDstDiffSpan(GenRegister dst, GenRegister src) {
if (src.hstride == GEN_HORIZONTAL_STRIDE_0) return false;
GBE_ASSERT(dst.hstride != GEN_HORIZONTAL_STRIDE_0 && "dst register is uniform but src is not.");
@@ -172,7 +172,7 @@ namespace gbe
return false;
}
- INLINE bool needToSplitCmp(GenEncoder *p, GenRegister src0, GenRegister src1, GenRegister dst) {
+ bool GenEncoder::needToSplitCmp(GenEncoder *p, GenRegister src0, GenRegister src1, GenRegister dst) {
if (p->curr.execWidth != 16) return false;
if (isVectorOfLongs(dst) == true) return true;
if (isCrossMoreThan2(dst) == true) return true;
diff --git a/backend/src/backend/gen_encoder.hpp b/backend/src/backend/gen_encoder.hpp
index 3e45c81..b8c7a91 100644
--- a/backend/src/backend/gen_encoder.hpp
+++ b/backend/src/backend/gen_encoder.hpp
@@ -162,6 +162,7 @@ namespace gbe
void BRD(GenRegister src);
/*! Compare instructions */
void CMP(uint32_t conditional, GenRegister src0, GenRegister src1, GenRegister dst = GenRegister::null());
+ virtual bool needToSplitCmp(GenEncoder *p, GenRegister src0, GenRegister src1, GenRegister dst);
/*! Select with embedded compare (like sel.le ...) */
void SEL_CMP(uint32_t conditional, GenRegister dst, GenRegister src0, GenRegister src1);
/*! EOT is used to finish GPGPU threads */
--
2.7.4
More information about the Beignet
mailing list