Skip to content

Commit

Permalink
Fix invalid threading of nodes in rationalization (#64012)
Browse files Browse the repository at this point in the history
The code in question assumes that the ASG will be
reversed and thus threads "simdTree" before "location"
in the linear order. That dependency, while valid,
because "gtSetEvalOrder" will always reverse ASGs
with locals on the LHS, is unnecessary and incorrect
from the IR validity point of view.

Fix this by using "InsertAfter" instead of manual
node threading.
  • Loading branch information
SingleAccretion committed Jan 20, 2022
1 parent 93dc760 commit 5cefc0f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/coreclr/jit/rationalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,10 @@ void Rationalizer::RewriteAssignment(LIR::Use& use)
}
GenTreeSIMD* simdTree =
comp->gtNewSIMDNode(simdType, initVal, SIMDIntrinsicInit, simdBaseJitType, genTypeSize(simdType));
assignment->AsOp()->gtOp2 = simdTree;
value = simdTree;
initVal->gtNext = simdTree;
simdTree->gtPrev = initVal;
assignment->gtOp2 = simdTree;
value = simdTree;

simdTree->gtNext = location;
location->gtPrev = simdTree;
BlockRange().InsertAfter(initVal, simdTree);
}
}
#endif // FEATURE_SIMD
Expand Down

0 comments on commit 5cefc0f

Please sign in to comment.