forked from OSchip/llvm-project
[HardwareLoops] NFC - move loop with irreducible control flow checking logic to HarewareLoopInfo.
llvm-svn: 364415
This commit is contained in:
parent
6876de90e8
commit
aa99952896
|
@ -96,6 +96,7 @@ struct HardwareLoopInfo {
|
|||
bool isHardwareLoopCandidate(ScalarEvolution &SE, LoopInfo &LI,
|
||||
DominatorTree &DT, bool ForceNestedLoop = false,
|
||||
bool ForceHardwareLoopPHI = false);
|
||||
bool canAnalyze(LoopInfo &LI);
|
||||
};
|
||||
|
||||
/// This pass provides access to the codegen interfaces that are needed
|
||||
|
@ -473,8 +474,7 @@ public:
|
|||
|
||||
/// Query the target whether it would be profitable to convert the given loop
|
||||
/// into a hardware loop.
|
||||
bool isHardwareLoopProfitable(Loop *L, LoopInfo &LI,
|
||||
ScalarEvolution &SE,
|
||||
bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE,
|
||||
AssumptionCache &AC,
|
||||
TargetLibraryInfo *LibInfo,
|
||||
HardwareLoopInfo &HWLoopInfo) const;
|
||||
|
|
|
@ -42,6 +42,16 @@ struct NoTTIImpl : TargetTransformInfoImplCRTPBase<NoTTIImpl> {
|
|||
};
|
||||
}
|
||||
|
||||
bool HardwareLoopInfo::canAnalyze(LoopInfo &LI) {
|
||||
// If the loop has irreducible control flow, it can not be converted to
|
||||
// Hardware loop.
|
||||
LoopBlocksRPO RPOT(L);
|
||||
RPOT.perform(&LI);
|
||||
if (containsIrreducibleCFG<const BasicBlock *>(RPOT, LI))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HardwareLoopInfo::isHardwareLoopCandidate(ScalarEvolution &SE,
|
||||
LoopInfo &LI, DominatorTree &DT,
|
||||
bool ForceNestedLoop,
|
||||
|
@ -218,14 +228,8 @@ bool TargetTransformInfo::isLoweredToCall(const Function *F) const {
|
|||
}
|
||||
|
||||
bool TargetTransformInfo::isHardwareLoopProfitable(
|
||||
Loop *L, LoopInfo &LI, ScalarEvolution &SE, AssumptionCache &AC,
|
||||
Loop *L, ScalarEvolution &SE, AssumptionCache &AC,
|
||||
TargetLibraryInfo *LibInfo, HardwareLoopInfo &HWLoopInfo) const {
|
||||
// If the loop has irreducible control flow, it can not be converted to
|
||||
// Hardware loop.
|
||||
LoopBlocksRPO RPOT(L);
|
||||
RPOT.perform(&LI);
|
||||
if (containsIrreducibleCFG<const BasicBlock *>(RPOT, LI))
|
||||
return false;
|
||||
return TTIImpl->isHardwareLoopProfitable(L, SE, AC, LibInfo, HWLoopInfo);
|
||||
}
|
||||
|
||||
|
|
|
@ -198,7 +198,10 @@ bool HardwareLoops::TryConvertLoop(Loop *L) {
|
|||
return true; // Stop search.
|
||||
|
||||
HardwareLoopInfo HWLoopInfo(L);
|
||||
if (TTI->isHardwareLoopProfitable(L, *LI, *SE, *AC, LibInfo, HWLoopInfo) ||
|
||||
if (!HWLoopInfo.canAnalyze(*LI))
|
||||
return false;
|
||||
|
||||
if (TTI->isHardwareLoopProfitable(L, *SE, *AC, LibInfo, HWLoopInfo) ||
|
||||
ForceHardwareLoops) {
|
||||
|
||||
// Allow overriding of the counter width and loop decrement value.
|
||||
|
|
Loading…
Reference in New Issue