[PATCH] D140647: Handle simple diamond CFG hoisting in DivRemPairs.

Sergei Barannikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 24 12:51:24 PST 2022


barannikov88 added a comment.

In D140647#4016094 <https://reviews.llvm.org/D140647#4016094>, @lebedev.ri wrote:

> May i suggest that reviewers first familiarize themselves
> with the code they are reviewing, in particular with the
> preconditions on the transformations,
> in particular with the `hasDivRemOp()` TTI hook?
> Hint: https://godbolt.org/z/K3dcxqEhE

The preconditions say:

  // If the target supports div+rem and the instructions are in the same block
  // already, there's nothing to do. The backend should handle this. If the
  // target does not support div+rem, then we will decompose the rem.
  if (HasDivRemOp && RemInst->getParent() == DivInst->getParent())
    continue;

So your example is irrelevant.

The relevant example is: https://godbolt.org/z/roGW5G54f
As you can see, in the case 'before' there are 3 instructions on each path.
In the case 'after' (which corresponds to the suggested transformation), the 'div' path contains 4 instructions and the 'rem' path contains 6 instructions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140647/new/

https://reviews.llvm.org/D140647



More information about the llvm-commits mailing list