[PATCH] D135010: [GlobalISel] Combine `(x + y) - y -> x` and friends

Jessica Paquette via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 30 21:55:12 PDT 2022


paquette created this revision.
paquette added reviewers: aemerson, arsenm, jroelofs.
Herald added subscribers: hiraditya, kristof.beyls, rovka.
Herald added a project: All.
paquette requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

This adds a combine that handles

  (x + y) - y -> x
  (x + y) - x -> y
  x - (y + x) -> 0 - y
  x - (x + z) -> 0 - z

On AArch64, we get added benefit for `0 - y` because it can be selected to a `neg` instruction.


https://reviews.llvm.org/D135010

Files:
  llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
  llvm/include/llvm/Target/GlobalISel/Combine.td
  llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
  llvm/test/CodeGen/AArch64/GlobalISel/combine-add-of-sub.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135010.464469.patch
Type: text/x-patch
Size: 12866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221001/08d7c225/attachment.bin>


More information about the llvm-commits mailing list