[llvm] bb20cf2 - [KnownBits] Pull out repeated getMinValue() calls from shift analysis. NFCI.
    Simon Pilgrim via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon Feb 22 10:41:20 PST 2021
    
    
  
Author: Simon Pilgrim
Date: 2021-02-22T18:41:01Z
New Revision: bb20cf2f1c7ad6ef8a6ab0bc5ca5ea7db4b2282d
URL: https://github.com/llvm/llvm-project/commit/bb20cf2f1c7ad6ef8a6ab0bc5ca5ea7db4b2282d
DIFF: https://github.com/llvm/llvm-project/commit/bb20cf2f1c7ad6ef8a6ab0bc5ca5ea7db4b2282d.diff
LOG: [KnownBits] Pull out repeated getMinValue() calls from shift analysis. NFCI.
Added: 
    
Modified: 
    llvm/lib/Support/KnownBits.cpp
Removed: 
    
################################################################################
diff  --git a/llvm/lib/Support/KnownBits.cpp b/llvm/lib/Support/KnownBits.cpp
index 6acd8412a9b6..d7265d03d27d 100644
--- a/llvm/lib/Support/KnownBits.cpp
+++ b/llvm/lib/Support/KnownBits.cpp
@@ -181,8 +181,9 @@ KnownBits KnownBits::shl(const KnownBits &LHS, const KnownBits &RHS) {
   unsigned MinTrailingZeros = LHS.countMinTrailingZeros();
 
   // Minimum shift amount low bits are known zero.
-  if (RHS.getMinValue().ult(BitWidth)) {
-    MinTrailingZeros += RHS.getMinValue().getZExtValue();
+  APInt MinShiftAmount = RHS.getMinValue();
+  if (MinShiftAmount.ult(BitWidth)) {
+    MinTrailingZeros += MinShiftAmount.getZExtValue();
     MinTrailingZeros = std::min(MinTrailingZeros, BitWidth);
   }
 
@@ -208,8 +209,9 @@ KnownBits KnownBits::lshr(const KnownBits &LHS, const KnownBits &RHS) {
   unsigned MinLeadingZeros = LHS.countMinLeadingZeros();
 
   // Minimum shift amount high bits are known zero.
-  if (RHS.getMinValue().ult(BitWidth)) {
-    MinLeadingZeros += RHS.getMinValue().getZExtValue();
+  APInt MinShiftAmount = RHS.getMinValue();
+  if (MinShiftAmount.ult(BitWidth)) {
+    MinLeadingZeros += MinShiftAmount.getZExtValue();
     MinLeadingZeros = std::min(MinLeadingZeros, BitWidth);
   }
 
@@ -234,13 +236,14 @@ KnownBits KnownBits::ashr(const KnownBits &LHS, const KnownBits &RHS) {
   unsigned MinLeadingOnes = LHS.countMinLeadingOnes();
 
   // Minimum shift amount high bits are known sign bits.
-  if (RHS.getMinValue().ult(BitWidth)) {
+  APInt MinShiftAmount = RHS.getMinValue();
+  if (MinShiftAmount.ult(BitWidth)) {
     if (MinLeadingZeros) {
-      MinLeadingZeros += RHS.getMinValue().getZExtValue();
+      MinLeadingZeros += MinShiftAmount.getZExtValue();
       MinLeadingZeros = std::min(MinLeadingZeros, BitWidth);
     }
     if (MinLeadingOnes) {
-      MinLeadingOnes += RHS.getMinValue().getZExtValue();
+      MinLeadingOnes += MinShiftAmount.getZExtValue();
       MinLeadingOnes = std::min(MinLeadingOnes, BitWidth);
     }
   }
        
    
    
More information about the llvm-commits
mailing list