This is an archive of the discontinued LLVM Phabricator instance.

[GVN] Encode GEPs in offset representation
ClosedPublic

Authored by nikic on Apr 27 2022, 6:56 AM.

Details

Reviewers
aeubanks
Group Reviewers
Restricted Project
Commits
rGb9dc5651477b: [GVN] Encode GEPs in offset representation
Summary

When using opaque pointers, convert GEPs into offset representation of the form P + V1 * Scale1 + V2 * Scale2 + ... + ConstantOffset. This allows us to recognize equivalent address calculations even if the GEPs don't use the same source element type.

This fixes an opaque pointer codegen regression seen in rustc.

Diff Detail

Event Timeline

nikic created this revision.Apr 27 2022, 6:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2022, 6:56 AM
nikic requested review of this revision.Apr 27 2022, 6:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2022, 6:56 AM
aeubanks added inline comments.
llvm/lib/Transforms/Scalar/GVN.cpp
408

why don't we do this for typed pointers as well?

aeubanks accepted this revision.Apr 27 2022, 9:53 AM

but lg anyway

This revision is now accepted and ready to land.Apr 27 2022, 9:53 AM
nikic added inline comments.Apr 27 2022, 9:57 AM
llvm/lib/Transforms/Scalar/GVN.cpp
408

For typed pointers the source element type is implicitly encoded as part of the pointer operand, so this wouldn't do anything useful. To make this work with typed pointers, we'd have to change GVN to work on stripped pointers and then insert bitcasts as necessary during replacement.

This revision was landed with ongoing or failed builds.Apr 28 2022, 12:33 AM
This revision was automatically updated to reflect the committed changes.