This is an archive of the discontinued LLVM Phabricator instance.

[LSR] Limit the recursion for setup cost
ClosedPublic

Authored by dmgreen on Apr 21 2019, 2:09 AM.

Details

Summary

In some circumstances we can end up with setup costs that are very complex to compute, even though the scevs are not very complex to create. This can also lead to setupcosts that are calculated to be exactly -1, which LSR treats as an invalid cost. This patch puts a limit on the recursion depth for setup cost to prevent them taking too long.

Thanks to @reames for the report and test case.

Diff Detail

Repository
rL LLVM

Event Timeline

dmgreen created this revision.Apr 21 2019, 2:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 21 2019, 2:09 AM
reames accepted this revision.Apr 22 2019, 9:35 AM

LGTM

llvm/test/Transforms/LoopStrengthReduce/gnarly-setupcost.ll
9 ↗(On Diff #195987)

A comment explaining why this sequence is special is probably warranted.

This revision is now accepted and ready to land.Apr 22 2019, 9:35 AM
This revision was automatically updated to reflect the committed changes.