[PATCH] D61653: [ConstantRange] Add makeAllowedNoWrapRegion()

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 7 13:44:36 PDT 2019


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

This adds a counterpart to makeGuaranteedNoWrapRegion(): While makeGNWR creates an LHS range which will never cause overflow, makeANWR creates a range //outside// of which will //always// cause overflow (more specifically: the smallest such range -- a conservative implementation would be to always return the full range). The intended use-case is to intersect the LHS operand of nuw/nsw operations with it.

The implementation is to the most part exactly the same as makeGNWR but with min/max swapped. The only non-trivial case is signed multiplication, where we need to take into account both the smallest non-negative value and the largest negative one (insofar as they exist). These are extracted by intersecting with the signed half-spaces.


Repository:
  rL LLVM

https://reviews.llvm.org/D61653

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: D61653.198522.patch
Type: text/x-patch
Size: 4936 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190507/27304b2d/attachment.bin>


More information about the llvm-commits mailing list