[PATCH] D37471: [TTI] Implement getCastInstrCost

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 6 07:10:20 PDT 2017


hfinkel added a comment.

In https://reviews.llvm.org/D37471#862124, @samparker wrote:

> Is there any way of telling which API each function is apart of? I was thinking that there was a model driven by TLI and DataLayout and then one specified by a TTI implementation in the backend. Most of the functions end up returning a TargetCostConstant, which I see are the mixed costs you described. Does it make sense to try to bundle all those costs into one enum?


Both cost models can be overridden by the targets, although there's been, at the present time, more explicit target customization of the reciprocal throughput model used by the vectorizers. TargetCostConstants are currently used by the user-cost model. There isn't really a mid-end-native model (I'm not sure what that would mean, TLI and DL don't really have cost information aside from DL's idea of the maximum size of legal types). Regarding bundling them, so you mean like this: https://reviews.llvm.org/D37170 (Carrot is working on this)?

> The issue I was having was that my test case wasn't being simplified into a single block because of the estimated cost of the trunc i64. Like I said, I know this is more easily handled by implementing another hook in the backend, but thought it would be better to try something in the mid-end too.

So you're trying to affect the user-cost model, and implementing the right backend hook seems like the right approach (either by implementing something like isTruncateFree/isZExtFree, or by directly customizing the model if there's more context dependence needed).

> thanks,
> sam




https://reviews.llvm.org/D37471





More information about the llvm-commits mailing list