[PATCH] D128547: [RISCV] Implement getVScaleForTuning and thus prefer scalable vectorization when enabled

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 24 11:54:41 PDT 2022


reames created this revision.
reames added reviewers: craig.topper, frasercrmck, kito-cheng.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, bollu, simoncook, johnrusso, rbar, asb, hiraditya, arichardson, mcrosier.
Herald added a project: All.
reames requested review of this revision.
Herald added subscribers: alextsao1999, pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.

LoopVectorizer uses getVScaleForTuning for deciding how to discount the cost of a potential vector factor by the amount of work performed.  Without the callback implemented, the vectorizer was defaulting to an estimated vscale of 1.  This results in fixed vectorization looking falsely profitable (since it used the command line VLEN).

The test change is pretty limited since a) we don't have much coverage of the vectorizer with scalable vectors at all, and b) what little coverage we have mostly uses i64 element types.  There's a separate issue with <vscale x 1 x i64> which prevents us from getting to this stage of costing, and thus only the one test explicitly written to avoid that is visible in the diff.  However, this is actually a very wide impact change as it changes the practical vectorization result when both fixed and scalable is enabled to scalable.

As an aside, I think the vectorizer is at little too strongly biased towards scalable when both are legal, but we can explore that separately.  For now, let's just get the cost model working the way it was intended.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128547

Files:
  llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
  llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
  llvm/test/Transforms/LoopVectorize/RISCV/scalable-basics.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128547.439831.patch
Type: text/x-patch
Size: 7176 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220624/42fc9093/attachment.bin>


More information about the llvm-commits mailing list