]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: don't store NaN in ppc64 floating point constant ops
authorKeith Randall <khr@golang.org>
Thu, 7 May 2020 23:09:33 +0000 (16:09 -0700)
committerKeith Randall <khr@golang.org>
Thu, 7 May 2020 23:22:45 +0000 (23:22 +0000)
Missed in CL 221790

This is the only remaining use of math.Float64frombits in the .rules
file that isn't already guarded.

Fixes #38880

Change-Id: I11f71e3a48516748d8d2701c6cf6920a7bc9e216
Reviewed-on: https://go-review.googlesource.com/c/go/+/232859
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
src/cmd/compile/internal/ssa/gen/PPC64.rules
src/cmd/compile/internal/ssa/rewritePPC64.go

index d8041e810fb7492ca23eb6e19599f131e2ce61c7..761ffa2f958b017964ff06cd0bc07ef5d1f909bf 100644 (file)
 (FMOVDstore [off] {sym} ptr (MTVSRD x) mem) => (MOVDstore [off] {sym} ptr x mem)
 (MOVDstore [off] {sym} ptr (MFVSRD x) mem) => (FMOVDstore [off] {sym} ptr x mem)
 
-(MTVSRD (MOVDconst [c])) => (FMOVDconst [math.Float64frombits(uint64(c))])
+(MTVSRD (MOVDconst [c])) && !math.IsNaN(math.Float64frombits(uint64(c))) => (FMOVDconst [math.Float64frombits(uint64(c))])
 (MFVSRD (FMOVDconst [c])) => (MOVDconst [int64(math.Float64bits(c))])
 
 (MTVSRD x:(MOVDload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (FMOVDload [off] {sym} ptr mem)
index 0b798c6a722ddcad27b74a463274b9592e687837..6a2c164fe0c2b3867271fa2c8fe5a747e5b52804 100644 (file)
@@ -10314,12 +10314,16 @@ func rewriteValuePPC64_OpPPC64MTVSRD(v *Value) bool {
        b := v.Block
        typ := &b.Func.Config.Types
        // match: (MTVSRD (MOVDconst [c]))
+       // cond: !math.IsNaN(math.Float64frombits(uint64(c)))
        // result: (FMOVDconst [math.Float64frombits(uint64(c))])
        for {
                if v_0.Op != OpPPC64MOVDconst {
                        break
                }
                c := auxIntToInt64(v_0.AuxInt)
+               if !(!math.IsNaN(math.Float64frombits(uint64(c)))) {
+                       break
+               }
                v.reset(OpPPC64FMOVDconst)
                v.AuxInt = float64ToAuxInt(math.Float64frombits(uint64(c)))
                return true