Source file test/codegen/simd_mulwiden.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  // These tests check code generation of widening multiplies.
     8  
     9  //go:build goexperiment.simd && (arm64 || wasm)
    10  
    11  package codegen
    12  
    13  import "simd/archsimd"
    14  
    15  // Multiplying the high halves of two vectors folds into a single instruction.
    16  
    17  func simdMulWidenHiInt8x16(x, y archsimd.Int8x16) archsimd.Int16x8 {
    18  	// arm64:`VSMULL2` -`VDUP`
    19  	// wasm:`I16x8ExtmulHighI8x16S` -`ExtractLane` -`ReplaceLane`
    20  	return x.HiToLo().MulWiden(y.HiToLo())
    21  }
    22  
    23  func simdMulWidenHiUint8x16(x, y archsimd.Uint8x16) archsimd.Uint16x8 {
    24  	// arm64:`VUMULL2` -`VDUP`
    25  	// wasm:`I16x8ExtmulHighI8x16U` -`ExtractLane` -`ReplaceLane`
    26  	return x.HiToLo().MulWiden(y.HiToLo())
    27  }
    28  
    29  func simdMulWidenHiInt16x8(x, y archsimd.Int16x8) archsimd.Int32x4 {
    30  	// arm64:`VSMULL2` -`VDUP`
    31  	// wasm:`I32x4ExtmulHighI16x8S` -`ExtractLane` -`ReplaceLane`
    32  	return x.HiToLo().MulWiden(y.HiToLo())
    33  }
    34  
    35  func simdMulWidenHiUint16x8(x, y archsimd.Uint16x8) archsimd.Uint32x4 {
    36  	// arm64:`VUMULL2` -`VDUP`
    37  	// wasm:`I32x4ExtmulHighI16x8U` -`ExtractLane` -`ReplaceLane`
    38  	return x.HiToLo().MulWiden(y.HiToLo())
    39  }
    40  
    41  func simdMulWidenHiInt32x4(x, y archsimd.Int32x4) archsimd.Int64x2 {
    42  	// arm64:`VSMULL2` -`VDUP`
    43  	// wasm:`I64x2ExtmulHighI32x4S` -`ExtractLane` -`ReplaceLane`
    44  	return x.HiToLo().MulWiden(y.HiToLo())
    45  }
    46  
    47  func simdMulWidenHiUint32x4(x, y archsimd.Uint32x4) archsimd.Uint64x2 {
    48  	// arm64:`VUMULL2` -`VDUP`
    49  	// wasm:`I64x2ExtmulHighI32x4U` -`ExtractLane` -`ReplaceLane`
    50  	return x.HiToLo().MulWiden(y.HiToLo())
    51  }
    52  

View as plain text