This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add a really basic cost model for SK_Splice.
ClosedPublic

Authored by craig.topper on Feb 8 2022, 10:48 PM.

Details

Summary

While testing scalable vectors I found that if we generate a
vector splice intrinsic and run the code through the loop unroller,
we'll crash due to an invalid cost.

This adds a basic cost based on the 2 slide instructions used by the
lowering in D119303.

We probably need to factor LMUL into this, but that's true for
arithmetic instructions too. So I've ignored for the moment.

Diff Detail

Event Timeline

craig.topper created this revision.Feb 8 2022, 10:48 PM
craig.topper requested review of this revision.Feb 8 2022, 10:48 PM

clang-format

ABataev added inline comments.Feb 9 2022, 4:05 AM
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
168

Shall we include the cost of extra calculations for slidedown+slideup offsets?

craig.topper added inline comments.Feb 9 2022, 7:53 AM
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
168

Other than the vsetvlis, the read of vlenb and the addi end up being loop invariant and hoisted by LICM.

Should we cost all of the instructions? Should we cost the vsetvlis?

ABataev added inline comments.Feb 9 2022, 7:55 AM
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
168

That's the question I'm asking myself. It may be not important for Loop Optimizer but important for SLP. Would be good to have a call (or a flag) for this kind of overhead.

craig.topper added inline comments.Feb 9 2022, 7:58 AM
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
168

This cost function is specific to scalable vectors, which I don't think SLP generates today. Will it in the future?

ABataev accepted this revision.Feb 9 2022, 8:11 AM

LG

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
168

Maybe. But ok, let's move ahead with this estimation for now.

This revision is now accepted and ready to land.Feb 9 2022, 8:11 AM
This revision was landed with ongoing or failed builds.Feb 9 2022, 11:43 AM
This revision was automatically updated to reflect the committed changes.