<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Dear LLVM developers,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I'm a beginner with LLVM, and I want to see how different loop optimization passes influence the performance. For example, I've generated IR code, and I would like to use "Loop Interchange" as the only loop optimization pass.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
However, when I simply used `<span style="font-size: 10pt; font-family: courier; color: rgb(51, 51, 51); background-color: rgba(0, 0, 0, 0); line-height: normal;">opt -loop-interchange input.ll -</span><span style="font-size: 10pt; font-family: Courier; color: rgb(51, 51, 51); background-color: rgb(248, 248, 248);"><span style="font-family: courier; font-size: 10pt; line-height: normal; color: rgb(51, 51, 51); background-color: rgba(0, 0, 0, 0);" class="">S
-o</span></span><span style="font-size: 10pt; font-family: courier; color: rgb(51, 51, 51); background-color: rgba(0, 0, 0, 0); line-height: normal;"> output.ll</span><span style="color: rgb(0, 0, 0); font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; background: var(--white);">`
command, the IR code didn't change. I guess the reason may be the "-loop-interchange" pass also depends on other passes, so I should also specify some other passes before the loop interchange pass. But how do I know these dependencies?</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; background: var(--white);"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; background: var(--white);">Here is my C program to test loop interchange:</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: courier; font-size: 10pt; line-height: normal; color: rgb(51, 51, 51); background-color: rgba(0, 0, 0, 0);">int main() {</span><br>
<div><span style="font-family: courier; font-size: 10pt; line-height: normal; color: rgb(51, 51, 51); background-color: rgba(0, 0, 0, 0);"> int i=0;</span><br>
</div>
<div><span style="font-family: courier; font-size: 10pt; line-height: normal; color: rgb(51, 51, 51); background-color: rgba(0, 0, 0, 0);"> int j=0;</span><br>
</div>
<div><span style="font-family: courier; font-size: 10pt; line-height: normal; color: rgb(51, 51, 51); background-color: rgba(0, 0, 0, 0);"> int a[333][222];</span><br>
</div>
<div><span style="font-family: courier; font-size: 10pt; line-height: normal; color: rgb(51, 51, 51); background-color: rgba(0, 0, 0, 0);"> for (i=0; i <222; i++) {</span><br>
</div>
<div><span style="font-family: courier; font-size: 10pt; line-height: normal; color: rgb(51, 51, 51); background-color: rgba(0, 0, 0, 0);"> for (j=0; j <333; j++) {</span><br>
</div>
<div><span style="font-family: courier; font-size: 10pt; line-height: normal; color: rgb(51, 51, 51); background-color: rgba(0, 0, 0, 0);"> a[j][i] = i * j;</span><br>
</div>
<div><span style="font-family: courier; font-size: 10pt; line-height: normal; color: rgb(51, 51, 51); background-color: rgba(0, 0, 0, 0);"> } </span></div>
<div><span style="font-family: courier; font-size: 10pt; line-height: normal; color: rgb(51, 51, 51); background-color: rgba(0, 0, 0, 0);"> }</span><br>
</div>
<span style="font-family: courier; font-size: 10pt; line-height: normal; color: rgb(51, 51, 51); background-color: rgba(0, 0, 0, 0);"> return 0; </span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: courier; font-size: 10pt; line-height: normal; color: rgb(51, 51, 51); background-color: rgba(0, 0, 0, 0);">}</span><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; background: var(--white);"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; background: var(--white);"><br>
</span></div>
<div><span style="background: var(--white);"><font color="#000000" face="Calibri, Arial, Helvetica, sans-serif" size="3">I also tried this command, but still no influence: </font>
<div title="Page 2" style="caret-color: rgb(0, 0, 0);">
<div style="background-color: rgb(255, 255, 255);">
<pre style="color: rgb(0, 0, 0); font-family: -webkit-standard; font-size: 12pt;"><span style="font-size: 10pt; font-family: Courier; color: rgb(51, 51, 51)">opt -mem2reg -simplifycfg -loops -lcssa -loop-simplify -loop-rotate -loop-
interchange input.ll -S -o output.ll</span></pre>
<pre><span style="color: rgb(0, 0, 0); font-family: calibri, arial, helvetica, sans-serif; font-size: 12pt; background-color: rgba(0, 0, 0, 0);">Thank you so much.</span><br></pre>
<pre><font color="#000000" face="calibri, arial, helvetica, sans-serif">Best,</font></pre>
<pre><font color="#000000" face="calibri, arial, helvetica, sans-serif">Luyuan Wang</font></pre>
<pre style="color: rgb(0, 0, 0); font-family: -webkit-standard; font-size: 12pt;"><br></pre>
<pre style="color: rgb(0, 0, 0); font-family: -webkit-standard; font-size: 12pt;"><span style="font-size: 10pt; font-family: Courier; color: rgb(51, 51, 51)"><br></span></pre>
</div>
</div>
</span></div>
</body>
</html>