]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fold extensions into constants on s390x
authorMichael Munday <munday@ca.ibm.com>
Thu, 6 Oct 2016 17:49:57 +0000 (13:49 -0400)
committerMichael Munday <munday@ca.ibm.com>
Thu, 6 Oct 2016 18:57:43 +0000 (18:57 +0000)
We insert extensions when lowering comparisons and they were
blocking constant folding.

Change-Id: I804bbf91c7606612ffe921a90853844a57e55955
Reviewed-on: https://go-review.googlesource.com/30541
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/compile/internal/ssa/gen/S390X.rules
src/cmd/compile/internal/ssa/rewriteS390X.go

index 3f1f5f86ef95ad275f7504dc83741bd90f7e292d..c09f5b38effff1614a5cf9aa583dcccc03077654 100644 (file)
 (MOVWZreg x:(MOVHZreg _)) -> x
 (MOVWZreg x:(MOVWZreg _)) -> x
 
+// fold extensions into constants
+(MOVBreg (MOVDconst [c])) -> (MOVDconst [int64(int8(c))])
+(MOVBZreg (MOVDconst [c])) -> (MOVDconst [int64(uint8(c))])
+(MOVHreg (MOVDconst [c])) -> (MOVDconst [int64(int16(c))])
+(MOVHZreg (MOVDconst [c])) -> (MOVDconst [int64(uint16(c))])
+(MOVWreg (MOVDconst [c])) -> (MOVDconst [int64(int32(c))])
+(MOVWZreg (MOVDconst [c])) -> (MOVDconst [int64(uint32(c))])
+
 // sign extended loads
 // Note: The combined instruction must end up in the same block
 // as the original load. If not, we end up making a value with
index 703939a398eead2ea7a6b44bcc009d4ee5c68dc4..2c2cef1f17e62e8cbcff9eeae289420ebc47213a 100644 (file)
@@ -7364,6 +7364,19 @@ func rewriteValueS390X_OpS390XMOVBZreg(v *Value, config *Config) bool {
                v.AddArg(x)
                return true
        }
+       // match: (MOVBZreg (MOVDconst [c]))
+       // cond:
+       // result: (MOVDconst [int64(uint8(c))])
+       for {
+               v_0 := v.Args[0]
+               if v_0.Op != OpS390XMOVDconst {
+                       break
+               }
+               c := v_0.AuxInt
+               v.reset(OpS390XMOVDconst)
+               v.AuxInt = int64(uint8(c))
+               return true
+       }
        // match: (MOVBZreg x:(MOVBZload [off] {sym} ptr mem))
        // cond: x.Uses == 1 && clobber(x)
        // result: @x.Block (MOVBZload <v.Type> [off] {sym} ptr mem)
@@ -7523,6 +7536,19 @@ func rewriteValueS390X_OpS390XMOVBreg(v *Value, config *Config) bool {
                v.AddArg(x)
                return true
        }
+       // match: (MOVBreg (MOVDconst [c]))
+       // cond:
+       // result: (MOVDconst [int64(int8(c))])
+       for {
+               v_0 := v.Args[0]
+               if v_0.Op != OpS390XMOVDconst {
+                       break
+               }
+               c := v_0.AuxInt
+               v.reset(OpS390XMOVDconst)
+               v.AuxInt = int64(int8(c))
+               return true
+       }
        // match: (MOVBreg x:(MOVBZload [off] {sym} ptr mem))
        // cond: x.Uses == 1 && clobber(x)
        // result: @x.Block (MOVBload <v.Type> [off] {sym} ptr mem)
@@ -10424,6 +10450,19 @@ func rewriteValueS390X_OpS390XMOVHZreg(v *Value, config *Config) bool {
                v.AddArg(x)
                return true
        }
+       // match: (MOVHZreg (MOVDconst [c]))
+       // cond:
+       // result: (MOVDconst [int64(uint16(c))])
+       for {
+               v_0 := v.Args[0]
+               if v_0.Op != OpS390XMOVDconst {
+                       break
+               }
+               c := v_0.AuxInt
+               v.reset(OpS390XMOVDconst)
+               v.AuxInt = int64(uint16(c))
+               return true
+       }
        // match: (MOVHZreg x:(MOVHZload [off] {sym} ptr mem))
        // cond: x.Uses == 1 && clobber(x)
        // result: @x.Block (MOVHZload <v.Type> [off] {sym} ptr mem)
@@ -10635,6 +10674,19 @@ func rewriteValueS390X_OpS390XMOVHreg(v *Value, config *Config) bool {
                v.AddArg(x)
                return true
        }
+       // match: (MOVHreg (MOVDconst [c]))
+       // cond:
+       // result: (MOVDconst [int64(int16(c))])
+       for {
+               v_0 := v.Args[0]
+               if v_0.Op != OpS390XMOVDconst {
+                       break
+               }
+               c := v_0.AuxInt
+               v.reset(OpS390XMOVDconst)
+               v.AuxInt = int64(int16(c))
+               return true
+       }
        // match: (MOVHreg x:(MOVHZload [off] {sym} ptr mem))
        // cond: x.Uses == 1 && clobber(x)
        // result: @x.Block (MOVHload <v.Type> [off] {sym} ptr mem)
@@ -11865,6 +11917,19 @@ func rewriteValueS390X_OpS390XMOVWZreg(v *Value, config *Config) bool {
                v.AddArg(x)
                return true
        }
+       // match: (MOVWZreg (MOVDconst [c]))
+       // cond:
+       // result: (MOVDconst [int64(uint32(c))])
+       for {
+               v_0 := v.Args[0]
+               if v_0.Op != OpS390XMOVDconst {
+                       break
+               }
+               c := v_0.AuxInt
+               v.reset(OpS390XMOVDconst)
+               v.AuxInt = int64(uint32(c))
+               return true
+       }
        // match: (MOVWZreg x:(MOVWZload [off] {sym} ptr mem))
        // cond: x.Uses == 1 && clobber(x)
        // result: @x.Block (MOVWZload <v.Type> [off] {sym} ptr mem)
@@ -12128,6 +12193,19 @@ func rewriteValueS390X_OpS390XMOVWreg(v *Value, config *Config) bool {
                v.AddArg(x)
                return true
        }
+       // match: (MOVWreg (MOVDconst [c]))
+       // cond:
+       // result: (MOVDconst [int64(int32(c))])
+       for {
+               v_0 := v.Args[0]
+               if v_0.Op != OpS390XMOVDconst {
+                       break
+               }
+               c := v_0.AuxInt
+               v.reset(OpS390XMOVDconst)
+               v.AuxInt = int64(int32(c))
+               return true
+       }
        // match: (MOVWreg x:(MOVWZload [off] {sym} ptr mem))
        // cond: x.Uses == 1 && clobber(x)
        // result: @x.Block (MOVWload <v.Type> [off] {sym} ptr mem)