Issue |
126375
|
Summary |
[AArch64] Elminate indirect conditional jump when branching to function
|
Labels |
backend:AArch64,
missed-optimization
|
Assignees |
|
Reporter |
marcauberer
|
Split off from the discussion here: https://github.com/llvm/llvm-project/issues/126363#issuecomment-2645730295
Given this code:
```cpp
void t(), f();
void decide(bool ok) {
if (ok) {
t();
} else {
f();
}
}
```
we currently produce this assembly for armv8-a / AArch64 (https://godbolt.org/z/hrEeqrTPM):
```asm
_Z6decideb:
tbz w0, #0, .LBB0_2
b _Z1tv
.LBB0_2:
b _Z1fv
```
This should be equivalent to this:
```asm
_Z6decideb:
tbz w0, #0, _Z1fv
b _Z1tv
```
In a second step, maybe even this, which compares the whole register instead of a single bit:
```asm
_Z6decideb:
cbz w0, _Z1fv
b _Z1tv
```
This optimization is of course only possible when the function call needs no register prep for arguments or such.
I am not particularly familiar with the AArch64 backend, so let me know if the current behaviour has a certain reason.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs