[llvm] [VPlan] Fix `pseudoprobe` being treated a vector intrinsic (PR #185347)

Henry Jiang via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 8 22:31:23 PDT 2026


https://github.com/mustartt created https://github.com/llvm/llvm-project/pull/185347

Fix assertion when `llvm.pseudoprobe` in VPlan's native path is being treated as a `WIDEN-INTRINSIC`. 

Reproducer: https://godbolt.org/z/GsPYobvYs


>From a4cc4e47ced6ee837f984b8058bc1c836c2cc976 Mon Sep 17 00:00:00 2001
From: Henry Jiang <henry_jiang2 at apple.com>
Date: Sun, 8 Mar 2026 22:25:27 -0700
Subject: [PATCH] Fix psuedoprobe being treated a vector intrinsic

---
 .../Transforms/Vectorize/VPlanTransforms.cpp  |  8 ++++-
 .../LoopVectorize/pseudo-probe-crash.ll       | 36 +++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/Transforms/LoopVectorize/pseudo-probe-crash.ll

diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index dc0edb178efbb..80f0b5d6a3b8b 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -92,7 +92,13 @@ bool VPlanTransforms::tryToConvertVPInstructionsToVPRecipes(
                                            Ingredient.getDebugLoc());
         } else if (CallInst *CI = dyn_cast<CallInst>(Inst)) {
           Intrinsic::ID VectorID = getVectorIntrinsicIDForCall(CI, &TLI);
-          if (VectorID == Intrinsic::not_intrinsic)
+          if (VectorID == Intrinsic::not_intrinsic ||
+              VectorID == Intrinsic::assume ||
+              VectorID == Intrinsic::lifetime_end ||
+              VectorID == Intrinsic::lifetime_start ||
+              VectorID == Intrinsic::sideeffect ||
+              VectorID == Intrinsic::pseudoprobe ||
+              VectorID == Intrinsic::experimental_noalias_scope_decl)
             return false;
           NewRecipe = new VPWidenIntrinsicRecipe(
               *CI, getVectorIntrinsicIDForCall(CI, &TLI),
diff --git a/llvm/test/Transforms/LoopVectorize/pseudo-probe-crash.ll b/llvm/test/Transforms/LoopVectorize/pseudo-probe-crash.ll
new file mode 100644
index 0000000000000..f4298d3c5d770
--- /dev/null
+++ b/llvm/test/Transforms/LoopVectorize/pseudo-probe-crash.ll
@@ -0,0 +1,36 @@
+; REQUIRES: asserts
+; RUN: opt -S -passes=loop-vectorize -enable-vplan-native-path -force-vector-width=2 -debug-only=loop-vectorize -mtriple=aarch64 < %s 2>&1 | FileCheck %s
+
+; Verify that llvm.pseudoprobe present in the outer loop does not crash the 
+; VPlan native path and is not treated as a widenable intrinsic.
+; CHECK-NOT: WIDEN-INTRINSIC
+
+define i32 @main() {
+entry:
+  br label %outer.header
+
+outer.header:
+  %j = phi i64 [ 0, %entry ], [ %j.next, %outer.latch ]
+  br label %inner
+
+outer.latch:
+  %j.next = add i64 %j, 1
+  call void @llvm.pseudoprobe(i64 0, i64 0, i32 0, i64 0)
+  %outer.cond = icmp eq i64 %j, 100
+  br i1 %outer.cond, label %exit, label %outer.header, !llvm.loop !0
+
+inner:
+  %k = phi i64 [ 0, %outer.header ], [ %k.next, %inner ]
+  %k.next = add i64 %k, 1
+  %inner.cond = icmp eq i64 %k.next, 0
+  br i1 %inner.cond, label %outer.latch, label %inner
+
+exit:
+  ret i32 0
+}
+
+declare void @llvm.pseudoprobe(i64, i64, i32, i64)
+
+!0 = distinct !{!0, !1, !2}
+!1 = !{!"llvm.loop.mustprogress"}
+!2 = !{!"llvm.loop.vectorize.enable", i1 true}



More information about the llvm-commits mailing list