bzip2: work around bad compiler optimization
authorDenys Vlasenko <vda.linux@googlemail.com>
Sun, 4 Feb 2018 23:34:08 +0000 (00:34 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 4 Feb 2018 23:34:08 +0000 (00:34 +0100)
commitc2a51b0cf16918482c993c4998a2a920e499a43f
treef138a8f9dfc180c60446e682ab4436c3bdfad127
parentf75a7c04397b8b3409b5c4f5a4438654b6b830ce
bzip2: work around bad compiler optimization

gc-6.1.1 x86_64:
function                                             old     new   delta
generateMTFValues                                    380     367     -13

gcc-4.3.1 386:
function                                             old     new   delta
inner_loop                                             -      41     +41
generateMTFValues                                    357     294     -63
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 41/-63)            Total: -22 bytes

gcc-6.3.0 386:
function                                             old     new   delta
inner_loop                                             -      36     +36
generateMTFValues                                    363     250    -113
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 36/-113)           Total: -77 bytes

The last case, gcc-6.3.0, runs almost 3 times faster after this change.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
archival/libarchive/bz/compress.c