pkg/math: undo manual inlining of IsInf and IsNaN

R=rsc
CC=golang-dev
https://golang.org/cl/5484076
diff --git a/src/pkg/math/acosh.go b/src/pkg/math/acosh.go
index 8d55637..c6c8645 100644
--- a/src/pkg/math/acosh.go
+++ b/src/pkg/math/acosh.go
@@ -44,11 +44,9 @@
 		Ln2   = 6.93147180559945286227e-01 // 0x3FE62E42FEFA39EF
 		Large = 1 << 28                    // 2**28
 	)
-	// TODO(rsc): Remove manual inlining of IsNaN
-	// when compiler does it for us
 	// first case is special case
 	switch {
-	case x < 1 || x != x: // x < 1 || IsNaN(x):
+	case x < 1 || IsNaN(x):
 		return NaN()
 	case x == 1:
 		return 0
diff --git a/src/pkg/math/asinh.go b/src/pkg/math/asinh.go
index f786dd9..0defbb9 100644
--- a/src/pkg/math/asinh.go
+++ b/src/pkg/math/asinh.go
@@ -42,10 +42,8 @@
 		NearZero = 1.0 / (1 << 28)            // 2**-28
 		Large    = 1 << 28                    // 2**28
 	)
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
-	if x != x || x > MaxFloat64 || x < -MaxFloat64 { // IsNaN(x) || IsInf(x, 0)
+	if IsNaN(x) || IsInf(x, 0) {
 		return x
 	}
 	sign := false
diff --git a/src/pkg/math/atan2.go b/src/pkg/math/atan2.go
index 3d1b52a..d84b332 100644
--- a/src/pkg/math/atan2.go
+++ b/src/pkg/math/atan2.go
@@ -29,11 +29,9 @@
 func Atan2(y, x float64) float64
 
 func atan2(y, x float64) float64 {
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
-	case y != y || x != x: // IsNaN(y) || IsNaN(x):
+	case IsNaN(y) || IsNaN(x):
 		return NaN()
 	case y == 0:
 		if x >= 0 && !Signbit(x) {
@@ -42,22 +40,22 @@
 		return Copysign(Pi, y)
 	case x == 0:
 		return Copysign(Pi/2, y)
-	case x < -MaxFloat64 || x > MaxFloat64: // IsInf(x, 0):
-		if x > MaxFloat64 { // IsInf(x, 1) {
+	case IsInf(x, 0):
+		if IsInf(x, 1) {
 			switch {
-			case y < -MaxFloat64 || y > MaxFloat64: // IsInf(y, -1) || IsInf(y, 1):
+			case IsInf(y, 0):
 				return Copysign(Pi/4, y)
 			default:
 				return Copysign(0, y)
 			}
 		}
 		switch {
-		case y < -MaxFloat64 || y > MaxFloat64: // IsInf(y, -1) || IsInf(y, 1):
+		case IsInf(y, 0):
 			return Copysign(3*Pi/4, y)
 		default:
 			return Copysign(Pi, y)
 		}
-	case y < -MaxFloat64 || y > MaxFloat64: //IsInf(y, 0):
+	case IsInf(y, 0):
 		return Copysign(Pi/2, y)
 	}
 
diff --git a/src/pkg/math/atanh.go b/src/pkg/math/atanh.go
index e150673..5b5d468 100644
--- a/src/pkg/math/atanh.go
+++ b/src/pkg/math/atanh.go
@@ -46,11 +46,9 @@
 //	Atanh(NaN) = NaN
 func Atanh(x float64) float64 {
 	const NearZero = 1.0 / (1 << 28) // 2**-28
-	// TODO(rsc): Remove manual inlining of IsNaN
-	// when compiler does it for us
 	// special cases
 	switch {
-	case x < -1 || x > 1 || x != x: // x < -1 || x > 1 || IsNaN(x):
+	case x < -1 || x > 1 || IsNaN(x):
 		return NaN()
 	case x == 1:
 		return Inf(1)
diff --git a/src/pkg/math/cbrt.go b/src/pkg/math/cbrt.go
index 09edc0e..8c43f0a 100644
--- a/src/pkg/math/cbrt.go
+++ b/src/pkg/math/cbrt.go
@@ -33,11 +33,9 @@
 		C3 = 6.46502159e-02
 		C4 = 1.412333954e-01
 	)
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
-	case x == 0 || x != x || x < -MaxFloat64 || x > MaxFloat64: // x == 0 || IsNaN(x) || IsInf(x, 0):
+	case x == 0 || IsNaN(x) || IsInf(x, 0):
 		return x
 	}
 	sign := false
diff --git a/src/pkg/math/dim.go b/src/pkg/math/dim.go
index 16363ac..1c634d4 100644
--- a/src/pkg/math/dim.go
+++ b/src/pkg/math/dim.go
@@ -26,13 +26,11 @@
 func Max(x, y float64) float64
 
 func max(x, y float64) float64 {
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
-	case x > MaxFloat64 || y > MaxFloat64: // IsInf(x, 1) || IsInf(y, 1):
+	case IsInf(x, 1) || IsInf(y, 1):
 		return Inf(1)
-	case x != x || y != y: // IsNaN(x) || IsNaN(y):
+	case IsNaN(x) || IsNaN(y):
 		return NaN()
 	case x == 0 && x == y:
 		if Signbit(x) {
@@ -55,13 +53,11 @@
 func Min(x, y float64) float64
 
 func min(x, y float64) float64 {
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
-	case x < -MaxFloat64 || y < -MaxFloat64: // IsInf(x, -1) || IsInf(y, -1):
+	case IsInf(x, -1) || IsInf(y, -1):
 		return Inf(-1)
-	case x != x || y != y: // IsNaN(x) || IsNaN(y):
+	case IsNaN(x) || IsNaN(y):
 		return NaN()
 	case x == 0 && x == y:
 		if Signbit(x) {
diff --git a/src/pkg/math/erf.go b/src/pkg/math/erf.go
index 6d3d9b7..87c70c2 100644
--- a/src/pkg/math/erf.go
+++ b/src/pkg/math/erf.go
@@ -191,14 +191,12 @@
 		Small    = 1.0 / (1 << 28)        // 2**-28
 	)
 	// special cases
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	switch {
-	case x != x: // IsNaN(x):
+	case IsNaN(x):
 		return NaN()
-	case x > MaxFloat64: // IsInf(x, 1):
+	case IsInf(x, 1):
 		return 1
-	case x < -MaxFloat64: // IsInf(x, -1):
+	case IsInf(x, -1):
 		return -1
 	}
 	sign := false
@@ -267,14 +265,12 @@
 func Erfc(x float64) float64 {
 	const Tiny = 1.0 / (1 << 56) // 2**-56
 	// special cases
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	switch {
-	case x != x: // IsNaN(x):
+	case IsNaN(x):
 		return NaN()
-	case x > MaxFloat64: // IsInf(x, 1):
+	case IsInf(x, 1):
 		return 0
-	case x < -MaxFloat64: // IsInf(x, -1):
+	case IsInf(x, -1):
 		return 2
 	}
 	sign := false
diff --git a/src/pkg/math/exp.go b/src/pkg/math/exp.go
index 2a1710a..f31585f 100644
--- a/src/pkg/math/exp.go
+++ b/src/pkg/math/exp.go
@@ -100,13 +100,11 @@
 		NearZero  = 1.0 / (1 << 28) // 2**-28
 	)
 
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
-	case x != x || x > MaxFloat64: // IsNaN(x) || IsInf(x, 1):
+	case IsNaN(x) || IsInf(x, 1):
 		return x
-	case x < -MaxFloat64: // IsInf(x, -1):
+	case IsInf(x, -1):
 		return 0
 	case x > Overflow:
 		return Inf(1)
@@ -145,13 +143,11 @@
 		Underflow = -1.0740e+03
 	)
 
-	// TODO: remove manual inlining of IsNaN and IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
-	case x != x || x > MaxFloat64: // IsNaN(x) || IsInf(x, 1):
+	case IsNaN(x) || IsInf(x, 1):
 		return x
-	case x < -MaxFloat64: // IsInf(x, -1):
+	case IsInf(x, -1):
 		return 0
 	case x > Overflow:
 		return Inf(1)
diff --git a/src/pkg/math/expm1.go b/src/pkg/math/expm1.go
index 15fc25f..8f56e15 100644
--- a/src/pkg/math/expm1.go
+++ b/src/pkg/math/expm1.go
@@ -142,12 +142,10 @@
 	)
 
 	// special cases
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	switch {
-	case x > MaxFloat64 || x != x: // IsInf(x, 1) || IsNaN(x):
+	case IsInf(x, 1) || IsNaN(x):
 		return x
-	case x < -MaxFloat64: // IsInf(x, -1):
+	case IsInf(x, -1):
 		return -1
 	}
 
diff --git a/src/pkg/math/floor.go b/src/pkg/math/floor.go
index a7090f5..9d30629 100644
--- a/src/pkg/math/floor.go
+++ b/src/pkg/math/floor.go
@@ -13,9 +13,7 @@
 func Floor(x float64) float64
 
 func floor(x float64) float64 {
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
-	if x == 0 || x != x || x > MaxFloat64 || x < -MaxFloat64 { // x == 0 || IsNaN(x) || IsInf(x, 0)
+	if x == 0 || IsNaN(x) || IsInf(x, 0) {
 		return x
 	}
 	if x < 0 {
@@ -50,9 +48,7 @@
 func Trunc(x float64) float64
 
 func trunc(x float64) float64 {
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
-	if x == 0 || x != x || x > MaxFloat64 || x < -MaxFloat64 { // x == 0 || IsNaN(x) || IsInf(x, 0)
+	if x == 0 || IsNaN(x) || IsInf(x, 0) {
 		return x
 	}
 	d, _ := Modf(x)
diff --git a/src/pkg/math/frexp.go b/src/pkg/math/frexp.go
index b5458d7..0e26feb 100644
--- a/src/pkg/math/frexp.go
+++ b/src/pkg/math/frexp.go
@@ -16,13 +16,11 @@
 func Frexp(f float64) (frac float64, exp int)
 
 func frexp(f float64) (frac float64, exp int) {
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
 	case f == 0:
 		return f, 0 // correctly return -0
-	case f < -MaxFloat64 || f > MaxFloat64 || f != f: // IsInf(f, 0) || IsNaN(f):
+	case IsInf(f, 0) || IsNaN(f):
 		return f, 0
 	}
 	f, exp = normalize(f)
diff --git a/src/pkg/math/gamma.go b/src/pkg/math/gamma.go
index 7365d8e..2385a53 100644
--- a/src/pkg/math/gamma.go
+++ b/src/pkg/math/gamma.go
@@ -121,7 +121,7 @@
 	const Euler = 0.57721566490153286060651209008240243104215933593992 // A001620
 	// special cases
 	switch {
-	case x < -MaxFloat64 || x != x: // IsInf(x, -1) || IsNaN(x):
+	case IsInf(x, -1) || IsNaN(x):
 		return x
 	case x < -170.5674972726612 || x > 171.61447887182298:
 		return Inf(1)
diff --git a/src/pkg/math/hypot.go b/src/pkg/math/hypot.go
index 233257b..df4d3eb 100644
--- a/src/pkg/math/hypot.go
+++ b/src/pkg/math/hypot.go
@@ -17,13 +17,11 @@
 func Hypot(p, q float64) float64
 
 func hypot(p, q float64) float64 {
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
-	case p < -MaxFloat64 || p > MaxFloat64 || q < -MaxFloat64 || q > MaxFloat64: // IsInf(p, 0) || IsInf(q, 0):
+	case IsInf(p, 0) || IsInf(q, 0):
 		return Inf(1)
-	case p != p || q != q: // IsNaN(p) || IsNaN(q):
+	case IsNaN(p) || IsNaN(q):
 		return NaN()
 	}
 	if p < 0 {
diff --git a/src/pkg/math/j0.go b/src/pkg/math/j0.go
index 5aaf4ab..c20a9b2 100644
--- a/src/pkg/math/j0.go
+++ b/src/pkg/math/j0.go
@@ -89,13 +89,11 @@
 		S03 = 5.13546550207318111446e-07  // 0x3EA13B54CE84D5A9
 		S04 = 1.16614003333790000205e-09  // 0x3E1408BCF4745D8F
 	)
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
-	case x != x: // IsNaN(x)
+	case IsNaN(x):
 		return x
-	case x < -MaxFloat64 || x > MaxFloat64: // IsInf(x, 0):
+	case IsInf(x, 0):
 		return 0
 	case x == 0:
 		return 1
@@ -171,13 +169,11 @@
 		V03    = 2.59150851840457805467e-07  // 0x3E91642D7FF202FD
 		V04    = 4.41110311332675467403e-10  // 0x3DFE50183BD6D9EF
 	)
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
-	case x < 0 || x != x: // x < 0 || IsNaN(x):
+	case x < 0 || IsNaN(x):
 		return NaN()
-	case x > MaxFloat64: // IsInf(x, 1):
+	case IsInf(x, 1):
 		return 0
 	case x == 0:
 		return Inf(-1)
diff --git a/src/pkg/math/j1.go b/src/pkg/math/j1.go
index 278162e..7ac186b 100644
--- a/src/pkg/math/j1.go
+++ b/src/pkg/math/j1.go
@@ -86,13 +86,11 @@
 		S04 = 5.04636257076217042715e-09  // 0x3E35AC88C97DFF2C
 		S05 = 1.23542274426137913908e-11  // 0x3DAB2ACFCFB97ED8
 	)
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
-	case x != x: // IsNaN(x)
+	case IsNaN(x):
 		return x
-	case x < -MaxFloat64 || x > MaxFloat64 || x == 0: // IsInf(x, 0) || x == 0:
+	case IsInf(x, 0) || x == 0:
 		return 0
 	}
 
@@ -168,13 +166,11 @@
 		V03    = 6.22741452364621501295e-09  // 0x3E3ABF1D5BA69A86
 		V04    = 1.66559246207992079114e-11  // 0x3DB25039DACA772A
 	)
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
-	case x < 0 || x != x: // x < 0 || IsNaN(x):
+	case x < 0 || IsNaN(x):
 		return NaN()
-	case x > MaxFloat64: // IsInf(x, 1):
+	case IsInf(x, 1):
 		return 0
 	case x == 0:
 		return Inf(-1)
diff --git a/src/pkg/math/jn.go b/src/pkg/math/jn.go
index 1878df5..a7909eb 100644
--- a/src/pkg/math/jn.go
+++ b/src/pkg/math/jn.go
@@ -55,13 +55,11 @@
 		TwoM29 = 1.0 / (1 << 29) // 2**-29 0x3e10000000000000
 		Two302 = 1 << 302        // 2**302 0x52D0000000000000
 	)
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
-	case x != x: // IsNaN(x)
+	case IsNaN(x):
 		return x
-	case x < -MaxFloat64 || x > MaxFloat64: // IsInf(x, 0):
+	case IsInf(x, 0):
 		return 0
 	}
 	// J(-n, x) = (-1)**n * J(n, x), J(n, -x) = (-1)**n * J(n, x)
@@ -236,13 +234,11 @@
 //	Y1(n, NaN) = NaN
 func Yn(n int, x float64) float64 {
 	const Two302 = 1 << 302 // 2**302 0x52D0000000000000
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
-	case x < 0 || x != x: // x < 0 || IsNaN(x):
+	case x < 0 || IsNaN(x):
 		return NaN()
-	case x > MaxFloat64: // IsInf(x, 1)
+	case IsInf(x, 1):
 		return 0
 	}
 
@@ -299,7 +295,7 @@
 		a := Y0(x)
 		b = Y1(x)
 		// quit if b is -inf
-		for i := 1; i < n && b >= -MaxFloat64; i++ { // for i := 1; i < n && !IsInf(b, -1); i++ {
+		for i := 1; i < n && !IsInf(b, -1); i++ {
 			a, b = b, (float64(i+i)/x)*b-a
 		}
 	}
diff --git a/src/pkg/math/ldexp.go b/src/pkg/math/ldexp.go
index 9534230..b5d2a5e 100644
--- a/src/pkg/math/ldexp.go
+++ b/src/pkg/math/ldexp.go
@@ -14,13 +14,11 @@
 func Ldexp(frac float64, exp int) float64
 
 func ldexp(frac float64, exp int) float64 {
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
 	case frac == 0:
 		return frac // correctly return -0
-	case frac < -MaxFloat64 || frac > MaxFloat64 || frac != frac: // IsInf(frac, 0) || IsNaN(frac):
+	case IsInf(frac, 0) || IsNaN(frac):
 		return frac
 	}
 	frac, e := normalize(frac)
diff --git a/src/pkg/math/lgamma.go b/src/pkg/math/lgamma.go
index e2bad69..6a02c41 100644
--- a/src/pkg/math/lgamma.go
+++ b/src/pkg/math/lgamma.go
@@ -183,15 +183,13 @@
 		// Tt = -(tail of Tf)
 		Tt = -3.63867699703950536541e-18 // 0xBC50C7CAA48A971F
 	)
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	sign = 1
 	switch {
-	case x != x: // IsNaN(x):
+	case IsNaN(x):
 		lgamma = x
 		return
-	case x < -MaxFloat64 || x > MaxFloat64: // IsInf(x, 0):
+	case IsInf(x, 0):
 		lgamma = x
 		return
 	case x == 0:
diff --git a/src/pkg/math/log.go b/src/pkg/math/log.go
index 1d467fb..818f00a 100644
--- a/src/pkg/math/log.go
+++ b/src/pkg/math/log.go
@@ -92,11 +92,9 @@
 		L7    = 1.479819860511658591e-01   /* 3FC2F112 DF3E5244 */
 	)
 
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
-	case x != x || x > MaxFloat64: // IsNaN(x) || IsInf(x, 1):
+	case IsNaN(x) || IsInf(x, 1):
 		return x
 	case x < 0:
 		return NaN()
diff --git a/src/pkg/math/log1p.go b/src/pkg/math/log1p.go
index dee7f2b..12b9868 100644
--- a/src/pkg/math/log1p.go
+++ b/src/pkg/math/log1p.go
@@ -113,14 +113,12 @@
 	)
 
 	// special cases
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	switch {
-	case x < -1 || x != x: // x < -1 || IsNaN(x): // includes -Inf
+	case x < -1 || IsNaN(x): // includes -Inf
 		return NaN()
 	case x == -1:
 		return Inf(-1)
-	case x > MaxFloat64: // IsInf(x, 1):
+	case IsInf(x, 1):
 		return Inf(1)
 	}
 
diff --git a/src/pkg/math/logb.go b/src/pkg/math/logb.go
index 072281d..d32f9f1 100644
--- a/src/pkg/math/logb.go
+++ b/src/pkg/math/logb.go
@@ -11,15 +11,13 @@
 //	Logb(0) = -Inf
 //	Logb(NaN) = NaN
 func Logb(x float64) float64 {
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
 	case x == 0:
 		return Inf(-1)
-	case x < -MaxFloat64 || x > MaxFloat64: // IsInf(x, 0):
+	case IsInf(x, 0):
 		return Inf(1)
-	case x != x: // IsNaN(x):
+	case IsNaN(x):
 		return x
 	}
 	return float64(ilogb(x))
@@ -32,15 +30,13 @@
 //	Ilogb(0) = MinInt32
 //	Ilogb(NaN) = MaxInt32
 func Ilogb(x float64) int {
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
 	case x == 0:
 		return MinInt32
-	case x != x: // IsNaN(x):
+	case IsNaN(x):
 		return MaxInt32
-	case x < -MaxFloat64 || x > MaxFloat64: // IsInf(x, 0):
+	case IsInf(x, 0):
 		return MaxInt32
 	}
 	return ilogb(x)
diff --git a/src/pkg/math/mod.go b/src/pkg/math/mod.go
index c1f244d..e1a414e 100644
--- a/src/pkg/math/mod.go
+++ b/src/pkg/math/mod.go
@@ -21,9 +21,7 @@
 func Mod(x, y float64) float64
 
 func mod(x, y float64) float64 {
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us.
-	if y == 0 || x > MaxFloat64 || x < -MaxFloat64 || x != x || y != y { // y == 0 || IsInf(x, 0) || IsNaN(x) || IsNan(y)
+	if y == 0 || IsInf(x, 0) || IsNaN(x) || IsNaN(y) {
 		return NaN()
 	}
 	if y < 0 {
diff --git a/src/pkg/math/nextafter.go b/src/pkg/math/nextafter.go
index e7723ba..7c4b5bc 100644
--- a/src/pkg/math/nextafter.go
+++ b/src/pkg/math/nextafter.go
@@ -11,10 +11,8 @@
 //      Nextafter(NaN, y) = NaN
 //      Nextafter(x, NaN) = NaN
 func Nextafter(x, y float64) (r float64) {
-	// TODO(rsc): Remove manual inlining of IsNaN
-	// when compiler does it for us
 	switch {
-	case x != x || y != y: // IsNaN(x) || IsNaN(y): // special case
+	case IsNaN(x) || IsNaN(y): // special case
 		r = NaN()
 	case x == y:
 		r = x
diff --git a/src/pkg/math/pow.go b/src/pkg/math/pow.go
index f0f52c5..77af256 100644
--- a/src/pkg/math/pow.go
+++ b/src/pkg/math/pow.go
@@ -36,8 +36,6 @@
 //	Pow(-Inf, y) = Pow(-0, -y)
 //	Pow(x, y) = NaN for finite x < 0 and finite non-integer y
 func Pow(x, y float64) float64 {
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	switch {
 	case y == 0 || x == 1:
 		return 1
@@ -47,7 +45,7 @@
 		return Sqrt(x)
 	case y == -0.5:
 		return 1 / Sqrt(x)
-	case x != x || y != y: // IsNaN(x) || IsNaN(y):
+	case IsNaN(x) || IsNaN(y):
 		return NaN()
 	case x == 0:
 		switch {
@@ -62,7 +60,7 @@
 			}
 			return 0
 		}
-	case y > MaxFloat64 || y < -MaxFloat64: // IsInf(y, 0):
+	case IsInf(y, 0):
 		switch {
 		case x == -1:
 			return 1
@@ -71,7 +69,7 @@
 		default:
 			return Inf(1)
 		}
-	case x > MaxFloat64 || x < -MaxFloat64: // IsInf(x, 0):
+	case IsInf(x, 0):
 		if IsInf(x, -1) {
 			return Pow(1/x, -y) // Pow(-0, -y)
 		}
diff --git a/src/pkg/math/remainder.go b/src/pkg/math/remainder.go
index 69d23e58..41efd79 100644
--- a/src/pkg/math/remainder.go
+++ b/src/pkg/math/remainder.go
@@ -41,13 +41,11 @@
 		Tiny    = 4.45014771701440276618e-308 // 0x0020000000000000
 		HalfMax = MaxFloat64 / 2
 	)
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
-	case x != x || y != y || x < -MaxFloat64 || x > MaxFloat64 || y == 0: // IsNaN(x) || IsNaN(y) || IsInf(x, 0) || y == 0:
+	case IsNaN(x) || IsNaN(y) || IsInf(x, 0) || y == 0:
 		return NaN()
-	case y < -MaxFloat64 || y > MaxFloat64: // IsInf(y):
+	case IsInf(y, 0):
 		return x
 	}
 	sign := false
diff --git a/src/pkg/math/sin.go b/src/pkg/math/sin.go
index 176ac22..8beb8bb 100644
--- a/src/pkg/math/sin.go
+++ b/src/pkg/math/sin.go
@@ -123,11 +123,9 @@
 		PI4C = 2.69515142907905952645E-15                            // 0x3ce8469898cc5170,
 		M4PI = 1.273239544735162542821171882678754627704620361328125 // 4/pi
 	)
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
-	case x != x || x < -MaxFloat64 || x > MaxFloat64: // IsNaN(x) || IsInf(x, 0):
+	case IsNaN(x) || IsInf(x, 0):
 		return NaN()
 	}
 
@@ -182,13 +180,11 @@
 		PI4C = 2.69515142907905952645E-15                            // 0x3ce8469898cc5170,
 		M4PI = 1.273239544735162542821171882678754627704620361328125 // 4/pi
 	)
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
-	case x == 0 || x != x: // x == 0 || IsNaN():
+	case x == 0 || IsNaN(x):
 		return x // return ±0 || NaN()
-	case x < -MaxFloat64 || x > MaxFloat64: // IsInf(x, 0):
+	case IsInf(x, 0):
 		return NaN()
 	}
 
diff --git a/src/pkg/math/sincos.go b/src/pkg/math/sincos.go
index ff6c328..7300429 100644
--- a/src/pkg/math/sincos.go
+++ b/src/pkg/math/sincos.go
@@ -21,13 +21,11 @@
 		PI4C = 2.69515142907905952645E-15                            // 0x3ce8469898cc5170,
 		M4PI = 1.273239544735162542821171882678754627704620361328125 // 4/pi
 	)
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
 	case x == 0:
 		return x, 1 // return ±0.0, 1.0
-	case x != x || x < -MaxFloat64 || x > MaxFloat64: // IsNaN(x) || IsInf(x, 0):
+	case IsNaN(x) || IsInf(x, 0):
 		return NaN(), NaN()
 	}
 
