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

Chris Lattner clattner at apple.com
Sun Nov 30 21:19:45 PST 2008


On Nov 30, 2008, at 5:07 PM, Bill Wendling wrote:
> Author: void
> Date: Sun Nov 30 19:07:11 2008
> New Revision: 60312
>
> URL: http://llvm.org/viewvc/llvm-project?rev=60312&view=rev
> Log:
> Implement ((A|B)&1)|(B&-2) -> (A&1) | B transformation. This also  
> takes care of
> permutations of this pattern.

Hi Bill,

> @@ -4649,6 +4649,73 @@
>       }
>   }
>
> +  // ((A|B)&1)|(B&-2) -> (A&1) | B
> +  if (match(Op0, m_And(m_Or(m_Value(A), m_Value(B)), m_Value(C))) ||
> +      match(Op0, m_And(m_Value(C), m_Or(m_Value(A), m_Value(B))))) {

This much code should be split out into a helper function.  Please do  
something like:

> +  if (match(Op0, m_And(m_Or(m_Value(A), m_Value(B)), m_Value(C))) ||
> +      match(Op0, m_And(m_Value(C), m_Or(m_Value(A), m_Value(B)))))
       HandleBlah(....)

> +  // (B&-2)|((A|B)&1) -> (A&1) | B
> +  if (match(Op1, m_And(m_Or(m_Value(A), m_Value(B)), m_Value(C))) ||
> +      match(Op1, m_And(m_Value(C), m_Or(m_Value(A), m_Value(B))))) {

       HandleBlah(....)

so that the code is shared, not copied and pasted.

Also, I don't think that this pattern has anything to do with the  
magic constants 1 and -2.  Please generalize it.

-Chris




More information about the llvm-commits mailing list