This is an archive of the discontinued LLVM Phabricator instance.

[SCEV][NFC] Introduce isSafeToExpandAt function to SCEVExpander
ClosedPublic

Authored by mkazantsev on Oct 24 2017, 5:15 AM.

Details

Summary

This function checks that:

  1. It is safe to expand a SCEV;
  2. It is OK to materialize it at the specified location.

For example, attempt to expand a loop's AddRec to the same loop's preheader should fail.

Diff Detail

Event Timeline

reames requested changes to this revision.Nov 7 2017, 4:03 PM

relatively minor code comments.

include/llvm/Analysis/ScalarEvolutionExpander.h
30

Adjust this comment to reflect the requirement to check dominance.

i.e. "are safe to speculate anywhere their operands are defined"

lib/Analysis/ScalarEvolutionExpander.cpp
2294

From the comment, this sounds like it's going to be smarted than isSafeToExpand where it's really more restrictive.

Maybe add a TODO about handling cases which aren't *generally* safe to speculate but are safe to speculate *at this particular location*?

This revision now requires changes to proceed.Nov 7 2017, 4:03 PM
mkazantsev added inline comments.Nov 8 2017, 11:17 PM
lib/Analysis/ScalarEvolutionExpander.cpp
2294

Let's not do it until we know the application for that.

mkazantsev edited edge metadata.
mkazantsev marked 2 inline comments as done.

Fixed comments.

reames accepted this revision.Nov 14 2017, 8:31 PM

LGTM

This revision is now accepted and ready to land.Nov 14 2017, 8:31 PM
This revision was automatically updated to reflect the committed changes.