#
dc185ee2 |
| 12-Aug-2018 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] fix/enhance fadd/fsub factorization (X * Z) + (Y * Z) --> (X + Y) * Z (X * Z) - (Y * Z) --> (X - Y) * Z (X / Z) + (Y / Z) --> (X + Y) / Z (X / Z) - (Y / Z) --> (X - Y) / Z
The
[InstCombine] fix/enhance fadd/fsub factorization (X * Z) + (Y * Z) --> (X + Y) * Z (X * Z) - (Y * Z) --> (X - Y) * Z (X / Z) + (Y / Z) --> (X + Y) / Z (X / Z) - (Y / Z) --> (X - Y) / Z
The existing code that implemented these folds failed to optimize vectors, and it transformed code with multiple uses when it should not have.
llvm-svn: 339519
show more ...
|
#
55accd7d |
| 09-Aug-2018 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] allow fsub+fmul FMF folds for vectors
llvm-svn: 339368
|
#
ebec4204 |
| 09-Aug-2018 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] reduce code duplication; NFC
llvm-svn: 339349
|
#
fe839695 |
| 08-Aug-2018 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] fold fadd+fsub with common operand
This is a sibling to the simplify from: https://reviews.llvm.org/rL339174
llvm-svn: 339267
|
#
2054dd79 |
| 08-Aug-2018 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] fold fsub+fsub with common operand
This is a sibling to the simplify from: rL339171
llvm-svn: 339266
|
#
a194b2d2 |
| 08-Aug-2018 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] fold fneg into constant operand of fmul/fdiv
This accounts for the missing IR fold noted in D50195. We don't need any fast-math to enable the negation transform. FP negation can alway
[InstCombine] fold fneg into constant operand of fmul/fdiv
This accounts for the missing IR fold noted in D50195. We don't need any fast-math to enable the negation transform. FP negation can always be folded into an fmul/fdiv constant to eliminate the fneg.
I've limited this to one-use to ensure that we are eliminating an instruction rather than replacing fneg by a potentially expensive fdiv or fmul.
Differential Revision: https://reviews.llvm.org/D50417
llvm-svn: 339248
show more ...
|
Revision tags: llvmorg-7.0.0-rc1 |
|
#
f78650a8 |
| 30-Jul-2018 |
Fangrui Song <maskray@google.com> |
Remove trailing space
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h}
llvm-svn: 338293
|
#
577c7057 |
| 29-Jul-2018 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] try to fold 'add+sub' to 'not+add'
These are reassociated versions of the same pattern and similar transforms as in rL338200 and rL338118.
The motivation is identical to those commits
[InstCombine] try to fold 'add+sub' to 'not+add'
These are reassociated versions of the same pattern and similar transforms as in rL338200 and rL338118.
The motivation is identical to those commits: Patterns with add/sub combos can be improved using 'not' ops. This is better for analysis and may lead to follow-on transforms because 'xor' and 'add' are commutative/associative. It can also help codegen.
llvm-svn: 338221
show more ...
|
#
818b253d |
| 28-Jul-2018 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] try to fold 'sub' to 'not'
https://rise4fun.com/Alive/jDd
Patterns with add/sub combos can be improved using 'not' ops. This is better for analysis and may lead to follow-on transform
[InstCombine] try to fold 'sub' to 'not'
https://rise4fun.com/Alive/jDd
Patterns with add/sub combos can be improved using 'not' ops. This is better for analysis and may lead to follow-on transforms because 'xor' and 'add' are commutative/associative. It can also help codegen.
llvm-svn: 338200
show more ...
|
#
70043b7e |
| 13-Jul-2018 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] return when SimplifyAssociativeOrCommutative makes a change
This bug was created by rL335258 because we used to always call instsimplify after trying the associative folds. After that
[InstCombine] return when SimplifyAssociativeOrCommutative makes a change
This bug was created by rL335258 because we used to always call instsimplify after trying the associative folds. After that change it became possible for subsequent folds to encounter unsimplified code (and potentially assert because of it).
Instead of carrying changed state through instcombine, we can just return immediately. This allows instsimplify to run, so we can continue assuming that easy folds have already occurred.
llvm-svn: 336965
show more ...
|
#
da2e2caa |
| 26-Jun-2018 |
Gil Rapaport <gil.rapaport@intel.com> |
[InstCombine] (A + 1) + (B ^ -1) --> A - B
Turn canonicalized subtraction back into (-1 - B) and combine it with (A + 1) into (A - B). This is similar to the folding already done for (B ^ -1) + Cons
[InstCombine] (A + 1) + (B ^ -1) --> A - B
Turn canonicalized subtraction back into (-1 - B) and combine it with (A + 1) into (A - B). This is similar to the folding already done for (B ^ -1) + Const into (-1 + Const) - B.
Differential Revision: https://reviews.llvm.org/D48535
llvm-svn: 335579
show more ...
|
#
7b0fc75f |
| 21-Jun-2018 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] simplify binops before trying other folds
This is outwardly NFC from what I can tell, but it should be more efficient to simplify first (despite the name, SimplifyAssociativeOrCommuta
[InstCombine] simplify binops before trying other folds
This is outwardly NFC from what I can tell, but it should be more efficient to simplify first (despite the name, SimplifyAssociativeOrCommutative does not actually simplify as InstSimplify does - it creates/morphs instructions).
This should make it easier to refactor duplicated code that runs for all binops.
llvm-svn: 335258
show more ...
|
Revision tags: llvmorg-6.0.1, llvmorg-6.0.1-rc3 |
|
#
3cd1aa88 |
| 06-Jun-2018 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] fold another shifty abs pattern to cmp+sel (PR36036)
The bug report: https://bugs.llvm.org/show_bug.cgi?id=36036
...requests a DAG change for this, but an IR canonicalization probably
[InstCombine] fold another shifty abs pattern to cmp+sel (PR36036)
The bug report: https://bugs.llvm.org/show_bug.cgi?id=36036
...requests a DAG change for this, but an IR canonicalization probably handles most cases. If we still want to match this pattern in the backend, there's a proposal for that too: D47831
Alive proofs including nsw/nuw cases that were first noted in: D46988
https://rise4fun.com/Alive/Kmp
This patch is largely copied from the existing code that was initially added with: D40984 ...but I didn't see much gain from trying to share code.
llvm-svn: 334137
show more ...
|
#
cbf84463 |
| 06-Jun-2018 |
Roman Lebedev <lebedev.ri@gmail.com> |
[InstCombine] PR37603: low bit mask canonicalization
Summary: This is [[ https://bugs.llvm.org/show_bug.cgi?id=37603 | PR37603 ]].
https://godbolt.org/g/VCMNpS https://rise4fun.com/Alive/idM
When
[InstCombine] PR37603: low bit mask canonicalization
Summary: This is [[ https://bugs.llvm.org/show_bug.cgi?id=37603 | PR37603 ]].
https://godbolt.org/g/VCMNpS https://rise4fun.com/Alive/idM
When doing bit manipulations, it is quite common to calculate some bit mask, and apply it to some value via `and`.
The typical C code looks like: ``` int mask_signed_add(int nbits) { return (1 << nbits) - 1; } ``` which is translated into (with `-O3`) ``` define dso_local i32 @mask_signed_add(int)(i32) local_unnamed_addr #0 { %2 = shl i32 1, %0 %3 = add nsw i32 %2, -1 ret i32 %3 } ```
But there is a second, less readable variant: ``` int mask_signed_xor(int nbits) { return ~(-(1 << nbits)); } ``` which is translated into (with `-O3`) ``` define dso_local i32 @mask_signed_xor(int)(i32) local_unnamed_addr #0 { %2 = shl i32 -1, %0 %3 = xor i32 %2, -1 ret i32 %3 } ```
Since we created such a mask, it is quite likely that we will use it in `and` next. And then we may get rid of `not` op by folding into `andn`.
But now that i have actually looked: https://godbolt.org/g/VTUDmU _some_ backend changes will be needed too. We clearly loose `bzhi` recognition.
Reviewers: spatel, craig.topper, RKSimon
Reviewed By: spatel
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D47428
llvm-svn: 334127
show more ...
|
Revision tags: llvmorg-6.0.1-rc2 |
|
#
3bd957b7 |
| 03-Jun-2018 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] improve sub with bool folds
There's a patchwork of existing transforms trying to handle these cases, but as seen in the changed test, we weren't catching them all.
llvm-svn: 333845
|
#
bbc6d606 |
| 02-Jun-2018 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] call simplify before trying vector folds
As noted in the review thread for rL333782, we could have made a bug harder to hit if we were simplifying instructions before trying other fold
[InstCombine] call simplify before trying vector folds
As noted in the review thread for rL333782, we could have made a bug harder to hit if we were simplifying instructions before trying other folds.
The shuffle transform in question isn't ever a simplification; it's just a canonicalization. So I've renamed that to make that clearer.
This is NFCI at this point, but I've regenerated the test file to show the cosmetic value naming difference of using instcombine's RAUW vs. the builder.
Possible follow-ups: 1. Move reassociation folds after simplifies too. 2. Refactor common code; we shouldn't have so much repetition.
llvm-svn: 333820
show more ...
|
#
ceb595b0 |
| 30-May-2018 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] don't negate constant expression with fsub (PR37605)
X + (-C) would be transformed back into X - C, so infinite loop: https://bugs.llvm.org/show_bug.cgi?id=37605
llvm-svn: 333610
|
#
3b768e86 |
| 23-May-2018 |
Craig Topper <craig.topper@intel.com> |
[InstCombine] Negate ABS/NABS patterns by swapping the select operands to remove the negation
Differential Revision: https://reviews.llvm.org/D47236
llvm-svn: 333101
|
#
fbb83dee |
| 10-May-2018 |
Omer Paparo Bivas <omer.paparo.bivas@intel.com> |
[InstCombine] Moving overflow computation logic from InstCombine to ValueTracking; NFC
Differential Revision: https://reviews.llvm.org/D46704
Change-Id: Ifabcbe431a2169743b3cc310f2a34fd706f13f02 ll
[InstCombine] Moving overflow computation logic from InstCombine to ValueTracking; NFC
Differential Revision: https://reviews.llvm.org/D46704
Change-Id: Ifabcbe431a2169743b3cc310f2a34fd706f13f02 llvm-svn: 332026
show more ...
|
#
5f8f34e4 |
| 01-May-2018 |
Adrian Prantl <aprantl@apple.com> |
Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they ar
Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
Differential Revision: https://reviews.llvm.org/D46290
llvm-svn: 331272
show more ...
|
#
6959b8e7 |
| 27-Apr-2018 |
Roman Lebedev <lebedev.ri@gmail.com> |
[PatternMatch] Stabilize the matching order of commutative matchers
Summary: Currently, we 1. match `LHS` matcher to the `first` operand of binary operator, 2. and then match `RHS` matcher to the `s
[PatternMatch] Stabilize the matching order of commutative matchers
Summary: Currently, we 1. match `LHS` matcher to the `first` operand of binary operator, 2. and then match `RHS` matcher to the `second` operand of binary operator. If that does not match, we swap the `LHS` and `RHS` matchers: 1. match `RHS` matcher to the `first` operand of binary operator, 2. and then match `LHS` matcher to the `second` operand of binary operator.
This works ok. But it complicates writing of commutative matchers, where one would like to match (`m_Value()`) the value on one side, and use (`m_Specific()`) it on the other side.
This is additionally complicated by the fact that `m_Specific()` stores the `Value *`, not `Value **`, so it won't work at all out of the box.
The last problem is trivially solved by adding a new `m_c_Specific()` that stores the `Value **`, not `Value *`. I'm choosing to add a new matcher, not change the existing one because i guess all the current users are ok with existing behavior, and this additional pointer indirection may have performance drawbacks. Also, i'm storing pointer, not reference, because for some mysterious-to-me reason it did not work with the reference.
The first one appears trivial, too. Currently, we 1. match `LHS` matcher to the `first` operand of binary operator, 2. and then match `RHS` matcher to the `second` operand of binary operator. If that does not match, we swap the ~~`LHS` and `RHS` matchers~~ **operands**: 1. match ~~`RHS`~~ **`LHS`** matcher to the ~~`first`~~ **`second`** operand of binary operator, 2. and then match ~~`LHS`~~ **`RHS`** matcher to the ~~`second`~ **`first`** operand of binary operator.
Surprisingly, `$ ninja check-llvm` still passes with this. But i expect the bots will disagree..
The motivational unittest is included. I'd like to use this in D45664.
Reviewers: spatel, craig.topper, arsenm, RKSimon
Reviewed By: craig.topper
Subscribers: xbolva00, wdng, llvm-commits
Differential Revision: https://reviews.llvm.org/D45828
llvm-svn: 331085
show more ...
|
#
6f1937b1 |
| 26-Apr-2018 |
Sanjoy Das <sanjoy@playingwithpointers.com> |
[InstCombine] Simplify Add with remainder expressions as operands.
Summary: Simplify integer add expression X % C0 + (( X / C0 ) % C1) * C0 to X % (C0 * C1). This is a common pattern seen in code g
[InstCombine] Simplify Add with remainder expressions as operands.
Summary: Simplify integer add expression X % C0 + (( X / C0 ) % C1) * C0 to X % (C0 * C1). This is a common pattern seen in code generated by the XLA GPU backend.
Add test cases for this new optimization.
Patch by Bixia Zheng!
Reviewers: sanjoy
Reviewed By: sanjoy
Subscribers: efriedma, craig.topper, lebedev.ri, llvm-commits, jlebar
Differential Revision: https://reviews.llvm.org/D45976
llvm-svn: 330992
show more ...
|
Revision tags: llvmorg-6.0.1-rc1 |
|
#
1170daa2 |
| 16-Apr-2018 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] simplify fneg+fadd folds; NFC
Two cleanups: 1. As noted in D45453, we had tests that don't need FMF that were misplaced in the 'fast-math.ll' test file. 2. This removes the final uses
[InstCombine] simplify fneg+fadd folds; NFC
Two cleanups: 1. As noted in D45453, we had tests that don't need FMF that were misplaced in the 'fast-math.ll' test file. 2. This removes the final uses of dyn_castFNegVal, so that can be deleted. We use 'match' now.
llvm-svn: 330126
show more ...
|
#
8b2f27ce |
| 14-Apr-2018 |
Warren Ristow <warren.ristow@sony.com> |
[InstCombine] Enable Add/Sub simplifications with only 'reassoc' FMF
These simplifications were previously enabled only with isFast(), but that is more restrictive than required. Since r317488, FMF
[InstCombine] Enable Add/Sub simplifications with only 'reassoc' FMF
These simplifications were previously enabled only with isFast(), but that is more restrictive than required. Since r317488, FMF has 'reassoc' to control these cases at a finer level.
llvm-svn: 330089
show more ...
|
#
ff98682c |
| 11-Apr-2018 |
Sanjay Patel <spatel@rotateright.com> |
[InstCombine] limit X - (cast(-Y) --> X + cast(Y) with hasOneUse()
llvm-svn: 329821
|