@@ -2893,7 +2893,7 @@ regNumber emitter::emitInsBinary(instruction ins, emitAttr attr, GenTree* dst, G
2893
2893
{
2894
2894
dblConst = src->AsDblCon ();
2895
2895
}
2896
-
2896
+
2897
2897
// find local field if any
2898
2898
GenTreeLclFld* lclField = nullptr ;
2899
2899
if (src->isContainedLclField ())
@@ -2918,9 +2918,25 @@ regNumber emitter::emitInsBinary(instruction ins, emitAttr attr, GenTree* dst, G
2918
2918
lclVar = dst->AsLclVar ();
2919
2919
}
2920
2920
2921
+ // find contained spill tmp if any
2922
+ TempDsc* tmpDsc = nullptr ;
2923
+ if (src->isContainedSpillTemp ())
2924
+ {
2925
+ assert (src->IsRegOptional ());
2926
+ tmpDsc = codeGen->getSpillTempDsc (src);
2927
+ }
2928
+ else if (dst->isContainedSpillTemp ())
2929
+ {
2930
+ assert (dst->IsRegOptional ());
2931
+ tmpDsc = codeGen->getSpillTempDsc (dst);
2932
+ }
2933
+
2921
2934
// First handle the simple non-memory cases
2922
2935
//
2923
- if ((mem == nullptr ) && (lclField == nullptr ) && (lclVar == nullptr ))
2936
+ if ((mem == nullptr ) &&
2937
+ (lclField == nullptr ) &&
2938
+ (lclVar == nullptr ) &&
2939
+ (tmpDsc == nullptr ))
2924
2940
{
2925
2941
if (intConst != nullptr )
2926
2942
{
@@ -2959,7 +2975,7 @@ regNumber emitter::emitInsBinary(instruction ins, emitAttr attr, GenTree* dst, G
2959
2975
// Next handle the cases where we have a stack based local memory operand.
2960
2976
//
2961
2977
unsigned varNum = BAD_VAR_NUM;
2962
- unsigned offset = (unsigned ) -1 ;
2978
+ unsigned offset = (unsigned )-1 ;
2963
2979
2964
2980
if (lclField != nullptr )
2965
2981
{
@@ -2971,12 +2987,22 @@ regNumber emitter::emitInsBinary(instruction ins, emitAttr attr, GenTree* dst, G
2971
2987
varNum = lclVar->AsLclVarCommon ()->GetLclNum ();
2972
2988
offset = 0 ;
2973
2989
}
2990
+ else if (tmpDsc != nullptr )
2991
+ {
2992
+ varNum = tmpDsc->tdTempNum ();
2993
+ offset = 0 ;
2994
+ }
2974
2995
2975
- if (varNum != BAD_VAR_NUM)
2996
+ // Spill temp numbers are negative and start with -1
2997
+ // which also happens to be BAD_VAR_NUM. For this reason
2998
+ // we also need to check 'tmpDsc != nullptr' here.
2999
+ if (varNum != BAD_VAR_NUM ||
3000
+ tmpDsc != nullptr )
2976
3001
{
2977
3002
// Is the memory op in the source position?
2978
3003
if (src->isContainedLclField () ||
2979
- src->isContainedLclVar ())
3004
+ src->isContainedLclVar () ||
3005
+ src->isContainedSpillTemp ())
2980
3006
{
2981
3007
if (instrHasImplicitRegPairDest (ins))
2982
3008
{
@@ -2993,7 +3019,7 @@ regNumber emitter::emitInsBinary(instruction ins, emitAttr attr, GenTree* dst, G
2993
3019
}
2994
3020
else // The memory op is in the dest position.
2995
3021
{
2996
- assert (dst->gtRegNum == REG_NA);
3022
+ assert (dst->gtRegNum == REG_NA || dst-> IsRegOptional () );
2997
3023
2998
3024
// src could be int or reg
2999
3025
if (src->isContainedIntOrIImmed ())
@@ -3011,6 +3037,11 @@ regNumber emitter::emitInsBinary(instruction ins, emitAttr attr, GenTree* dst, G
3011
3037
}
3012
3038
}
3013
3039
3040
+ if (tmpDsc != nullptr )
3041
+ {
3042
+ emitComp->tmpRlsTemp (tmpDsc);
3043
+ }
3044
+
3014
3045
return dst->gtRegNum ;
3015
3046
}
3016
3047
0 commit comments