diff --git a/src/pkg/math/sqrt.go b/src/pkg/math/sqrt.go
index d0b5535..21336df 100644
--- a/src/pkg/math/sqrt.go
+++ b/src/pkg/math/sqrt.go
@@ -100,10 +100,8 @@
 //	Sqrt(NaN) = NaN
 func sqrt(x float64) float64 {
 	// special cases
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	switch {
-	case x == 0 || x != x || x > MaxFloat64: // x == 0 || IsNaN(x) || IsInf(x, 1):
+	case x == 0 || IsNaN(x) || IsInf(x, 1):
 		return x
 	case x < 0:
 		return NaN()
diff --git a/src/pkg/math/tan.go b/src/pkg/math/tan.go
index 4e722e1..b2f29cc 100644
--- a/src/pkg/math/tan.go
+++ b/src/pkg/math/tan.go
@@ -88,13 +88,11 @@
 		PI4C = 2.69515142907905952645E-15                            // 0x3ce8469898cc5170,
 		M4PI = 1.273239544735162542821171882678754627704620361328125 // 4/pi
 	)
-	// TODO(rsc): Remove manual inlining of IsNaN, IsInf
-	// when compiler does it for us
 	// special cases
 	switch {
-	case x == 0 || x != x: // x == 0 || IsNaN():
+	case x == 0 || IsNaN(x):
 		return x // return ±0 || NaN()
-	case x < -MaxFloat64 || x > MaxFloat64: // IsInf(x, 0):
+	case IsInf(x, 0):
 		return NaN()
 	}