[PATCH] D129013: [RISCV] Enable (scalable) vectorization by default

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 1 13:14:11 PDT 2022


reames created this revision.
reames added reviewers: craig.topper, kito-cheng, frasercrmck, rogfer01.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, 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.

This change enables vectorization (using scalable vectorization only, fixed vectors are not yet enabled).  There is no test change as all of our tests are fixed to particular vectorization flags; if desired, I can add a test which exercises the default heuristics.

At this point, the resulting configuration should be both stable (e.g. no crashes), and profitable (i.e. few cases where scalar loops beat vector ones), but is not going to be particularly well tuned (i.e. we emit the best possible vector loop).  The goal of this change is to align testing across organizations and ensure the default configuration matches what downstreams are using as closely as possible.

I would appreciate any help testing this before it lands.  I've detailed my testing to date below, but as a practical matter, it's smaller than I'd prefer for something this major.

So far, I have successfully cross built the following: sqlite3, LLVM, Clang, Flang, LLD, LLVM's test-suite, spec2017.   Not all of these *link* due to problems with my cross compilation environments, but we do compile all of the source files, and all crashes have been fixed.

Additionally, I have successfully *run* (on qemu-riscv64*) the llvm-lit portion of check-llvm, and the test-suite.  Both have some failures, but everything I've looked at appears to be due to either a) human error in the run setup or b) cross build configuration problems.  So, we have at least some confidence that we're not miscompiling when vectorization is enabled.

- I had to use a downstream qemu-riscv64 implementation as the package available on ubuntu appears to not include +v at all.

Additionally, sqlite3, and clang + LLVM are invalid cost clean - meaning the cost model never returns Invalid when compiling them.  Other codebases - in particular test-suite - do return Invalid costs, and I don't consider that to be blocking.  After the fixes to bailout properly on invalid costs, an invalid cost should prevent vectorization, but otherwise have no impact.

I'll note that there's a bunch of work pending to improve the output of the vectorizer.  At the moment, I believe this all to be tuning work, and do not consider any of it blocking for this patch.

I have not done any native builds, or been able to run any of the resulting code on real hardware.  If anyone else has the potential to do so, I'd greatly appreciate the help.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129013

Files:
  llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h


Index: llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
===================================================================
--- llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
+++ llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
@@ -57,6 +57,7 @@
 
   bool shouldExpandReduction(const IntrinsicInst *II) const;
   bool supportsScalableVectors() const { return ST->hasVInstructions(); }
+  bool enableScalableVectorization() const { return ST->hasVInstructions(); }
   Optional<unsigned> getMaxVScale() const;
   Optional<unsigned> getVScaleForTuning() const;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129013.441777.patch
Type: text/x-patch
Size: 562 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220701/b9723c43/attachment.bin>


More information about the llvm-commits mailing list