Skip to content

Commit

Permalink
Update cord-simd implementation to fix nightly.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitshifter committed Dec 3, 2023
1 parent 9be932e commit 5a934e3
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 276 deletions.
62 changes: 31 additions & 31 deletions codegen/templates/coresimd.rs.tera
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
let swp0a = simd_swizzle!(
self.w_axis.0,
self.z_axis.0,
[First(3), First(3), Second(3), Second(3)]
[3, 3, 7, 7]
);
let swp0b = simd_swizzle!(
self.w_axis.0,
self.z_axis.0,
[First(2), First(2), Second(2), Second(2)]
[2, 2, 6, 6]
);

let swp00 = simd_swizzle!(
self.z_axis.0,
self.y_axis.0,
[First(2), First(2), Second(2), Second(2)]
[2, 2, 6, 6]
);
let swp01 = simd_swizzle!(swp0a, [0, 0, 0, 2]);
let swp02 = simd_swizzle!(swp0b, [0, 0, 0, 2]);
let swp03 = simd_swizzle!(
self.z_axis.0,
self.y_axis.0,
[First(3), First(3), Second(3), Second(3)]
[3, 3, 7, 7]
);

let mul00 = swp00 * swp01;
Expand All @@ -33,25 +33,25 @@
let swp0a = simd_swizzle!(
self.w_axis.0,
self.z_axis.0,
[First(3), First(3), Second(3), Second(3)]
[3, 3, 7, 7]
);
let swp0b = simd_swizzle!(
self.w_axis.0,
self.z_axis.0,
[First(1), First(1), Second(1), Second(1)]
[1, 1, 5, 5]
);

let swp00 = simd_swizzle!(
self.z_axis.0,
self.y_axis.0,
[First(1), First(1), Second(1), Second(1)]
[1, 1, 5, 5]
);
let swp01 = simd_swizzle!(swp0a, [0, 0, 0, 2]);
let swp02 = simd_swizzle!(swp0b, [0, 0, 0, 2]);
let swp03 = simd_swizzle!(
self.z_axis.0,
self.y_axis.0,
[First(3), First(3), Second(3), Second(3)]
[3, 3, 7, 7]
);

let mul00 = swp00 * swp01;
Expand All @@ -62,25 +62,25 @@
let swp0a = simd_swizzle!(
self.w_axis.0,
self.z_axis.0,
[First(2), First(2), Second(2), Second(2)]
[2, 2, 6, 6]
);
let swp0b = simd_swizzle!(
self.w_axis.0,
self.z_axis.0,
[First(1), First(1), Second(1), Second(1)]
[1, 1, 5, 5]
);

let swp00 = simd_swizzle!(
self.z_axis.0,
self.y_axis.0,
[First(1), First(1), Second(1), Second(1)]
[1, 1, 5, 5]
);
let swp01 = simd_swizzle!(swp0a, [0, 0, 0, 2]);
let swp02 = simd_swizzle!(swp0b, [0, 0, 0, 2]);
let swp03 = simd_swizzle!(
self.z_axis.0,
self.y_axis.0,
[First(2), First(2), Second(2), Second(2)]
[2, 2, 6, 6]
);

let mul00 = swp00 * swp01;
Expand All @@ -91,25 +91,25 @@
let swp0a = simd_swizzle!(
self.w_axis.0,
self.z_axis.0,
[First(3), First(3), Second(3), Second(3)]
[3, 3, 7, 7]
);
let swp0b = simd_swizzle!(
self.w_axis.0,
self.z_axis.0,
[First(0), First(0), Second(0), Second(0)]
[0, 0, 4, 4]
);

let swp00 = simd_swizzle!(
self.z_axis.0,
self.y_axis.0,
[First(0), First(0), Second(0), Second(0)]
[0, 0, 4, 4]
);
let swp01 = simd_swizzle!(swp0a, [0, 0, 0, 2]);
let swp02 = simd_swizzle!(swp0b, [0, 0, 0, 2]);
let swp03 = simd_swizzle!(
self.z_axis.0,
self.y_axis.0,
[First(3), First(3), Second(3), Second(3)]
[3, 3, 7, 7]
);

let mul00 = swp00 * swp01;
Expand All @@ -120,25 +120,25 @@
let swp0a = simd_swizzle!(
self.w_axis.0,
self.z_axis.0,
[First(2), First(2), Second(2), Second(2)]
[2, 2, 6, 6]
);
let swp0b = simd_swizzle!(
self.w_axis.0,
self.z_axis.0,
[First(0), First(0), Second(0), Second(0)]
[0, 0, 4, 4]
);

let swp00 = simd_swizzle!(
self.z_axis.0,
self.y_axis.0,
[First(0), First(0), Second(0), Second(0)]
[0, 0, 4, 4]
);
let swp01 = simd_swizzle!(swp0a, [0, 0, 0, 2]);
let swp02 = simd_swizzle!(swp0b, [0, 0, 0, 2]);
let swp03 = simd_swizzle!(
self.z_axis.0,
self.y_axis.0,
[First(2), First(2), Second(2), Second(2)]
[2, 2, 6, 6]
);

let mul00 = swp00 * swp01;
Expand All @@ -149,25 +149,25 @@
let swp0a = simd_swizzle!(
self.w_axis.0,
self.z_axis.0,
[First(1), First(1), Second(1), Second(1)]
[1, 1, 5, 5]
);
let swp0b = simd_swizzle!(
self.w_axis.0,
self.z_axis.0,
[First(0), First(0), Second(0), Second(0)]
[0, 0, 4, 4]
);

let swp00 = simd_swizzle!(
self.z_axis.0,
self.y_axis.0,
[First(0), First(0), Second(0), Second(0)]
[0, 0, 4, 4]
);
let swp01 = simd_swizzle!(swp0a, [0, 0, 0, 2]);
let swp02 = simd_swizzle!(swp0b, [0, 0, 0, 2]);
let swp03 = simd_swizzle!(
self.z_axis.0,
self.y_axis.0,
[First(1), First(1), Second(1), Second(1)]
[1, 1, 5, 5]
);

let mul00 = swp00 * swp01;
Expand All @@ -180,28 +180,28 @@
let temp0 = simd_swizzle!(
self.y_axis.0,
self.x_axis.0,
[First(0), First(0), Second(0), Second(0)]
[0, 0, 4, 4]
);
let vec0 = simd_swizzle!(temp0, [0, 2, 2, 2]);

let temp1 = simd_swizzle!(
self.y_axis.0,
self.x_axis.0,
[First(1), First(1), Second(1), Second(1)]
[1, 1, 5, 5]
);
let vec1 = simd_swizzle!(temp1, [0, 2, 2, 2]);

let temp2 = simd_swizzle!(
self.y_axis.0,
self.x_axis.0,
[First(2), First(2), Second(2), Second(2)]
[2, 2, 6, 6]
);
let vec2 = simd_swizzle!(temp2, [0, 2, 2, 2]);

let temp3 = simd_swizzle!(
self.y_axis.0,
self.x_axis.0,
[First(3), First(3), Second(3), Second(3)]
[3, 3, 7, 7]
);
let vec3 = simd_swizzle!(temp3, [0, 2, 2, 2]);

Expand Down Expand Up @@ -233,9 +233,9 @@
let add03 = sub03 + mul11;
let inv3 = sign_a * add03;

let row0 = simd_swizzle!(inv0, inv1, [First(0), First(0), Second(0), Second(0)]);
let row1 = simd_swizzle!(inv2, inv3, [First(0), First(0), Second(0), Second(0)]);
let row2 = simd_swizzle!(row0, row1, [First(0), First(2), Second(0), Second(2)]);
let row0 = simd_swizzle!(inv0, inv1, [0, 0, 4, 4]);
let row1 = simd_swizzle!(inv2, inv3, [0, 0, 4, 4]);
let row2 = simd_swizzle!(row0, row1, [0, 2, 4, 6]);

let dot0 = dot4(self.x_axis.0, row2);
glam_assert!(dot0 != 0.0);
Expand Down
34 changes: 17 additions & 17 deletions codegen/templates/mat.rs.tera
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ use core::arch::x86_64::*;
{% elif is_wasm32 %}
use core::arch::wasm32::*;
{% elif is_coresimd %}
use core::simd::{Which::*, *};
use core::simd::*;
{% endif %}

