[llvm] [RFC][IR] Support vector splats in `ConstantPointerNull` (PR #195486)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon May 4 03:31:04 PDT 2026


================
@@ -696,26 +696,29 @@ class ConstantVector final : public ConstantAggregate {
 };
 
 //===----------------------------------------------------------------------===//
-/// A constant pointer value that points to null
+/// A constant pointer value that points to null. This represents both scalar
+/// pointer nulls and vector splats of pointer nulls.
 ///
 class ConstantPointerNull final : public ConstantData {
   friend class Constant;
 
-  explicit ConstantPointerNull(PointerType *T)
+  explicit ConstantPointerNull(Type *T)
       : ConstantData(T, Value::ConstantPointerNullVal) {}
 
   void destroyConstantImpl();
 
 public:
   ConstantPointerNull(const ConstantPointerNull &) = delete;
 
-  /// Static factory methods - Return objects of the specified value
+  /// Static factory methods - Return objects of the specified value. If Ty is a
+  /// vector type, return a ConstantPointerNull with a splat of null pointer
+  /// values. Otherwise return a ConstantPointerNull for the given pointer type.
   LLVM_ABI static ConstantPointerNull *get(PointerType *T);
+  LLVM_ABI static ConstantPointerNull *get(Type *T);
 
-  /// Specialize the getType() method to always return an PointerType,
-  /// which reduces the amount of casting needed in parts of the compiler.
-  inline PointerType *getType() const {
-    return cast<PointerType>(Value::getType());
+  /// Return the scalar pointer type for this null value.
+  inline PointerType *getPointerType() const {
----------------
arsenm wrote:

The inline is redundant with being defined in class 

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


More information about the llvm-commits mailing list