From cf6016e62d32d855efebcf92e83231d11d5b2f9e Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Fri, 30 Jun 2017 18:58:29 +0000 Subject: [PATCH] [InstCombine] Add m_BitReverse pattern match helper. NFCI. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306860 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/PatternMatch.h | 5 +++++ lib/Transforms/InstCombine/InstCombineCalls.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/llvm/IR/PatternMatch.h b/include/llvm/IR/PatternMatch.h index e5b4160c5c7..5b69e7855cc 100644 --- a/include/llvm/IR/PatternMatch.h +++ b/include/llvm/IR/PatternMatch.h @@ -1359,6 +1359,11 @@ m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2, const T3 &Op3) { } // Helper intrinsic matching specializations. +template +inline typename m_Intrinsic_Ty::Ty m_BitReverse(const Opnd0 &Op0) { + return m_Intrinsic(Op0); +} + template inline typename m_Intrinsic_Ty::Ty m_BSwap(const Opnd0 &Op0) { return m_Intrinsic(Op0); diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp index dbed7ad4eae..3770021de10 100644 --- a/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -1985,7 +1985,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { Value *X = nullptr; // bitreverse(bitreverse(x)) -> x - if (match(IIOperand, m_Intrinsic(m_Value(X)))) + if (match(IIOperand, m_BitReverse(m_Value(X)))) return replaceInstUsesWith(CI, X); break; } -- 2.50.1