[llvm-dev] Source level code transformation V.S. IR-level code transformation

陳韋任 via llvm-dev llvm-dev at lists.llvm.org
Mon Jan 15 04:25:11 PST 2018


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180115/79f75553/attachment.html>


More information about the llvm-dev mailing list