diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2009-07-12 02:19:05 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2009-07-12 02:19:05 +0000 |
commit | 5c21d71bda0f77f6c31460e6ff15e3bb2824b4aa (patch) | |
tree | f57a6796196fc208afbc658446ec7412277886d5 /lib/Support | |
parent | cb66d3ee015a67b013209923c463ebd563e94135 (diff) | |
download | external_llvm-5c21d71bda0f77f6c31460e6ff15e3bb2824b4aa.zip external_llvm-5c21d71bda0f77f6c31460e6ff15e3bb2824b4aa.tar.gz external_llvm-5c21d71bda0f77f6c31460e6ff15e3bb2824b4aa.tar.bz2 |
Implement ConstantRange::multiply based on the code in LoopVR.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75410 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/ConstantRange.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/Support/ConstantRange.cpp b/lib/Support/ConstantRange.cpp index ad301c3..7fe1568 100644 --- a/lib/Support/ConstantRange.cpp +++ b/lib/Support/ConstantRange.cpp @@ -550,9 +550,19 @@ ConstantRange::add(const ConstantRange &Other) const { ConstantRange ConstantRange::multiply(const ConstantRange &Other) const { - // TODO: Implement multiply. - return ConstantRange(getBitWidth(), - !(isEmptySet() || Other.isEmptySet())); + if (isEmptySet() || Other.isEmptySet()) + return ConstantRange(getBitWidth(), /*isFullSet=*/false); + 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); + + return Result_zext.truncate(getBitWidth()); } ConstantRange |