[llvm] [NFC][SPIR-V] Fuse redundant store-collecting loop into main scan in SPIRVEmitIntrinsics (PR #215489)
Arseniy Obolenskiy via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 11 01:22:27 PDT 2026
https://github.com/aobolensk updated https://github.com/llvm/llvm-project/pull/215489
>From c257df1bcbb7859af821df2415469fae0d87a536 Mon Sep 17 00:00:00 2001
From: Arseniy Obolenskiy <arseniy.obolenskiy at amd.com>
Date: Tue, 11 Aug 2026 09:37:56 +0200
Subject: [PATCH] [NFC][SPIR-V] Fuse redundant store-collecting loop into main
scan in SPIRVEmitIntrinsics
Split out of #211299 per review: the AggrStores collection loop is folded
into the main instruction loop instead of running as a separate pass.
---
llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp b/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
index c5af31bc733d7..4211f714374fe 100644
--- a/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
@@ -3665,6 +3665,13 @@ bool SPIRVEmitIntrinsicsImpl::runOnFunction(Function &Func) {
// Data structure for dead instructions that were simplified and replaced.
SmallPtrSet<Instruction *, 4> DeadInsts;
for (auto &I : instructions(Func)) {
+ if (StoreInst *SI = dyn_cast<StoreInst>(&I)) {
+ Type *ElTy = SI->getValueOperand()->getType();
+ if (ElTy->isAggregateType() || ElTy->isVectorTy())
+ AggrStores.insert(&I);
+ continue;
+ }
+
auto *GEP = dyn_cast<GetElementPtrInst>(&I);
auto *SGEP = dyn_cast<StructuredGEPInst>(&I);
@@ -3692,18 +3699,6 @@ bool SPIRVEmitIntrinsicsImpl::runOnFunction(Function &Func) {
I->eraseFromParent();
}
- // StoreInst's operand type can be changed during the next
- // transformations, so we need to store it in the set. Also store already
- // transformed types.
- for (auto &I : instructions(Func)) {
- StoreInst *SI = dyn_cast<StoreInst>(&I);
- if (!SI)
- continue;
- Type *ElTy = SI->getValueOperand()->getType();
- if (ElTy->isAggregateType() || ElTy->isVectorTy())
- AggrStores.insert(&I);
- }
-
B.SetInsertPoint(&Func.getEntryBlock(), Func.getEntryBlock().begin());
for (auto &GV : Func.getParent()->globals())
processGlobalValue(GV, B);
More information about the llvm-commits
mailing list