diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2009-07-13 03:27:41 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2009-07-13 03:27:41 +0000 |
commit | 08ee8812e70ea01e8e91ef4e9522ca877106f81c (patch) | |
tree | 9f4f1b55e931c834af75ad37649a7b9e689c2516 /lib | |
parent | 70c5ab85595c3b8706c7bf6ac96ea427a9cd5799 (diff) | |
download | external_llvm-08ee8812e70ea01e8e91ef4e9522ca877106f81c.zip external_llvm-08ee8812e70ea01e8e91ef4e9522ca877106f81c.tar.gz external_llvm-08ee8812e70ea01e8e91ef4e9522ca877106f81c.tar.bz2 |
Multiply was very wrong for wrapped ranges. This supplies a half-fix that will
generally return Full on all wrapped inputs. "Fixes" PR4545.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75444 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Support/ConstantRange.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/Support/ConstantRange.cpp b/lib/Support/ConstantRange.cpp index 8bab537..d7a57bb 100644 --- a/lib/Support/ConstantRange.cpp +++ b/lib/Support/ConstantRange.cpp @@ -557,13 +557,13 @@ ConstantRange::multiply(const ConstantRange &Other) const { if (isFullSet() || Other.isFullSet()) return ConstantRange(getBitWidth(), /*isFullSet=*/true); - ConstantRange this_zext = zeroExtend(getBitWidth() * 2); - ConstantRange Other_zext = Other.zeroExtend(getBitWidth() * 2); - - ConstantRange Result_zext = ConstantRange( - this_zext.getLower() * Other_zext.getLower(), - ((this_zext.getUpper()-1) * (Other_zext.getUpper()-1)) + 1); + APInt this_min = getUnsignedMin().zext(getBitWidth() * 2); + APInt this_max = getUnsignedMax().zext(getBitWidth() * 2); + APInt Other_min = Other.getUnsignedMin().zext(getBitWidth() * 2); + APInt Other_max = Other.getUnsignedMax().zext(getBitWidth() * 2); + ConstantRange Result_zext = ConstantRange(this_min * Other_min, + this_max * Other_max + 1); return Result_zext.truncate(getBitWidth()); } |