]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: don't simplify nilchecks in loops
authorAlexandru Moșoi <mosoi@google.com>
Wed, 23 Mar 2016 10:11:34 +0000 (11:11 +0100)
committerAlexandru Moșoi <alexandru@mosoi.ro>
Wed, 23 Mar 2016 15:51:55 +0000 (15:51 +0000)
khr: Lifting the nil check out of the loop altogether is an admirable
goal, and this rewrite is one step on the way. But without lifting it
out of the loop, the rewrite is just hurting us.

Fixes #14917

Change-Id: Idb917f37d89f50f8e046d5ebd7c092b1e0eb0633
Reviewed-on: https://go-review.googlesource.com/21040
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/compile/internal/ssa/gen/generic.rules
src/cmd/compile/internal/ssa/rewritegeneric.go

index d405419905ba79cb570eebc934d37a2190d92b57..1848873f20e5d8413ab3dbb0f5c2bb22309713c6 100644 (file)
 // succ* fields must be variables
 // For now, the generated successors must be a permutation of the matched successors.
 
-// Simplify nil checks.
-// These are inserted by for _, e := range a {}
-(NilCheck z:(Phi x (Add64 (Const64 [c]) y)) mem) && c > 0 && z == y -> (NilCheck x mem)
-
 // constant folding
 (Trunc16to8 (Const16 [c])) -> (Const8 [int64(int8(c))])
 (Trunc32to8 (Const32 [c])) -> (Const8 [int64(int8(c))])
index 518240f6b79a832dd05a83df59a75e221c2980ed..d30674fc3e206d7e613cc2aece8f19d972453320 100644 (file)
@@ -220,8 +220,6 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
                return rewriteValuegeneric_OpNeqPtr(v, config)
        case OpNeqSlice:
                return rewriteValuegeneric_OpNeqSlice(v, config)
-       case OpNilCheck:
-               return rewriteValuegeneric_OpNilCheck(v, config)
        case OpOffPtr:
                return rewriteValuegeneric_OpOffPtr(v, config)
        case OpOr16:
@@ -5604,42 +5602,6 @@ func rewriteValuegeneric_OpNeqSlice(v *Value, config *Config) bool {
        }
        return false
 }
-func rewriteValuegeneric_OpNilCheck(v *Value, config *Config) bool {
-       b := v.Block
-       _ = b
-       // match: (NilCheck z:(Phi x (Add64 (Const64 [c]) y)) mem)
-       // cond: c > 0 && z == y
-       // result: (NilCheck x mem)
-       for {
-               z := v.Args[0]
-               if z.Op != OpPhi {
-                       break
-               }
-               x := z.Args[0]
-               z_1 := z.Args[1]
-               if z_1.Op != OpAdd64 {
-                       break
-               }
-               z_1_0 := z_1.Args[0]
-               if z_1_0.Op != OpConst64 {
-                       break
-               }
-               c := z_1_0.AuxInt
-               y := z_1.Args[1]
-               if len(z.Args) != 2 {
-                       break
-               }
-               mem := v.Args[1]
-               if !(c > 0 && z == y) {
-                       break
-               }
-               v.reset(OpNilCheck)
-               v.AddArg(x)
-               v.AddArg(mem)
-               return true
-       }
-       return false
-}
 func rewriteValuegeneric_OpOffPtr(v *Value, config *Config) bool {
        b := v.Block
        _ = b