[LLVMdev] CostModel analysis -- what is its actual purpose?

Arnold aschwaighofer at apple.com
Sun Feb 1 07:23:45 PST 2015


Yes.it is only meant to form tests of the cost model by writing llvm IR instructions. Typically, one IR instruction.

The only 'logic' it has today are the utility functions which allow for writing tests of horizontal vector reduction instruction costs. Since, there is no horizontal reduction IR instruction we have to model them as a sequence of instructions. That's what that logic does. The vectorizer does not have this logic because it sees a scalar reduction and then asks what the cost of doing this with vector instructions. It emits such a sequence of instructions but never tests for them (since this would mean the block was already vectorized).

A print would be fine where there not the issue of testing the horizontal reduction cost and you would still need a driver to print costs of all instructions in a basic block.

How did you port the alias analysis evaluator it does the same thing: it is an analysis that tests alias analysis.

In my opinion either of the two could be a pass instead of an analysis.

Sent from my iPhone

> On Feb 1, 2015, at 1:24 AM, Chandler Carruth <chandlerc at gmail.com> wrote:
> 
> Greetings,
> 
> So the CostModel 'analysis' today isn't actually an analysis at all. It is one of the only analyses which doesn't even have an interface available outside of the .cpp file, so it is literally impossible to use it today.
> 
> The only use is to form tests of TargetTransformInfo, but if that's really the only intent, then I have two somewhat large questions:
> 
> 1) Why isn't this just the implementation of the print method for TTI? Should I make it into that?
> 
> 2) Why is there so much logic in it? This doesn't really seem like it's *just* testing TTI, it almost seems its duplicating some logic in the vectorizers to ensure that logic behaves correctly.... But if so, that logic should really be de-duplicated into an actual analysis with an API that is used by the vectorizers...
> 
> Anyways, I'm asking because I've ported TTI to the new pass manager, but it the testing is quite weak. I can port CostModel as well, but I don't really know what the right port is given that it is an analysis which can only be used to print things.
> 
> -Chandler




More information about the llvm-dev mailing list