Source file test/codegen/issue56440.go
1 // asmcheck 2 3 // Copyright 2022 The Go Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 // Check to make sure that we recognize when the length of an append 8 // is constant. We check this by making sure that the constant length 9 // is folded into a load offset. 10 11 package p 12 13 func f(x []int) int { 14 s := make([]int, 3) 15 s = append(s, 4, 5) 16 // amd64:`MOVQ\t40\(.*\),` 17 return x[len(s)] 18 } 19 20 func g(x []int, p *bool) int { 21 s := make([]int, 3) 22 for { 23 s = s[:3] 24 if cap(s) < 5 { 25 s = make([]int, 3, 5) 26 } 27 s = append(s, 4, 5) 28 if *p { 29 // amd64:`MOVQ\t40\(.*\),` 30 return x[len(s)] 31 } 32 } 33 return 0 34 } 35