add code demonstrating 8 instructions replaced by one in ls016 twin-butterfly
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 29 Apr 2023 16:30:08 +0000 (17:30 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 29 Apr 2023 16:30:08 +0000 (17:30 +0100)
openpower/sv/twin_butterfly.mdwn

index 7b71dca02452196fa25c745e03176e05aea0233f..082dd79e2c0c60bfd806df05359326f245128fbc 100644 (file)
@@ -51,6 +51,32 @@ run in accumulate mode, so in order to calculate the 2-coeff version
 one would just have to call the same instruction with different order a,
 b and a different constant c.
 
+Example taken from libvpx
+<https://chromium.googlesource.com/webm/libvpx/+/refs/heads/main/vpx_dsp/fwd_txfm.c#132>:
+
+```
+    #include <stdint.h>
+    #define ROUND_POWER_OF_TWO(value, n) \
+            (((value) + (1 << ((n)-1))) >> (n))
+    void twin_int(int16_t *t, int16_t x0, int16_t x1, int16_t cospi_16_64) {
+        t[0] = ROUND_POWER_OF_TWO((x0 + x1) * cospi_16_64, 14);
+        t[1] = ROUND_POWER_OF_TWO((x0 - x1) * cospi_16_64, 14);
+    }
+```
+
+8 instructions are required  - replaced by just the one (maddsubrs):
+
+```
+    add 9,5,4
+    subf 5,5,4
+    mullw 9,9,6
+    mullw 5,5,6
+    addi 9,9,8192
+    addi 5,5,8192
+    srawi 9,9,14
+    srawi 5,5,14
+```
+
 ## Integer Butterfly Multiply Add/Sub FFT/DCT
 
 **Add the following to Book I Section 3.3.9.1**