[all-commits] [llvm/llvm-project] e38b7e: [DivRemPairs] Add an initial case for hoisting to ...

Craig Topper via All-commits all-commits at lists.llvm.org
Sun Jul 11 10:08:26 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e38b7e894808ec2a0c976ab01e44364f167508d3
      https://github.com/llvm/llvm-project/commit/e38b7e894808ec2a0c976ab01e44364f167508d3
  Author: Craig Topper <craig.topper at intel.com>
  Date:   2021-07-11 (Sun, 11 Jul 2021)

  Changed paths:
    M llvm/lib/Transforms/Scalar/DivRemPairs.cpp
    M llvm/test/Transforms/DivRemPairs/X86/div-expanded-rem-pair.ll

  Log Message:
  -----------
  [DivRemPairs] Add an initial case for hoisting to a common predecessor.

This patch adds support for hoisting the division and maybe the
remainder for control flow graphs like this.

```
PredBB
  |  \
  |  Rem
  |  /
 Div
```

If we have DivRem we'll hoist both to PredBB. If not we'll just
hoist Div and expand Rem using the Div.

This improves our codegen for something like this

```
__uint128_t udivmodti4(__uint128_t dividend, __uint128_t divisor, __uint128_t *remainder) {
    if (remainder != 0)
        *remainder = dividend % divisor;
    return dividend / divisor;
}
```

Reviewed By: spatel, lebedev.ri

Differential Revision: https://reviews.llvm.org/D87555




More information about the All-commits mailing list