[PATCH] D59749: [ConstantRange] Fix isWrappedSet()
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 24 09:46:49 PDT 2019
nikic created this revision.
nikic added reviewers: lebedev.ri, spatel.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
`isWrappedSet()` currently incorrectly returns true for ranges like `i8 [42, 255]`, also known as `i8 [42, 0)`. While a reasonable person might argue that the current behavior is correct if you interpret "wrapping" relative to the exclusive upper bound, the behavior is inconsistent with `isSignWrappedSet()` in two ways:
- While `i8 [42, 0)` is considered unsigned wrapping, `i8 [42, -128)` is not considered signed wrapping.
- The full set is not considered unsigned wrapping, but considered signed wrapping.
This patch changes `isWrappedSet()` and `isSignWrappedSet()` to behave consistently: They will both not consider 0/SignedMin upper bound as wrapping, and both not consider full sets as wrapping.
Additionally `isUpperWrapped()` and `isUpperSignWrapped()` methods are added which *do* consider 0/SignedMin as wrapping. Both interpretations of wrapping are useful depending on context, so both are provided.
Repository:
rL LLVM
https://reviews.llvm.org/D59749
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: D59749.192035.patch
Type: text/x-patch
Size: 8701 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190324/98d0e8e1/attachment.bin>
More information about the llvm-commits
mailing list