[llvm] r328058 - [MustExecute] Shwo the effect of using full loop info variant
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 20 16:00:54 PDT 2018
Author: reames
Date: Tue Mar 20 16:00:54 2018
New Revision: 328058
URL: http://llvm.org/viewvc/llvm-project?rev=328058&view=rev
Log:
[MustExecute] Shwo the effect of using full loop info variant
Most basic possible test for the logic used by LICM.
Also contains a speculative build fix for compiles which complain about a definition of a stuct K; followed by a declaration as class K;
Modified:
llvm/trunk/include/llvm/Transforms/Utils/LoopUtils.h
llvm/trunk/lib/Analysis/MustExecute.cpp
llvm/trunk/test/Analysis/MustExecute/loop-header.ll
Modified: llvm/trunk/include/llvm/Transforms/Utils/LoopUtils.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/LoopUtils.h?rev=328058&r1=328057&r2=328058&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/LoopUtils.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/LoopUtils.h Tue Mar 20 16:00:54 2018
@@ -40,7 +40,6 @@ class BasicBlock;
class DataLayout;
class Loop;
class LoopInfo;
-class LoopSafetyInfo;
class OptimizationRemarkEmitter;
class PredicatedScalarEvolution;
class PredIteratorCache;
Modified: llvm/trunk/lib/Analysis/MustExecute.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MustExecute.cpp?rev=328058&r1=328057&r2=328058&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MustExecute.cpp (original)
+++ llvm/trunk/lib/Analysis/MustExecute.cpp Tue Mar 20 16:00:54 2018
@@ -185,11 +185,13 @@ FunctionPass *llvm::createMustExecutePri
}
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
Modified: llvm/trunk/test/Analysis/MustExecute/loop-header.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/MustExecute/loop-header.ll?rev=328058&r1=328057&r2=328058&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/MustExecute/loop-header.ll (original)
+++ llvm/trunk/test/Analysis/MustExecute/loop-header.ll Tue Mar 20 16:00:54 2018
@@ -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:
More information about the llvm-commits
mailing list