From a7b6f2c16e3b25be251c9f4570d8c2249cb382ac Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Tue, 3 Oct 2023 14:57:57 +0200 Subject: [PATCH] JIT: Expand unaligned address recognition for ARM32 The JIT has some backwards compatibility for accessing unaligned float fields on ARM32. With physical promotion, we can end up with some new patterns that we didn't handle. Expand the pattern matching to handle a constant address unaligned address. Fix #92382 --- src/coreclr/jit/morph.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 5082308aa59070..6fa8a90d3bdfb2 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -9889,18 +9889,18 @@ GenTree* Compiler::fgMorphFinalizeIndir(GenTreeIndir* indir) GenTree* addr = indir->Addr(); #ifdef TARGET_ARM - GenTree* effAddr = addr->gtEffectiveVal(true); - // Check for a misalignment floating point indirection. - if (effAddr->OperIs(GT_ADD) && varTypeIsFloating(indir)) + if (varTypeIsFloating(indir)) { - GenTree* addOp2 = effAddr->gtGetOp2(); - if (addOp2->IsCnsIntOrI()) + // Check for a misaligned floating point indirection. + GenTree* effAddr = addr->gtEffectiveVal(true); + target_ssize_t offset; + FieldSeq* fldSeq; + gtPeelOffsets(&effAddr, &offset, &fldSeq); + + if (((offset % genTypeSize(TYP_FLOAT)) != 0) || + (effAddr->IsCnsIntOrI() && ((effAddr->AsIntConCommon()->IconValue() % genTypeSize(TYP_FLOAT)) != 0))) { - ssize_t offset = addOp2->AsIntCon()->IconValue(); - if ((offset % genTypeSize(TYP_FLOAT)) != 0) - { - indir->gtFlags |= GTF_IND_UNALIGNED; - } + indir->gtFlags |= GTF_IND_UNALIGNED; } } #endif // TARGET_ARM