Source file src/simd/testdata/timport/isimd/isimd.go
1 // Copyright 2026 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Package isimd is the leaf package (importing "simd") in the transitive-import 6 // test chain main1 -> relay -> isimd -> simd. It exports a constructor F 7 // returning an unexported struct that embeds simd.Int8s, plus non-SIMD 8 // variables derived from SIMD-dependent package-variable initialization chains. 9 package isimd 10 11 import "simd" 12 13 type t struct { 14 simd.Int8s 15 } 16 17 //go:noinline 18 func id(i int32) int32 { 19 return i 20 } 21 22 var a = id(4) // not constant, must evaluate before b 23 var b = simd.BroadcastInt32s(a) // evaluation depends on simd hardware 24 var c = b.ReduceSum() // derive a non-simd value from a simd value 25 var d = c + 1 // does this no-simd-dependence evaluation occur in the right order? 26 27 var i = simd.Int8s{}.Len() 28 var j = i // non-SIMD var chained off SIMD-initialized i 29 30 const three = 3 31 32 func F() t { 33 return t{simd.BroadcastInt8s(three)} 34 } 35 36 // G returns the result of F().ReduceSum() 37 func G() int { 38 return three * i 39 } 40 41 // H returns 4*(Int32s{}.Len())+1 == 17, 33, 65 42 func H() int32 { 43 return d 44 } 45