Skip to content

[ValueTracking] Combine variable declaration with its only assignment. NFC #89526

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
Apr 21, 2024

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Apr 21, 2024

No description provided.

@topperc topperc requested a review from goldsteinn April 21, 2024 02:33
@topperc topperc requested a review from nikic as a code owner April 21, 2024 02:33
@llvmbot
Copy link
Member

llvmbot commented Apr 21, 2024

@llvm/pr-subscribers-llvm-analysis

Author: Craig Topper (topperc)

Changes

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

1 Files Affected:

  • (modified) llvm/lib/Analysis/ValueTracking.cpp (+1-2)
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index c038f7eaabbb67..21e3f8a4cc52c7 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -2682,7 +2682,6 @@ static bool isKnownNonZeroFromOperator(const Operator *I,
     if (cast<PossiblyExactOperator>(I)->isExact())
       return isKnownNonZero(I->getOperand(0), DemandedElts, Q, Depth);
 
-    std::optional<bool> XUgeY;
     KnownBits XKnown =
         computeKnownBits(I->getOperand(0), DemandedElts, Depth, Q);
     // If X is fully unknown we won't be able to figure anything out so don't
@@ -2698,7 +2697,7 @@ static bool isKnownNonZeroFromOperator(const Operator *I,
       YKnown = YKnown.abs(/*IntMinIsPoison*/ false);
     }
     // If X u>= Y then div is non zero (0/0 is UB).
-    XUgeY = KnownBits::uge(XKnown, YKnown);
+    std::optional<bool> XUgeY = KnownBits::uge(XKnown, YKnown);
     // If X is total unknown or X u< Y we won't be able to prove non-zero
     // with compute known bits so just return early.
     return XUgeY && *XUgeY;

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@topperc topperc merged commit 48324f0 into llvm:main Apr 21, 2024
6 checks passed
@topperc topperc deleted the pr/valuetracking-var branch April 21, 2024 16:57
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