Fix Valuenum:EvalFuncForConstantArgs (#17506)
authorSergey Andreenko <seandree@microsoft.com>
Wed, 11 Apr 2018 20:16:22 +0000 (13:16 -0700)
committerGitHub <noreply@github.com>
Wed, 11 Apr 2018 20:16:22 +0000 (13:16 -0700)
src/jit/valuenum.cpp

index fcb38d3..15a970d 100644 (file)
@@ -1098,6 +1098,11 @@ ValueNum ValueNumStore::VNForFunc(var_types typ, VNFunc func, ValueNum arg0VN, V
         {
             canFold = false;
         }
+        if (typ == TYP_BYREF)
+        {
+            // We don't want to fold expressions that produce TYP_BYREF
+            canFold = false;
+        }
 
         if (canFold)
         {
@@ -1752,12 +1757,6 @@ ValueNum ValueNumStore::EvalFuncForConstantArgs(var_types typ, VNFunc func, Valu
         return EvalCastForConstantArgs(typ, func, arg0VN, arg1VN);
     }
 
-    if (typ == TYP_BYREF)
-    {
-        // We don't want to fold expressions that produce TYP_BYREF
-        return false;
-    }
-
     var_types arg0VNtyp = TypeOfVN(arg0VN);
     var_types arg1VNtyp = TypeOfVN(arg1VN);