[PATCH] D60790: [LPM/BPI] Preserve BPI through trivial loop pass pipeline

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 22 10:12:01 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL358901: [LPM/BPI] Preserve BPI through trivial loop pass pipeline (e.g. LCSSA… (authored by reames, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60790?vs=195753&id=196087#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60790/new/

https://reviews.llvm.org/D60790

Files:
  llvm/trunk/lib/Transforms/Utils/LCSSA.cpp
  llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp
  llvm/trunk/test/Other/opt-O2-pipeline.ll
  llvm/trunk/test/Other/opt-O3-pipeline.ll
  llvm/trunk/test/Other/opt-Os-pipeline.ll


Index: llvm/trunk/test/Other/opt-Os-pipeline.ll
===================================================================
--- llvm/trunk/test/Other/opt-Os-pipeline.ll
+++ llvm/trunk/test/Other/opt-Os-pipeline.ll
@@ -258,7 +258,6 @@
 ; CHECK-NEXT:       Basic Alias Analysis (stateless AA impl)
 ; CHECK-NEXT:       Function Alias Analysis Results
 ; CHECK-NEXT:       Scalar Evolution Analysis
-; CHECK-NEXT:       Branch Probability Analysis
 ; CHECK-NEXT:       Block Frequency Analysis
 ; CHECK-NEXT:       Loop Pass Manager
 ; CHECK-NEXT:         Loop Sink
Index: llvm/trunk/test/Other/opt-O3-pipeline.ll
===================================================================
--- llvm/trunk/test/Other/opt-O3-pipeline.ll
+++ llvm/trunk/test/Other/opt-O3-pipeline.ll
@@ -276,7 +276,6 @@
 ; CHECK-NEXT:       Basic Alias Analysis (stateless AA impl)
 ; CHECK-NEXT:       Function Alias Analysis Results
 ; CHECK-NEXT:       Scalar Evolution Analysis
-; CHECK-NEXT:       Branch Probability Analysis
 ; CHECK-NEXT:       Block Frequency Analysis
 ; CHECK-NEXT:       Loop Pass Manager
 ; CHECK-NEXT:         Loop Sink
Index: llvm/trunk/test/Other/opt-O2-pipeline.ll
===================================================================
--- llvm/trunk/test/Other/opt-O2-pipeline.ll
+++ llvm/trunk/test/Other/opt-O2-pipeline.ll
@@ -271,7 +271,6 @@
 ; CHECK-NEXT:       Basic Alias Analysis (stateless AA impl)
 ; CHECK-NEXT:       Function Alias Analysis Results
 ; CHECK-NEXT:       Scalar Evolution Analysis
-; CHECK-NEXT:       Branch Probability Analysis
 ; CHECK-NEXT:       Block Frequency Analysis
 ; CHECK-NEXT:       Loop Pass Manager
 ; CHECK-NEXT:         Loop Sink
Index: llvm/trunk/lib/Transforms/Utils/LCSSA.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Utils/LCSSA.cpp
+++ llvm/trunk/lib/Transforms/Utils/LCSSA.cpp
@@ -31,6 +31,7 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/BasicAliasAnalysis.h"
+#include "llvm/Analysis/BranchProbabilityInfo.h"
 #include "llvm/Analysis/GlobalsModRef.h"
 #include "llvm/Analysis/LoopPass.h"
 #include "llvm/Analysis/ScalarEvolution.h"
@@ -442,6 +443,7 @@
     AU.addPreserved<GlobalsAAWrapperPass>();
     AU.addPreserved<ScalarEvolutionWrapperPass>();
     AU.addPreserved<SCEVAAWrapperPass>();
+    AU.addPreserved<BranchProbabilityInfoWrapperPass>();
 
     // This is needed to perform LCSSA verification inside LPPassManager
     AU.addRequired<LCSSAVerificationPass>();
@@ -485,5 +487,8 @@
   PA.preserve<GlobalsAA>();
   PA.preserve<SCEVAA>();
   PA.preserve<ScalarEvolutionAnalysis>();
+  // BPI maps terminators to probabilities, since we don't modify the CFG, no
+  // updates are needed to preserve it.
+  PA.preserve<BranchProbabilityAnalysis>();
   return PA;
 }
Index: llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp
+++ llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp
@@ -48,6 +48,7 @@
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/AssumptionCache.h"
 #include "llvm/Analysis/BasicAliasAnalysis.h"
+#include "llvm/Analysis/BranchProbabilityInfo.h"
 #include "llvm/Analysis/DependenceAnalysis.h"
 #include "llvm/Analysis/GlobalsModRef.h"
 #include "llvm/Analysis/InstructionSimplify.h"
@@ -740,6 +741,7 @@
       AU.addPreservedID(LCSSAID);
       AU.addPreserved<DependenceAnalysisWrapperPass>();
       AU.addPreservedID(BreakCriticalEdgesID);  // No critical edges added.
+      AU.addPreserved<BranchProbabilityInfoWrapperPass>();
     }
 
     /// verifyAnalysis() - Verify LoopSimplifyForm's guarantees.
@@ -812,6 +814,12 @@
   PA.preserve<SCEVAA>();
   PA.preserve<ScalarEvolutionAnalysis>();
   PA.preserve<DependenceAnalysis>();
+  // BPI maps conditional terminators to probabilities, LoopSimplify can insert
+  // blocks, but it does so only by splitting existing blocks and edges. This
+  // results in the interesting property that all new terminators inserted are
+  // unconditional branches which do not appear in BPI. All deletions are
+  // handled via ValueHandle callbacks w/in BPI. 
+  PA.preserve<BranchProbabilityAnalysis>();
   return PA;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60790.196087.patch
Type: text/x-patch
Size: 4278 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190422/adb0db11/attachment.bin>


More information about the llvm-commits mailing list