llvm / llvm/llvm-project

[aarch64] Missed MADD folding opportunity

Open
#224,696 1 comment 0 reactions 1 assignee Claimed by @pzhengqc View on GitHub
backend:AArch64 missed-optimization
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

For the following function foo,

```c
long foo(long stride, int mvx, int mvy)
{
return (long)(mvy >> 2) * stride + (mvx >> 2);
}
```

LLVM currently generates MUL+ADD, instead of MADD.

```asm
foo:
sbfx x8, x2, #2, #30
asr w9, w1, #2
mul x8, x0, x8
add x0, x8, w9, sxtw
ret
```

With MADD, we could generate the following:

```asm
foo:
sbfx x8, x2, #2, #30
sbfx x9, x1, #2, #30
madd x0, x0, x8, x9
```

The test case was found in DCPerf's VideoTranscodeBench benchmark.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.