Skip to content

Commit 1962b50

Browse files
authored
JIT: Fix unrecognized unaligned field indirections on ARM32 (#75078)
For large field offsets we need to insert explicit null checks. This was breaking recognition of unaligned accesses that needs special treatment for floating point instructions. Fix #74260
1 parent e0835c9 commit 1962b50

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/coreclr/jit/morph.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11271,13 +11271,14 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optA
1127111271
temp = nullptr;
1127211272
}
1127311273
}
11274-
else if (op1->OperGet() == GT_ADD)
11274+
else
1127511275
{
1127611276
#ifdef TARGET_ARM
11277+
GenTree* effOp1 = op1->gtEffectiveVal(true);
1127711278
// Check for a misalignment floating point indirection.
11278-
if (varTypeIsFloating(typ))
11279+
if (effOp1->OperIs(GT_ADD) && varTypeIsFloating(typ))
1127911280
{
11280-
GenTree* addOp2 = op1->AsOp()->gtGetOp2();
11281+
GenTree* addOp2 = effOp1->gtGetOp2();
1128111282
if (addOp2->IsCnsIntOrI())
1128211283
{
1128311284
ssize_t offset = addOp2->AsIntCon()->gtIconVal;

src/tests/JIT/Regression/JitBlue/Runtime_34170/Runtime_34170.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public FloatNonAlignedFieldWithSmallOffset(float a)
2121
[StructLayout(LayoutKind.Explicit)]
2222
internal struct FloatNonAlignedFieldWithLargeOffset
2323
{
24-
[FieldOffset(1021)]
24+
[FieldOffset(0x10001)]
2525
public float field;
2626

2727
public FloatNonAlignedFieldWithLargeOffset(float a)
@@ -45,7 +45,7 @@ public DoubleNonAlignedFieldWithSmallOffset(float a)
4545
[StructLayout(LayoutKind.Explicit)]
4646
internal struct DoubleNonAlignedFieldWithLargeOffset
4747
{
48-
[FieldOffset(1021)]
48+
[FieldOffset(0x10001)]
4949
public double field;
5050

5151
public DoubleNonAlignedFieldWithLargeOffset(float a)

0 commit comments

Comments
 (0)