Compiler bug, access violation when passing @Vector wraped inside struct

I have he following structs in my math library

pub const F32x4 = @Vector(4, f32);
pub const Quat = extern struct {
  xyzw: F32x4 = .{ 0.0, 0.0, 0.0, 1.0 },
};

pub fn matRotation_1(q: Quat)  Mat4 // q is passed via stack
pub fn matRotation_2(q: F32x4) Mat4 // q is passed via xmm0 as it should

pub fn matTRS_1(pos: F32x4, rot: Quat, s: F32x4) Mat4; // crashes on access violation
pub fn matTRS_2(pos: F32x4, rot: F32x4, s: F32x4) Mat4; // works fine

the issue is when using matTRS_1 I get an access violation exception, no error occurs if inline the function (by copy/paste or tag with inline keyword) looking at the assembly I notice that Quat is passed via stack while F32x4 is passed via xmm register not sure if this is a causing the bug or not.

In the past zig had produce invalid code with long an complex functions; I’m calling matTRS_1 from main that is about 1K line function

About Quat been passed in the stack rather than xmm is that working as intended?

Edit 1:
I found another thing: calling Quat.mat(rot) produces a different result that rot.mat() whut

pub fn trs(pos: F32x4, rot: Quat, s: F32x4) Mat4 {
  var m = Quat.mat(rot); // works fine
  var m = rot.mat(); // access violation
  inline for (0..3) |i| m.rows[i] *= @splat(s[i]);
  m.rows[3] = @shuffle(f32, pos, m.rows[3], [4]i32{ 0, 1, 2, -4 });
  return m;
}

Maybe take a look at this strategy: @Vector abuse? - #3 by Plebosaur

Hum, interesting, I’m on 0.16 but I think this is related, using Quat = struct without extern didn’t made difference at frist; but it enforced me to use .{ .xyzw = @bitCast(t.rotation) } instead of just @bitCast(t.rotation) and that fixed it;

Like the post said it tries to load the quaternion from stack by using vmovdqa instead of vmovdqu but t.rotation is a [4]f32 alinged to 4 instead of 16, I was getting access violation because of that;

This could have been avoided if quat had been passed by value via some xmm register :confused: