Skip to content

Commit 2785473

Browse files
dlei6gsys_zuul
authored andcommitted
Bugfix for copying from stack, remaining bytes less than OWORD size
Change-Id: I129cf5120b136c75b7c57cc316da2654916610ef
1 parent e849212 commit 2785473

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9597,7 +9597,7 @@ void EmitPass::emitStackCall(llvm::CallInst* inst)
95979597
CVariable* pStackOffset = m_currShader->ImmToVariable(RdBytes, ISA_TYPE_UD);
95989598
emitAddSP(pTempVar, pSP, pStackOffset);
95999599

9600-
bool needRmCopy = RdSize == SIZE_OWORD && RmnBytes < SIZE_OWORD;
9600+
bool needRmCopy = RdSize == SIZE_OWORD && RmnBytes > 0 && RmnBytes < SIZE_OWORD;
96019601
if (!needRmCopy)
96029602
{
96039603
if (is64BitSP)
@@ -9619,9 +9619,9 @@ void EmitPass::emitStackCall(llvm::CallInst* inst)
96199619
if (is64BitSP)
96209620
m_encoder->OWLoadA64(pTempDst, pTempVar, SIZE_OWORD);
96219621
else
9622-
m_encoder->OWLoad(pTempDst, resource, pTempVar, false, RdSize);
9622+
m_encoder->OWLoad(pTempDst, resource, pTempVar, false, SIZE_OWORD);
96239623
m_encoder->Push();
9624-
emitVectorCopy(Dst, pTempDst, RdSize / elemSize, RdBytes, 0);
9624+
emitVectorCopy(Dst, pTempDst, RmnBytes / elemSize, RdBytes, 0);
96259625
}
96269626
}
96279627
RdBytes += RdSize;
@@ -9770,7 +9770,8 @@ void EmitPass::emitStackFuncEntry(Function* F, bool ptr64bits)
97709770
EALIGN_HWORD, false, 1);
97719771
}
97729772

9773-
bool needRmCopy = RdSize == SIZE_OWORD && LdDst->GetSize() < (DstOffset + RdSize);
9773+
int RmnBytes = LdDst->GetSize() - DstOffset;
9774+
bool needRmCopy = RdSize == SIZE_OWORD && RmnBytes > 0 && RmnBytes < SIZE_OWORD;
97749775
if (!needRmCopy)
97759776
{
97769777
if (is64bitSP)
@@ -9793,9 +9794,9 @@ void EmitPass::emitStackFuncEntry(Function* F, bool ptr64bits)
97939794
if (is64bitSP)
97949795
m_encoder->OWLoadA64(pTempDst, pTempVar, SIZE_OWORD);
97959796
else
9796-
m_encoder->OWLoad(pTempDst, resource, pTempVar, false, RdSize);
9797+
m_encoder->OWLoad(pTempDst, resource, pTempVar, false, SIZE_OWORD);
97979798
m_encoder->Push();
9798-
emitVectorCopy(LdDst, pTempDst, RdSize / ldDstElemSize, DstOffset, 0);
9799+
emitVectorCopy(LdDst, pTempDst, RmnBytes / ldDstElemSize, DstOffset, 0);
97999800
}
98009801
}
98019802
if (LdDst != Dst)

0 commit comments

Comments
 (0)