llvm-project
927a56d2 - [AArch64] Avoid folding SRA/SRL into ALU when it can be folded with SHL/AND (#234737)

Commit
1 day ago
[AArch64] Avoid folding SRA/SRL into ALU when it can be folded with SHL/AND (#234737) For the following function ``` int f(int a, int b) { b -= (a<<26)>>29; return b; } ``` LLVM currently generates ``` f: lsl w8, w0, #26 sub w0, w1, w8, asr #29 ret ``` However, if we don't fold the `asr` into the `sub`, the `asr` can be folded with the `lsl` instead, and we can avoid generating the shifted-register `sub` which is more expensive on some cores. With this patch, we generate the following instead ``` f: sbfx w8, w0, #3, #3 sub w0, w1, w8 ret ``` Fixes #234730
Author
Parents
Loading