This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking] Simplify llvm::isPointerOffset()
ClosedPublic

Authored by aeubanks on Feb 24 2022, 3:45 PM.

Details

Summary

We still need the code after stripAndAccumulateConstantOffsets() since
it doesn't handle GEPs of scalable types and non-constant but identical
indexes.

Diff Detail

Event Timeline

aeubanks created this revision.Feb 24 2022, 3:45 PM
aeubanks requested review of this revision.Feb 24 2022, 3:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 24 2022, 3:45 PM
nikic added inline comments.Feb 25 2022, 12:15 AM
llvm/lib/Analysis/ValueTracking.cpp
7107

This will cause issues if Ptr1 and Ptr2 are in differently-sized address spaces. I think just doing Offset2.getSExtValue() - Offset1.getSExtValue() would be fine here.

llvm/test/Transforms/MemCpyOpt/opaque-ptr.ll
55

I think the main motivation for the additional code isn't scalable vectors, but rather cases that have a common non-constant index, like GEP p, x, 0 and GEP p, x, 1.

aeubanks updated this revision to Diff 414228.Mar 9 2022, 3:36 PM

address comments

Herald added a project: Restricted Project. · View Herald TranscriptMar 9 2022, 3:36 PM
aeubanks edited the summary of this revision. (Show Details)Mar 9 2022, 3:37 PM
aeubanks added inline comments.
llvm/test/Transforms/MemCpyOpt/opaque-ptr.ll
55

yes you're right, I was trying to use GEPOperator::collectOffset here but it didn't handle vscale types and that was on my mind when writing the commit message

nikic accepted this revision.Mar 10 2022, 12:19 AM

LGTM

This revision is now accepted and ready to land.Mar 10 2022, 12:19 AM
This revision was landed with ongoing or failed builds.Mar 14 2022, 9:32 AM
This revision was automatically updated to reflect the committed changes.