[llvm] 72a21ad - [CR] ConstantRange::sshl_sat(): check sigdness of the min/max, not ranges

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 7 23:33:38 PST 2019


Author: Roman Lebedev
Date: 2019-11-08T10:32:56+03:00
New Revision: 72a21ad6c9cdbb41c8f17de2318fa469c013caef

URL: https://github.com/llvm/llvm-project/commit/72a21ad6c9cdbb41c8f17de2318fa469c013caef
DIFF: https://github.com/llvm/llvm-project/commit/72a21ad6c9cdbb41c8f17de2318fa469c013caef.diff

LOG: [CR] ConstantRange::sshl_sat(): check sigdness of the min/max, not ranges

This was pointed out in review,
but forgot to stage this change into the commit itself..

Added: 
    

Modified: 
    llvm/lib/IR/ConstantRange.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp
index 63a6494fc178..e9bdf4193529 100644
--- a/llvm/lib/IR/ConstantRange.cpp
+++ b/llvm/lib/IR/ConstantRange.cpp
@@ -1348,8 +1348,8 @@ ConstantRange ConstantRange::sshl_sat(const ConstantRange &Other) const {
 
   APInt Min = getSignedMin(), Max = getSignedMax();
   APInt ShAmtMin = Other.getUnsignedMin(), ShAmtMax = Other.getUnsignedMax();
-  APInt NewL = Min.sshl_sat(isAllNonNegative() ? ShAmtMin : ShAmtMax);
-  APInt NewU = Max.sshl_sat(isAllNegative() ? ShAmtMin : ShAmtMax) + 1;
+  APInt NewL = Min.sshl_sat(Min.isNonNegative() ? ShAmtMin : ShAmtMax);
+  APInt NewU = Max.sshl_sat(Max.isNegative() ? ShAmtMin : ShAmtMax) + 1;
   return getNonEmpty(std::move(NewL), std::move(NewU));
 }
 


        


More information about the llvm-commits mailing list