Source file test/codegen/simd_tofrom_wasm.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 on wasm.
     9  
    10  //go:build goexperiment.simd && wasm
    11  
    12  package codegen
    13  
    14  import (
    15  	"simd"
    16  	"simd/archsimd"
    17  )
    18  
    19  func toFromArchWasm(x simd.Int32s) simd.Int32s {
    20  	// wasm:-`Call` -`BrIf`
    21  	switch a := x.ToArch().(type) {
    22  	case archsimd.Int32x4:
    23  		// wasm:`I32x4Add` -`Call` -`BrIf`
    24  		return simd.Int32sFromArch(a.Add(a))
    25  	default:
    26  		return x.Add(x)
    27  	}
    28  }
    29  

View as plain text