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

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 14 07:24:53 PDT 2021


Author: Simon Pilgrim
Date: 2021-04-14T15:24:41+01:00
New Revision: b49c41afbaa212cc15343af68c3293ab929a2d34

URL: https://github.com/llvm/llvm-project/commit/b49c41afbaa212cc15343af68c3293ab929a2d34
DIFF: https://github.com/llvm/llvm-project/commit/b49c41afbaa212cc15343af68c3293ab929a2d34.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 8b6460b61d1b..8d022623e40d 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<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;


        


More information about the llvm-commits mailing list