diff --git a/src/coreclr/jit/lower.cpp b/src/coreclr/jit/lower.cpp index 5dd38af4cd04cf..310cb99d3c6787 100644 --- a/src/coreclr/jit/lower.cpp +++ b/src/coreclr/jit/lower.cpp @@ -7684,11 +7684,11 @@ bool Lowering::TryCreateAddrMode(GenTree* addr, bool isContainable, GenTree* par } #ifdef TARGET_ARM64 - if (parent->OperIsIndir() && parent->AsIndir()->IsVolatile() && - !m_compiler->compOpportunisticallyDependsOn(InstructionSet_Rcpc2)) + if (parent->OperIs(GT_STOREIND) && parent->AsIndir()->IsVolatile() && + m_compiler->codeGen->gcInfo.gcIsWriteBarrierStoreIndNode(parent->AsStoreInd())) { - // For Arm64 we avoid using LEA for volatile INDs - // because we won't be able to use ldar/star + // Early out here so we don't report an RCPC2 dependency for a store that will ultimately + // be a write barrier instead of a volatile RCPC2 store return false; } @@ -7734,8 +7734,6 @@ bool Lowering::TryCreateAddrMode(GenTree* addr, bool isContainable, GenTree* par // Generally, we try to avoid creating addressing modes for volatile INDs so we can then use // ldar/stlr instead of ldr/str + dmb. Although, with Arm 8.4+'s RCPC2 we can handle unscaled // addressing modes (if the offset fits into 9 bits) - assert(m_compiler->compIsaSupportedDebugOnly(InstructionSet_Rcpc2)); - if ((scale > 1) || (!emitter::emitIns_valid_imm_for_unscaled_ldst_offset(offset)) || (index != nullptr)) { return false; @@ -7771,6 +7769,14 @@ bool Lowering::TryCreateAddrMode(GenTree* addr, bool isContainable, GenTree* par return false; } +#ifdef TARGET_ARM64 + if (parent->OperIsIndir() && parent->AsIndir()->IsVolatile() && + !m_compiler->compOpportunisticallyDependsOn(InstructionSet_Rcpc2)) + { + return false; + } +#endif + JITDUMP("Addressing mode:\n"); JITDUMP(" Base\n "); DISPNODE(base);