<div dir="ltr"><div>test.c :</div><div>-----------------------------------------------------------------------</div><div><div>int foo(int a)</div><div>{</div><div> int zero = 0;</div><div> for (int i = 0; i < 10000; i++)</div><div> zero *= a;</div><div> return zero;</div><div>}</div></div><div>-------------------------------------------------------------------------</div><div><br></div><div>run clang : clang -O2 -S test.c -o test.s</div><div><br></div><div>My clang version is 3.7.1.</div><div>We will get a horrible assembly output.<br></div><div><br></div><div>Why constant propagation and other optimization skills can not find out that variable zero is initialized 0, and the only statement in for loop (i.e. zero *= a) always get a 0?</div><div><br></div><div>I can read the clang/llvm source, Please tell me more details.</div><div><br></div><div>THX</div><div><br></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><font face="nsimsun, monospace"><span style="color:rgb(51,51,51);line-height:24px;white-space:pre-wrap;background-color:rgb(241,254,221)">业精于勤</span><span style="color:rgb(51,51,51);line-height:24px;white-space:pre-wrap;background-color:rgb(241,254,221)">,</span><span style="color:rgb(51,51,51);line-height:24px;white-space:pre-wrap;background-color:rgb(241,254,221)">荒于嬉..</span></font></div></div></div>
</div>