summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine/add.ll
Commit message (Collapse)AuthorAgeFilesLines
* [InstCombine] (Y + ~X) + 1 --> Y - X fold (PR42459)Roman Lebedev2019-07-011-7/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [InstCombine] Add new combine to add foldingRobert Lougher2019-05-071-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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
* Precommit tests for or/add transform. NFC.Robert Lougher2019-05-071-0/+80
| | | | llvm-svn: 360149
* Revert "Temporarily Revert "Add basic loop fusion pass.""Eric Christopher2019-04-171-0/+980
| | | | | | | | The reversion apparently deleted the test/Transforms directory. Will be re-reverting again. llvm-svn: 358552
* Temporarily Revert "Add basic loop fusion pass."Eric Christopher2019-04-171-980/+0
| | | | | | | | As it's causing some bot failures (and per request from kbarton). This reverts commit r358543/ab70da07286e618016e78247e4a24fcb84077fda. llvm-svn: 358546
* Add extra ops in add to sub transform test in order to enforce proper ↵Amaury Sechet2019-03-031-4/+8
| | | | | | operand ordering. NFC llvm-svn: 355291
* Add test case for add to sub transformation. NFCAmaury Sechet2019-03-021-0/+27
| | | | llvm-svn: 355277
* [InstCombine] fold adds of constants separated by sext/zextSanjay Patel2019-02-281-10/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [ValueTracking] More accurate unsigned add overflow detectionNikita Popov2019-02-281-1/+1
| | | | | | | | | | | | Part of D58593. Compute precise overflow conditions based on all known bits, rather than just the sign bits. Unsigned a + b overflows iff a > ~b, and we can determine whether this always/never happens based on the minimal and maximal values achievable for a and ~b subject to the known bits constraint. llvm-svn: 355072
* [InstCombine] add tests for add+ext+add; NFCSanjay Patel2019-02-271-0/+86
| | | | llvm-svn: 355020
* [InstCombine] canonicalize add/sub with boolSanjay Patel2019-02-241-4/+2
| | | | | | | | | | | | | | | | | | | | | | | 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
* [PatternMatch] allow undef elements in vectors with m_NegSanjay Patel2018-07-011-5/+3
| | | | | | This is similar to the m_Not change from D44076. llvm-svn: 336064
* [InstCombine] add tests for negate vector with undef elts; NFC Sanjay Patel2018-06-301-3/+27
| | | | llvm-svn: 336050
* [InstCombine] (A + 1) + (B ^ -1) --> A - BGil Rapaport2018-06-261-0/+37
| | | | | | | | | 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
* [InstCombine] add tests for add-of-sext-bool; NFCSanjay Patel2018-06-251-0/+22
| | | | | | | We canonicalize to select with a zext-add and either zext-sub or sext-sub, so this shows a pattern that's not conforming to the general trend. llvm-svn: 335506
* [InstCombine] fix test to restore intentSanjay Patel2018-04-301-3/+2
| | | | | | | | | This test had values that differed in only in capitalization, and that causes problems for the auto-generating check line script. So I changed that in rL331226, but I accidentally forgot to change a subsequent use of a param. llvm-svn: 331228
* [InstCombine] add tests, update checks; NFCSanjay Patel2018-04-301-86/+120
| | | | llvm-svn: 331226
* [InstCombine] move code to remove repeated constant check; NFCISanjay Patel2017-10-131-2/+10
| | | | | | Also, consolidate tests for this fold in one place. llvm-svn: 315745
* [InstCombine] add hasOneUse check to add-zext-add fold to prevent increasing ↵Sanjay Patel2017-10-131-3/+2
| | | | | | instructions llvm-svn: 315718
* [InstCombine] add tests for add (zext (add nuw X, C2)), C --> zext (add nuw ↵Sanjay Patel2017-10-131-0/+32
| | | | | | X, C2 + C); NFC llvm-svn: 315717
* [InstCombine] Support (X ^ C1) & C2 --> (X & C2) ^ (C1&C2) for vector splats.Craig Topper2017-08-061-2/+2
| | | | llvm-svn: 310233
* [InstCombine] add (sext i1 X), 1 --> zext (not X)Sanjay Patel2017-06-251-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | http://rise4fun.com/Alive/i8Q A narrow bitwise logic op is obviously better than math for value tracking, and zext is better than sext. Typically, the 'not' will be folded into an icmp predicate. The IR difference would even survive through codegen for x86, so we would see worse code: https://godbolt.org/g/C14HMF one_or_zero(int, int): # @one_or_zero(int, int) xorl %eax, %eax cmpl %esi, %edi setle %al retq one_or_zero_alt(int, int): # @one_or_zero_alt(int, int) xorl %ecx, %ecx cmpl %esi, %edi setg %cl movl $1, %eax subl %ecx, %eax retq llvm-svn: 306243
* [InstCombine] add (ashr (shl i32 X, 31), 31), 1 --> and (not X), 1Sanjay Patel2017-05-101-6/+4
| | | | | | | | | | | | | | This is another step towards favoring 'not' ops over random 'xor' in IR: https://bugs.llvm.org/show_bug.cgi?id=32706 This transformation may have occurred in longer IR sequences using computeKnownBits, but that could be much more expensive to calculate. As the scalar result shows, we do not currently favor 'not' in all cases. The 'not' created by the transform is transformed again (unnecessarily). Vectors don't have this problem because vectors are (wrongly) excluded from several other combines. llvm-svn: 302659
* [InstCombine] add tests for andn; NFCSanjay Patel2017-05-091-0/+28
| | | | llvm-svn: 302599
* [InstCombine] Support folding of add instructions with vector constants into ↵Craig Topper2017-04-101-6/+3
| | | | | | | | | | select operations We currently only fold scalar add of constants into selects. This improves this to support vectors too. Differential Revision: https://reviews.llvm.org/D31683 llvm-svn: 299847
* [InstCombine] add tests for missing add canonicalization; NFCSanjay Patel2017-04-051-0/+26
| | | | llvm-svn: 299539
* [InstCombine] Add test cases for various add/subtracts of constants(scalar, ↵Craig Topper2017-04-041-0/+98
| | | | | | splat, and vector) with phis and selects. Improvements coming in a future commit. llvm-svn: 299476
* [InstCombine] Add test cases showing how we fail to fold vector constants ↵Craig Topper2017-04-031-0/+11
| | | | | | into selects the way we do with scalars. llvm-svn: 299369
* [InstCombine] add nsw/nuw X, signbit --> or X, signbitSanjay Patel2017-02-181-6/+4
| | | | | | | | | Changing to 'or' (rather than 'xor' when no wrapping flags are set) allows icmp simplifies to happen as expected. Differential Revision: https://reviews.llvm.org/D29729 llvm-svn: 295574
* [InstSimplify] add nsw/nuw (xor X, signbit), signbit --> XSanjay Patel2017-02-181-1/+3
| | | | | | | | | The change to InstCombine in: https://reviews.llvm.org/D29729 ...exposes this missing fold in InstSimplify, so adding this first to avoid a regression. llvm-svn: 295573
* [InstCombine] add tests to show information-losing add nsw/nuw transforms; NFCSanjay Patel2017-02-081-4/+39
| | | | llvm-svn: 294524
* [InstCombine] fix operand-complexity-based canonicalization (PR28296)Sanjay Patel2017-02-031-2/+2
| | | | | | | | | | | | | | | | | | | The code comments didn't match the code logic, and we didn't actually distinguish the fake unary (not/neg/fneg) operators from arguments. Adding another level to the weighting scheme provides more structure and can help simplify the pattern matching in InstCombine and other places. I fixed regressions that would have shown up from this change in: rL290067 rL290127 But that doesn't mean there are no pattern-matching logic holes left; some combines may just be missing regression tests. Should fix: https://llvm.org/bugs/show_bug.cgi?id=28296 Differential Revision: https://reviews.llvm.org/D27933 llvm-svn: 294049
* [InstCombine] Combine adds across a zextDavid Majnemer2017-01-041-0/+12
| | | | | | | | | We can perform the following: (add (zext (add nuw X, C1)), C2) -> (zext (add nuw X, C1+C2)) This is only possible if C2 is negative and C2 is greater than or equal to negative C1. llvm-svn: 290927
* [InstCombine] use m_APInt to allow icmp eq (add X, C1), C2 folds for splat ↵Sanjay Patel2016-08-031-3/+1
| | | | | | constant vectors llvm-svn: 277659
* [InstCombine] use m_APInt to allow icmp (binop X, Y), C folds with constant ↵Sanjay Patel2016-08-031-7/+3
| | | | | | | | | splat vectors This removes the restriction for the icmp constant, but as noted by the FIXME comments, we still need to change individual checks for binop operand constants. llvm-svn: 277629
* add tests for icmp vector foldsSanjay Patel2016-07-221-0/+37
| | | | llvm-svn: 276472
* update to use FileCheck and auto-generate checksSanjay Patel2016-07-221-161/+338
| | | | llvm-svn: 276466
* Revert 'Fix a typo 'iff' => 'if''. iff is an abreviation of if and only if. ↵Sylvestre Ledru2012-09-271-1/+1
| | | | | | See: http://en.wikipedia.org/wiki/If_and_only_if Commit 164767 llvm-svn: 164768
* Fix a typo 'iff' => 'if'Sylvestre Ledru2012-09-271-1/+1
| | | | llvm-svn: 164767
* Also fold (A+B) == A -> B == 0 when the add is commuted.Benjamin Kramer2011-02-111-10/+18
| | | | llvm-svn: 125411
* Recognize and simplifyAnders Carlsson2011-01-301-0/+16
| | | | | | | (A+B) == A -> B == 0 A == (A+B) -> B == 0 llvm-svn: 124567
* Use opt -S instead of piping bitcode output through llvm-dis.Dan Gohman2009-09-081-1/+1
| | | | llvm-svn: 81257
* Change these tests to feed the assembly files to opt directly, insteadDan Gohman2009-09-081-1/+1
| | | | | | of using llvm-as, now that opt supports this. llvm-svn: 81226
* Teach masked value is zero about add and sub, and use MVIZ toChris Lattner2008-03-211-0/+7
| | | | | | | | simplify things like (X & 4) >> 1 == 2 --> (X & 4) == 4. since it is obvious that the shift doesn't remove any bits. llvm-svn: 48631
* Remove llvm-upgrade and update tests.Tanya Lattner2008-03-091-170/+189
| | | | llvm-svn: 48103
* For PR1319:Reid Spencer2007-04-161-1/+0
| | | | | | | | Remove && from the end of the lines to prevent tests from throwing run lines into the background. Also, clean up places where the same command is run multiple times by using a temporary file. llvm-svn: 36142
* For PR1319:Reid Spencer2007-04-151-0/+1
| | | | | | | Make use of the END. facility on all files > 1K so that we aren't wasting CPU cycles searching for RUN: lines that we'll never find. llvm-svn: 36059
* Changes to support making the shift instructions be true BinaryOperators.Reid Spencer2007-02-021-2/+4
| | | | | | | | | | | | This feature is needed in order to support shifts of more than 255 bits on large integer types. This changes the syntax for llvm assembly to make shl, ashr and lshr instructions look like a binary operator: shl i32 %X, 1 instead of shl i32 %X, i8 1 Additionally, this should help a few passes perform additional optimizations. llvm-svn: 33776
* For PR411:Reid Spencer2007-01-301-1/+1
| | | | | | | | Update these tests to not use the same name even though the type of the value differs. After PR411 hits, type planes will be gone and it will be illegal for a name to be used twice, regardless of type. llvm-svn: 33660
* For PR761:Reid Spencer2007-01-261-4/+4
| | | | | | | | | | | | | | Remove "target endian/pointersize" or add "target datalayout" to make the test parse properly or set the datalayout because defaults changes. For PR645: Make global names use the @ prefix. For llvm-upgrade changes: Fix test cases or completely remove use of llvm-upgrade for test cases that cannot survive the new renaming or upgrade capabilities. llvm-svn: 33533
OpenPOWER on IntegriCloud