There are cases where a do-while loop would be converted to a while loop before finding out that it would be unsafe to expand the SCEV in this situation and then bailing out of hardware loop conversion.
This patch checks if it would be unsafe to expand the SCEV and if so stops converting the do-while into a while, allowing conversion to a hardware loop.
nit: I think we're supposed to just use auto when it's obvious what the type is, say when using a cast.