]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: ensure S390X moves don't overflow int32
authorKeith Randall <keithr@alum.mit.edu>
Wed, 28 Nov 2018 20:41:23 +0000 (12:41 -0800)
committerKeith Randall <khr@golang.org>
Wed, 28 Nov 2018 21:17:40 +0000 (21:17 +0000)
Break ADDconst into ADD + MOVDconst, so that if the constant
is too big it won't overflow ADDconst's constant field.

For normal sizes, other rules will recombine into an ADDconst.

Fixes S390X breakage from CL 33909.

Change-Id: Id804ee052365527efb580f797688b0ce83c47915
Reviewed-on: https://go-review.googlesource.com/c/151597
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
src/cmd/compile/internal/ssa/gen/S390X.rules
src/cmd/compile/internal/ssa/rewriteS390X.go

index de2c09c2d1de280edb90280d58adb96ef3db2212..0aeea535616833db1c7cafece7e221ef35823a0d 100644 (file)
 
 // Move more than 1024 bytes using a loop.
 (Move [s] dst src mem) && s > 1024 ->
-       (LoweredMove [s%256] dst src (ADDconst <src.Type> src [(s/256)*256]) mem)
+       (LoweredMove [s%256] dst src (ADD <src.Type> src (MOVDconst [(s/256)*256])) mem)
 
 // Lowering Zero instructions
 (Zero [0] _ mem) -> mem
index dce7a52529041e5200a14407093d5af8ff5d71b0..1695b08780985b3fae767faef323f6693bf2637d 100644 (file)
@@ -4799,7 +4799,7 @@ func rewriteValueS390X_OpMove_10(v *Value) bool {
        }
        // match: (Move [s] dst src mem)
        // cond: s > 1024
-       // result: (LoweredMove [s%256] dst src (ADDconst <src.Type> src [(s/256)*256]) mem)
+       // result: (LoweredMove [s%256] dst src (ADD <src.Type> src (MOVDconst [(s/256)*256])) mem)
        for {
                s := v.AuxInt
                _ = v.Args[2]
@@ -4813,9 +4813,11 @@ func rewriteValueS390X_OpMove_10(v *Value) bool {
                v.AuxInt = s % 256
                v.AddArg(dst)
                v.AddArg(src)
-               v0 := b.NewValue0(v.Pos, OpS390XADDconst, src.Type)
-               v0.AuxInt = (s / 256) * 256
+               v0 := b.NewValue0(v.Pos, OpS390XADD, src.Type)
                v0.AddArg(src)
+               v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64)
+               v1.AuxInt = (s / 256) * 256
+               v0.AddArg(v1)
                v.AddArg(v0)
                v.AddArg(mem)
                return true