]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: post CL 20089 cleanups
authorDave Cheney <dave@cheney.net>
Fri, 4 Mar 2016 02:15:40 +0000 (13:15 +1100)
committerDave Cheney <dave@cheney.net>
Fri, 4 Mar 2016 04:10:36 +0000 (04:10 +0000)
This CL addresses some issues noted during CL 20089.

Change-Id: I4e91a8077c07a571ccc9c004278672eb951c5104
Reviewed-on: https://go-review.googlesource.com/20181
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/compile/internal/amd64/peep.go
src/cmd/compile/internal/arm/ggen.go
src/cmd/compile/internal/arm/peep.go
src/cmd/compile/internal/arm64/ggen.go
src/cmd/compile/internal/arm64/peep.go
src/cmd/compile/internal/gc/pgen.go
src/cmd/compile/internal/mips64/ggen.go
src/cmd/compile/internal/mips64/peep.go
src/cmd/compile/internal/ppc64/ggen.go
src/cmd/compile/internal/ppc64/peep.go

index f0e22de6fd3385de11e311a5b370838aa1b218d4..e8817e829c5730a108904c737b1e8e30c93df26e 100644 (file)
@@ -605,9 +605,7 @@ func subprop(r0 *gc.Flow) bool {
                                }
                        }
 
-                       t := int(v1.Reg)
-                       v1.Reg = v2.Reg
-                       v2.Reg = int16(t)
+                       v1.Reg, v2.Reg = v2.Reg, v1.Reg
                        if gc.Debug['P'] != 0 {
                                fmt.Printf("%v last\n", r.Prog)
                        }
