This is an archive of the discontinued LLVM Phabricator instance.

[SCEV] Don't expand Wrap predicate using inttoptr in ni addrspaces
ClosedPublic

Authored by loladiro on Jul 25 2018, 7:19 PM.

Details

Summary

In non-integral address spaces, we're not allowed to introduce inttoptr/ptrtoint
intrinsics. Instead, we need to expand any pointer arithmetic as geps on the
base pointer. Luckily this is a common task for SCEV, so all we have to do here
is hook up the corresponding helper function and add test case.

Fixes PR38290

Diff Detail

Event Timeline

loladiro created this revision.Jul 25 2018, 7:19 PM
loladiro updated this revision to Diff 157419.Jul 25 2018, 7:29 PM

Add a small fix found during testing that I forgot to commit.

sanjoy accepted this revision.Jul 26 2018, 9:17 AM

lgtm

lib/Analysis/ScalarEvolutionExpander.cpp
2204

This can be

if (auto *ARPtrTy = dyn_cast<PointerType>(ARExpandTy)) {
}
2208

This pattern is a bit confusing -- do you mind adding an overload for expandAddToGEP that takes one operand and does this internally?

test/Analysis/LoopAccessAnalysis/wrapping-pointer-ni.ll
16

Do you mind cleaning up the test using instnamer? Having %1, %2 as instruction names make it difficult to change the test later since adding an instruction changes the numbering for all following instructions.

While you're at it, can you please also remove some of the unnecessary metadata here?

This revision is now accepted and ready to land.Jul 26 2018, 9:17 AM
This revision was automatically updated to reflect the committed changes.