Skip to content

Conversation

@topperc
Copy link
Collaborator

@topperc topperc commented Jun 26, 2024

This avoids the need to subtract 1 and explain why.

…etUpper to simplify some code.

This avoids the need to subtract 1 and explain why.
@topperc topperc requested a review from wangpc-pp June 26, 2024 20:27
@topperc topperc requested a review from nikic as a code owner June 26, 2024 20:27
@llvmbot llvmbot added the llvm:analysis Includes value tracking, cost tables and constant folding label Jun 26, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 26, 2024

@llvm/pr-subscribers-llvm-analysis

Author: Craig Topper (topperc)

Changes

This avoids the need to subtract 1 and explain why.


Full diff: https://github.com/llvm/llvm-project/pull/96816.diff

1 Files Affected:

  • (modified) llvm/lib/Analysis/ValueTracking.cpp (+1-3)
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.

@topperc topperc merged commit 326ba38 into llvm:main Jun 27, 2024
@topperc topperc deleted the pr/vsetvli-unsigned-max branch June 27, 2024 00:30
cpiaseque pushed a commit to cpiaseque/llvm-project that referenced this pull request Jul 3, 2024
…etUpper to simplify some code. (llvm#96816)

This avoids the need to subtract 1 and explain why.
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
…etUpper to simplify some code. (llvm#96816)

This avoids the need to subtract 1 and explain why.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llvm:analysis Includes value tracking, cost tables and constant folding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants