// Note that ptrtoint may change the bitwidth.
Value *A, *B;
- auto m_V = m_CombineOr(m_Specific(V), m_PtrToInt(m_Specific(V)));
+ auto m_V =
+ m_CombineOr(m_Specific(V), m_PtrToIntSameSize(Q.DL, m_Specific(V)));
CmpInst::Predicate Pred;
uint64_t C;
case ICmpInst::ICMP_EQ:
// assume(v = a)
if (match(Cmp, m_c_ICmp(Pred, m_V, m_Value(A)))) {
- KnownBits RHSKnown =
- computeKnownBits(A, Depth + 1, QueryNoAC).anyextOrTrunc(BitWidth);
+ KnownBits RHSKnown = computeKnownBits(A, Depth + 1, QueryNoAC);
Known = Known.unionWith(RHSKnown);
// assume(v & b = a)
} else if (match(Cmp,
m_c_ICmp(Pred, m_c_And(m_V, m_Value(B)), m_Value(A)))) {
- KnownBits RHSKnown =
- computeKnownBits(A, Depth + 1, QueryNoAC).anyextOrTrunc(BitWidth);
- KnownBits MaskKnown =
- computeKnownBits(B, Depth + 1, QueryNoAC).anyextOrTrunc(BitWidth);
+ 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
// known bits from the RHS to V.
// 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).anyextOrTrunc(BitWidth);
- KnownBits MaskKnown =
- computeKnownBits(B, Depth + 1, QueryNoAC).anyextOrTrunc(BitWidth);
+ 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.
// assume(v | b = a)
} else if (match(Cmp,
m_c_ICmp(Pred, m_c_Or(m_V, m_Value(B)), m_Value(A)))) {
- KnownBits RHSKnown =
- computeKnownBits(A, Depth + 1, QueryNoAC).anyextOrTrunc(BitWidth);
- KnownBits BKnown =
- computeKnownBits(B, Depth + 1, QueryNoAC).anyextOrTrunc(BitWidth);
+ 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 known
// bits from the RHS to V.
// 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).anyextOrTrunc(BitWidth);
- KnownBits BKnown =
- computeKnownBits(B, Depth + 1, QueryNoAC).anyextOrTrunc(BitWidth);
+ 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.
// assume(v ^ b = a)
} else if (match(Cmp,
m_c_ICmp(Pred, m_c_Xor(m_V, m_Value(B)), m_Value(A)))) {
- KnownBits RHSKnown =
- computeKnownBits(A, Depth + 1, QueryNoAC).anyextOrTrunc(BitWidth);
- KnownBits BKnown =
- computeKnownBits(B, Depth + 1, QueryNoAC).anyextOrTrunc(BitWidth);
+ 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 known
// bits from the RHS to V. For those bits in B that are known to be 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).anyextOrTrunc(BitWidth);
- KnownBits BKnown =
- computeKnownBits(B, Depth + 1, QueryNoAC).anyextOrTrunc(BitWidth);
+ 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
} else if (match(Cmp, m_c_ICmp(Pred, m_Shl(m_V, m_ConstantInt(C)),
m_Value(A))) &&
C < BitWidth) {
- KnownBits RHSKnown =
- computeKnownBits(A, Depth + 1, QueryNoAC).anyextOrTrunc(BitWidth);
+ KnownBits RHSKnown = computeKnownBits(A, Depth + 1, QueryNoAC);
// For those bits in RHS that are known, we can propagate them to known
// bits in V shifted to the right by C.
} 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).anyextOrTrunc(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);
} else if (match(Cmp, m_c_ICmp(Pred, m_Shr(m_V, m_ConstantInt(C)),
m_Value(A))) &&
C < BitWidth) {
- KnownBits RHSKnown =
- computeKnownBits(A, Depth + 1, QueryNoAC).anyextOrTrunc(BitWidth);
+ KnownBits RHSKnown = computeKnownBits(A, Depth + 1, QueryNoAC);
// For those bits in RHS that are known, we can propagate them to known
// bits in V shifted to the right by C.
Known.Zero |= RHSKnown.Zero << C;
} 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).anyextOrTrunc(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;
case ICmpInst::ICMP_SGE:
// assume(v >=_s c) where c is non-negative
if (match(Cmp, m_ICmp(Pred, m_V, m_Value(A)))) {
- KnownBits RHSKnown =
- computeKnownBits(A, Depth + 1, QueryNoAC).anyextOrTrunc(BitWidth);
+ KnownBits RHSKnown = computeKnownBits(A, Depth + 1, QueryNoAC);
if (RHSKnown.isNonNegative()) {
// We know that the sign bit is zero.
case ICmpInst::ICMP_SGT:
// assume(v >_s c) where c is at least -1.
if (match(Cmp, m_ICmp(Pred, m_V, m_Value(A)))) {
- KnownBits RHSKnown =
- computeKnownBits(A, Depth + 1, QueryNoAC).anyextOrTrunc(BitWidth);
+ KnownBits RHSKnown = computeKnownBits(A, Depth + 1, QueryNoAC);
if (RHSKnown.isAllOnes() || RHSKnown.isNonNegative()) {
// We know that the sign bit is zero.
case ICmpInst::ICMP_SLE:
// assume(v <=_s c) where c is negative
if (match(Cmp, m_ICmp(Pred, m_V, m_Value(A)))) {
- KnownBits RHSKnown =
- computeKnownBits(A, Depth + 1, QueryNoAC).anyextOrTrunc(BitWidth);
+ KnownBits RHSKnown = computeKnownBits(A, Depth + 1, QueryNoAC);
if (RHSKnown.isNegative()) {
// We know that the sign bit is one.
case ICmpInst::ICMP_SLT:
// assume(v <_s c) where c is non-positive
if (match(Cmp, m_ICmp(Pred, m_V, m_Value(A)))) {
- KnownBits RHSKnown =
- computeKnownBits(A, Depth + 1, QueryNoAC).anyextOrTrunc(BitWidth);
+ KnownBits RHSKnown = computeKnownBits(A, Depth + 1, QueryNoAC);
if (RHSKnown.isZero() || RHSKnown.isNegative()) {
// We know that the sign bit is one.
case ICmpInst::ICMP_ULE:
// assume(v <=_u c)
if (match(Cmp, m_ICmp(Pred, m_V, m_Value(A)))) {
- KnownBits RHSKnown =
- computeKnownBits(A, Depth + 1, QueryNoAC).anyextOrTrunc(BitWidth);
+ KnownBits RHSKnown = computeKnownBits(A, Depth + 1, QueryNoAC);
// Whatever high bits in c are zero are known to be zero.
Known.Zero.setHighBits(RHSKnown.countMinLeadingZeros());
case ICmpInst::ICMP_ULT:
// assume(v <_u c)
if (match(Cmp, m_ICmp(Pred, m_V, m_Value(A)))) {
- KnownBits RHSKnown =
- computeKnownBits(A, Depth + 1, QueryNoAC).anyextOrTrunc(BitWidth);
+ KnownBits RHSKnown = computeKnownBits(A, Depth + 1, QueryNoAC);
// If the RHS is known zero, then this assumption must be wrong (nothing
// is unsigned less than zero). Signal a conflict and get out of here.
// assume (v & b != 0) where b is a power of 2
const APInt *BPow2;
if (match(Cmp, m_ICmp(Pred, m_c_And(m_V, m_Power2(BPow2)), m_Zero()))) {
- Known.One |= BPow2->zextOrTrunc(BitWidth);
+ Known.One |= *BPow2;
}
} break;
}