[PATCH] D91174: [Analysis] Introduce a new InstructionCost class

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 13 03:39:06 PST 2020


david-arm added inline comments.


================
Comment at: llvm/include/llvm/Analysis/InstructionCost.h:42
+  T Value;
+  CostState State;
+
----------------
nikic wrote:
> Please make "invalid" a special value (like -1) instead.
Hi @nikic , do you mean remove the CostState and use a set of special values to define any possible state such as invalid? The reason I chose not to do this was for two reasons:

1. If we ever want to support an additional state in future then it means another special value, e.g. -2. I thought it was better to avoid having a list of special values and simply encode the state separately.
2. There are plenty of examples in the codebase where costs can go negative, for example when calculating the cost budget remaining for some loop optimisations or in the SLPVectorizer. In such cases you could hit a value of -1 accidentally during normal operation and it would then be treated as invalid.

Does anyone else have any thoughts about this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91174



More information about the llvm-commits mailing list