<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<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 all,</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);">
Hi! Recently, I try to combine the passes SeparateConstOffsetFromGEP and LoopStrengthReduction to transform the multiplication in the lowered GEP IRs into addition.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
However, it seems LoopStrengthReduction is unable to remove all the multiplications for the element offset calculation.<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
My test code is shown below and thanks a lot in advance for your time and suggestion!</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
-----------------------------------------------</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div style="color: #d4d4d4; background-color: #1e1e1e; font-family: 'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback'; font-weight: normal; font-size: 14px; line-height: 19px">
<div><span style="color: #c586c0">#define</span><span style="color: #569cd6"> </span><span style="color: #dcdcaa">NI</span><span style="color: #569cd6"> </span><span style="color: #b5cea8">16</span></div>
<div><span style="color: #c586c0">#define</span><span style="color: #569cd6"> </span><span style="color: #dcdcaa">NJ</span><span style="color: #569cd6"> </span><span style="color: #b5cea8">18</span></div>
<div><span style="color: #c586c0">#define</span><span style="color: #569cd6"> </span><span style="color: #dcdcaa">NK</span><span style="color: #569cd6"> </span><span style="color: #b5cea8">22</span></div>
<div><span style="color: #c586c0">#define</span><span style="color: #569cd6"> </span><span style="color: #dcdcaa">NL</span><span style="color: #569cd6"> </span><span style="color: #b5cea8">24</span></div>
<div><span style="color: #569cd6">void</span><span> </span><span style="color: #dcdcaa">kernel_2mm</span><span>(</span><span style="color: #569cd6">int</span><span> ni,
</span><span style="color: #569cd6">int</span><span> nj, </span><span style="color: #569cd6">int</span><span> nk,
</span><span style="color: #569cd6">int</span><span> nl,</span></div>
<div><span> </span><span style="color: #569cd6">int</span><span> alpha,</span></div>
<div><span> </span><span style="color: #569cd6">int</span><span> beta,</span></div>
<div><span> </span><span style="color: #569cd6">int</span><span> tmp[NI][NJ],</span></div>
<div><span> </span><span style="color: #569cd6">int</span><span> A[NI][NK],</span></div>
<div><span> </span><span style="color: #569cd6">int</span><span> B[NK][NJ],</span></div>
<div><span> </span><span style="color: #569cd6">int</span><span> C[NJ][NL],</span></div>
<div><span> </span><span style="color: #569cd6">int</span><span> D[NI][NL])</span></div>
<div><span>{</span></div>
<div><span> </span><span style="color: #569cd6">int</span><span> i, j, k;</span></div>
<br>
<div><span> </span><span style="color: #6a9955">/* D := alpha*A*B*C + beta*D */</span></div>
<div><span> </span><span style="color: #c586c0">for</span><span> (i </span><span>=</span><span> </span><span style="color: #b5cea8">0</span><span>; i
</span><span><</span><span> NI; i</span><span>++</span><span>)</span></div>
<div><span> </span><span style="color: #c586c0">for</span><span> (j </span><span>=</span><span> </span><span style="color: #b5cea8">0</span><span>; j
</span><span><</span><span> NJ; j</span><span>++</span><span>)</span></div>
<div><span> {</span></div>
<div><span> tmp[i][j] </span><span>=</span><span> </span><span style="color: #b5cea8">0</span><span>;</span></div>
<div><span> </span><span style="color: #c586c0">for</span><span> (k </span>
<span>=</span><span> </span><span style="color: #b5cea8">0</span><span>; k </span>
<span><</span><span> NK; </span><span>++</span><span>k)</span></div>
<div><span> tmp[i][j] </span><span>+=</span><span> alpha </span><span>*</span><span> A[i][k]
</span><span>*</span><span> B[k][j];</span></div>
<div><span> }</span></div>
<div><span> </span><span style="color: #c586c0">for</span><span> (i </span><span>=</span><span> </span><span style="color: #b5cea8">0</span><span>; i
</span><span><</span><span> NI; i</span><span>++</span><span>)</span></div>
<div><span> </span><span style="color: #c586c0">for</span><span> (j </span><span>=</span><span> </span><span style="color: #b5cea8">0</span><span>; j
</span><span><</span><span> NL; j</span><span>++</span><span>)</span></div>
<div><span> {</span></div>
<div><span> D[i][j] </span><span>*=</span><span> beta;</span></div>
<div><span> </span><span style="color: #c586c0">for</span><span> (k </span>
<span>=</span><span> </span><span style="color: #b5cea8">0</span><span>; k </span>
<span><</span><span> NJ; </span><span>++</span><span>k)</span></div>
<div><span> D[i][j] </span><span>+=</span><span> tmp[i][k] </span><span>*</span><span> C[k][j];</span></div>
<div><span> }</span></div>
<div><span>}</span></div>
<br>
</div>
<br>
</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);">
<br>
</div>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<span id="ms-rterangepaste-start"></span>
<div><font size="2" face="Calibri,sans-serif"><span style="font-size:12pt">Best regards,</span></font><span style="font-size:12pt">
</span><span style="font-size:12pt"></span>
<div><span style="font-size:12pt"></span>
<div style="margin:0"><font size="2" face="Calibri,sans-serif"><span style="font-size:12pt">------------------------------------------</span></font></div>
<span style="font-size:12pt"></span></div>
<span style="font-size:12pt"></span>
<div><span style="font-size:12pt"></span>
<div style="margin:0"><font size="2" face="Calibri,sans-serif"><span style="font-size:12pt">Tingyuan LIANG</span></font></div>
<span style="font-size:12pt"></span></div>
<span style="font-size:12pt"></span>
<div><span style="font-size:12pt"></span>
<div style="margin:0"><font size="2" face="Calibri,sans-serif"><span style="font-size:12pt">MPhil Student</span></font></div>
<span style="font-size:12pt"></span></div>
<span style="font-size:12pt"></span>
<div><span style="font-size:12pt"></span>
<div style="margin:0"><font size="2" face="Calibri,sans-serif"><span style="font-size:12pt">Department of Electronic and Computer Engineering</span></font></div>
<span style="font-size:12pt"></span></div>
<span style="font-size:12pt"></span>
<div><span style="font-size:12pt"></span>
<div style="margin:0"><font size="2" face="Calibri,sans-serif"><span style="font-size:12pt">The Hong Kong University of Science and Technology</span></font></div>
<span style="font-size:12pt"></span></div>
<span style="font-size:12pt"></span></div>
<span style="font-size:12pt"></span><span style="font-size:12pt"></span><span id="ms-rterangepaste-end"></span></div>
</div>
</body>
</html>