[PATCH] D135970: [InstCombine] try to determine "exact" for sdiv

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 14 12:13:28 PDT 2022


nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LGTM



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:1351
 
     if (match(Op1, m_NegatedPower2())) {
       // X sdiv (-(1 << C)) -> -(X sdiv (1 << C)) ->
----------------
Side note, as you are working on division transforms. This has an obvious generalization to any `nonneg / neg` (https://alive2.llvm.org/ce/z/bYVnFG), and similar for `neg / nonneg` and `neg / neg`. It does require adding two negations in the general case, but I believe we consider that worthwhile to relax sdiv to udiv -- or at least we do the same transform based on range information in CVP.


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

https://reviews.llvm.org/D135970



More information about the llvm-commits mailing list