Skip to content

Commit 41bbdb0

Browse files
committed
Use ConditionProfile in math.acosh() and atanh()
1 parent caf80a5 commit 41bbdb0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,6 +1463,9 @@ public abstract static class AcoshNode extends MathDoubleUnaryBuiltinNode {
14631463
private static final double TWO_POW_P28 = 0x1.0p28;
14641464
private static final double LN_2 = 6.93147180559945286227e-01;
14651465

1466+
private final ConditionProfile largeProfile = ConditionProfile.createBinaryProfile();
1467+
private final ConditionProfile smallProfile = ConditionProfile.createBinaryProfile();
1468+
14661469
@Specialization
14671470
@TruffleBoundary
14681471
@Override
@@ -1482,10 +1485,10 @@ public double doPI(PInt value) {
14821485
@Override
14831486
public double count(double value) {
14841487
checkMathDomainError(value < 1);
1485-
if (value >= TWO_POW_P28) {
1488+
if (largeProfile.profile(value >= TWO_POW_P28)) {
14861489
return Math.log(value) + LN_2;
14871490
}
1488-
if (value <= 2.0) {
1491+
if (smallProfile.profile(value <= 2.0)) {
14891492
double t = value - 1.0;
14901493
return Math.log1p(t + Math.sqrt(2.0 * t + t * t));
14911494
}
@@ -1584,15 +1587,18 @@ public abstract static class AtanhNode extends MathDoubleUnaryBuiltinNode {
15841587

15851588
private static final double TWO_POW_M28 = 0x1.0p-28;
15861589

1590+
private final ConditionProfile closeToZeroProfile = ConditionProfile.createBinaryProfile();
1591+
private final ConditionProfile lessThanHalfProfile = ConditionProfile.createBinaryProfile();
1592+
15871593
@Override
15881594
public double count(double value) {
15891595
double abs = Math.abs(value);
15901596
checkMathDomainError(abs >= 1.0);
1591-
if (abs < TWO_POW_M28) {
1597+
if (closeToZeroProfile.profile(abs < TWO_POW_M28)) {
15921598
return value;
15931599
}
15941600
double t;
1595-
if (abs < 0.5) {
1601+
if (lessThanHalfProfile.profile(abs < 0.5)) {
15961602
t = abs + abs;
15971603
t = 0.5 * Math.log1p(t + t * abs / (1.0 - abs));
15981604
} else {

0 commit comments

Comments
 (0)