<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_extra"><br><div class="gmail_quote">2018-01-15 9:36 GMT+08:00 Linchuan Chen via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><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></blockquote><div><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">​The transformed code should be</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><div style="font-family:arial,sans-serif"><font color="#000000">    <b style="">int A[4];    </b></font></div><div style="font-family:arial,sans-serif"><b><font color="#000000"><br></font></b></div><div style="font-family:arial,sans-serif"><b><font color="#000000">    for (int i = 0; i < N; i+=4) {</font></b></div><div style="font-family:arial,sans-serif"><b><font color="#000000">        A[0] = M[i] + b;</font></b></div><div style="font-family:arial,sans-serif"><b><font color="#000000">        A[1] = M[i+1] + b;</font></b></div><div style="font-family:arial,sans-serif"><b><font color="#000000">        A[2] = M[i+2] + b;</font></b></div><div style="font-family:arial,sans-serif"><b><font color="#000000">        A[3] = M[i+3] + b;</font></b></div><div style="font-family:arial,sans-serif"><b><font color="#000000">    }</font></b></div></div></div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">​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. </div></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>Wei-Ren Chen (陳韋任)<br>Homepage: <a href="https://people.cs.nctu.edu.tw/~chenwj" target="_blank">https://people.cs.nctu.edu.tw/~chenwj</a></div></div></div>
</div></div>