The attached test produces a wrong result for C2 due to lost control dependencies for loop predicates while unswitching a loop after it was partially peeled.
The C2 compiled code produces a wrong result for 'iFld' in the attached test case. It is -8 instead of -7. The loop in the test case is partially peeled and then unswitched. The wrong result is produced because a wrong state is transferred to the interpreter when an uncommon trap is hit in the C2 compiled code in the fast version of the unswitched loop.
The problem is when unswitching the loop, we clone the original loop predicates for the slow and fast version of the loop but we do not account for partially peeled statements that are control dependent on the loop predicates (i.e. need to be executed after the predicates). As a result, these are executed before the cloned loop predicates.