Skip to content

Commit e721750

Browse files
t-a-kkhwilliamson
authored andcommitted
pp.c, pp_hot.c: Use SvIsUV rather than SvUOK after SvIV_please_nomg
SvUOK(x) inside a block guarded by SvIV_please_nomg(x) can be replaced by SvIsUV(x) because SvIV_please_nomg implies SvIOK. This will save a few code size and runtime CPU cycles, because many CPUs can do single-bit tests like SvIsUV in fewer instructions than multi-bit tests like SvUOK.
1 parent a61bf55 commit e721750

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

pp.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ PP(pp_pow)
11541154
bool baseuok;
11551155
UV baseuv;
11561156

1157-
if (SvUOK(svr)) {
1157+
if (SvIsUV(svr)) {
11581158
power = SvUVX(svr);
11591159
} else {
11601160
const IV iv = SvIVX(svr);
@@ -1165,7 +1165,7 @@ PP(pp_pow)
11651165
}
11661166
}
11671167

1168-
baseuok = SvUOK(svl);
1168+
baseuok = SvIsUV(svl);
11691169
if (baseuok) {
11701170
baseuv = SvUVX(svl);
11711171
} else {
@@ -1375,8 +1375,8 @@ PP(pp_multiply)
13751375
we know the left is integer. */
13761376
/* Left operand is defined, so is it IV? */
13771377
if (SvIV_please_nomg(svl)) {
1378-
bool auvok = SvUOK(svl);
1379-
bool buvok = SvUOK(svr);
1378+
bool auvok = SvIsUV(svl);
1379+
bool buvok = SvIsUV(svr);
13801380
UV alow;
13811381
UV blow;
13821382
UV product;
@@ -1469,8 +1469,8 @@ PP(pp_divide)
14691469

14701470
#ifdef PERL_TRY_UV_DIVIDE
14711471
if (SvIV_please_nomg(svr) && SvIV_please_nomg(svl)) {
1472-
bool left_non_neg = SvUOK(svl);
1473-
bool right_non_neg = SvUOK(svr);
1472+
bool left_non_neg = SvIsUV(svl);
1473+
bool right_non_neg = SvIsUV(svr);
14741474
UV left;
14751475
UV right;
14761476

@@ -1588,7 +1588,7 @@ PP(pp_modulo)
15881588
SV * const svr = PL_stack_sp[0];
15891589
SV * const svl = PL_stack_sp[-1];
15901590
if (SvIV_please_nomg(svr)) {
1591-
right_neg = !SvUOK(svr);
1591+
right_neg = !SvIsUV(svr);
15921592
if (!right_neg) {
15931593
right = SvUVX(svr);
15941594
} else {
@@ -1618,7 +1618,7 @@ PP(pp_modulo)
16181618
a UV. In range NV has been rounded down to nearest UV and
16191619
use_double false. */
16201620
if (!use_double && SvIV_please_nomg(svl)) {
1621-
left_neg = !SvUOK(svl);
1621+
left_neg = !SvIsUV(svl);
16221622
if (!left_neg) {
16231623
left = SvUVX(svl);
16241624
} else {
@@ -1911,7 +1911,7 @@ PP(pp_subtract)
19111911
} else {
19121912
/* Left operand is defined, so is it IV? */
19131913
if (SvIV_please_nomg(svl)) {
1914-
if ((auvok = SvUOK(svl)))
1914+
if ((auvok = SvIsUV(svl)))
19151915
auv = SvUVX(svl);
19161916
else {
19171917
const IV aiv = SvIVX(svl);
@@ -1929,7 +1929,7 @@ PP(pp_subtract)
19291929
bool result_good = 0;
19301930
UV result;
19311931
UV buv;
1932-
bool buvok = SvUOK(svr);
1932+
bool buvok = SvIsUV(svr); /* svr is always IOK here */
19331933

19341934
if (buvok)
19351935
buv = SvUVX(svr);
@@ -2248,9 +2248,9 @@ Perl_do_ncmp(pTHX_ SV* const left, SV * const right)
22482248
#ifdef PERL_PRESERVE_IVUV
22492249
/* Fortunately it seems NaN isn't IOK */
22502250
if (SvIV_please_nomg(right) && SvIV_please_nomg(left)) {
2251-
if (!SvUOK(left)) {
2251+
if (!SvIsUV(left)) {
22522252
const IV leftiv = SvIVX(left);
2253-
if (!SvUOK(right)) {
2253+
if (!SvIsUV(right)) {
22542254
/* ## IV <=> IV ## */
22552255
const IV rightiv = SvIVX(right);
22562256
return (leftiv > rightiv) - (leftiv < rightiv);
@@ -2265,7 +2265,7 @@ Perl_do_ncmp(pTHX_ SV* const left, SV * const right)
22652265
}
22662266
}
22672267

2268-
if (SvUOK(right)) {
2268+
if (SvIsUV(right)) {
22692269
/* ## UV <=> UV ## */
22702270
const UV leftuv = SvUVX(left);
22712271
const UV rightuv = SvUVX(right);

pp_hot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,7 +1920,7 @@ PP(pp_add)
19201920
} else {
19211921
/* Left operand is defined, so is it IV? */
19221922
if (SvIV_please_nomg(svl)) {
1923-
if ((auvok = SvUOK(svl)))
1923+
if ((auvok = SvIsUV(svl)))
19241924
auv = SvUVX(svl);
19251925
else {
19261926
const IV aiv = SvIVX(svl);
@@ -1938,7 +1938,7 @@ PP(pp_add)
19381938
bool result_good = 0;
19391939
UV result;
19401940
UV buv;
1941-
bool buvok = SvUOK(svr);
1941+
bool buvok = SvIsUV(svr); /* svr is always IOK here */
19421942

19431943
if (buvok)
19441944
buv = SvUVX(svr);

0 commit comments

Comments
 (0)