[SLP] createOp - fix null dereference warning. NFCI.

Only attempt to propagateIRFlags if we have both SelectInst - afaict we shouldn't have matched a min/max reduction without both SelectInst, but static analyzer doesn't know that.
This commit is contained in:
Simon Pilgrim 2021-04-14 11:33:41 +01:00
parent cca40aa8d8
commit b49c41afba
1 changed files with 3 additions and 2 deletions

View File

@ -6696,15 +6696,16 @@ class HorizontalReduction {
propagateIRFlags(Op, ReductionOps[0]);
return Op;
}
/// Creates reduction operation with the current opcode with the IR flags
/// from \p I.
static Value *createOp(IRBuilder<> &Builder, RecurKind RdxKind, Value *LHS,
Value *RHS, const Twine &Name, Instruction *I) {
auto *SelI = dyn_cast<SelectInst>(I);
Value *Op = createOp(Builder, RdxKind, LHS, RHS, Name, SelI != nullptr);
if (RecurrenceDescriptor::isIntMinMaxRecurrenceKind(RdxKind)) {
if (SelI && RecurrenceDescriptor::isIntMinMaxRecurrenceKind(RdxKind)) {
if (auto *Sel = dyn_cast<SelectInst>(Op))
propagateIRFlags(Sel->getCondition(), SelI->getCondition());
propagateIRFlags(Sel->getCondition(), SelI->getCondition());
}
propagateIRFlags(Op, I);
return Op;