odin-lang / Odin

Odin Programming Language
https://odin-lang.org
BSD 3-Clause "New" or "Revised" License
6.17k stars 550 forks source link

linalg.transpose crashes on row_major matrices #3686

Closed karl-zylinski closed 1 month ago

karl-zylinski commented 1 month ago

Context

    Odin:    dev-2024-05:7058d6f32
    OS:      Windows 10 Professional (version: 22H2), build 19045.4412
    CPU:     Intel(R) Core(TM) i7-6950X CPU @ 3.00GHz
    RAM:     32674 MiB
    Backend: LLVM 17.0.1

Expected Behavior

Feeding row_major matrices to linalg.transpose should work

Current Behavior

Feeding row_major matrices to linalg.transpose crashes

Steps to Reproduce

package transpose_crash_repro

import "core:math/linalg"
import "core:fmt"

main :: proc() {
    inv := linalg.inverse((#row_major matrix[4,4]f32)(1))
    fmt.println(inv)
    transp := linalg.transpose(inv)
    fmt.println("got here")
}

run this code, you'll never get to "got here". It seems to crash. Remove #row_major on the line inv := linalg.inverse((#row_major matrix[4,4]f32)(1)) and it works.

karl-zylinski commented 1 month ago

If I change lb_emit_matrix_tranpose and remove the if (lb_is_matrix_simdable(mt)) {} block then the compiler outputs code that works.