From: Luke Kenneth Casson Leighton Date: Mon, 19 Jul 2021 14:53:17 +0000 (+0100) Subject: simplify DCT code X-Git-Tag: xlen-bcd~252 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=144715292481a4489178690e3bd0c6ceb5f72b2a;p=openpower-isa.git simplify DCT code --- diff --git a/src/openpower/decoder/isa/fastdct-test.py b/src/openpower/decoder/isa/fastdct-test.py index 872cfb5c..25a16f3d 100644 --- a/src/openpower/decoder/isa/fastdct-test.py +++ b/src/openpower/decoder/isa/fastdct-test.py @@ -28,7 +28,7 @@ import fastdctlee, naivedct class FastDctTest(unittest.TestCase): def test_fast_dct_lee_vs_naive(self): - for i in range(3, 4): + for i in range(3, 10): n = 2**i vector = FastDctTest.nonrandom_vector(n) expect = naivedct.transform(vector) diff --git a/src/openpower/decoder/isa/fastdctlee.py b/src/openpower/decoder/isa/fastdctlee.py index 97b95363..425c5e33 100644 --- a/src/openpower/decoder/isa/fastdctlee.py +++ b/src/openpower/decoder/isa/fastdctlee.py @@ -164,10 +164,9 @@ def transform2(vec): for i in ir: k = 0 j = list(range(i, i + halfsize)) - jr = list(range(i+halfsize, i + size)) - jr.reverse() - print (" xform jr", j, jr) - for ci, (jl, jh) in enumerate(zip(j, jr)): + print (" xform j", j) + for ci, jl in enumerate(j): + jh = i+size-jl-1 t1, t2 = vec[ri[jl]], vec[ri[jh]] # normally DCT would use jl+halfsize not jh, here. # to be able to work in-place, the idea is to perform a @@ -186,7 +185,8 @@ def transform2(vec): # incredibly... bizarrely... this works *without* having # to do anything else. hz2 = halfsize // 2 # can be zero which stops reversing 1-item lists - for ci, (jl, jh) in enumerate(zip(j[:hz2], jr[:hz2])): + for jl in j[:hz2]: + jh = i+size-jl-1 tmp = ri[jl+halfsize] ri[jl+halfsize] = ri[jh] ri[jh] = tmp