llvm-project
2dc53f79 - [AArch64] Cap upper-bound unrolling of loops with uncomputable trip counts (#205102)

Commit
38 days ago
[AArch64] Cap upper-bound unrolling of loops with uncomputable trip counts (#205102) SCEV can compute a small maximum trip count for a loop even when it cannot compute the exact backedge-taken count. This is typical of data-dependent exits, such as the varint-length loops in sqlite3: for (i = 1; (v >>= 7) != 0; i++) ; Unrolling to the maximum trip count turns the loop into a chain of copies containing an exit test for every possible iteration. This increases code size and the number of static branches without knowing whether enough iterations usually execute to make unrolling profitable. These loops were not unrolled before #197292. That change improved SCEV's maximum backedge-taken count for shift recurrences, reducing the maximum trip count of these loops to 6. This made them eligible for AArch64 upper-bound unrolling and caused an approximately 3% regression in sqlite3 from SPEC CPU 2026. For AArch64 loops with a single exiting block that are not MaxOrZero and whose exact backedge-taken count SCEV cannot compute, lower MaxUpperBound to 5 and disable runtime unrolling. The lower bound still allows smaller loops to be unrolled. Runtime unrolling is also disabled because it would clamp its unroll count to the known maximum and produce the same complete unroll.
Author
Parents
Loading