]> git.ipfire.org Git - thirdparty/gcc.git/commit
aarch64: Remove redundant zero-extends with LDAR
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>
Thu, 6 Oct 2022 11:09:28 +0000 (12:09 +0100)
committerKyrylo Tkachov <kyrylo.tkachov@arm.com>
Thu, 6 Oct 2022 11:09:28 +0000 (12:09 +0100)
commit33b93ac3f2fb68a2da0d42fd692fe59533f7a84f
tree3fa7370fdc7bf579f8f7c1869cd52a9636e08cbf
parentbadd1ac23d24664b2258b1db4d49f37a3f60ccca
aarch64: Remove redundant zero-extends with LDAR

Like other loads in AArch64, the LDARB,LDARH,LDAR instructions clear out the top part of their
destination register and we can thus avoid having to explicitly zero-extend it.
We were missing a combine pattern that this patch adds.

For one of the examples in the testcase we generated:
load_uint8_t_ext_uint16_t:
        adrp    x0, .LANCHOR0
        add     x0, x0, :lo12:.LANCHOR0
        ldarb   w0, [x0]
        and     w0, w0, 255
        ret

but now generate:
load_uint8_t_ext_uint16_t:
        adrp    x0, .LANCHOR0
        add     x0, x0, :lo12:.LANCHOR0
        ldarb   w0, [x0]
        ret

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/ChangeLog:

* config/aarch64/atomics.md (*atomic_load<ALLX:mode>_zext<SD_HSDI:mode>):
New pattern.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/ldar_2.c: New test.
gcc/config/aarch64/atomics.md
gcc/testsuite/gcc.target/aarch64/ldar_2.c [new file with mode: 0644]