llvm.org GIT mirror llvm / a72a0be
[InstSimplify] Use commutable matchers to simplify some code. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308125 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 3 years ago
1 changed file(s) with 7 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
17441744 return Constant::getNullValue(Op0->getType());
17451745
17461746 // (A | ?) & A = A
1747 Value *A = nullptr, *B = nullptr;
1748 if (match(Op0, m_Or(m_Value(A), m_Value(B))) &&
1749 (A == Op1 || B == Op1))
1747 if (match(Op0, m_c_Or(m_Specific(Op1), m_Value())))
17501748 return Op1;
17511749
17521750 // A & (A | ?) = A
1753 if (match(Op1, m_Or(m_Value(A), m_Value(B))) &&
1754 (A == Op0 || B == Op0))
1751 if (match(Op1, m_c_Or(m_Specific(Op0), m_Value())))
17551752 return Op0;
17561753
17571754 // A mask that only clears known zeros of a shifted value is a no-op.
18511848 return Constant::getAllOnesValue(Op0->getType());
18521849
18531850 // (A & ?) | A = A
1854 Value *A = nullptr, *B = nullptr;
1855 if (match(Op0, m_And(m_Value(A), m_Value(B))) &&
1856 (A == Op1 || B == Op1))
1851 if (match(Op0, m_c_And(m_Specific(Op1), m_Value())))
18571852 return Op1;
18581853
18591854 // A | (A & ?) = A
1860 if (match(Op1, m_And(m_Value(A), m_Value(B))) &&
1861 (A == Op0 || B == Op0))
1855 if (match(Op1, m_c_And(m_Specific(Op0), m_Value())))
18621856 return Op0;
18631857
18641858 // ~(A & ?) | A = -1
1865 if (match(Op0, m_Not(m_And(m_Value(A), m_Value(B)))) &&
1866 (A == Op1 || B == Op1))
1859 if (match(Op0, m_Not(m_c_And(m_Specific(Op1), m_Value()))))
18671860 return Constant::getAllOnesValue(Op1->getType());
18681861
18691862 // A | ~(A & ?) = -1
1870 if (match(Op1, m_Not(m_And(m_Value(A), m_Value(B)))) &&
1871 (A == Op0 || B == Op0))
1863 if (match(Op1, m_Not(m_c_And(m_Specific(Op1), m_Value()))))
18721864 return Constant::getAllOnesValue(Op0->getType());
18731865
1866 Value *A, *B;
18741867 // (A & ~B) | (A ^ B) -> (A ^ B)
18751868 // (~B & A) | (A ^ B) -> (A ^ B)
18761869 // (A & ~B) | (B ^ A) -> (B ^ A)