[llvm-dev] auto simd
quic_sanirudh via llvm-dev
llvm-dev at lists.llvm.org
Wed Jul 15 23:23:41 PDT 2020
Hi Jerry,
The way I understand it, the auto-vectorizer decides whether to “Widen” an instruction into a vector instruction is by calling one of the “get*Cost” methods of the TargetTransformInfo<https://llvm.org/doxygen/classllvm_1_1TargetTransformInfo.html> class. For example, take a look at this line in LoopVectorize.cpp<https://github.com/llvm/llvm-project/blob/master/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp#L6356> which is calling the TTI.getArithmeticInstrCost<https://github.com/llvm/llvm-project/blob/master/llvm/lib/Analysis/TargetTransformInfo.cpp#L690> for all the basic arithmetic instruction cases, and it passes in the instruction opcode, Vector Type and any other info needed. These get*Cost calls eventually end up with one of the <Backend>TargetTransformInfo methods, for example this is the ARM backend implementation<https://github.com/llvm/llvm-project/blob/master/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp#L827> for calculating the vector arithmetic instruction costs.
So I believe all you need to do to tune the auto-vectorizer for your backend is to implement a subclass of BaseTTIImplBase<T><http://llvm.org/doxygen/classllvm_1_1BasicTTIImplBase.html#details> as done here for ARM<https://github.com/llvm/llvm-project/blob/master/llvm/lib/Target/ARM/ARMTargetTransformInfo.h#L51> and then implement the appropriate get*Cost methods to return proper costs for your backend along with the getST and getTLI methods which are needed by the BaseTTIIimpl class. A few other methods you might need to implement for your <Backend>TargetTransformInfo are the getNumberOfRegisters to return the number of registers for a given (VectorType) RegisterClass, getMinimumVF (for the minimum vectorization factor for your subtarget), etc. You can take a look at any of the existing backend TTI implementations to get an idea as to how these methods have to be implemented.
P.S. I’m still relatively new to LLVM (little over 7 months of experience working on an LLVM backend), so I apologize if I’ve made any mistakes.
Thanks,
Anirudh
From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of ??? via llvm-dev
Sent: Thursday, July 16, 2020 8:48 AM
To: llvm-dev at lists.llvm.org
Subject: [EXT] [llvm-dev] auto simd
Hi, there
I am doing optimization for an new backend. And I have read the auto-vectorization guide,https://llvm.org/docs/Vectorizers.html.
The hardware support vector operation. I wonder how can I get the loop vectorizer tuned for my backend.
Is there any documents or suggestions? Thanks!
Best regards,
Jerry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200716/925192af/attachment-0001.html>
More information about the llvm-dev
mailing list