[PATCH] D96030: NFC: Migrate CodeMetrics to work on InstructionCost

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 4 07:37:47 PST 2021


sdesmalen added inline comments.


================
Comment at: llvm/lib/Analysis/CodeMetrics.cpp:122
+  // properties.
+  InstructionCost NumInstsProxy = NumInsts;
+  InstructionCost NumInstsBeforeThisBB = NumInsts;
----------------
david-arm wrote:
> Hi @sdesmalen, I'm not entirely sure why we're using an InstructionCost here to be honest, when NumInsts is an unsigned and any new costs are immediately dereferenced below at line 183 after calling TTI.getUserCost?
Part of the value of InstructionCost comes when we'll add saturation, so that the value doesn't wrap for 'magical' values returned by TTI.get*Cost functions (targets may return some very high value to indicate something is expensive). By accumulating the values from TTI.get*Cost into an InstructionCost, it already prepares these cases for the future. I tried to imply that a bit with "using InstructionCost's arithmetic properties".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96030



More information about the llvm-commits mailing list