File tree 1 file changed +14
-5
lines changed 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -258,17 +258,26 @@ GenTree* Compiler::fgMorphCast(GenTree* tree)
258
258
}
259
259
#endif //! TARGET_64BIT
260
260
261
+ #ifdef TARGET_ARMARCH
262
+ // AArch, unlike x86/amd64, has instructions that can cast directly from
263
+ // all integers (except for longs on AArch32 of course) to floats.
264
+ // Because there is no IL instruction conv.r4.un, uint/ulong -> float
265
+ // casts are always inported as CAST(float <- CAST(double <- uint/ulong)).
266
+ // We can eliminate the redundant intermediate cast as an optimization.
267
+ else if ((dstType == TYP_FLOAT) && (srcType == TYP_DOUBLE) && oper->OperIs(GT_CAST)
261
268
#ifdef TARGET_ARM
262
- else if ((dstType == TYP_FLOAT) && (srcType == TYP_DOUBLE) && (oper->gtOper == GT_CAST) &&
263
- !varTypeIsLong(oper->AsCast()->CastOp()))
269
+ && !varTypeIsLong(oper->AsCast()->CastOp())
270
+ #endif
271
+ )
264
272
{
265
- // optimization: conv.r4(conv.r8(?)) -> conv.r4(d)
266
- // except when the ultimate source is a long because there is no long-to-float helper, so it must be 2 step.
267
- // This happens semi-frequently because there is no IL 'conv.r4.un'
268
273
oper->gtType = TYP_FLOAT;
269
274
oper->CastToType() = TYP_FLOAT;
275
+
270
276
return fgMorphTree(oper);
271
277
}
278
+ #endif // TARGET_ARMARCH
279
+
280
+ #ifdef TARGET_ARM
272
281
// converts long/ulong --> float/double casts into helper calls.
273
282
else if (varTypeIsFloating(dstType) && varTypeIsLong(srcType))
274
283
{
You can’t perform that action at this time.
0 commit comments