[PATCH] D60946: [ConstantRange] Add saturating add/sub methods

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 21 04:59:11 PDT 2019


nikic created this revision.
nikic added a reviewer: lebedev.ri.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Add support for uadd_sat and friends to ConstantRange, so we can handle uadd.sat and friends in LVI. The implementation is forwarding to the corresponding APInt methods with appropriate bounds.

One thing worth pointing out here is that the handling of wrapping ranges is not maximally accurate. A simple example is that adding 0 to a wrapped range will return a full range, rather than the original wrapping range. The tests also only check that the non-wrapping envelope is correct and minimal.


Repository:
  rL LLVM

https://reviews.llvm.org/D60946

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60946.195991.patch
Type: text/x-patch
Size: 6178 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190421/2d7f301a/attachment.bin>


More information about the llvm-commits mailing list