Page MenuHomePhabricator

[ValueTracking] Improve pointer offset computation for cases of same base
ClosedPublic

Authored by xur on Tue, Sep 24, 2:55 PM.

Details

Summary

This patch improves the handling of pointer offset in GEP expressions where one argument is the base pointer.
isPointerOffset() is being used by memcpyopt where current code synthesizes consecutive 32 bytes stores to one store and two memset intrinsic calls.
With this patch, we convert the stores to one memset intrinsic.

Diff Detail

Event Timeline

xur created this revision.Tue, Sep 24, 2:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptTue, Sep 24, 2:55 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
gchatelet added inline comments.
llvm/lib/Analysis/ValueTracking.cpp
5760

iteratively

5764

it will or we'll?

xur updated this revision to Diff 221796.Wed, Sep 25, 9:55 AM

Fixed comments suggested by Guillaume.

looks fine to me, but please wait for evghenii@'s comment.

xur edited reviewers, added: eugenis; removed: evghenii.Tue, Oct 1, 10:39 AM
xur added a reviewer: fhahn.Tue, Oct 1, 10:46 AM
eugenis accepted this revision.Tue, Oct 1, 10:57 AM

I think this can be easily generalized even more to handle the case when both Ptr1 and Ptr2 are GEPs of some common base - replace getOffsetFromBase with getOffsetAndBase, check that the bases are the same, return the difference between offsets.

But this is fine at it is, LGTM.

This revision is now accepted and ready to land.Tue, Oct 1, 10:57 AM
xur added a comment.Thu, Oct 10, 11:27 AM

I totally agree with what eugenis said.
I added his comments to a TODO comment.
I will commit this version and may address the TODO later.

This revision was automatically updated to reflect the committed changes.