| 1 | ## natural assembly |
| 2 | * no register dependency, no penalty |
| 3 | ``` |
| 4 | ld1 {v0.4s}, [r0], #16 |
| 5 | fmla v10.4s, v16.4s, v24.s[0] |
| 6 | fmla v11.4s, v16.4s, v24.s[1] |
| 7 | fmla v12.4s, v16.4s, v24.s[2] |
| 8 | fmla v13.4s, v16.4s, v24.s[3] |
| 9 | ``` |
| 10 | |
| 11 | ## A53 |
| 12 | * 128bit vector load cannot be dual issued with fmla, wait 2 cycles |
| 13 | * 64bit vector load cannot be dual issued with fmla, wait 1 cycle |
| 14 | * 64bit integer load can be dual issued with fmla, no penalty |
| 15 | * pointer update can be dual issued with fmla, no penalty |
| 16 | * 64bit vector load and 64bit vector insert can be dual issued, no penalty |
| 17 | * any vector load cannot be issued on the 4th cycle of each fmla (enters the accumulator pipeline) |
| 18 | |
| 19 | ### practical guide |
| 20 | * use 64bit vector load only |
| 21 | * issue vector load every three fmla |
| 22 | * 1 cycle to load 64bit, dual issue with the previous interleaved 64bit insert |
| 23 | * load the remaining 64bit into integer register, dual issue with fmla |
| 24 | * update pointer, dual issue with fmla |
| 25 | * insert 64bit into vector from integer register, dual issue with the next interleaved 64bit load |
| 26 | * add nop every three fmla if no load, seems to be faster |
| 27 | ``` |
| 28 | ldr d0, [r0] // 1 cycle, v0 first 64bit |
| 29 | fmla |
| 30 | ldr x23, [r0, #8] // 0 cycle, v0 second 64bit to temp register |
| 31 | fmla |
| 32 | add r0, r0, #16 // 0 cycle, update pointer |
| 33 | fmla |
| 34 | ldr d1, [r0] // 1 cycle, v1 first 64bit |
| 35 | ins v0.d[1], x23 // 0 cycle, v0 second 64bit complete |
| 36 | fmla |
| 37 | ldr x23, [r0, #8] // 0 cycle, v1 second 64bit to temp register |
| 38 | fmla |
| 39 | add r0, r0, #16 // 0 cycle, update pointer |
| 40 | fmla |
| 41 | ins v1.d[1], x23 // 1 cycle, v1 second 64bit complete |
| 42 | nop |
| 43 | fmla |
| 44 | fmla |
| 45 | fmla |
| 46 | nop |
| 47 | nop |
| 48 | fmla |
| 49 | fmla |
| 50 | fmla |
| 51 | ``` |
| 52 | |
| 53 | ## A55 |
| 54 | * Limited by the number of neon register read and write ports, most neon instructions cannot be dual-issued. |
| 55 | * neon instructions have different latencies |
| 56 | * 128bit vector load cannot be issued with fmla, WAR wait 2 cycles |
| 57 | * 64bit integer load can be dual issued with fmla, no penalty |
| 58 | * pointer update can be dual issued with fmla, no penalty |
| 59 | * 64bit vector insert can be dual issued with fmla, no penalty |
| 60 | |
| 61 | ### practical guide |
| 62 | * A55 supports 128bit load and 256bit write in one clock. Support dual emission of two 64bit vector loads or single emission of 128bit vector load |
| 63 | * `ldr`, dual issue with fmla |
| 64 | * load the remaining 64bit into integer register, dual issue with fmla |
| 65 | * update pointer, dual issue with fmla |
| 66 | * insert 64bit into vector from integer register, dual issue with fmla |
| 67 | * interleaved load loose register dependency |
| 68 | * nop trick is not needed |
| 69 | * Loop unrolling fma reduces pipeline bubbles |
| 70 | * Some data type conversion neon instructions can be dual issued, such as `fsvts` |
| 71 | ``` |
| 72 | ldr d0, [r0] // 0 cycle, v0 first 64bit |
| 73 | fmla |
| 74 | ldr x23, [r0, #8] // 0 cycle, v0 second 64bit to temp register |
| 75 | fmla |
| 76 | add r0, r0, #16 // 0 cycle, update pointer |
| 77 | fmla |
| 78 | ldr d1, [r0] // 0 cycle, v1 first 64bit |
| 79 | fmla |
| 80 | ins v0.d[1], x23 // 0 cycle, v0 second 64bit complete |
| 81 | fmla |
| 82 | ldr x23, [r0, #8] // 0 cycle, v1 second 64bit to temp register |
| 83 | fmla |
| 84 | add r0, r0, #16 // 0 cycle, update pointer |
| 85 | fmla |
| 86 | ins v1.d[1], x23 // 0 cycle, v1 second 64bit complete |
| 87 | fmla |
| 88 | ``` |