[PATCH] D59959: [ConstantRange] Add unsigned intersection type

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 28 13:58:03 PDT 2019


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

The intersection of two ConstantRanges may consist of two disjoint ranges. As we can only return one range as the result, we need to return one of the two possible ranges that cover both. Currently the result is picked based on set size. However, this is not always optimal: If we're in an unsigned context, we'd prefer to get a large unsigned range over a small signed range -- the latter effectively becomes a full set in the unsigned domain. (The same also hold for the signed case, I'm just starting with one case...)

This revision adds an `IntersectionType`, which can be either `Smallest` or `Unsigned` (or in the future `Signed`). `Smallest` is the current behavior and `Unsigned` is a new variant that prefers not to wrap the unsigned domain. The new type isn't used anywhere yet (but SCEV will be a good first user once the signed variant is there as well.)

I've also added some comments to illustrate the various cases in intersectWith(), which should hopefully make it more obvious what is going on.


Repository:
  rL LLVM

https://reviews.llvm.org/D59959

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: D59959.192711.patch
Type: text/x-patch
Size: 7898 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190328/75fb5065/attachment.bin>


More information about the llvm-commits mailing list