From 7e733eab2f11fceb24d6b4f25c27d7ba7d92d97e Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Mon, 16 Jul 2012 20:47:16 +0000 Subject: teach ConstantRange that zero times X is always zero git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160317 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/ConstantRange.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/Support/ConstantRange.cpp') diff --git a/lib/Support/ConstantRange.cpp b/lib/Support/ConstantRange.cpp index b83dcccca6..221ca948ca 100644 --- a/lib/Support/ConstantRange.cpp +++ b/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); -- cgit v1.2.3-18-g5258