@@ -16963,38 +16963,71 @@ const GenTreeLclVarCommon* GenTree::IsLocalAddrExpr() const
16963
16963
}
16964
16964
16965
16965
//------------------------------------------------------------------------
16966
- // IsImplicitByrefParameterValue: determine if this tree is the entire
16967
- // value of a local implicit byref parameter
16966
+ // IsImplicitByrefParameterValuePreMorph:
16967
+ // Determine if this tree represents the value of an implicit byref
16968
+ // parameter, and if so return the tree for the parameter. To be used
16969
+ // before implicit byrefs have been morphed.
16968
16970
//
16969
16971
// Arguments:
16970
- // compiler -- compiler instance
16972
+ // compiler - compiler instance
16971
16973
//
16972
16974
// Return Value:
16973
- // GenTreeLclVar node for the local, or nullptr.
16975
+ // Node for the local, or nullptr.
16974
16976
//
16975
- GenTreeLclVar * GenTree::IsImplicitByrefParameterValue (Compiler* compiler)
16977
+ GenTreeLclVarCommon * GenTree::IsImplicitByrefParameterValuePreMorph (Compiler* compiler)
16976
16978
{
16977
16979
#if FEATURE_IMPLICIT_BYREFS && !defined(TARGET_LOONGARCH64) // TODO-LOONGARCH64-CQ: enable this.
16978
16980
16979
- GenTreeLclVar * lcl = nullptr;
16981
+ GenTreeLclVarCommon * lcl = OperIsLocal() ? AsLclVarCommon() : nullptr;
16980
16982
16981
- if (OperIs(GT_LCL_VAR ))
16983
+ if ((lcl != nullptr) && compiler->lvaIsImplicitByRefLocal(lcl->GetLclNum() ))
16982
16984
{
16983
- lcl = AsLclVar() ;
16985
+ return lcl ;
16984
16986
}
16985
- else if (OperIsIndir())
16987
+
16988
+ #endif // FEATURE_IMPLICIT_BYREFS && !defined(TARGET_LOONGARCH64)
16989
+
16990
+ return nullptr;
16991
+ }
16992
+
16993
+ //------------------------------------------------------------------------
16994
+ // IsImplicitByrefParameterValuePostMorph:
16995
+ // Determine if this tree represents the value of an implicit byref
16996
+ // parameter, and if so return the tree for the parameter. To be used after
16997
+ // implicit byrefs have been morphed.
16998
+ //
16999
+ // Arguments:
17000
+ // compiler - compiler instance
17001
+ // addr - [out] tree representing the address computation on top of the implicit byref.
17002
+ // Will be the same as the return value if the whole implicit byref is used, for example.
17003
+ //
17004
+ // Return Value:
17005
+ // Node for the local, or nullptr.
17006
+ //
17007
+ GenTreeLclVar* GenTree::IsImplicitByrefParameterValuePostMorph(Compiler* compiler, GenTree** addr)
17008
+ {
17009
+ #if FEATURE_IMPLICIT_BYREFS && !defined(TARGET_LOONGARCH64) // TODO-LOONGARCH64-CQ: enable this.
17010
+
17011
+ if (!OperIsIndir())
16986
17012
{
16987
- GenTree* addr = AsIndir()->Addr();
17013
+ return nullptr;
17014
+ }
16988
17015
16989
- if (addr->OperIs(GT_LCL_VAR, GT_LCL_VAR_ADDR))
16990
- {
16991
- lcl = addr->AsLclVar();
16992
- }
17016
+ *addr = AsIndir()->Addr();
17017
+ GenTree* innerAddr = *addr;
17018
+
17019
+ while (innerAddr->OperIs(GT_ADD) && innerAddr->gtGetOp2()->IsCnsIntOrI())
17020
+ {
17021
+ innerAddr = innerAddr->gtGetOp1();
16993
17022
}
16994
17023
16995
- if ((lcl != nullptr) && compiler->lvaIsImplicitByRefLocal(lcl->GetLclNum() ))
17024
+ if (innerAddr->OperIs(GT_LCL_VAR ))
16996
17025
{
16997
- return lcl;
17026
+ GenTreeLclVar* lcl = innerAddr->AsLclVar();
17027
+ if (compiler->lvaIsImplicitByRefLocal(lcl->GetLclNum()))
17028
+ {
17029
+ return lcl;
17030
+ }
16998
17031
}
16999
17032
17000
17033
#endif // FEATURE_IMPLICIT_BYREFS && !defined(TARGET_LOONGARCH64)
0 commit comments