]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: use bounded shift information on ppc64x
authorLynn Boger <laboger@linux.vnet.ibm.com>
Thu, 13 Sep 2018 18:45:23 +0000 (14:45 -0400)
committerLynn Boger <laboger@linux.vnet.ibm.com>
Tue, 18 Sep 2018 12:42:02 +0000 (12:42 +0000)
Makes use of bounded shift information to generate
more efficient shift instructions.

Updates #25167 for ppc64x

Change-Id: I7fc8d49a3fb3e0f273cc51bc767470b239cbdca7
Reviewed-on: https://go-review.googlesource.com/135380
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
src/cmd/compile/internal/ssa/gen/PPC64.rules
src/cmd/compile/internal/ssa/rewritePPC64.go

index bc218444c0838ae43ebfb313fb2d50336dfb7345..e9e3cbc5bba680d778c93b49f861ce40d7339761 100644 (file)
 (Rsh8x32   x (MOVDconst [c])) && uint32(c) < 8  -> (SRAWconst (SignExt8to32  x) [c])
 (Rsh8Ux32  x (MOVDconst [c])) && uint32(c) < 8  -> (SRWconst (ZeroExt8to32  x) [c])
 
+// Lower bounded shifts first. No need to check shift value.
+(Lsh64x(64|32|16|8)  x y) && shiftIsBounded(v) -> (SLD x y)
+(Lsh32x(64|32|16|8)  x y) && shiftIsBounded(v) -> (SLW x y)
+(Lsh16x(64|32|16|8)  x y) && shiftIsBounded(v) -> (SLW x y)
+(Lsh8x(64|32|16|8)   x y) && shiftIsBounded(v) -> (SLW x y)
+(Rsh64Ux(64|32|16|8) x y) && shiftIsBounded(v) -> (SRD x y)
+(Rsh32Ux(64|32|16|8) x y) && shiftIsBounded(v) -> (SRW x y)
+(Rsh16Ux(64|32|16|8) x y) && shiftIsBounded(v) -> (SRW (MOVHZreg x) y)
+(Rsh8Ux(64|32|16|8)  x y) && shiftIsBounded(v) -> (SRW (MOVBZreg x) y)
+(Rsh64x(64|32|16|8)  x y) && shiftIsBounded(v) -> (SRAD x y)
+(Rsh32x(64|32|16|8)  x y) && shiftIsBounded(v) -> (SRAW x y)
+(Rsh16x(64|32|16|8)  x y) && shiftIsBounded(v) -> (SRAW (MOVHreg x) y)
+(Rsh8x(64|32|16|8)   x y) && shiftIsBounded(v) -> (SRAW (MOVBreg x) y)
+
 // non-constant rotates
 // These are subexpressions found in statements that can become rotates
 // In these cases the shift count is known to be < 64 so the more complicated expressions
index 19ee33d9faf1aa6b0fb00928ec36ca53affe2ae0..a53db286d45c8f34071e2ed312cc14910ba217bf 100644 (file)
@@ -544,7 +544,7 @@ func rewriteValuePPC64(v *Value) bool {
        case OpRsh32Ux32:
                return rewriteValuePPC64_OpRsh32Ux32_0(v)
        case OpRsh32Ux64:
-               return rewriteValuePPC64_OpRsh32Ux64_0(v)
+               return rewriteValuePPC64_OpRsh32Ux64_0(v) || rewriteValuePPC64_OpRsh32Ux64_10(v)
        case OpRsh32Ux8:
                return rewriteValuePPC64_OpRsh32Ux8_0(v)
        case OpRsh32x16:
@@ -552,7 +552,7 @@ func rewriteValuePPC64(v *Value) bool {
        case OpRsh32x32:
                return rewriteValuePPC64_OpRsh32x32_0(v)
        case OpRsh32x64:
-               return rewriteValuePPC64_OpRsh32x64_0(v)
+               return rewriteValuePPC64_OpRsh32x64_0(v) || rewriteValuePPC64_OpRsh32x64_10(v)
        case OpRsh32x8:
                return rewriteValuePPC64_OpRsh32x8_0(v)
        case OpRsh64Ux16:
@@ -560,7 +560,7 @@ func rewriteValuePPC64(v *Value) bool {
        case OpRsh64Ux32:
                return rewriteValuePPC64_OpRsh64Ux32_0(v)
        case OpRsh64Ux64:
-               return rewriteValuePPC64_OpRsh64Ux64_0(v)
+               return rewriteValuePPC64_OpRsh64Ux64_0(v) || rewriteValuePPC64_OpRsh64Ux64_10(v)
        case OpRsh64Ux8:
                return rewriteValuePPC64_OpRsh64Ux8_0(v)
        case OpRsh64x16:
@@ -568,7 +568,7 @@ func rewriteValuePPC64(v *Value) bool {
        case OpRsh64x32:
                return rewriteValuePPC64_OpRsh64x32_0(v)
        case OpRsh64x64:
-               return rewriteValuePPC64_OpRsh64x64_0(v)
+               return rewriteValuePPC64_OpRsh64x64_0(v) || rewriteValuePPC64_OpRsh64x64_10(v)
        case OpRsh64x8:
                return rewriteValuePPC64_OpRsh64x8_0(v)
        case OpRsh8Ux16:
@@ -3070,6 +3070,21 @@ func rewriteValuePPC64_OpLsh16x16_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Lsh16x16 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SLW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SLW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Lsh16x16 x y)
        // cond:
        // result: (SLW x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-16] (ZeroExt16to64 y)))))
        for {
@@ -3136,6 +3151,21 @@ func rewriteValuePPC64_OpLsh16x32_0(v *Value) bool {
                return true
        }
        // match: (Lsh16x32 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SLW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SLW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Lsh16x32 x y)
        // cond:
        // result: (SLW x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-16] (ZeroExt32to64 y)))))
        for {
@@ -3219,6 +3249,21 @@ func rewriteValuePPC64_OpLsh16x64_0(v *Value) bool {
                return true
        }
        // match: (Lsh16x64 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SLW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SLW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Lsh16x64 x y)
        // cond:
        // result: (SLW x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-16] y))))
        for {
@@ -3245,6 +3290,21 @@ func rewriteValuePPC64_OpLsh16x8_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Lsh16x8 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SLW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SLW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Lsh16x8 x y)
        // cond:
        // result: (SLW x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-16] (ZeroExt8to64 y)))))
        for {
@@ -3273,6 +3333,21 @@ func rewriteValuePPC64_OpLsh32x16_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Lsh32x16 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SLW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SLW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Lsh32x16 x y)
        // cond:
        // result: (SLW x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-32] (ZeroExt16to64 y)))))
        for {
@@ -3339,6 +3414,21 @@ func rewriteValuePPC64_OpLsh32x32_0(v *Value) bool {
                return true
        }
        // match: (Lsh32x32 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SLW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SLW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Lsh32x32 x y)
        // cond:
        // result: (SLW x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-32] (ZeroExt32to64 y)))))
        for {
@@ -3421,6 +3511,21 @@ func rewriteValuePPC64_OpLsh32x64_0(v *Value) bool {
                v.AddArg(x)
                return true
        }
+       // match: (Lsh32x64 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SLW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SLW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
        // match: (Lsh32x64 x (AND y (MOVDconst [31])))
        // cond:
        // result: (SLW x (ANDconst <typ.Int32> [31] y))
@@ -3527,6 +3632,21 @@ func rewriteValuePPC64_OpLsh32x8_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Lsh32x8 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SLW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SLW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Lsh32x8 x y)
        // cond:
        // result: (SLW x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-32] (ZeroExt8to64 y)))))
        for {
@@ -3555,6 +3675,21 @@ func rewriteValuePPC64_OpLsh64x16_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Lsh64x16 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SLD x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SLD)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Lsh64x16 x y)
        // cond:
        // result: (SLD x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-64] (ZeroExt16to64 y)))))
        for {
@@ -3621,6 +3756,21 @@ func rewriteValuePPC64_OpLsh64x32_0(v *Value) bool {
                return true
        }
        // match: (Lsh64x32 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SLD x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SLD)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Lsh64x32 x y)
        // cond:
        // result: (SLD x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-64] (ZeroExt32to64 y)))))
        for {
@@ -3703,6 +3853,21 @@ func rewriteValuePPC64_OpLsh64x64_0(v *Value) bool {
                v.AddArg(x)
                return true
        }
+       // match: (Lsh64x64 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SLD x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SLD)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
        // match: (Lsh64x64 x (AND y (MOVDconst [63])))
        // cond:
        // result: (SLD x (ANDconst <typ.Int64> [63] y))
@@ -3809,6 +3974,21 @@ func rewriteValuePPC64_OpLsh64x8_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Lsh64x8 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SLD x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SLD)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Lsh64x8 x y)
        // cond:
        // result: (SLD x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-64] (ZeroExt8to64 y)))))
        for {
@@ -3837,6 +4017,21 @@ func rewriteValuePPC64_OpLsh8x16_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Lsh8x16 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SLW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SLW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Lsh8x16 x y)
        // cond:
        // result: (SLW x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-8] (ZeroExt16to64 y)))))
        for {
@@ -3903,6 +4098,21 @@ func rewriteValuePPC64_OpLsh8x32_0(v *Value) bool {
                return true
        }
        // match: (Lsh8x32 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SLW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SLW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Lsh8x32 x y)
        // cond:
        // result: (SLW x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-8] (ZeroExt32to64 y)))))
        for {
@@ -3986,6 +4196,21 @@ func rewriteValuePPC64_OpLsh8x64_0(v *Value) bool {
                return true
        }
        // match: (Lsh8x64 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SLW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SLW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Lsh8x64 x y)
        // cond:
        // result: (SLW x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-8] y))))
        for {
@@ -4012,6 +4237,21 @@ func rewriteValuePPC64_OpLsh8x8_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Lsh8x8 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SLW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SLW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Lsh8x8 x y)
        // cond:
        // result: (SLW x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-8] (ZeroExt8to64 y)))))
        for {
@@ -25137,6 +25377,23 @@ func rewriteValuePPC64_OpRsh16Ux16_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Rsh16Ux16 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRW (MOVHZreg x) y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRW)
+               v0 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64)
+               v0.AddArg(x)
+               v.AddArg(v0)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh16Ux16 x y)
        // cond:
        // result: (SRW (ZeroExt16to32 x) (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-16] (ZeroExt16to64 y)))))
        for {
@@ -25209,6 +25466,23 @@ func rewriteValuePPC64_OpRsh16Ux32_0(v *Value) bool {
                return true
        }
        // match: (Rsh16Ux32 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRW (MOVHZreg x) y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRW)
+               v0 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64)
+               v0.AddArg(x)
+               v.AddArg(v0)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh16Ux32 x y)
        // cond:
        // result: (SRW (ZeroExt16to32 x) (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-16] (ZeroExt32to64 y)))))
        for {
@@ -25298,6 +25572,23 @@ func rewriteValuePPC64_OpRsh16Ux64_0(v *Value) bool {
                return true
        }
        // match: (Rsh16Ux64 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRW (MOVHZreg x) y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRW)
+               v0 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64)
+               v0.AddArg(x)
+               v.AddArg(v0)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh16Ux64 x y)
        // cond:
        // result: (SRW (ZeroExt16to32 x) (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-16] y))))
        for {
@@ -25326,6 +25617,23 @@ func rewriteValuePPC64_OpRsh16Ux8_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Rsh16Ux8 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRW (MOVHZreg x) y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRW)
+               v0 := b.NewValue0(v.Pos, OpPPC64MOVHZreg, typ.Int64)
+               v0.AddArg(x)
+               v.AddArg(v0)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh16Ux8 x y)
        // cond:
        // result: (SRW (ZeroExt16to32 x) (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-16] (ZeroExt8to64 y)))))
        for {
@@ -25356,18 +25664,35 @@ func rewriteValuePPC64_OpRsh16x16_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Rsh16x16 x y)
-       // cond:
-       // result: (SRAW (SignExt16to32 x) (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-16] (ZeroExt16to64 y)))))
+       // cond: shiftIsBounded(v)
+       // result: (SRAW (MOVHreg x) y)
        for {
                _ = v.Args[1]
                x := v.Args[0]
                y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
                v.reset(OpPPC64SRAW)
-               v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32)
+               v0 := b.NewValue0(v.Pos, OpPPC64MOVHreg, typ.Int64)
                v0.AddArg(x)
                v.AddArg(v0)
-               v1 := b.NewValue0(v.Pos, OpPPC64ORN, typ.Int64)
-               v1.AddArg(y)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh16x16 x y)
+       // cond:
+       // result: (SRAW (SignExt16to32 x) (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-16] (ZeroExt16to64 y)))))
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               v.reset(OpPPC64SRAW)
+               v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32)
+               v0.AddArg(x)
+               v.AddArg(v0)
+               v1 := b.NewValue0(v.Pos, OpPPC64ORN, typ.Int64)
+               v1.AddArg(y)
                v2 := b.NewValue0(v.Pos, OpPPC64MaskIfNotCarry, typ.Int64)
                v3 := b.NewValue0(v.Pos, OpPPC64ADDconstForCarry, types.TypeFlags)
                v3.AuxInt = -16
@@ -25428,6 +25753,23 @@ func rewriteValuePPC64_OpRsh16x32_0(v *Value) bool {
                return true
        }
        // match: (Rsh16x32 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRAW (MOVHreg x) y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRAW)
+               v0 := b.NewValue0(v.Pos, OpPPC64MOVHreg, typ.Int64)
+               v0.AddArg(x)
+               v.AddArg(v0)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh16x32 x y)
        // cond:
        // result: (SRAW (SignExt16to32 x) (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-16] (ZeroExt32to64 y)))))
        for {
@@ -25521,6 +25863,23 @@ func rewriteValuePPC64_OpRsh16x64_0(v *Value) bool {
                return true
        }
        // match: (Rsh16x64 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRAW (MOVHreg x) y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRAW)
+               v0 := b.NewValue0(v.Pos, OpPPC64MOVHreg, typ.Int64)
+               v0.AddArg(x)
+               v.AddArg(v0)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh16x64 x y)
        // cond:
        // result: (SRAW (SignExt16to32 x) (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-16] y))))
        for {
@@ -25549,6 +25908,23 @@ func rewriteValuePPC64_OpRsh16x8_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Rsh16x8 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRAW (MOVHreg x) y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRAW)
+               v0 := b.NewValue0(v.Pos, OpPPC64MOVHreg, typ.Int64)
+               v0.AddArg(x)
+               v.AddArg(v0)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh16x8 x y)
        // cond:
        // result: (SRAW (SignExt16to32 x) (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-16] (ZeroExt8to64 y)))))
        for {
@@ -25579,6 +25955,21 @@ func rewriteValuePPC64_OpRsh32Ux16_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Rsh32Ux16 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh32Ux16 x y)
        // cond:
        // result: (SRW x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-32] (ZeroExt16to64 y)))))
        for {
@@ -25645,6 +26036,21 @@ func rewriteValuePPC64_OpRsh32Ux32_0(v *Value) bool {
                return true
        }
        // match: (Rsh32Ux32 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh32Ux32 x y)
        // cond:
        // result: (SRW x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-32] (ZeroExt32to64 y)))))
        for {
@@ -25727,6 +26133,21 @@ func rewriteValuePPC64_OpRsh32Ux64_0(v *Value) bool {
                v.AddArg(x)
                return true
        }
+       // match: (Rsh32Ux64 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
        // match: (Rsh32Ux64 x (AND y (MOVDconst [31])))
        // cond:
        // result: (SRW x (ANDconst <typ.Int32> [31] y))
@@ -25951,6 +26372,13 @@ func rewriteValuePPC64_OpRsh32Ux64_0(v *Value) bool {
                v.AddArg(v0)
                return true
        }
+       return false
+}
+func rewriteValuePPC64_OpRsh32Ux64_10(v *Value) bool {
+       b := v.Block
+       _ = b
+       typ := &b.Func.Config.Types
+       _ = typ
        // match: (Rsh32Ux64 x y)
        // cond:
        // result: (SRW x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-32] y))))
@@ -25978,6 +26406,21 @@ func rewriteValuePPC64_OpRsh32Ux8_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Rsh32Ux8 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh32Ux8 x y)
        // cond:
        // result: (SRW x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-32] (ZeroExt8to64 y)))))
        for {
@@ -26006,6 +26449,21 @@ func rewriteValuePPC64_OpRsh32x16_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Rsh32x16 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRAW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRAW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh32x16 x y)
        // cond:
        // result: (SRAW x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-32] (ZeroExt16to64 y)))))
        for {
@@ -26072,6 +26530,21 @@ func rewriteValuePPC64_OpRsh32x32_0(v *Value) bool {
                return true
        }
        // match: (Rsh32x32 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRAW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRAW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh32x32 x y)
        // cond:
        // result: (SRAW x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-32] (ZeroExt32to64 y)))))
        for {
@@ -26156,6 +26629,21 @@ func rewriteValuePPC64_OpRsh32x64_0(v *Value) bool {
                v.AddArg(x)
                return true
        }
+       // match: (Rsh32x64 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRAW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRAW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
        // match: (Rsh32x64 x (AND y (MOVDconst [31])))
        // cond:
        // result: (SRAW x (ANDconst <typ.Int32> [31] y))
@@ -26380,6 +26868,13 @@ func rewriteValuePPC64_OpRsh32x64_0(v *Value) bool {
                v.AddArg(v0)
                return true
        }
+       return false
+}
+func rewriteValuePPC64_OpRsh32x64_10(v *Value) bool {
+       b := v.Block
+       _ = b
+       typ := &b.Func.Config.Types
+       _ = typ
        // match: (Rsh32x64 x y)
        // cond:
        // result: (SRAW x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-32] y))))
@@ -26407,6 +26902,21 @@ func rewriteValuePPC64_OpRsh32x8_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Rsh32x8 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRAW x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRAW)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh32x8 x y)
        // cond:
        // result: (SRAW x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-32] (ZeroExt8to64 y)))))
        for {
@@ -26435,6 +26945,21 @@ func rewriteValuePPC64_OpRsh64Ux16_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Rsh64Ux16 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRD x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRD)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh64Ux16 x y)
        // cond:
        // result: (SRD x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-64] (ZeroExt16to64 y)))))
        for {
@@ -26501,6 +27026,21 @@ func rewriteValuePPC64_OpRsh64Ux32_0(v *Value) bool {
                return true
        }
        // match: (Rsh64Ux32 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRD x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRD)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh64Ux32 x y)
        // cond:
        // result: (SRD x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-64] (ZeroExt32to64 y)))))
        for {
@@ -26583,6 +27123,21 @@ func rewriteValuePPC64_OpRsh64Ux64_0(v *Value) bool {
                v.AddArg(x)
                return true
        }
+       // match: (Rsh64Ux64 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRD x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRD)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
        // match: (Rsh64Ux64 x (AND y (MOVDconst [63])))
        // cond:
        // result: (SRD x (ANDconst <typ.Int64> [63] y))
@@ -26807,6 +27362,13 @@ func rewriteValuePPC64_OpRsh64Ux64_0(v *Value) bool {
                v.AddArg(v0)
                return true
        }
+       return false
+}
+func rewriteValuePPC64_OpRsh64Ux64_10(v *Value) bool {
+       b := v.Block
+       _ = b
+       typ := &b.Func.Config.Types
+       _ = typ
        // match: (Rsh64Ux64 x y)
        // cond:
        // result: (SRD x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-64] y))))
@@ -26834,6 +27396,21 @@ func rewriteValuePPC64_OpRsh64Ux8_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Rsh64Ux8 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRD x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRD)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh64Ux8 x y)
        // cond:
        // result: (SRD x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-64] (ZeroExt8to64 y)))))
        for {
@@ -26862,6 +27439,21 @@ func rewriteValuePPC64_OpRsh64x16_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Rsh64x16 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRAD x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRAD)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh64x16 x y)
        // cond:
        // result: (SRAD x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-64] (ZeroExt16to64 y)))))
        for {
@@ -26928,6 +27520,21 @@ func rewriteValuePPC64_OpRsh64x32_0(v *Value) bool {
                return true
        }
        // match: (Rsh64x32 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRAD x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRAD)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh64x32 x y)
        // cond:
        // result: (SRAD x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-64] (ZeroExt32to64 y)))))
        for {
@@ -27012,6 +27619,21 @@ func rewriteValuePPC64_OpRsh64x64_0(v *Value) bool {
                v.AddArg(x)
                return true
        }
+       // match: (Rsh64x64 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRAD x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRAD)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
        // match: (Rsh64x64 x (AND y (MOVDconst [63])))
        // cond:
        // result: (SRAD x (ANDconst <typ.Int64> [63] y))
@@ -27236,6 +27858,13 @@ func rewriteValuePPC64_OpRsh64x64_0(v *Value) bool {
                v.AddArg(v0)
                return true
        }
+       return false
+}
+func rewriteValuePPC64_OpRsh64x64_10(v *Value) bool {
+       b := v.Block
+       _ = b
+       typ := &b.Func.Config.Types
+       _ = typ
        // match: (Rsh64x64 x y)
        // cond:
        // result: (SRAD x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-64] y))))
@@ -27263,6 +27892,21 @@ func rewriteValuePPC64_OpRsh64x8_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Rsh64x8 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRAD x y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRAD)
+               v.AddArg(x)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh64x8 x y)
        // cond:
        // result: (SRAD x (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-64] (ZeroExt8to64 y)))))
        for {
@@ -27291,6 +27935,23 @@ func rewriteValuePPC64_OpRsh8Ux16_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Rsh8Ux16 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRW (MOVBZreg x) y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRW)
+               v0 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64)
+               v0.AddArg(x)
+               v.AddArg(v0)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh8Ux16 x y)
        // cond:
        // result: (SRW (ZeroExt8to32 x) (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-8] (ZeroExt16to64 y)))))
        for {
@@ -27363,6 +28024,23 @@ func rewriteValuePPC64_OpRsh8Ux32_0(v *Value) bool {
                return true
        }
        // match: (Rsh8Ux32 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRW (MOVBZreg x) y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRW)
+               v0 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64)
+               v0.AddArg(x)
+               v.AddArg(v0)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh8Ux32 x y)
        // cond:
        // result: (SRW (ZeroExt8to32 x) (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-8] (ZeroExt32to64 y)))))
        for {
@@ -27452,6 +28130,23 @@ func rewriteValuePPC64_OpRsh8Ux64_0(v *Value) bool {
                return true
        }
        // match: (Rsh8Ux64 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRW (MOVBZreg x) y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRW)
+               v0 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64)
+               v0.AddArg(x)
+               v.AddArg(v0)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh8Ux64 x y)
        // cond:
        // result: (SRW (ZeroExt8to32 x) (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-8] y))))
        for {
@@ -27480,6 +28175,23 @@ func rewriteValuePPC64_OpRsh8Ux8_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Rsh8Ux8 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRW (MOVBZreg x) y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRW)
+               v0 := b.NewValue0(v.Pos, OpPPC64MOVBZreg, typ.Int64)
+               v0.AddArg(x)
+               v.AddArg(v0)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh8Ux8 x y)
        // cond:
        // result: (SRW (ZeroExt8to32 x) (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-8] (ZeroExt8to64 y)))))
        for {
@@ -27510,6 +28222,23 @@ func rewriteValuePPC64_OpRsh8x16_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Rsh8x16 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRAW (MOVBreg x) y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRAW)
+               v0 := b.NewValue0(v.Pos, OpPPC64MOVBreg, typ.Int64)
+               v0.AddArg(x)
+               v.AddArg(v0)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh8x16 x y)
        // cond:
        // result: (SRAW (SignExt8to32 x) (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-8] (ZeroExt16to64 y)))))
        for {
@@ -27582,6 +28311,23 @@ func rewriteValuePPC64_OpRsh8x32_0(v *Value) bool {
                return true
        }
        // match: (Rsh8x32 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRAW (MOVBreg x) y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRAW)
+               v0 := b.NewValue0(v.Pos, OpPPC64MOVBreg, typ.Int64)
+               v0.AddArg(x)
+               v.AddArg(v0)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh8x32 x y)
        // cond:
        // result: (SRAW (SignExt8to32 x) (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-8] (ZeroExt32to64 y)))))
        for {
@@ -27675,6 +28421,23 @@ func rewriteValuePPC64_OpRsh8x64_0(v *Value) bool {
                return true
        }
        // match: (Rsh8x64 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRAW (MOVBreg x) y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRAW)
+               v0 := b.NewValue0(v.Pos, OpPPC64MOVBreg, typ.Int64)
+               v0.AddArg(x)
+               v.AddArg(v0)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh8x64 x y)
        // cond:
        // result: (SRAW (SignExt8to32 x) (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-8] y))))
        for {
@@ -27703,6 +28466,23 @@ func rewriteValuePPC64_OpRsh8x8_0(v *Value) bool {
        typ := &b.Func.Config.Types
        _ = typ
        // match: (Rsh8x8 x y)
+       // cond: shiftIsBounded(v)
+       // result: (SRAW (MOVBreg x) y)
+       for {
+               _ = v.Args[1]
+               x := v.Args[0]
+               y := v.Args[1]
+               if !(shiftIsBounded(v)) {
+                       break
+               }
+               v.reset(OpPPC64SRAW)
+               v0 := b.NewValue0(v.Pos, OpPPC64MOVBreg, typ.Int64)
+               v0.AddArg(x)
+               v.AddArg(v0)
+               v.AddArg(y)
+               return true
+       }
+       // match: (Rsh8x8 x y)
        // cond:
        // result: (SRAW (SignExt8to32 x) (ORN y <typ.Int64> (MaskIfNotCarry (ADDconstForCarry [-8] (ZeroExt8to64 y)))))
        for {