There was a bug from cost calculation for partially invariant unswitch.
The costs of non-duplicated blocks are substracted from the total LoopCost, so anything that is duplicated should *not* be counted.
On omnetpp of SPEC2017, more functions are inlined with new pass manager's inliner against legacy pass manager one.
It causes bigger unswitch cost and I have found my update of the cost calculation is wrong from it.
A test case is updated because it has multiple unswitch candidates and the different candidate is picked up.
Isn't this always true for a partial unswitch? If there is a partial unswitch candidate, PartialIVCondBranch will be the terminator of the loop header. When ComputeUnswitchedCost is called for a partial unswitch TI is *also* the terminator of the loop header. Did I miss something?
FWIW I also think that the previous condition is always true: for a partial unswitch, there is always at least one instruction in InstToDuplicate. (again, the terminator of the loop header!)