Do loop cloning only if zero trip test can be ensured.
The problem is our loop detection logic detects the loop structure, but it
doesnt know the code outside the loop structure, esp., nothing about the
edge from the "head" into the loop "entry" block.
In the bug case, there is no zero-trip test in the "head", so the entrance
into the loop is not guarded. Note that the other point of entrance into
the "entry" block is from the "top" block which will be guarded by the
loop "bottom" test.
One way to make sure is when we invert a while loop into a do-while with
an explicit compiler cloned zero trip test, in fgOptWhileLoop, i.e., we
mark it as good to optimize with a flag. The fix marks the loop as ZTT.
The caveat is the JIT doesnt always do loop inversion.
This change is more conservative than it needs to be in the interest of
managing risk.