@@ -82,6 +82,8 @@ namespace {
8282 bool AllowNegativeSymPtrsForLoad = false ;
8383 bool AllowVector8LoadStore = false ;
8484
85+ unsigned Limit = IGC_GET_FLAG_VALUE(MemOptWindowSize);
86+
8587 // Map of profit vector lengths per scalar type. Each entry specifies the
8688 // profit vector length of a given scalar type.
8789 // NOTE: Prepare the profit vector lengths in the *DESCENDING* order.
@@ -520,6 +522,18 @@ bool MemOpt::runOnFunction(Function& F) {
520522 CGC = getAnalysis<CodeGenContextWrapper>().getCodeGenContext ();
521523 TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI ();
522524
525+ auto isKernelWithForcedRetry = [this ](Function* F) -> bool {
526+ auto it = std::find (CGC->m_kernelsWithForcedRetry .begin (), CGC->m_kernelsWithForcedRetry .end (), F);
527+ return (it != CGC->m_kernelsWithForcedRetry .end ()) && !CGC->m_retryManager .IsFirstTry ();
528+ };
529+ bool shouldMemOptWindowSizeBeReduced = isKernelWithForcedRetry (&F);
530+
531+ if (shouldMemOptWindowSizeBeReduced) {
532+ Limit = 1 ;
533+ } else {
534+ Limit = IGC_GET_FLAG_VALUE (MemOptWindowSize);
535+ }
536+
523537 if (ProfitVectorLengths.empty ())
524538 buildProfitVectorLengths (F);
525539
@@ -636,7 +650,6 @@ bool MemOpt::removeRedBlockRead(GenIntrinsicInst* LeadingBlockRead,
636650 TrivialMemRefListTy& ToOpt, unsigned & sg_size)
637651{
638652 MemRefListTy::iterator MI = aMI;
639- const unsigned Limit = IGC_GET_FLAG_VALUE (MemOptWindowSize);
640653 const unsigned windowEnd = Limit + MI->second ;
641654 auto ME = MemRefs.end ();
642655
@@ -1208,7 +1221,6 @@ bool MemOpt::mergeLoad(LoadInst* LeadingLoad,
12081221 // List of instructions need dependency check.
12091222 SmallVector<Instruction*, 8 > CheckList;
12101223
1211- const unsigned Limit = IGC_GET_FLAG_VALUE (MemOptWindowSize);
12121224 // Given the Start position of the Window is MI->second,
12131225 // the End postion of the Window is "limit + Windows' start".
12141226 const unsigned windowEnd = Limit + MI->second ;
@@ -1562,7 +1574,6 @@ bool MemOpt::mergeStore(StoreInst* LeadingStore,
15621574 // List of instructions need dependency check.
15631575 SmallVector<Instruction*, 8 > CheckList;
15641576
1565- const unsigned Limit = IGC_GET_FLAG_VALUE (MemOptWindowSize);
15661577 // Given the Start position of the Window is MI->second,
15671578 // the End postion of the Window is "limit + Windows' start".
15681579 const unsigned windowEnd = Limit + MI->second ;
0 commit comments