[LICM] Hoist assumes out of loops
ClosedPublic

Authored by reames on Mon, Aug 6, 3:14 PM.

Details

Summary

If we have an assume which is known to execute and whose operand is invariant, we can lift that into the pre-header. So long as we don't change which paths the assume executes on, this is a legal transformation. It's likely to be a useful canonicalization as other transforms only look for dominating assumes.

Diff Detail

Repository
rL LLVM
reames created this revision.Mon, Aug 6, 3:14 PM
mkazantsev added inline comments.Mon, Aug 6, 6:57 PM
test/Transforms/LICM/assume.ll
36 ↗(On Diff #159406)

Could you please add another test where assume uses a Phi or another unhoistable value from the loop, and therefore cannot be hoisted?

reames updated this revision to Diff 159549.Tue, Aug 7, 10:57 AM

Rebased on top of newly submitted tests to address review comment

reames marked an inline comment as done.Tue, Aug 7, 10:57 AM
This revision is now accepted and ready to land.Thu, Aug 9, 9:01 PM
This revision was automatically updated to reflect the committed changes.