File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ bool PrivateMemoryUsageAnalysis::runOnModule(Module& M)
42
42
43
43
bool hasStackCall = false ;
44
44
45
+ m_hasDPDivSqrtEmu = !pCtx->platform .hasNoFP64Inst () && !pCtx->platform .hasCorrectlyRoundedMacros () && pCtx->m_DriverInfo .NeedFP64DivSqrt ();
46
+
45
47
// Run on all functions defined in this module
46
48
for (Module::iterator I = M.begin (), E = M.end (); I != E; ++I)
47
49
{
@@ -125,7 +127,6 @@ bool PrivateMemoryUsageAnalysis::runOnFunction(Function& F)
125
127
CodeGenContext* pCtx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext ();
126
128
// This is the condition that double emulation is used.
127
129
if ((IGC_IS_FLAG_ENABLED (ForceDPEmulation) ||
128
- (!pCtx->platform .hasNoFP64Inst () && !pCtx->platform .hasCorrectlyRoundedMacros () && pCtx->m_DriverInfo .NeedFP64DivSqrt ()) ||
129
130
(pCtx->m_DriverInfo .NeedFP64 (pCtx->platform .getPlatformInfo ().eProductFamily ) && pCtx->platform .hasNoFP64Inst ())))
130
131
{
131
132
m_hasPrivateMem = true ;
@@ -171,4 +172,26 @@ void PrivateMemoryUsageAnalysis::visitBinaryOperator(llvm::BinaryOperator& I)
171
172
break ;
172
173
}
173
174
}
175
+
176
+ // Check if an instruction is fp64 div to enable privMem
177
+ if (m_hasDPDivSqrtEmu)
178
+ {
179
+ if (I.getOpcode () == Instruction::FDiv)
180
+ {
181
+ m_hasPrivateMem = true ;
182
+ }
183
+ }
184
+ }
185
+
186
+ void PrivateMemoryUsageAnalysis::visitCallInst (llvm::CallInst& CI)
187
+ {
188
+ // Check if a sqrtd builtin is called to enable privMem
189
+ if (m_hasDPDivSqrtEmu)
190
+ {
191
+ Function* calledFunc = CI.getCalledFunction ();
192
+ if (calledFunc->getName ().startswith (" __builtin_IB_native_sqrtd" ))
193
+ {
194
+ m_hasPrivateMem = true ;
195
+ }
196
+ }
174
197
}
Original file line number Diff line number Diff line change @@ -61,6 +61,11 @@ namespace IGC
61
61
// / @param I The binary op
62
62
void visitBinaryOperator (llvm::BinaryOperator& I);
63
63
64
+ // / @brief CallInst instructions visitor.
65
+ // / Analyzes if there are private memory allocation.
66
+ // / @param CI The binary op
67
+ void visitCallInst (llvm::CallInst& CI);
68
+
64
69
private:
65
70
// / @brief Function entry point.
66
71
// / Finds all alloca instructions in this function, analyzes them and adds
@@ -72,6 +77,9 @@ namespace IGC
72
77
// / @brief A flag signaling if the current function uses private memory
73
78
bool m_hasPrivateMem;
74
79
80
+ // / @brief A flag signaling if the platform has partial fp64 emulation
81
+ bool m_hasDPDivSqrtEmu = false ;
82
+
75
83
// / @brief MetaData utils used to generate LLVM metadata
76
84
IGCMD::MetaDataUtils* m_pMDUtils;
77
85
};
You can’t perform that action at this time.
0 commit comments