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

Owen Anderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 24 14:35:14 PST 2022


resistor added a comment.

In D140647#4016069 <https://reviews.llvm.org/D140647#4016069>, @nikic wrote:

> Hm, could you provide some more information on what the motivation for this transform is? If we don't have a domination relationship, then we won't be able to reuse a result we have to compute anyway, so is the intention here a code size improvement for the case where a divrem op exists, because we now only need to materialize the instruction once? In that case though, does this transform make sense if we are going to use expanded form, as in the PowerPC example? We are replacing a div/rem on disjoint code paths with a common div plus mul+sub on one code path, which seems strictly worse?

Note that there is actually a domination requirement, just not tested via dominator tree. See this example on x86 that shows where this is profitable for code size: https://godbolt.org/z/xo7P1MnGr


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