<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial">Hi Tobias,<br><span style="white-space: pre-wrap; font-size: 14px; line-height: 1.7;">At 2013-09-19 22:59:25,"Tobias Grosser" <tobias@grosser.es> wrote:</span><br><pre>>On 09/19/2013 04:46 PM, Star Tan wrote:
>> Hi Tobias,
>>
>>
>> I am trying to move Polly later.
>>
>>
>> LLVM provides some predefined ExtensionPointTy:
>>      EP_EarlyAsPossible,
>>      EP_ModuleOptimizerEarly,
>>      EP_LoopOptimizerEnd,
>>      EP_ScalarOptimizerLate,
>>      ...
>>
>>
>> Currently Polly uses "EP_EarlyAsPossible" to run as early as possible.  As what you suggested:
>>> Instead of removing canonicalization passes, I believe we may want to
>>> move Polly to a later place in the pass manager. Possibly at the
>>> beginning of the loop optimizer right before PM.add(createLoopRotatePass());
>> I want to move it to the point immediate after someone Loop optimization pass, e.g. MPM.add(createLoopRotatePass()).  However no predefined ExtensionPointTy is available for this purpose. Instead, the "EP_ModuleOptimizerEarly" would move Polly before all loop optimization passes.
>>
>>
>> In my option, there are two solutions: one is to use "EP_ModuleOptimizerEarly" (only modify the tool/polly/lib/RegisterPasses.cpp) to move Polly before all loop optimization passes; the other is to add a new ExtensionPointTy, e.g. "EP_LoopRotateEnd" and move Polly exactly immediate after the "LoopRotate" pass (need to modify tool/polly/lib/RegisterPasses.cpp, include/llvm/Transforms/IPO/PassManagerBuilder.h and lib/Transforms/IPO/PassManagerBuilder.cpp). We can use the second way to investigate other points to start Polly.
>>
>> Is my understanding correct? Do you have any further suggestion?
>
>Yes, fully correct. I would play with solution two. Why would you add 
>Polly after the loop rotate pass?</pre><pre>Forgot it. I just wanted to give an immature example to show how to move Polly to other points.</pre><pre>>I would possibly add it at the beginning of the loop optimizer (right 
>before the loop rotation pass) possibly experimenting with a new 
>extension point called EP_LoopOptimizerBegin.
>
Thanks for your advice. <span style="font-size: 14px; line-height: 1.7;">I have tried to move Polly immediately before the loop rotation pass. The </span>temporary<span style="font-size: 14px; line-height: 1.7;"> patch file can be reached on </span><a href="http://llvm.org/bugs/attachment.cgi?id=11262" style="font-size: 14px; line-height: 1.7;">http://llvm.org/bugs/attachment.cgi?id=11262</a><span style="font-size: 14px; line-height: 1.7;">.</span></pre><pre>First of all, I evaluated Polly's canonicalization passes based on this patch file. Results are posted on <a href="http://188.40.87.11:8000/" style="font-size: 14px; line-height: 1.7;">http://188.40.87.11:8000</a>, which contains two new runs:</pre><pre><span class="Apple-tab-span" style="white-space:pre">     </span>PollyNoGen_loop (run 56): move polly later but keep all polly canonicalization passes;</pre><pre><span class="Apple-tab-span" style="white-space:pre">       </span>PollyNoGen_loop_nocan(run57): move polly later a!
 nd delete all polly canonicalization passes;</pre><pre>Comparison is shown on  <a href="http://188.40.87.11:8000/db_default/v4/nts/57?compare_to=56&baseline=56" style="font-size: 14px; line-height: 1.7;">http://188.40.87.11:8000/db_default/v4/nts/57?compare_to=56&baseline=56</a>. <span style="font-size: 14px; line-height: 1.7;">It seems that even we move polly later, those canonicalization passes still have significant impact on the final execution-time performance. </span></pre><pre>A very bad news is that Polly would produce wrong code if we move Polly right immediately before the loop rotate pass. Many benchmarks in LLVM testsuite would fail in execution. I constructed a relatively simple testcase for this bug as shown on <a href="http://llvm.org/bugs/show_bug.cgi?id=17323" style="font-size: 14px; line-height: 1.7;">http://llvm.org/bugs/show_bug.cgi?id=17323</a>. The key problem is Polly would produce wrong basic blocks like this:</pre><pre><span class="Appl!
 e-tab-span" style="white-space:pre"> </span>polly.loop_header27:      
                        ; preds = %vector.body, %polly.loop_header27
  <span class="Apple-tab-span" style="white-space:pre">               </span>br label %polly.loop_header27</pre><pre>For your information, the source code is posted on <a href="http://llvm.org/bugs/attachment.cgi?id=11263" target="_blank" style="font-size: 14px; line-height: 1.7;">http://llvm.org/bugs/attachment.cgi?id=11263</a> and the LLVM IR code is posted on <a href="http://llvm.org/bugs/attachment.cgi?id=11264" target="_blank" style="font-size: 14px; line-height: 1.7;">http://llvm.org/bugs/attachment.cgi?id=11264</a></pre><pre>I have not yet found out why Polly produces such wrong code.  However, maybe I should also investigate other points where we can move Polly. Do you have any suggestion?</pre><pre>Best,</pre><pre>Star Tan</pre></div>