<div dir="ltr">Hi Dan,<div><br></div><div>I consider your question again, and now I think the lattice lowering order in this algorithm should be "overdefined -> constant/constant_range".</div><div><br></div><div>At first look, following the text book it seems the lattice value TOP should be "undefined", and BOTTOM should be "overdefined". But this is not true for the specific implementation in this LLVM algorithm.</div><div><br></div><div>In this algorithm, the lowering order is</div><div><br></div><div>Overdefined(TOP) -> constant/constant_range -> Undefined(BOTTOM).</div><div><br></div><div>In order to easily implement the algorithm, originally the BBLV is initialized to be BOTTOM, and this doesn't mean the lowering start point is "Undefined", and it should still be "Overdefined" instead. If we never touch it in the algorithm, it will be kept as it is. This is why once we visit a value at a specific BB, the algorithm will change Undefined to be Overdefined immediately at the very beginning of each lowering procedure.</div><div><br></div><div>If you look into the implementation details of this algorithm, you may find originally the lower ordering is like that. Originally the algorithm will return "overdefined"(TOP) forever for a specific (Val, BB) pair. This could miss some optimization opportunities as I described in the comment. My patch is trying to increase the number of lowering this "overdefined"(TOP) value.</div><div><br></div><div>This is my current understanding, but maybe I'm wrong.</div><div><br></div><div>Thanks,<br></div><div>-Jiangning</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">2014-09-23 11:08 GMT+08:00 Jiangning Liu <span dir="ltr"><<a href="mailto:liujiangning1@gmail.com" target="_blank">liujiangning1@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Dan,<div class="gmail_extra"><div class="gmail_quote"><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span><br></span><div>So can you explain how you aren't doing this?<br><br></div><div>It looksl ike you think the lattice goes</div><div>undefined</div><div>overdefined</div><div>constant</div><div><br></div><div>That should 100% not be the case</div><div>the lattice order should be</div><div>undefined</div><div>constant</div><div>overdefined</div><div><br></div><div>undefined means you don't know</div><div>constant means it has one value.</div><div>overdefined means it has too many values<br></div><div><br></div><div>This is a traditional value range lattice (though sometimes there are more things in the middle).</div><div>There is no way you should go from overdefined back to constant.</div><span><div><br></div></span></div></div></div></blockquote></span><div>Ah, I see. Thanks for your explanation! I think you are absolutely correct, and I misunderstood lattice value 'overdefined'. The original code is like this,</div><div><br></div><div>  if ((!BBLV.isUndefined() {<br></div><div>     ...</div><div>     return;</div><span class=""><div>  }</div><div><br></div><div><div>  // Otherwise, this is the first time we're seeing this block.  Reset the</div><div>  // lattice value to overdefined, so that cycles will terminate and be</div><div>  // conservatively correct.</div><div>  BBLV.markOverdefined();</div></div><div><br></div></span><div>So this algorithm is really conservative. I think the solution might be removing this lowering or adding threshold control for this lowering. Do you have any suggestions?</div><div><br></div><div>Thanks,</div><div>-Jiangning </div></div></div></div>
</blockquote></div><br></div></div>