@@ -1632,7 +1632,7 @@ struct LoopVectorize : public FunctionPass {
1632
1632
[&](Loop &L) -> const LoopAccessInfo & { return LAA->getInfo (&L); };
1633
1633
1634
1634
return Impl.runImpl (F, *SE, *LI, *TTI, *DT, *BFI, TLI, *DB, *AA, *AC,
1635
- GetLAA, *ORE, PSI);
1635
+ GetLAA, *ORE, PSI). MadeAnyChange ;
1636
1636
}
1637
1637
1638
1638
void getAnalysisUsage (AnalysisUsage &AU) const override {
@@ -7954,7 +7954,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
7954
7954
return true ;
7955
7955
}
7956
7956
7957
- bool LoopVectorizePass::runImpl (
7957
+ LoopVectorizeResult LoopVectorizePass::runImpl (
7958
7958
Function &F, ScalarEvolution &SE_, LoopInfo &LI_, TargetTransformInfo &TTI_,
7959
7959
DominatorTree &DT_, BlockFrequencyInfo &BFI_, TargetLibraryInfo *TLI_,
7960
7960
DemandedBits &DB_, AliasAnalysis &AA_, AssumptionCache &AC_,
@@ -7982,17 +7982,17 @@ bool LoopVectorizePass::runImpl(
7982
7982
// interleaving.
7983
7983
if (!TTI->getNumberOfRegisters (TTI->getRegisterClassForType (true )) &&
7984
7984
TTI->getMaxInterleaveFactor (1 ) < 2 )
7985
- return false ;
7985
+ return LoopVectorizeResult ( false , false ) ;
7986
7986
7987
- bool Changed = false ;
7987
+ bool Changed = false , CFGChanged = false ;
7988
7988
7989
7989
// The vectorizer requires loops to be in simplified form.
7990
7990
// Since simplification may add new inner loops, it has to run before the
7991
7991
// legality and profitability checks. This means running the loop vectorizer
7992
7992
// will simplify all loops, regardless of whether anything end up being
7993
7993
// vectorized.
7994
7994
for (auto &L : *LI)
7995
- Changed |=
7995
+ Changed |= CFGChanged |=
7996
7996
simplifyLoop (L, DT, LI, SE, AC, nullptr , false /* PreserveLCSSA */ );
7997
7997
7998
7998
// Build up a worklist of inner-loops to vectorize. This is necessary as
@@ -8013,11 +8013,11 @@ bool LoopVectorizePass::runImpl(
8013
8013
// transform.
8014
8014
Changed |= formLCSSARecursively (*L, *DT, LI, SE);
8015
8015
8016
- Changed |= processLoop (L);
8016
+ Changed |= CFGChanged |= processLoop (L);
8017
8017
}
8018
8018
8019
8019
// Process each loop nest in the function.
8020
- return Changed;
8020
+ return LoopVectorizeResult ( Changed, CFGChanged) ;
8021
8021
}
8022
8022
8023
8023
PreservedAnalyses LoopVectorizePass::run (Function &F,
@@ -8046,9 +8046,9 @@ PreservedAnalyses LoopVectorizePass::run(Function &F,
8046
8046
AM.getResult <ModuleAnalysisManagerFunctionProxy>(F).getManager ();
8047
8047
ProfileSummaryInfo *PSI =
8048
8048
MAM.getCachedResult <ProfileSummaryAnalysis>(*F.getParent ());
8049
- bool Changed =
8049
+ LoopVectorizeResult Result =
8050
8050
runImpl (F, SE, LI, TTI, DT, BFI, &TLI, DB, AA, AC, GetLAA, ORE, PSI);
8051
- if (!Changed )
8051
+ if (!Result. MadeAnyChange )
8052
8052
return PreservedAnalyses::all ();
8053
8053
PreservedAnalyses PA;
8054
8054
@@ -8062,5 +8062,7 @@ PreservedAnalyses LoopVectorizePass::run(Function &F,
8062
8062
}
8063
8063
PA.preserve <BasicAA>();
8064
8064
PA.preserve <GlobalsAA>();
8065
+ if (!Result.MadeCFGChange )
8066
+ PA.preserveSet <CFGAnalyses>();
8065
8067
return PA;
8066
8068
}
0 commit comments