diff --git a/src/coreclr/jit/fgopt.cpp b/src/coreclr/jit/fgopt.cpp index 50bc965a68d0d..16eb52cf3823e 100644 --- a/src/coreclr/jit/fgopt.cpp +++ b/src/coreclr/jit/fgopt.cpp @@ -4321,9 +4321,9 @@ bool Compiler::fgOptimizeSwitchJumps() // Update flags // - switchTree->gtFlags = switchTree->AsOp()->gtOp1->gtFlags; - dominantCaseCompare->gtFlags |= dominantCaseCompare->AsOp()->gtOp1->gtFlags; - jmpTree->gtFlags |= dominantCaseCompare->gtFlags; + switchTree->gtFlags = switchTree->AsOp()->gtOp1->gtFlags & GTF_ALL_EFFECT; + dominantCaseCompare->gtFlags |= dominantCaseCompare->AsOp()->gtOp1->gtFlags & GTF_ALL_EFFECT; + jmpTree->gtFlags |= dominantCaseCompare->gtFlags & GTF_ALL_EFFECT; dominantCaseCompare->gtFlags |= GTF_RELOP_JMP_USED | GTF_DONT_CSE; // Wire up the new control flow.