This is an archive of the discontinued LLVM Phabricator instance.

[unroll] Use SCEV to evaluate branch conditions in cost model
AbandonedPublic

Authored by reames on May 21 2021, 9:15 AM.

Details

Reviewers
mkazantsev
dalegr
Summary

The current full unroll cost model does a symbolic evaluation of the loop up to a fixed limit. That symbolic evaluation currently simplifies to constants, but I'm planning to extend that to using SimplifyInstruction infrastructure in the near future. This patch uses the simplified operands (at this point constants), and asks SCEV to prove a condition. SCEV can use a mix of induction reasoning, and (most relevantly) dominating branch conditions.

With the constant domain, this is a bit hard to exercise. I mostly split it into it's own patch for ease of review - it becomes more useful once we have symbolic evaluation on the value domain. (Forthcoming.)

Diff Detail

Event Timeline

reames created this revision.May 21 2021, 9:15 AM
reames requested review of this revision.May 21 2021, 9:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 21 2021, 9:15 AM
reames updated this revision to Diff 347076.May 21 2021, 10:33 AM

Rebase over D102934 so that it's easier to see why this is useful from the test changes.

reames updated this revision to Diff 347085.May 21 2021, 11:05 AM

Rebase over landed tests

mkazantsev added inline comments.May 23 2021, 8:19 PM
llvm/test/Transforms/LoopUnroll/unroll-cost-symbolic-execute.ll
809

I like the change, but the results like this scare me a lot. Is this really what we want to see in code?

mkazantsev added inline comments.May 23 2021, 8:27 PM
llvm/test/Transforms/LoopUnroll/unroll-cost-symbolic-execute.ll
809

Ah, it's dead code... Nvm then.

mkazantsev accepted this revision.May 26 2021, 5:52 AM

LGTM, but mind that maybe we'll have to downgrade isKnownPredicateAt to isKnownPredicate if it harms the CT.

This revision is now accepted and ready to land.May 26 2021, 5:52 AM
reames abandoned this revision.Sun, Nov 26, 11:50 AM

Closing stale phabricator review. No longer actively working on this, if someone wants to pick it up, feel free.

Herald added a project: Restricted Project. · View Herald TranscriptSun, Nov 26, 11:50 AM
Herald added a subscriber: StephenFan. · View Herald Transcript