[llvm-dev] Source level code transformation V.S. IR-level code transformation
Linchuan Chen via llvm-dev
llvm-dev at lists.llvm.org
Mon Jan 15 15:11:15 PST 2018
Thanks Weiren!
My goal is to transform the code automatically by doing some code
analysis, instead of rewriting it manually.
To do this source level auto transformation, do you have any
suggestions on what tool to use? Thanks again!!
On Mon, Jan 15, 2018 at 04:25 陳韋任 via llvm-dev <llvm-dev at lists.llvm.org>
wrote:
> 2018-01-15 9:36 GMT+08:00 Linchuan Chen via llvm-dev <
> llvm-dev at lists.llvm.org>:
>
>> Dear all,
>> I'm working on a simple code transformation problem that can be
>> described as below:
>>
>> for a C++ loop:
>>
>> *for (int i = 0; i < N; ++i) {*
>> * a = M[i] + b;*
>> * }*
>>
>> I want to transform it to:
>>
>> *int A[4]; *
>>
>> * for (int i = 0; i < N; ++i) {*
>> * A[0] = M[i] + b;*
>> * A[1] = M[i] + b;*
>> * A[2] = M[i] + b;*
>> * A[3] = M[i] + b;*
>> * }*
>>
>
> The transformed code should be
>
> *int A[4]; *
>
> * for (int i = 0; i < N; i+=4) {*
> * A[0] = M[i] + b;*
> * A[1] = M[i+1] + b;*
> * A[2] = M[i+2] + b;*
> * A[3] = M[i+3] + b;*
> * }*
>
> I would suggest you manually rewrite the code, and see if SLP works on
> it. I think doing the transformation in source level would be easier. Or
> you can observe the IR for both side, see if you can think of algorithm
> handling your case.
>
> --
> Wei-Ren Chen (陳韋任)
> Homepage: https://people.cs.nctu.edu.tw/~chenwj
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
--
Sincerely,
Linchuan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180115/95e409ed/attachment.html>
More information about the llvm-dev
mailing list