This patch tries to fully unroll loops having break statement like this
for (int i = 0; i < 8; i++) { if (a[i] == value) { found = true; break; } }
GCC can fully unroll such loops, but currently LLVM cannot because LLVM only supports loops having exact constant trip counts.
The upper bound of the trip count can be obtained from calling ScalarEvolution::getMaxBackedgeTakenCount(). Part of the patch is the refactoring work in SCEV to prevent duplicating code.
The feature of using the upper bound is enabled under the same circumstance when runtime unrolling is enabled since both are used to unroll loops without knowing the exact constant trip count.
The modified test/CodeGen/AMDGPU/tti-unroll-prefs.ll can be used as the test case of this patch.
The first letter shouldn't be capitalized. I think the routine name also might be improved, but I don't have any better suggestions at the moment.