diff options
author | Davide Italiano <davide@freebsd.org> | 2019-02-03 20:33:20 +0000 |
---|---|---|
committer | Davide Italiano <davide@freebsd.org> | 2019-02-03 20:33:20 +0000 |
commit | 73929c4d240fd7c1ade94b9aeab808777a6fe9e9 (patch) | |
tree | 23b0ab4747ac7b3626edf7a77acda85a3faefa6a /llvm/lib | |
parent | e64aee87a0cd5e7146e4dbba68072deecb8a4739 (diff) | |
download | bcm5719-llvm-73929c4d240fd7c1ade94b9aeab808777a6fe9e9.tar.gz bcm5719-llvm-73929c4d240fd7c1ade94b9aeab808777a6fe9e9.zip |
[LoopIdiomRecognize] @llvm.dbg values shouldn't affect the transformation.
Summary: PR40564
Reviewers: aprantl, rnk
Subscribers: llvm-commits, hiraditya
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D57629
llvm-svn: 353007
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp index 799f40d8724..5f9f54c35cb 100644 --- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp @@ -1460,9 +1460,15 @@ bool LoopIdiomRecognize::recognizeAndInsertFFS() { const Value *Args[] = {InitX, ZeroCheck ? ConstantInt::getTrue(InitX->getContext()) : ConstantInt::getFalse(InitX->getContext())}; - if (CurLoop->getHeader()->size() != IdiomCanonicalSize && + + // @llvm.dbg doesn't count as they have no semantic effect. + auto InstWithoutDebugIt = CurLoop->getHeader()->instructionsWithoutDebug(); + uint32_t HeaderSize = + std::distance(InstWithoutDebugIt.begin(), InstWithoutDebugIt.end()); + + if (HeaderSize != IdiomCanonicalSize && TTI->getIntrinsicCost(IntrinID, InitX->getType(), Args) > - TargetTransformInfo::TCC_Basic) + TargetTransformInfo::TCC_Basic) return false; transformLoopToCountable(IntrinID, PH, CntInst, CntPhi, InitX, DefX, |