-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
nested ifelse not giving computed gotos #10320
Comments
It's a fixed LLVM issue. LLVM is smart enough to generate switches (i.e. jump tables) for a few cases I've tested (even triggering a bug that needs to be workarounded). For the code shown above, llvm is smart enough to optimize it as if x - 1 < 11
return statically_computed_results[x]
else
return 0
end |
I think @simonbyrne's code was mostly for demonstration purposes... |
That's why I first addressed the general case. |
Which version of LLVM is it fixed in? |
Not sure, I'm using 4.0. |
Julia 0.6 and 0.7-DEV both produce native code using LLVM 3.9.1: .section __TEXT,__text,regular,pure_instructions
Filename: REPL[111]
pushq %rbp
movq %rsp, %rbp
Source line: 2
leaq -1(%rdi), %rax
cmpq $10, %rax
ja L31
movabsq $4745995008, %rax ## imm = 0x11AE22300
movq -8(%rax,%rdi,8), %rax
popq %rbp
retq
Source line: 3
L31:
xorl %eax, %eax
popq %rbp
retq
nopw %cs:(%rax,%rax) |
From #5410: LLVM should be able optimise certain chains of
ifelse
statements into computed gotos. However the examples mentioned in that issue no longer work, e.g.gives a sequence of
cmp
/jne
instructions.The text was updated successfully, but these errors were encountered: