[PATCH] D13677: [IR] Fix bug in `ConstantRange::intersectWith`
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 12 15:02:38 PDT 2015
sanjoy created this revision.
sanjoy added a reviewer: nlewycky.
sanjoy added a subscriber: llvm-commits.
NOTE: this is still failing tests, so it isn't yet ready to go in and is
a WIP. The failing tests will have to be audited manually before
checking this in.
NOTE: all of the fixes in `ConstantRangeTest.cpp` were bugs to begin
with, AFAICT.
This "fixes" a bug in `intersectWith` by rewriting it. The idea is that
we can extend the bitwidth of a constant range by a bit and use that to
simplify the logic around checking for wrapped ranges.
Roughly, if this is our number line with a wrapped range
|---)----[-------|
we map the wrapped range to
|--------[-------|---)------------| .. (A)
and if this is the number line with an not-wrapped range
|---[----)-------|
we map it to
|---[----)-------|----------------| .. (B)
or
|----------------|---[----)-------| .. (C)
When intersecting a wrapped range with an unwrapped one (the "hard"
case), we intersect (A) with (B) and (A) with (C); and pick the larger
of the two.
We can do the same thing for unions.
http://reviews.llvm.org/D13677
Files:
lib/IR/ConstantRange.cpp
unittests/IR/ConstantRangeTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13677.37186.patch
Type: text/x-patch
Size: 7068 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151012/7bda9566/attachment-0001.bin>
More information about the llvm-commits
mailing list