Page MenuHomePhabricator

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

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



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


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


636 ↗(On Diff #204342)


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.