[llvm] 1cab3bf - [InstCombine] matchBSwapOrBitReverse - expose bswap/bitreverse matching flags.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 23 04:36:03 PDT 2020
Author: Simon Pilgrim
Date: 2020-10-23T12:35:28+01:00
New Revision: 1cab3bf0046117759cc7891eec66affbbeb5965c
URL: https://github.com/llvm/llvm-project/commit/1cab3bf0046117759cc7891eec66affbbeb5965c
DIFF: https://github.com/llvm/llvm-project/commit/1cab3bf0046117759cc7891eec66affbbeb5965c.diff
LOG: [InstCombine] matchBSwapOrBitReverse - expose bswap/bitreverse matching flags.
matchBSwapOrBitReverse was hardcoded to just match bswaps - we're going to need to expose the ability to match bitreverse as well, so make this part of the function call.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 13670ff7ee50..1e291fbe3f73 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -1985,7 +1985,9 @@ Instruction *InstCombinerImpl::visitAnd(BinaryOperator &I) {
return nullptr;
}
-Instruction *InstCombinerImpl::matchBSwapOrBitReverse(BinaryOperator &Or) {
+Instruction *InstCombinerImpl::matchBSwapOrBitReverse(BinaryOperator &Or,
+ bool MatchBSwaps,
+ bool MatchBitReversals) {
assert(Or.getOpcode() == Instruction::Or && "bswap requires an 'or'");
Value *Op0 = Or.getOperand(0), *Op1 = Or.getOperand(1);
@@ -2011,8 +2013,9 @@ Instruction *InstCombinerImpl::matchBSwapOrBitReverse(BinaryOperator &Or) {
if (!OrWithOrs && !OrWithShifts && !OrWithAnds)
return nullptr;
- SmallVector<Instruction*, 4> Insts;
- if (!recognizeBSwapOrBitReverseIdiom(&Or, true, false, Insts))
+ SmallVector<Instruction *, 4> Insts;
+ if (!recognizeBSwapOrBitReverseIdiom(&Or, MatchBSwaps, MatchBitReversals,
+ Insts))
return nullptr;
Instruction *LastInst = Insts.pop_back_val();
LastInst->removeFromParent();
@@ -2563,7 +2566,8 @@ Instruction *InstCombinerImpl::visitOr(BinaryOperator &I) {
if (Instruction *FoldedLogic = foldBinOpIntoSelectOrPhi(I))
return FoldedLogic;
- if (Instruction *BSwap = matchBSwapOrBitReverse(I))
+ if (Instruction *BSwap = matchBSwapOrBitReverse(I, /*MatchBSwaps*/ true,
+ /*MatchBitReversals*/ false))
return BSwap;
if (Instruction *Funnel = matchFunnelShift(I, *this))
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
index 69811b419389..6489327e9b84 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -724,7 +724,8 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
/// Given an 'or' instruction, check to see if it is part of a
/// bswap/bitreverse idiom. If so, return the equivalent bswap/bitreverse
/// intrinsic.
- Instruction *matchBSwapOrBitReverse(BinaryOperator &Or);
+ Instruction *matchBSwapOrBitReverse(BinaryOperator &Or, bool MatchBSwaps,
+ bool MatchBitReversals);
Instruction *SimplifyAnyMemTransfer(AnyMemTransferInst *MI);
Instruction *SimplifyAnyMemSet(AnyMemSetInst *MI);
More information about the llvm-commits
mailing list