[PATCH] D91957: [Analysis] Migrate more high level cost functions to using InstructionCost

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 13 22:42:57 PST 2020


sdesmalen added inline comments.


================
Comment at: llvm/lib/Analysis/CodeMetrics.cpp:179
 
+  notDuplicatable |= !NumInsts.isValid();
+
----------------
If the basic-block contains an instruction that would have an Invalid codesize-cost, that means it can't be expanded and having such an instruction in the block is an error. So you can just dereference TTI.getUserCost(...) here directly (which will fail when the cost is invalid). That also removes the need for a lot of the other changes.


================
Comment at: llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp:303
+
+  unsigned LoopSize = *(Metrics.NumInsts.getValue());
   if (!LoopSize)
----------------
nit: the extra parenthesis are not required, e.g. `unsigned LoopSize = *Metrics.NumInsts.getValue()`;


================
Comment at: llvm/lib/Transforms/Scalar/LoopFlatten.cpp:320
   // loop but not in the inner loop to be executed extra times.
-  if (RepeatedInstrCost > RepeatedInstructionThreshold) {
+  if (!RepeatedInstrCost.isValid() ||
+      RepeatedInstrCost > RepeatedInstructionThreshold) {
----------------
The same holds true here (that you can just dereference RepeatedInstrCost) because the cost should never be Invalid.


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

https://reviews.llvm.org/D91957



More information about the llvm-commits mailing list