diff --git a/src/coreclr/src/jit/optcse.cpp b/src/coreclr/src/jit/optcse.cpp
index f578b2aa7e3..648e67047cd 100644
--- a/src/coreclr/src/jit/optcse.cpp
+++ b/src/coreclr/src/jit/optcse.cpp
@@ -1971,6 +1971,32 @@ public:
return result;
}
+ // IsCompatibleType() takes two var_types and returns true if they
+ // are compatible types for CSE substitution
+ //
+ bool IsCompatibleType(var_types cseLclVarTyp, var_types expTyp)
+ {
+ // Exact type match is the expected case
+ if (cseLclVarTyp == expTyp)
+ {
+ return true;
+ }
+
+ // We also allow TYP_BYREF and TYP_I_IMPL as compatible types
+ //
+ if ((cseLclVarTyp == TYP_BYREF) && (expTyp == TYP_I_IMPL))
+ {
+ return true;
+ }
+ if ((cseLclVarTyp == TYP_I_IMPL) && (expTyp == TYP_BYREF))
+ {
+ return true;
+ }
+
+ // Otherwise we have incompatible types
+ return false;
+ }
+
// PerformCSE() takes a successful candidate and performs the appropriate replacements:
//
// It will replace all of the CSE defs with assignments to a new "cse0" LclVar
@@ -2105,7 +2131,10 @@ public:
/* Figure out the actual type of the value */
var_types expTyp = genActualType(exp->TypeGet());
- noway_assert(expTyp == cseLclVarTyp);
+
+ // The cseLclVarType must be a compatible with expTyp
+ //
+ noway_assert(IsCompatibleType(cseLclVarTyp, expTyp));
// This will contain the replacement tree for exp
// It will either be the CSE def or CSE ref
diff --git a/src/coreclr/tests/issues.targets b/src/coreclr/tests/issues.targets
index 40265003dd3..a021d08e1e2 100644
--- a/src/coreclr/tests/issues.targets
+++ b/src/coreclr/tests/issues.targets
@@ -255,18 +255,6 @@
Varargs supported on this platform
-
- 22436
-
-
- 22436
-
-
- 22436
-
-
- 22436
-
@@ -295,12 +283,6 @@
Varargs supported on this platform
-
- 22436
-
-
- 22436
-