Page MenuHomePhabricator

[MemCpyOpt] Move GEP during call slot optimization
ClosedPublic

Authored by nikic on Sat, Oct 17, 6:59 AM.

Details

Summary

When performing a call slot optimization to a GEP dest, it will currently usually not apply, because the GEP is directly before the memcpy and as such does not dominate the call. We should move it above the call if that satisfies the domination requirement. I think that a constant-index GEP is the only useful thing to move here, as otherwise isDereferenceablePointer couldn't look through it anyway. As such I'm not trying to generalize this further.

Diff Detail

Event Timeline

nikic created this revision.Sat, Oct 17, 6:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptSat, Oct 17, 6:59 AM
nikic requested review of this revision.Sat, Oct 17, 6:59 AM
nikic added inline comments.
llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
920

I'm wondering if it would make sense to extend the dominates() API to accept a Value* instead of Instruction* as first argument. Handling "arguments, constants and globals dominate everything" seems like something the DominatorTree API should do, not the caller.

MSxDOS added a subscriber: MSxDOS.Sat, Oct 17, 7:51 AM
jdoerfert added inline comments.Sat, Oct 17, 9:32 AM
llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
920

agreed.

nikic updated this revision to Diff 300029.Thu, Oct 22, 10:07 AM

Rebase over generalized dominates() API.

This revision is now accepted and ready to land.Thu, Oct 22, 10:11 AM
This revision was automatically updated to reflect the committed changes.