Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
New fix - only disable GT_CLS_VAR's
Browse files Browse the repository at this point in the history
  • Loading branch information
briansull committed Sep 20, 2019
1 parent 93c9dc5 commit 39820ca
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6795,8 +6795,21 @@ void Compiler::optHoistLoopBlocks(unsigned loopNum, ArrayStack<BasicBlock*>* blo

bool IsTreeVNInvariant(GenTree* tree)
{
return m_compiler->optVNIsLoopInvariant(tree->gtVNPair.GetLiberal(), m_loopNum,
&m_hoistContext->m_curLoopVnInvariantCache);
ValueNum vn = tree->gtVNPair.GetLiberal();

if (m_compiler->vnStore->IsVNConstant(vn))
{
// It is unsafe to allow a GT_CLS_VAR that has been assigned a constant.
// The logic in optVNIsLoopInvariant woudl consider it to be loop-invariant, even
// if the assignment of the constant to the GT_CLS_VAR was inside the loop.
//
if (tree->OperIs(GT_CLS_VAR))
{
return false;
}
}

return m_compiler->optVNIsLoopInvariant(vn, m_loopNum, &m_hoistContext->m_curLoopVnInvariantCache);
}

public:
Expand Down

0 comments on commit 39820ca

Please sign in to comment.