Skip to content

Commit 8775232

Browse files
committed
[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.
1 parent c4fd1fd commit 8775232

File tree

2 files changed

+1
-60
lines changed

2 files changed

+1
-60
lines changed

llvm/lib/Analysis/AssumptionCache.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,7 @@ findAffectedValues(CallBase *CI, TargetTransformInfo *TTI,
9494
if (Pred == ICmpInst::ICMP_EQ) {
9595
// For equality comparisons, we handle the case of bit inversion.
9696
auto AddAffectedFromEq = [&AddAffected](Value *V) {
97-
Value *A;
98-
if (match(V, m_Not(m_Value(A)))) {
99-
AddAffected(A);
100-
V = A;
101-
}
102-
103-
Value *B;
97+
Value *A, *B;
10498
// (A & B) or (A | B) or (A ^ B).
10599
if (match(V, m_BitwiseLogic(m_Value(A), m_Value(B)))) {
106100
AddAffected(A);

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -662,16 +662,6 @@ static void computeKnownBitsFromCmp(const Value *V, const ICmpInst *Cmp,
662662
// known bits from the RHS to V.
663663
Known.Zero |= RHSKnown.Zero & MaskKnown.One;
664664
Known.One |= RHSKnown.One & MaskKnown.One;
665-
// assume(~(v & b) = a)
666-
} else if (match(Cmp, m_c_ICmp(Pred, m_Not(m_c_And(m_V, m_Value(B))),
667-
m_Value(A)))) {
668-
KnownBits RHSKnown = computeKnownBits(A, Depth + 1, QueryNoAC);
669-
KnownBits MaskKnown = computeKnownBits(B, Depth + 1, QueryNoAC);
670-
671-
// For those bits in the mask that are known to be one, we can propagate
672-
// inverted known bits from the RHS to V.
673-
Known.Zero |= RHSKnown.One & MaskKnown.One;
674-
Known.One |= RHSKnown.Zero & MaskKnown.One;
675665
// assume(v | b = a)
676666
} else if (match(Cmp,
677667
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,
682672
// bits from the RHS to V.
683673
Known.Zero |= RHSKnown.Zero & BKnown.Zero;
684674
Known.One |= RHSKnown.One & BKnown.Zero;
685-
// assume(~(v | b) = a)
686-
} else if (match(Cmp, m_c_ICmp(Pred, m_Not(m_c_Or(m_V, m_Value(B))),
687-
m_Value(A)))) {
688-
KnownBits RHSKnown = computeKnownBits(A, Depth + 1, QueryNoAC);
689-
KnownBits BKnown = computeKnownBits(B, Depth + 1, QueryNoAC);
690-
691-
// For those bits in B that are known to be zero, we can propagate
692-
// inverted known bits from the RHS to V.
693-
Known.Zero |= RHSKnown.One & BKnown.Zero;
694-
Known.One |= RHSKnown.Zero & BKnown.Zero;
695675
// assume(v ^ b = a)
696676
} else if (match(Cmp,
697677
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,
705685
Known.One |= RHSKnown.One & BKnown.Zero;
706686
Known.Zero |= RHSKnown.One & BKnown.One;
707687
Known.One |= RHSKnown.Zero & BKnown.One;
708-
// assume(~(v ^ b) = a)
709-
} else if (match(Cmp, m_c_ICmp(Pred, m_Not(m_c_Xor(m_V, m_Value(B))),
710-
m_Value(A)))) {
711-
KnownBits RHSKnown = computeKnownBits(A, Depth + 1, QueryNoAC);
712-
KnownBits BKnown = computeKnownBits(B, Depth + 1, QueryNoAC);
713-
714-
// For those bits in B that are known to be zero, we can propagate
715-
// inverted known bits from the RHS to V. For those bits in B that are
716-
// known to be one, we can propagate known bits from the RHS to V.
717-
Known.Zero |= RHSKnown.One & BKnown.Zero;
718-
Known.One |= RHSKnown.Zero & BKnown.Zero;
719-
Known.Zero |= RHSKnown.Zero & BKnown.One;
720-
Known.One |= RHSKnown.One & BKnown.One;
721688
// assume(v << c = a)
722689
} else if (match(Cmp, m_c_ICmp(Pred, m_Shl(m_V, m_ConstantInt(C)),
723690
m_Value(A))) &&
@@ -729,17 +696,6 @@ static void computeKnownBitsFromCmp(const Value *V, const ICmpInst *Cmp,
729696
RHSKnown.Zero.lshrInPlace(C);
730697
RHSKnown.One.lshrInPlace(C);
731698
Known = Known.unionWith(RHSKnown);
732-
// assume(~(v << c) = a)
733-
} else if (match(Cmp, m_c_ICmp(Pred, m_Not(m_Shl(m_V, m_ConstantInt(C))),
734-
m_Value(A))) &&
735-
C < BitWidth) {
736-
KnownBits RHSKnown = computeKnownBits(A, Depth + 1, QueryNoAC);
737-
// For those bits in RHS that are known, we can propagate them inverted
738-
// to known bits in V shifted to the right by C.
739-
RHSKnown.One.lshrInPlace(C);
740-
Known.Zero |= RHSKnown.One;
741-
RHSKnown.Zero.lshrInPlace(C);
742-
Known.One |= RHSKnown.Zero;
743699
// assume(v >> c = a)
744700
} else if (match(Cmp, m_c_ICmp(Pred, m_Shr(m_V, m_ConstantInt(C)),
745701
m_Value(A))) &&
@@ -749,15 +705,6 @@ static void computeKnownBitsFromCmp(const Value *V, const ICmpInst *Cmp,
749705
// bits in V shifted to the right by C.
750706
Known.Zero |= RHSKnown.Zero << C;
751707
Known.One |= RHSKnown.One << C;
752-
// assume(~(v >> c) = a)
753-
} else if (match(Cmp, m_c_ICmp(Pred, m_Not(m_Shr(m_V, m_ConstantInt(C))),
754-
m_Value(A))) &&
755-
C < BitWidth) {
756-
KnownBits RHSKnown = computeKnownBits(A, Depth + 1, QueryNoAC);
757-
// For those bits in RHS that are known, we can propagate them inverted
758-
// to known bits in V shifted to the right by C.
759-
Known.Zero |= RHSKnown.One << C;
760-
Known.One |= RHSKnown.Zero << C;
761708
}
762709
break;
763710
case ICmpInst::ICMP_NE: {

0 commit comments

Comments
 (0)