[PATCH] D28975: [LV] Introducing VPlan to model the vectorized code and drive its transformation

Renato Golin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 30 09:28:44 PST 2017


rengolin added inline comments.


================
Comment at: docs/VectorizationPlan.rst:244
+   model and the code generation phases, where the cost estimation must
+   evaluate the to-be-generated code accurately.
+
----------------
mkuper wrote:
> rengolin wrote:
> > Aligning cost and codegen will always have to rely on heuristics, even if we codegen multiple variations, as this is modelling IR, not assembly.
> > 
> > We should respect the cost analysis and we should strive to do the best we can, yes, but we shouldn't try to estimate the generated code **accurately** over other improvements.
> I think "codegen" here means "the IR generated by the vectorizer", not "backend code generation". See line 123.
> Actually getting the cost model to accurately estimate the cost of complex IR constructs is an orthogonal problem.
Right, but costs are associated with what assembly instructions will be generated by those IR instructions. So we associate zero cost to a lot of shuffles because we know they'll be merged into the load or add. But the same shuffles, in a different pattern, will demand a sequence of insert/extract instructions that will cost a lot more than zero.

This is my point, that **accuracy** is not possible at this level and that, as you say, it's an orthogonal problem to solve.

Maybe the word we're looking for is "reliably"?


================
Comment at: docs/VectorizationPlan.rst:425
+
+   a. including those that take place after Legal, which is kept intact;
+   b. including those that use the Cost Model - refactor it slightly to expose
----------------
mkuper wrote:
> rengolin wrote:
> > Couldn't different VPlans expose different legality issues? For example, for different combination of UFs and VFs?
> I think this is why the design says that Legal would "encode constraints". I guess the LVP would have to consult Legal per-potential-VPlan to see whether it's feasible or not?
Right, this is what I didn't understand. We can do it both ways: one legal consulting all plans, or each plan consulting legal.

I'd prefer we act on plans for everything, as it would be a cleaner concept and an easier move.

As I wrote in another comment: first we iterate through all plans and discard all illegals, then we calculate the costs, sort and pick the best.

We could even (in the far future) have multiple costs per plan (VF, UF, code-size, hazards, etc) and sort by a formula that takes all of them into account.


https://reviews.llvm.org/D28975





More information about the llvm-commits mailing list