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

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 17 02:35:50 PST 2020


david-arm added inline comments.


================
Comment at: llvm/include/llvm/Analysis/TargetTransformInfo.h:257-258
     }
-    llvm_unreachable("Unknown instruction cost kind");
+    if (Cost == -1)
+      Cost.setInvalid();
+    return Cost;
----------------
ctetreau wrote:
> Why is this being done? Did the code not handle -1 correctly before?
So this patch doesn't change the getUserCost interface - that will be done in a later patch. getUserCost returns -1 for invalid costs, or costs that it cannot determine. This matches up with our new Invalid state in InstructionCost so as a temporary measure I've added the check here. A later patch will remove this "if (Cost == -1)" code and ensure that getUserCost returns a proper Invalid Cost.


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

https://reviews.llvm.org/D91174



More information about the llvm-commits mailing list