[llvm-commits] [llvm] r60291 - in /llvm/trunk: lib/Target/README.txt lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/or-to-xor.ll

Chris Lattner clattner at apple.com
Sun Nov 30 21:17:50 PST 2008


On Nov 30, 2008, at 5:52 AM, Bill Wendling wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=60291&view=rev
> Log:
> Add instruction combining for ((A&~B)|(~A&B)) -> A^B and all  
> permutations.

Thanks Bill!

> +    V1 = V2 = 0;
> +
> +    // ((A&~B)|(~A&B)) -> A^B
> +    if ((match(C, m_Not(m_Value(V1))) &&
> +         match(B, m_Not(m_Value(V2)))))
> +      if (V1 == D && V2 == A)
> +        return BinaryOperator::CreateXor(V1, V2);
> +    // ((~B&A)|(~A&B)) -> A^B
> +    if ((match(A, m_Not(m_Value(V1))) &&
> +         match(B, m_Not(m_Value(V2)))))
> +      if (V1 == D && V2 == C)
> +        return BinaryOperator::CreateXor(V1, V2);
> +    // ((A&~B)|(B&~A)) -> A^B
> +    if ((match(C, m_Not(m_Value(V1))) &&
> +         match(D, m_Not(m_Value(V2)))))
> +      if (V1 == B && V2 == A)
> +        return BinaryOperator::CreateXor(V1, V2);
> +    // ((~B&A)|(B&~A)) -> A^B
> +    if ((match(A, m_Not(m_Value(V1))) &&
> +         match(D, m_Not(m_Value(V2)))))
> +      if (V1 == B && V2 == C)
> +        return BinaryOperator::CreateXor(V1, V2);
>   }

Please use m_Specific instead of two stage matching where possible.

-Chris



More information about the llvm-commits mailing list