Commit 8775232c authored by Nikita Popov's avatar Nikita Popov
Browse files

[ValueTracking] Remove handling of KnownBits assumptions with invert

For all practical purposes, we only care about comparisons with
constant RHS in this code. In that case, an invert will be
canonicalized into the constant and it will be handled by other cases.

Given the complete lack of test coverage, I'm removing this code.
parent c4fd1fd6
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -94,13 +94,7 @@ findAffectedValues(CallBase *CI, TargetTransformInfo *TTI,
    if (Pred == ICmpInst::ICMP_EQ) {
      // For equality comparisons, we handle the case of bit inversion.
      auto AddAffectedFromEq = [&AddAffected](Value *V) {
        Value *A;
        if (match(V, m_Not(m_Value(A)))) {
          AddAffected(A);
          V = A;
        }

        Value *B;
        Value *A, *B;
        // (A & B) or (A | B) or (A ^ B).
        if (match(V, m_BitwiseLogic(m_Value(A), m_Value(B)))) {
          AddAffected(A);
+0 −53
Original line number Diff line number Diff line
@@ -662,16 +662,6 @@ static void computeKnownBitsFromCmp(const Value *V, const ICmpInst *Cmp,
      // known bits from the RHS to V.
      Known.Zero |= RHSKnown.Zero & MaskKnown.One;
      Known.One |= RHSKnown.One & MaskKnown.One;
      // assume(~(v & b) = a)
    } else if (match(Cmp, m_c_ICmp(Pred, m_Not(m_c_And(m_V, m_Value(B))),
                                   m_Value(A)))) {
      KnownBits RHSKnown = computeKnownBits(A, Depth + 1, QueryNoAC);
      KnownBits MaskKnown = computeKnownBits(B, Depth + 1, QueryNoAC);

      // For those bits in the mask that are known to be one, we can propagate
      // inverted known bits from the RHS to V.
      Known.Zero |= RHSKnown.One & MaskKnown.One;
      Known.One |= RHSKnown.Zero & MaskKnown.One;
      // assume(v | b = a)
    } else if (match(Cmp,
                     m_c_ICmp(Pred, m_c_Or(m_V, m_Value(B)), m_Value(A)))) {
@@ -682,16 +672,6 @@ static void computeKnownBitsFromCmp(const Value *V, const ICmpInst *Cmp,
      // bits from the RHS to V.
      Known.Zero |= RHSKnown.Zero & BKnown.Zero;
      Known.One |= RHSKnown.One & BKnown.Zero;
      // assume(~(v | b) = a)
    } else if (match(Cmp, m_c_ICmp(Pred, m_Not(m_c_Or(m_V, m_Value(B))),
                                   m_Value(A)))) {
      KnownBits RHSKnown = computeKnownBits(A, Depth + 1, QueryNoAC);
      KnownBits BKnown = computeKnownBits(B, Depth + 1, QueryNoAC);

      // For those bits in B that are known to be zero, we can propagate
      // inverted known bits from the RHS to V.
      Known.Zero |= RHSKnown.One & BKnown.Zero;
      Known.One |= RHSKnown.Zero & BKnown.Zero;
      // assume(v ^ b = a)
    } else if (match(Cmp,
                     m_c_ICmp(Pred, m_c_Xor(m_V, m_Value(B)), m_Value(A)))) {
@@ -705,19 +685,6 @@ static void computeKnownBitsFromCmp(const Value *V, const ICmpInst *Cmp,
      Known.One |= RHSKnown.One & BKnown.Zero;
      Known.Zero |= RHSKnown.One & BKnown.One;
      Known.One |= RHSKnown.Zero & BKnown.One;
      // assume(~(v ^ b) = a)
    } else if (match(Cmp, m_c_ICmp(Pred, m_Not(m_c_Xor(m_V, m_Value(B))),
                                   m_Value(A)))) {
      KnownBits RHSKnown = computeKnownBits(A, Depth + 1, QueryNoAC);
      KnownBits BKnown = computeKnownBits(B, Depth + 1, QueryNoAC);

      // For those bits in B that are known to be zero, we can propagate
      // inverted known bits from the RHS to V. For those bits in B that are
      // known to be one, we can propagate known bits from the RHS to V.
      Known.Zero |= RHSKnown.One & BKnown.Zero;
      Known.One |= RHSKnown.Zero & BKnown.Zero;
      Known.Zero |= RHSKnown.Zero & BKnown.One;
      Known.One |= RHSKnown.One & BKnown.One;
      // assume(v << c = a)
    } else if (match(Cmp, m_c_ICmp(Pred, m_Shl(m_V, m_ConstantInt(C)),
                                   m_Value(A))) &&
@@ -729,17 +696,6 @@ static void computeKnownBitsFromCmp(const Value *V, const ICmpInst *Cmp,
      RHSKnown.Zero.lshrInPlace(C);
      RHSKnown.One.lshrInPlace(C);
      Known = Known.unionWith(RHSKnown);
      // assume(~(v << c) = a)
    } else if (match(Cmp, m_c_ICmp(Pred, m_Not(m_Shl(m_V, m_ConstantInt(C))),
                                   m_Value(A))) &&
               C < BitWidth) {
      KnownBits RHSKnown = computeKnownBits(A, Depth + 1, QueryNoAC);
      // For those bits in RHS that are known, we can propagate them inverted
      // to known bits in V shifted to the right by C.
      RHSKnown.One.lshrInPlace(C);
      Known.Zero |= RHSKnown.One;
      RHSKnown.Zero.lshrInPlace(C);
      Known.One |= RHSKnown.Zero;
      // assume(v >> c = a)
    } else if (match(Cmp, m_c_ICmp(Pred, m_Shr(m_V, m_ConstantInt(C)),
                                   m_Value(A))) &&
@@ -749,15 +705,6 @@ static void computeKnownBitsFromCmp(const Value *V, const ICmpInst *Cmp,
      // bits in V shifted to the right by C.
      Known.Zero |= RHSKnown.Zero << C;
      Known.One |= RHSKnown.One << C;
      // assume(~(v >> c) = a)
    } else if (match(Cmp, m_c_ICmp(Pred, m_Not(m_Shr(m_V, m_ConstantInt(C))),
                                   m_Value(A))) &&
               C < BitWidth) {
      KnownBits RHSKnown = computeKnownBits(A, Depth + 1, QueryNoAC);
      // For those bits in RHS that are known, we can propagate them inverted
      // to known bits in V shifted to the right by C.
      Known.Zero |= RHSKnown.One << C;
      Known.One |= RHSKnown.Zero << C;
    }
    break;
  case ICmpInst::ICMP_NE: {