summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/Transforms/Utils/LoopUtils.h1
-rw-r--r--llvm/lib/Analysis/MustExecute.cpp12
-rw-r--r--llvm/test/Analysis/MustExecute/loop-header.ll7
3 files changed, 13 insertions, 7 deletions
diff --git a/llvm/include/llvm/Transforms/Utils/LoopUtils.h b/llvm/include/llvm/Transforms/Utils/LoopUtils.h
index f503a34d474..131a4b09c09 100644
--- a/llvm/include/llvm/Transforms/Utils/LoopUtils.h
+++ b/llvm/include/llvm/Transforms/Utils/LoopUtils.h
@@ -40,7 +40,6 @@ class BasicBlock;
class DataLayout;
class Loop;
class LoopInfo;
-class LoopSafetyInfo;
class OptimizationRemarkEmitter;
class PredicatedScalarEvolution;
class PredIteratorCache;
diff --git a/llvm/lib/Analysis/MustExecute.cpp b/llvm/lib/Analysis/MustExecute.cpp
index c3b4de738b4..437946a6ebb 100644
--- a/llvm/lib/Analysis/MustExecute.cpp
+++ b/llvm/lib/Analysis/MustExecute.cpp
@@ -185,11 +185,13 @@ FunctionPass *llvm::createMustExecutePrinter() {
}
bool isMustExecuteIn(const Instruction &I, Loop *L, DominatorTree *DT) {
- // TODO: move loop specific code to analysis
- //LoopSafetyInfo LSI;
- //computeLoopSafetyInfo(&LSI, L);
- //return isGuaranteedToExecute(I, DT, L, &LSI);
- return isGuaranteedToExecuteForEveryIteration(&I, L);
+ // TODO: merge these two routines. For the moment, we display the best
+ // result obtained by *either* implementation. This is a bit unfair since no
+ // caller actually gets the full power at the moment.
+ LoopSafetyInfo LSI;
+ computeLoopSafetyInfo(&LSI, L);
+ return isGuaranteedToExecute(I, DT, L, &LSI) ||
+ isGuaranteedToExecuteForEveryIteration(&I, L);
}
/// \brief An assembly annotator class to print must execute information in
diff --git a/llvm/test/Analysis/MustExecute/loop-header.ll b/llvm/test/Analysis/MustExecute/loop-header.ll
index 4d4c1ff90fc..3e729993d42 100644
--- a/llvm/test/Analysis/MustExecute/loop-header.ll
+++ b/llvm/test/Analysis/MustExecute/loop-header.ll
@@ -88,9 +88,14 @@ exit:
; FIXME: handled by loop safety info, test it
define i1 @nothrow_loop(i32* noalias %p, i32 %high) {
; CHECK-LABEL: @nothrow_loop(
-; CHECK-LABEL: loop:
+; CHECK-LABEL: loop:
; CHECK: %iv = phi i32 [ 0, %entry ], [ %iv.next, %next ] ; (mustexec in: loop)
; CHECK: br label %next ; (mustexec in: loop)
+; CHECK-LABEL: next:
+; CHECK: %v = load i32, i32* %p ; (mustexec in: loop)
+; CHECK: %iv.next = add nuw nsw i32 %iv, 1 ; (mustexec in: loop)
+; CHECK: %exit.test = icmp slt i32 %iv, %high ; (mustexec in: loop)
+; CHECK: br i1 %exit.test, label %exit, label %loop ; (mustexec in: loop)
; CHECK-NOT: mustexec
entry:
OpenPOWER on IntegriCloud