[llvm] ebc54e0 - [SCCP] Make check for unknown/undef in unary op handling more explicit (NFCI)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 14 01:56:19 PDT 2022


Author: Nikita Popov
Date: 2022-07-14T10:56:11+02:00
New Revision: ebc54e0cd43e6abd595c45ae091ef67a8b38863b

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

LOG: [SCCP] Make check for unknown/undef in unary op handling more explicit (NFCI)

Make the implementation more similar to other functions, by
explicitly skipping an unknown/undef first, and always falling
back to overdefined at the end. I don't think it makes a difference
now, but could make one once the constant evaluation can fail. In
that case we would directly mark the result as overdefined now,
rather than keeping it unknown (and later making it overdefined
because we think it's undef-based).

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/SCCPSolver.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/SCCPSolver.cpp b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
index 3cec437ea33d..09a83f1ea094 100644
--- a/llvm/lib/Transforms/Utils/SCCPSolver.cpp
+++ b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
@@ -953,15 +953,15 @@ void SCCPInstVisitor::visitUnaryOperator(Instruction &I) {
   if (isOverdefined(IV))
     return (void)markOverdefined(&I);
 
+  // If something is unknown/undef, wait for it to resolve.
+  if (V0State.isUnknownOrUndef())
+    return;
+
   if (isConstant(V0State))
     if (Constant *C = ConstantFoldUnaryOpOperand(I.getOpcode(),
                                                  getConstant(V0State), DL))
       return (void)markConstant(IV, &I, C);
 
-  // If something is undef, wait for it to resolve.
-  if (!isOverdefined(V0State))
-    return;
-
   markOverdefined(&I);
 }
 


        


More information about the llvm-commits mailing list