Instead of calculating a^2, b^2, (a+b)^2 and (a-b)^2, calculate only a^2, b^2 and 2*a*b in each iteration and derive the latter parts from these three at the end. Before and after: A78 ac3_sum_square_bufferfly_int32_neon: 484.8 ( 2.00x) ac3_sum_square_bufferfly_int32_neon: 468.2 ( 2.08x) A72 ac3_sum_square_bufferfly_int32_neon: 793.6 ( 1.26x) ac3_sum_square_bufferfly_int32_neon: 527.3 ( 1.92x)
Unified · Split
| @@ -69,21 +69,20 @@ function ff_ac3_sum_square_butterfly_int32_neon, export=1 · 68 unmodified lines | |||
| 69 | movi v0.2d, #0 | 69 | movi v0.2d, #0 |
| 70 | movi v1.2d, #0 | 70 | movi v1.2d, #0 |
| 71 | movi v2.2d, #0 | 71 | movi v2.2d, #0 |
| 72 | movi v3.2d, #0 | ||
| 73 | 1: ld1 {v4.2s}, [x1], #8 | 72 | 1: ld1 {v4.2s}, [x1], #8 |
| 74 | ld1 {v5.2s}, [x2], #8 | 73 | ld1 {v5.2s}, [x2], #8 |
| 75 | add v6.2s, v4.2s, v5.2s | ||
| 76 | sub v7.2s, v4.2s, v5.2s | ||
| 77 | smlal v0.2d, v4.2s, v4.2s | ||
| 78 | smlal v1.2d, v5.2s, v5.2s | ||
| 79 | smlal v2.2d, v6.2s, v6.2s | ||
| 80 | smlal v3.2d, v7.2s, v7.2s | ||
| 81 | subs w3, w3, #2 | 74 | subs w3, w3, #2 |
| 75 | smlal v0.2d, v4.2s, v4.2s // sum of a^2 | ||
| 76 | smlal v1.2d, v5.2s, v5.2s // sum of b^2 | ||
| 77 | sqdmlal v2.2d, v4.2s, v5.2s // sum of 2ab | ||
| 82 | b.gt 1b | 78 | b.gt 1b |
| 83 | addp d0, v0.2d | 79 | addp d0, v0.2d |
| 84 | addp d1, v1.2d | 80 | addp d1, v1.2d |
| 85 | addp d2, v2.2d | 81 | addp d2, v2.2d |
| 86 | addp d3, v3.2d | 82 | sub d3, d0, d2 // a^2 + b^2 - 2ab |
| 83 | add d2, d0, d2 | ||
| 84 | add d3, d3, d1 // a^2 + b^2 + 2ab | ||
| 85 | add d2, d2, d1 | ||
| 87 | st1 {v0.1d-v3.1d}, [x0] | 86 | st1 {v0.1d-v3.1d}, [x0] |
| 88 | ret | 87 | ret |
| 89 | endfunc | 88 | endfunc |