summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorSam Parker <sam.parker@arm.com>2019-06-13 08:28:46 +0000
committerSam Parker <sam.parker@arm.com>2019-06-13 08:28:46 +0000
commit9d28473a355503bfc730a4eb5b9dbbc8d0ca321c (patch)
tree1a27117586bac3cb9adb3cf374f8ba01d779ebaf /llvm/lib/Target
parent7957fc6547e1b8af8e6586e2c25446b724eabb75 (diff)
downloadbcm5719-llvm-9d28473a355503bfc730a4eb5b9dbbc8d0ca321c.tar.gz
bcm5719-llvm-9d28473a355503bfc730a4eb5b9dbbc8d0ca321c.zip
[ARM][TTI] Scan for existing loop intrinsics
TTI should report that it's not profitable to generate a hardware loop if it, or one of its child loops, has already been converted. Differential Revision: https://reviews.llvm.org/D63212 llvm-svn: 363234
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp38
1 files changed, 33 insertions, 5 deletions
diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
index 128d14c1537..5f0fbd03cc9 100644
--- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
@@ -804,12 +804,39 @@ bool ARMTTIImpl::isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE,
return false;
};
+ auto IsHardwareLoopIntrinsic = [](Instruction &I) {
+ if (auto *Call = dyn_cast<IntrinsicInst>(&I)) {
+ switch (Call->getCalledFunction()->getIntrinsicID()) {
+ default:
+ break;
+ case Intrinsic::set_loop_iterations:
+ case Intrinsic::loop_decrement:
+ case Intrinsic::loop_decrement_reg:
+ return true;
+ }
+ }
+ return false;
+ };
+
// Scan the instructions to see if there's any that we know will turn into a
- // call.
- for (auto *BB : L->getBlocks())
- for (auto &I : *BB)
- if (MaybeCall(I))
- return false;
+ // call or if this loop is already a low-overhead loop.
+ auto ScanLoop = [&](Loop *L) {
+ for (auto *BB : L->getBlocks()) {
+ for (auto &I : *BB) {
+ if (MaybeCall(I) || IsHardwareLoopIntrinsic(I))
+ return false;
+ }
+ }
+ return true;
+ };
+
+ // Visit inner loops.
+ for (auto Inner : *L)
+ if (!ScanLoop(Inner))
+ return false;
+
+ if (!ScanLoop(L))
+ return false;
// TODO: Check whether the trip count calculation is expensive. If L is the
// inner loop but we know it has a low trip count, calculating that trip
@@ -817,6 +844,7 @@ bool ARMTTIImpl::isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE,
LLVMContext &C = L->getHeader()->getContext();
HWLoopInfo.CounterInReg = true;
+ HWLoopInfo.IsNestingLegal = false;
HWLoopInfo.CountType = Type::getInt32Ty(C);
HWLoopInfo.LoopDecrement = ConstantInt::get(HWLoopInfo.CountType, 1);
return true;
OpenPOWER on IntegriCloud