History log of /llvm-project/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp (Results 226 – 250 of 463)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-10-init, llvmorg-8.0.1, llvmorg-8.0.1-rc4
# 9f0c8390 03-Jul-2019 Roman Lebedev <lebedev.ri@gmail.com>

[InstCombine] Y - ~X --> X + Y + 1 fold (PR42457)

Summary:
I *think* we'd want this new variant, because we obviously
have better handling for `add` as compared to `sub`/`not`.

https://rise4fun.com

[InstCombine] Y - ~X --> X + Y + 1 fold (PR42457)

Summary:
I *think* we'd want this new variant, because we obviously
have better handling for `add` as compared to `sub`/`not`.

https://rise4fun.com/Alive/WMn

Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=42457 | PR42457 ]]

Reviewers: spatel, nikic, huihuiz, efriedma

Reviewed By: spatel

Subscribers: RKSimon, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D63992

llvm-svn: 365011

show more ...


# 04d3d3bb 01-Jul-2019 Roman Lebedev <lebedev.ri@gmail.com>

[InstCombine] (Y + ~X) + 1 --> Y - X fold (PR42459)

Summary:
To be noted, this pattern is not unhandled by instcombine per-se,
it is somehow does end up being folded when one runs opt -O3,
but not

[InstCombine] (Y + ~X) + 1 --> Y - X fold (PR42459)

Summary:
To be noted, this pattern is not unhandled by instcombine per-se,
it is somehow does end up being folded when one runs opt -O3,
but not if it's just -instcombine. Regardless, that fold is
indirect, depends on some other folds, and is thus blind
when there are extra uses.

This does address the regression being exposed in D63992.

https://godbolt.org/z/7DGltU
https://rise4fun.com/Alive/EPO0

Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=42459 | PR42459 ]]

Reviewers: spatel, nikic, huihuiz

Reviewed By: spatel

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D63993

llvm-svn: 364792

show more ...


Revision tags: llvmorg-8.0.1-rc3
# 08200d6d 11-Jun-2019 Cameron McInally <cameron.mcinally@nyu.edu>

[InstCombine] Handle -(X-Y) --> (Y-X) for unary fneg when NSZ

Differential Revision: https://reviews.llvm.org/D62612

llvm-svn: 363082


Revision tags: llvmorg-8.0.1-rc2
# 39390d83 31-May-2019 Roman Lebedev <lebedev.ri@gmail.com>

[InstCombine] 'C-(C2-X) --> X+(C-C2)' constant-fold

It looks this fold was already partially happening, indirectly
via some other folds, but with one-use limitation.
No other fold here has that rest

[InstCombine] 'C-(C2-X) --> X+(C-C2)' constant-fold

It looks this fold was already partially happening, indirectly
via some other folds, but with one-use limitation.
No other fold here has that restriction.

https://rise4fun.com/Alive/ftR

llvm-svn: 362217

show more ...


# 886c4ef3 31-May-2019 Roman Lebedev <lebedev.ri@gmail.com>

[InstCombine] 'add (sub C1, X), C2 --> sub (add C1, C2), X' constant-fold

https://rise4fun.com/Alive/qJQ

llvm-svn: 362216


# 8bec58d5 20-May-2019 Cameron McInally <cameron.mcinally@nyu.edu>

[NFC][InstCombine] Add FIXME for one-use check on constant negation transforms.

llvm-svn: 361197


# 2557ca29 20-May-2019 Cameron McInally <cameron.mcinally@nyu.edu>

[InstCombine] Add visitFNeg(...) visitor for unary Fneg

