[PATCH] D32712: [ConstantRange] Reduce the number of allocations in ConstantRange::makeGuaranteedNoWrapRegion

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 1 11:47:34 PDT 2017


craig.topper created this revision.

Currently,  makeGuaranteedNoWrapRegion creates 3 temporary APInts each time it calls SubsetIntersect. Two to hold the inverses of CR0 and CR1 and one to hold the result before inverting for the return. If the APInt is larger than 64-bits, each of these represents an allocation. We're also doing extra inversions on Result if SubsetIntersect is called multiple time.

This patch adds an inverseInPlace method that will turn a ConstantRange to its inverse without creating a new object. This can help remove the temporary allocations.

Additionally, we now store Result in its inverse form through all of the possible calls to SubsetIntersect and only invert it at the end before the return. I've modified the lambda to write to read/write Result through a capture so that it no longer looks like a generic function. It also takes Other by value now so that we can capture the temporary ConstantRange that's always passed to it and call inverseInPlace on it.


https://reviews.llvm.org/D32712

Files:
  include/llvm/IR/ConstantRange.h
  lib/IR/ConstantRange.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32712.97319.patch
Type: text/x-patch
Size: 4004 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170501/5ed53765/attachment.bin>


More information about the llvm-commits mailing list