<div dir="ltr">Hi Fellows,<div> </div><div> I have a question about why DemotePHIToStack inserts the StoreInst's right before the terminator instruction of each incoming basic block. Shouldn't it make more sense to put them immediate below where the original incoming value was computed? For example, </div>
<div><br></div><div> %indvar = phi i32 [ 0, %LoopHeader ], [ %nextindvar, %Loop ]<br></div><div><br></div><div>where, in the second incoming BB,</div><div><br></div><div>(front) ......</div><div> some instructions here</div>
<div> ......</div><div> %nextindar = add one<br></div><div>(A) .....</div><div> several instructions here</div><div>(B) .....</div>
<div> br label %toindvar</div><div><br></div><div> </div><div> Reg2Mem puts the StoreInst at point (B), where I think it would make more sense to put it at point (A). Are these ways two equivalent? Are there any particular reason to choose what was implemented? Thanks a bunch.</div>
<div><br></div><div><br></div><div>Best Regards,</div><div>Paul</div></div>