<div class="gmail_quote">On Fri, Jul 6, 2012 at 5:27 PM, Jakob Stoklund Olesen <span dir="ltr"><<a href="mailto:stoklund@2pi.dk" target="_blank">stoklund@2pi.dk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
On Jul 6, 2012, at 5:02 PM, Chandler Carruth <<a href="mailto:chandlerc@gmail.com">chandlerc@gmail.com</a>> wrote:<br>
<br>
> This isn't nearly finished, and its still missing both some cleanups I suspect and it has a few bugs that I haven't had time to track down, but wanted to see if this is more along the lines you were thinking of algorithm-wise. New patch attached.<br>

<br>
</div>I missed this the first time:<br>
<br>
+  if (empty()) {<br>
+    for (const_iterator RI = RHS.begin(), RE = RHS.end(); RI != RE; ++RI)<br>
<div class="im">+      if (!RHSValNo || RI->valno == RHSValNo) {<br>
</div>+        ranges.push_back(*RI);<br>
+        ranges.back().valno = LHSValNo;<br>
+      }<br>
+    return;<br>
+  }<br>
<br>
If RHS has segments that are touching (ranges[i].end == ranges[i+1].start), but have different values, they would need to be merged here because now they all have the same value: LHSValNo. (This is where verify() would come in handy).<br>
</blockquote><div><br></div><div>Yea there were a few bugs like this. That's why I had the big caveat, hadn't finished testing it.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im"><br>
> If (algorithmically) you're liking this direction, then after cleaning up, fixing bugs, and testing performance in both cases, is this a good initial step to commit?<br>
<br>
</div>Yes, but you definitely need to run a test where you verify invariants.</blockquote><div><br></div><div>OK, it now passes with the verification I mailed out layered on top to assert everywhere. Passes both regtests and a bootstrap.</div>
<div><br>I also measured the 'llc' time for a few big bitcode files from "normal" code (117.mesa LTO-ed, sqlite3, and a single-source-file version of Clang's lexer / preprocessor library). I saw no measurable performance change.</div>
<div><br></div><div>Updated patch attached.</div></div>