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 | 5302389442e928e7d8e9d07be1a4a463085d754a (patch) | |
tree | 9f4f40ecf17cf09abd6002f1e4718820145092ab /llvm/lib | |
parent | 73b704dd9c694d3c4641befa20fa00a7fee06065 (diff) | |
download | bcm5719-llvm-5302389442e928e7d8e9d07be1a4a463085d754a.tar.gz bcm5719-llvm-5302389442e928e7d8e9d07be1a4a463085d754a.zip |
Multiply was very wrong for wrapped ranges. This supplies a half-fix that will
generally return Full on all wrapped inputs. "Fixes" PR4545.
llvm-svn: 75444
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Support/ConstantRange.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/lib/Support/ConstantRange.cpp b/llvm/lib/Support/ConstantRange.cpp index 8bab5377952..d7a57bb134c 100644 --- a/llvm/lib/Support/ConstantRange.cpp +++ b/llvm/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()); } |