]> git.ipfire.org Git - thirdparty/gcc.git/commit
Alpha: Also use tree information to get base block alignment
authorMaciej W. Rozycki <macro@orcam.me.uk>
Wed, 25 Dec 2024 22:23:40 +0000 (22:23 +0000)
committerMaciej W. Rozycki <macro@orcam.me.uk>
Wed, 25 Dec 2024 22:23:40 +0000 (22:23 +0000)
commite0dae4da4c45e3959b0624551f80283c45a60446
tree34d1a78fdef342679fd01b8575c9858f29440288
parent524fedd7f658f9c57e5f230f21cadf406c5d5011
Alpha: Also use tree information to get base block alignment

We hardly ever emit code using machine instructions for aligned memory
accesses for block move and clear operation and the reason for this
appears to be that suboptimal alignment is often passed by the caller
and then we only try to find a better alignment by checking pseudo
register pointer alignment information, and from observation it's most
often only set for stack frame references.

This code originates from before Tree SSA days and we can do better
nowadays, by looking up the original tree node associated with a MEM
RTL, so implement this approach, factoring out repeating code from
`alpha_expand_block_move' and `alpha_expand_block_clear' to a new
function.

In some cases howewer tree information is not available while pointer
alignment is, such as with the case concerned with PR target/115459,
where we have:

(gdb) pr orig_src
(mem:BLK (plus:DI (reg/f:DI 65 virtual-stack-vars [ lock.206_2 ])
        (const_int 8368 [0x20b0])) [8  S18 A8])
(gdb) pr orig_dst
(mem/j/c:BLK (plus:DI (reg/f:DI 65 virtual-stack-vars [ lock.206_2 ])
        (const_int 8208 [0x2010])) [8 MEM[(struct gnat__debug_pools__print_info_stdout__internal__L_18__B1182b__S1183b___PAD *)_339].F[1 ...]{lb: 1 sz: 1}+0 S18 A128])
(gdb)

showing no tree information and the alignment of 8 only for `orig_src',
while indeed REGNO_POINTER_ALIGN returns 128 for pseudo 65.  So retain
the old approach and return the largest alignment determined and its
associated offset.

Add test cases accordingly and remove XFAILs from memclr-a2-o1-c9-ptr.c
now that it does get aligned code produced now.

gcc/
* config/alpha/alpha.cc
(alpha_get_mem_rtx_alignment_and_offset): New function.
(alpha_expand_block_move, alpha_expand_block_clear): Use it for
alignment retrieval.

gcc/testsuite/
* gcc.target/alpha/memclr-a2-o1-c9-ptr.c: Remove XFAILs.
* gcc.target/alpha/memcpy-di-aligned.c: New file.
* gcc.target/alpha/memcpy-di-unaligned.c: New file.
* gcc.target/alpha/memcpy-di-unaligned-dst.c: New file.
* gcc.target/alpha/memcpy-di-unaligned-src.c: New file.
gcc/config/alpha/alpha.cc
gcc/testsuite/gcc.target/alpha/memclr-a2-o1-c9-ptr.c
gcc/testsuite/gcc.target/alpha/memcpy-di-aligned.c [new file with mode: 0644]
gcc/testsuite/gcc.target/alpha/memcpy-di-unaligned-dst.c [new file with mode: 0644]
gcc/testsuite/gcc.target/alpha/memcpy-di-unaligned-src.c [new file with mode: 0644]
gcc/testsuite/gcc.target/alpha/memcpy-di-unaligned.c [new file with mode: 0644]