From 2191c812dff17a2b0efba3754ce6cca67aada19a Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 9 Jul 2024 21:31:42 +0200 Subject: [PATCH] JIT: Skip switch recognition for handles Recognizing a series of handle compares as a switch is not legal since those handles may change values. --- src/coreclr/jit/switchrecognition.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/switchrecognition.cpp b/src/coreclr/jit/switchrecognition.cpp index 747d046699340e..dcfb57cabf4e2a 100644 --- a/src/coreclr/jit/switchrecognition.cpp +++ b/src/coreclr/jit/switchrecognition.cpp @@ -86,7 +86,7 @@ bool IsConstantTestCondBlock(const BasicBlock* block, } // We're looking for "X EQ/NE CNS" or "CNS EQ/NE X" pattern - if (op1->IsCnsIntOrI() ^ op2->IsCnsIntOrI()) + if ((op1->IsCnsIntOrI() && !op1->IsIconHandle()) ^ (op2->IsCnsIntOrI() && !op2->IsIconHandle())) { // TODO: relax this to support any side-effect free expression if (!op1->OperIs(GT_LCL_VAR) && !op2->OperIs(GT_LCL_VAR))