<div dir="ltr">Dear all,<div>    I'm working on a simple code transformation problem that can be described as below:</div><div> </div><div>    for a C++ loop:</div><div><br></div><div>    <b><font color="#38761d">for (int i = 0; i < N; ++i) {</font></b></div><div><b><font color="#38761d">        a = M[i] + b;</font></b></div><div><b><font color="#38761d">    }</font></b></div><div><br></div><div>    I want to transform it to:</div><div>    </div><div><font color="#ff0000">    <b>int A[4];    </b></font></div><div><b><font color="#ff0000"><br></font></b></div><div><b><font color="#ff0000">    for (int i = 0; i < N; ++i) {</font></b></div><div><b><font color="#ff0000">        A[0] = M[i] + b;</font></b></div><div><b><font color="#ff0000">        A[1] = M[i] + b;</font></b></div><div><b><font color="#ff0000">        A[2] = M[i] + b;</font></b></div><div><b><font color="#ff0000">        A[3] = M[i] + b;</font></b></div><div><b><font color="#ff0000">    }</font></b></div><div><br></div><div>   The reason I want to do it is to transform my code to a form that SLP vectorizer is able to vectorize it.</div><div><br></div><div>   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.</div><div><div><br></div><div>   I also got to know a few other alternatives: </div><div><ol><li>using libTooling to edit the AST<br></li><li>transform the IR code of the loop, in a PASS, so that the SLP PASS can consume the resulting IR</li></ol><div>   Does anyone know which alternative is the most used or most standard way of doing such a transformation work? Thanks!</div></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span style="font-family:Arial;color:rgb(35,35,35);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">Sincerely,</span><div><span style="font-family:Arial;color:rgb(35,35,35);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">Linchuan</span></div></div></div>
</div></div>