Skip to content

Commit 973b783

Browse files
jaladreipsigcbot
authored andcommitted
Use cross block load vectorization for new inline raytracing by default
Use cross block load vectorization for new inline raytracing by default
1 parent d6a14e5 commit 973b783

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

IGC/AdaptorCommon/LivenessUtils/AllocationLivenessAnalyzer.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ using namespace llvm;
3333
using namespace IGC;
3434

3535
AllocationLivenessAnalyzer::LivenessData
36-
AllocationLivenessAnalyzer::ProcessInstruction(Instruction *I, DominatorTree &DT, LoopInfo &LI) {
36+
AllocationLivenessAnalyzer::ProcessInstruction(Instruction *I, DominatorTree &DT, LoopInfo &LI, bool includeOrigin) {
3737
// static allocas are usually going to be in the entry block
3838
// that's a practice, but we only care about the last block that dominates all uses
3939
BasicBlock *commonDominator = nullptr;
@@ -93,14 +93,9 @@ AllocationLivenessAnalyzer::ProcessInstruction(Instruction *I, DominatorTree &DT
9393
}
9494
}
9595
} break;
96-
case Instruction::Call: {
97-
auto *callI = cast<CallInst>(II);
98-
if (!callI->doesNotCapture(use->getOperandNo()))
99-
lifetimeLeakingUsers.insert(II);
100-
101-
if (II->getType()->isPointerTy())
102-
addUsesFn(II->uses());
103-
} break;
96+
case Instruction::Call:
97+
implementCallSpecificBehavior(cast<CallInst>(II), use, worklist, allUsers, lifetimeLeakingUsers);
98+
break;
10499
case Instruction::Load:
105100
if (II->getType()->isPointerTy())
106101
addUsesFn(II->uses());
@@ -111,6 +106,9 @@ AllocationLivenessAnalyzer::ProcessInstruction(Instruction *I, DominatorTree &DT
111106
}
112107
}
113108

109+
if (includeOrigin)
110+
allUsers.insert(I);
111+
114112
return LivenessData(I, std::move(allUsers), LI, DT, commonDominator, std::move(lifetimeLeakingUsers));
115113
}
116114

@@ -120,6 +118,20 @@ void AllocationLivenessAnalyzer::getAnalysisUsage(llvm::AnalysisUsage &AU) const
120118
getAdditionalAnalysisUsage(AU);
121119
}
122120

121+
void AllocationLivenessAnalyzer::implementCallSpecificBehavior(CallInst *callI, Use* use, SmallVector<Use *> &worklist,
122+
SetVector<Instruction *> &allUsers,
123+
SetVector<Instruction *> &lifetimeLeakingUsers) {
124+
125+
if (!callI->doesNotCapture(use->getOperandNo()))
126+
lifetimeLeakingUsers.insert(callI);
127+
128+
if (callI->getType()->isPointerTy()) {
129+
130+
for (auto &use : callI->uses())
131+
worklist.push_back(&use);
132+
}
133+
}
134+
123135
template <typename range>
124136
static inline void doWorkLoop(SmallVector<BasicBlock *> &worklist, DenseSet<BasicBlock *> &bbSet1,
125137
DenseSet<BasicBlock *> &bbSet2, std::function<range(BasicBlock *)> iterate,

IGC/AdaptorCommon/LivenessUtils/AllocationLivenessAnalyzer.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ SPDX-License-Identifier: MIT
1515

1616
namespace llvm {
1717
class BasicBlock;
18+
class CallInst;
1819
class DominatorTree;
1920
class Instruction;
2021
class LoopInfo;
22+
class Use;
2123
} // namespace llvm
2224

2325
namespace IGC {
@@ -49,10 +51,15 @@ class AllocationLivenessAnalyzer : public llvm::FunctionPass {
4951
AllocationLivenessAnalyzer(char &pid) : llvm::FunctionPass(pid) {}
5052

5153
protected:
52-
LivenessData ProcessInstruction(llvm::Instruction *I, llvm::DominatorTree &DT, llvm::LoopInfo &LI);
54+
LivenessData ProcessInstruction(llvm::Instruction *I, llvm::DominatorTree &DT, llvm::LoopInfo &LI,
55+
bool includeOrigin = false);
5356

5457
void getAnalysisUsage(llvm::AnalysisUsage &AU) const override;
5558
virtual void getAdditionalAnalysisUsage(llvm::AnalysisUsage &AU) const = 0;
59+
virtual void implementCallSpecificBehavior(llvm::CallInst *I, llvm::Use *use,
60+
llvm::SmallVector<llvm::Use *> &worklist,
61+
llvm::SetVector<llvm::Instruction *> &allUsers,
62+
llvm::SetVector<llvm::Instruction *> &lifetimeLeakingUsers);
5663
};
5764

5865
namespace Provenance {

IGC/common/igc_flags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1844,7 +1844,7 @@ DECLARE_IGC_REGKEY_BITMASK(UseNewInlineRaytracing, 4, "Use the new rayquery impl
18441844
NEW_INLINE_RAYTRACING_MASK, true)
18451845
DECLARE_IGC_REGKEY(DWORD, AddDummySlotsForNewInlineRaytracing, 0,
18461846
"Add dummy rayquery slots when doing new inline raytracing", true)
1847-
DECLARE_IGC_REGKEY(bool, UseCrossBlockLoadVectorizationForInlineRaytracing, false,
1847+
DECLARE_IGC_REGKEY(bool, UseCrossBlockLoadVectorizationForInlineRaytracing, true,
18481848
"If enabled, will try to vectorize loads that are not adjacent to each other. May increase GRF pressure", true)
18491849
DECLARE_IGC_REGKEY(bool, OverrideRayQueryThrottling, false,
18501850
"Force rayquery throttling (dynamic ray management) to be enabled or disabled. Default value of "

0 commit comments

Comments
 (0)