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;
|
Instruction *Inst;
|
||||||
unsigned Level;
|
unsigned Level;
|
||||||
std::tie(Inst, Level) = Stack.pop_back_val();
|
std::tie(Inst, Level) = Stack.pop_back_val();
|
||||||
auto *BI = dyn_cast<BinaryOperator>(Inst);
|
Value *B0, *B1;
|
||||||
auto *SI = dyn_cast<SelectInst>(Inst);
|
bool IsBinop = match(Inst, m_BinOp(m_Value(B0), m_Value(B1)));
|
||||||
if (BI || SI) {
|
bool IsSelect = match(Inst, m_Select(m_Value(), m_Value(), m_Value()));
|
||||||
|
if (IsBinop || IsSelect) {
|
||||||
HorizontalReduction HorRdx;
|
HorizontalReduction HorRdx;
|
||||||
if (HorRdx.matchAssociativeReduction(P, Inst)) {
|
if (HorRdx.matchAssociativeReduction(P, Inst)) {
|
||||||
if (HorRdx.tryToReduce(R, TTI)) {
|
if (HorRdx.tryToReduce(R, TTI)) {
|
||||||
|
@ -7476,10 +7477,10 @@ static bool tryToVectorizeHorReductionOrInstOperands(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (P && BI) {
|
if (P && IsBinop) {
|
||||||
Inst = dyn_cast<Instruction>(BI->getOperand(0));
|
Inst = dyn_cast<Instruction>(B0);
|
||||||
if (Inst == P)
|
if (Inst == P)
|
||||||
Inst = dyn_cast<Instruction>(BI->getOperand(1));
|
Inst = dyn_cast<Instruction>(B1);
|
||||||
if (!Inst) {
|
if (!Inst) {
|
||||||
// Set P to nullptr to avoid re-analysis of phi node in
|
// Set P to nullptr to avoid re-analysis of phi node in
|
||||||
// matchAssociativeReduction function unless this is the root node.
|
// matchAssociativeReduction function unless this is the root node.
|
||||||
|
|
Loading…
Reference in New Issue