Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

LLVM Cost Tuning #404

Open
Open
@omnisip

Description

@omnisip

Hi everyone,

I'm creating this ticket to keep Compiler Level Common Subexpression Elimination (#403) separate from LLVM Cost Tuning -- which is a common annoyance but is very different from the way we optimize the implementations of each individual instruction.

@tlively is suggesting we come up with a principled methodology for how we do this, so here's what I'm thinking.

Let's create a Google Sheet with every instruction we have listed on the left hand side. On the top for each column, we can put everyone's name and/or their github handle. Then in each row, they can put the reciprocal cost in tp they think should exist for each instruction.

As an example:

Instruction Dan Weber (@omnisip)
v128.load 0.25
v128.load8_splat 0.75
v128.load16_splat 0.75
... ...

Then if anyone has specific comments about why they scored or costed something a certain way, they can highlight the cell and put sheet comments. For instance, I'm going to calculate the cost of my load operation based on what I would expect it to cost on x64 and ARM64 with a weighted blend. Since x64 affects me more because I use it more than ARM for WASM SIMD, I'm going to weigh it 75% and 25% for ARM64 and take the average.

As a side effect, I'll put a higher cost on i8x16.shr_s and i8x16.shr_u because no native instruction exists on x64 and they have a long sequence of instructions required to emulate the functionality.

If people are okay with this idea -- or -- have better ideas -- by all means, put them here. It might be possible for us to have more than 1 cost model with clang and WASM if we know that our audience has more of a certain device or architecture type than others.

Updated:

Here is the Google Sheet for posting your proposed model: https://docs.google.com/spreadsheets/d/1dYXjm40a2XzhjLGchlcMSdibSRvCvxUEBLHVyUc-Ivo/edit?usp=sharing

Focus first on scoring strategy and methodology, and then on individual instructions. If your proposed methodology is easy enough to calculate, it's possible someone else can help fill in the instruction costs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions