<div dir="ltr"><div dir="ltr"><div>Hi Das,</div><div><br></div><div>Thanks for your reply! I have received similar responses from @LebedevRI on the IRC.</div><div><br></div><div>After I modified the arguments for opt as the following, my loops can be unroll-and-jam successfully:<br>
<span style="font-size:9pt;color:rgb(31,73,125)">-loop-unroll-and-jam -allow-unroll-and-jam -unroll-and-jam-count=2</span></div><div><span style="font-size:9pt;color:rgb(31,73,125)"><br></span></div><div><span style="font-size:9pt;color:rgb(31,73,125)">
<span style="background-color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0)">'loop-unroll-and-jam' and 'allow-unroll-and-jam' are both needed to turn on the functionality.<br></span></span></span></span></div><div><span style="font-size:9pt;color:rgb(31,73,125)"><span style="background-color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0)"><br></span></span></span></span></div><div><span style="font-size:9pt;color:rgb(31,73,125)"><span style="background-color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0)">Thanks again. Have a nice day.<br></span></span></span></span></div><div><span style="font-size:9pt;color:rgb(31,73,125)"><span style="background-color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style=""></span></span></span></span>
</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Das, Dibyendu <<a href="mailto:Dibyendu.Das@amd.com">Dibyendu.Das@amd.com</a>> 於 2019年4月25日 週四 下午4:24寫道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="EN-US">
<div class="gmail-m_-643133654341864320WordSection1">
<p class="MsoNormal"><span style="font-size:9pt;color:rgb(31,73,125)">Try the combo:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9pt;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:9pt;color:rgb(31,73,125)">-enable-unroll-and-jam -allow-unroll-and-jam -unroll-and-jam-count=4<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9pt;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><b>From:</b> llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>> <b>On Behalf Of
</b>ZHEN WEI via llvm-dev<br>
<b>Sent:</b> Thursday, April 25, 2019 12:13 PM<br>
<b>To:</b> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<b>Subject:</b> [llvm-dev] How to use the pass 'Unroll and Jam'<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<div>
<div>
<p class="MsoNormal">Dear LLVM developers,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Recently I want to try the pass '-loop-unroll-and-jam' to observe how the IR is transformed, but I don't see the IR changed after doing the following steps.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12pt">Here are the details for preparing my experiment and I have tried the LLVM 6, 7 and 8:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">1) Simple 2D array source code (loop.c) is given<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">```<u></u><u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal">#define M 32768<u></u><u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal">#define N 32768<u></u><u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal">double a[M][N], b[M][N], c[M][N];<u></u><u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal">int main() {<u></u><u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal"> for (int i = 0; i < M; i++) {<u></u><u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal"> for (int j = 0; j < N; j++) {<u></u><u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal"> c[i][j] = a[i][j] + b[i][j];<u></u><u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal"> }<u></u><u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal"> }<u></u><u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal"> return 0;<u></u><u></u></p>
</div>
<div style="margin-left:30pt">
<p class="MsoNormal">}<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12pt">```<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">2) Create an LLVM IR file<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">./bin/clang -O1 loop.c -emit-llvm -S -o loop.ll<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">3) Run the 'unroll-and-jam' pass<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">./bin/opt -loop-unroll-and-jam loop.ll -S -o loop-unrolljam.ll<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I added the option '--debug-pass=Structure' to the opt, and I can see the 'Unroll and Jam loops' indeed executed by the Loop Pass Manager.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">```<u></u><u></u></p>
</div>
<div>
<div style="margin-left:30pt">
<p class="MsoNormal"> ModulePass Manager<br>
FunctionPass Manager<br>
Dominator Tree Construction<br>
Basic Alias Analysis (stateless AA impl)<br>
Function Alias Analysis Results<br>
Natural Loop Information<br>
Scalar Evolution Analysis<br>
Dependence Analysis<br>
Canonicalize natural loops<br>
LCSSA Verifier<br>
Loop-Closed SSA Form Pass<br>
Loop Pass Manager<br>
Unroll and Jam loops<br>
Module Verifier<br>
Print Module IR<u></u><u></u></p>
</div>
<p class="MsoNormal">```<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I also tried to add the option '-debug' to the opt to see if there is the debug information printed by LoopUnrollAndJam, but nothing.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Thank you very much.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">-- <u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-family:"PMingLiU",serif">Zhen Wei (魏禛)</span><br>
<span style="font-family:"PMingLiU",serif">Master Student</span><br>
<span style="font-family:"PMingLiU",serif;color:black">Department of Computer Science & Information Engineering</span><br>
<span style="font-family:"PMingLiU",serif;color:black">National Taiwan University</span><br>
<span style="font-family:"PMingLiU",serif">Email: <a href="mailto:zhenwei.tw@gmail.com" target="_blank">
zhenwei.tw@gmail.com</a></span><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><span><span style="font-family:pmingliu,serif">Zhen Wei (魏禛)</span><br><span style="font-family:pmingliu,serif">Master Student</span><br><span style="color:rgb(0,0,0);font-family:pmingliu,serif">Department of Computer Science & Information Engineering</span><br><span style="color:rgb(0,0,0);font-family:pmingliu,serif">National Taiwan University</span><br><span style="font-family:pmingliu,serif">Email: <a href="mailto:zhenwei.tw@gmail.com" target="_blank">zhenwei.tw@gmail.com</a></span><span style="font-family:pmingliu,serif"></span></span></div></div></div></div></div></div></div></div></div>