Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit79f9415

Browse files
authored
JIT: Optimize *x = dblCns to *x = intCns (#52298)
1 parent65afa4e commit79f9415

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

‎src/coreclr/jit/lowerxarch.cpp‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,38 @@ void Lowering::LowerStoreIndir(GenTreeIndir* node)
130130
return;
131131
}
132132
}
133+
elseif (node->AsStoreInd()->Data()->OperIs(GT_CNS_DBL))
134+
{
135+
// Optimize *x = DCON to *x = ICON which is slightly faster on xarch
136+
GenTree* data = node->AsStoreInd()->Data();
137+
double dblCns = data->AsDblCon()->gtDconVal;
138+
ssize_t intCns =0;
139+
var_types type = TYP_UNKNOWN;
140+
141+
if (node->TypeIs(TYP_FLOAT))
142+
{
143+
float fltCns =static_cast<float>(dblCns);// should be a safe round-trip
144+
intCns =static_cast<ssize_t>(*reinterpret_cast<UINT32*>(&fltCns));
145+
type = TYP_UINT;
146+
}
147+
#ifdef TARGET_AMD64
148+
else
149+
{
150+
assert(node->TypeIs(TYP_DOUBLE));
151+
intCns =static_cast<ssize_t>(*reinterpret_cast<UINT64*>(&dblCns));
152+
type = TYP_ULONG;
153+
}
154+
#endif
155+
156+
if (type != TYP_UNKNOWN)
157+
{
158+
data->SetContained();
159+
data->ChangeOperConst(GT_CNS_INT);
160+
data->AsIntCon()->SetIconValue(intCns);
161+
data->ChangeType(type);
162+
node->ChangeType(type);
163+
}
164+
}
133165
ContainCheckStoreIndir(node);
134166
}
135167

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp