[PATCH] D58877: [InstCombine] fold add(add(A, ~B), 1) -> sub(A, B)

Amaury SECHET via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 3 12:41:50 PST 2019


deadalnix added a comment.

In D58877#1416363 <https://reviews.llvm.org/D58877#1416363>, @RKSimon wrote:

> Test for ((A + 1) + ~B) and ((~B + 1) + A) cases?


The first is already handled explicitly. The second is handled via ((~B + 1) + A) -> ((0-B) + A) -> A - B . There are tests for both patterns already.



================
Comment at: lib/Transforms/InstCombine/InstCombineAddSub.cpp:1177
   if (match(&I, m_c_BinOp(m_Add(m_Value(A), m_One()), m_Not(m_Value(B)))))
     return BinaryOperator::CreateSub(A, B);
 
----------------
See here.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58877/new/

https://reviews.llvm.org/D58877





More information about the llvm-commits mailing list