[RyuJIT/ARM32] Reserve a double register for both TYP_DOUBLE and TYP_FLOAT
authorHyung-Kyu Choi <hk0110.choi@samsung.com>
Thu, 15 Jun 2017 08:16:14 +0000 (17:16 +0900)
committerHyung-Kyu Choi <hk0110.choi@samsung.com>
Thu, 15 Jun 2017 08:43:57 +0000 (17:43 +0900)
First, try to reserve a double temp register for both TYP_DOUBLE and TYP_FLOAT.
If fails, try to reserve a float temp register for only TYP_FLOAT.

Signed-off-by: Hyung-Kyu Choi <hk0110.choi@samsung.com>
Commit migrated from https://github.com/dotnet/coreclr/commit/a0a4799cdea1d779f40579c9223de6bf9ae996f2

src/coreclr/src/jit/lsra.cpp

index e820b50..187dd84 100644 (file)
@@ -9884,17 +9884,19 @@ void LinearScan::resolveEdge(BasicBlock*      fromBlock,
         (resolveType == ResolveSharedCritical) ? REG_NA : getTempRegForResolution(fromBlock, toBlock, TYP_INT);
 #endif // !_TARGET_XARCH_
     regNumber tempRegFlt = REG_NA;
-#ifdef _TARGET_ARM_
-    // ARM32 requires double temp register in addition to integer and float temp registers.
-    regNumber tempRegDbl = REG_NA;
-#endif
     if ((compiler->compFloatingPointUsed) && (resolveType != ResolveSharedCritical))
     {
-        tempRegFlt = getTempRegForResolution(fromBlock, toBlock, TYP_FLOAT);
 
 #ifdef _TARGET_ARM_
-        // ARM32 requires double temp register in addition to integer and float temp registers.
-        tempRegDbl = getTempRegForResolution(fromBlock, toBlock, TYP_DOUBLE);
+        // Let's try to reserve a double register for TYP_FLOAT and TYP_DOUBLE
+        tempRegFlt = getTempRegForResolution(fromBlock, toBlock, TYP_DOUBLE);
+        if (tempRegFlt == REG_NA)
+        {
+            // If fails, try to reserve a float register for TYP_FLOAT
+            tempRegFlt = getTempRegForResolution(fromBlock, toBlock, TYP_FLOAT);
+        }
+#else
+        tempRegFlt = getTempRegForResolution(fromBlock, toBlock, TYP_FLOAT);
 #endif
     }
 
@@ -10050,17 +10052,18 @@ void LinearScan::resolveEdge(BasicBlock*      fromBlock,
             {
                 regNumber tempReg = REG_NA;
                 bool      useSwap = false;
-#ifdef _TARGET_ARM_
-                // ARM32 requires double temp register when TYP_DOUBLE
-                if (sourceIntervals[fromReg]->registerType == TYP_DOUBLE)
+                if (emitter::isFloatReg(targetReg))
                 {
-                    tempReg = tempRegDbl;
-                }
-                else
-#endif
-                    if (emitter::isFloatReg(targetReg))
-                {
-                    tempReg = tempRegFlt;
+#ifdef _TARGET_ARM_
+                    if (sourceIntervals[fromReg]->registerType == TYP_DOUBLE)
+                    {
+                        // ARM32 requires a double temp register for TYP_DOUBLE.
+                        // We tried to reserve a double temp register first, but sometimes we can't.
+                        tempReg = genIsValidDoubleReg(tempRegFlt) ? tempRegFlt : REG_NA;
+                    }
+                    else
+#endif // _TARGET_ARM_
+                        tempReg = tempRegFlt;
                 }
 #ifdef _TARGET_XARCH_
                 else