summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2012-07-16 20:47:16 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2012-07-16 20:47:16 +0000
commit986cc181b0ac566e4de37da82b0ea66451ec0b7c (patch)
tree82bd96f900eb84470dbe61f9e12b293aef0f4758 /llvm/lib/Support
parent784933b791626f16422ac8cf234a127bf6981406 (diff)
downloadbcm5719-llvm-986cc181b0ac566e4de37da82b0ea66451ec0b7c.tar.gz
bcm5719-llvm-986cc181b0ac566e4de37da82b0ea66451ec0b7c.zip
teach ConstantRange that zero times X is always zero
llvm-svn: 160317
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r--llvm/lib/Support/ConstantRange.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Support/ConstantRange.cpp b/llvm/lib/Support/ConstantRange.cpp
index b83dcccca67..221ca948ca5 100644
--- a/llvm/lib/Support/ConstantRange.cpp
+++ b/llvm/lib/Support/ConstantRange.cpp
@@ -537,6 +537,12 @@ ConstantRange::multiply(const ConstantRange &Other) const {
if (isEmptySet() || Other.isEmptySet())
return ConstantRange(getBitWidth(), /*isFullSet=*/false);
+
+ // If any of the operands is zero, then the result is also zero.
+ if ((getSingleElement() && *getSingleElement() == 0) ||
+ (Other.getSingleElement() && *Other.getSingleElement() == 0))
+ return ConstantRange(APInt(getBitWidth(), 0));
+
if (isFullSet() || Other.isFullSet())
return ConstantRange(getBitWidth(), /*isFullSet=*/true);
OpenPOWER on IntegriCloud