From 2a80066954697ec0c632208d1a9e8be105a34f19 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Wed, 1 Dec 2021 18:34:46 -0800 Subject: [PATCH] JIT: don't forward sub a volatile read tree via copy (#62224) The copy may not get the same value as the original. Detect this by looking for `GTF_ORDER_SIDEEFF`. Closes #62048. --- src/coreclr/jit/redundantbranchopts.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/jit/redundantbranchopts.cpp b/src/coreclr/jit/redundantbranchopts.cpp index d00de9901da4d..d8e4f97e68cf8 100644 --- a/src/coreclr/jit/redundantbranchopts.cpp +++ b/src/coreclr/jit/redundantbranchopts.cpp @@ -907,13 +907,13 @@ bool Compiler::optRedundantRelop(BasicBlock* const block) continue; } - // If prevTree has side effects other than GTF_EXCEPT or GTF_ASG, bail, + // If prevTree has side effects, bail, // unless it is in the immediately preceeding statement. // // (we'll later show that any exception must come from the RHS as the LHS // will be a simple local). // - if ((prevTree->gtFlags & GTF_SIDE_EFFECT) != (prevTree->gtFlags & (GTF_EXCEPT | GTF_ASG))) + if ((prevTree->gtFlags & (GTF_CALL | GTF_ORDER_SIDEEFF)) != 0) { if (prevStmt->GetNextStmt() != stmt) {