[llvm-dev] Document to understand vectorized code

Craig Topper via llvm-dev llvm-dev at lists.llvm.org
Sun Jun 6 22:49:37 PDT 2021


Shufflevector is a powerful instruction that can be used to copy a scalar
to every elements of a vector, concatenate smaller vectors into a larger
vector, rearrange elements one or two vectors, etc. Without example code I
can't say for sure what the use of shufflevector in your case is for.

~Craig


On Sun, Jun 6, 2021 at 10:44 PM Sudakshina Dutta <sudakshina at iitgoa.ac.in>
wrote:

> Dear Craig,
>
> Thanks for your reply. It seems the control flow of the vectorized program
> is very different from that of the source code. Is there any document
> describing difference in control flow, the reason for using shufflevector,
> etc ?
>
> Sudakshina
>
> On Mon, 7 Jun 2021, 07:41 Craig Topper, <craig.topper at gmail.com> wrote:
>
>> There's some notes here https://llvm.org/docs/Vectorizers.html but I
>> didn't look too closely at it.  If you compile with -fno-discard-values
>> names or use a debug build, some of the basic blocks will be named similar
>> to the CFG diagram in this section
>> https://llvm.org/docs/Vectorizers.html#epilogue-vectorization
>>
>> ~Craig
>>
>>
>> On Sun, Jun 6, 2021 at 7:04 PM Sudakshina Dutta via llvm-dev <
>> llvm-dev at lists.llvm.org> wrote:
>>
>>> Dear Stefanos,
>>>
>>> I want to understand how the generated code works. For example, the code
>>> that I generated using -Rpass=loop-vectorize -Rpass-analysis=loop-vectorize
>>> has many shufflevector and other instructions. I wanted to have a document
>>> (if there exists any) where an example on loop-vectorization is done with
>>> some explanation on the workflow of the code.
>>>
>>> Thanks,
>>> Sudakshina
>>>
>>> On Mon, Jun 7, 2021 at 7:03 AM Stefanos Baziotis <
>>> stefanos.baziotis at gmail.com> wrote:
>>>
>>>> Hi Sudakshina,
>>>>
>>>> First, it helps if you can put your code in a godbolt snippet, like
>>>> this [1]. It helps people in multiple ways (e.g., they don't have to
>>>> download files, they can see exactly what cmd arguments you used, they can
>>>> tweak the cmd arguments without having LLVM on their machine etc.).
>>>>
>>>> Is there any comprehensive tutorial/document to understand generated
>>>>> instructions or the semantics of the vectorized code ?
>>>>
>>>>
>>>> This is quite generic, what is more specifically that you want to
>>>> understand? Do you want to understand what each individual instruction
>>>> does? Do you maybe understand that but
>>>> you don't know what is the general method to generate, let's say by
>>>> hand, vectorized code (or more specifically, branching vectorized code). Or
>>>> maybe, you want to understand
>>>> how _LLVM_ generates this code, i.e., the inner workings of the
>>>> vectorization passes.
>>>>
>>>> Best,
>>>> Stefanos
>>>>
>>>> [1] https://godbolt.org/z/8eKqnrMPn
>>>>
>>>> Στις Κυρ, 6 Ιουν 2021 στις 6:17 π.μ., ο/η Sudakshina Dutta via llvm-dev
>>>> <llvm-dev at lists.llvm.org> έγραψε:
>>>>
>>>>> Dear all,
>>>>>
>>>>> Greetings. I have generated a vectorized code from a C source file
>>>>> (attached). Is there any comprehensive tutorial/document to understand
>>>>> generated instructions or the semantics of the vectorized code ?
>>>>>
>>>>> Thanks,
>>>>> Sudakshina
>>>>> _______________________________________________
>>>>> LLVM Developers mailing list
>>>>> llvm-dev at lists.llvm.org
>>>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>>>>
>>>> _______________________________________________
>>> LLVM Developers mailing list
>>> llvm-dev at lists.llvm.org
>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210606/bbca960b/attachment-0001.html>


More information about the llvm-dev mailing list