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 | 2951c990cd0e13f4face58a5b785526b6cd3e740 (patch) | |
tree | 85898f70b1ef9aa4fb3dd8b243afa23462beac5b /llvm/lib/Support/ConstantRange.cpp | |
parent | 575db66e1b41e6f0cb753bb529998e999f547d48 (diff) | |
download | bcm5719-llvm-2951c990cd0e13f4face58a5b785526b6cd3e740.tar.gz bcm5719-llvm-2951c990cd0e13f4face58a5b785526b6cd3e740.zip |
Implement ConstantRange::multiply based on the code in LoopVR.
llvm-svn: 75410
Diffstat (limited to 'llvm/lib/Support/ConstantRange.cpp')
-rw-r--r-- | llvm/lib/Support/ConstantRange.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/llvm/lib/Support/ConstantRange.cpp b/llvm/lib/Support/ConstantRange.cpp index ad301c3e18a..7fe156835db 100644 --- a/llvm/lib/Support/ConstantRange.cpp +++ b/llvm/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 |