<div dir="ltr"><div class="gmail_extra"><div>Tim and guys,</div><div><br></div><div>let's look at the following example:<br></div><div>============</div><div>unsigned char f;<br></div><div>void main()</div><div>{</div>
<div> for(unsigned char i = 0; i < f;i ++)</div><div> asm("nop");</div><div>}</div><div>================</div><div><br></div><div>the optimized LLVM code was as follows:</div><div><br></div><div>====================</div>
<div><p class="MsoNormal"><span lang="EN-US">1.define void @main() nounwind {</span></p>
<p class="MsoNormal"><span lang="EN-US">2.entry:</span></p>
<p class="MsoNormal"><span lang="EN-US">3. %0
= load i8* @f, align 1, !tbaa !0</span></p>
<p class="MsoNormal"><span lang="EN-US">4. %cmp4 = icmp eq i8 %0, 0</span></p>
<p class="MsoNormal"><span lang="EN-US">5. br
i1 %cmp4, label %for.end, label %for.body</span></p>
<p class="MsoNormal"><span lang="EN-US">6 </span></p>
<p class="MsoNormal"><span lang="EN-US">7.for.body: ; preds = %entry, %for.body</span></p>
<p class="MsoNormal"><span lang="EN-US">8. %i.05 = phi i8 [ %inc, %for.body ], [ 0, %entry ]</span></p>
<p class="MsoNormal"><span lang="EN-US">9. tail call void asm sideeffect "nop", ""() nounwind,
!srcloc !2</span></p>
<p class="MsoNormal"><span lang="EN-US">10. %inc = add i8 %i.05, 1</span></p>
<p class="MsoNormal"><span lang="EN-US">11. %1
= load i8* @f, align 1, !tbaa !0</span></p>
<p class="MsoNormal"><span lang="EN-US">12. %cmp = icmp ult i8 %inc, %1</span></p>
<p class="MsoNormal"><span lang="EN-US">13. br
i1 %cmp, label %for.body, label %for.end</span></p>
<p class="MsoNormal"><span lang="EN-US">14.</span></p>
<p class="MsoNormal"><span lang="EN-US">15.for.end: ;
preds = %for.body, %entry</span></p>
<p class="MsoNormal"><span lang="EN-US">16. ret
void</span></p>
<p class="MsoNormal"><span lang="EN-US">17.}</span></p><p class="MsoNormal"><span lang="EN-US">===============</span></p><p class="MsoNormal"><span lang="EN-US"><br></span></p><p class="MsoNormal"><span lang="EN-US">From line 3 to 5, whether f is equal to 0 is checked first.</span></p>
<p class="MsoNormal"><span lang="EN-US"><br></span></p><p class="MsoNormal">because the profit of the optimization did not make sense for the target.</p><p class="MsoNormal">why it did not make sense in our target was out the scope of the post.</p>
<p class="MsoNormal"><br></p><p class="MsoNormal">I was asking for help, can I prevent this optimization in command line or which function i need to work on to skip such optimization in front end?</p><p class="MsoNormal">
<br></p><p class="MsoNormal"><br></p><p class="MsoNormal"><br></p><p class="MsoNormal">thanks,</p><p class="MsoNormal"><br></p><p class="MsoNormal">cheers,</p><p class="MsoNormal"><br></p><p class="MsoNormal">hilbert</p><p class="MsoNormal">
<br></p><p class="MsoNormal"> </p><p class="MsoNormal"><br></p><p class="MsoNormal"><span lang="EN-US"><br></span></p><p class="MsoNormal"><span lang="EN-US"><br></span></p></div></div></div>