<div dir="ltr">Hi, guys,<div><br></div><div>I compiled a subroutine with -O2, and llvm backend produced codes like:</div><div><br></div><div>##################################################################</div><div>LBB0_32:</div>
<div> ...</div><div> R31 = -1</div><div> R20 = R31 * R20;</div><div> ....</div><div> bnz R2, LBB0_34</div><div>LBB0_31:<br clear="all"><div><div> ...</div><div> b LBB0_34</div></div><div>LBB0_33: # weird basic block?<br>
</div><div> R20 = R5</div><div>LBB0_34:<br></div><div> ....</div><div>##################################################################</div><div><br></div><div>Wrong answer is produced when executing bove codes. LBB0_33 is not used as destination basic block for any branch instruction, so its a dead basic block. Original C source codes need "R20 = R5" to restore its old value if "bnz R2, LBB0_34" does not change control flow.</div>
<div><br></div><div>So if I move LBB0_33 just after LBB0_32 as follows:</div><div><br></div><div><div>##################################################################</div><div>LBB0_32:</div><div> ...</div><div> R31 = -1</div>
<div> R20 = R31 * R20;</div><div> ....</div><div> bnz R2, LBB0_34</div><div><br></div><div><div>LBB0_33:<br></div><div> R20 = R5</div></div><div><br></div><div>LBB0_31:<br clear="all"><div><div> ...</div><div>
b LBB0_34</div></div><div><br></div><div>#LBB0_33: # weird basic block?</div><div># R20 = R5 </div><div><br></div><div>LBB0_34:<br></div><div> ....</div><div>##################################################################</div>
</div></div><div><br></div><div>Resulting codes are correct. If I compile original subroutine with -O0, result codes are also right.</div><div><br></div><div>I do not have any clue what happens when compiling with -O2.</div>
<div>Can someone make a suggestion?</div><div><br></div>-- <br>杨勇勇 (Yang Yong-Yong)
</div></div>