This is an archive of the discontinued LLVM Phabricator instance.

[SCEV] Avoid copying ConstantRange just to get the min/max value
ClosedPublic

Authored by craig.topper on May 8 2017, 1:37 PM.

Details

Summary

This patch changes getRange to getRangeRef and returns a reference to the ConstantRange object stored inside the DenseMap caches. We then take advantage of that to add new helper methods that can return min/max value of a signed or unsigned ConstantRange using that reference without first copying the ConstantRange.

getRangeRef calls itself recursively and I believe the reference return is fine for those calls.

I've left getSignedRange and getUnsignedRange returning a ConstantRange object so they will make a copy now. This is to ensure safety since the reference will be invalidated if the DenseMap changes.

I'm sure there are still more places that can take advantage of the reference and I'll submit future patches as I find them.

Diff Detail

Event Timeline

craig.topper created this revision.May 8 2017, 1:37 PM
zzheng added a subscriber: zzheng.May 8 2017, 1:47 PM
sanjoy accepted this revision.Jun 24 2017, 1:21 PM

lgtm

I did not carefully check the getSignedRange(RHS).getSignedMin() -> getSignedRangeMin(RHS) -like transforms, I assumed you got those right.

This revision is now accepted and ready to land.Jun 24 2017, 1:21 PM
craig.topper closed this revision.Jun 25 2017, 11:34 PM