From: Luke Kenneth Casson Leighton Date: Wed, 27 Sep 2023 18:44:43 +0000 (+0100) Subject: reduce 4-repeats of identical code down to 1 copy with indices in powmod.py X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=85abafd442636873bcc96cff931a05b5aa9a0856;p=openpower-isa.git reduce 4-repeats of identical code down to 1 copy with indices in powmod.py --- diff --git a/src/openpower/test/bigint/powmod.py b/src/openpower/test/bigint/powmod.py index d25486d3..7e17cc9a 100644 --- a/src/openpower/test/bigint/powmod.py +++ b/src/openpower/test/bigint/powmod.py @@ -97,29 +97,13 @@ def python_mul_algorithm2(a, b): y = [0] * 8 t = [0] * 5 - y[0], ca = addc(y[0], t[0]) - for i in range(4): - y[1 + i], ca = adde(y[1 + i], t[1 + i], ca) - for i in range(4): - y[i], y[4] = maddedu(a[0], b[i], y[4]) - t[4] = 0 - for i in range(4): - t[i], t[4] = maddedu(a[1], b[i], t[4]) - y[1], ca = addc(y[1], t[0]) - for i in range(4): - y[2 + i], ca = adde(y[2 + i], t[1 + i], ca) - t[4] = 0 - for i in range(4): - t[i], t[4] = maddedu(a[2], b[i], t[4]) - y[2], ca = addc(y[2], t[0]) - for i in range(4): - y[3 + i], ca = adde(y[3 + i], t[1 + i], ca) - t[4] = 0 - for i in range(4): - t[i], t[4] = maddedu(a[3], b[i], t[4]) - y[3], ca = addc(y[3], t[0]) - for i in range(4): - y[4 + i], ca = adde(y[4 + i], t[1 + i], ca) + for iy in range(4): + t[4] = 0 + for i in range(4): + t[i], t[4] = maddedu(a[iy], b[i], t[4]) + y[iy], ca = addc(y[iy], t[0]) + for i in range(4): + y[1 + iy + i], ca = adde(y[1 + iy + i], t[1 + i], ca) return y