{% if self_t == "Mat2" and is_sse2 %}
Expand Down Expand Up @@ -1017,29 +1017,29 @@ impl {{ self_t }} {
let tmp0 = simd_swizzle!(
self.x_axis.0,
self.y_axis.0,
[First(0), First(1), Second(0), Second(1)]
[0, 1, 4, 5]
);
let tmp1 = simd_swizzle!(
self.x_axis.0,
self.y_axis.0,
[First(2), First(3), Second(2), Second(3)]
[2, 3, 6, 7]
);

Self {
x_axis: Vec3A(simd_swizzle!(
tmp0,
self.z_axis.0,
[First(0), First(2), Second(0), Second(0)]
[0, 2, 4, 4]
)),
y_axis: Vec3A(simd_swizzle!(
tmp0,
self.z_axis.0,
[First(1), First(3), Second(1), Second(1)]
[1, 3, 5, 5]
)),
z_axis: Vec3A(simd_swizzle!(
tmp1,
self.z_axis.0,
[First(0), First(2), Second(2), Second(2)]
[0, 2, 6, 6]
)),
}
{% elif self_t == "Mat4" and is_sse2 %}
Expand Down Expand Up @@ -1075,29 +1075,29 @@ impl {{ self_t }} {
let tmp0 = simd_swizzle!(
self.x_axis.0,
self.y_axis.0,
[First(0), First(1), Second(0), Second(1)]
[0, 1, 4, 5]
);
let tmp1 = simd_swizzle!(
self.x_axis.0,
self.y_axis.0,
[First(2), First(3), Second(2), Second(3)]
[2, 3, 6, 7]
);
let tmp2 = simd_swizzle!(
self.z_axis.0,
self.w_axis.0,
[First(0), First(1), Second(0), Second(1)]
[0, 1, 4, 5]
);
let tmp3 = simd_swizzle!(
self.z_axis.0,
self.w_axis.0,
[First(2), First(3), Second(2), Second(3)]
[2, 3, 6, 7]
);

Self {
x_axis: Vec4(simd_swizzle!(tmp0, tmp2, [First(0), First(2), Second(0), Second(2)])),
y_axis: Vec4(simd_swizzle!(tmp0, tmp2, [First(1), First(3), Second(1), Second(3)])),
z_axis: Vec4(simd_swizzle!(tmp1, tmp3, [First(0), First(2), Second(0), Second(2)])),
w_axis: Vec4(simd_swizzle!(tmp1, tmp3, [First(1), First(3), Second(1), Second(3)])),
x_axis: Vec4(simd_swizzle!(tmp0, tmp2, [0, 2, 4, 6])),
y_axis: Vec4(simd_swizzle!(tmp0, tmp2, [1, 3, 5, 7])),
z_axis: Vec4(simd_swizzle!(tmp1, tmp3, [0, 2, 4, 6])),
w_axis: Vec4(simd_swizzle!(tmp1, tmp3, [1, 3, 5, 7])),
}
{% else %}
Self {
Expand Down Expand Up @@ -1226,13 +1226,13 @@ impl {{ self_t }} {
let swpfaca = simd_swizzle!(self.y_axis.0, [1, 0, 0, 0]);
let mulfaca = swpfaca * subfaca;

let subtmpb = simd_swizzle!(sube, subf, [First(1), First(3), Second(0), Second(0)]);
let subtmpb = simd_swizzle!(sube, subf, [1, 3, 4, 4]);
let subfacb = simd_swizzle!(subtmpb, [0, 1, 1, 3]);
let swpfacb = simd_swizzle!(self.y_axis.0, [2, 2, 1, 1]);
let mulfacb = swpfacb * subfacb;

let subres = mulfaca - mulfacb;
let subtmpc = simd_swizzle!(sube, subf, [First(2), First(2), Second(0), Second(1)]);
let subtmpc = simd_swizzle!(sube, subf, [2, 2, 4, 5]);
let subfacc = simd_swizzle!(subtmpc, [0, 2, 3, 3]);
let swpfacc = simd_swizzle!(self.y_axis.0, [3, 3, 3, 2]);
let mulfacc = swpfacc * subfacc;
Expand Down Expand Up @@ -1933,7 +1933,7 @@ impl {{ self_t }} {
let cydyaxbx1 = simd_swizzle!(axbxcydy1, [2, 3, 0, 1]);
let result0 = axbxcydy0 + cydyaxbx0;
let result1 = axbxcydy1 + cydyaxbx1;
Self(simd_swizzle!(result0, result1, [First(0), First(1), Second(0), Second(1)]))
Self(simd_swizzle!(result0, result1, [0, 1, 4, 5]))
{% else %}
Self::from_cols(
{% for axis in axes %}
Expand Down
2 changes: 1 addition & 1 deletion codegen/templates/vec.rs.tera
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ use core::arch::x86_64::*;
{% elif is_wasm32 %}
use core::arch::wasm32::*;
{% elif is_coresimd %}
use core::simd::*;
use core::simd::{cmp::SimdPartialEq, cmp::SimdPartialOrd, num::SimdFloat, *};
use std::simd::StdFloat;
{% endif %}

Expand Down
2 changes: 1 addition & 1 deletion src/coresimd.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use core::simd::*;
use core::simd::{num::SimdFloat, *};

/// Calculates the vector 3 dot product and returns answer in x lane of f32x4.
#[inline(always)]
Expand Down
8 changes: 2 additions & 6 deletions src/f32/coresimd/mat2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use core::fmt;
use core::iter::{Product, Sum};
use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};

use core::simd::{Which::*, *};
use core::simd::*;

/// Creates a 2x2 matrix from two column vectors.
#[inline(always)]
Expand Down Expand Up @@ -249,11 +249,7 @@ impl Mat2 {
let cydyaxbx1 = simd_swizzle!(axbxcydy1, [2, 3, 0, 1]);
let result0 = axbxcydy0 + cydyaxbx0;
let result1 = axbxcydy1 + cydyaxbx1;
Self(simd_swizzle!(
result0,
result1,
[First(0), First(1), Second(0), Second(1)]
))
Self(simd_swizzle!(result0, result1, [0, 1, 4, 5]))
}

/// Adds two 2x2 matrices.
Expand Down
Loading

0 comments on commit 5a934e3

Please sign in to comment.