[PATCH] D120232: [SelectOpti][4/5] Loop Heuristics

Bradley Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 3 05:57:33 PDT 2022


bsmith added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectOptimize.cpp:745
+        InstCostMap[&I] = {IPredCost, INonPredCost};
+        MaxCost.PredCost = std::max(MaxCost.PredCost, IPredCost);
+        MaxCost.NonPredCost = std::max(MaxCost.NonPredCost, INonPredCost);
----------------
apostolakis wrote:
> davidxl wrote:
> > Should Sum (of cost in a SI group) be used instead of max?
> This computes the critical path which essentially is the cost of the last instruction of the critical path (and thus the instruction with the highest latency). This is regardless of how many select groups are included in the loop. These groups may or may not be part of the path. 
Is this really what we want though? As an example, a workload I'm looking at has a structure akin to:

```
----------------------------critical path
     \------------select-store
     \------------select-store
     \------------select-store
     \------------select-store
     \------------select-store
```

None of the selects are on the critical path, however they are still significant in terms of cost. This may be for a future patch that looks at resources, but it may be better to cost each path with a select on it individually, rather than costing the loop as a whole.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120232



More information about the llvm-commits mailing list