Skip to content

Commit

Permalink
Fixed bug with * x = dConst if dConst is not 0
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanWoo committed Nov 19, 2021
1 parent ee617c7 commit 36bc6b4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/coreclr/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6792,8 +6792,6 @@ void Lowering::LowerStoreIndirCommon(GenTreeStoreInd* ind)
TryCreateAddrMode(ind->Addr(), true, ind->TypeGet());
if (!comp->codeGen->gcInfo.gcIsWriteBarrierStoreIndNode(ind))
{
LowerStoreIndir(ind);

if (varTypeIsFloating(ind) && ind->Data()->IsCnsFltOrDbl())
{
// Optimize *x = DCON to *x = ICON which is slightly faster on xarch
Expand All @@ -6802,11 +6800,16 @@ void Lowering::LowerStoreIndirCommon(GenTreeStoreInd* ind)
ssize_t intCns = 0;
var_types type = TYP_UNKNOWN;

if (ind->TypeIs(TYP_FLOAT))
if (ind->TypeIs(TYP_FLOAT)
#if defined(TARGET_ARM64) || defined(TARGET_ARM)
&& data->IsFPZero()
#endif
)
{
float fltCns = static_cast<float>(dblCns); // should be a safe round-trip
intCns = static_cast<ssize_t>(*reinterpret_cast<INT32*>(&fltCns));
type = TYP_INT;
printf("qwe");
}
#ifdef TARGET_AMD64
else
Expand All @@ -6820,12 +6823,11 @@ void Lowering::LowerStoreIndirCommon(GenTreeStoreInd* ind)
if (type != TYP_UNKNOWN)
{
data->BashToConst(intCns, type);
#if defined(TARGET_ARM64)
data->SetContained();
#endif
ind->ChangeType(type);
}
}

LowerStoreIndir(ind);
}
}

Expand Down

0 comments on commit 36bc6b4

Please sign in to comment.