[llvm] [SLP][AMDGPU] Vectorize operands of non-trivially-vectorizable intrinsic calls (PR #189784)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 6 18:01:13 PDT 2026
================
@@ -29475,8 +29508,37 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
PostProcessInserts.insert(&*It);
else if (isa<CmpInst>(It))
PostProcessCmps.insert(cast<CmpInst>(&*It));
+
+ // Collect operands of non-trivially vectorizable intrinsic calls (e.g.,
+ // llvm.amdgcn.exp2) and group by intrinsic ID, so their operands can be
+ // vectorized independently.
+ // FIXME: Extend for all non-vectorized functions.
+ if (R.isDeleted(&*It))
+ continue;
+ SmallVector<Value *, 4> Ops =
+ getNonTriviallyVectorizableIntrinsicCallOperand(&*It);
+ if (!Ops.empty()) {
+ Intrinsic::ID ID = cast<CallInst>(&*It)->getIntrinsicID();
+ for (auto [OpIdx, Op] : enumerate(Ops)) {
+ if (auto *OpI = dyn_cast<Instruction>(Op)) {
+ IntrinsicSeedOps[{ID, OpIdx}][OpI->getOpcode()].push_back(Op);
+ }
+ }
+ }
}
+ // Vectorize non-trivially-vectorizable intrinsic candidates.
+ for (auto &[_, OpcodeMap] : IntrinsicSeedOps)
+ for (auto &[_, Group] : OpcodeMap) {
+ // Don't include instructions that were deleted by previous
+ // vectorization.
+ auto Candidates = make_filter_range(Group, [&](Value *V) {
+ auto *I = dyn_cast<Instruction>(V);
+ return I && !R.isDeleted(I);
+ });
+ Changed |= tryToVectorizeList(SmallVector<Value *, 4>(Candidates), R);
+ }
+
----------------
xgxanq wrote:
> Why don't we handle calls just like inserts/compares?
It is incorrect to have target intrinsc calls and PostProcessInserts entangled together and competing to construct the vector tree.
https://github.com/llvm/llvm-project/pull/189784
More information about the llvm-commits
mailing list