[llvm-dev] Source level code transformation V.S. IR-level code transformation
Linchuan Chen via llvm-dev
llvm-dev at lists.llvm.org
Sun Jan 14 17:36:16 PST 2018
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 reason I want to do it is to transform my code to a form that SLP
vectorizer is able to vectorize it.
I know there are a few approaches for transforming the code, the
simplest being a naive text processor for duplicating the assignment
instructions in the loop, but I don't think it a standard way for code
transformation.
I also got to know a few other alternatives:
1. using libTooling to edit the AST
2. transform the IR code of the loop, in a PASS, so that the SLP PASS
can consume the resulting IR
Does anyone know which alternative is the most used or most standard way
of doing such a transformation work? Thanks!
--
Sincerely,
Linchuan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180114/b850231e/attachment.html>
More information about the llvm-dev
mailing list