[llvm] 773ab3c - [Analysis] remove unneeded casts; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 27 10:49:09 PST 2021


Author: Sanjay Patel
Date: 2021-12-27T13:41:50-05:00
New Revision: 773ab3c6655f4d2beec25bb3516b4d4fe2eea990

URL: https://github.com/llvm/llvm-project/commit/773ab3c6655f4d2beec25bb3516b4d4fe2eea990
DIFF: https://github.com/llvm/llvm-project/commit/773ab3c6655f4d2beec25bb3516b4d4fe2eea990.diff

LOG: [Analysis] remove unneeded casts; NFC

The callee does the casting too; this matches a plain call later in the same function for 'shl'.

Added: 
    

Modified: 
    llvm/lib/Analysis/ValueTracking.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index fc378f97de0b1..7a1caed0420a1 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -6762,11 +6762,13 @@ static void setLimitsForBinOp(const BinaryOperator &BO, APInt &Lower,
   switch (BO.getOpcode()) {
   case Instruction::Add:
     if (match(BO.getOperand(1), m_APInt(C)) && !C->isZero()) {
+      bool HasNSW = IIQ.hasNoSignedWrap(&BO);
+      bool HasNUW = IIQ.hasNoUnsignedWrap(&BO);
       // FIXME: If we have both nuw and nsw, we should reduce the range further.
-      if (IIQ.hasNoUnsignedWrap(cast<OverflowingBinaryOperator>(&BO))) {
+      if (HasNUW) {
         // 'add nuw x, C' produces [C, UINT_MAX].
         Lower = *C;
-      } else if (IIQ.hasNoSignedWrap(cast<OverflowingBinaryOperator>(&BO))) {
+      } else if (HasNSW) {
         if (C->isNegative()) {
           // 'add nsw x, -C' produces [SINT_MIN, SINT_MAX - C].
           Lower = APInt::getSignedMinValue(Width);


        


More information about the llvm-commits mailing list