Sanjay Patel
cbf458f9f0
[InstCombine] add tests to show missed canonicalization of min/max; NFC
...
Unfortunately, recognizing these in value tracking may cause us to hit
a hack in InstCombiner::visitICmpInst() more often:
http://lists.llvm.org/pipermail/llvm-dev/2017-January/109340.html
...but besides being the obviously Right Thing To Do, there's a clear
codegen win from identifying these patterns for several targets.
llvm-svn: 292655
2017-01-20 21:49:41 +00:00
Simon Pilgrim
228925067e
[InstCombine][X86] Add MULDQ/MULUDQ undef handling
...
llvm-svn: 292627
2017-01-20 18:20:30 +00:00
Simon Pilgrim
014fbda9bf
[InstCombine][SSE] Tests showing missed opportunities to handle muldq/muludq with undef arguments
...
Fixed a typo in existing test names at the same time
llvm-svn: 292619
2017-01-20 17:06:38 +00:00
Simon Pilgrim
81f5b7f9e4
[InstCombine][SSE] Tests showing missed opportunities to constant fold packss/packus
...
llvm-svn: 292609
2017-01-20 13:21:30 +00:00
Simon Pilgrim
78d53eb230
[InstCombine][SSE] Tests showing missed opportunities to handle packss/packus with undef arguments
...
llvm-svn: 292601
2017-01-20 11:28:07 +00:00
Simon Pilgrim
7f59f5cfb4
[InstCombine][SSE] Add DemandedElts support for PACKSS/PACKUS instructions
...
Simplify a packss/packus truncation based on the elements of the mask that are actually demanded.
Differential Revision: https://reviews.llvm.org/D28777
llvm-svn: 292591
2017-01-20 09:28:21 +00:00
Davide Italiano
97a0cbad8b
[InstCombine] Simplify gep (gep p, a), (b-a)
...
Patch by Andrea Canciani.
Differential Revision: https://reviews.llvm.org/D27413
llvm-svn: 292506
2017-01-19 18:51:56 +00:00
Sanjay Patel
70009a571f
[InstCombine] icmp Pred (shl nsw X, C1), C0 --> icmp Pred X, C0 >> C1
...
Try harder to fold icmp with shl nsw as discussed here:
http://lists.llvm.org/pipermail/llvm-dev/2017-January/108749.html
This is similar to the 'shl nuw' transforms that were added with D25913.
This may eventually help solve:
https://llvm.org/bugs/show_bug.cgi?id=30773
Differential Revision: https://reviews.llvm.org/D28406
llvm-svn: 292492
2017-01-19 16:12:10 +00:00
Sanjay Patel
8e5e48bb94
[InstCombine] add tests for shl nsw with icmp eq/ne; NFCI
...
These should be fixed with D28406.
llvm-svn: 292441
2017-01-18 21:31:21 +00:00
Simon Pilgrim
e534f0a508
[InstCombine][AVX2] Add DemandedElts support for VPERMD/VPERMPS shuffles
...
Simplify a vpermv shuffle mask based on the elements of the mask that are actually demanded.
llvm-svn: 292371
2017-01-18 14:47:49 +00:00
Simon Pilgrim
ecedefdc99
[InstCombine][AVX2] Tests showing missed opportunities to pass demanded elts through a vpermd/vpermps shuffle
...
llvm-svn: 292368
2017-01-18 14:23:06 +00:00
Sanjay Patel
06bcd26bab
[InstCombine] add tests to show missed shrinkage; NFC
...
A patch to partially solve this:
https://reviews.llvm.org/D28625
llvm-svn: 292296
2017-01-18 00:03:23 +00:00
Sanjay Patel
ea4bdd6b81
[InstCombine] add tests for shl nsw + icmp sle; NFC
...
We want to handle these cases similarly to icmp sgt, so add the tests for it.
See: https://reviews.llvm.org/D28406
llvm-svn: 292248
2017-01-17 20:15:26 +00:00
Sanjay Patel
d9256d18d9
[ValueTracking] recognize a 'not' of an assumed condition as false
...
Also, add the corresponding match to the AssumptionCache's 'Affected Values' list.
Differential Revision: https://reviews.llvm.org/D28485
llvm-svn: 292239
2017-01-17 18:15:49 +00:00
David Majnemer
5ce5bd5531
[InstCombine] Fold ((C1 OP zext(X)) & C2) -> zext((C1 OP X) & C2)
...
This further extends r292179 to support additional binary operators
beyond subtraction.
llvm-svn: 292238
2017-01-17 18:08:06 +00:00
Chad Rosier
831d15d618
[ValueTracking] Extend known bits to understand @llvm.bitreverse.
...
Differential Revision: https://reviews.llvm.org/D28780
llvm-svn: 292233
2017-01-17 17:23:51 +00:00
Simon Pilgrim
3b4ac7dc2a
[InstCombine][X86][AVX] Add DemandedElts support for VPERMILPD/VPERMILPS instructions
...
Simplify a vpermilvar shuffle mask based on the elements of the mask that are actually demanded.
llvm-svn: 292209
2017-01-17 11:35:03 +00:00
Sanjoy Das
1728d455cf
[InstCombine] Don't DSE across readnone functions that may throw
...
Summary: Depends on D28740
Reviewers: dberlin, chandlerc, hfinkel, majnemer
Subscribers: mcrosier, llvm-commits
Differential Revision: https://reviews.llvm.org/D28742
llvm-svn: 292197
2017-01-17 05:45:09 +00:00
David Majnemer
b33ccfb48d
[InstCombine] Fold ((C1-zext(X)) & C2) -> zext((C1-X) & C2)
...
This is valid if C2 fits within the bitwidth of X thanks to two's
complement modulo arithmetic.
llvm-svn: 292179
2017-01-17 00:45:57 +00:00
Matt Arsenault
a568a0d4a6
Add comment to test file I forgot to save
...
llvm-svn: 292178
2017-01-17 00:35:28 +00:00
Matt Arsenault
018a8adda0
SimplifyLibCalls: Remove checks for fabs
...
Use the intrinsic instead of emitting the libcall which
will be replaced by the intrinsic.
llvm-svn: 292176
2017-01-17 00:30:31 +00:00
Matt Arsenault
ccfb3dd68e
SimplifyLibCalls: Replace fabs libcalls with intrinsics
...
Add missing fabs(fpext) optimzation that worked with the call,
and also fixes it creating a second fpext when there were multiple
uses.
llvm-svn: 292172
2017-01-17 00:10:40 +00:00
Simon Pilgrim
b3d302c9e0
[InstCombine][AVX] Tests showing missed opportunities to pass demanded elts through a permilpd/permilps shuffle mask
...
llvm-svn: 292165
2017-01-16 21:34:22 +00:00
Sanjay Patel
ab8f315ba8
[InstCombine] use m_APInt to allow shift-shift folds for vectors with splat constants
...
Some existing 'FIXME' tests are still not folded because of splat holes in value tracking.
llvm-svn: 292151
2017-01-16 19:35:45 +00:00
Sanjay Patel
1ec279d94f
[InstCombine] add tests to show missed vector folds; NFC
...
The shift-shift possibilities became easier to see after:
https://reviews.llvm.org/rL292145
llvm-svn: 292150
2017-01-16 19:23:34 +00:00
Simon Pilgrim
cdda17446c
[InstCombine][SSE] Tests showing missed opportunities to pass demanded elts through a packss/packus truncation
...
llvm-svn: 292144
2017-01-16 17:26:23 +00:00
Simon Pilgrim
9d900b5f6e
[InstCombine][SSE] Add DemandedElts support for PSHUFB instructions
...
Simplify a pshufb shuffle mask based on the elements of the mask that are actually demanded.
Differential Revision: https://reviews.llvm.org/D28745
llvm-svn: 292101
2017-01-16 11:30:41 +00:00
Sanjay Patel
3b866f23f8
[InstCombine] add tests to show missed vector folds; NFC
...
Also, add comments and remove bogus comment.
llvm-svn: 292082
2017-01-15 23:45:03 +00:00
Simon Pilgrim
c1b9ed731d
[InstCombine][SSE] Tests showing missed opportunities to pass demanded elts through a pshufb shuffle mask
...
llvm-svn: 292072
2017-01-15 17:49:04 +00:00
Sanjay Patel
5495465040
[InstCombine] use m_APInt to allow ashr folds for vectors with splat constants
...
llvm-svn: 292064
2017-01-15 16:38:19 +00:00
Sanjay Patel
f8ca2aa064
[InstCombine] add explanatory comments to tests; NFC
...
llvm-svn: 292063
2017-01-15 16:22:26 +00:00
Chandler Carruth
fa2e854de5
[PM] Fix instcombine's analysis preservation in the new pass manager to
...
cover domtree and alias analysis. These are the pretty clear analyses
that we would always want to survive this pass.
To make these survive, we also need to preserve the assumption cache.
Added a test that verifies the important bits of this preservation.
llvm-svn: 292037
2017-01-14 23:25:22 +00:00
Sanjay Patel
286505799a
[InstCombine] add test to show missed vector fold; NFC
...
llvm-svn: 292035
2017-01-14 23:12:29 +00:00
Sanjay Patel
c20cf10406
[InstCombine] optimize unsigned icmp of increment
...
Allows LLVM to optimize sequences like the following:
%add = add nuw i32 %x, 1
%cmp = icmp ugt i32 %add, %y
Into:
%cmp = icmp uge i32 %x, %y
Previously, only signed comparisons were being handled.
Decrements could also be handled, but 'sub nuw %x, 1' is currently canonicalized to
'add %x, -1' in InstCombineAddSub, losing the nuw flag. Removing that canonicalization
seems like it might have far-reaching ramifications so I kept this simple for now.
Patch by Matti Niemenmaa!
Differential Revision: https://reviews.llvm.org/D24700
llvm-svn: 291975
2017-01-13 23:25:46 +00:00
Sanjay Patel
fcb9044bb8
[InstCombine] use m_APInt to allow lshr folds for vectors with splat constants
...
llvm-svn: 291972
2017-01-13 23:04:10 +00:00
Sanjay Patel
4485ac55e2
[InstCombine / InstSimplify] add and move tests for lshr transforms; NFC
...
llvm-svn: 291970
2017-01-13 22:54:12 +00:00
Sanjay Patel
3edc9b2bd9
[InstCombine] use m_APInt to allow shl folds for vectors with splat constants
...
llvm-svn: 291934
2017-01-13 18:39:09 +00:00
Sanjay Patel
68dd981647
[InstCombine] add tests to show missing transforms for vector shl; NFC
...
llvm-svn: 291926
2017-01-13 18:27:23 +00:00
Sanjay Patel
ee734847d0
[InstCombine] if the condition of a select may be known via assumes, eliminate the select
...
This is a limited solution for PR31512:
https://llvm.org/bugs/show_bug.cgi?id=31512
The motivation is that we will need to increase usage of llvm.assume and/or metadata to solve PR28430:
https://llvm.org/bugs/show_bug.cgi?id=28430
...and this kind of simplification is needed to take advantage of that extra information.
The 'not' test case would be handled by:
https://reviews.llvm.org/D28485
Differential Revision:
https://reviews.llvm.org/D28337
llvm-svn: 291915
2017-01-13 17:02:42 +00:00
Matt Arsenault
588e04537c
InstSimplify: Eliminate fabs on known positive
...
llvm-svn: 291624
2017-01-11 00:33:24 +00:00
Matt Arsenault
0be1430dec
InstCombine: fdiv -x, -y -> fdiv x, y
...
llvm-svn: 291611
2017-01-10 23:08:54 +00:00
Davide Italiano
ba6e5d0a9e
[SimplifyLibCalls] Propagate fast math flags while optimizing pow().
...
llvm-svn: 291577
2017-01-10 18:02:05 +00:00
Davide Italiano
bc2b08fb6d
[SimplifyLibCalls] pow(x, -0.5) -> 1.0 / sqrt(x).
...
Differential Revision: https://reviews.llvm.org/D28479
llvm-svn: 291486
2017-01-09 21:55:23 +00:00
Sanjay Patel
3ac455e916
[InstCombine] add test to show missed fold using llvm.assume; NFC
...
llvm-svn: 291472
2017-01-09 20:18:30 +00:00
Sanjay Patel
a6e75ebdd0
[InstCombine] regenerate checks; NFC
...
llvm-svn: 291469
2017-01-09 19:43:26 +00:00
Sanjay Patel
02b3fa484b
[InstCombine] regenerate checks; NFC
...
llvm-svn: 291464
2017-01-09 19:18:46 +00:00
Sanjay Patel
ac0df93034
[InstCombine] remove unnecessary attribute comments from test files; NFC
...
llvm-svn: 291463
2017-01-09 19:13:38 +00:00
Matt Arsenault
b5e40e0ffe
SimplifyLibCalls: Remove incorrect optimization of fabs
...
fabs(x * x) is not generally safe to assume x is positive if x is a NaN.
This is also less general than it could be, so this will be replaced
with a transformation on the intrinsic.
llvm-svn: 291359
2017-01-07 19:55:12 +00:00
David Majnemer
56f8a7c1a4
[InstSimplify] Optimize away urems in the presence of range metadata
...
We know that urem %V, C can be optimized away to %V if %V is ult C.
llvm-svn: 291282
2017-01-06 21:23:51 +00:00
Sanjay Patel
bbb8bbf58b
[InstCombine] add a vector version of a test added in r291262; NFC
...
llvm-svn: 291265
2017-01-06 19:14:05 +00:00