@@ -948,19 +946,16 @@ func copyau(a *obj.Addr, v *obj.Addr) bool {
  */
 func copysub(a *obj.Addr, v *obj.Addr, s *obj.Addr, f int) int {
        if copyas(a, v) {
-               reg := int(s.Reg)
-               if reg >= x86.REG_AX && reg <= x86.REG_R15 || reg >= x86.REG_X0 && reg <= x86.REG_X0+15 {
+               if s.Reg >= x86.REG_AX && s.Reg <= x86.REG_R15 || s.Reg >= x86.REG_X0 && s.Reg <= x86.REG_X0+15 {
                        if f != 0 {
-                               a.Reg = int16(reg)
+                               a.Reg = s.Reg
                        }
                }
-
                return 0
        }
 
        if regtyp(v) {
-               reg := int(v.Reg)
-               if a.Type == obj.TYPE_MEM && int(a.Reg) == reg {
+               if a.Type == obj.TYPE_MEM && a.Reg == v.Reg {
                        if (s.Reg == x86.REG_BP || s.Reg == x86.REG_R13) && a.Index != x86.REG_NONE {
                                return 1 /* can't use BP-base with index */
                        }
@@ -968,18 +963,14 @@ func copysub(a *obj.Addr, v *obj.Addr, s *obj.Addr, f int) int {
                                a.Reg = s.Reg
                        }
                }
-
-               //                      return 0;
-               if int(a.Index) == reg {
+               if a.Index == v.Reg {
                        if f != 0 {
                                a.Index = s.Reg
                        }
                        return 0
                }
-
                return 0
        }
-
        return 0
 }
 
index d52e27a3b1ceb304442228518b7d99c21df5f450..d4d4e27d099f7e15ec67967bcf6e47c921bc73ef 100644 (file)
@@ -121,7 +121,7 @@ func cgen_hmul(nl *gc.Node, nr *gc.Node, res *gc.Node) {
        }
 
        t := nl.Type
-       w := int(t.Width * 8)
+       w := t.Width * 8
        var n1 gc.Node
        gc.Regalloc(&n1, t, res)
        gc.Cgen(nl, &n1)
index 67944414896fdac3c7e2784bbdea985e7d917467..3f13b4993a545b97ace348585c1d3949cfaa97c1 100644 (file)
@@ -308,9 +308,7 @@ func subprop(r0 *gc.Flow) bool {
                                                        }
                                                }
 
-                                               t := int(v1.Reg)
-                                               v1.Reg = v2.Reg
-                                               v2.Reg = int16(t)
+                                               v1.Reg, v2.Reg = v2.Reg, v1.Reg
                                                if gc.Debug['P'] != 0 {
                                                        fmt.Printf("%v last\n", r.Prog)
                                                }
@@ -571,8 +569,8 @@ func shiftprop(r *gc.Flow) bool {
                return false
        }
 
-       n := int(p.To.Reg)
-       a := obj.Addr{}
+       n := p.To.Reg
+       var a obj.Addr
        if p.Reg != 0 && p.Reg != p.To.Reg {
                a.Type = obj.TYPE_REG
                a.Reg = p.Reg
@@ -644,7 +642,7 @@ func shiftprop(r *gc.Flow) bool {
                arm.ASBC,
                arm.ARSB,
                arm.ARSC:
-               if int(p1.Reg) == n || (p1.Reg == 0 && p1.To.Type == obj.TYPE_REG && int(p1.To.Reg) == n) {
+               if p1.Reg == n || (p1.Reg == 0 && p1.To.Type == obj.TYPE_REG && p1.To.Reg == n) {
                        if p1.From.Type != obj.TYPE_REG {
                                if gc.Debug['P'] != 0 {
                                        fmt.Printf("\tcan't swap; FAILURE\n")
@@ -653,7 +651,7 @@ func shiftprop(r *gc.Flow) bool {
                        }
 
                        p1.Reg = p1.From.Reg
-                       p1.From.Reg = int16(n)
+                       p1.From.Reg = n
                        switch p1.As {
                        case arm.ASUB:
                                p1.As = arm.ARSB
@@ -678,14 +676,14 @@ func shiftprop(r *gc.Flow) bool {
                arm.ATST,
                arm.ACMP,
                arm.ACMN:
-               if int(p1.Reg) == n {
+               if p1.Reg == n {
                        if gc.Debug['P'] != 0 {
                                fmt.Printf("\tcan't swap; FAILURE\n")
                        }
                        return false
                }
 
-               if p1.Reg == 0 && int(p1.To.Reg) == n {
+               if p1.Reg == 0 && p1.To.Reg == n {
                        if gc.Debug['P'] != 0 {
                                fmt.Printf("\tshift result used twice; FAILURE\n")
                        }
@@ -700,7 +698,7 @@ func shiftprop(r *gc.Flow) bool {
                        return false
                }
 
-               if p1.From.Type != obj.TYPE_REG || int(p1.From.Reg) != n {
+               if p1.From.Type != obj.TYPE_REG || p1.From.Reg != n {
                        if gc.Debug['P'] != 0 {
                                fmt.Printf("\tBOTCH: where is it used?; FAILURE\n")
                        }
@@ -711,7 +709,7 @@ func shiftprop(r *gc.Flow) bool {
        /* check whether shift result is used subsequently */
        p2 := p1
 
-       if int(p1.To.Reg) != n {
+       if p1.To.Reg != n {
                var p1 *obj.Prog
                for {
                        r1 = gc.Uniqs(r1)
@@ -746,19 +744,18 @@ func shiftprop(r *gc.Flow) bool {
 
        /* make the substitution */
        p2.From.Reg = 0
-
-       o := int(p.Reg)
+       o := p.Reg
        if o == 0 {
-               o = int(p.To.Reg)
+               o = p.To.Reg
        }
        o &= 15
 
        switch p.From.Type {
        case obj.TYPE_CONST:
-               o |= int((p.From.Offset & 0x1f) << 7)
+               o |= int16(p.From.Offset&0x1f) << 7
 
        case obj.TYPE_REG:
-               o |= 1<<4 | (int(p.From.Reg)&15)<<8
+               o |= 1<<4 | (p.From.Reg&15)<<8
        }
 
        switch p.As {
index 13be1b6fe10a34e5f90c1968e11bbe3ab1e2e03b..da2f71cfc39e64535d5634ef9d4a71edcd06bba6 100644 (file)
@@ -263,7 +263,7 @@ func cgen_hmul(nl *gc.Node, nr *gc.Node, res *gc.Node) {
        }
 
        t := nl.Type
-       w := int(t.Width * 8)
+       w := t.Width * 8
        var n1 gc.Node
        gc.Cgenr(nl, &n1, res)
        var n2 gc.Node
@@ -275,7 +275,7 @@ func cgen_hmul(nl *gc.Node, nr *gc.Node, res *gc.Node) {
                gins(optoas(gc.OMUL, t), &n2, &n1)
                p := gins(arm64.AASR, nil, &n1)
                p.From.Type = obj.TYPE_CONST
-               p.From.Offset = int64(w)
+               p.From.Offset = w
 
        case gc.TUINT8,
                gc.TUINT16,
@@ -283,7 +283,7 @@ func cgen_hmul(nl *gc.Node, nr *gc.Node, res *gc.Node) {
                gins(optoas(gc.OMUL, t), &n2, &n1)
                p := gins(arm64.ALSR, nil, &n1)
                p.From.Type = obj.TYPE_CONST
-               p.From.Offset = int64(w)
+               p.From.Offset = w
 
        case gc.TINT64,
                gc.TUINT64:
@@ -315,7 +315,7 @@ func cgen_shift(op gc.Op, bounded bool, nl *gc.Node, nr *gc.Node, res *gc.Node)
                gc.Regalloc(&n1, nl.Type, res)
                gc.Cgen(nl, &n1)
                sc := uint64(nr.Int())
-               if sc >= uint64(nl.Type.Width*8) {
+               if sc >= uint64(nl.Type.Width)*8 {
                        // large shift gets 2 shifts by width-1
                        var n3 gc.Node
                        gc.Nodconst(&n3, gc.Types[gc.TUINT32], nl.Type.Width*8-1)
index 0d3dc2b59df156b5cb5a3a0536715b2a10569fa9..d821edfed32a724e9bf45ab2f90d9100e55dadc3 100644 (file)
@@ -253,9 +253,7 @@ func subprop(r0 *gc.Flow) bool {
                                                }
                                        }
 
-                                       t := int(v1.Reg)
-                                       v1.Reg = v2.Reg
-                                       v2.Reg = int16(t)
+                                       v1.Reg, v2.Reg = v2.Reg, v1.Reg
                                        if gc.Debug['P'] != 0 {
                                                fmt.Printf("%v last\n", r.Prog)
                                        }
index 432637ab55cc06450b93bfeaea2cf6a9f00e74f1..963d59fcba7ea9b8b3e1a7592aea5b81dc7f4e06 100644 (file)
@@ -355,7 +355,6 @@ func compile(fn *Node) {
        Curfn = fn
        dowidth(Curfn.Type)
 
-       var oldstksize int64
        var nod1 Node
        var ptxt *obj.Prog
        var pl *obj.Plist
@@ -535,13 +534,8 @@ func compile(fn *Node) {
 
        Thearch.Expandchecks(ptxt)
 
-       oldstksize = Stksize
        allocauto(ptxt)
 
-       if false {
-               fmt.Printf("allocauto: %d to %d\n", oldstksize, Stksize)
-       }
-
        setlineno(Curfn)
        if Stksize+Maxarg > 1<<31 {
                Yyerror("stack frame too large (>2GB)")
index 6ef661a24c9895d1ee6e0e99cf8eb8d2c4893cbb..6436ce6a83c9e8a501623b0ed1607d399ba0a555 100644 (file)
@@ -204,7 +204,7 @@ func cgen_hmul(nl *gc.Node, nr *gc.Node, res *gc.Node) {
        }
 
        t := nl.Type
-       w := int(t.Width * 8)
+       w := t.Width * 8
        var n1 gc.Node
        gc.Cgenr(nl, &n1, res)
        var n2 gc.Node
@@ -219,7 +219,7 @@ func cgen_hmul(nl *gc.Node, nr *gc.Node, res *gc.Node) {
                gins(mips.AMOVV, &lo, &n1)
                p := gins(mips.ASRAV, nil, &n1)
                p.From.Type = obj.TYPE_CONST
-               p.From.Offset = int64(w)
+               p.From.Offset = w
 
        case gc.TUINT8,
                gc.TUINT16,
@@ -230,7 +230,7 @@ func cgen_hmul(nl *gc.Node, nr *gc.Node, res *gc.Node) {
                gins(mips.AMOVV, &lo, &n1)
                p := gins(mips.ASRLV, nil, &n1)
                p.From.Type = obj.TYPE_CONST
-               p.From.Offset = int64(w)
+               p.From.Offset = w
 
        case gc.TINT64,
                gc.TUINT64:
index aa57c15ca8d7cf22fc9115a02ceca45cb995964c..1da55001a815c87e0871ee2bbe2d35092e55c740 100644 (file)
@@ -242,9 +242,7 @@ func subprop(r0 *gc.Flow) bool {
                                                }
                                        }
 
-                                       t := int(v1.Reg)
-                                       v1.Reg = v2.Reg
-                                       v2.Reg = int16(t)
+                                       v1.Reg, v2.Reg = v2.Reg, v1.Reg
                                        if gc.Debug['P'] != 0 {
                                                fmt.Printf("%v last\n", r.Prog)
                                        }
index ac7ccc0a79974923b46a6de7a1451e273cf5f9c6..8e63d38ce117c7b12607752605f13ab23f8cb351 100644 (file)
@@ -252,7 +252,7 @@ func cgen_hmul(nl *gc.Node, nr *gc.Node, res *gc.Node) {
        }
 
        t := nl.Type
-       w := int(t.Width * 8)
+       w := t.Width * 8
        var n1 gc.Node
        gc.Cgenr(nl, &n1, res)
        var n2 gc.Node
@@ -264,7 +264,7 @@ func cgen_hmul(nl *gc.Node, nr *gc.Node, res *gc.Node) {
                gins(optoas(gc.OMUL, t), &n2, &n1)
                p := gins(ppc64.ASRAD, nil, &n1)
                p.From.Type = obj.TYPE_CONST
-               p.From.Offset = int64(w)
+               p.From.Offset = w
 
        case gc.TUINT8,
                gc.TUINT16,
@@ -272,7 +272,7 @@ func cgen_hmul(nl *gc.Node, nr *gc.Node, res *gc.Node) {
                gins(optoas(gc.OMUL, t), &n2, &n1)
                p := gins(ppc64.ASRD, nil, &n1)
                p.From.Type = obj.TYPE_CONST
-               p.From.Offset = int64(w)
+               p.From.Offset = w
 
        case gc.TINT64,
                gc.TUINT64:
index 68ca5149eb5be6e51d6e31490e6974467cd3b142..a23ed1042988e5f37a23e3b8e79fe7c082dd0ff2 100644 (file)
@@ -441,9 +441,7 @@ func subprop(r0 *gc.Flow) bool {
                                                }
                                        }
 
-                                       t := int(v1.Reg)
-                                       v1.Reg = v2.Reg
-                                       v2.Reg = int16(t)
+                                       v1.Reg, v2.Reg = v2.Reg, v1.Reg
                                        if gc.Debug['P'] != 0 {
                                                fmt.Printf("%v last\n", r.Prog)
                                        }