<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial, helvetica, sans-serif;font-size:10pt;color:#000000;"><div><span class="Apple-style-span" style="font-family: verdana, geneva, helvetica, arial, sans-serif; ">Hi, <br><br>I use the llvm::ExtractCodeRegion to extract each loop into a separate function, but I have a problem when I run this on the SPEC CPU 2006 on the 401.bzip2 benchmark.  First I use clang -O3 to generate optimized llvm code and then I extract some loops from the module built from blocksort.c source file. <br><br>The problem is that the PHI nodes contained in the successors of the codeRepl include two or more incoming edges for different blocks contained in the loop. Therefore, when the loop is extracted in the new function, these incoming edges are updated to have an entry from the codeRepl block instead of the the original blocks. But in case there are incoming
 edges from more blocks belonging to the loop, this generates an invalid Phi node which contains multiple entries for the codeRepl block. <br><br>I use LLVM 2.8 and in the file CodeExtractor.cpp lines 730 - 745 when the Phi nodes in the successors are updated, there is a test to check that the Phi node does not contain an entry from the same BasicBlock from the loop. But there is no test to check if two different blocks of the loop reach the same phi node. (If I correctly understood this part of code... ) <br><br>Did I obtain an invalid loop or this kind of loops are not eligible for llvm::ExtractCodeRegion  ?   <br>Is there any other method to eliminate the PHI nodes except the reg2mem pass? I do not want to pollute the code with so many additional load instructions. Is it possible to dissolve the PHI nodes without reg2mem? <br><br>Thank you. <br>Alexandra</span></div><div style="position:fixed"></div>


</div><br>

      </body></html>