mirror of
https://github.com/golang/go
synced 2024-11-23 00:20:12 -07:00
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: Michael Munday <mike.munday@ibm.com>
This commit is contained in:
parent
96d41786c5
commit
4f15b54780
@ -350,7 +350,7 @@
|
||||
|
||||
// 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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user