[PATCH] D50222: [CodeGen] [SelectionDAG] More efficient code for X % C == 0 (UREM case)

Dmytro Shynkevych via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 6 19:07:33 PST 2018


hermord added a comment.

@RKSimon I am sorry for the long radio silence. It is entirely my fault.

Regarding `test1`, the problem seems to be that once this fold is applied, producing something of the form `(setule (mul t, -85), 85)`, it is difficult to deduce that this is the same as `(seteq t, 0)` in this case. In what was produced before, `(seteq (sub t, (mul ...)), 0)`, a series of optimizations could figure out that the `mul` node is always zero.

This can be worked around in InstCombine without any additional `KnownBits` computations beyond what already happens. I'd looked into implementing a fix there before (mentioned in dicussion with @lebedev.ri) and could replicate it, but this will require running `opt` on `jump_sign.ll` to restore previous behavior.

I do not have commit rights, so I cannot enact the suggestion to commit the tests as NFC, but I can implement the above (or any other) approach for `test1` now, if required, to finalize the patch. I feel like this is very close to completion, but if this is not acceptable, please feel free to commandeer the patch.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D50222





More information about the llvm-commits mailing list