Repository: dotnet/runtime
File: src/libraries/System.Private.CoreLib/src/System/Numerics/Matrix4x4.Impl.cs (C#)

Code before:
                    Vector128<float> y_ggff = Sse.Shuffle(y, y, 0b01011010);
                    Vector128<float> y_hhhg = Sse.Shuffle(y, y, 0b10111111);

                    // tmp1[0] = kp_lo
                    // tmp1[1] = jp_ln
                    // tmp1[2] = jo_kn
                    // tmp1[3] = ip_lm
                    Vector128<float> tmp1 = z_kjji * w_ppop - z_llkl * w_onnm;

                    // tmp2[0] = io_km
                    // tmp2[1] = in_jm
                    // tmp2[2] = ip_lm
                    // tmp2[3] = jo_kn
                    Vector128<float> tmp2 = z_iiij * w_onpo - z_kjlk * w_mmmn;

                    // tmp3[0] = kp_lo
                    // tmp3[1] = kp_lo
                    // tmp3[2] = jp_ln
                    // tmp3[3] = jo_kn
                    Vector128<float> tmp3 = Sse.Shuffle(tmp1, tmp1, 0b10010000);

                    // tmp4[0] = jp_ln
                    // tmp4[1] = ip_lm
                    // tmp4[2] = ip_lm
                    // tmp4[3] = io_km
                    Vector128<float> tmp4 = Sse.Shuffle(tmp1, tmp2, 0b00101101);

                    // tmp5[0] = jo_kn
                    // tmp5[1] = io_km
                    // tmp5[2] = in_jm
                    // tmp5[3] = in_jm
                    Vector128<float> tmp5 = Sse.Shuffle(tmp2, tmp2, 0b01010011);

                    Vector128<float> tmp6 = x * (y_feee * tmp3 - y_ggff * tmp4 + y_hhhg * tmp5);
                    Vector128<float> tmp7 = tmp6 - Sse.Shuffle(tmp6, tmp6, 0b00110001);
                    return tmp7[0] + tmp7[2];
                }

                float a = X.X, b = X.Y, c = X.Z, d = X.W;
                float e = Y.X, f = Y.Y, g = Y.Z, h = Y.W;
                float i = Z.X, j = Z.Y, k = Z.Z, l = Z.W;
                float m = W.X, n = W.Y, o = W.Z, p = W.W;

                float kp_lo = k * p - l * o;
                float jp_ln = j * p - l * n;
                float jo_kn = j * o - k * n;
                float ip_lm = i * p - l * m;
                float io_km = i * o - k * m;
                float in_jm = i * n - j * m;

                return a * (f * kp_lo - g * jp_ln + h * jo_kn) -

Review comment (suggestion):
This is the only one that can't easily be switched to `Vector128.Shuffle` today.

Functionally it is:
```csharp
Vector128.Create(tmp1[1], tmp1[3], tmp2[2], tmp2[0])
```

This could probably be done as...
```suggestion
                    Vector128<float> tmp4;

                    if (Sse.IsSupported)
                    {
                        tmp4 = Sse.Shuffle(tmp1, tmp2, 0b00_10_11_01);
                    }
                    else
                    {
                        tmp4 = Vector128.ConditionalSelect(
                            Vector128.Create(-1, -1, 0, 0),
                            Vector128.Shuffle(tmp1, Vector128.Create(1, 3, 1, 3)),
                            Vector128.Shuffle(tmp2, Vector128.Create(2, 0, 2, 0))
                        );
                    }
```

This keeps it optimal for xarch, while not restricting it for other contexts. We have two parameter xplat shuffle approved, just not implemented yet: https://github.com/dotnet/runtime/issues/63331. Once that is implemented this would become:
```csharp
Vector128<float> tmp4 = Vector128.Shuffle(tmp1, tmp2, Vector128.Create(1, 3, 6, 4));
```

Code after:
                    Vector128<float> y_ggff = Vector128.Shuffle(y, Vector128.Create(2, 2, 1, 1));
                    Vector128<float> y_hhhg = Vector128.Shuffle(y, Vector128.Create(3, 3, 3, 2));

                    // tmp1[0] = kp_lo
                    // tmp1[1] = jp_ln
                    // tmp1[2] = jo_kn
                    // tmp1[3] = ip_lm
                    Vector128<float> tmp1 = z_kjji * w_ppop - z_llkl * w_onnm;

                    // tmp2[0] = io_km
                    // tmp2[1] = in_jm
                    // tmp2[2] = ip_lm
                    // tmp2[3] = jo_kn
                    Vector128<float> tmp2 = z_iiij * w_onpo - z_kjlk * w_mmmn;

                    // tmp3[0] = kp_lo
                    // tmp3[1] = kp_lo
                    // tmp3[2] = jp_ln
                    // tmp3[3] = jo_kn
                    Vector128<float> tmp3 = Vector128.Shuffle(tmp1, Vector128.Create(0, 0, 1, 2));

                    // tmp4[0] = jp_ln
                    // tmp4[1] = ip_lm
                    // tmp4[2] = ip_lm
                    // tmp4[3] = io_km
                    Vector128<float> tmp4;
                    if (Sse.IsSupported)
                    {
                        tmp4 = Sse.Shuffle(tmp1, tmp2, 0b00_10_11_01);
                    }
                    else
                    {
                        tmp4 = Vector128.ConditionalSelect(
                            Vector128.Create(-1, -1, 0, 0).AsSingle(),
                            Vector128.Shuffle(tmp1, Vector128.Create(1, 3, 1, 3)),
                            Vector128.Shuffle(tmp2, Vector128.Create(2, 0, 2, 0))
                        );
                    }

                    // tmp5[0] = jo_kn
                    // tmp5[1] = io_km
                    // tmp5[2] = in_jm
                    // tmp5[3] = in_jm
                    Vector128<float> tmp5 = Vector128.Shuffle(tmp2, Vector128.Create(3, 0, 1, 1));

                    Vector128<float> tmp6 = x * (y_feee * tmp3 - y_ggff * tmp4 + y_hhhg * tmp5);
                    Vector128<float> tmp7 = tmp6 - Vector128.Shuffle(tmp6, Vector128.Create(1, 0, 3, 0));
                    return tmp7[0] + tmp7[2];
                }

                float a = X.X, b = X.Y, c = X.Z, d = X.W;