Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler fails to convert loop into memcpy / vectorize it #4622

Open
Waqar144 opened this issue Dec 24, 2024 · 0 comments
Open

Compiler fails to convert loop into memcpy / vectorize it #4622

Waqar144 opened this issue Dec 24, 2024 · 0 comments

Comments

@Waqar144
Copy link
Contributor

Context

Consider the following simple code:

@require
test_fn2 :: proc(length: int) #no_bounds_check {
    arr1 := make([]int, length + 1)
    arr2 := make([]int, length + 1)

    for i := 0; i <= length; i += 1 {
        arr1[i] = arr2[i]
    }
}

The compiler fails to vectorize it or turn it into a memcpy. If the loop end condition is modified to be just <, it gets vectorized:

    for i := 0; i < length; i += 1 { // vectorizes

Link to compiler explorer: https://compiler-explorer.com/z/TM74EcfKh


  • Operating System & Odin Version: Linux, dev-2024-12
  • Please paste odin report output:
Odin:    dev-2024-12-nightly
OS:      Manjaro Linux, Linux 6.6.63-1-MANJARO
CPU:     AMD Ryzen 7 4700U with Radeon Graphics         
RAM:     15355 MiB
Backend: LLVM 18.1.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant