[InstCombine] distribute div over add with matching mul-by-constant
authorSanjay Patel <spatel@rotateright.com>
Mon, 20 Feb 2023 18:42:04 +0000 (13:42 -0500)
committerSanjay Patel <spatel@rotateright.com>
Mon, 20 Feb 2023 18:45:06 +0000 (13:45 -0500)
commit4966d8ebe1bbe5bd6a4d28b36efdbe6dd1659b3f
treefd2287d2ab5b0445b5d7fe91189cd6d47f57cb2e
parentf49d19d50238feabee5364d55db6c40f608530bd
[InstCombine] distribute div over add with matching mul-by-constant

((X * C2) + C1) / C2 --> X + C1/C2
https://alive2.llvm.org/ce/z/P66io8
https://alive2.llvm.org/ce/z/vghegw

This could be made more general -- the multiplier could be a
multiple of the divisor -- but this is the pattern from
issue #60754.
llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
llvm/test/Transforms/InstCombine/div.ll