Handle long value in MergedReturns optimization
authorRoman Artemev <rartemev@microsoft.com>
Thu, 21 Sep 2017 23:20:27 +0000 (16:20 -0700)
committerRoman Artemev <rartemev@microsoft.com>
Fri, 22 Sep 2017 00:10:09 +0000 (17:10 -0700)
src/jit/flowgraph.cpp

index dc420f4..f60f573 100644 (file)
@@ -8185,7 +8185,7 @@ private:
     // returns that constant (up to the limit on number of returns); in
     // `returnConstants` we track the constant values returned by these
     // merged constant return blocks.
-    ssize_t returnConstants[ReturnCountHardLimit];
+    INT64 returnConstants[ReturnCountHardLimit];
 
     // Indicators of where in the lexical block list we'd like to place
     // each constant return block.
@@ -8361,7 +8361,11 @@ private:
         if (returnConst != nullptr)
         {
             returnExpr             = comp->gtNewOperNode(GT_RETURN, returnConst->gtType, returnConst);
-            returnConstants[index] = returnConst->IconValue();
+#ifdef _TARGET_64BIT_
+            returnConstants[index] = returnConst->LngValue();
+#else
+            returnConstants[index] = returnConst->gtOper == GT_CNS_LNG ? returnConst->LngValue() : (INT64)returnConst->IconValue();
+#endif // _TARGET_64BIT_
         }
         else if (comp->compMethodHasRetVal())
         {
@@ -8609,14 +8613,6 @@ private:
             return nullptr;
         }
 
-#if defined(_TARGET_X86_) || defined(_TARGET_ARM_)
-        if (retExpr->gtOper != GT_CNS_INT)
-        {
-            // There is no long cache in 32 bit VM so skip it
-            return nullptr;
-        }
-#endif // _TARGET_X86_ || _TARGET_ARM_
-
         return retExpr->AsIntConCommon();
     }
 
@@ -8637,7 +8633,11 @@ private:
     //
     BasicBlock* FindConstReturnBlock(GenTreeIntConCommon* constExpr, unsigned searchLimit, unsigned* index)
     {
-        ssize_t constVal = constExpr->IconValue();
+#ifdef _TARGET_64BIT_
+        INT64 constVal = constExpr->LngValue();
+#else
+        INT64 constVal = constExpr->gtOper == GT_CNS_LNG ? constExpr->LngValue() : (INT64)constExpr->IconValue();
+#endif // _TARGET_64BIT_
 
         for (unsigned i = 0; i < searchLimit; ++i)
         {