[all-commits] [llvm/llvm-project] dd0cf2: [LICM] Reassociate & hoist sub expressions

Max Kazantsev via All-commits all-commits at lists.llvm.org
Sun May 28 22:53:10 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: dd0cf23e4a87765b03bb1003d4cc37445d8217b4
      https://github.com/llvm/llvm-project/commit/dd0cf23e4a87765b03bb1003d4cc37445d8217b4
  Author: Max Kazantsev <mkazantsev at azul.com>
  Date:   2023-05-29 (Mon, 29 May 2023)

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

  Log Message:
  -----------
  [LICM] Reassociate & hoist sub expressions

LICM could reassociate mixed variant/invariant comparison/arithmetic operations
and hoist invariant parts out of loop if it can prove that they can be computed
without overflow. Motivating example here:
```
  INV1 - VAR1 < INV2
```
can be turned into
```
  VAR > INV1 - INV2
```
if we can prove no-signed-overflow here. Then `INV1 - INV2` can be computed
out of loop, so we save one arithmetic operation in-loop.

Reviewed By: skatkov
Differential Revision: https://reviews.llvm.org/D148001




More information about the All-commits mailing list