Source file src/cmd/compile/internal/amd64/versions_simd_test.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  //go:build amd64 && goexperiment.simd && !boringcrypto
     6  
     7  package amd64_test
     8  
     9  import "simd/archsimd"
    10  
    11  //go:noinline
    12  func testLoop2(n int, x float64) float64 {
    13  	var r float64
    14  	for range n {
    15  		if archsimd.X86.AVX2() {
    16  			v := archsimd.BroadcastFloat64x2(x)
    17  			v = v.Mul(v)
    18  			r += v.GetElem(0)
    19  		}
    20  	}
    21  	return r
    22  }
    23  
    24  //go:noinline
    25  func testLoop3(n int, x float64) float64 {
    26  	var r float64
    27  	if !archsimd.X86.AVX2() {
    28  		n = 0
    29  	}
    30  	for range n {
    31  		v := archsimd.BroadcastFloat64x2(x)
    32  		v = v.Mul(v)
    33  		r += v.GetElem(0)
    34  	}
    35  	return r
    36  }
    37  

View as plain text