Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent hoisting nodes with order side effects #100160

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/coreclr/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4596,6 +4596,15 @@ void Compiler::optHoistLoopBlocks(FlowGraphNaturalLoop* loop,
// hence this check is not present in optIsCSEcandidate().
return true;
}
else if ((node->gtFlags & GTF_ORDER_SIDEEFF) != 0)
{
// If a node has an order side effect, we can't hoist it at all: we don't know what the order
// dependence actually is. For example, assertion prop might have determined a node can't throw
// an exception, and eliminated the GTF_EXCEPT flag, replacing it with GTF_ORDER_SIDEEFF. We
// can't hoist because we might then hoist above the expression that led assertion prop to make
// that decision. This can happen in JitOptRepeat, where hoisting can follow assertion prop.
return false;
}

// Tree must be a suitable CSE candidate for us to be able to hoist it.
return m_compiler->optIsCSEcandidate(node);
Expand Down Expand Up @@ -4786,7 +4795,7 @@ void Compiler::optHoistLoopBlocks(FlowGraphNaturalLoop* loop,
}
else if (!top.m_hoistable)
{
top.m_failReason = "not handled by cse";
top.m_failReason = "not handled by hoisting or CSE";
}
#endif

Expand Down Expand Up @@ -4869,7 +4878,7 @@ void Compiler::optHoistLoopBlocks(FlowGraphNaturalLoop* loop,
treeIsHoistable = IsNodeHoistable(tree);
if (!treeIsHoistable)
{
INDEBUG(failReason = "not handled by cse";)
INDEBUG(failReason = "not handled by hoisting or CSE";)
}
}

Expand Down
Loading