From 2bb41851a10c1473bda9a87b4bfabf99527b3929 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Tue, 4 May 2021 13:46:45 +0100 Subject: [Utils] recognizeBSwapOrBitReverseIdiom - support matching from funnel shift roots (PR40058) We were missing bitreverse matches in cases where InstCombine had seen a byte-level rotation at the end of a bitreverse sequence (replacing or() with fshl()), hindering the exhaustive bitreverse matching in CodeGenPrepare later on. --- llvm/lib/Transforms/Utils/Local.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Transforms/Utils/Local.cpp') diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 3cb6705..ed75337 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -3101,7 +3101,9 @@ static bool bitTransformIsCorrectForBitReverse(unsigned From, unsigned To, bool llvm::recognizeBSwapOrBitReverseIdiom( Instruction *I, bool MatchBSwaps, bool MatchBitReversals, SmallVectorImpl &InsertedInsts) { - if (Operator::getOpcode(I) != Instruction::Or) + if (!match(I, m_Or(m_Value(), m_Value())) && + !match(I, m_FShl(m_Value(), m_Value(), m_Value())) && + !match(I, m_FShr(m_Value(), m_Value(), m_Value()))) return false; if (!MatchBSwaps && !MatchBitReversals) return false; -- cgit v1.1