(Convert <t> x mem) && config.PtrSize == 4 -> (MOVLconvert <t> x mem)
(IsNonNil p) && config.PtrSize == 8 -> (SETNE (TESTQ p p))
(IsNonNil p) && config.PtrSize == 4 -> (SETNE (TESTL p p))
-(IsInBounds idx len) -> (SETB (CMPQ idx len))
-(IsSliceInBounds idx len) -> (SETBE (CMPQ idx len))
+(IsInBounds idx len) && config.PtrSize == 8 -> (SETB (CMPQ idx len))
+(IsInBounds idx len) && config.PtrSize == 4 -> (SETB (CMPL idx len))
+(IsSliceInBounds idx len) && config.PtrSize == 8 -> (SETBE (CMPQ idx len))
+(IsSliceInBounds idx len) && config.PtrSize == 4 -> (SETBE (CMPL idx len))
(NilCheck ptr mem) -> (LoweredNilCheck ptr mem)
(GetG mem) -> (LoweredGetG mem)
(GetClosurePtr) -> (LoweredGetClosurePtr)
func rewriteValueAMD64_OpIsInBounds_0(v *Value) bool {
b := v.Block
_ = b
+ config := b.Func.Config
+ _ = config
// match: (IsInBounds idx len)
- // cond:
+ // cond: config.PtrSize == 8
// result: (SETB (CMPQ idx len))
for {
_ = v.Args[1]
idx := v.Args[0]
len := v.Args[1]
+ if !(config.PtrSize == 8) {
+ break
+ }
v.reset(OpAMD64SETB)
v0 := b.NewValue0(v.Pos, OpAMD64CMPQ, types.TypeFlags)
v0.AddArg(idx)
v.AddArg(v0)
return true
}
+ // match: (IsInBounds idx len)
+ // cond: config.PtrSize == 4
+ // result: (SETB (CMPL idx len))
+ for {
+ _ = v.Args[1]
+ idx := v.Args[0]
+ len := v.Args[1]
+ if !(config.PtrSize == 4) {
+ break
+ }
+ v.reset(OpAMD64SETB)
+ v0 := b.NewValue0(v.Pos, OpAMD64CMPL, types.TypeFlags)
+ v0.AddArg(idx)
+ v0.AddArg(len)
+ v.AddArg(v0)
+ return true
+ }
+ return false
}
func rewriteValueAMD64_OpIsNonNil_0(v *Value) bool {
b := v.Block
func rewriteValueAMD64_OpIsSliceInBounds_0(v *Value) bool {
b := v.Block
_ = b
+ config := b.Func.Config
+ _ = config
// match: (IsSliceInBounds idx len)
- // cond:
+ // cond: config.PtrSize == 8
// result: (SETBE (CMPQ idx len))
for {
_ = v.Args[1]
idx := v.Args[0]
len := v.Args[1]
+ if !(config.PtrSize == 8) {
+ break
+ }
v.reset(OpAMD64SETBE)
v0 := b.NewValue0(v.Pos, OpAMD64CMPQ, types.TypeFlags)
v0.AddArg(idx)
v.AddArg(v0)
return true
}
+ // match: (IsSliceInBounds idx len)
+ // cond: config.PtrSize == 4
+ // result: (SETBE (CMPL idx len))
+ for {
+ _ = v.Args[1]
+ idx := v.Args[0]
+ len := v.Args[1]
+ if !(config.PtrSize == 4) {
+ break
+ }
+ v.reset(OpAMD64SETBE)
+ v0 := b.NewValue0(v.Pos, OpAMD64CMPL, types.TypeFlags)
+ v0.AddArg(idx)
+ v0.AddArg(len)
+ v.AddArg(v0)
+ return true
+ }
+ return false
}
func rewriteValueAMD64_OpLeq16_0(v *Value) bool {
b := v.Block
--- /dev/null
+// run
+
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 20811: slice-in-bound check is lowered incorrectly on
+// amd64p32.
+
+package main
+
+func main() {
+ i := g()
+ _ = "x"[int32(i)]
+ j := g()
+ _ = "x"[:int32(j)]
+}
+
+//go:noinline
+func g() int64 {
+ return 4398046511104
+}
+