[llvm] 2b624e0 - Fix 'unsigned variable can never be negative' cppcheck warning. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 2 10:53:51 PST 2020


Author: Simon Pilgrim
Date: 2020-03-02T18:53:18Z
New Revision: 2b624e04c718f4bdcab114618eb0a457165922a9

URL: https://github.com/llvm/llvm-project/commit/2b624e04c718f4bdcab114618eb0a457165922a9
DIFF: https://github.com/llvm/llvm-project/commit/2b624e04c718f4bdcab114618eb0a457165922a9.diff

LOG: Fix 'unsigned variable can never be negative' cppcheck warning. NFCI.

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86ISelDAGToDAG.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index ed0c050a2b97..d1975191c795 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -1826,7 +1826,7 @@ static bool foldMaskAndShiftToScale(SelectionDAG &DAG, SDValue N,
 
   // There is nothing we can do here unless the mask is removing some bits.
   // Also, the addressing mode can only represent shifts of 1, 2, or 3 bits.
-  if (AMShiftAmt <= 0 || AMShiftAmt > 3) return true;
+  if (AMShiftAmt == 0 || AMShiftAmt > 3) return true;
 
   // We also need to ensure that mask is a continuous run of bits.
   if (countTrailingOnes(Mask >> MaskTZ) + MaskTZ + MaskLZ != 64) return true;
@@ -1921,7 +1921,7 @@ static bool foldMaskedShiftToBEXTR(SelectionDAG &DAG, SDValue N,
 
   // There is nothing we can do here unless the mask is removing some bits.
   // Also, the addressing mode can only represent shifts of 1, 2, or 3 bits.
-  if (AMShiftAmt <= 0 || AMShiftAmt > 3) return true;
+  if (AMShiftAmt == 0 || AMShiftAmt > 3) return true;
 
   MVT VT = N.getSimpleValueType();
   SDLoc DL(N);


        


More information about the llvm-commits mailing list