diff --git a/src/compiler/types.c b/src/compiler/types.c index f2ac6f63b..10ac4f2a2 100644 --- a/src/compiler/types.c +++ b/src/compiler/types.c @@ -668,11 +668,11 @@ AlignSize type_abi_alignment(Type *type) if (!len) len = 1; ByteSize width = type_size(type->array.base) * len; AlignSize alignment = (AlignSize)(int32_t)width; - if (alignment & (alignment - 1)) + if (max_alignment_vector && alignment > max_alignment_vector) return max_alignment_vector; + if (!is_power_of_two(alignment)) { alignment = (AlignSize)next_highest_power_of_2((uint32_t)alignment); } - if (max_alignment_vector && alignment > max_alignment_vector) alignment = max_alignment_vector; return alignment; } case TYPE_VOID: diff --git a/test/unit/stdlib/math/matrix.c3 b/test/unit/stdlib/math/matrix.c3 index bb66d0b54..97bb966d3 100644 --- a/test/unit/stdlib/math/matrix.c3 +++ b/test/unit/stdlib/math/matrix.c3 @@ -50,8 +50,8 @@ fn void test_mat4() -0.988936, -2.970838, -20.765262, 1.000000 }; - Matrix4 look_at = vector::matrix4_look_at({4.0, 5.0, 20.0}, {1.0, 3.0, 0.0}, {0.0, 1.0, 0.0}); - Matrix4f look_at_f = vector::matrix4f_look_at({4.0, 5.0, 20.0}, {1.0, 3.0, 0.0}, {0.0, 1.0, 0.0}); + Matrix4 look_at = matrix::look_at()({4.0, 5.0, 20.0}, {1.0, 3.0, 0.0}, {0.0, 1.0, 0.0}); + Matrix4f look_at_f = matrix::look_at()({4.0, 5.0, 20.0}, {1.0, 3.0, 0.0}, {0.0, 1.0, 0.0}); assert(math::round_to_decimals((double[<16>])look_at.m, 4) == math::round_to_decimals((double[<16>])result.m, 4)); assert(math::round_to_decimals((float[<16>])look_at_f.m, 4) == math::round_to_decimals((float[<16>])result_f.m, 4));