[llvm] [SLP][AMDGPU] Vectorize operands of non-trivially-vectorizable intrinsic calls (PR #189784)

Syadus Sefat via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 2 23:30:46 PDT 2026


================
@@ -243,6 +243,39 @@ static const int MinScheduleRegionSize = 16;
 /// Maximum allowed number of operands in the PHI nodes.
 static const unsigned MaxPHINumOperands = 128;
 
+/// For instructions that are not trivially vectorizable, try to vectorize their
+/// operands.
+/// FIXME: Extend for all non-vectorized functions.
+static Value *getNonTriviallyVectorizableIntrinsicCallOperand(Value *V) {
+  auto *CI = dyn_cast<CallInst>(V);
+  if (!CI)
+    return nullptr;
+  Intrinsic::ID ID = CI->getIntrinsicID();
+  // Only consider intrinsic calls.
+  // FIXME: We may want to relax this condition in future.
+  if (ID == Intrinsic::not_intrinsic)
+    return nullptr;
+  // Skip trivially vectorizable intrinsics.
+  if (isTriviallyVectorizable(ID))
+    return nullptr;
+  // Only consider unary intrinsic calls.
+  if (CI->arg_size() != 1)
+    return nullptr;
+  // Check if it is speculatable, no memory access and will return
+  if (!CI->hasFnAttr(Attribute::Speculatable) || !CI->doesNotAccessMemory() ||
+      !CI->willReturn())
+    return nullptr;
+  auto *Operand = dyn_cast<Instruction>(CI->getArgOperand(0));
+  if (!Operand)
+    return nullptr;
+  // Operand type should match the result type we ignore type changing
+  // intrinsics.
+  if (Operand->getType() != CI->getType())
+    return nullptr;
----------------
mssefat wrote:

Fixed, please check.

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


More information about the llvm-commits mailing list