@@ -1758,66 +1758,6 @@ static Value *simplifyAndOfICmpsWithAdd(ICmpInst *Op0, ICmpInst *Op1,
1758
1758
return nullptr ;
1759
1759
}
1760
1760
1761
- // / Try to eliminate compares with signed or unsigned min/max constants.
1762
- static Value *simplifyAndOrOfICmpsWithLimitConst (ICmpInst *Cmp0, ICmpInst *Cmp1,
1763
- bool IsAnd) {
1764
- // Canonicalize an equality compare as Cmp0.
1765
- if (Cmp1->isEquality ())
1766
- std::swap (Cmp0, Cmp1);
1767
- if (!Cmp0->isEquality ())
1768
- return nullptr ;
1769
-
1770
- // The non-equality compare must include a common operand (X). Canonicalize
1771
- // the common operand as operand 0 (the predicate is swapped if the common
1772
- // operand was operand 1).
1773
- ICmpInst::Predicate Pred0 = Cmp0->getPredicate ();
1774
- Value *X = Cmp0->getOperand (0 );
1775
- ICmpInst::Predicate Pred1;
1776
- bool HasNotOp = match (Cmp1, m_c_ICmp (Pred1, m_Not (m_Specific (X)), m_Value ()));
1777
- if (!HasNotOp && !match (Cmp1, m_c_ICmp (Pred1, m_Specific (X), m_Value ())))
1778
- return nullptr ;
1779
- if (ICmpInst::isEquality (Pred1))
1780
- return nullptr ;
1781
-
1782
- // The equality compare must be against a constant. Flip bits if we matched
1783
- // a bitwise not. Convert a null pointer constant to an integer zero value.
1784
- APInt MinMaxC;
1785
- const APInt *C;
1786
- if (match (Cmp0->getOperand (1 ), m_APInt (C)))
1787
- MinMaxC = HasNotOp ? ~*C : *C;
1788
- else if (isa<ConstantPointerNull>(Cmp0->getOperand (1 )))
1789
- MinMaxC = APInt::getZero (8 );
1790
- else
1791
- return nullptr ;
1792
-
1793
- // DeMorganize if this is 'or': P0 || P1 --> !P0 && !P1.
1794
- if (!IsAnd) {
1795
- Pred0 = ICmpInst::getInversePredicate (Pred0);
1796
- Pred1 = ICmpInst::getInversePredicate (Pred1);
1797
- }
1798
-
1799
- // Normalize to unsigned compare and unsigned min/max value.
1800
- // Example for 8-bit: -128 + 128 -> 0; 127 + 128 -> 255
1801
- if (ICmpInst::isSigned (Pred1)) {
1802
- Pred1 = ICmpInst::getUnsignedPredicate (Pred1);
1803
- MinMaxC += APInt::getSignedMinValue (MinMaxC.getBitWidth ());
1804
- }
1805
-
1806
- // (X != MAX) && (X < Y) --> X < Y
1807
- // (X == MAX) || (X >= Y) --> X >= Y
1808
- if (MinMaxC.isMaxValue ())
1809
- if (Pred0 == ICmpInst::ICMP_NE && Pred1 == ICmpInst::ICMP_ULT)
1810
- return Cmp1;
1811
-
1812
- // (X != MIN) && (X > Y) --> X > Y
1813
- // (X == MIN) || (X <= Y) --> X <= Y
1814
- if (MinMaxC.isMinValue ())
1815
- if (Pred0 == ICmpInst::ICMP_NE && Pred1 == ICmpInst::ICMP_UGT)
1816
- return Cmp1;
1817
-
1818
- return nullptr ;
1819
- }
1820
-
1821
1761
// / Try to simplify and/or of icmp with ctpop intrinsic.
1822
1762
static Value *simplifyAndOrOfICmpsWithCtpop (ICmpInst *Cmp0, ICmpInst *Cmp1,
1823
1763
bool IsAnd) {
@@ -1849,9 +1789,6 @@ static Value *simplifyAndOfICmps(ICmpInst *Op0, ICmpInst *Op1,
1849
1789
if (Value *X = simplifyAndOrOfICmpsWithConstants (Op0, Op1, true ))
1850
1790
return X;
1851
1791
1852
- if (Value *X = simplifyAndOrOfICmpsWithLimitConst (Op0, Op1, true ))
1853
- return X;
1854
-
1855
1792
if (Value *X = simplifyAndOrOfICmpsWithZero (Op0, Op1, true ))
1856
1793
return X;
1857
1794
@@ -1925,9 +1862,6 @@ static Value *simplifyOrOfICmps(ICmpInst *Op0, ICmpInst *Op1,
1925
1862
if (Value *X = simplifyAndOrOfICmpsWithConstants (Op0, Op1, false ))
1926
1863
return X;
1927
1864
1928
- if (Value *X = simplifyAndOrOfICmpsWithLimitConst (Op0, Op1, false ))
1929
- return X;
1930
-
1931
1865
if (Value *X = simplifyAndOrOfICmpsWithZero (Op0, Op1, false ))
1932
1866
return X;
1933
1867
0 commit comments