[llvm] 837bf32 - [ValueTracking] Remove unused `V ^ Mask == C` from `computeKnownBitsFromCmp`. NFCI. (#125666)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 4 13:27:09 PST 2025


Author: Yingwei Zheng
Date: 2025-02-05T05:27:05+08:00
New Revision: 837bf325528440ab0a73b31f810a39d6f8bec53e

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

LOG: [ValueTracking] Remove unused `V ^ Mask == C` from `computeKnownBitsFromCmp`. NFCI. (#125666)

I believe it is unused since we always convert it into `V == Mask ^ C`.
Code coverage:
https://dtcxzyw.github.io/llvm-opt-benchmark/coverage/data/zyw/opt-ci/actions-runner/_work/llvm-opt-benchmark/llvm-opt-benchmark/llvm/llvm-project/llvm/lib/Analysis/ValueTracking.cpp.html#L706

Added: 
    

Modified: 
    llvm/lib/Analysis/ValueTracking.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 55feb15dfb1527..f4958162accfe3 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -702,11 +702,6 @@ static void computeKnownBitsFromCmp(const Value *V, CmpInst::Predicate Pred,
       Known.Zero |= ~*C;
       if (match(Y, m_APInt(Mask)))
         Known.One |= *C & ~*Mask;
-      // assume(V ^ Mask = C)
-    } else if (match(LHS, m_Xor(m_V, m_APInt(Mask))) &&
-               match(RHS, m_APInt(C))) {
-      // Equivalent to assume(V == Mask ^ C)
-      Known = Known.unionWith(KnownBits::makeConstant(*C ^ *Mask));
       // assume(V << ShAmt = C)
     } else if (match(LHS, m_Shl(m_V, m_ConstantInt(ShAmt))) &&
                match(RHS, m_APInt(C)) && ShAmt < BitWidth) {
@@ -10217,10 +10212,9 @@ void llvm::findValuesAffectedByCondition(
       if (ICmpInst::isEquality(Pred)) {
         if (HasRHSC) {
           Value *Y;
-          // (X & C) or (X | C) or (X ^ C).
+          // (X & C) or (X | C).
           // (X << C) or (X >>_s C) or (X >>_u C).
-          if (match(A, m_BitwiseLogic(m_Value(X), m_ConstantInt())) ||
-              match(A, m_Shift(m_Value(X), m_ConstantInt())))
+          if (match(A, m_Shift(m_Value(X), m_ConstantInt())))
             AddAffected(X);
           else if (match(A, m_And(m_Value(X), m_Value(Y))) ||
                    match(A, m_Or(m_Value(X), m_Value(Y)))) {


        


More information about the llvm-commits mailing list