[llvm] 6e26ddb - [NFC][PatternMatch] Add helper for m_Intrinsic<Intrinsic::experimental_vector_reverse>.
Paul Walker via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 5 08:37:35 PST 2022
Author: Paul Walker
Date: 2022-12-05T16:36:08Z
New Revision: 6e26ddbc7e91b6e49f77ad93a5e972d424c701f3
URL: https://github.com/llvm/llvm-project/commit/6e26ddbc7e91b6e49f77ad93a5e972d424c701f3
DIFF: https://github.com/llvm/llvm-project/commit/6e26ddbc7e91b6e49f77ad93a5e972d424c701f3.diff
LOG: [NFC][PatternMatch] Add helper for m_Intrinsic<Intrinsic::experimental_vector_reverse>.
Added:
Modified:
llvm/include/llvm/IR/PatternMatch.h
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/PatternMatch.h b/llvm/include/llvm/IR/PatternMatch.h
index 2901c6456c99..6d80c37cc34f 100644
--- a/llvm/include/llvm/IR/PatternMatch.h
+++ b/llvm/include/llvm/IR/PatternMatch.h
@@ -2206,6 +2206,11 @@ inline typename m_Intrinsic_Ty<Opnd0>::Ty m_Sqrt(const Opnd0 &Op0) {
return m_Intrinsic<Intrinsic::sqrt>(Op0);
}
+template <typename Opnd0>
+inline typename m_Intrinsic_Ty<Opnd0>::Ty m_VecReverse(const Opnd0 &Op0) {
+ return m_Intrinsic<Intrinsic::experimental_vector_reverse>(Op0);
+}
+
//===----------------------------------------------------------------------===//
// Matchers for two-operands operators with the operators in either order
//
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 43d7368b3971..5410a901ac6b 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -5900,8 +5900,7 @@ static Value *simplifyUnaryIntrinsic(Function *F, Value *Op0,
break;
case Intrinsic::experimental_vector_reverse:
// experimental.vector.reverse(experimental.vector.reverse(x)) -> x
- if (match(Op0,
- m_Intrinsic<Intrinsic::experimental_vector_reverse>(m_Value(X))))
+ if (match(Op0, m_VecReverse(m_Value(X))))
return X;
// experimental.vector.reverse(splat(X)) -> splat(X)
if (isSplatValue(Op0))
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 2d8a514698ac..1c3fd8666af4 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -2588,11 +2588,9 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
Value *Vec = II->getArgOperand(0);
if (match(Vec, m_OneUse(m_BinOp(m_Value(BO0), m_Value(BO1))))) {
auto *OldBinOp = cast<BinaryOperator>(Vec);
- if (match(BO0, m_Intrinsic<Intrinsic::experimental_vector_reverse>(
- m_Value(X)))) {
+ if (match(BO0, m_VecReverse(m_Value(X)))) {
// rev(binop rev(X), rev(Y)) --> binop X, Y
- if (match(BO1, m_Intrinsic<Intrinsic::experimental_vector_reverse>(
- m_Value(Y))))
+ if (match(BO1, m_VecReverse(m_Value(Y))))
return replaceInstUsesWith(CI,
BinaryOperator::CreateWithCopiedFlags(
OldBinOp->getOpcode(), X, Y, OldBinOp,
@@ -2605,17 +2603,13 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
OldBinOp, OldBinOp->getName(), II));
}
// rev(binop BO0Splat, rev(Y)) --> binop BO0Splat, Y
- if (match(BO1, m_Intrinsic<Intrinsic::experimental_vector_reverse>(
- m_Value(Y))) &&
- isSplatValue(BO0))
+ if (match(BO1, m_VecReverse(m_Value(Y))) && isSplatValue(BO0))
return replaceInstUsesWith(CI, BinaryOperator::CreateWithCopiedFlags(
OldBinOp->getOpcode(), BO0, Y,
OldBinOp, OldBinOp->getName(), II));
}
// rev(unop rev(X)) --> unop X
- if (match(Vec, m_OneUse(m_UnOp(
- m_Intrinsic<Intrinsic::experimental_vector_reverse>(
- m_Value(X)))))) {
+ if (match(Vec, m_OneUse(m_UnOp(m_VecReverse(m_Value(X)))))) {
auto *OldUnOp = cast<UnaryOperator>(Vec);
auto *NewUnOp = UnaryOperator::CreateWithCopiedFlags(
OldUnOp->getOpcode(), X, OldUnOp, OldUnOp->getName(), II);
More information about the llvm-commits
mailing list