[llvm] r307000 - [InstCombine] Remove support for BITWISE_OP(CONSTANT, BSWAP(x)) -> BSWAP(OP(BSWAP(CONSTANT), x)).

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 2 22:54:14 PDT 2017


Author: ctopper
Date: Sun Jul  2 22:54:13 2017
New Revision: 307000

URL: http://llvm.org/viewvc/llvm-project?rev=307000&view=rev
Log:
[InstCombine] Remove support for BITWISE_OP(CONSTANT, BSWAP(x)) -> BSWAP(OP(BSWAP(CONSTANT), x)).

Constants were already canonicalized to the right hand side before we got here.

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=307000&r1=306999&r2=307000&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Sun Jul  2 22:54:13 2017
@@ -85,17 +85,13 @@ Value *InstCombiner::SimplifyBSwap(Binar
   // 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(Binar
 
   /// 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());




More information about the llvm-commits mailing list