[PATCH] D129606: [DAGCombine] fold (urem x, (lshr pow2, y)) -> (and x, (add (lshr pow2, y), -1))

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 12 17:16:05 PDT 2022


reames created this revision.
reames added reviewers: craig.topper, spatel.
Herald added subscribers: jsji, StephenFan, ecnelises, pengfei, bollu, hiraditya, mcrosier.
Herald added a project: All.
reames requested review of this revision.
Herald added a project: LLVM.

We have the same fold in InstCombine - though implemented via OrZero flag on isKnownToBePowerOfTwo.  The reasoning here is that either a) the result of the lshr is a power-of-two, or b) we have a div-by-zero triggering UB which we can ignore.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129606

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/test/CodeGen/X86/combine-urem.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129606.444114.patch
Type: text/x-patch
Size: 12639 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220713/13e282eb/attachment.bin>


More information about the llvm-commits mailing list