This reverts CL 213477.
Reason for revert: tests are failing on linux-mips*-rtrk builders.
Change-Id: I8168f7450890233f1bd7e53930b73693c26d4dc0
Reviewed-on: https://go-review.googlesource.com/c/go/+/220897
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
}
}
-// Signaling NaN values as constants.
-const (
- snan32bits uint32 = 0x7f800001
- snan64bits uint64 = 0x7ff0000000000001
-)
-
-// Signaling NaNs as variables.
-var snan32bitsVar uint32 = snan32bits
-var snan64bitsVar uint64 = snan64bits
-
-func TestFloatSignalingNaN(t *testing.T) {
- // Make sure we generate a signaling NaN from a constant properly.
- // See issue 36400.
- f32 := math.Float32frombits(snan32bits)
- g32 := math.Float32frombits(snan32bitsVar)
- x32 := math.Float32bits(f32)
- y32 := math.Float32bits(g32)
- if x32 != y32 {
- t.Errorf("got %x, want %x (diff=%x)", x32, y32, x32^y32)
- }
-
- f64 := math.Float64frombits(snan64bits)
- g64 := math.Float64frombits(snan64bitsVar)
- x64 := math.Float64bits(f64)
- y64 := math.Float64bits(g64)
- if x64 != y64 {
- t.Errorf("got %x, want %x (diff=%x)", x64, y64, x64^y64)
- }
-}
-
-func TestFloatSignalingNaNConversion(t *testing.T) {
- // Test to make sure when we convert a signaling NaN, it converts to a quiet NaN.
- // See issue 36399.
- s32 := math.Float32frombits(snan32bitsVar)
- q64 := float64(s32)
- if math.Float64bits(q64)>>52&1 == 0 {
- t.Errorf("got signaling NaN, want quiet NaN")
- }
- s64 := math.Float64frombits(snan64bitsVar)
- q32 := float32(s64)
- if math.Float32bits(q32)>>22&1 == 0 {
- t.Errorf("got signaling NaN, want quiet NaN")
- }
-}
-
-func TestFloatSignalingNaNConversionConst(t *testing.T) {
- // Test to make sure when we convert a signaling NaN, it converts to a quiet NaN.
- // See issue 36399 and 36400.
- s32 := math.Float32frombits(snan32bits)
- q64 := float64(s32)
- if math.Float64bits(q64)>>52&1 == 0 {
- t.Errorf("got signaling NaN, want quiet NaN")
- }
- s64 := math.Float64frombits(snan64bits)
- q32 := float32(s64)
- if math.Float32bits(q32)>>22&1 == 0 {
- t.Errorf("got signaling NaN, want quiet NaN")
- }
-}
-
var sinkFloat float64
func BenchmarkMul2(b *testing.B) {
f.Fatalf("bad int32 AuxInt value for %v", v)
}
canHaveAuxInt = true
- case auxInt64:
+ case auxInt64, auxFloat64:
canHaveAuxInt = true
case auxInt128:
// AuxInt must be zero, so leave canHaveAuxInt set to false.
case auxFloat32:
canHaveAuxInt = true
- if math.IsNaN(v.AuxFloat()) {
- f.Fatalf("value %v has an AuxInt that encodes a NaN", v)
- }
if !isExactFloat32(v.AuxFloat()) {
f.Fatalf("value %v has an AuxInt value that is not an exact float32", v)
}
- case auxFloat64:
- canHaveAuxInt = true
- if math.IsNaN(v.AuxFloat()) {
- f.Fatalf("value %v has an AuxInt that encodes a NaN", v)
- }
case auxString, auxSym, auxTyp, auxArchSpecific:
canHaveAux = true
case auxSymOff, auxSymValAndOff, auxTypSize:
// Constant folding
(FABS (FMOVDconst [x])) -> (FMOVDconst [auxFrom64F(math.Abs(auxTo64F(x)))])
-(FSQRT (FMOVDconst [x])) && auxTo64F(x) >= 0 -> (FMOVDconst [auxFrom64F(math.Sqrt(auxTo64F(x)))])
+(FSQRT (FMOVDconst [x])) -> (FMOVDconst [auxFrom64F(math.Sqrt(auxTo64F(x)))])
(FFLOOR (FMOVDconst [x])) -> (FMOVDconst [auxFrom64F(math.Floor(auxTo64F(x)))])
(FCEIL (FMOVDconst [x])) -> (FMOVDconst [auxFrom64F(math.Ceil(auxTo64F(x)))])
(FTRUNC (FMOVDconst [x])) -> (FMOVDconst [auxFrom64F(math.Trunc(auxTo64F(x)))])
(I64Or (I64Const [x]) (I64Const [y])) -> (I64Const [x | y])
(I64Xor (I64Const [x]) (I64Const [y])) -> (I64Const [x ^ y])
(F64Add (F64Const [x]) (F64Const [y])) -> (F64Const [auxFrom64F(auxTo64F(x) + auxTo64F(y))])
-(F64Mul (F64Const [x]) (F64Const [y])) && !math.IsNaN(auxTo64F(x) * auxTo64F(y)) -> (F64Const [auxFrom64F(auxTo64F(x) * auxTo64F(y))])
+(F64Mul (F64Const [x]) (F64Const [y])) -> (F64Const [auxFrom64F(auxTo64F(x) * auxTo64F(y))])
(I64Eq (I64Const [x]) (I64Const [y])) && x == y -> (I64Const [1])
(I64Eq (I64Const [x]) (I64Const [y])) && x != y -> (I64Const [0])
(I64Ne (I64Const [x]) (I64Const [y])) && x == y -> (I64Const [0])
(I64ShrU (I64Const [x]) (I64Const [y])) -> (I64Const [int64(uint64(x) >> uint64(y))])
(I64ShrS (I64Const [x]) (I64Const [y])) -> (I64Const [x >> uint64(y)])
-// TODO: declare these operations as commutative and get rid of these rules?
-(I64Add (I64Const [x]) y) && y.Op != OpWasmI64Const -> (I64Add y (I64Const [x]))
-(I64Mul (I64Const [x]) y) && y.Op != OpWasmI64Const -> (I64Mul y (I64Const [x]))
-(I64And (I64Const [x]) y) && y.Op != OpWasmI64Const -> (I64And y (I64Const [x]))
-(I64Or (I64Const [x]) y) && y.Op != OpWasmI64Const -> (I64Or y (I64Const [x]))
-(I64Xor (I64Const [x]) y) && y.Op != OpWasmI64Const -> (I64Xor y (I64Const [x]))
-(F64Add (F64Const [x]) y) && y.Op != OpWasmF64Const -> (F64Add y (F64Const [x]))
-(F64Mul (F64Const [x]) y) && y.Op != OpWasmF64Const -> (F64Mul y (F64Const [x]))
-(I64Eq (I64Const [x]) y) && y.Op != OpWasmI64Const -> (I64Eq y (I64Const [x]))
-(I64Ne (I64Const [x]) y) && y.Op != OpWasmI64Const -> (I64Ne y (I64Const [x]))
+(I64Add (I64Const [x]) y) -> (I64Add y (I64Const [x]))
+(I64Mul (I64Const [x]) y) -> (I64Mul y (I64Const [x]))
+(I64And (I64Const [x]) y) -> (I64And y (I64Const [x]))
+(I64Or (I64Const [x]) y) -> (I64Or y (I64Const [x]))
+(I64Xor (I64Const [x]) y) -> (I64Xor y (I64Const [x]))
+(F64Add (F64Const [x]) y) -> (F64Add y (F64Const [x]))
+(F64Mul (F64Const [x]) y) -> (F64Mul y (F64Const [x]))
+(I64Eq (I64Const [x]) y) -> (I64Eq y (I64Const [x]))
+(I64Ne (I64Const [x]) y) -> (I64Ne y (I64Const [x]))
(I64Eq x (I64Const [0])) -> (I64Eqz x)
(I64Ne x (I64Const [0])) -> (I64Eqz (I64Eqz x))
(Mul16 (Const16 [c]) (Const16 [d])) -> (Const16 [int64(int16(c*d))])
(Mul32 (Const32 [c]) (Const32 [d])) -> (Const32 [int64(int32(c*d))])
(Mul64 (Const64 [c]) (Const64 [d])) -> (Const64 [c*d])
-(Mul32F (Const32F [c]) (Const32F [d])) && !math.IsNaN(float64(auxTo32F(c) * auxTo32F(d))) -> (Const32F [auxFrom32F(auxTo32F(c) * auxTo32F(d))])
-(Mul64F (Const64F [c]) (Const64F [d])) && !math.IsNaN(auxTo64F(c) * auxTo64F(d)) -> (Const64F [auxFrom64F(auxTo64F(c) * auxTo64F(d))])
+(Mul32F (Const32F [c]) (Const32F [d])) -> (Const32F [auxFrom32F(auxTo32F(c) * auxTo32F(d))])
+(Mul64F (Const64F [c]) (Const64F [d])) -> (Const64F [auxFrom64F(auxTo64F(c) * auxTo64F(d))])
(And8 (Const8 [c]) (Const8 [d])) -> (Const8 [int64(int8(c&d))])
(And16 (Const16 [c]) (Const16 [d])) -> (Const16 [int64(int16(c&d))])
(Div16u (Const16 [c]) (Const16 [d])) && d != 0 -> (Const16 [int64(int16(uint16(c)/uint16(d)))])
(Div32u (Const32 [c]) (Const32 [d])) && d != 0 -> (Const32 [int64(int32(uint32(c)/uint32(d)))])
(Div64u (Const64 [c]) (Const64 [d])) && d != 0 -> (Const64 [int64(uint64(c)/uint64(d))])
-(Div32F (Const32F [c]) (Const32F [d])) && !math.IsNaN(float64(auxTo32F(c) / auxTo32F(d))) -> (Const32F [auxFrom32F(auxTo32F(c) / auxTo32F(d))])
-(Div64F (Const64F [c]) (Const64F [d])) && !math.IsNaN(auxTo64F(c) / auxTo64F(d)) -> (Const64F [auxFrom64F(auxTo64F(c) / auxTo64F(d))])
+(Div32F (Const32F [c]) (Const32F [d])) -> (Const32F [auxFrom32F(auxTo32F(c) / auxTo32F(d))])
+(Div64F (Const64F [c]) (Const64F [d])) -> (Const64F [auxFrom64F(auxTo64F(c) / auxTo64F(d))])
(Select0 (Div128u (Const64 [0]) lo y)) -> (Div64u lo y)
(Select1 (Div128u (Const64 [0]) lo y)) -> (Mod64u lo y)
-> x
// Pass constants through math.Float{32,64}bits and math.Float{32,64}frombits
- (Load <t1> p1 (Store {t2} p2 (Const64 [x]) _)) && isSamePtr(p1,p2) && sizeof(t2) == 8 && is64BitFloat(t1) && !math.IsNaN(math.Float64frombits(uint64(x))) -> (Const64F [x])
- (Load <t1> p1 (Store {t2} p2 (Const32 [x]) _)) && isSamePtr(p1,p2) && sizeof(t2) == 4 && is32BitFloat(t1) && !math.IsNaN(float64(math.Float32frombits(uint32(x)))) -> (Const32F [auxFrom32F(math.Float32frombits(uint32(x)))])
+(Load <t1> p1 (Store {t2} p2 (Const64 [x]) _)) && isSamePtr(p1,p2) && sizeof(t2) == 8 && is64BitFloat(t1) -> (Const64F [x])
+(Load <t1> p1 (Store {t2} p2 (Const32 [x]) _)) && isSamePtr(p1,p2) && sizeof(t2) == 4 && is32BitFloat(t1) -> (Const32F [auxFrom32F(math.Float32frombits(uint32(x)))])
(Load <t1> p1 (Store {t2} p2 (Const64F [x]) _)) && isSamePtr(p1,p2) && sizeof(t2) == 8 && is64BitInt(t1) -> (Const64 [x])
(Load <t1> p1 (Store {t2} p2 (Const32F [x]) _)) && isSamePtr(p1,p2) && sizeof(t2) == 4 && is32BitInt(t1) -> (Const32 [int64(int32(math.Float32bits(auxTo32F(x))))])
(Div32F x (Const32F <t> [c])) && reciprocalExact32(auxTo32F(c)) -> (Mul32F x (Const32F <t> [auxFrom32F(1/auxTo32F(c))]))
(Div64F x (Const64F <t> [c])) && reciprocalExact64(auxTo64F(c)) -> (Mul64F x (Const64F <t> [auxFrom64F(1/auxTo64F(c))]))
-(Sqrt (Const64F [c])) && !math.IsNaN(math.Sqrt(auxTo64F(c))) -> (Const64F [auxFrom64F(math.Sqrt(auxTo64F(c)))])
+(Sqrt (Const64F [c])) -> (Const64F [auxFrom64F(math.Sqrt(auxTo64F(c)))])
// recognize runtime.newobject and don't Zero/Nilcheck it
(Zero (Load (OffPtr [c] (SP)) mem) mem)
{name: "Const32", aux: "Int32"}, // auxint is sign-extended 32 bits
// Note: ConstX are sign-extended even when the type of the value is unsigned.
// For instance, uint8(0xaa) is stored as auxint=0xffffffffffffffaa.
- {name: "Const64", aux: "Int64"}, // value is auxint
- // Note: for both Const32F and Const64F, we disallow encoding NaNs.
- // Signaling NaNs are tricky because if you do anything with them, they become quiet.
- // Particularly, converting a 32 bit sNaN to 64 bit and back converts it to a qNaN.
- // See issue 36399 and 36400.
- // Encodings of +inf, -inf, and -0 are fine.
+ {name: "Const64", aux: "Int64"}, // value is auxint
{name: "Const32F", aux: "Float32"}, // value is math.Float64frombits(uint64(auxint)) and is exactly representable as float 32
{name: "Const64F", aux: "Float64"}, // value is math.Float64frombits(uint64(auxint))
{name: "ConstInterface"}, // nil interface
// auxFrom64F encodes a float64 value so it can be stored in an AuxInt.
func auxFrom64F(f float64) int64 {
- if f != f {
- panic("can't encode a NaN in AuxInt field")
- }
return int64(math.Float64bits(f))
}
// auxFrom32F encodes a float32 value so it can be stored in an AuxInt.
func auxFrom32F(f float32) int64 {
- if f != f {
- panic("can't encode a NaN in AuxInt field")
- }
return int64(math.Float64bits(extend32Fto64F(f)))
}
func rewriteValuePPC64_OpPPC64FSQRT(v *Value) bool {
v_0 := v.Args[0]
// match: (FSQRT (FMOVDconst [x]))
- // cond: auxTo64F(x) >= 0
// result: (FMOVDconst [auxFrom64F(math.Sqrt(auxTo64F(x)))])
for {
if v_0.Op != OpPPC64FMOVDconst {
break
}
x := v_0.AuxInt
- if !(auxTo64F(x) >= 0) {
- break
- }
v.reset(OpPPC64FMOVDconst)
v.AuxInt = auxFrom64F(math.Sqrt(auxTo64F(x)))
return true
package ssa
-import "math"
import "cmd/internal/objabi"
import "cmd/compile/internal/types"
return true
}
// match: (F64Add (F64Const [x]) y)
- // cond: y.Op != OpWasmF64Const
// result: (F64Add y (F64Const [x]))
for {
if v_0.Op != OpWasmF64Const {
}
x := v_0.AuxInt
y := v_1
- if !(y.Op != OpWasmF64Const) {
- break
- }
v.reset(OpWasmF64Add)
v.AddArg(y)
v0 := b.NewValue0(v.Pos, OpWasmF64Const, typ.Float64)
b := v.Block
typ := &b.Func.Config.Types
// match: (F64Mul (F64Const [x]) (F64Const [y]))
- // cond: !math.IsNaN(auxTo64F(x) * auxTo64F(y))
// result: (F64Const [auxFrom64F(auxTo64F(x) * auxTo64F(y))])
for {
if v_0.Op != OpWasmF64Const {
break
}
y := v_1.AuxInt
- if !(!math.IsNaN(auxTo64F(x) * auxTo64F(y))) {
- break
- }
v.reset(OpWasmF64Const)
v.AuxInt = auxFrom64F(auxTo64F(x) * auxTo64F(y))
return true
}
// match: (F64Mul (F64Const [x]) y)
- // cond: y.Op != OpWasmF64Const
// result: (F64Mul y (F64Const [x]))
for {
if v_0.Op != OpWasmF64Const {
}
x := v_0.AuxInt
y := v_1
- if !(y.Op != OpWasmF64Const) {
- break
- }
v.reset(OpWasmF64Mul)
v.AddArg(y)
v0 := b.NewValue0(v.Pos, OpWasmF64Const, typ.Float64)
return true
}
// match: (I64Add (I64Const [x]) y)
- // cond: y.Op != OpWasmI64Const
// result: (I64Add y (I64Const [x]))
for {
if v_0.Op != OpWasmI64Const {
}
x := v_0.AuxInt
y := v_1
- if !(y.Op != OpWasmI64Const) {
- break
- }
v.reset(OpWasmI64Add)
v.AddArg(y)
v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64)
return true
}
// match: (I64And (I64Const [x]) y)
- // cond: y.Op != OpWasmI64Const
// result: (I64And y (I64Const [x]))
for {
if v_0.Op != OpWasmI64Const {
}
x := v_0.AuxInt
y := v_1
- if !(y.Op != OpWasmI64Const) {
- break
- }
v.reset(OpWasmI64And)
v.AddArg(y)
v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64)
return true
}
// match: (I64Eq (I64Const [x]) y)
- // cond: y.Op != OpWasmI64Const
// result: (I64Eq y (I64Const [x]))
for {
if v_0.Op != OpWasmI64Const {
}
x := v_0.AuxInt
y := v_1
- if !(y.Op != OpWasmI64Const) {
- break
- }
v.reset(OpWasmI64Eq)
v.AddArg(y)
v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64)
return true
}
// match: (I64Mul (I64Const [x]) y)
- // cond: y.Op != OpWasmI64Const
// result: (I64Mul y (I64Const [x]))
for {
if v_0.Op != OpWasmI64Const {
}
x := v_0.AuxInt
y := v_1
- if !(y.Op != OpWasmI64Const) {
- break
- }
v.reset(OpWasmI64Mul)
v.AddArg(y)
v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64)
return true
}
// match: (I64Ne (I64Const [x]) y)
- // cond: y.Op != OpWasmI64Const
// result: (I64Ne y (I64Const [x]))
for {
if v_0.Op != OpWasmI64Const {
}
x := v_0.AuxInt
y := v_1
- if !(y.Op != OpWasmI64Const) {
- break
- }
v.reset(OpWasmI64Ne)
v.AddArg(y)
v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64)
return true
}
// match: (I64Or (I64Const [x]) y)
- // cond: y.Op != OpWasmI64Const
// result: (I64Or y (I64Const [x]))
for {
if v_0.Op != OpWasmI64Const {
}
x := v_0.AuxInt
y := v_1
- if !(y.Op != OpWasmI64Const) {
- break
- }
v.reset(OpWasmI64Or)
v.AddArg(y)
v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64)
return true
}
// match: (I64Xor (I64Const [x]) y)
- // cond: y.Op != OpWasmI64Const
// result: (I64Xor y (I64Const [x]))
for {
if v_0.Op != OpWasmI64Const {
}
x := v_0.AuxInt
y := v_1
- if !(y.Op != OpWasmI64Const) {
- break
- }
v.reset(OpWasmI64Xor)
v.AddArg(y)
v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64)
v_0 := v.Args[0]
b := v.Block
// match: (Div32F (Const32F [c]) (Const32F [d]))
- // cond: !math.IsNaN(float64(auxTo32F(c) / auxTo32F(d)))
// result: (Const32F [auxFrom32F(auxTo32F(c) / auxTo32F(d))])
for {
if v_0.Op != OpConst32F {
break
}
d := v_1.AuxInt
- if !(!math.IsNaN(float64(auxTo32F(c) / auxTo32F(d)))) {
- break
- }
v.reset(OpConst32F)
v.AuxInt = auxFrom32F(auxTo32F(c) / auxTo32F(d))
return true
v_0 := v.Args[0]
b := v.Block
// match: (Div64F (Const64F [c]) (Const64F [d]))
- // cond: !math.IsNaN(auxTo64F(c) / auxTo64F(d))
// result: (Const64F [auxFrom64F(auxTo64F(c) / auxTo64F(d))])
for {
if v_0.Op != OpConst64F {
break
}
d := v_1.AuxInt
- if !(!math.IsNaN(auxTo64F(c) / auxTo64F(d))) {
- break
- }
v.reset(OpConst64F)
v.AuxInt = auxFrom64F(auxTo64F(c) / auxTo64F(d))
return true
return true
}
// match: (Load <t1> p1 (Store {t2} p2 (Const64 [x]) _))
- // cond: isSamePtr(p1,p2) && sizeof(t2) == 8 && is64BitFloat(t1) && !math.IsNaN(math.Float64frombits(uint64(x)))
+ // cond: isSamePtr(p1,p2) && sizeof(t2) == 8 && is64BitFloat(t1)
// result: (Const64F [x])
for {
t1 := v.Type
break
}
x := v_1_1.AuxInt
- if !(isSamePtr(p1, p2) && sizeof(t2) == 8 && is64BitFloat(t1) && !math.IsNaN(math.Float64frombits(uint64(x)))) {
+ if !(isSamePtr(p1, p2) && sizeof(t2) == 8 && is64BitFloat(t1)) {
break
}
v.reset(OpConst64F)
return true
}
// match: (Load <t1> p1 (Store {t2} p2 (Const32 [x]) _))
- // cond: isSamePtr(p1,p2) && sizeof(t2) == 4 && is32BitFloat(t1) && !math.IsNaN(float64(math.Float32frombits(uint32(x))))
+ // cond: isSamePtr(p1,p2) && sizeof(t2) == 4 && is32BitFloat(t1)
// result: (Const32F [auxFrom32F(math.Float32frombits(uint32(x)))])
for {
t1 := v.Type
break
}
x := v_1_1.AuxInt
- if !(isSamePtr(p1, p2) && sizeof(t2) == 4 && is32BitFloat(t1) && !math.IsNaN(float64(math.Float32frombits(uint32(x))))) {
+ if !(isSamePtr(p1, p2) && sizeof(t2) == 4 && is32BitFloat(t1)) {
break
}
v.reset(OpConst32F)
v_1 := v.Args[1]
v_0 := v.Args[0]
// match: (Mul32F (Const32F [c]) (Const32F [d]))
- // cond: !math.IsNaN(float64(auxTo32F(c) * auxTo32F(d)))
// result: (Const32F [auxFrom32F(auxTo32F(c) * auxTo32F(d))])
for {
for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
continue
}
d := v_1.AuxInt
- if !(!math.IsNaN(float64(auxTo32F(c) * auxTo32F(d)))) {
- continue
- }
v.reset(OpConst32F)
v.AuxInt = auxFrom32F(auxTo32F(c) * auxTo32F(d))
return true
v_1 := v.Args[1]
v_0 := v.Args[0]
// match: (Mul64F (Const64F [c]) (Const64F [d]))
- // cond: !math.IsNaN(auxTo64F(c) * auxTo64F(d))
// result: (Const64F [auxFrom64F(auxTo64F(c) * auxTo64F(d))])
for {
for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
continue
}
d := v_1.AuxInt
- if !(!math.IsNaN(auxTo64F(c) * auxTo64F(d))) {
- continue
- }
v.reset(OpConst64F)
v.AuxInt = auxFrom64F(auxTo64F(c) * auxTo64F(d))
return true
func rewriteValuegeneric_OpSqrt(v *Value) bool {
v_0 := v.Args[0]
// match: (Sqrt (Const64F [c]))
- // cond: !math.IsNaN(math.Sqrt(auxTo64F(c)))
// result: (Const64F [auxFrom64F(math.Sqrt(auxTo64F(c)))])
for {
if v_0.Op != OpConst64F {
break
}
c := v_0.AuxInt
- if !(!math.IsNaN(math.Sqrt(auxTo64F(c)))) {
- break
- }
v.reset(OpConst64F)
v.AuxInt = auxFrom64F(math.Sqrt(auxTo64F(c)))
return true
func constantCheck64() bool {
// amd64:"MOVB\t[$]0",-"FCMP",-"MOVB\t[$]1"
// s390x:"MOV(B|BZ|D)\t[$]0,",-"FCMPU",-"MOV(B|BZ|D)\t[$]1,"
- return 0.5 == float64(uint32(1)) || 1.5 > float64(uint64(1<<63))
+ return 0.5 == float64(uint32(1)) || 1.5 > float64(uint64(1<<63)) || math.NaN() == math.NaN()
}
func constantCheck32() bool {
// amd64:"MOVB\t[$]1",-"FCMP",-"MOVB\t[$]0"
// s390x:"MOV(B|BZ|D)\t[$]1,",-"FCMPU",-"MOV(B|BZ|D)\t[$]0,"
- return float32(0.5) <= float32(int64(1)) && float32(1.5) >= float32(int32(-1<<31))
+ return float32(0.5) <= float32(int64(1)) && float32(1.5) >= float32(int32(-1<<31)) && float32(math.NaN()) != float32(math.NaN())
}
// Test that integer constants are converted to floating point constants
}
return x
}
-
-func nanGenerate64() float64 {
- // Test to make sure we don't generate a NaN while constant propagating.
- // See issue 36400.
- zero := 0.0
- // amd64:-"DIVSD"
- inf := 1 / zero // +inf. We can constant propagate this one.
- negone := -1.0
-
- // amd64:"DIVSD"
- z0 := zero / zero
- // amd64:"MULSD"
- z1 := zero * inf
- // amd64:"SQRTSD"
- z2 := math.Sqrt(negone)
- return z0 + z1 + z2
-}
-
-func nanGenerate32() float32 {
- zero := float32(0.0)
- // amd64:-"DIVSS"
- inf := 1 / zero // +inf. We can constant propagate this one.
-
- // amd64:"DIVSS"
- z0 := zero / zero
- // amd64:"MULSS"
- z1 := zero * inf
- return z0 + z1
-}