Commit 4f15b547 authored by Keith Randall's avatar Keith Randall Committed by Keith Randall

cmd/compile: ensure S390X moves don't overflow int32

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: default avatarMichael Munday <mike.munday@ibm.com>
parent 96d41786
...@@ -350,7 +350,7 @@ ...@@ -350,7 +350,7 @@
// Move more than 1024 bytes using a loop. // Move more than 1024 bytes using a loop.
(Move [s] dst src mem) && s > 1024 -> (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 // Lowering Zero instructions
(Zero [0] _ mem) -> mem (Zero [0] _ mem) -> mem
......
...@@ -4799,7 +4799,7 @@ func rewriteValueS390X_OpMove_10(v *Value) bool { ...@@ -4799,7 +4799,7 @@ func rewriteValueS390X_OpMove_10(v *Value) bool {
} }
// match: (Move [s] dst src mem) // match: (Move [s] dst src mem)
// cond: s > 1024 // 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 { for {
s := v.AuxInt s := v.AuxInt
_ = v.Args[2] _ = v.Args[2]
...@@ -4813,9 +4813,11 @@ func rewriteValueS390X_OpMove_10(v *Value) bool { ...@@ -4813,9 +4813,11 @@ func rewriteValueS390X_OpMove_10(v *Value) bool {
v.AuxInt = s % 256 v.AuxInt = s % 256
v.AddArg(dst) v.AddArg(dst)
v.AddArg(src) v.AddArg(src)
v0 := b.NewValue0(v.Pos, OpS390XADDconst, src.Type) v0 := b.NewValue0(v.Pos, OpS390XADD, src.Type)
v0.AuxInt = (s / 256) * 256
v0.AddArg(src) v0.AddArg(src)
v1 := b.NewValue0(v.Pos, OpS390XMOVDconst, typ.UInt64)
v1.AuxInt = (s / 256) * 256
v0.AddArg(v1)
v.AddArg(v0) v.AddArg(v0)
v.AddArg(mem) v.AddArg(mem)
return true return true
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment