[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:05 PDT 2026


================
@@ -492,6 +511,14 @@ Constant *Constant::getAggregateElement(unsigned Elt) const {
                ? ConstantFP::get(getContext(), CFP->getValue())
                : nullptr;
 
+  if (const auto *CPN = dyn_cast<ConstantPointerNull>(this)) {
+    return Elt < cast<VectorType>(getType())
+                       ->getElementCount()
+                       .getKnownMinValue()
+               ? ConstantPointerNull::get(CPN->getPointerType())
+               : nullptr;
----------------
arsenm wrote:

```suggestion
    auto *VT = cast<VectorType>(getType());
    return Elt < VT->getElementCount().getKnownMinValue()
               ? ConstantPointerNull::get(VT->getElementType())
               : nullptr;
```

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


More information about the llvm-commits mailing list