Recognize 16-bit bswaps by relaxing overconstrained pattern.
authorChris Lattner <sabre@nondot.org>
Mon, 10 Jul 2006 20:25:24 +0000 (20:25 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 10 Jul 2006 20:25:24 +0000 (20:25 +0000)
This implements Transforms/InstCombine/bswap.ll:test[34].

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29087 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index ebefdb31a44a7c6c22e520838df597a6b485aeaf..5273e958da27c31d298195edd2735905285df752 100644 (file)
@@ -2976,9 +2976,12 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
     if (A == Op0 || B == Op0)    // A | (A & ?)  --> A
       return ReplaceInstUsesWith(I, Op0);
 
-  // (A | B) | C  and  A | (B | C)  -> bswap if possible.
+  // (A | B) | C  and  A | (B | C)                  -> bswap if possible.
+  // (A >> B) | (C << D)  and  (A << B) | (B >> C)  -> bswap if possible.
   if (match(Op0, m_Or(m_Value(), m_Value())) ||
-      match(Op1, m_Or(m_Value(), m_Value()))) {
+      match(Op1, m_Or(m_Value(), m_Value())) ||
+      (match(Op0, m_Shift(m_Value(), m_Value())) &&
+       match(Op1, m_Shift(m_Value(), m_Value())))) {
     if (Instruction *BSwap = MatchBSwap(I))
       return BSwap;
   }