Skip to content

ARM64: Use STLUR/LDUR on arm64-v8.4+ #64457

@EgorBo

Description

@EgorBo

As per #64354 (comment)

For cases when we need to access a field using Store-Release semantic with an offset we can do that in a single instruction stlur/ldur.

Thanks to @neon-sunset for checking it on Apple M1 (arm64 v8.5), e.g.:

class MyClass
{
public:
    std::atomic<int> x;
    std::atomic<int> y;
};

void Foo(MyClass* cls)
{
    cls->x = 42;
    cls->y = 42;
}

compiles down to:

Foo(MyClass*):
        mov     w1, 42
        stlr    w1, [x0]
        stlur   w1, [x0, 4]
        ret

while we currently emit something like:

        mov     w1, 42
        stlr    w1, [x0]
        add     x0, x0, #4
        stlr    w1, [x0]
        ret

category:cq
theme:basic-cq
skill-level:beginner
cost:small
impact:small

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIhelp wanted[up-for-grabs] Good issue for external contributorstenet-performancePerformance related issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions