summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [InstCombine] use m_APInt to allow icmp (and (sh X, Y), C2), C1 folds for ↵Sanjay Patel2016-09-071-51/+21
| | | | | | splat constant vectors llvm-svn: 280873
* [InstCombine] allow icmp (and X, C2), C1 folds for splat constant vectorsSanjay Patel2016-09-071-43/+33
| | | | | | | | This is a revert of r280676 which was a revert of r280637; ie, this is r280637 again. It was speculatively reverted to help debug buildbot failures. llvm-svn: 280861
* [InstCombine] don't assert that division-by-constant has been folded (PR30281)Sanjay Patel2016-09-051-7/+6
| | | | | | | | | | This is effectively a revert of: https://reviews.llvm.org/rL280115 And this should fix https://llvm.org/bugs/show_bug.cgi?id=30281: llvm-svn: 280677
* [InstCombine] revert r280637 because it causes test failures on an ARM botSanjay Patel2016-09-051-33/+43
| | | | | | http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/14952/steps/ninja%20check%201/logs/FAIL%3A%20LLVM%3A%3Aicmp.ll llvm-svn: 280676
* [InstCombine] allow icmp (and X, C2), C1 folds for splat constant vectorsSanjay Patel2016-09-041-43/+33
| | | | | | | | The code to calculate 'UsesRemoved' could be simplified. As-is, that code is a victim of PR30273: https://llvm.org/bugs/show_bug.cgi?id=30273 llvm-svn: 280637
* [InstCombine] recode icmp fold in a vector-friendly way; NFCSanjay Patel2016-09-041-22/+30
| | | | | | | | | | | The transform in question: icmp (and (trunc W), C2), C1 -> icmp (and W, C2'), C1' ...is still not enabled for vectors, thus no functional change intended. It's not clear to me if this is a good transform for vectors or even scalars in general. Changing that behavior may be a follow-on patch. llvm-svn: 280627
* [InstCombine] remove fold of an icmp pattern that should never happenSanjay Patel2016-09-011-15/+0
| | | | | | | | | | | | While removing a scalar shackle from an icmp fold, I noticed that I couldn't find any tests to trigger this code path. The 'and' shrinking transform should be handled by InstCombiner::foldCastedBitwiseLogic() or eliminated with InstSimplify. The icmp narrowing is part of InstCombiner::foldICmpWithCastAndCast(). Differential Revision: https://reviews.llvm.org/D24031 llvm-svn: 280370
* [InstCombine] allow icmp (shr exact X, C2), C fold for splat constant vectorsSanjay Patel2016-08-311-5/+0
| | | | | | | The enhancement to foldICmpDivConstant ( http://llvm.org/viewvc/llvm-project?view=revision&revision=280299 ) allows us to remove the ConstantInt check; no other changes needed. llvm-svn: 280300
* [InstCombine] allow icmp (div X, Y), C folds for splat constant vectorsSanjay Patel2016-08-311-37/+26
| | | | | | Converting all of the overflow ops to APInt looked risky, so I've left that as a TODO. llvm-svn: 280299
* [InstCombine] change insertRangeTest() to use APInt instead of Constant; NFCISanjay Patel2016-08-311-4/+8
| | | | | | | | This is prep work before changing the callers to also use APInt which will allow folds for splat vectors. Currently, the callers have ConstantInt guards in place, so no functional change intended with this commit. llvm-svn: 280282
* [InstCombine] replace divide-by-constant checks with asserts; NFCSanjay Patel2016-08-301-19/+16
| | | | | | | These folds already have tests for scalar and vector types, except for the vector div-by-0 case, so I'm adding tests for that. llvm-svn: 280115
* [InstCombine] clean up foldICmpDivConstant; NFCISanjay Patel2016-08-301-16/+20
| | | | | | | | 1. Fix comments to match variable names 2. Remove redundant CmpRHS variable 3. Add FIXME to replace some checks with asserts llvm-svn: 280112
* [InstCombine] use m_APInt to allow icmp (and X, Y), C folds for splat ↵Sanjay Patel2016-08-281-32/+34
| | | | | | constant vectors llvm-svn: 279937
* [InstCombine] add helper function for icmp (and (sh X, Y), C2), C1 ; NFCSanjay Patel2016-08-261-44/+61
| | | | | | | | Like other recent changes near here, the goal is to allow vector types for all of these folds. Splitting things up makes it easier to incrementally enhance the code and easier to read. llvm-svn: 279851
* [InstCombine] clean up foldICmpAndConstConst(); NFCSanjay Patel2016-08-261-172/+166
| | | | | | | | 1. Early exit to reduce indent 2. Fix comments and variable names to match 3. Reformat comments / clang-format code llvm-svn: 279837
* [InstCombine] add helper function for folding of icmp (and X, C2), C; NFCSanjay Patel2016-08-261-6/+19
| | | | llvm-svn: 279834
* [InstCombine] rename variables in foldICmpAndConstant(); NFCSanjay Patel2016-08-261-54/+55
| | | | llvm-svn: 279831
* [InstCombine] rename variables in foldICmpDivConstant(); NFCSanjay Patel2016-08-261-29/+28
| | | | | | | | | | | Removing the redundant 'CmpRHSV' local variable exposes a bug in the caller foldICmpShrConstant() - it was sending in the div constant instead of the cmp constant. But I have not been able to expose this in a regression test yet - the affected folds all appear to be handled before we ever reach this code. I'll keep trying to find a case as I make changes to allow vector folds in both functions. llvm-svn: 279828
* [InstCombine] move foldICmpDivConstConst() contents to ↵Sanjay Patel2016-08-241-165/+158
| | | | | | | | | foldICmpDivConstant(); NFCI There was no logic in foldICmpDivConstant, so no need for a separate function. The code is directly copy/pasted, so further cleanups to follow. llvm-svn: 279685
* [InstCombine] use m_APInt to allow icmp eq/ne (shr X, C2), C folds for splat ↵Sanjay Patel2016-08-241-16/+19
| | | | | | constant vectors llvm-svn: 279677
* [InstCombine] add assert and explanatory comment for fold removed in ↵Sanjay Patel2016-08-241-0/+7
| | | | | | | | | | | | | | | | r279568; NFC I deleted a fold from InstCombine at: https://reviews.llvm.org/rL279568 because it (like any InstCombine to a constant?) should always happen in InstSimplify, however, it's not obvious what the assumptions are in the remaining code. Add a comment and assert to make it clearer. Differential Revision: https://reviews.llvm.org/D23819 llvm-svn: 279626
* [InstCombine] use local variables for repeated values; NFCISanjay Patel2016-08-231-12/+9
| | | | llvm-svn: 279578
* [InstCombine] move foldICmpShrConstConst() contents to foldICmpShrConst(); NFCISanjay Patel2016-08-231-75/+65
| | | | | | | There will only be 3 lines of code in foldICmpShrConst() when the cleanup is done, so it doesn't make much sense to have a separate function for a single fold. llvm-svn: 279575
* [InstCombine] remove icmp shr folds that are already handled by InstSimplifySanjay Patel2016-08-231-17/+3
| | | | | | | | AFAICT, these already worked in all cases for scalar types, and I enhanced the code to work for vector types in: https://reviews.llvm.org/rL279543 llvm-svn: 279568
* [InstCombine] change param type from Instruction to BinaryOperator for icmp ↵Sanjay Patel2016-08-221-73/+85
| | | | | | | | helpers; NFCI This saves some casting in the helper functions and eases some further refactoring. llvm-svn: 279478
* [InstCombine] use m_APInt to allow icmp (shr exact X, Y), 0 folds for splat ↵Sanjay Patel2016-08-221-14/+13
| | | | | | constant vectors llvm-svn: 279472
* [InstCombine] use m_APInt to allow icmp (shl X, Y), C folds for splat ↵Sanjay Patel2016-08-211-13/+10
| | | | | | | | | | | constant vectors, part 4 This concludes the fixes for icmp+shl in this series: https://reviews.llvm.org/rL279339 https://reviews.llvm.org/rL279398 https://reviews.llvm.org/rL279399 llvm-svn: 279401
* [InstCombine] use m_APInt to allow icmp (shl X, Y), C folds for splat ↵Sanjay Patel2016-08-211-6/+6
| | | | | | | | constant vectors, part 3 This is a partial enablement (move the ConstantInt guard down). llvm-svn: 279399
* [InstCombine] use m_APInt to allow icmp (shl X, Y), C folds for splat ↵Sanjay Patel2016-08-211-6/+6
| | | | | | | | constant vectors, part 2 This is a partial enablement (move the ConstantInt guard down). llvm-svn: 279398
* [InstCombine] use APInt instead of ConstantInt in isSignBitCheck(); NFCISanjay Patel2016-08-211-8/+8
| | | | | | | | The callers still have ConstantInt guards, so there is no functional change intended from this change. But relaxing the callers will allow more folds for vector types. llvm-svn: 279396
* [InstCombine] use m_APInt to allow icmp (shl X, Y), C folds for splat ↵Sanjay Patel2016-08-191-17/+16
| | | | | | | | | constant vectors, part 1 This is a partial enablement (move the ConstantInt guard down) because there are many different folds here and one of the later ones will require reworking 'isSignBitCheck'. llvm-svn: 279339
* [InstCombine] remove an icmp fold that is already handled by InstSimplifySanjay Patel2016-08-191-10/+0
| | | | | | | | | | | | Specifically, this is done near the end of "SimplifyICmpInst" using computeKnownBits() as the broader solution. There are even vector tests (yay!) for this in test/Transforms/InstSimplify/compare.ll. I considered putting an assert here instead of just deleting, but then we could assert every possible fold in InstSimplify in InstCombine, so...less is more? llvm-svn: 279300
* [InstCombine] use local variables to reduce code in foldICmpShlConstant; NFCSanjay Patel2016-08-191-21/+15
| | | | llvm-svn: 279282
* [InstCombine] rename variables in foldICmpShlConstant(); NFCSanjay Patel2016-08-191-34/+34
| | | | llvm-svn: 279279
* Fix regression in InstCombine introduced by r278944Reid Kleckner2016-08-191-3/+4
| | | | | | | | | | | The intended transform is: // Simplify icmp eq (or (ptrtoint P), (ptrtoint Q)), 0 // -> and (icmp eq P, null), (icmp eq Q, null). P and Q are both pointer types, but may have different types. We need two calls to getNullValue() to make the icmps. llvm-svn: 279271
* [InstCombine] use m_APInt to allow icmp (shl 1, Y), C folds for splat ↵Sanjay Patel2016-08-191-4/+5
| | | | | | constant vectors llvm-svn: 279266
* [InstCombine] use m_APInt to allow icmp X, C folds for splat constant vectorsSanjay Patel2016-08-191-5/+10
| | | | | | | | | Of course, we really need to refactor and fix all of the cmp predicates, but this one is interesting because without it, we later perform an information-losing transform of icmp (shl 1, Y), C, and we can't recover the better fold. llvm-svn: 279263
* [InstCombine] add helper function for folds of icmp (shl 1, Y), C; NFCISanjay Patel2016-08-181-62/+65
| | | | | | | | | | | | | Clean up the existing code by: 1. Renaming variables 2. Adding local variables 3. Making it vector-safe This is still guarded by a ConstantInt check, so no functional change is intended. But this should be ready to go: if we move the ConstantInt check down, all of these folds should do the right thing for vector types. llvm-svn: 279150
* [InstCombine] use m_APInt to allow icmp (trunc X, Y), C folds for splat ↵Sanjay Patel2016-08-181-9/+4
| | | | | | | | | | | | | | constant vectors This is a sibling of: https://reviews.llvm.org/rL278859 https://reviews.llvm.org/rL278935 https://reviews.llvm.org/rL278945 https://reviews.llvm.org/rL279066 https://reviews.llvm.org/rL279077 https://reviews.llvm.org/rL279101 llvm-svn: 279133
* [InstCombine] clean up foldICmpTruncConstant(); NFCISanjay Patel2016-08-181-14/+17
| | | | | | | 1. Fix variable names 2. Add local variables to reduce code llvm-svn: 279132
* [InstCombine] use m_APInt to allow icmp (udiv X, Y), C folds for splat ↵Sanjay Patel2016-08-181-18/+20
| | | | | | | | | | | | | constant vectors This is a sibling of: https://reviews.llvm.org/rL278859 https://reviews.llvm.org/rL278935 https://reviews.llvm.org/rL278945 https://reviews.llvm.org/rL279066 https://reviews.llvm.org/rL279077 llvm-svn: 279101
* [InstCombine] clean up foldICmpUDivConstant; NFCSanjay Patel2016-08-181-16/+12
| | | | | | | 1. Better variable names 2. Remove unnecessary check of ConstantInt llvm-svn: 279094
* [InstCombine] use m_APInt to allow icmp (mul X, Y), C folds for splat ↵Sanjay Patel2016-08-181-18/+14
| | | | | | | | | | | | constant vectors This is a sibling of: https://reviews.llvm.org/rL278859 https://reviews.llvm.org/rL278935 https://reviews.llvm.org/rL278945 https://reviews.llvm.org/rL279066 llvm-svn: 279077
* [InstCombine] use APInt in isSignTest instead of ConstantInt; NFCSanjay Patel2016-08-181-6/+7
| | | | | | | This will enable vector splat folding, but NFC until the callers have their ConstantInt restrictions removed. llvm-svn: 279072
* [InstCombine] use m_APInt to allow icmp (xor X, Y), C folds for splat ↵Sanjay Patel2016-08-181-13/+10
| | | | | | | | | | | constant vectors This is a sibling of: https://reviews.llvm.org/rL278859 https://reviews.llvm.org/rL278935 https://reviews.llvm.org/rL278945 llvm-svn: 279066
* Replace a few more "fall through" comments with LLVM_FALLTHROUGHJustin Bogner2016-08-171-6/+9
| | | | | | Follow up to r278902. I had missed "fall through", with a space. llvm-svn: 278970
* [InstCombine] more clean up of foldICmpXorConstant(); NFCISanjay Patel2016-08-171-27/+21
| | | | | | | Use m_APInt for the xor constant, but this is all still guarded by the initial ConstantInt check, so no vector types should make it in here. llvm-svn: 278957
* [InstCombine] clean up foldICmpXorConstant(); NFCISanjay Patel2016-08-171-55/+60
| | | | | | | | 1. Change variable names 2. Use local variables to reduce code 3. Early exit to reduce indent llvm-svn: 278955
* [InstCombine] use m_APInt to allow icmp (or X, Y), C folds for splat ↵Sanjay Patel2016-08-171-5/+0
| | | | | | | | | | constant vectors This is a sibling of: https://reviews.llvm.org/rL278859 https://reviews.llvm.org/rL278935 llvm-svn: 278945
* [InstCombine] clean up foldICmpOrConstant(); NFCISanjay Patel2016-08-171-18/+16
| | | | | | | | | 1. Change variable names 2. Use local variables to reduce code 3. Use ? instead of if/else 4. Use the APInt variable instead of 'RHS' so the removal of the FIXME code will be direct llvm-svn: 278944
OpenPOWER on IntegriCloud