aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/aarch64/atomics.md
diff options
context:
space:
mode:
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>2022-10-06 12:09:28 +0100
committerKyrylo Tkachov <kyrylo.tkachov@arm.com>2022-10-06 12:09:28 +0100
commit33b93ac3f2fb68a2da0d42fd692fe59533f7a84f (patch)
tree3fa7370fdc7bf579f8f7c1869cd52a9636e08cbf /gcc/config/aarch64/atomics.md
parentbadd1ac23d24664b2258b1db4d49f37a3f60ccca (diff)
downloadgcc-33b93ac3f2fb68a2da0d42fd692fe59533f7a84f.zip
gcc-33b93ac3f2fb68a2da0d42fd692fe59533f7a84f.tar.gz
gcc-33b93ac3f2fb68a2da0d42fd692fe59533f7a84f.tar.bz2
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.
Diffstat (limited to 'gcc/config/aarch64/atomics.md')
-rw-r--r--gcc/config/aarch64/atomics.md17
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/config/aarch64/atomics.md b/gcc/config/aarch64/atomics.md
index 9048700..bc95f6d 100644
--- a/gcc/config/aarch64/atomics.md
+++ b/gcc/config/aarch64/atomics.md
@@ -640,6 +640,23 @@
}
)
+(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