[PATCH] D123399: [InstCombine] Fold sub(add(x,y),min/max(x,y)) -> max/min(x,y) (PR38280)

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 8 09:10:13 PDT 2022


RKSimon created this revision.
RKSimon added reviewers: nikic, lebedev.ri, spatel.
Herald added a subscriber: hiraditya.
Herald added a project: All.
RKSimon requested review of this revision.
Herald added a project: LLVM.

As discussed on Issue #37628, we can flip a min/max node if we're subtracting from the sum of the node's operands

My main query is whether we need any oneuse limits or not - the only case where we don't see any reduction in instructions is if both the add + min/max have other uses, where we then replace a sub with a max/min intrinsic, which is probably going too far - any thoughts?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123399

Files:
  llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
  llvm/test/Transforms/InstCombine/sub-minmax.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123399.421543.patch
Type: text/x-patch
Size: 5549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220408/ed639ea5/attachment.bin>


More information about the llvm-commits mailing list