simplification of halfrev2 algorithm (really neat)
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 22 Jul 2021 14:24:00 +0000 (15:24 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 22 Jul 2021 14:24:00 +0000 (15:24 +0100)
src/openpower/decoder/isa/fastdctlee.py

index f9f481b7f0187dee8b7a691c09bf8449ad9a5dbf..f26414613ac6469e0f3d3c60a5685ea32a358c52 100644 (file)
@@ -102,8 +102,7 @@ def halfrev2(vec, pre_rev=True):
             ri = i
             bl = i.bit_length()
             for ji in range(1, bl):
-                if (1<<ji) & i:
-                    ri ^= ((1<<ji)-1)
+                ri ^= (i >> ji)
             res.append(vec[ri])
     return res