Handle simple diamond CFG hoisting in DivRemPairs.
authorOwen Anderson <resistor@mac.com>
Sat, 24 Dec 2022 04:22:36 +0000 (21:22 -0700)
committerOwen Anderson <resistor@mac.com>
Wed, 28 Dec 2022 18:24:18 +0000 (11:24 -0700)
commit88e85aa580062c0f2b5882eef71bed498a6af159
tree3766bb4f59b1bb19307d21eb4fdb91197d86c431
parent2184fcf17ee00a939b3bde98a28ef586c67d6b1a
Handle simple diamond CFG hoisting in DivRemPairs.

Previous we only handled triangle CFGs. This patch expands that
to support diamonds, where the div and rem appear in the then/else
sides of a condition. In that case, we can hoist the div into the
shared predecessor.

This could be generalized further to use nearest common ancestors,
but some of the conditions for hoisting would then require
post-dominator information.

Reviewed By: nikic, lebedev.ri

Differential Revision: https://reviews.llvm.org/D140647
llvm/lib/Transforms/Scalar/DivRemPairs.cpp
llvm/test/Transforms/DivRemPairs/MSP430/div-rem-pairs.ll [new file with mode: 0644]
llvm/test/Transforms/DivRemPairs/Mips/div-rem-pairs.ll
llvm/test/Transforms/DivRemPairs/PowerPC/div-rem-pairs.ll
llvm/test/Transforms/DivRemPairs/RISCV/div-rem-pairs.ll [new file with mode: 0644]
llvm/test/Transforms/DivRemPairs/X86/div-expanded-rem-pair.ll
llvm/test/Transforms/DivRemPairs/X86/div-rem-pairs.ll