[llvm] [GlobalIsel] Combine G_ADD and G_SUB (PR #92879)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Wed May 22 06:24:03 PDT 2024
Thorsten =?utf-8?q?Schütt?= <schuett at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/92879 at github.com>
jayfoad wrote:
> // fold ((0-A) + B) -> B-A
For cases like this it's not clear that a `hasOneUse` check is needed. If you do the transform when there are multiple uses you'll end up with the same number of operations but less latency, so it seems like a win. Before:
```
sub x, 0, a
add y, x, b // dependent on result of sub
// both x and y are used after this
```
After:
```
sub x, 0, a
sub y, b, a // not dependent on first sub
// both x and y are used after this
```
There _might_ be register pressure effects but they are pretty hard to reason about at the GMIR level.
https://github.com/llvm/llvm-project/pull/92879
More information about the llvm-commits
mailing list