forked from OSchip/llvm-project
[SLP] use 'match' for binop/select; NFC
This might be a small improvement in readability, but the real motivation is to make it easier to adapt the code to deal with intrinsics like 'maxnum' and/or integer min/max. There is potentially help in doing that with D92086, but we might also just add specialized wrappers here to deal with the expected patterns.
This commit is contained in:
parent
240dd92432
commit
56fd29e93b
|
@ -7463,9 +7463,10 @@ static bool tryToVectorizeHorReductionOrInstOperands(
|
|||
Instruction *Inst;
|
||||
unsigned Level;
|
||||
std::tie(Inst, Level) = Stack.pop_back_val();
|
||||
auto *BI = dyn_cast<BinaryOperator>(Inst);
|
||||
auto *SI = dyn_cast<SelectInst>(Inst);
|
||||
if (BI || SI) {
|
||||
Value *B0, *B1;
|
||||
bool IsBinop = match(Inst, m_BinOp(m_Value(B0), m_Value(B1)));
|
||||
bool IsSelect = match(Inst, m_Select(m_Value(), m_Value(), m_Value()));
|
||||
if (IsBinop || IsSelect) {
|
||||
HorizontalReduction HorRdx;
|
||||
if (HorRdx.matchAssociativeReduction(P, Inst)) {
|
||||
if (HorRdx.tryToReduce(R, TTI)) {
|
||||
|
@ -7476,10 +7477,10 @@ static bool tryToVectorizeHorReductionOrInstOperands(
|
|||
continue;
|
||||
}
|
||||
}
|
||||
if (P && BI) {
|
||||
Inst = dyn_cast<Instruction>(BI->getOperand(0));
|
||||
if (P && IsBinop) {
|
||||
Inst = dyn_cast<Instruction>(B0);
|
||||
if (Inst == P)
|
||||
Inst = dyn_cast<Instruction>(BI->getOperand(1));
|
||||
Inst = dyn_cast<Instruction>(B1);
|
||||
if (!Inst) {
|
||||
// Set P to nullptr to avoid re-analysis of phi node in
|
||||
// matchAssociativeReduction function unless this is the root node.
|
||||
|
|
Loading…
Reference in New Issue