[PATCH] D62123: [NFC] SimplifyCFG prof branch_weighs handling is simplified

David Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 20 12:05:29 PDT 2019


davidxl added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:3632
+    auto W0 = SIW.getSuccessorWeight(0);
+    SwitchInstProfBranchWeightsWrapper::CaseWeightOpt NewW;
+    if (W0) {
----------------
Perhaps add a 'SplitDefault' method in SwitchInstProfBranchWeightsWrapper class?


================
Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:4438
 
-  SmallVector<uint64_t, 8> Weights;
-  bool HasWeight = HasBranchWeights(SI);
-  if (HasWeight) {
-    GetBranchWeights(SI, Weights);
-    HasWeight = (Weights.size() == 1 + SI->getNumCases());
-  }
-
-  // Remove dead cases from the switch.
-  for (ConstantInt *DeadCase : DeadCases) {
-    SwitchInst::CaseIt CaseI = SI->findCaseValue(DeadCase);
-    assert(CaseI != SI->case_default() &&
-           "Case was not found. Probably mistake in DeadCases forming.");
-    if (HasWeight) {
-      std::swap(Weights[CaseI->getCaseIndex() + 1], Weights.back());
-      Weights.pop_back();
+  if (!DeadCases.empty()) {
+    SwitchInstProfBranchWeightsWrapper SIW(*SI);
----------------
Early return instead of doing the guard here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62123





More information about the llvm-commits mailing list