This is an archive of the discontinued LLVM Phabricator instance.

[LoopUnroll] Be more permissive to high-cost loop trip count SCEV's
Needs RevisionPublic

Authored by lebedev.ri on Dec 27 2022, 9:16 AM.

Details

Summary

Loop unroll's loop trip count expansion is optionally
guarded by a 'cheap expansion budget' cut-off.
Unlike the loop ind var simplification, here,
if we do unroll the loop, it's usually beneficial,
so it's generally justified to deal with a slightly
more costly loop trip counts.

Alternative to D139858.

Diff Detail

Event Timeline

lebedev.ri created this revision.Dec 27 2022, 9:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 27 2022, 9:16 AM
nikic added a reviewer: fhahn.EditedDec 27 2022, 1:12 PM

Compile-time: https://llvm-compile-time-tracker.com/compare.php?from=781eabeb40b8e47e3a46b0b927784e63f0aad9ab&to=c0e5cd413681c1622e6d454bba677cf8847c3db3&stat=instructions:u ThinLTO +0.5% geomean with +2.7% tramp3d-v4

Code-size: https://llvm-compile-time-tracker.com/compare.php?from=781eabeb40b8e47e3a46b0b927784e63f0aad9ab&to=c0e5cd413681c1622e6d454bba677cf8847c3db3&stat=size-text ThinLTO +1.0% geomean with +6.7% tramp3d-v4

I checked, and using a factor of two instead of four only makes a relatively small difference (that is, the code size / compile-time impact is about the same for factor two and four).

Looks like this change has a higher impact than I would have expected. The code size increase might be worthwhile, but it's not possible to say without performance data.

It's possible that D115261 would mitigate this somewhat, by avoiding at least some of the known non-profitable unrolling.

Ultimately this (once again) comes back to our lack of a runtime unrolling cost model :/

mkazantsev accepted this revision.Jan 16 2023, 9:19 PM

If CT impact is small, fine by me.

This revision is now accepted and ready to land.Jan 16 2023, 9:19 PM

Do you have any perf data on the impact of this change?

nikic requested changes to this revision.Jan 17 2023, 12:18 AM

If CT impact is small, fine by me.

CT and code size impact is still large: Compile time, Code size

This revision now requires changes to proceed.Jan 17 2023, 12:18 AM