mirror of
https://github.com/golang/go
synced 2024-11-16 20:14:48 -07:00
cmd/compile: cast riscv64 rewrite shifts to unsigned int
This appeases Go 1.4, making it possible to bootstrap GOARCH=riscv64 with a Go 1.4 compiler. Fixes #52583 Change-Id: Ib13c2afeb095b2bb1464dcd7f1502574209bc7ab Reviewed-on: https://go-review.googlesource.com/c/go/+/409974 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
d43ddc1f3f
commit
95547aee8c
@ -735,9 +735,9 @@
|
||||
(NEGW (MOVDconst [x])) => (MOVDconst [int64(int32(-x))])
|
||||
|
||||
// Shift of a constant.
|
||||
(SLLI [x] (MOVDconst [y])) && is32Bit(y << x) => (MOVDconst [y << x])
|
||||
(SRLI [x] (MOVDconst [y])) => (MOVDconst [int64(uint64(y) >> x)])
|
||||
(SRAI [x] (MOVDconst [y])) => (MOVDconst [int64(y) >> x])
|
||||
(SLLI [x] (MOVDconst [y])) && is32Bit(y << uint32(x)) => (MOVDconst [y << uint32(x)])
|
||||
(SRLI [x] (MOVDconst [y])) => (MOVDconst [int64(uint64(y) >> uint32(x))])
|
||||
(SRAI [x] (MOVDconst [y])) => (MOVDconst [int64(y) >> uint32(x)])
|
||||
|
||||
// SLTI/SLTIU with constants.
|
||||
(SLTI [x] (MOVDconst [y])) => (MOVDconst [b2i(int64(y) < int64(x))])
|
||||
|
@ -4843,19 +4843,19 @@ func rewriteValueRISCV64_OpRISCV64SLL(v *Value) bool {
|
||||
func rewriteValueRISCV64_OpRISCV64SLLI(v *Value) bool {
|
||||
v_0 := v.Args[0]
|
||||
// match: (SLLI [x] (MOVDconst [y]))
|
||||
// cond: is32Bit(y << x)
|
||||
// result: (MOVDconst [y << x])
|
||||
// cond: is32Bit(y << uint32(x))
|
||||
// result: (MOVDconst [y << uint32(x)])
|
||||
for {
|
||||
x := auxIntToInt64(v.AuxInt)
|
||||
if v_0.Op != OpRISCV64MOVDconst {
|
||||
break
|
||||
}
|
||||
y := auxIntToInt64(v_0.AuxInt)
|
||||
if !(is32Bit(y << x)) {
|
||||
if !(is32Bit(y << uint32(x))) {
|
||||
break
|
||||
}
|
||||
v.reset(OpRISCV64MOVDconst)
|
||||
v.AuxInt = int64ToAuxInt(y << x)
|
||||
v.AuxInt = int64ToAuxInt(y << uint32(x))
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@ -4913,7 +4913,7 @@ func rewriteValueRISCV64_OpRISCV64SRA(v *Value) bool {
|
||||
func rewriteValueRISCV64_OpRISCV64SRAI(v *Value) bool {
|
||||
v_0 := v.Args[0]
|
||||
// match: (SRAI [x] (MOVDconst [y]))
|
||||
// result: (MOVDconst [int64(y) >> x])
|
||||
// result: (MOVDconst [int64(y) >> uint32(x)])
|
||||
for {
|
||||
x := auxIntToInt64(v.AuxInt)
|
||||
if v_0.Op != OpRISCV64MOVDconst {
|
||||
@ -4921,7 +4921,7 @@ func rewriteValueRISCV64_OpRISCV64SRAI(v *Value) bool {
|
||||
}
|
||||
y := auxIntToInt64(v_0.AuxInt)
|
||||
v.reset(OpRISCV64MOVDconst)
|
||||
v.AuxInt = int64ToAuxInt(int64(y) >> x)
|
||||
v.AuxInt = int64ToAuxInt(int64(y) >> uint32(x))
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@ -4947,7 +4947,7 @@ func rewriteValueRISCV64_OpRISCV64SRL(v *Value) bool {
|
||||
func rewriteValueRISCV64_OpRISCV64SRLI(v *Value) bool {
|
||||
v_0 := v.Args[0]
|
||||
// match: (SRLI [x] (MOVDconst [y]))
|
||||
// result: (MOVDconst [int64(uint64(y) >> x)])
|
||||
// result: (MOVDconst [int64(uint64(y) >> uint32(x))])
|
||||
for {
|
||||
x := auxIntToInt64(v.AuxInt)
|
||||
if v_0.Op != OpRISCV64MOVDconst {
|
||||
@ -4955,7 +4955,7 @@ func rewriteValueRISCV64_OpRISCV64SRLI(v *Value) bool {
|
||||
}
|
||||
y := auxIntToInt64(v_0.AuxInt)
|
||||
v.reset(OpRISCV64MOVDconst)
|
||||
v.AuxInt = int64ToAuxInt(int64(uint64(y) >> x))
|
||||
v.AuxInt = int64ToAuxInt(int64(uint64(y) >> uint32(x)))
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
Loading…
Reference in New Issue
Block a user