Skip to content

Commit

Permalink
JIT: Remove special handling for GT_INTRINSIC in `gtTreeHasSideEffe…
Browse files Browse the repository at this point in the history
…cts` (#106257)

This handling is wrong.

Fix #106187
  • Loading branch information
jakobbotsch authored Aug 12, 2024
1 parent e29ffeb commit 714be4b
Showing 1 changed file with 15 additions and 37 deletions.
52 changes: 15 additions & 37 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16866,50 +16866,28 @@ bool Compiler::gtTreeHasSideEffects(GenTree* tree, GenTreeFlags flags /* = GTF_S
return false;
}

if (sideEffectFlags == GTF_CALL)
if ((sideEffectFlags == GTF_CALL) && tree->IsHelperCall())
{
if (tree->IsHelperCall())
// Generally all trees that contain GT_CALL nodes are considered to have side-effects.
// However, for some pure helper calls we lie about this.
if (gtNodeHasSideEffects(tree, flags, ignoreCctors))
{
// Generally all trees that contain GT_CALL nodes are considered to have side-effects.
// However, for some pure helper calls we lie about this.
if (gtNodeHasSideEffects(tree, flags, ignoreCctors))
{
return true;
}

// The GTF_CALL may be contributed by an operand, so check for
// that.
bool hasCallInOperand = false;
tree->VisitOperands([=, &hasCallInOperand](GenTree* op) {
if (gtTreeHasSideEffects(op, GTF_CALL, ignoreCctors))
{
hasCallInOperand = true;
return GenTree::VisitResult::Abort;
}
return GenTree::VisitResult::Continue;
});

return hasCallInOperand;
return true;
}
else if (tree->OperIs(GT_INTRINSIC))
{
if (gtNodeHasSideEffects(tree, flags, ignoreCctors))
{
return true;
}

if (gtNodeHasSideEffects(tree->AsOp()->gtOp1, flags, ignoreCctors))
{
return true;
}

if ((tree->AsOp()->gtOp2 != nullptr) && gtNodeHasSideEffects(tree->AsOp()->gtOp2, flags, ignoreCctors))
// The GTF_CALL may be contributed by an operand, so check for
// that.
bool hasCallInOperand = false;
tree->VisitOperands([=, &hasCallInOperand](GenTree* op) {
if (gtTreeHasSideEffects(op, GTF_CALL, ignoreCctors))
{
return true;
hasCallInOperand = true;
return GenTree::VisitResult::Abort;
}
return GenTree::VisitResult::Continue;
});

return false;
}
return hasCallInOperand;
}

return true;
Expand Down

0 comments on commit 714be4b

Please sign in to comment.