This is an archive of the discontinued LLVM Phabricator instance.

[ScalarEvolutionExpander] Refactor isHighCostExpansionHelper division case
ClosedPublic

Authored by igor-laevsky on Aug 13 2015, 7:53 AM.

Details

Summary

This is follow up after http://reviews.llvm.org/D11687

In SCEVUDivExpr case inside isHighCostExpansionHelper we had lookup code which was almost exactly same as code inside findExistingExpansion. Refactor it to make use of the existing function.

Diff Detail

Repository
rL LLVM

Event Timeline

igor-laevsky retitled this revision from to [ScalarEvolutionExpander] Refactor isHighCostExpansionHelper division case.
igor-laevsky updated this object.
igor-laevsky added a reviewer: sanjoy.
igor-laevsky set the repository for this revision to rL LLVM.
igor-laevsky added a subscriber: llvm-commits.
sanjoy requested changes to this revision.Aug 16 2015, 6:05 PM
sanjoy edited edge metadata.
sanjoy added inline comments.
lib/Analysis/ScalarEvolutionExpander.cpp
1819

Latches are not exiting blocks, so this is a semantic change. Perhaps this should be iterating over both exits and latches?

1890

Typo here?

1898

Nit: "This is just a simple search heuristic."

This revision now requires changes to proceed.Aug 16 2015, 6:05 PM
igor-laevsky marked an inline comment as done.Aug 17 2015, 6:14 AM
igor-laevsky added inline comments.
lib/Analysis/ScalarEvolutionExpander.cpp
1819

Right. However this heuristic is based on the fact that we are looking at the loop exit conditions. All latches which exit loop should be listed in the ExitingBlocks. So the overall heuristic stays roughly the same. I probably shouldn't call this change purely a refactoring though.

If you think that it is important to visit non-exiting latches it would be easy to add them into lookup list. It's just small amount of additional complexity which I don't see real need for.

igor-laevsky marked an inline comment as done.Aug 17 2015, 6:15 AM
sanjoy accepted this revision.Aug 17 2015, 8:53 AM
sanjoy edited edge metadata.

LGTM, but please mention something along the lines of

"However this heuristic is based on the fact that we are looking at the loop exit conditions. All latches which exit loop should be listed in the ExitingBlocks. So the overall heuristic stays roughly the same."

in the commit message.

lib/Analysis/ScalarEvolutionExpander.cpp
1819

Ok.

This revision is now accepted and ready to land.Aug 17 2015, 8:53 AM
This revision was automatically updated to reflect the committed changes.