<div dir="ltr">Hi all, <div>I meet this problem when <span style="font-family:arial,sans-serif;font-size:13.888888359069824px">compiling the</span> TREAM benchmark (<a href="http://www.cs.virginia.edu/stream/FTP/Code/">http://www.cs.virginia.edu/stream/FTP/Code/</a>) with enable-misched</div>
<div><br></div><div>The small function will be scheduled as good code, but if opt inline this function, the inline part will be scheduled as bad code.</div><div><br></div><div>so I rewrite a simple code as attached link (foo.c), and compiled with two different methods:<br>
</div><div><br></div><div><b><font face="arial, helvetica, sans-serif">method A:</font></b></div><div><b><font face="arial, helvetica, sans-serif">$clang -O3 foo.c -static -S -o foo.s -mllvm -enable-misched -mllvm -unroll-count=4 <font color="#000000">--target=arm </font><font color="#000000">-mfloat-abi=hard </font>-mcpu=cortex-a9 -fno-vectorize -fno-slp-vectorize</font></b></div>
<div><b><font face="arial, helvetica, sans-serif"><br></font></b></div><div><b><font face="arial, helvetica, sans-serif">and</font></b></div><div><b><font face="arial, helvetica, sans-serif"><br></font></b></div><div><b><font face="arial, helvetica, sans-serif">method B:</font></b></div>
<div><b><font face="arial, helvetica, sans-serif"><font color="#000000">$clang foo.c -S -emit-llvm -o foo.bc --target=arm -mfloat-abi=hard -mcpu=cortex-a9</font><br></font></b></div><div>
<p style="margin-top:0pt;margin-bottom:0pt;margin-left:0in;direction:ltr;word-break:normal"><font color="#000000" face="arial, helvetica, sans-serif"><b>$opt foo.bc -O3 -unroll-count=4 -o foo.opt.bc</b></font></p><b><font face="arial, helvetica, sans-serif">
</font></b><p style="margin-top:0pt;margin-bottom:0pt;margin-left:0in;direction:ltr;word-break:normal"><font color="#000000" face="arial, helvetica, sans-serif"><b>$llc foo.opt.bc -o foo.opt.s -march=arm -mcpu=cortex-a9 -enable-misched</b></font><br>
</p><p style="margin-top:0pt;margin-bottom:0pt;margin-left:0in;direction:ltr;word-break:normal"><span style="font-size:12pt;font-family:Calibri;color:black"><br></span></p><p style="margin-top:0pt;margin-bottom:0pt;margin-left:0in;word-break:normal">
<span style="font-size:12pt;font-family:Calibri;color:black">(ps. I had checked with debug-pass=structure, so I think they are </span><font color="#000000" face="Calibri"><span style="font-size:15.972221374511719px">equivalently)</span></font></p>
<p style="margin-top:0pt;margin-bottom:0pt;margin-left:0in;word-break:normal"><br></p><p style="margin-top:0pt;margin-bottom:0pt;margin-left:0in;word-break:normal"><span style="color:black;font-family:Calibri;font-size:12pt">but the result is different: </span><br>
</p><p style="margin-top:0pt;margin-bottom:0pt;margin-left:0in;word-break:normal"><span style="font-size:12pt;font-family:Calibri;color:black">You can find the </span><font color="#000000" face="Calibri"><span style="font-size:15.972221374511719px">LBB1_4 of foo.s, it always reuses the same reg for computation, but LBB1_4 of foo.opt.s doesn't.</span></font></p>
<p style="margin-top:0pt;margin-bottom:0pt;margin-left:0in;word-break:normal"><font color="#000000" face="Calibri"><span style="font-size:15.972221374511719px"><br></span></font></p><p style="margin-top:0pt;margin-bottom:0pt;margin-left:0in;word-break:normal">
<font color="#000000" face="Calibri"><span style="font-size:15.972221374511719px">My question is how to just use clang (method A) to achieve B result? <br>Or i am missing something here?</span></font></p><p style="margin-top:0pt;margin-bottom:0pt;margin-left:0in;word-break:normal">
<font color="#000000" face="Calibri"><span style="font-size:15.972221374511719px"><br></span></font></p><p style="margin-top:0pt;margin-bottom:0pt;margin-left:0in;word-break:normal"><span style="font-family:arial,sans-serif;font-size:13.888888359069824px">I really appreciate </span><span class="" style="background-color:rgb(255,255,204);font-family:arial,sans-serif;font-size:13.888888359069824px">any</span><span style="font-family:arial,sans-serif;font-size:13.888888359069824px"> </span><span class="" style="background-color:rgb(255,255,204);font-family:arial,sans-serif;font-size:13.888888359069824px">help and suggestions</span><span style="font-family:arial,sans-serif;font-size:13.888888359069824px">.</span><font color="#000000" face="Calibri"><span style="font-size:15.972221374511719px"><br>
</span></font></p><p style="margin-top:0pt;margin-bottom:0pt;margin-left:0in;word-break:normal"><span style="font-family:arial,sans-serif;font-size:13.888888359069824px">Thanks</span><br></p><p style="margin-top:0pt;margin-bottom:0pt;margin-left:0in;word-break:normal">
<span style="font-family:arial,sans-serif;font-size:13.888888359069824px"><br></span></p>Kuan-Hsu<br><br>------- file link -------
</div><div><p style="margin-top:0pt;margin-bottom:0pt;margin-left:0in;word-break:normal">foo.c: <a href="http://goo.gl/nVa2K0">http://goo.gl/nVa2K0</a><br></p><div>foo.s: <a href="http://goo.gl/ML9eNj">http://goo.gl/ML9eNj</a></div>
<div>foo.opt.s: <a href="http://goo.gl/31PCnf">http://goo.gl/31PCnf</a></div></div></div>