Issue 234730
Summary [AArch64] Missed folding opportunity for (sub b, (sra (shl a, C1), C2))
Labels backend:AArch64, missed-optimization
Assignees pzhengqc
Reporter pzhengqc
    For the following function,
```
int f(int a, int b) {
  b -= (a << 26) >> 29;
  return b;
}
```
LLVM generates:
```
f:
    lsl w8, w0, #26
 sub w0, w1, w8, asr #29
    ret
```
GCC generates the following instead:
```
foo:
    sbfx    w0, w0, 3, 3
    sub     w0, w1, w0
 ret
```
The shifted-register `sub` (` sub w0, w1, w8, asr #29`) is more expensive for some cores and can be avoided in this case. This pattern shows up in benchmarks such as DCPerf's VideoTranscodeBench.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to