LLVM 24.0.0git
SLPReductionUtils.cpp
Go to the documentation of this file.
1//===- SLPReductionUtils.cpp - SLP reduction match helpers ----------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "SLPReductionUtils.h"
10
12#include "llvm/IR/Intrinsics.h"
14
15using namespace llvm;
16using namespace llvm::PatternMatch;
17
18namespace llvm::slpvectorizer {
19
20static bool matchRdxBop(Instruction *I, Value *&V0, Value *&V1) {
21 if (match(I, m_BinOp(m_Value(V0), m_Value(V1))))
22 return true;
23 if (match(I, m_FMaxNum(m_Value(V0), m_Value(V1))))
24 return true;
25 if (match(I, m_FMinNum(m_Value(V0), m_Value(V1))))
26 return true;
27 if (match(I, m_FMaximum(m_Value(V0), m_Value(V1))))
28 return true;
29 if (match(I, m_FMinimum(m_Value(V0), m_Value(V1))))
30 return true;
32 return true;
34 return true;
36 return true;
38 return true;
39 return false;
40}
41
43 Value *Op0 = nullptr;
44 Value *Op1 = nullptr;
45 if (!matchRdxBop(I, Op0, Op1))
46 return nullptr;
47 return dyn_cast<Instruction>(Op0 == Phi ? Op1 : Op0);
48}
49
51 bool IsSelect = match(I, m_Select(m_Value(), m_Value(), m_Value()));
52 Value *B0 = nullptr, *B1 = nullptr;
53 bool IsBinop = matchRdxBop(I, B0, B1);
54 return IsBinop || IsSelect;
55}
56
57} // namespace llvm::slpvectorizer
#define I(x, y, z)
Definition MD5.cpp:57
static bool IsSelect(unsigned Opcode, bool CheckOnlyCC=false)
Check if the opcode is a SELECT or SELECT_CC variant.
LLVM Value Representation.
Definition Value.h:75
bool match(Val *V, const Pattern &P)
ThreeOps_match< Cond, LHS, RHS, Instruction::Select > m_Select(const Cond &C, const LHS &L, const RHS &R)
Matches SelectInst.
auto m_BinOp()
Match an arbitrary binary operation and ignore it.
auto m_FMinimum(const Opnd0 &Op0, const Opnd1 &Op1)
auto m_Value()
Match an arbitrary value and ignore it.
auto m_FMaximum(const Opnd0 &Op0, const Opnd1 &Op1)
auto m_Intrinsic(const Ts &...Ops)
Match intrinsic calls like this: m_Intrinsic<Intrinsic::fabs>(m_Value(X))
auto m_FMinNum(const Opnd0 &Op0, const Opnd1 &Op1)
auto m_FMaxNum(const Opnd0 &Op0, const Opnd1 &Op1)
A private "module" namespace for types and utilities used by this pass.
static bool matchRdxBop(Instruction *I, Value *&V0, Value *&V1)
Instruction * getNonPhiOperand(Instruction *I, PHINode *Phi)
bool isReductionCandidate(Instruction *I)
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643