[all-commits] [llvm/llvm-project] 33ca7a: [LICM] Reassociate add/sub expressions to hoist in...

Valeriy Savchenko via All-commits all-commits at lists.llvm.org
Wed Apr 1 10:30:01 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 33ca7a4667d7f60a4692a2e03b3de94f66ff0d10
      https://github.com/llvm/llvm-project/commit/33ca7a4667d7f60a4692a2e03b3de94f66ff0d10
  Author: Valeriy Savchenko <vsavchenko at apple.com>
  Date:   2026-04-01 (Wed, 01 Apr 2026)

  Changed paths:
    M llvm/lib/Transforms/Scalar/LICM.cpp
    M llvm/test/Transforms/LICM/hoist-binop.ll

  Log Message:
  -----------
  [LICM] Reassociate add/sub expressions to hoist invariant computations (#183082)

While `sub` is not associative, we can still reassociate `add` and
`sub`.

## Alive2 proofs

| Case | Transform | Proof |
|------|-----------|-------|
| 1 | `(x + c1) - c2` => `x + (c1 - c2)` |
[proof](https://alive2.llvm.org/ce/z/iofzYy) |
| 2 | `(x - c1) - c2` => `x - (c1 + c2)` |
[proof](https://alive2.llvm.org/ce/z/U4K_tE) |
| 3 | `(x - c1) + c2` => `x + (c2 - c1)` |
[proof](https://alive2.llvm.org/ce/z/moiJVw) |



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list