This is an archive of the discontinued LLVM Phabricator instance.

[SCEV] Reduce the number of invocation to non trivial getExact function
ClosedPublic

Authored by skatkov on Apr 27 2018, 1:06 AM.

Details

Summary

The invocation of getExact in ScalarEvolution::getBackedgeTakenInfo is used
only for getting statistic and for assert. And even if statistics is disable and code
related to it will be eliminated the invocation to getExact itself will not be eliminated
because it may have side-effects like creation of new SCEVs.

So do invocation only when we collect statistics or executes asserts.

Diff Detail

Repository
rL LLVM

Event Timeline

skatkov created this revision.Apr 27 2018, 1:06 AM

Please add more details commit message that getExact in this place is only used for statistics collection, and since it has side effects it cannot be eliminated even if the collection is disabled.

Code-wise, it should be fine, but I'm not sure if it is OK to use this define outside of statistic collection infrastructure. I don't see precedents. If there is no guideline against that then I'm fine with it.

lib/Analysis/ScalarEvolution.cpp
6518 ↗(On Diff #144290)
#endif  // LLVM_ENABLE_STATS

AFAIU the correctness check would now get gated on STATS colelction and that may not be right. I would recommend separating the two.

lib/Analysis/ScalarEvolution.cpp
6506 ↗(On Diff #144290)

Please s/auto/"const SCEV *" to be consistent with other such instances in SCEV.

skatkov updated this revision to Diff 144297.Apr 27 2018, 1:54 AM
skatkov marked 2 inline comments as done.

assert now works.

skatkov edited the summary of this revision. (Show Details)Apr 27 2018, 1:57 AM
skatkov edited the summary of this revision. (Show Details)Apr 27 2018, 2:01 AM

Fine for me (with the same doubt of direct usage of LLVM_ENABLE_STATS).

javed.absar accepted this revision.Apr 27 2018, 2:30 AM

Please rephrase this part of commit message as it is hard to read/understand - "And even if statistics is disable and code
related to it will be eliminated the invocation to getExact itself will not be eliminated because it may have side-effects like creation of new SCEVs".

May be something like this - "Even if statistics is disabled, the code related to it will be eliminated the invocation to getExact itself will not be eliminated
because it may have side-effects like creation of new SCEVs". - if you agree with it

This revision is now accepted and ready to land.Apr 27 2018, 2:30 AM

Thank you for review guys. I'm ok with your version of commit message.

This revision was automatically updated to reflect the committed changes.