Branch: refs/heads/blead Home: https://github.com/Perl/perl5 Commit: cd304e76e0a975a4d5600077b2891ed469708009 https://github.com/Perl/perl5/commit/cd304e76e0a975a4d5600077b2891ed469708009 Author: David Mitchell <da...@iabyn.com> Date: 2020-08-27 (Thu, 27 Aug 2020)
Changed paths: M inline.h Log Message: ----------- S_lossless_NV_to_IV(): skip Perl_isnan This inline function was added by v5.31.0-27-g3a019afd6f to consolidate similar code in several places, like pp_add(). It also avoided undefined behaviour, as seen by ASan, by no longer unconditionally trying to cast an NV to IV - ASan would complain when nv was -Inf for example. However that commit introduced a performance regression into common numeric operators like pp_and(). This commit partially claws back performance by skipping the initial test of 'skip if Nan' which called Perl_isnan(). Instead, except on systems where NAN_COMPARE_BROKEN is true, it relies on NaN being compared to anything always being false, and simply rearranges existing conditions nv < IV_MIN etc to be nv >= IV_MIN so that any NaN comparison will trigger a false return. This claws back about half the performance loss. The rest seems unavoidable, since the two range tests for IV_MIN..IV_MAX are an unavoidable part of avoiding undefined behaviour.