Source file test/codegen/simd_tofrom_amd64.go

     1  // asmcheck
     2  
     3  // Copyright 2026 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  // Verify that portable simd <-> archsimd conversions via ToArch and FromArch
     8  // inline and fold away with zero overhead.
     9  
    10  //go:build goexperiment.simd && amd64
    11  
    12  package codegen
    13  
    14  import (
    15  	"simd"
    16  	"simd/archsimd"
    17  )
    18  
    19  func toFromArchAMD64(x simd.Int32s) simd.Int32s {
    20  	// amd64:-`CALL` -`CMP` -`JEQ` -`JNE`
    21  	switch a := x.ToArch().(type) {
    22  	case archsimd.Int32x4:
    23  		// amd64:`VPADDD X[0-9]+, X[0-9]+, X[0-9]+` -`CALL` -`VMOV`
    24  		return simd.Int32sFromArch(a.Add(a))
    25  	case archsimd.Int32x8:
    26  		// amd64:`VPADDD Y[0-9]+, Y[0-9]+, Y[0-9]+` -`CALL` -`VMOV`
    27  		return simd.Int32sFromArch(a.Add(a))
    28  	case archsimd.Int32x16:
    29  		// amd64:`VPADDD Z[0-9]+, Z[0-9]+, Z[0-9]+` -`CALL` -`VMOV`
    30  		return simd.Int32sFromArch(a.Add(a))
    31  	default:
    32  		return x.Add(x)
    33  	}
    34  }
    35  

View as plain text