This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Avoid folding GEPs across loop boundaries
ClosedPublic

Authored by clin1 on Aug 11 2021, 3:44 PM.

Details

Summary

Folding a GEP from outside to inside a loop will materialize an add where there wasn't an equivalent operation before. Check the containing loops before making this fold.

Diff Detail

Event Timeline

clin1 created this revision.Aug 11 2021, 3:44 PM
clin1 requested review of this revision.Aug 11 2021, 3:44 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2021, 3:44 PM
clin1 updated this revision to Diff 365870.Aug 11 2021, 3:59 PM

Forgot the check lines...

clin1 added a comment.Aug 12 2021, 1:45 PM

Failing "task-dependency.c" test looks like unrelated flakiness. Observed it pass/failing randomly in local testing.

Adding some likely reviewers (I'm currently away with only limited web access).

lebedev.ri accepted this revision.Aug 18 2021, 11:03 AM

Hm, i thought i commented here, but alas not. LGTM.

I suspect while we want to merge this, it's only half of the story - what if LICM didn't run yet?
We need some kind of an undo transform. (and no, SeparateConstOffsetFromGEP doesn't help, i tried)

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
2137
This revision is now accepted and ready to land.Aug 18 2021, 11:03 AM
clin1 added a comment.Aug 18 2021, 5:07 PM

Thank you for the review. Could I please ask someone to commit, with --author="Chang-Sun Lin, Jr. <chang-sun.lin.jr@intel.com>"?

This revision was landed with ongoing or failed builds.Aug 19 2021, 10:04 AM
This revision was automatically updated to reflect the committed changes.