Skip to content

Commit 0485040

Browse files
jgu222sys_zuul
authored andcommitted
Minor internal performance change
Change-Id: Ia1a93d05e76bebd92a17e8d634d630eab8bb27bd
1 parent 112f2f2 commit 0485040

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

IGC/Compiler/CISACodeGen/VectorPreProcess.cpp

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ using namespace IGC;
6666
// Note that splitting keeps the vector element's type without
6767
// changing it.
6868
//
69+
// Note that as 6/2020,
70+
// if size of vector element >= DW, the number of elements of the new vector
71+
// should be power of 2 except for vector3. Thus, we should not see 5xi32,
72+
// 7xi32, etc. This makes code emit easier.
73+
//
6974
// 2. Special processing of 3-element vectors
7075
// If (vector element's size < 4 bytes)
7176
// {
@@ -321,7 +326,7 @@ namespace
321326
// of SPLIT_SIZE (plus smaller sub-vectors or scalar if any).
322327
// With SPLIT_SIZE=32, we have the max vectors as below after this pass:
323328
// <32 x i8>, 16xi16, 8xi32, or 4xi64!
324-
SPLIT_SIZE = 32, // 32 bytes (power of 2)
329+
SPLIT_SIZE = 32, // default, 32 bytes
325330
RAW_SPLIT_SIZE = 16
326331
};
327332

@@ -360,6 +365,7 @@ namespace
360365
bool isValueUsedOnlyByEEI(Value* V, ExtractElementInst** EEInsts);
361366

362367
// Split load/store that cannot be re-layout or is too big.
368+
uint32_t getSplitByteSize(Instruction* I, WIAnalysisRunner& WI) const;
363369
bool splitLoadStore(Instruction* Inst, V2SMap& vecToSubVec, WIAnalysisRunner& WI);
364370
bool splitLoad(AbstractLoadInst& LI, V2SMap& vecToSubVec, WIAnalysisRunner& WI);
365371
bool splitStore(AbstractStoreInst& SI, V2SMap& vecToSubVec, WIAnalysisRunner& WI);
@@ -582,6 +588,28 @@ void VectorPreProcess::createSplitVectorTypes(
582588
}
583589
}
584590

591+
uint32_t VectorPreProcess::getSplitByteSize(Instruction* I, WIAnalysisRunner& WI) const
592+
{
593+
uint32_t bytes = 0;
594+
if (LoadInst* LI = dyn_cast<LoadInst>(I))
595+
{
596+
bytes = (uint32_t)VPConst::SPLIT_SIZE;
597+
}
598+
else if (StoreInst* SI = dyn_cast<StoreInst>(I))
599+
{
600+
bytes = (uint32_t)VPConst::SPLIT_SIZE;
601+
}
602+
else if (isa<LdRawIntrinsic>(I) || isa<StoreRawIntrinsic>(I))
603+
{
604+
bytes = (uint32_t)VPConst::RAW_SPLIT_SIZE;
605+
}
606+
else
607+
{
608+
bytes = (uint32_t)VPConst::SPLIT_SIZE;
609+
}
610+
return bytes;
611+
}
612+
585613
bool VectorPreProcess::splitStore(
586614
AbstractStoreInst& ASI, V2SMap& vecToSubVec, WIAnalysisRunner& WI)
587615
{
@@ -594,7 +622,7 @@ bool VectorPreProcess::splitStore(
594622
// splitInfo: Keep track of all pairs of (sub-vec type, #sub-vec).
595623
SmallVector<std::pair<Type*, uint32_t>, 8> splitInfo;
596624
bool isStoreInst = isa<StoreInst>(SI);
597-
uint32_t splitSize = (uint32_t)(isStoreInst ? VPConst::SPLIT_SIZE : VPConst::RAW_SPLIT_SIZE);
625+
uint32_t splitSize = getSplitByteSize(SI, WI);
598626
if (IGC_IS_FLAG_ENABLED(EnableSplitUnalignedVector))
599627
{
600628
// byte and word-aligned stores can only store a dword at a time.
@@ -764,7 +792,7 @@ bool VectorPreProcess::splitLoad(
764792
// ...
765793
// SplitInfo : all pairs, each of which is (sub-vector's type, #sub-vectors).
766794
SmallVector< std::pair<Type*, uint32_t>, 8 > splitInfo;
767-
uint32_t splitSize = (uint32_t)(isLdRaw ? VPConst::RAW_SPLIT_SIZE : VPConst::SPLIT_SIZE);
795+
uint32_t splitSize = getSplitByteSize(LI, WI);
768796
if (IGC_IS_FLAG_ENABLED(EnableSplitUnalignedVector))
769797
{
770798
// byte and word-aligned loads can only load a dword at a time.

0 commit comments

Comments
 (0)