]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile,runtime: fix atomic And8 for mipsle
authorVladimir Stefanovic <vladimir.stefanovic@imgtec.com>
Tue, 21 Mar 2017 13:57:58 +0000 (14:57 +0100)
committerCherry Zhang <cherryyz@google.com>
Tue, 21 Mar 2017 16:03:12 +0000 (16:03 +0000)
Removing stray xori that came from big endian copy/paste.
Adding atomicand8 check to runtime.check() that would have revealed
this error.
Might fix #19396.

Change-Id: If8d6f25d3e205496163541eb112548aa66df9c2a
Reviewed-on: https://go-review.googlesource.com/38257
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/ssa/gen/MIPS.rules
src/cmd/compile/internal/ssa/rewriteMIPS.go
src/runtime/runtime1.go

index fe6f182ca4ee2274be1c9f9e627f114e2e1b77a9..3f40951d3bf78456e6549cc3400df19b465ab74b 100644 (file)
                                (ANDconst  <types.UInt32> [3] ptr)))
                (NORconst [0] <types.UInt32> (SLL <types.UInt32>
                        (MOVWconst [0xff]) (SLLconst <types.UInt32> [3]
-                               (ANDconst <types.UInt32> [3]
-                                       (XORconst <types.UInt32> [3] ptr)))))) mem)
+                               (ANDconst <types.UInt32> [3] ptr))))) mem)
 
 // AtomicOr8(ptr,val) -> LoweredAtomicOr(ptr&^3,uint32(val) << (((ptr^3) & 3) * 8))
 (AtomicOr8 ptr val mem) && config.BigEndian ->
index 5e70fc4f7387953b872f8a384182de6290179dba..19144108e75224c0dca1f714a2ebf099fffda476 100644 (file)
@@ -688,7 +688,7 @@ func rewriteValueMIPS_OpAtomicAnd8(v *Value) bool {
        _ = types
        // match: (AtomicAnd8  ptr val mem)
        // cond: !config.BigEndian
-       // result: (LoweredAtomicAnd (AND <types.UInt32Ptr> (MOVWconst [^3]) ptr)               (OR <types.UInt32> (SLL <types.UInt32> (ZeroExt8to32 val)                       (SLLconst <types.UInt32> [3]                            (ANDconst  <types.UInt32> [3] ptr)))            (NORconst [0] <types.UInt32> (SLL <types.UInt32>                        (MOVWconst [0xff]) (SLLconst <types.UInt32> [3]                                 (ANDconst <types.UInt32> [3]                                    (XORconst <types.UInt32> [3] ptr)))))) mem)
+       // result: (LoweredAtomicAnd (AND <types.UInt32Ptr> (MOVWconst [^3]) ptr)               (OR <types.UInt32> (SLL <types.UInt32> (ZeroExt8to32 val)                       (SLLconst <types.UInt32> [3]                            (ANDconst  <types.UInt32> [3] ptr)))            (NORconst [0] <types.UInt32> (SLL <types.UInt32>                        (MOVWconst [0xff]) (SLLconst <types.UInt32> [3]                                 (ANDconst <types.UInt32> [3] ptr))))) mem)
        for {
                ptr := v.Args[0]
                val := v.Args[1]
@@ -726,10 +726,7 @@ func rewriteValueMIPS_OpAtomicAnd8(v *Value) bool {
                v10.AuxInt = 3
                v11 := b.NewValue0(v.Pos, OpMIPSANDconst, types.UInt32)
                v11.AuxInt = 3
-               v12 := b.NewValue0(v.Pos, OpMIPSXORconst, types.UInt32)
-               v12.AuxInt = 3
-               v12.AddArg(ptr)
-               v11.AddArg(v12)
+               v11.AddArg(ptr)
                v10.AddArg(v11)
                v8.AddArg(v10)
                v7.AddArg(v8)
index 2f7317b501a4d20c98c6d0207cb2241cf652e85e..c0733481a895f0ba6278fbf812a1a1a603040603 100644 (file)
@@ -259,6 +259,12 @@ func check() {
                throw("atomicor8")
        }
 
+       m = [4]byte{0xff, 0xff, 0xff, 0xff}
+       atomic.And8(&m[1], 0x1)
+       if m[0] != 0xff || m[1] != 0x1 || m[2] != 0xff || m[3] != 0xff {
+               throw("atomicand8")
+       }
+
        *(*uint64)(unsafe.Pointer(&j)) = ^uint64(0)
        if j == j {
                throw("float64nan")