This is an archive of the discontinued LLVM Phabricator instance.

Discount invariants instructions in full unrolling
ClosedPublic

Authored by reames on May 14 2021, 9:10 AM.

Details

Summary

(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.

Diff Detail

Event Timeline

reames created this revision.May 14 2021, 9:10 AM
reames requested review of this revision.May 14 2021, 9:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 14 2021, 9:10 AM
reames added inline comments.May 14 2021, 9:53 AM
llvm/test/Transforms/LoopUnroll/full-unroll-invariant.ll
38

JFYI, this test output gets reduced a lot once D102511 lands.

fhahn accepted this revision.May 14 2021, 10:10 AM
fhahn added a subscriber: fhahn.

LGTM, thanks!

This revision is now accepted and ready to land.May 14 2021, 10:10 AM
This revision was automatically updated to reflect the committed changes.