[PATCH] D61517: [InstCombine] Add new combine to add folding.

Chris Dawson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 3 08:46:06 PDT 2019


cdawson created this revision.
cdawson added reviewers: spatel, majnemer, lebedev.ri.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

  (X | C1) + C2 --> (X | C1) ^ C1 iff (C1 == -C2)

I verified the correctness using Alive:
https://rise4fun.com/Alive/YNV

This transform enables the following transform that already exists in instcombine:

  (X | Y) ^ Y --> X & ~Y

As a result, the full expected transform is:

  (X | C1) + C2 --> X & ~C1 iff (C1 == -C2)

There already exists the transform in the sub case:

  (X | Y) - Y --> X & ~Y

however this does not trigger in the case where Y is constant due to an earlier transform:

  X - (-C) --> X + C

With this new add fold, both the add and sub constant cases are handled.

This is a spin off from: https://reviews.llvm.org/D61307


https://reviews.llvm.org/D61517

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61517.198023.patch
Type: text/x-patch
Size: 4050 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190503/8205a6ee/attachment.bin>


More information about the llvm-commits mailing list