Alex Susu via llvm-dev
2016-Aug-21 20:15 UTC
[llvm-dev] LoopVectorize module - some possible enhancements
Hello, Michael, I'd like to ask if we can enhance the LoopVectorize LLVM module (I am currently using a version from Jul 2016). More exactly: - do you envision to support in the near future LLVM IR gather and scatter intrinsics (as described at http://llvm.org/docs/LangRef.html#llvm-masked-gather-intrinsics and scatter)? I see you have defined some methods that should use them like: - bool isLegalMaskedGather(Type *DataType); - void InnerLoopVectorizer::vectorizeMemoryInstruction(Instruction *Instr) which defines a bool CreateGatherScatter, etc I gave to clang a simple vector add C program with step/stride 2 with flag "-avx2", but the resulting vector code does NOT use gather nor scatter. - did you try to consider pathological cases of loops such as: for (int i = 0; i < N; i += 2) { C[i/2] = A[i/2] + B[i/2]; } which does NOT get vectorized with my version of LoopVectorize, although it's simple to reason it's trivial to vectorize. One more question: how can I obtain an expression for the bounds and the step of the original loop? For example, when I print the ScalarEvolution object in LoopVectorizationLegality::isConsecutivePtr(), I can get the value reported in "Exits" for the indvars.iv instruction which is the upper bound for the loop getting vectorized. Thank you, Alex
Renato Golin via llvm-dev
2016-Aug-23 12:00 UTC
[llvm-dev] LoopVectorize module - some possible enhancements
Hi Alex, Intel was doing the scatter/gather support for AVX, so I'm copying Elena who should know more about this. cheers, --renato On 21 August 2016 at 21:15, Alex Susu via llvm-dev <llvm-dev at lists.llvm.org> wrote:> Hello, Michael, > I'd like to ask if we can enhance the LoopVectorize LLVM module (I am > currently using a version from Jul 2016). > > More exactly: > - do you envision to support in the near future LLVM IR gather and > scatter intrinsics (as described at > http://llvm.org/docs/LangRef.html#llvm-masked-gather-intrinsics and > scatter)? > I see you have defined some methods that should use them like: > - bool isLegalMaskedGather(Type *DataType); > - void InnerLoopVectorizer::vectorizeMemoryInstruction(Instruction > *Instr) which defines a bool CreateGatherScatter, etc > I gave to clang a simple vector add C program with step/stride 2 with > flag "-avx2", but the resulting vector code does NOT use gather nor scatter. > > - did you try to consider pathological cases of loops such as: > for (int i = 0; i < N; i += 2) { > C[i/2] = A[i/2] + B[i/2]; > } > which does NOT get vectorized with my version of LoopVectorize, > although it's simple to reason it's trivial to vectorize. > > One more question: how can I obtain an expression for the bounds and the > step of the original loop? For example, when I print the ScalarEvolution > object in LoopVectorizationLegality::isConsecutivePtr(), I can get the value > reported in "Exits" for the indvars.iv instruction which is the upper bound > for the loop getting vectorized. > > > Thank you, > Alex > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Nuzman, Dorit via llvm-dev
2016-Aug-24 08:24 UTC
[llvm-dev] LoopVectorize module - some possible enhancements
Hi Alex, About the gather/scatter intrinsics mechanism: it is already supported (they are part of LLVM-IR), but each target has to decide whether to allow using them for auto-vectorization. On X86, avx2 gathers are not enabled for vectorization due to cost considerations. With avx512, Gathers and Scatters are enabled for vectorization (so if you use -march=skx or -mavx512bw there's a chance you'll see them used). Dorit -----Original Message----- From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of Renato Golin via llvm-dev Sent: Tuesday, August 23, 2016 15:00 To: Alex Susu <alex.e.susu at gmail.com> Cc: llvm-dev <llvm-dev at lists.llvm.org> Subject: Re: [llvm-dev] LoopVectorize module - some possible enhancements Hi Alex, Intel was doing the scatter/gather support for AVX, so I'm copying Elena who should know more about this. cheers, --renato On 21 August 2016 at 21:15, Alex Susu via llvm-dev <llvm-dev at lists.llvm.org> wrote:> Hello, Michael, > I'd like to ask if we can enhance the LoopVectorize LLVM module (I > am currently using a version from Jul 2016). > > More exactly: > - do you envision to support in the near future LLVM IR gather and > scatter intrinsics (as described at > http://llvm.org/docs/LangRef.html#llvm-masked-gather-intrinsics and > scatter)? > I see you have defined some methods that should use them like: > - bool isLegalMaskedGather(Type *DataType); > - void > InnerLoopVectorizer::vectorizeMemoryInstruction(Instruction > *Instr) which defines a bool CreateGatherScatter, etc > I gave to clang a simple vector add C program with step/stride 2 > with flag "-avx2", but the resulting vector code does NOT use gather nor scatter. > > - did you try to consider pathological cases of loops such as: > for (int i = 0; i < N; i += 2) { > C[i/2] = A[i/2] + B[i/2]; > } > which does NOT get vectorized with my version of LoopVectorize, > although it's simple to reason it's trivial to vectorize. > > One more question: how can I obtain an expression for the bounds > and the step of the original loop? For example, when I print the > ScalarEvolution object in > LoopVectorizationLegality::isConsecutivePtr(), I can get the value > reported in "Exits" for the indvars.iv instruction which is the upper bound for the loop getting vectorized. > > > Thank you, > Alex > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev_______________________________________________ LLVM Developers mailing list llvm-dev at lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev --------------------------------------------------------------------- Intel Israel (74) Limited This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
Maybe Matching Threads
- RFC: [LV] any objections in moving isLegalMasked* check from Legal to CostModel? (Cleaning up LoopVectorizationLegality)
- RFC: [LV] any objections in moving isLegalMasked* check from Legal to CostModel? (Cleaning up LoopVectorizationLegality)
- RFC: [LV] any objections in moving isLegalMasked* check from Legal to CostModel? (Cleaning up LoopVectorizationLegality)
- RFC: [LV] any objections in moving isLegalMasked* check from Legal to CostModel? (Cleaning up LoopVectorizationLegality)
- RFC: [LV] any objections in moving isLegalMasked* check from Legal to CostModel? (Cleaning up LoopVectorizationLegality)