Source file src/simd/archsimd/shuffles_internal_amd64.go

     1  // Copyright 2025 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 goexperiment.simdstable && amd64
     6  
     7  package archsimd
     8  
     9  func (x Int32x4) concatPermuteScalars(a, b, c, d uint8, y Int32x4) Int32x4 {
    10  	// pattern gets the concatenation of "x or y?" bits
    11  	// (0 == x, 1 == y)
    12  	// This will determine operand choice/order and whether a second
    13  	// instruction is needed.
    14  	pattern := a>>2 + (b&4)>>1 + (c & 4) + (d&4)<<1
    15  
    16  	// a-d are masked down to their offsets within x or y
    17  	// this is not necessary for x, but this is easier on the
    18  	// eyes and reduces the risk of an error now or later.
    19  	a, b, c, d = a&3, b&3, c&3, d&3
    20  
    21  	switch pattern {
    22  	case _LLLL:
    23  		return x.concatSelectedConstant(cscimm4(a, b, c, d), x)
    24  	case _HHHH:
    25  		return y.concatSelectedConstant(cscimm4(a, b, c, d), y)
    26  	case _LLHH:
    27  		return x.concatSelectedConstant(cscimm4(a, b, c, d), y)
    28  	case _HHLL:
    29  		return y.concatSelectedConstant(cscimm4(a, b, c, d), x)
    30  
    31  	case _HLLL:
    32  		z := y.concatSelectedConstant(cscimm4(a, a, b, b), x)
    33  		return z.concatSelectedConstant(cscimm4(0, 2, c, d), x)
    34  	case _LHLL:
    35  		z := x.concatSelectedConstant(cscimm4(a, a, b, b), y)
    36  		return z.concatSelectedConstant(cscimm4(0, 2, c, d), x)
    37  
    38  	case _HLHH:
    39  		z := y.concatSelectedConstant(cscimm4(a, a, b, b), x)
    40  		return z.concatSelectedConstant(cscimm4(0, 2, c, d), y)
    41  	case _LHHH:
    42  		z := x.concatSelectedConstant(cscimm4(a, a, b, b), y)
    43  		return z.concatSelectedConstant(cscimm4(0, 2, c, d), y)
    44  
    45  	case _LLLH:
    46  		z := x.concatSelectedConstant(cscimm4(c, c, d, d), y)
    47  		return x.concatSelectedConstant(cscimm4(a, b, 0, 2), z)
    48  	case _LLHL:
    49  		z := y.concatSelectedConstant(cscimm4(c, c, d, d), x)
    50  		return x.concatSelectedConstant(cscimm4(a, b, 0, 2), z)
    51  	case _HHLH:
    52  		z := x.concatSelectedConstant(cscimm4(c, c, d, d), y)
    53  		return y.concatSelectedConstant(cscimm4(a, b, 0, 2), z)
    54  	case _HHHL:
    55  		z := y.concatSelectedConstant(cscimm4(c, c, d, d), x)
    56  		return y.concatSelectedConstant(cscimm4(a, b, 0, 2), z)
    57  
    58  	case _LHLH:
    59  		z := x.concatSelectedConstant(cscimm4(a, c, b, d), y)
    60  		return z.concatSelectedConstant(0b11_01_10_00 /* =cscimm4(0, 2, 1, 3) */, z)
    61  	case _HLHL:
    62  		z := x.concatSelectedConstant(cscimm4(b, d, a, c), y)
    63  		return z.concatSelectedConstant(0b01_11_00_10 /* =cscimm4(2, 0, 3, 1) */, z)
    64  	case _HLLH:
    65  		z := x.concatSelectedConstant(cscimm4(b, c, a, d), y)
    66  		return z.concatSelectedConstant(0b11_01_00_10 /* =cscimm4(2, 0, 1, 3) */, z)
    67  	case _LHHL:
    68  		z := x.concatSelectedConstant(cscimm4(a, d, b, c), y)
    69  		return z.concatSelectedConstant(0b01_11_10_00 /* =cscimm4(0, 2, 3, 1) */, z)
    70  	}
    71  	panic("missing case, switch should be exhaustive")
    72  }
    73  
    74  func (x Uint32x4) concatPermuteScalars(a, b, c, d uint8, y Uint32x4) Uint32x4 {
    75  	pattern := a>>2 + (b&4)>>1 + (c & 4) + (d&4)<<1
    76  
    77  	a, b, c, d = a&3, b&3, c&3, d&3
    78  
    79  	switch pattern {
    80  	case _LLLL:
    81  		return x.concatSelectedConstant(cscimm4(a, b, c, d), x)
    82  	case _HHHH:
    83  		return y.concatSelectedConstant(cscimm4(a, b, c, d), y)
    84  	case _LLHH:
    85  		return x.concatSelectedConstant(cscimm4(a, b, c, d), y)
    86  	case _HHLL:
    87  		return y.concatSelectedConstant(cscimm4(a, b, c, d), x)
    88  
    89  	case _HLLL:
    90  		z := y.concatSelectedConstant(cscimm4(a, a, b, b), x)
    91  		return z.concatSelectedConstant(cscimm4(0, 2, c, d), x)
    92  	case _LHLL:
    93  		z := x.concatSelectedConstant(cscimm4(a, a, b, b), y)
    94  		return z.concatSelectedConstant(cscimm4(0, 2, c, d), x)
    95  
    96  	case _HLHH:
    97  		z := y.concatSelectedConstant(cscimm4(a, a, b, b), x)
    98  		return z.concatSelectedConstant(cscimm4(0, 2, c, d), y)
    99  	case _LHHH:
   100  		z := x.concatSelectedConstant(cscimm4(a, a, b, b), y)
   101  		return z.concatSelectedConstant(cscimm4(0, 2, c, d), y)
   102  
   103  	case _LLLH:
   104  		z := x.concatSelectedConstant(cscimm4(c, c, d, d), y)
   105  		return x.concatSelectedConstant(cscimm4(a, b, 0, 2), z)
   106  	case _LLHL:
   107  		z := y.concatSelectedConstant(cscimm4(c, c, d, d), x)
   108  		return x.concatSelectedConstant(cscimm4(a, b, 0, 2), z)
   109  	case _HHLH:
   110  		z := x.concatSelectedConstant(cscimm4(c, c, d, d), y)
   111  		return y.concatSelectedConstant(cscimm4(a, b, 0, 2), z)
   112  	case _HHHL:
   113  		z := y.concatSelectedConstant(cscimm4(c, c, d, d), x)
   114  		return y.concatSelectedConstant(cscimm4(a, b, 0, 2), z)
   115  
   116  	case _LHLH:
   117  		z := x.concatSelectedConstant(cscimm4(a, c, b, d), y)
   118  		return z.concatSelectedConstant(0b11_01_10_00 /* =cscimm4(0, 2, 1, 3) */, z)
   119  	case _HLHL:
   120  		z := x.concatSelectedConstant(cscimm4(b, d, a, c), y)
   121  		return z.concatSelectedConstant(0b01_11_00_10 /* =cscimm4(2, 0, 3, 1) */, z)
   122  	case _HLLH:
   123  		z := x.concatSelectedConstant(cscimm4(b, c, a, d), y)
   124  		return z.concatSelectedConstant(0b11_01_00_10 /* =cscimm4(2, 0, 1, 3) */, z)
   125  	case _LHHL:
   126  		z := x.concatSelectedConstant(cscimm4(a, d, b, c), y)
   127  		return z.concatSelectedConstant(0b01_11_10_00 /* =cscimm4(0, 2, 3, 1) */, z)
   128  	}
   129  	panic("missing case, switch should be exhaustive")
   130  }
   131  
   132  func (x Float32x4) concatPermuteScalars(a, b, c, d uint8, y Float32x4) Float32x4 {
   133  	pattern := a>>2 + (b&4)>>1 + (c & 4) + (d&4)<<1
   134  
   135  	a, b, c, d = a&3, b&3, c&3, d&3
   136  
   137  	switch pattern {
   138  	case _LLLL:
   139  		return x.concatSelectedConstant(cscimm4(a, b, c, d), x)
   140  	case _HHHH:
   141  		return y.concatSelectedConstant(cscimm4(a, b, c, d), y)
   142  	case _LLHH:
   143  		return x.concatSelectedConstant(cscimm4(a, b, c, d), y)
   144  	case _HHLL:
   145  		return y.concatSelectedConstant(cscimm4(a, b, c, d), x)
   146  
   147  	case _HLLL:
   148  		z := y.concatSelectedConstant(cscimm4(a, a, b, b), x)
   149  		return z.concatSelectedConstant(cscimm4(0, 2, c, d), x)
   150  	case _LHLL:
   151  		z := x.concatSelectedConstant(cscimm4(a, a, b, b), y)
   152  		return z.concatSelectedConstant(cscimm4(0, 2, c, d), x)
   153  
   154  	case _HLHH:
   155  		z := y.concatSelectedConstant(cscimm4(a, a, b, b), x)
   156  		return z.concatSelectedConstant(cscimm4(0, 2, c, d), y)
   157  	case _LHHH:
   158  		z := x.concatSelectedConstant(cscimm4(a, a, b, b), y)
   159  		return z.concatSelectedConstant(cscimm4(0, 2, c, d), y)
   160  
   161  	case _LLLH:
   162  		z := x.concatSelectedConstant(cscimm4(c, c, d, d), y)
   163  		return x.concatSelectedConstant(cscimm4(a, b, 0, 2), z)
   164  	case _LLHL:
   165  		z := y.concatSelectedConstant(cscimm4(c, c, d, d), x)
   166  		return x.concatSelectedConstant(cscimm4(a, b, 0, 2), z)
   167  	case _HHLH:
   168  		z := x.concatSelectedConstant(cscimm4(c, c, d, d), y)
   169  		return y.concatSelectedConstant(cscimm4(a, b, 0, 2), z)
   170  	case _HHHL:
   171  		z := y.concatSelectedConstant(cscimm4(c, c, d, d), x)
   172  		return y.concatSelectedConstant(cscimm4(a, b, 0, 2), z)
   173  
   174  	case _LHLH:
   175  		z := x.concatSelectedConstant(cscimm4(a, c, b, d), y)
   176  		return z.concatSelectedConstant(0b11_01_10_00 /* =cscimm4(0, 2, 1, 3) */, z)
   177  	case _HLHL:
   178  		z := x.concatSelectedConstant(cscimm4(b, d, a, c), y)
   179  		return z.concatSelectedConstant(0b01_11_00_10 /* =cscimm4(2, 0, 3, 1) */, z)
   180  	case _HLLH:
   181  		z := x.concatSelectedConstant(cscimm4(b, c, a, d), y)
   182  		return z.concatSelectedConstant(0b11_01_00_10 /* =cscimm4(2, 0, 1, 3) */, z)
   183  	case _LHHL:
   184  		z := x.concatSelectedConstant(cscimm4(a, d, b, c), y)
   185  		return z.concatSelectedConstant(0b01_11_10_00 /* =cscimm4(0, 2, 3, 1) */, z)
   186  	}
   187  	panic("missing case, switch should be exhaustive")
   188  }
   189  
   190  func (x Int32x8) concatPermuteScalarsGrouped(a, b, c, d uint8, y Int32x8) Int32x8 {
   191  	pattern := a>>2 + (b&4)>>1 + (c & 4) + (d&4)<<1
   192  
   193  	a, b, c, d = a&3, b&3, c&3, d&3
   194  
   195  	switch pattern {
   196  	case _LLLL:
   197  		return x.concatSelectedConstantGrouped(cscimm4(a, b, c, d), x)
   198  	case _HHHH:
   199  		return y.concatSelectedConstantGrouped(cscimm4(a, b, c, d), y)
   200  	case _LLHH:
   201  		return x.concatSelectedConstantGrouped(cscimm4(a, b, c, d), y)
   202  	case _HHLL:
   203  		return y.concatSelectedConstantGrouped(cscimm4(a, b, c, d), x)
   204  
   205  	case _HLLL:
   206  		z := y.concatSelectedConstantGrouped(cscimm4(a, a, b, b), x)
   207  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), x)
   208  	case _LHLL:
   209  		z := x.concatSelectedConstantGrouped(cscimm4(a, a, b, b), y)
   210  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), x)
   211  
   212  	case _HLHH:
   213  		z := y.concatSelectedConstantGrouped(cscimm4(a, a, b, b), x)
   214  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), y)
   215  	case _LHHH:
   216  		z := x.concatSelectedConstantGrouped(cscimm4(a, a, b, b), y)
   217  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), y)
   218  
   219  	case _LLLH:
   220  		z := x.concatSelectedConstantGrouped(cscimm4(c, c, d, d), y)
   221  		return x.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   222  	case _LLHL:
   223  		z := y.concatSelectedConstantGrouped(cscimm4(c, c, d, d), x)
   224  		return x.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   225  	case _HHLH:
   226  		z := x.concatSelectedConstantGrouped(cscimm4(c, c, d, d), y)
   227  		return y.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   228  	case _HHHL:
   229  		z := y.concatSelectedConstantGrouped(cscimm4(c, c, d, d), x)
   230  		return y.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   231  
   232  	case _LHLH:
   233  		z := x.concatSelectedConstantGrouped(cscimm4(a, c, b, d), y)
   234  		return z.concatSelectedConstantGrouped(0b11_01_10_00 /* =cscimm4(0, 2, 1, 3) */, z)
   235  	case _HLHL:
   236  		z := x.concatSelectedConstantGrouped(cscimm4(b, d, a, c), y)
   237  		return z.concatSelectedConstantGrouped(0b01_11_00_10 /* =cscimm4(2, 0, 3, 1) */, z)
   238  	case _HLLH:
   239  		z := x.concatSelectedConstantGrouped(cscimm4(b, c, a, d), y)
   240  		return z.concatSelectedConstantGrouped(0b11_01_00_10 /* =cscimm4(2, 0, 1, 3) */, z)
   241  	case _LHHL:
   242  		z := x.concatSelectedConstantGrouped(cscimm4(a, d, b, c), y)
   243  		return z.concatSelectedConstantGrouped(0b01_11_10_00 /* =cscimm4(0, 2, 3, 1) */, z)
   244  	}
   245  	panic("missing case, switch should be exhaustive")
   246  }
   247  
   248  func (x Uint32x8) concatPermuteScalarsGrouped(a, b, c, d uint8, y Uint32x8) Uint32x8 {
   249  	pattern := a>>2 + (b&4)>>1 + (c & 4) + (d&4)<<1
   250  
   251  	a, b, c, d = a&3, b&3, c&3, d&3
   252  
   253  	switch pattern {
   254  	case _LLLL:
   255  		return x.concatSelectedConstantGrouped(cscimm4(a, b, c, d), x)
   256  	case _HHHH:
   257  		return y.concatSelectedConstantGrouped(cscimm4(a, b, c, d), y)
   258  	case _LLHH:
   259  		return x.concatSelectedConstantGrouped(cscimm4(a, b, c, d), y)
   260  	case _HHLL:
   261  		return y.concatSelectedConstantGrouped(cscimm4(a, b, c, d), x)
   262  
   263  	case _HLLL:
   264  		z := y.concatSelectedConstantGrouped(cscimm4(a, a, b, b), x)
   265  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), x)
   266  	case _LHLL:
   267  		z := x.concatSelectedConstantGrouped(cscimm4(a, a, b, b), y)
   268  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), x)
   269  
   270  	case _HLHH:
   271  		z := y.concatSelectedConstantGrouped(cscimm4(a, a, b, b), x)
   272  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), y)
   273  	case _LHHH:
   274  		z := x.concatSelectedConstantGrouped(cscimm4(a, a, b, b), y)
   275  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), y)
   276  
   277  	case _LLLH:
   278  		z := x.concatSelectedConstantGrouped(cscimm4(c, c, d, d), y)
   279  		return x.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   280  	case _LLHL:
   281  		z := y.concatSelectedConstantGrouped(cscimm4(c, c, d, d), x)
   282  		return x.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   283  	case _HHLH:
   284  		z := x.concatSelectedConstantGrouped(cscimm4(c, c, d, d), y)
   285  		return y.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   286  	case _HHHL:
   287  		z := y.concatSelectedConstantGrouped(cscimm4(c, c, d, d), x)
   288  		return y.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   289  
   290  	case _LHLH:
   291  		z := x.concatSelectedConstantGrouped(cscimm4(a, c, b, d), y)
   292  		return z.concatSelectedConstantGrouped(0b11_01_10_00 /* =cscimm4(0, 2, 1, 3) */, z)
   293  	case _HLHL:
   294  		z := x.concatSelectedConstantGrouped(cscimm4(b, d, a, c), y)
   295  		return z.concatSelectedConstantGrouped(0b01_11_00_10 /* =cscimm4(2, 0, 3, 1) */, z)
   296  	case _HLLH:
   297  		z := x.concatSelectedConstantGrouped(cscimm4(b, c, a, d), y)
   298  		return z.concatSelectedConstantGrouped(0b11_01_00_10 /* =cscimm4(2, 0, 1, 3) */, z)
   299  	case _LHHL:
   300  		z := x.concatSelectedConstantGrouped(cscimm4(a, d, b, c), y)
   301  		return z.concatSelectedConstantGrouped(0b01_11_10_00 /* =cscimm4(0, 2, 3, 1) */, z)
   302  	}
   303  	panic("missing case, switch should be exhaustive")
   304  }
   305  
   306  func (x Float32x8) concatPermuteScalarsGrouped(a, b, c, d uint8, y Float32x8) Float32x8 {
   307  	pattern := a>>2 + (b&4)>>1 + (c & 4) + (d&4)<<1
   308  
   309  	a, b, c, d = a&3, b&3, c&3, d&3
   310  
   311  	switch pattern {
   312  	case _LLLL:
   313  		return x.concatSelectedConstantGrouped(cscimm4(a, b, c, d), x)
   314  	case _HHHH:
   315  		return y.concatSelectedConstantGrouped(cscimm4(a, b, c, d), y)
   316  	case _LLHH:
   317  		return x.concatSelectedConstantGrouped(cscimm4(a, b, c, d), y)
   318  	case _HHLL:
   319  		return y.concatSelectedConstantGrouped(cscimm4(a, b, c, d), x)
   320  
   321  	case _HLLL:
   322  		z := y.concatSelectedConstantGrouped(cscimm4(a, a, b, b), x)
   323  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), x)
   324  	case _LHLL:
   325  		z := x.concatSelectedConstantGrouped(cscimm4(a, a, b, b), y)
   326  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), x)
   327  
   328  	case _HLHH:
   329  		z := y.concatSelectedConstantGrouped(cscimm4(a, a, b, b), x)
   330  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), y)
   331  	case _LHHH:
   332  		z := x.concatSelectedConstantGrouped(cscimm4(a, a, b, b), y)
   333  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), y)
   334  
   335  	case _LLLH:
   336  		z := x.concatSelectedConstantGrouped(cscimm4(c, c, d, d), y)
   337  		return x.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   338  	case _LLHL:
   339  		z := y.concatSelectedConstantGrouped(cscimm4(c, c, d, d), x)
   340  		return x.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   341  	case _HHLH:
   342  		z := x.concatSelectedConstantGrouped(cscimm4(c, c, d, d), y)
   343  		return y.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   344  	case _HHHL:
   345  		z := y.concatSelectedConstantGrouped(cscimm4(c, c, d, d), x)
   346  		return y.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   347  
   348  	case _LHLH:
   349  		z := x.concatSelectedConstantGrouped(cscimm4(a, c, b, d), y)
   350  		return z.concatSelectedConstantGrouped(0b11_01_10_00 /* =cscimm4(0, 2, 1, 3) */, z)
   351  	case _HLHL:
   352  		z := x.concatSelectedConstantGrouped(cscimm4(b, d, a, c), y)
   353  		return z.concatSelectedConstantGrouped(0b01_11_00_10 /* =cscimm4(2, 0, 3, 1) */, z)
   354  	case _HLLH:
   355  		z := x.concatSelectedConstantGrouped(cscimm4(b, c, a, d), y)
   356  		return z.concatSelectedConstantGrouped(0b11_01_00_10 /* =cscimm4(2, 0, 1, 3) */, z)
   357  	case _LHHL:
   358  		z := x.concatSelectedConstantGrouped(cscimm4(a, d, b, c), y)
   359  		return z.concatSelectedConstantGrouped(0b01_11_10_00 /* =cscimm4(0, 2, 3, 1) */, z)
   360  	}
   361  	panic("missing case, switch should be exhaustive")
   362  }
   363  
   364  func (x Int32x16) concatPermuteScalarsGrouped(a, b, c, d uint8, y Int32x16) Int32x16 {
   365  	pattern := a>>2 + (b&4)>>1 + (c & 4) + (d&4)<<1
   366  
   367  	a, b, c, d = a&3, b&3, c&3, d&3
   368  
   369  	switch pattern {
   370  	case _LLLL:
   371  		return x.concatSelectedConstantGrouped(cscimm4(a, b, c, d), x)
   372  	case _HHHH:
   373  		return y.concatSelectedConstantGrouped(cscimm4(a, b, c, d), y)
   374  	case _LLHH:
   375  		return x.concatSelectedConstantGrouped(cscimm4(a, b, c, d), y)
   376  	case _HHLL:
   377  		return y.concatSelectedConstantGrouped(cscimm4(a, b, c, d), x)
   378  
   379  	case _HLLL:
   380  		z := y.concatSelectedConstantGrouped(cscimm4(a, a, b, b), x)
   381  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), x)
   382  	case _LHLL:
   383  		z := x.concatSelectedConstantGrouped(cscimm4(a, a, b, b), y)
   384  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), x)
   385  
   386  	case _HLHH:
   387  		z := y.concatSelectedConstantGrouped(cscimm4(a, a, b, b), x)
   388  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), y)
   389  	case _LHHH:
   390  		z := x.concatSelectedConstantGrouped(cscimm4(a, a, b, b), y)
   391  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), y)
   392  
   393  	case _LLLH:
   394  		z := x.concatSelectedConstantGrouped(cscimm4(c, c, d, d), y)
   395  		return x.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   396  	case _LLHL:
   397  		z := y.concatSelectedConstantGrouped(cscimm4(c, c, d, d), x)
   398  		return x.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   399  	case _HHLH:
   400  		z := x.concatSelectedConstantGrouped(cscimm4(c, c, d, d), y)
   401  		return y.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   402  	case _HHHL:
   403  		z := y.concatSelectedConstantGrouped(cscimm4(c, c, d, d), x)
   404  		return y.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   405  
   406  	case _LHLH:
   407  		z := x.concatSelectedConstantGrouped(cscimm4(a, c, b, d), y)
   408  		return z.concatSelectedConstantGrouped(0b11_01_10_00 /* =cscimm4(0, 2, 1, 3) */, z)
   409  	case _HLHL:
   410  		z := x.concatSelectedConstantGrouped(cscimm4(b, d, a, c), y)
   411  		return z.concatSelectedConstantGrouped(0b01_11_00_10 /* =cscimm4(2, 0, 3, 1) */, z)
   412  	case _HLLH:
   413  		z := x.concatSelectedConstantGrouped(cscimm4(b, c, a, d), y)
   414  		return z.concatSelectedConstantGrouped(0b11_01_00_10 /* =cscimm4(2, 0, 1, 3) */, z)
   415  	case _LHHL:
   416  		z := x.concatSelectedConstantGrouped(cscimm4(a, d, b, c), y)
   417  		return z.concatSelectedConstantGrouped(0b01_11_10_00 /* =cscimm4(0, 2, 3, 1) */, z)
   418  	}
   419  	panic("missing case, switch should be exhaustive")
   420  }
   421  
   422  func (x Uint32x16) concatPermuteScalarsGrouped(a, b, c, d uint8, y Uint32x16) Uint32x16 {
   423  	pattern := a>>2 + (b&4)>>1 + (c & 4) + (d&4)<<1
   424  
   425  	a, b, c, d = a&3, b&3, c&3, d&3
   426  
   427  	switch pattern {
   428  	case _LLLL:
   429  		return x.concatSelectedConstantGrouped(cscimm4(a, b, c, d), x)
   430  	case _HHHH:
   431  		return y.concatSelectedConstantGrouped(cscimm4(a, b, c, d), y)
   432  	case _LLHH:
   433  		return x.concatSelectedConstantGrouped(cscimm4(a, b, c, d), y)
   434  	case _HHLL:
   435  		return y.concatSelectedConstantGrouped(cscimm4(a, b, c, d), x)
   436  
   437  	case _HLLL:
   438  		z := y.concatSelectedConstantGrouped(cscimm4(a, a, b, b), x)
   439  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), x)
   440  	case _LHLL:
   441  		z := x.concatSelectedConstantGrouped(cscimm4(a, a, b, b), y)
   442  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), x)
   443  
   444  	case _HLHH:
   445  		z := y.concatSelectedConstantGrouped(cscimm4(a, a, b, b), x)
   446  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), y)
   447  	case _LHHH:
   448  		z := x.concatSelectedConstantGrouped(cscimm4(a, a, b, b), y)
   449  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), y)
   450  
   451  	case _LLLH:
   452  		z := x.concatSelectedConstantGrouped(cscimm4(c, c, d, d), y)
   453  		return x.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   454  	case _LLHL:
   455  		z := y.concatSelectedConstantGrouped(cscimm4(c, c, d, d), x)
   456  		return x.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   457  	case _HHLH:
   458  		z := x.concatSelectedConstantGrouped(cscimm4(c, c, d, d), y)
   459  		return y.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   460  	case _HHHL:
   461  		z := y.concatSelectedConstantGrouped(cscimm4(c, c, d, d), x)
   462  		return y.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   463  
   464  	case _LHLH:
   465  		z := x.concatSelectedConstantGrouped(cscimm4(a, c, b, d), y)
   466  		return z.concatSelectedConstantGrouped(0b11_01_10_00 /* =cscimm4(0, 2, 1, 3) */, z)
   467  	case _HLHL:
   468  		z := x.concatSelectedConstantGrouped(cscimm4(b, d, a, c), y)
   469  		return z.concatSelectedConstantGrouped(0b01_11_00_10 /* =cscimm4(2, 0, 3, 1) */, z)
   470  	case _HLLH:
   471  		z := x.concatSelectedConstantGrouped(cscimm4(b, c, a, d), y)
   472  		return z.concatSelectedConstantGrouped(0b11_01_00_10 /* =cscimm4(2, 0, 1, 3) */, z)
   473  	case _LHHL:
   474  		z := x.concatSelectedConstantGrouped(cscimm4(a, d, b, c), y)
   475  		return z.concatSelectedConstantGrouped(0b01_11_10_00 /* =cscimm4(0, 2, 3, 1) */, z)
   476  	}
   477  	panic("missing case, switch should be exhaustive")
   478  }
   479  
   480  func (x Float32x16) concatPermuteScalarsGrouped(a, b, c, d uint8, y Float32x16) Float32x16 {
   481  	pattern := a>>2 + (b&4)>>1 + (c & 4) + (d&4)<<1
   482  
   483  	a, b, c, d = a&3, b&3, c&3, d&3
   484  
   485  	switch pattern {
   486  	case _LLLL:
   487  		return x.concatSelectedConstantGrouped(cscimm4(a, b, c, d), x)
   488  	case _HHHH:
   489  		return y.concatSelectedConstantGrouped(cscimm4(a, b, c, d), y)
   490  	case _LLHH:
   491  		return x.concatSelectedConstantGrouped(cscimm4(a, b, c, d), y)
   492  	case _HHLL:
   493  		return y.concatSelectedConstantGrouped(cscimm4(a, b, c, d), x)
   494  
   495  	case _HLLL:
   496  		z := y.concatSelectedConstantGrouped(cscimm4(a, a, b, b), x)
   497  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), x)
   498  	case _LHLL:
   499  		z := x.concatSelectedConstantGrouped(cscimm4(a, a, b, b), y)
   500  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), x)
   501  
   502  	case _HLHH:
   503  		z := y.concatSelectedConstantGrouped(cscimm4(a, a, b, b), x)
   504  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), y)
   505  	case _LHHH:
   506  		z := x.concatSelectedConstantGrouped(cscimm4(a, a, b, b), y)
   507  		return z.concatSelectedConstantGrouped(cscimm4(0, 2, c, d), y)
   508  
   509  	case _LLLH:
   510  		z := x.concatSelectedConstantGrouped(cscimm4(c, c, d, d), y)
   511  		return x.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   512  	case _LLHL:
   513  		z := y.concatSelectedConstantGrouped(cscimm4(c, c, d, d), x)
   514  		return x.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   515  	case _HHLH:
   516  		z := x.concatSelectedConstantGrouped(cscimm4(c, c, d, d), y)
   517  		return y.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   518  	case _HHHL:
   519  		z := y.concatSelectedConstantGrouped(cscimm4(c, c, d, d), x)
   520  		return y.concatSelectedConstantGrouped(cscimm4(a, b, 0, 2), z)
   521  
   522  	case _LHLH:
   523  		z := x.concatSelectedConstantGrouped(cscimm4(a, c, b, d), y)
   524  		return z.concatSelectedConstantGrouped(0b11_01_10_00 /* =cscimm4(0, 2, 1, 3) */, z)
   525  	case _HLHL:
   526  		z := x.concatSelectedConstantGrouped(cscimm4(b, d, a, c), y)
   527  		return z.concatSelectedConstantGrouped(0b01_11_00_10 /* =cscimm4(2, 0, 3, 1) */, z)
   528  	case _HLLH:
   529  		z := x.concatSelectedConstantGrouped(cscimm4(b, c, a, d), y)
   530  		return z.concatSelectedConstantGrouped(0b11_01_00_10 /* =cscimm4(2, 0, 1, 3) */, z)
   531  	case _LHHL:
   532  		z := x.concatSelectedConstantGrouped(cscimm4(a, d, b, c), y)
   533  		return z.concatSelectedConstantGrouped(0b01_11_10_00 /* =cscimm4(0, 2, 3, 1) */, z)
   534  	}
   535  	panic("missing case, switch should be exhaustive")
   536  }
   537  
   538  func (x Uint64x2) concatPermuteScalars(a, b uint8, y Uint64x2) Uint64x2 {
   539  	pattern := (a&2)>>1 + (b & 2)
   540  
   541  	a, b = a&1, b&1
   542  
   543  	switch pattern {
   544  	case _LL:
   545  		return x.concatSelectedConstant(cscimm2(a, b), x)
   546  	case _HH:
   547  		return y.concatSelectedConstant(cscimm2(a, b), y)
   548  	case _LH:
   549  		return x.concatSelectedConstant(cscimm2(a, b), y)
   550  	case _HL:
   551  		return y.concatSelectedConstant(cscimm2(a, b), x)
   552  	}
   553  	panic("missing case, switch should be exhaustive")
   554  }
   555  
   556  func (x Uint64x4) concatPermuteScalarsGrouped(a, b uint8, y Uint64x4) Uint64x4 {
   557  	pattern := (a&2)>>1 + (b & 2)
   558  
   559  	a, b = a&1, b&1
   560  
   561  	switch pattern {
   562  	case _LL:
   563  		return x.concatSelectedConstantGrouped(cscimm2g2(a, b), x)
   564  	case _HH:
   565  		return y.concatSelectedConstantGrouped(cscimm2g2(a, b), y)
   566  	case _LH:
   567  		return x.concatSelectedConstantGrouped(cscimm2g2(a, b), y)
   568  	case _HL:
   569  		return y.concatSelectedConstantGrouped(cscimm2g2(a, b), x)
   570  	}
   571  	panic("missing case, switch should be exhaustive")
   572  }
   573  
   574  func (x Uint64x8) concatPermuteScalarsGrouped(a, b uint8, y Uint64x8) Uint64x8 {
   575  	pattern := (a&2)>>1 + (b & 2)
   576  
   577  	a, b = a&1, b&1
   578  
   579  	switch pattern {
   580  	case _LL:
   581  		return x.concatSelectedConstantGrouped(cscimm2g4(a, b), x)
   582  	case _HH:
   583  		return y.concatSelectedConstantGrouped(cscimm2g4(a, b), y)
   584  	case _LH:
   585  		return x.concatSelectedConstantGrouped(cscimm2g4(a, b), y)
   586  	case _HL:
   587  		return y.concatSelectedConstantGrouped(cscimm2g4(a, b), x)
   588  	}
   589  	panic("missing case, switch should be exhaustive")
   590  }
   591  
   592  func (x Float64x2) concatPermuteScalars(a, b uint8, y Float64x2) Float64x2 {
   593  	pattern := (a&2)>>1 + (b & 2)
   594  
   595  	a, b = a&1, b&1
   596  
   597  	switch pattern {
   598  	case _LL:
   599  		return x.concatSelectedConstant(cscimm2(a, b), x)
   600  	case _HH:
   601  		return y.concatSelectedConstant(cscimm2(a, b), y)
   602  	case _LH:
   603  		return x.concatSelectedConstant(cscimm2(a, b), y)
   604  	case _HL:
   605  		return y.concatSelectedConstant(cscimm2(a, b), x)
   606  	}
   607  	panic("missing case, switch should be exhaustive")
   608  }
   609  
   610  func (x Float64x4) concatPermuteScalarsGrouped(a, b uint8, y Float64x4) Float64x4 {
   611  	pattern := (a&2)>>1 + (b & 2)
   612  
   613  	a, b = a&1, b&1
   614  
   615  	switch pattern {
   616  	case _LL:
   617  		return x.concatSelectedConstantGrouped(cscimm2g2(a, b), x)
   618  	case _HH:
   619  		return y.concatSelectedConstantGrouped(cscimm2g2(a, b), y)
   620  	case _LH:
   621  		return x.concatSelectedConstantGrouped(cscimm2g2(a, b), y)
   622  	case _HL:
   623  		return y.concatSelectedConstantGrouped(cscimm2g2(a, b), x)
   624  	}
   625  	panic("missing case, switch should be exhaustive")
   626  }
   627  
   628  func (x Float64x8) concatPermuteScalarsGrouped(a, b uint8, y Float64x8) Float64x8 {
   629  	pattern := (a&2)>>1 + (b & 2)
   630  
   631  	a, b = a&1, b&1
   632  
   633  	switch pattern {
   634  	case _LL:
   635  		return x.concatSelectedConstantGrouped(cscimm2g4(a, b), x)
   636  	case _HH:
   637  		return y.concatSelectedConstantGrouped(cscimm2g4(a, b), y)
   638  	case _LH:
   639  		return x.concatSelectedConstantGrouped(cscimm2g4(a, b), y)
   640  	case _HL:
   641  		return y.concatSelectedConstantGrouped(cscimm2g4(a, b), x)
   642  	}
   643  	panic("missing case, switch should be exhaustive")
   644  }
   645  
   646  func (x Int64x2) concatPermuteScalars(a, b uint8, y Int64x2) Int64x2 {
   647  	pattern := (a&2)>>1 + (b & 2)
   648  
   649  	a, b = a&1, b&1
   650  
   651  	switch pattern {
   652  	case _LL:
   653  		return x.concatSelectedConstant(cscimm2(a, b), x)
   654  	case _HH:
   655  		return y.concatSelectedConstant(cscimm2(a, b), y)
   656  	case _LH:
   657  		return x.concatSelectedConstant(cscimm2(a, b), y)
   658  	case _HL:
   659  		return y.concatSelectedConstant(cscimm2(a, b), x)
   660  	}
   661  	panic("missing case, switch should be exhaustive")
   662  }
   663  
   664  func (x Int64x4) concatPermuteScalarsGrouped(a, b uint8, y Int64x4) Int64x4 {
   665  	pattern := (a&2)>>1 + (b & 2)
   666  
   667  	a, b = a&1, b&1
   668  
   669  	switch pattern {
   670  	case _LL:
   671  		return x.concatSelectedConstantGrouped(cscimm2g2(a, b), x)
   672  	case _HH:
   673  		return y.concatSelectedConstantGrouped(cscimm2g2(a, b), y)
   674  	case _LH:
   675  		return x.concatSelectedConstantGrouped(cscimm2g2(a, b), y)
   676  	case _HL:
   677  		return y.concatSelectedConstantGrouped(cscimm2g2(a, b), x)
   678  	}
   679  	panic("missing case, switch should be exhaustive")
   680  }
   681  
   682  func (x Int64x8) concatPermuteScalarsGrouped(a, b uint8, y Int64x8) Int64x8 {
   683  	pattern := (a&2)>>1 + (b & 2)
   684  
   685  	a, b = a&1, b&1
   686  
   687  	switch pattern {
   688  	case _LL:
   689  		return x.concatSelectedConstantGrouped(cscimm2g4(a, b), x)
   690  	case _HH:
   691  		return y.concatSelectedConstantGrouped(cscimm2g4(a, b), y)
   692  	case _LH:
   693  		return x.concatSelectedConstantGrouped(cscimm2g4(a, b), y)
   694  	case _HL:
   695  		return y.concatSelectedConstantGrouped(cscimm2g4(a, b), x)
   696  	}
   697  	panic("missing case, switch should be exhaustive")
   698  }
   699  

View as plain text