| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-mcpu=sifive-u74 -march=rv64gc -mabi=lp64" } */ |
| 3 |
/* { dg-skip-if "" { *-*-* } { "-O0" "-Os" "-Oz" "-Og" } } */ |
| 4 |
|
| 5 |
|
| 6 |
#define COPY_N(N) \ |
| 7 |
void copy##N (char *src, char *dst) \ |
| 8 |
{ \ |
| 9 |
dst = __builtin_assume_aligned (dst, 4096); \ |
| 10 |
src = __builtin_assume_aligned (src, 4096); \ |
| 11 |
__builtin_memcpy (dst, src, N); \ |
| 12 |
} |
| 13 |
|
| 14 |
/* Emits 1x {ld,sd} and 1x {lhu,lbu,sh,sb}. */ |
| 15 |
COPY_N(11) |
| 16 |
|
| 17 |
/* Emits 1x {ld,sd} and 1x {lw,lbu,sw,sb}. */ |
| 18 |
COPY_N(13) |
| 19 |
|
| 20 |
/* Emits 1x {ld,sd} and 1x {lw,lhu,sw,sh}. */ |
| 21 |
COPY_N(14) |
| 22 |
|
| 23 |
/* Emits 1x {ld,sd} and 1x {lw,lhu,lbu,sw,sh,sb}. */ |
| 24 |
COPY_N(15) |
| 25 |
|
| 26 |
/* Emits 2x {ld,sd} and 1x {lhu,lbu,sh,sb}. */ |
| 27 |
COPY_N(19) |
| 28 |
|
| 29 |
/* Emits 2x {ld,sd} and 1x {lw,lhu,lbu,sw,sh,sb}. */ |
| 30 |
COPY_N(23) |
| 31 |
|
| 32 |
/* The by-pieces infrastructure handles up to 24 bytes. |
| 33 |
So the code below is emitted via cpymemsi/block_move_straight. */ |
| 34 |
|
| 35 |
/* Emits 3x {ld,sd} and 1x {lhu,lbu,sh,sb}. */ |
| 36 |
COPY_N(27) |
| 37 |
|
| 38 |
/* Emits 3x {ld,sd} and 1x {lw,lbu,sw,sb}. */ |
| 39 |
COPY_N(29) |
| 40 |
|
| 41 |
/* Emits 3x {ld,sd} and 1x {lw,lhu,lbu,sw,sh,sb}. */ |
| 42 |
COPY_N(31) |
| 43 |
|
| 44 |
/* { dg-final { scan-assembler-times "ld\t" 17 } } */ |
| 45 |
/* { dg-final { scan-assembler-times "sd\t" 17 } } */ |
| 46 |
|
| 47 |
/* { dg-final { scan-assembler-times "lw\t" 6 } } */ |
| 48 |
/* { dg-final { scan-assembler-times "sw\t" 6 } } */ |
| 49 |
|
| 50 |
/* { dg-final { scan-assembler-times "lhu\t" 7 } } */ |
| 51 |
/* { dg-final { scan-assembler-times "sh\t" 7 } } */ |
| 52 |
|
| 53 |
/* { dg-final { scan-assembler-times "lbu\t" 8 } } */ |
| 54 |
/* { dg-final { scan-assembler-times "sb\t" 8 } } */ |