[PATCH] D59193: [ConstantRange] Add overflow check helpers

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 10 13:44:15 PDT 2019


nikic created this revision.
nikic added reviewers: spatel, craig.topper.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Add functions to ConstantRange that determine whether the unsigned/signed addition/subtraction of two ConstantRanges may/always/never overflows. This will allow checking overflow conditions based on known constant ranges in addition to known bits (with D59071 <https://reviews.llvm.org/D59071> in mind).

I'm implementing these methods on ConstantRange to allow them to be unit tested independently of any ValueTracking machinery.

The OverflowResult enum is redeclared on ConstantRange, because I wanted to avoid a dependency in either direction between ValueTracking.h and ConstantRange.h.


Repository:
  rL LLVM

https://reviews.llvm.org/D59193

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: D59193.190018.patch
Type: text/x-patch
Size: 13305 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190310/29c56e82/attachment.bin>


More information about the llvm-commits mailing list