This patch teaches LoopUnswitch to split unswitch quota to old loop and newly generated loop based on branch weight.
Consider the following example
for (...) if (cond1) dummy1() else dummy2() if (cond2) dummy3() else break
This loop can be unswitched twice based on cond1 and cond2, ending with 4 loops if we have enough quota. However, if we dont have enough quota, we should spend most of them on the hot branch based on branch weight. In this example, if the branch to dummy1() is hotter than dummy2(), we should give the quota to loop with dummy1() and end up with:
if (cond1) if (cond2) for (...) dummy1() dummy3() else for (...) dummy1() break else for (...) dummy2() if (cond2) dummy3() else break
If we don't spilt quota based on branch weight, the colder branch will get unswitched and not help performance.
This should probably be a cl::opt. One should be 100-TheOther.