[llvm] 92c3af7 - [VPlan] Use correct constructor when cloning VPWidenIntrinsicRecipe without underlying CallInst (#137493)

via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 27 19:08:48 PDT 2025


Author: Luke Lau
Date: 2025-04-28T10:08:45+08:00
New Revision: 92c3af7c3e3163254cdd84b135ce87de9886be94

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

LOG: [VPlan] Use correct constructor when cloning VPWidenIntrinsicRecipe without underlying CallInst (#137493)

I noticed this when working on a patch downstream, and I don't think
this is an issue upstream yet.

But if a VPWidenIntrinsicRecipe is created without an underlying
CallInst, e.g. in createEVLRecipe, it will crash if you try to clone it
because it assumes the CallInst always exists.

This fixes it by using the CallInst-less constructor in this case.

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/VPlan.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 2826a1af78220..147ca5b4475b5 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1351,8 +1351,11 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
   ~VPWidenIntrinsicRecipe() override = default;
 
   VPWidenIntrinsicRecipe *clone() override {
-    return new VPWidenIntrinsicRecipe(*cast<CallInst>(getUnderlyingValue()),
-                                      VectorIntrinsicID, {op_begin(), op_end()},
+    if (Value *CI = getUnderlyingValue())
+      return new VPWidenIntrinsicRecipe(*cast<CallInst>(CI), VectorIntrinsicID,
+                                        {op_begin(), op_end()}, ResultTy,
+                                        getDebugLoc());
+    return new VPWidenIntrinsicRecipe(VectorIntrinsicID, {op_begin(), op_end()},
                                       ResultTy, getDebugLoc());
   }
 


        


More information about the llvm-commits mailing list