Also, break out a helper function, namely foldFNegIntoConstant(...), which performs transforms common between visitFNeg(...) and visitFSub(...

[InstCombine] Add visitFNeg(...) visitor for unary Fneg

Also, break out a helper function, namely foldFNegIntoConstant(...), which performs transforms common between visitFNeg(...) and visitFSub(...).

Differential Revision: https://reviews.llvm.org/D61693

llvm-svn: 361188

show more ...


Revision tags: llvmorg-8.0.1-rc1
# e75412ab 10-May-2019 Cameron McInally <cameron.mcinally@nyu.edu>

Add InstCombine::visitFNeg(...)

Differential Revision: https://reviews.llvm.org/D61784

llvm-svn: 360461


# 8681ef8f 07-May-2019 Robert Lougher <rob.lougher@gmail.com>

[InstCombine] Add new combine to add folding

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

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

This transform enables the follo

[InstCombine] Add new combine to add folding

(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.

Patch by Chris Dawson.

Differential Revision: https://reviews.llvm.org/D61517

llvm-svn: 360185

show more ...


# f62dcea7 09-Apr-2019 Sanjay Patel <spatel@rotateright.com>

[InstCombine] prevent possible miscompile with negate+sdiv of vector op

// 0 - (X sdiv C) -> (X sdiv -C) provided the negation doesn't overflow.

This fold has been around for many years and nobod

[InstCombine] prevent possible miscompile with negate+sdiv of vector op

// 0 - (X sdiv C) -> (X sdiv -C) provided the negation doesn't overflow.

This fold has been around for many years and nobody noticed the potential
vector miscompile from overflow until recently...
So it seems unlikely that there's much demand for a vector sdiv optimization
on arbitrary vector constants, so just limit the matching to splat constants
to avoid the possible bug.

Differential Revision: https://reviews.llvm.org/D60426

llvm-svn: 358005

show more ...


# 923c7c9d 08-Apr-2019 Chen Zheng <czhengsz@cn.ibm.com>

[InstCombine] sdiv exact flag fixup.

Differential Revision: https://reviews.llvm.org/D60396

llvm-svn: 357904


# 81e8d76f 26-Mar-2019 Sanjay Patel <spatel@rotateright.com>

[InstCombine] form uaddsat from add+umin (PR14613)

This is the last step towards solving the examples shown in:
https://bugs.llvm.org/show_bug.cgi?id=14613

With this change, x86 should end up with

[InstCombine] form uaddsat from add+umin (PR14613)

This is the last step towards solving the examples shown in:
https://bugs.llvm.org/show_bug.cgi?id=14613

With this change, x86 should end up with psubus instructions
when those are available.

All known codegen issues with expanding the saturating intrinsics
were resolved with:
D59006 / rL356855

We also have some early evidence in D58872 that using the intrinsics
will lead to better perf. If some target regresses from this, custom
lowering of the intrinsics (as in the above for x86) may be needed.

llvm-svn: 357012

show more ...


Revision tags: llvmorg-8.0.0, llvmorg-8.0.0-rc5, llvmorg-8.0.0-rc4
# 4a47f5f5 28-Feb-2019 Sanjay Patel <spatel@rotateright.com>

[InstCombine] fold adds of constants separated by sext/zext

This is part of a transform that may be done in the backend:
D13757
...but it should always be beneficial to fold this sooner in IR
for al

[InstCombine] fold adds of constants separated by sext/zext

This is part of a transform that may be done in the backend:
D13757
...but it should always be beneficial to fold this sooner in IR
for all targets.

https://rise4fun.com/Alive/vaiW

Name: sext add nsw
%add = add nsw i8 %i, C0
%ext = sext i8 %add to i32
%r = add i32 %ext, C1
=>
%s = sext i8 %i to i32
%r = add i32 %s, sext(C0)+C1

Name: zext add nuw
%add = add nuw i8 %i, C0
%ext = zext i8 %add to i16
%r = add i16 %ext, C1
=>
%s = zext i8 %i to i16
%r = add i16 %s, zext(C0)+C1

llvm-svn: 355118

show more ...


Revision tags: llvmorg-8.0.0-rc3
# 9907d3c8 24-Feb-2019 Sanjay Patel <spatel@rotateright.com>

[InstCombine] canonicalize add/sub with bool

add A, sext(B) --> sub A, zext(B)

We have to choose 1 of these forms, so I'm opting for the
zext because that's easier for value tracking.

The backend

[InstCombine] canonicalize add/sub with bool

add A, sext(B) --> sub A, zext(B)

We have to choose 1 of these forms, so I'm opting for the
zext because that's easier for value tracking.

The backend should be prepared for this change after:
D57401
rL353433

This is also a preliminary step towards reducing the amount
of bit hackery that we do in IR to optimize icmp/select.
That should be waiting to happen at a later optimization stage.

The seeming regression in the fuzzer test was discussed in:
D58359

We were only managing that fold in instcombine by luck, and
other passes should be able to deal with that better anyway.

llvm-svn: 354748

show more ...


Revision tags: llvmorg-7.1.0, llvmorg-7.1.0-rc1, llvmorg-8.0.0-rc2, llvmorg-8.0.0-rc1
# 2946cd70 19-Jan-2019 Chandler Carruth <chandlerc@gmail.com>

Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the ne

Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636

show more ...


# 4094f34f 15-Jan-2019 Florian Hahn <flo@fhahn.com>

[InstCombine] Don't undo 0 - (X * Y) canonicalization when combining subs.

Otherwise instcombine gets stuck in a cycle. The canonicalization was
added in D55961.

This patch fixes https://bugs.chrom

[InstCombine] Don't undo 0 - (X * Y) canonicalization when combining subs.

Otherwise instcombine gets stuck in a cycle. The canonicalization was
added in D55961.

This patch fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=12400

llvm-svn: 351187

show more ...


Revision tags: llvmorg-7.0.1, llvmorg-7.0.1-rc3, llvmorg-7.0.1-rc2, llvmorg-7.0.1-rc1
# 79dceb29 03-Oct-2018 Sanjay Patel <spatel@rotateright.com>

[InstCombine] name change: foldShuffledBinop -> foldVectorBinop; NFC

This function will deal with more than shuffles with D50992, and I
have another potential per-element fold that could live here.

[InstCombine] name change: foldShuffledBinop -> foldVectorBinop; NFC

This function will deal with more than shuffles with D50992, and I
have another potential per-element fold that could live here.

llvm-svn: 343692

show more ...


# 1e44c3b6 02-Oct-2018 David Green <david.green@arm.com>

[InstCombine] Fold ~A - Min/Max(~A, O) -> Max/Min(A, ~O) - A

This is an attempt to get out of a local-minimum that instcombine currently
gets stuck in. We essentially combine two optimisations at on

[InstCombine] Fold ~A - Min/Max(~A, O) -> Max/Min(A, ~O) - A

This is an attempt to get out of a local-minimum that instcombine currently
gets stuck in. We essentially combine two optimisations at once, ~a - ~b = b-a
and min(~a, ~b) = ~max(a, b), only doing the transform if the result is at
least neutral. This involves using IsFreeToInvert, which has been expanded a
little to include selects that can be easily inverted.

This is trying to fix PR35875, using the ideas from Sanjay. It is a large
improvement to one of our rgb to cmy kernels.

Differential Revision: https://reviews.llvm.org/D52177

llvm-svn: 343569

show more ...


# 2da73816 15-Sep-2018 Craig Topper <craig.topper@intel.com>

[InstCombine] Support (sub (sext x), (sext y)) --> (sext (sub x, y)) and (sub (zext x), (zext y)) --> (zext (sub x, y))

Summary:
If the sub doesn't overflow in the original type we can move it above

[InstCombine] Support (sub (sext x), (sext y)) --> (sext (sub x, y)) and (sub (zext x), (zext y)) --> (zext (sub x, y))

Summary:
If the sub doesn't overflow in the original type we can move it above the sext/zext.

This is similar to what we do for add. The overflow checking for sub is currently weaker than add, so the test cases are constructed for what is supported.

Reviewers: spatel

Reviewed By: spatel

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D52075

llvm-svn: 342335

show more ...


# 90a36346 14-Sep-2018 Sanjay Patel <spatel@rotateright.com>

[InstCombine] refactor mul narrowing folds; NFCI

Similar to rL342278:
The test diffs are all cosmetic due to the change in
value naming, but I'm including that to show that the
new code does perform

[InstCombine] refactor mul narrowing folds; NFCI

Similar to rL342278:
The test diffs are all cosmetic due to the change in
value naming, but I'm including that to show that the
new code does perform these folds rather than something
else in instcombine.

D52075 should be able to use this code too rather than
duplicating all of the logic.

llvm-svn: 342292

show more ...


# 46945b9e 14-Sep-2018 Sanjay Patel <spatel@rotateright.com>

[InstCombine] add/use overflowing math helper functions; NFC

The mul case can already be refactored to use this similar to
rL342278.
The sub case is proposed in D52075.

llvm-svn: 342289


# 2426eb46 14-Sep-2018 Sanjay Patel <spatel@rotateright.com>

[InstCombine] refactor add narrowing folds; NFCI

The test diffs are all cosmetic due to the change in
value naming, but I'm including that to show that the
new code does perform these folds rather t

[InstCombine] refactor add narrowing folds; NFCI

The test diffs are all cosmetic due to the change in
value naming, but I'm including that to show that the
new code does perform these folds rather than something
else in instcombine.

llvm-svn: 342278

show more ...


Revision tags: llvmorg-7.0.0
# 12fd6bd4 11-Sep-2018 Craig Topper <craig.topper@intel.com>

[InstCombine] Use dyn_cast instead of match(m_Constant). NFC

llvm-svn: 341962


Revision tags: llvmorg-7.0.0-rc3
# a6cd4b9b 28-Aug-2018 Craig Topper <craig.topper@intel.com>

[InstCombine] Extend (add (sext x), cst) --> (sext (add x, cst')) and (add (zext x), cst) --> (zext (add x, cst')) to work for vectors

Differential Revision: https://reviews.llvm.org/D51236

llvm-sv

[InstCombine] Extend (add (sext x), cst) --> (sext (add x, cst')) and (add (zext x), cst) --> (zext (add x, cst')) to work for vectors

Differential Revision: https://reviews.llvm.org/D51236

llvm-svn: 340796

show more ...


Revision tags: llvmorg-7.0.0-rc2
# f874607f 17-Aug-2018 Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net>

[InstCombine] Remove unused method FAddCombine::createFDiv(). NFC

This commit fixes a (gcc 7.3.0) [-Wunused-function] warning caused by the
presence of unused method FaddCombine::createFDiv().
The l

[InstCombine] Remove unused method FAddCombine::createFDiv(). NFC

This commit fixes a (gcc 7.3.0) [-Wunused-function] warning caused by the
presence of unused method FaddCombine::createFDiv().
The last use of that method was removed at r339519.

llvm-svn: 340014

show more ...


12345678910>>...19