[llvm] [SCCPSolver] Move getValueState to later (PR #175307)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 10 04:41:25 PST 2026


https://github.com/aokblast created https://github.com/llvm/llvm-project/pull/175307

If the IV is overDefined, there is no reason for us to init V0State.

>From 6f475b8e9e49eeaece1e991bcdf70b1d1548f561 Mon Sep 17 00:00:00 2001
From: ShengYi Hung <aokblast at FreeBSD.org>
Date: Sat, 10 Jan 2026 15:41:54 +0800
Subject: [PATCH] [SCCPSolver] Move getValueState to later

If the IV is overDefined, there is no reason for us to init V0State.
---
 llvm/lib/Transforms/Utils/SCCPSolver.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Transforms/Utils/SCCPSolver.cpp b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
index 021bf0618754a..b5b7a7fbb587b 100644
--- a/llvm/lib/Transforms/Utils/SCCPSolver.cpp
+++ b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
@@ -1661,14 +1661,13 @@ void SCCPInstVisitor::visitSelectInst(SelectInst &I) {
 
 // Handle Unary Operators.
 void SCCPInstVisitor::visitUnaryOperator(Instruction &I) {
-  ValueLatticeElement V0State = getValueState(I.getOperand(0));
-
   ValueLatticeElement &IV = ValueState[&I];
   // resolvedUndefsIn might mark I as overdefined. Bail out, even if we would
   // discover a concrete value later.
   if (IV.isOverdefined())
     return (void)markOverdefined(&I);
 
+  ValueLatticeElement V0State = getValueState(I.getOperand(0));
   // If something is unknown/undef, wait for it to resolve.
   if (V0State.isUnknownOrUndef())
     return;
@@ -1687,13 +1686,13 @@ void SCCPInstVisitor::visitFreezeInst(FreezeInst &I) {
   if (I.getType()->isStructTy())
     return (void)markOverdefined(&I);
 
-  ValueLatticeElement V0State = getValueState(I.getOperand(0));
   ValueLatticeElement &IV = ValueState[&I];
   // resolvedUndefsIn might mark I as overdefined. Bail out, even if we would
   // discover a concrete value later.
   if (IV.isOverdefined())
     return (void)markOverdefined(&I);
 
+  ValueLatticeElement V0State = getValueState(I.getOperand(0));
   // If something is unknown/undef, wait for it to resolve.
   if (V0State.isUnknownOrUndef())
     return;



More information about the llvm-commits mailing list