summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
diff options
context:
space:
mode:
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2016-10-26 10:28:32 +0000
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2016-10-26 10:28:32 +0000
commit9bcb064f1928264a7b8f1bc0352f101e418d04e4 (patch)
tree6f4ce751fef3b826a2f27a1d47d681624b7f1ff9 /llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
parente53a4b7402ed311d06e25adfce44b6d12b7c89b1 (diff)
downloadbcm5719-llvm-9bcb064f1928264a7b8f1bc0352f101e418d04e4.tar.gz
bcm5719-llvm-9bcb064f1928264a7b8f1bc0352f101e418d04e4.zip
[IndVarSimplify][DebugLoc] When widening the exit loop condition, correctly reuse the debug location of the original comparison.
When the loop exit condition is canonicalized as a != compaison, reuse the debug location of the original (non canonical) comparison. Before this patch, the debug location of the new icmp was obtained from the loop latch terminator. This patch fixes the issue by correctly setting the IRBuilder's "current debug location" to the location of the original compare. Differential Revision: https://reviews.llvm.org/D25953 llvm-svn: 285185
Diffstat (limited to 'llvm/lib/Transforms/Scalar/IndVarSimplify.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/IndVarSimplify.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index ab1076582f0..c78e3acf3ab 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -2189,6 +2189,11 @@ linearFunctionTestReplace(Loop *L,
IRBuilder<> Builder(BI);
+ // The new loop exit condition should reuse the debug location of the
+ // original loop exit condition.
+ if (auto *Cond = dyn_cast<Instruction>(BI->getCondition()))
+ Builder.SetCurrentDebugLocation(Cond->getDebugLoc());
+
// LFTR can ignore IV overflow and truncate to the width of
// BECount. This avoids materializing the add(zext(add)) expression.
unsigned CmpIndVarSize = SE->getTypeSizeInBits(CmpIndVar->getType());
OpenPOWER on IntegriCloud