<div dir="ltr"><div>Hi Fellows, </div><div><br></div><div>   In the following C code, </div><div><br></div><div>          for (int t = 0; t < N; ++t) { // loop A</div><div>             int result = 0;</div><div>             for (int i = 0; i < M; ++i) { // loop B</div>
<div>                ... ... ...</div><div>             }</div><div>          }</div><div><br></div><div>   clang puts "int result = 0" in the loop B's header (along with int i = 0). But </div><div>what I need is "int result = 0" residing in the preheader of the loop (I.e., in </div>
<div>a separated BB from where "int i = 0" is at). Is there an LLVM pass that can </div><div>force that to happen always?</div><div><br></div><div><br></div><div><br></div><div>                                                 __________</div>
<div>                           \                    |</div><div>                            \                  \|/</div><div>                            \/</div><div>                            %result = phi i32 [%val1, %BB1],[%val2, %BB2]</div>
<div>                            %i = phi i32 [%inc, %loopB.inc], [0, %loopB.preheader]</div><div>                            %cmp = icmp slt i32 %i, M</div><div>                            br i1 %cmp ...</div><div>                               \</div>
<div>                                \</div><div>                                \/</div><div><br></div><div>into</div><div><br></div><div>                                                 __________</div><div>                           \                    |</div>
<div>                            \                  \|/</div><div>                            \/</div><div>                            %result = phi i32 [%val1, %BB1],[%val2, %BB2]</div><div>                                            |</div>
<div>                                            |</div><div>                                           \|/  </div><div>                            %i = phi i32 [%inc, %loopB.inc], [0, %loopB.preheader]</div><div>                            %cmp = icmp slt i32 %i, M</div>
<div>                            br i1 %cmp ...</div><div>                               \</div><div>                                \</div><div>                                \/</div><div><br></div><div><br></div><div>Best Regards,</div>
<div>Paul</div><div><br></div></div>