@@ -260,24 +260,29 @@ SwitchIRBuilder::OnCase(IR::RegOpnd * src1Opnd, IR::Opnd * src2Opnd, uint32 offs
260
260
//
261
261
// For optimizing, the Load instruction corresponding to the switch instruction is profiled in the interpreter.
262
262
// Based on the dynamic profile data, optimization technique is decided.
263
- if (m_switchIntDynProfile && isIntConst && GlobOpt::IsSwitchOptEnabledForIntTypeSpec (m_func->GetTopFunc ()))
264
- {
265
- CaseNode* caseNode = JitAnew (m_tempAlloc, CaseNode, branchInstr, offset, targetOffset, src2Opnd);
266
- m_caseNodes->Add (caseNode);
267
- }
268
- else if (m_switchStrDynProfile && isStrConst && GlobOpt::IsSwitchOptEnabled (m_func->GetTopFunc ()))
269
- {
270
- CaseNode* caseNode = JitAnew (m_tempAlloc, CaseNode, branchInstr, offset, targetOffset, src2Opnd);
271
- m_caseNodes->Add (caseNode);
272
- m_seenOnlySingleCharStrCaseNodes = m_seenOnlySingleCharStrCaseNodes && caseNode->GetUpperBoundStringConstLocal ()->GetLength () == 1 ;
273
- }
274
- else
263
+
264
+ // TODO: support switch opt when breaking out of loops
265
+ if (!m_func->IsLoopBody () || (targetOffset < m_func->m_workItem ->GetLoopHeader ()->endOffset && targetOffset >= m_func->m_workItem ->GetLoopHeader ()->startOffset ))
275
266
{
276
- // Otherwise, there are no optimizations to defer, so add the branch for
277
- // this case instruction now
278
- FlushCases (offset);
279
- m_adapter->AddBranchInstr (branchInstr, offset, targetOffset);
267
+ if (m_switchIntDynProfile && isIntConst && GlobOpt::IsSwitchOptEnabledForIntTypeSpec (m_func->GetTopFunc ()))
268
+ {
269
+ CaseNode* caseNode = JitAnew (m_tempAlloc, CaseNode, branchInstr, offset, targetOffset, src2Opnd);
270
+ m_caseNodes->Add (caseNode);
271
+ return ;
272
+ }
273
+ else if (m_switchStrDynProfile && isStrConst && GlobOpt::IsSwitchOptEnabled (m_func->GetTopFunc ()))
274
+ {
275
+ CaseNode* caseNode = JitAnew (m_tempAlloc, CaseNode, branchInstr, offset, targetOffset, src2Opnd);
276
+ m_caseNodes->Add (caseNode);
277
+ m_seenOnlySingleCharStrCaseNodes = m_seenOnlySingleCharStrCaseNodes && caseNode->GetUpperBoundStringConstLocal ()->GetLength () == 1 ;
278
+ return ;
279
+ }
280
280
}
281
+
282
+ // Otherwise, there are no optimizations to defer, so add the branch for
283
+ // this case instruction now
284
+ FlushCases (offset);
285
+ m_adapter->AddBranchInstr (branchInstr, offset, targetOffset);
281
286
}
282
287
283
288
0 commit comments