[PATCH] D138814: [InstCombine] Combine a/lshr of add -> uadd.with.overflow

Pierre van Houtryve via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 28 06:57:27 PST 2022


Pierre-vh created this revision.
Pierre-vh added reviewers: arsenm, lebedev.ri, spatel, craig.topper, foad.
Herald added subscribers: StephenFan, hiraditya, Anastasia.
Herald added a project: All.
Pierre-vh requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

Tries to perform

  (Xshr (add (zext a, i2^n), (zext b, i2^n)), 2^(n-1))
    -> (llvm.uadd.with.overflow a, b).overflow
  where
    - Xshr can be ashr or lshr
    - a and b has type i2^(n-1).

This seems to be a pattern that just comes from OpenCL front-ends, so adding DAG/GISel combines doesn't seem to be worth the complexity.

Original patch D107552 <https://reviews.llvm.org/D107552> by @abinavpp
Resolves issue raised on ROCm repo: https://github.com/RadeonOpenCompute/ROCm/issues/488


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138814

Files:
  llvm/lib/Transforms/InstCombine/InstCombineInternal.h
  llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
  llvm/test/Transforms/InstCombine/shift-add.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138814.478229.patch
Type: text/x-patch
Size: 8553 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221128/ad0604fb/attachment.bin>


More information about the llvm-commits mailing list