JIT: Prefer block copies for unenregisterable locals even with GC pointers (#85620)
authorJakob Botsch Nielsen <Jakob.botsch.nielsen@gmail.com>
Tue, 2 May 2023 10:29:09 +0000 (12:29 +0200)
committerGitHub <noreply@github.com>
Tue, 2 May 2023 10:29:09 +0000 (12:29 +0200)
This comment seems outdated/wrong, the backend's block copy strategy
when GC pointers are involved is highly tuned and often no helper is
necessary at all.

src/coreclr/jit/morphblock.cpp

index 2048612..750efd2 100644 (file)
@@ -917,14 +917,11 @@ void MorphCopyBlockHelper::MorphStructCases()
         // A struct with 8 bool fields will require 8 moves instead of one if we do this transformation.
         // A simple heuristic when field by field copy is preferred:
         // - if fields can be enregistered;
-        // - if the struct has GCPtrs (block copy would be done via helper that is expensive);
         // - if the struct has only one field.
         bool dstFldIsProfitable =
-            ((m_dstVarDsc != nullptr) &&
-             (!m_dstVarDsc->lvDoNotEnregister || m_dstVarDsc->HasGCPtr() || (m_dstVarDsc->lvFieldCnt == 1)));
+            ((m_dstVarDsc != nullptr) && (!m_dstVarDsc->lvDoNotEnregister || (m_dstVarDsc->lvFieldCnt == 1)));
         bool srcFldIsProfitable =
-            ((m_srcVarDsc != nullptr) &&
-             (!m_srcVarDsc->lvDoNotEnregister || m_srcVarDsc->HasGCPtr() || (m_srcVarDsc->lvFieldCnt == 1)));
+            ((m_srcVarDsc != nullptr) && (!m_srcVarDsc->lvDoNotEnregister || (m_srcVarDsc->lvFieldCnt == 1)));
         // Are both dest and src promoted structs?
         if (m_dstDoFldAsg && m_srcDoFldAsg && (dstFldIsProfitable || srcFldIsProfitable))
         {