[llvm] [VPlan] Introduce VPInstructionWithType, use instead of VPScalarCast (PR #135037)

via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 9 08:11:42 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h llvm/lib/Transforms/Vectorize/LoopVectorize.cpp llvm/lib/Transforms/Vectorize/VPlan.cpp llvm/lib/Transforms/Vectorize/VPlan.h llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp llvm/lib/Transforms/Vectorize/VPlanUtils.cpp llvm/lib/Transforms/Vectorize/VPlanUtils.h llvm/lib/Transforms/Vectorize/VPlanValue.h llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 1ea4ffc78..edf038534 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -503,11 +503,10 @@ public:
                     DebugLoc DL = {})
       : VPRecipeBase(SC, Operands, DL), VPValue(this, UV) {}
 
-  VPSingleDefRecipe(const unsigned char SC, ArrayRef<VPValue *> Operands, Type *ResultTy,
-                    DebugLoc DL = {})
+  VPSingleDefRecipe(const unsigned char SC, ArrayRef<VPValue *> Operands,
+                    Type *ResultTy, DebugLoc DL = {})
       : VPRecipeBase(SC, Operands, DL), VPValue(ResultTy, this) {}
 
-
   static inline bool classof(const VPRecipeBase *R) {
     switch (R->getVPDefID()) {
     case VPRecipeBase::VPDerivedIVSC:
@@ -700,7 +699,8 @@ public:
       : VPSingleDefRecipe(SC, Operands, DL), OpType(OperationType::DisjointOp),
         DisjointFlags(DisjointFlags) {}
 
-  VPRecipeWithIRFlags(const unsigned char SC, ArrayRef<VPValue *> Operands, Type *ResultTy, DebugLoc DL = {})
+  VPRecipeWithIRFlags(const unsigned char SC, ArrayRef<VPValue *> Operands,
+                      Type *ResultTy, DebugLoc DL = {})
       : VPSingleDefRecipe(SC, Operands, ResultTy, DL) {
     OpType = OperationType::Other;
     AllFlags = 0;
@@ -934,8 +934,8 @@ public:
       : VPRecipeWithIRFlags(VPDef::VPInstructionSC, Operands, DL),
         Opcode(Opcode), Name(Name.str()) {}
 
-  VPInstruction(unsigned Opcode, ArrayRef<VPValue *> Operands, Type *ResultTy, DebugLoc DL,
-                const Twine &Name = "")
+  VPInstruction(unsigned Opcode, ArrayRef<VPValue *> Operands, Type *ResultTy,
+                DebugLoc DL, const Twine &Name = "")
       : VPRecipeWithIRFlags(VPDef::VPInstructionSC, Operands, ResultTy, DL),
         Opcode(Opcode), Name(Name.str()) {}
 
diff --git a/llvm/lib/Transforms/Vectorize/VPlanValue.h b/llvm/lib/Transforms/Vectorize/VPlanValue.h
index 3d9ac67de..329fbe70e 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanValue.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanValue.h
@@ -62,10 +62,10 @@ class VPValue {
 
 protected:
   // Hold the underlying Value, if any, attached to this VPValue.
-union {
-  Value *UnderlyingVal;
-  Type *UnderlyingType;
-};
+  union {
+    Value *UnderlyingVal;
+    Type *UnderlyingType;
+  };
 
   /// Pointer to the VPDef that defines this VPValue. If it is nullptr, the
   /// VPValue is not defined by any recipe modeled in VPlan.
@@ -91,12 +91,14 @@ union {
 
 public:
   /// Return the underlying Value attached to this VPValue.
-  Value *getUnderlyingValue() const { return isTyped() ? nullptr : UnderlyingVal; }
+  Value *getUnderlyingValue() const {
+    return isTyped() ? nullptr : UnderlyingVal;
+  }
 
   /// An enumeration for keeping track of the concrete subclass of VPValue that
   /// are actually instantiated.
   enum {
-    VPIRValueSC, /// A VPValue with an optional underlying IR value.
+    VPIRValueSC,   /// A VPValue with an optional underlying IR value.
     VPTypedValueSC /// A VPValue with an underlying type.
   };
 
@@ -111,11 +113,12 @@ public:
   unsigned getVPValueID() const { return SubclassID; }
 
   Type *getScalarType() const {
-    assert(SubclassID == VPTypedValueSC && "Can only be called on VPValues with an underlying type");
+    assert(SubclassID == VPTypedValueSC &&
+           "Can only be called on VPValues with an underlying type");
     return UnderlyingType;
   }
 
-bool isTyped() const { return SubclassID == VPTypedValueSC; }
+  bool isTyped() const { return SubclassID == VPTypedValueSC; }
 
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
   void printAsOperand(raw_ostream &OS, VPSlotTracker &Tracker) const;

``````````

</details>


https://github.com/llvm/llvm-project/pull/135037


More information about the llvm-commits mailing list