Use field type value-numbering local field stores
authorJoseph Tremoulet <jotrem@microsoft.com>
Tue, 20 Dec 2016 18:23:58 +0000 (10:23 -0800)
committerJoseph Tremoulet <jotrem@microsoft.com>
Tue, 20 Dec 2016 18:23:58 +0000 (10:23 -0800)
Method `VNPairApplySelectorsAssign` takes the type of the value being
assigned, so when processing a store to a field of a local struct, pass
the type of the field rather than the type of the local; failure to do so
was blocking propagation of the value number to subsequent loads of the
same field due to the type mismatch.

Commit migrated from https://github.com/dotnet/coreclr/commit/ae3f036d1527dddc399a15da6151661143e2948a

src/coreclr/src/jit/valuenum.cpp

index c67611f..f7cc0c9 100644 (file)
@@ -5640,10 +5640,9 @@ void Compiler::fgValueNumberTree(GenTreePtr tree, bool evalAsgLhsInd)
                                 // (we looked in a side table above for its "def" identity).  Look up that value.
                                 ValueNumPair oldLhsVNPair =
                                     lvaTable[lclFld->GetLclNum()].GetPerSsaData(lclFld->GetSsaNum())->m_vnPair;
-                                newLhsVNPair =
-                                    vnStore->VNPairApplySelectorsAssign(oldLhsVNPair, lclFld->gtFieldSeq,
-                                                                        rhsVNPair, // Pre-value.
-                                                                        lvaGetActualType(lclFld->gtLclNum), compCurBB);
+                                newLhsVNPair = vnStore->VNPairApplySelectorsAssign(oldLhsVNPair, lclFld->gtFieldSeq,
+                                                                                   rhsVNPair, // Pre-value.
+                                                                                   lclFld->TypeGet(), compCurBB);
                             }
                         }
                         lvaTable[lclFld->GetLclNum()].GetPerSsaData(lclDefSsaNum)->m_vnPair = newLhsVNPair;