<div dir="ltr"><div class="gmail_extra">Thanks for moving the interface around, however it seems to highlight why this is not a good interface even isolated in a single file:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_quote">On Tue, Dec 9, 2014 at 6:32 PM, Juergen Ributzka <span dir="ltr"><<a href="mailto:juergen@apple.com" target="_blank">juergen@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":394" class="a3s" style="overflow:hidden">-      if (Br1->getBranchWeights(TrueWeight, FalseWeight)) {<br>
+      if (extractBranchMetadata(Br1, TrueWeight, FalseWeight)) {<br>
         uint64_t NewTrueWeight = TrueWeight;<br>
         uint64_t NewFalseWeight = TrueWeight + 2 * FalseWeight;<br></div></blockquote><div><br></div><div>What happens if 2 * FalseWeight wraps the uint64_t?</div><div><br></div><div>I'm not sure why this pattern of code for updating branch weights is sound. Maybe it is,  but it isn't at all clear.why. Do we have some guarantee that these are run through scaleWeights first and so only have 32-bits of active data in it?</div><div><br></div><div>Also, is there some common interface for updating branch weight metadata that both CGP and SimplifyCFG *could* share, ideally with more of the scaling logic encapsulated and explained there?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":394" class="a3s" style="overflow:hidden">
         scaleWeights(NewTrueWeight, NewFalseWeight);<br>
@@ -3975,7 +3996,7 @@ bool CodeGenPrepare::splitBranchConditio<br>
       // assumes that<br>
       //   FalseProb for BB1 == TrueProb for BB1 * FalseProb for TmpBB.<br>
       uint64_t TrueWeight, FalseWeight;<br>
-      if (Br1->getBranchWeights(TrueWeight, FalseWeight)) {<br>
+      if (extractBranchMetadata(Br1, TrueWeight, FalseWeight)) {<br>
         uint64_t NewTrueWeight = 2 * TrueWeight + FalseWeight;<br>
         uint64_t NewFalseWeight = FalseWeight;<br>
         scaleWeights(NewTrueWeight, NewFalseWeight);</div></blockquote></div><br><br></div></div>