}
)
+(define_insn "*atomic_load<ALLX:mode>_zext<SD_HSDI:mode>"
+ [(set (match_operand:SD_HSDI 0 "register_operand" "=r")
+ (zero_extend:SD_HSDI
+ (unspec_volatile:ALLX
+ [(match_operand:ALLX 1 "aarch64_sync_memory_operand" "Q")
+ (match_operand:SI 2 "const_int_operand")] ;; model
+ UNSPECV_LDA)))]
+ "GET_MODE_SIZE (<SD_HSDI:MODE>mode) > GET_MODE_SIZE (<ALLX:MODE>mode)"
+ {
+ enum memmodel model = memmodel_from_int (INTVAL (operands[2]));
+ if (is_mm_relaxed (model) || is_mm_consume (model) || is_mm_release (model))
+ return "ldr<ALLX:atomic_sfx>\t%<ALLX:w>0, %1";
+ else
+ return "ldar<ALLX:atomic_sfx>\t%<ALLX:w>0, %1";
+ }
+)
+
(define_insn "atomic_load<mode>"
[(set (match_operand:ALLI 0 "register_operand" "=r")
(unspec_volatile:ALLI
--- /dev/null
+/* Test that the zero-extending patterns for LDAR are used. */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#include <stdint.h>
+
+uint8_t v_uint8_t;
+uint16_t v_uint16_t;
+uint32_t v_uint32_t;
+uint64_t v_uint64_t;
+
+#define FUNC(FROM, TO) \
+TO \
+load_##FROM##_ext_##TO (void) \
+{ \
+ return __atomic_load_n (&v_##FROM, __ATOMIC_ACQUIRE); \
+}
+
+FUNC (uint8_t, uint16_t)
+FUNC (uint8_t, uint32_t)
+FUNC (uint8_t, uint64_t)
+FUNC (uint16_t, uint32_t)
+FUNC (uint16_t, uint64_t)
+FUNC (uint32_t, uint64_t)
+
+/* { dg-final { scan-assembler-not {and\tw[0-9+], w[0-9]+, 255} } } */
+/* { dg-final { scan-assembler-not {uxtw\tx[0-9+], w[0-9]+} } } */