File tree 1 file changed +32
-0
lines changed 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,38 @@ void Lowering::LowerStoreIndir(GenTreeIndir* node)
130
130
return ;
131
131
}
132
132
}
133
+ else if (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
+ }
133
165
ContainCheckStoreIndir (node);
134
166
}
135
167
You can’t perform that action at this time.
0 commit comments