diff options
| author | gingerBill <bill@gingerbill.org> | 2024-06-06 17:59:12 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-06-06 17:59:12 +0100 |
| commit | 039bb8794aae3b88cc0c14ac1b3f17c28bac0184 (patch) | |
| tree | 62224bf528bf05af08643b21ba1a17f70d52d80a /src/types.cpp | |
| parent | 3a9b86628a484aa03b594599653c1cab4b916c8e (diff) | |
Improve `matrix_align_of` logic when it has invalid inputs.
Diffstat (limited to 'src/types.cpp')
| -rw-r--r-- | src/types.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/types.cpp b/src/types.cpp index 618e5bd8a..45aa26894 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -1491,10 +1491,10 @@ gb_internal i64 matrix_align_of(Type *t, struct TypePath *tp) { i64 total_expected_size = row_count*t->Matrix.column_count*elem_size; // i64 min_alignment = prev_pow2(elem_align * row_count); i64 min_alignment = prev_pow2(total_expected_size); - while ((total_expected_size % min_alignment) != 0) { + while (total_expected_size != 0 && (total_expected_size % min_alignment) != 0) { min_alignment >>= 1; } - GB_ASSERT(min_alignment >= elem_align); + min_alignment = gb_max(min_alignment, elem_align); i64 align = gb_min(min_alignment, build_context.max_simd_align); return align; |