From b49c41afbaa212cc15343af68c3293ab929a2d34 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Wed, 14 Apr 2021 11:33:41 +0100 Subject: [PATCH] [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. --- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 8b6460b..8d02262 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -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(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(Op)) - propagateIRFlags(Sel->getCondition(), SelI->getCondition()); + propagateIRFlags(Sel->getCondition(), SelI->getCondition()); } propagateIRFlags(Op, I); return Op; -- 2.7.4