]> granicus.if.org Git - llvm/commitdiff
[InstCombine] Remove support for BITWISE_OP(CONSTANT, BSWAP(x)) -> BSWAP(OP(BSWAP...
authorCraig Topper <craig.topper@intel.com>
Mon, 3 Jul 2017 05:54:13 +0000 (05:54 +0000)
committerCraig Topper <craig.topper@intel.com>
Mon, 3 Jul 2017 05:54:13 +0000 (05:54 +0000)
Constants were already canonicalized to the right hand side before we got here.

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

lib/Transforms/InstCombine/InstCombineAndOrXor.cpp

index 9a6199fdafba7479eb076aef5fbc24a3010a5022..5a73eb5cc2f39c9a533c12dc12f4bfe59a6d20e6 100644 (file)
@@ -85,17 +85,13 @@ Value *InstCombiner::SimplifyBSwap(BinaryOperator &I) {
   // TODO handle constant on one side with vectors.
   Value *OldLHS = I.getOperand(0);
   Value *OldRHS = I.getOperand(1);
-  ConstantInt *ConstLHS = dyn_cast<ConstantInt>(OldLHS);
   ConstantInt *ConstRHS = dyn_cast<ConstantInt>(OldRHS);
   IntrinsicInst *IntrLHS = dyn_cast<IntrinsicInst>(OldLHS);
   IntrinsicInst *IntrRHS = dyn_cast<IntrinsicInst>(OldRHS);
   bool IsBswapLHS = (IntrLHS && IntrLHS->getIntrinsicID() == Intrinsic::bswap);
   bool IsBswapRHS = (IntrRHS && IntrRHS->getIntrinsicID() == Intrinsic::bswap);
 
-  if (!IsBswapLHS && !IsBswapRHS)
-    return nullptr;
-
-  if (!IsBswapLHS && !ConstLHS)
+  if (!IsBswapLHS)
     return nullptr;
 
   if (!IsBswapRHS && !ConstRHS)
@@ -103,8 +99,7 @@ Value *InstCombiner::SimplifyBSwap(BinaryOperator &I) {
 
   /// OP( BSWAP(x), BSWAP(y) ) -> BSWAP( OP(x, y) )
   /// OP( BSWAP(x), CONSTANT ) -> BSWAP( OP(x, BSWAP(CONSTANT) ) )
-  Value *NewLHS = IsBswapLHS ? IntrLHS->getOperand(0) :
-                  Builder->getInt(ConstLHS->getValue().byteSwap());
+  Value *NewLHS = IntrLHS->getOperand(0);
 
   Value *NewRHS = IsBswapRHS ? IntrRHS->getOperand(0) :
                   Builder->getInt(ConstRHS->getValue().byteSwap());