[InstCombine] try harder to cancel out mul/div
authorSanjay Patel <spatel@rotateright.com>
Tue, 11 Oct 2022 13:28:09 +0000 (09:28 -0400)
committerSanjay Patel <spatel@rotateright.com>
Tue, 11 Oct 2022 13:51:51 +0000 (09:51 -0400)
commit7ec604a317c765552e28626dc85d610f8ca20dc0
tree97b427b8bf929caef85e84041c73094303b22010
parent5185c5db0e8966d38ee5c6934f2de1f2f32f6792
[InstCombine] try harder to cancel out mul/div

((Op1 * X) / Y) / Op1 --> X / Y
https://alive2.llvm.org/ce/z/JYxWjA

InstSimplify handles the more basic mul+div pattern with
shared operand, but we don't seem to have any reassociation
folds to handle cases where the common op is further away.

This is a generalization of 9cff4711ac72 and another
transform derived from issue #58137.
llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
llvm/test/Transforms/InstCombine/div.ll