[PATCH] D32978: [SCEV] Avoid copying ConstantRange just to get the min/max value

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 8 13:37:50 PDT 2017


craig.topper created this revision.
Herald added a subscriber: mzolotukhin.

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.


https://reviews.llvm.org/D32978

Files:
  include/llvm/Analysis/ScalarEvolution.h
  lib/Analysis/ScalarEvolution.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32978.98199.patch
Type: text/x-patch
Size: 18428 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170508/158f8dac/attachment-0001.bin>


More information about the llvm-commits mailing list