This is an archive of the discontinued LLVM Phabricator instance.

Teach getSCEVAtScope how to handle loop phis w/invariant operands in loops w/taken backedges
ClosedPublic

Authored by reames on Jun 12 2019, 12:38 PM.

Details

Summary

This patch really contains two pieces:

  1. Teach SCEV how to fold a phi in the header of a loop to the value on the backedge when a) the backedge is known to execute at least once, and b) the value is safe to use globally within the scope dominated by the original phi.
  2. Teach IndVarSimplify's rewriteLoopExitValues to allow loop invariant expressions which already exist (and thus don't need new computation inserted) even in loops where we can't optimize away other uses.

Noticed when writing test cases for generalizations of D58113, but otherwise unrelated.

Diff Detail

Repository
rL LLVM

Event Timeline

reames created this revision.Jun 12 2019, 12:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 12 2019, 12:38 PM
sanjoy accepted this revision.Jun 14 2019, 7:06 PM

lgtm

lib/Transforms/Scalar/IndVarSimplify.cpp
636 ↗(On Diff #204342)

s/it's/its/

This revision is now accepted and ready to land.Jun 14 2019, 7:06 PM
This revision was automatically updated to reflect the committed changes.