Skip to content

Commit 0c6a77b

Browse files
committed
[InstSimplify] Remove redundant simplifyAndOrOfICmpsWithZero() fold (NFCI)
This has been subsumed by simplifyAndOrWithICmpEq().
1 parent 013d1ca commit 0c6a77b

File tree

1 file changed

+0
-43
lines changed

1 file changed

+0
-43
lines changed

llvm/lib/Analysis/InstructionSimplify.cpp

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,43 +1674,6 @@ static Value *simplifyAndOrOfICmpsWithConstants(ICmpInst *Cmp0, ICmpInst *Cmp1,
16741674
return nullptr;
16751675
}
16761676

1677-
static Value *simplifyAndOrOfICmpsWithZero(ICmpInst *Cmp0, ICmpInst *Cmp1,
1678-
bool IsAnd) {
1679-
ICmpInst::Predicate P0 = Cmp0->getPredicate(), P1 = Cmp1->getPredicate();
1680-
if (!match(Cmp0->getOperand(1), m_Zero()) ||
1681-
!match(Cmp1->getOperand(1), m_Zero()) || P0 != P1)
1682-
return nullptr;
1683-
1684-
if ((IsAnd && P0 != ICmpInst::ICMP_NE) || (!IsAnd && P1 != ICmpInst::ICMP_EQ))
1685-
return nullptr;
1686-
1687-
// We have either "(X == 0 || Y == 0)" or "(X != 0 && Y != 0)".
1688-
Value *X = Cmp0->getOperand(0);
1689-
Value *Y = Cmp1->getOperand(0);
1690-
1691-
// If one of the compares is a masked version of a (not) null check, then
1692-
// that compare implies the other, so we eliminate the other. Optionally, look
1693-
// through a pointer-to-int cast to match a null check of a pointer type.
1694-
1695-
// (X == 0) || (([ptrtoint] X & ?) == 0) --> ([ptrtoint] X & ?) == 0
1696-
// (X == 0) || ((? & [ptrtoint] X) == 0) --> (? & [ptrtoint] X) == 0
1697-
// (X != 0) && (([ptrtoint] X & ?) != 0) --> ([ptrtoint] X & ?) != 0
1698-
// (X != 0) && ((? & [ptrtoint] X) != 0) --> (? & [ptrtoint] X) != 0
1699-
if (match(Y, m_c_And(m_Specific(X), m_Value())) ||
1700-
match(Y, m_c_And(m_PtrToInt(m_Specific(X)), m_Value())))
1701-
return Cmp1;
1702-
1703-
// (([ptrtoint] Y & ?) == 0) || (Y == 0) --> ([ptrtoint] Y & ?) == 0
1704-
// ((? & [ptrtoint] Y) == 0) || (Y == 0) --> (? & [ptrtoint] Y) == 0
1705-
// (([ptrtoint] Y & ?) != 0) && (Y != 0) --> ([ptrtoint] Y & ?) != 0
1706-
// ((? & [ptrtoint] Y) != 0) && (Y != 0) --> (? & [ptrtoint] Y) != 0
1707-
if (match(X, m_c_And(m_Specific(Y), m_Value())) ||
1708-
match(X, m_c_And(m_PtrToInt(m_Specific(Y)), m_Value())))
1709-
return Cmp0;
1710-
1711-
return nullptr;
1712-
}
1713-
17141677
static Value *simplifyAndOfICmpsWithAdd(ICmpInst *Op0, ICmpInst *Op1,
17151678
const InstrInfoQuery &IIQ) {
17161679
// (icmp (add V, C0), C1) & (icmp V, C0)
@@ -1789,9 +1752,6 @@ static Value *simplifyAndOfICmps(ICmpInst *Op0, ICmpInst *Op1,
17891752
if (Value *X = simplifyAndOrOfICmpsWithConstants(Op0, Op1, true))
17901753
return X;
17911754

1792-
if (Value *X = simplifyAndOrOfICmpsWithZero(Op0, Op1, true))
1793-
return X;
1794-
17951755
if (Value *X = simplifyAndOrOfICmpsWithCtpop(Op0, Op1, true))
17961756
return X;
17971757
if (Value *X = simplifyAndOrOfICmpsWithCtpop(Op1, Op0, true))
@@ -1862,9 +1822,6 @@ static Value *simplifyOrOfICmps(ICmpInst *Op0, ICmpInst *Op1,
18621822
if (Value *X = simplifyAndOrOfICmpsWithConstants(Op0, Op1, false))
18631823
return X;
18641824

1865-
if (Value *X = simplifyAndOrOfICmpsWithZero(Op0, Op1, false))
1866-
return X;
1867-
18681825
if (Value *X = simplifyAndOrOfICmpsWithCtpop(Op0, Op1, false))
18691826
return X;
18701827
if (Value *X = simplifyAndOrOfICmpsWithCtpop(Op1, Op0, false))

0 commit comments

Comments
 (0)