[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

Chris Lattner sabre at nondot.org
Tue Nov 28 21:02:30 PST 2006



Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.552 -> 1.553
---
Log message:

Implement Regression/Transforms/InstCombine/bswap-fold.ll,
folding   seteq (bswap(x)), c -> seteq(x,bswap(c))



---
Diffs of the changes:  (+24 -1)

 InstructionCombining.cpp |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.552 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.553
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.552	Tue Nov 28 19:11:01 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Tue Nov 28 23:02:16 2006
@@ -4664,7 +4664,7 @@
         break;
       }
 
-    // Simplify seteq and setne instructions...
+    // Simplify seteq and setne instructions with integer constant RHS.
     if (I.isEquality()) {
       bool isSetNE = I.getOpcode() == Instruction::SetNE;
 
@@ -4780,6 +4780,29 @@
           }
         default: break;
         }
+      } else if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(Op0)) {
+        // Handle set{eq|ne} <intrinsic>, intcst.
+        switch (II->getIntrinsicID()) {
+        default: break;
+        case Intrinsic::bswap_i16:   // seteq (bswap(x)), c -> seteq(x,bswap(c))
+          WorkList.push_back(II);  // Dead?
+          I.setOperand(0, II->getOperand(1));
+          I.setOperand(1, ConstantInt::get(Type::UShortTy,
+                                           ByteSwap_16(CI->getZExtValue())));
+          return &I;
+        case Intrinsic::bswap_i32:   // seteq (bswap(x)), c -> seteq(x,bswap(c))
+          WorkList.push_back(II);  // Dead?
+          I.setOperand(0, II->getOperand(1));
+          I.setOperand(1, ConstantInt::get(Type::UIntTy,
+                                           ByteSwap_32(CI->getZExtValue())));
+          return &I;
+        case Intrinsic::bswap_i64:   // seteq (bswap(x)), c -> seteq(x,bswap(c))
+          WorkList.push_back(II);  // Dead?
+          I.setOperand(0, II->getOperand(1));
+          I.setOperand(1, ConstantInt::get(Type::ULongTy,
+                                           ByteSwap_64(CI->getZExtValue())));
+          return &I;
+        }
       }
     } else {  // Not a SetEQ/SetNE
       // If the LHS is a cast from an integral value of the same size,






More information about the llvm-commits mailing list