<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/65284>65284</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            ldapur/stlur are not recognized
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          EgorBo
      </td>
    </tr>
</table>

<pre>
    It seems that LLVM doesn't try to optimize acquire/release loads/stores with RCPC2's instructions (namely, `ldapur`/`stlur`) which support imm offsets, e.g.:
```cpp
#include <atomic>

class MyClass
{
public:
 std::atomic<int> a1; 
    std::atomic<int> a2;

    void SetA2() { a2.store(42, std::memory_order_release); }
    int GetA2() { return a2.load(std::memory_order_acquire); }
};

void Test_set(MyClass* p)
{
    p->SetA2();
}

int Test_get(MyClass* p)

 return p->GetA2();
}
```
Current machine code for `Test*` functions:
```asm
Test_set(MyClass*):
        add     x8, x0, #4
 mov     w9, #42
        stlr    w9, [x8]
 ret

Test_get(MyClass*):
        add     x8, x0, #4
        ldapr w0, [x8]
        ret
```
Expected code on arm64 v8.4+ (feat_rcpc2):
```asm
Test_set(MyClass*):
        mov     w9, #42
 stlur   w9, [x0, #4]
        ret

Test_get(MyClass*):
 ldapur  w0, [x0, #4]
 ret
```



https://godbolt.org/z/h4neohx7r
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVd-P4jYQ_muGl9Eh44T8eMgDsORU6U6q2qqvK-MMxFUSp_ZkF_avrxzCAnfsqmqtyI7jmW---Tyxlffm0BEVsFzD8mmmBq6tK7YH69Z2trPVqfiF0RO1HrlWjN--_fkdK0u-A5kysjshW7Q9m9a8ESr992AcgSwdNaQ8YWNV5UGWnq0jj6-Ga_xt8-tGgkw9ms6zGzQb23kEmXWqpeYEcoOQiKZS_eAgESBLSITnZprl-FobXaMf-t46RtO2aPd7T-yDK80Pc4hWIJ5ArILD-Oi-n77IyHS6GSpCiDaKbWs0RNtpcex1o7zH76dNGKeFdH1-6YddExwmU_RchUm0uiBtTMcQbVEtIFrjZIX4iaGEaH0bPli_WFPh78QrCTILKUO6RiXno44gs1iGVN8xW2qtOz1bV5F7nrQHmY8M0qcrrOkYv_6A6ogH1wXwsFkgs8eo73t7jxpe7umP1P8gz8-eGGR20VGusA_e93oGVv0XiLY3yV4B36OMfWA_Ah8-Bb6IPiU2on_9FP1SJOfpZnCOOsZW6dp0hNpWhHvrQlGG8CCDB-6H7ly5Pxeb8u35y0MZRg43ex2aqqpxPGZhX49i_AdkFE9WrX0Zl1_zy4K89_fcuBuD5fqYwfLpKsStjA8l_A-kphb-U4ev4kHgqV3j3wu9PfakmaqzwrZD5dokxpdsHoNchwNhT4qfne61vOX3P3T-WMjxfLlT8Jrvxwn9S0HPZxneqPQA_COZfu5r5n4sO1mCLA-22tmG59YdQJZvIMs67sjWx9TNqiKq8ihXMyoWSR5lqRSxmNXFPl8klCsRp_vdLlmQFFmcqFSS1mJZqXxmCilkJHKxFEKIWMx1vFxEiY5EvBdKLVOIBbXKNPOmeWlD7JnxfqAiWcosnjVqR42_3CuuCEZfdsPBQywa49lf3dhwQ8V02oebIuyDcoSdZXSk7aEzb1TNBtcUPyRuuB52c21bkGXAm4YvvbN_kWaQ5cgpXEAjrX8CAAD__99e7b0">