From looking at godbolt gcc 8.3.0 optimizes that branch into the conditional expression while 13.2.0 doesn't
Going back through my own builds of perl on Windows, I can see that the rot goes back as far as gcc-10.
I don't know if gcc-9 was afflicted with this same issue as I don't have a perl that was built with gcc-9.
Incidentally, things are much better with perl-5.42.0 built using Microsoft's Visual Studio 2022:
v5.42.0
String length: 100000
Rate c4 c3
c4 13558/s -- -8%
c3 14740/s 9% --
(Well done, them ;-)
BTW, the OP will probably be able to use gcc-8.3.0 to build the script, and reap the benefits of the better optimization capabilities provided by gcc-8.3.0.
I inserted the following just prior to the "
use Inline C => << 'END_OF_C';" in the OP's script.
use Inline C => Config =>
# Force recompilation
FORCE_BUILD => 1,
# Set CC to to path to gcc.exe version 8.3.0
CC => 'C:/sp/_64/sp-5.32.0/c/bin/gcc.exe',
# View build output
BUILD_NOISY => 1,
;
That worked fine for me on my build of perl-5.42.0, using gcc-15.1.0:
v5.42.0
String length: 100000
Rate c3 c4
c3 14460/s -- -0%
c4 14531/s 0% --
Without that modification, the output was:
v5.42.0
String length: 100000
Rate c4 c3
c4 3528/s -- -76%
c3 14777/s 319% --
UPDATE:
I tried that same hack of using gcc.exe version 8.3.0 with current blead (built using gcc-15.2.0) and it failed with:
try2_pl_62b5.c: loadable library and perl binaries are mismatched (got
+ first handshake key 0000000012e00080, needed 0000000012d00080)
Looks like us hackers have now been deprived of yet another liberty.
It's a bit more fickle than I thought. The hacked script works fine for my own build of perl-5.42.0, but not for Strawberry's build of perl-5.42.0. (There are small differences between those two builds of 5.42.0, but it would make better sense to me if it was the other way around. Anyway .... whilst I find this to be tantalizingly interesting, it's not massively important.)
(If it's going to crash, I would prefer that they let it just do that - rather than forbid something simply because the practice is deemed to be dubious.)
Cheers,
Rob