[llvm] 326ba38 - [ValueTracking][RISCV] Use ConstantRange::getUnsignedMax instead of getUpper to simplify some code. (#96816)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 26 17:30:22 PDT 2024


Author: Craig Topper
Date: 2024-06-26T17:30:19-07:00
New Revision: 326ba38a991250a8587a399a260b0f7af2c9166a

URL: https://github.com/llvm/llvm-project/commit/326ba38a991250a8587a399a260b0f7af2c9166a
DIFF: https://github.com/llvm/llvm-project/commit/326ba38a991250a8587a399a260b0f7af2c9166a.diff

LOG: [ValueTracking][RISCV] Use ConstantRange::getUnsignedMax instead of getUpper to simplify some code. (#96816)

This avoids the need to subtract 1 and explain why.

Added: 
    

Modified: 
    llvm/lib/Analysis/ValueTracking.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 777b2792a1ed2..1dfc6cfac4551 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -1740,10 +1740,8 @@ static void computeKnownBitsFromOperator(const Operator *I,
             cast<ConstantInt>(II->getArgOperand(HasAVL))->getZExtValue());
         RISCVII::VLMUL VLMUL = static_cast<RISCVII::VLMUL>(
             cast<ConstantInt>(II->getArgOperand(1 + HasAVL))->getZExtValue());
-        // The Range is [Lower, Upper), so we need to subtract 1 here to get the
-        // real upper value.
         uint64_t MaxVLEN =
-            (Range.getUpper().getZExtValue() - 1) * RISCV::RVVBitsPerBlock;
+            Range.getUnsignedMax().getZExtValue() * RISCV::RVVBitsPerBlock;
         uint64_t MaxVL = MaxVLEN / RISCVVType::getSEWLMULRatio(SEW, VLMUL);
 
         // Result of vsetvli must be not larger than AVL.


        


More information about the llvm-commits mailing list