Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2024

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
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
7 of 8 checks passed
@topperc topperc deleted the pr/vsetvli-unsigned-max branch June 27, 2024 00:30
lravenclaw pushed a commit to lravenclaw/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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants