(This is split from D91481, and should hopefully be an easier review.)
This patch updates the cost model for full unrolling to discount the cost of a loop invariant expression on all but one iteration. The reasoning here is that such an expression (as determined by SCEV) will be CSEd or DSEd once the loop is unrolled. Note that SCEVs reasoning will find things which could be invariant, not simply those outside the loop.
The test updates show that the current DCE done by unrolling is deficient. It's an easy fix, but will be done in a separate pass.
JFYI, this test output gets reduced a lot once D102511 lands.