From 6072842770222e3afca3585dc93104249c4e14c2 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Wed, 14 Nov 2018 16:03:36 +0000 Subject: [PATCH] [InstCombine] fix formatting for matchBSwap(); NFC We should have a similar function for matching rotate and/or funnel shift, so tidy up the related existing call. llvm-svn: 346871 --- .../Transforms/InstCombine/InstCombineAndOrXor.cpp | 11 +++++------ llvm/lib/Transforms/InstCombine/InstCombineInternal.h | 5 ++++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index 7e7a515bfc8d..173ae6367711 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -1762,10 +1762,9 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { return nullptr; } -/// Given an OR instruction, check to see if this is a bswap idiom. If so, -/// insert the new intrinsic and return it. -Instruction *InstCombiner::MatchBSwap(BinaryOperator &I) { - Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1); +Instruction *InstCombiner::matchBSwap(BinaryOperator &Or) { + assert(Or.getOpcode() == Instruction::Or && "bswap requires an 'or'"); + Value *Op0 = Or.getOperand(0), *Op1 = Or.getOperand(1); // Look through zero extends. if (Instruction *Ext = dyn_cast(Op0)) @@ -1801,7 +1800,7 @@ Instruction *InstCombiner::MatchBSwap(BinaryOperator &I) { return nullptr; SmallVector Insts; - if (!recognizeBSwapOrBitReverseIdiom(&I, true, false, Insts)) + if (!recognizeBSwapOrBitReverseIdiom(&Or, true, false, Insts)) return nullptr; Instruction *LastInst = Insts.pop_back_val(); LastInst->removeFromParent(); @@ -2168,7 +2167,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { if (Instruction *FoldedLogic = foldBinOpIntoSelectOrPhi(I)) return FoldedLogic; - if (Instruction *BSwap = MatchBSwap(I)) + if (Instruction *BSwap = matchBSwap(I)) return BSwap; Value *X, *Y; diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h index 6c9a3facf510..07e212254501 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h +++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h @@ -919,9 +919,12 @@ private: Value *insertRangeTest(Value *V, const APInt &Lo, const APInt &Hi, bool isSigned, bool Inside); Instruction *PromoteCastOfAllocation(BitCastInst &CI, AllocaInst &AI); - Instruction *MatchBSwap(BinaryOperator &I); bool mergeStoreIntoSuccessor(StoreInst &SI); + /// Given an 'or' instruction, check to see if it is part of a bswap idiom. + /// If so, return the equivalent bswap intrinsic. + Instruction *matchBSwap(BinaryOperator &Or); + Instruction *SimplifyAnyMemTransfer(AnyMemTransferInst *MI); Instruction *SimplifyAnyMemSet(AnyMemSetInst *MI);