This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add cost model for SK_Broadcast
ClosedPublic

Authored by liaolucy on Apr 20 2022, 9:21 AM.

Details

Summary

Add cost model for broadcast shuffle in RISCVTTIImpl::getShuffleCost
with scalable vector. The cost model might not the best.

For scalable vector, BasicTTIImpl::getShuffleCost return invalid cost,
so this patch relies on the existing cost model in BasicTTIImpl.

Diff Detail

Event Timeline

liaolucy created this revision.Apr 20 2022, 9:21 AM
liaolucy requested review of this revision.Apr 20 2022, 9:21 AM
liaolucy retitled this revision from Add cost model for SK_Broadcast to [RISCV] Add cost model for SK_Broadcast.Apr 20 2022, 9:25 AM
liaolucy edited the summary of this revision. (Show Details)
rogfer01 added inline comments.Apr 27 2022, 11:06 PM
llvm/test/Analysis/CostModel/RISCV/rvv-shuffle.ll
14–15

I am curious with this one. I would expect this case to be 1 too. How is different to the other ones?

liaolucy added inline comments.Apr 27 2022, 11:30 PM
llvm/test/Analysis/CostModel/RISCV/rvv-shuffle.ll
14–15

I am curious with this one. I would expect this case to be 1 too. How is different to the other ones?

Actually, I just solved the crash problem. Cost is 1, it's ok for me

craig.topper added inline comments.Apr 28 2022, 9:33 PM
llvm/test/Analysis/CostModel/RISCV/rvv-shuffle.ll
14–15

I think it's being incorrectly identified as an identity shuffle because the minimum element count is 1 for the source and dest. The mask is stored using the minimum element count and the checks against the number of source and destination elements are also made using minimum element count.

craig.topper accepted this revision.Apr 28 2022, 9:35 PM

LGTM

llvm/test/Analysis/CostModel/RISCV/rvv-shuffle.ll
14–15

Let's commit this as is. And I'll work on a patch to fix identity shuffle detection.

This revision is now accepted and ready to land.Apr 28 2022, 9:35 PM
liaolucy updated this revision to Diff 425971.Apr 28 2022, 10:27 PM

Thanks craig.topper for the quick fix. rebase

This revision was landed with ongoing or failed builds.Apr 28 2022, 10:28 PM
This revision was automatically updated to reflect the committed changes.