Changeset View
Changeset View
Standalone View
Standalone View
llvm/include/llvm/Transforms/Vectorize/LoopVectorize.h
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | |||||
class ProfileSummaryInfo; | class ProfileSummaryInfo; | ||||
class ScalarEvolution; | class ScalarEvolution; | ||||
class TargetLibraryInfo; | class TargetLibraryInfo; | ||||
class TargetTransformInfo; | class TargetTransformInfo; | ||||
extern cl::opt<bool> EnableLoopInterleaving; | extern cl::opt<bool> EnableLoopInterleaving; | ||||
extern cl::opt<bool> EnableLoopVectorization; | extern cl::opt<bool> EnableLoopVectorization; | ||||
/// A marker to determine if extra passes after loop vectorization should be | |||||
/// run. | |||||
struct ShouldRunExtraVectorPasses | |||||
: public AnalysisInfoMixin<ShouldRunExtraVectorPasses> { | |||||
static AnalysisKey Key; | |||||
struct Result { | |||||
bool invalidate(Function &F, const PreservedAnalyses &PA, | |||||
FunctionAnalysisManager::Invalidator &) { | |||||
// Check whether the analysis has been explicitly invalidated. Otherwise, | |||||
// it remains preserved. | |||||
auto PAC = PA.getChecker<ShouldRunExtraVectorPasses>(); | |||||
return !PAC.preservedWhenStateless(); | |||||
} | |||||
}; | |||||
Result run(Function &F, FunctionAnalysisManager &FAM) { return Result(); } | |||||
aeubanks: can `ExtraVectorPassManager` only contain `ConditionalPasses` and we have a separate FPM for… | |||||
The reason why ExtraVectorPassManager contains both the conditional and unconditional passes is that this way we can check whether ShouldRunExtraVectorPasses is available *before* the unconditional passes run. If we would run the unconditional passes outside of ExtraVectorPassManager, then any change they make would invalidate ShouldRunExtraVectorPasses IIUC. Unless we teach all those passes to preserve it. Or perhaps there's a different alternative? fhahn: The reason why `ExtraVectorPassManager` contains both the conditional and unconditional passes… | |||||
you could override the invalidate() method of Result to be stateless, e.g. following bool GlobalsAAResult::invalidate(Module &, const PreservedAnalyses &PA, ModuleAnalysisManager::Invalidator &) { // Check whether the analysis has been explicitly invalidated. Otherwise, it's // stateless and remains preserved. auto PAC = PA.getChecker<GlobalsAA>(); return !PAC.preservedWhenStateless(); } this makes it so it's only invalidated if it's specifically abandoned this should make it so this only needs to wrap the ConditionaPasses and not be its own FunctionPassManager aeubanks: you could override the `invalidate()` method of `Result` to be stateless, e.g. following
```… | |||||
Done, thanks! fhahn: Done, thanks! | |||||
}; | |||||
/// A pass manager to conditionally run a set of extra function passes after | |||||
/// vectorization. The manager contains 2 set of passes: The first set of | |||||
/// passes to run unconditonally and the second set is only run if the | |||||
/// ShouldRunExtraVectorPasses analysis is cached (LoopVectorize sets it if | |||||
/// extra simplifications could be beneficial). | |||||
struct ExtraVectorPassManager : public FunctionPassManager { | |||||
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM) { | |||||
auto PA = PreservedAnalyses::all(); | |||||
if (AM.getCachedResult<ShouldRunExtraVectorPasses>(F)) | |||||
PA.intersect(FunctionPassManager::run(F, AM)); | |||||
PA.abandon<ShouldRunExtraVectorPasses>(); | |||||
return PA; | |||||
} | |||||
}; | |||||
struct LoopVectorizeOptions { | struct LoopVectorizeOptions { | ||||
/// If false, consider all loops for interleaving. | /// If false, consider all loops for interleaving. | ||||
/// If true, only loops that explicitly request interleaving are considered. | /// If true, only loops that explicitly request interleaving are considered. | ||||
bool InterleaveOnlyWhenForced; | bool InterleaveOnlyWhenForced; | ||||
/// If false, consider all loops for vectorization. | /// If false, consider all loops for vectorization. | ||||
/// If true, only loops that explicitly request vectorization are considered. | /// If true, only loops that explicitly request vectorization are considered. | ||||
bool VectorizeOnlyWhenForced; | bool VectorizeOnlyWhenForced; | ||||
▲ Show 20 Lines • Show All 98 Lines • Show Last 20 Lines |
can ExtraVectorPassManager only contain ConditionalPasses and we have a separate FPM for the normal passes? separation of concerns, seems like this is doing two things that could be separated