[llvm] [VPlan] Also expand pointer-typed SCEVAddExpr in VPSCEVExpander. (PR #206366)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 29 05:31:20 PDT 2026


================
@@ -846,9 +846,25 @@ VPValue *VPSCEVExpander::tryToExpand(const SCEV *S) {
     return Builder.createNaryOp(VPInstruction::VScale, {}, S->getType());
   case scAddExpr:
   case scMulExpr: {
-    if (S->getType()->isPointerTy())
-      return nullptr;
     auto *NAry = cast<SCEVNAryExpr>(S);
+    VPIRFlags::WrapFlagsTy WrapFlags(NAry->hasNoUnsignedWrap(),
+                                     NAry->hasNoSignedWrap());
+
+    // Expanded poiner SCEVAddExpr as a ptradd of the pointer base and the
+    // integer offset, matching SCEVExpander.
+    if (S->getType()->isPointerTy()) {
+      VPValue *Base = tryToExpand(SE.getPointerBase(S));
+      if (!Base)
+        return nullptr;
+      VPValue *Offset = tryToExpand(SE.removePointerBase(S));
----------------
artagnon wrote:

It's an NAry expression: can it not have multiple offsets?

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


More information about the llvm-commits mailing list