summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine/select.ll
Commit message (Collapse)AuthorAgeFilesLines
* [InstSimplify] add tests for vector select; NFCSanjay Patel2020-01-141-9/+9
|
* [InstCombine] add FMF to tests for more coverage; NFCSanjay Patel2020-01-131-6/+6
|
* [InstCombine] add tests for select --> copysign; NFCSanjay Patel2020-01-131-0/+108
| | | | | This is testing for another (possibly final) transform suggested in: https://bugs.llvm.org/show_bug.cgi?id=44153
* [InstSimplify] move tests for select from InstCombine; NFCSanjay Patel2020-01-131-33/+0
| | | | | | InstCombine has transforms that would enable these simplifications in an indirect way, but those transforms are unsafe and likely to be removed.
* [InstCombine] Invert `add A, sext(B) --> sub A, zext(B)` canonicalization ↵Roman Lebedev2019-12-051-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (to `sub A, zext B -> add A, sext B`) Summary: D68408 proposes to greatly improve our negation sinking abilities. But in current canonicalization, we produce `sub A, zext(B)`, which we will consider non-canonical and try to sink that negation, undoing the existing canonicalization. So unless we explicitly stop producing previous canonicalization, we will have two conflicting folds, and will end up endlessly looping. This inverts canonicalization, and adds back the obvious fold that we'd miss: * `sub [nsw] Op0, sext/zext (bool Y) -> add [nsw] Op0, zext/sext (bool Y)` https://rise4fun.com/Alive/xx4 * `sext(bool) + C -> bool ? C - 1 : C` https://rise4fun.com/Alive/fBl It is obvious that `@ossfuzz_9880()` / `@lshr_out_of_range()`/`@ashr_out_of_range()` (oss-fuzz 4871) are no longer folded as much, though those aren't really worrying. Reviewers: spatel, efriedma, t.p.northover, hfinkel Reviewed By: spatel Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D71064
* [InstCombine] add tests for select/shift transforms; NFCSanjay Patel2019-10-141-0/+26
| | | | | | A transform proposal for the shift form is in D63382. llvm-svn: 374818
* [InstCombine] fold cmp+select using select operand equivalenceSanjay Patel2019-08-021-14/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed in PR42696: https://bugs.llvm.org/show_bug.cgi?id=42696 ...but won't help that case yet. We have an odd situation where a select operand equivalence fold was implemented in InstSimplify when it could have been done more generally in InstCombine if we allow dropping of {nsw,nuw,exact} from a binop operand. Here's an example: https://rise4fun.com/Alive/Xplr %cmp = icmp eq i32 %x, 2147483647 %add = add nsw i32 %x, 1 %sel = select i1 %cmp, i32 -2147483648, i32 %add => %sel = add i32 %x, 1 I've left the InstSimplify code in place for now, but my guess is that we'd prefer to remove that as a follow-up to save on code duplication and compile-time. Differential Revision: https://reviews.llvm.org/D65576 llvm-svn: 367695
* [InstCombine] add tests with 'ne' predicates; NFCSanjay Patel2019-08-011-0/+30
| | | | | | More coverage for the proposal in D65576. llvm-svn: 367579
* [InstCombine] add test with swapped select operands; NFCSanjay Patel2019-08-011-0/+13
| | | | | | More coverage for the proposal in D65576. llvm-svn: 367577
* Revert "Temporarily Revert "Add basic loop fusion pass.""Eric Christopher2019-04-171-0/+1506
| | | | | | | | 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-1506/+0
| | | | | | | | As it's causing some bot failures (and per request from kbarton). This reverts commit r358543/ab70da07286e618016e78247e4a24fcb84077fda. llvm-svn: 358546
* [InstCombine] canonicalize add/sub with boolSanjay Patel2019-02-241-4/+4
| | | | | | | | | | | | | | | | | | | | | | | 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
* [ValueTracking] Look through casts when determining non-nullnessJohannes Doerfert2019-01-261-7/+7
| | | | | | | | | | Bitcast and certain Ptr2Int/Int2Ptr instructions will not alter the value of their operand and can therefore be looked through when we determine non-nullness. Differential Revision: https://reviews.llvm.org/D54956 llvm-svn: 352293
* [InstCombine] Fold (min/max ~X, Y) -> ~(max/min X, ~Y) when Y is freely ↵Craig Topper2018-09-221-4/+4
| | | | | | | | | | | | | | | | invertible Summary: This restores the combine that was reverted in r341883. The infinite loop from the failing test no longer occurs due to changes from r342163. Reviewers: spatel, dmgreen Reviewed By: spatel Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D52070 llvm-svn: 342797
* [InstCombine] Partially revert rL341674 due to PR38897.Alina Sbirlea2018-09-101-4/+4
| | | | | | | | | | | | | | | Summary: Revert min/max changes in rL341674 dues to high compile times causing timeouts (PR38897). Checking in to unblock failing builds. Patch available for post-commit review and re-revert once resolved. Working on a smaller reproducer for PR38897. Reviewers: craig.topper, spatel Subscribers: sanjoy, jlebar, llvm-commits Differential Revision: https://reviews.llvm.org/D51897 llvm-svn: 341883
* [InstCombine] Fold (min/max ~X, Y) -> ~(max/min X, ~Y) when Y is freely ↵Craig Topper2018-09-071-4/+4
| | | | | | | | | | | | invertible If the ~X wasn't able to simplify above the max/min, we might be able to simplify it by moving it below the max/min. I had to modify the ~(min/max ~X, Y) transform to prevent getting stuck in a loop when we saw the new ~(max/min X, ~Y) before the ~Y had been folded away to remove the new not. Differential Revision: https://reviews.llvm.org/D51398 llvm-svn: 341674
* llvm: Add support for "-fno-delete-null-pointer-checks"Manoj Gupta2018-07-091-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Support for this option is needed for building Linux kernel. This is a very frequently requested feature by kernel developers. More details : https://lkml.org/lkml/2018/4/4/601 GCC option description for -fdelete-null-pointer-checks: This Assume that programs cannot safely dereference null pointers, and that no code or data element resides at address zero. -fno-delete-null-pointer-checks is the inverse of this implying that null pointer dereferencing is not undefined. This feature is implemented in LLVM IR in this CL as the function attribute "null-pointer-is-valid"="true" in IR (Under review at D47894). The CL updates several passes that assumed null pointer dereferencing is undefined to not optimize when the "null-pointer-is-valid"="true" attribute is present. Reviewers: t.p.northover, efriedma, jyknight, chandlerc, rnk, srhines, void, george.burgess.iv Reviewed By: efriedma, george.burgess.iv Subscribers: eraman, haicheng, george.burgess.iv, drinkcat, theraven, reames, sanjoy, xbolva00, llvm-commits Differential Revision: https://reviews.llvm.org/D47895 llvm-svn: 336613
* [InstCombine] move tests for select with bit-test of condition; NFCSanjay Patel2018-04-241-215/+0
| | | | | | | | | | | | | | | | | | These are all but 1 of the select-of-constant tests that appear to be transformed within foldSelectICmpAnd() and the block above it predicated by decomposeBitTestICmp(). As discussed in D45862 (and can be seen in several tests here), we probably want to stop doing those transforms because they can increase the instruction count without benefitting other passes or codegen. The 1 test not included here is a urem test where the bit hackery allows us to remove a urem. To preserve killing that urem, we should do some stronger known-bits analysis or pattern matching of 'urem x, (select-of-pow2-constants)'. llvm-svn: 330768
* [InstCombine] regenerate checks; NFCSanjay Patel2018-04-241-430/+573
| | | | | | | | | | The first step in fixing problems raised in D45862 is to make the problems visible. Now we can more easily see/update cases where selects have been turned into multiple instructions with no apparent improvement in analysis or benefits for other passes (vectorization). llvm-svn: 330731
* [PatternMatch] enhance m_One() to ignore undef elements in vectorsSanjay Patel2018-02-171-1/+1
| | | | llvm-svn: 325437
* [InstSimplify, InstCombine] add tests with vector undef elts; NFCSanjay Patel2018-02-171-6/+15
| | | | | | These would fold if the m_One pattern matcher accounted for undef elts. llvm-svn: 325436
* [InstCombine] Simplify binops that are only used by a select and are fed by ↵Craig Topper2017-11-151-0/+52
| | | | | | | | | | | | | | | | | | | a select with the same condition. Summary: This patch optimizes a binop sandwiched between 2 selects with the same condition. Since we know its only used by the select we can propagate the appropriate input value from the earlier select. As I'm writing this I realize I may need to avoid doing this for division in case the select was protecting a divide by zero? Reviewers: spatel, majnemer Reviewed By: majnemer Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D39999 llvm-svn: 318267
* Fix some misc. -enable-var-scope violationsMatt Arsenault2017-11-131-1/+1
| | | | llvm-svn: 318006
* [InstCombine] auto-generate complete checks; NFCSanjay Patel2017-10-021-39/+54
| | | | llvm-svn: 314712
* [InstCombine] Teach select01 helper of foldSelectIntoOp to handle vector splatsCraig Topper2017-08-281-0/+47
| | | | | | | | We were handling some vectors in foldSelectIntoOp, but not if the operand of the bin op was any kind of vector constant. This patch fixes it to treat vector splats the same as scalars. Differential Revision: https://reviews.llvm.org/D37232 llvm-svn: 311940
* [InstCombine] Make folding (X >s -1) ? C1 : C2 --> ((X >>s 31) & (C2 - C1)) ↵Craig Topper2017-08-161-0/+51
| | | | | | | | | | + C1 support splat vectors This also uses decomposeBitTestICmp to decode the compare. Differential Revision: https://reviews.llvm.org/D36781 llvm-svn: 311044
* [InstCombine] Add test case for PR33721.Craig Topper2017-07-111-0/+7
| | | | llvm-svn: 307621
* [InstCombine] canonicalize icmp predicate feeding selectSanjay Patel2017-06-271-12/+14
| | | | | | | | | | | | | | | | | | | | | This canonicalization was suggested in D33172 as a way to make InstCombine behavior more uniform. We have this transform for icmp+br, so unless there's some reason that icmp+select should be treated differently, we should do the same thing here. The benefit comes from increasing the chances of creating identical instructions. This is shown in the tests in logical-select.ll (PR32791). InstCombine doesn't fold those directly, but EarlyCSE can simplify the identical cmps, and then InstCombine can fold the selects together. The possible regression for the tests in select.ll raises questions about poison/undef: http://lists.llvm.org/pipermail/llvm-dev/2017-May/113261.html ...but that transform is just as likely to be triggered by this canonicalization as it is to be missed, so we're just pointing out a commutation deficiency in the pattern matching: https://reviews.llvm.org/rL228409 Differential Revision: https://reviews.llvm.org/D34242 llvm-svn: 306435
* fix trivial typos in comment, NFCHiroshi Inoue2017-06-241-2/+2
| | | | | | dereferencable -> dereferenceable llvm-svn: 306210
* [InstCombine] fix wrong undef handling when converting select to shuffleSanjay Patel2017-04-121-3/+14
| | | | | | | | | | | | | As discussed in: https://bugs.llvm.org/show_bug.cgi?id=32486 ...the canonicalization of vector select to shufflevector does not hold up when undef elements are present in the condition vector. Try to make the undef handling clear in the code and the LangRef. Differential Revision: https://reviews.llvm.org/D31980 llvm-svn: 300092
* [InstCombine] canonicalize non-obivous forms of integer min/maxSanjay Patel2017-02-211-2/+1
| | | | | | | | | | | | | | | | This is part of trying to clean up our handling of min/max patterns in IR. By converting these to canonical form, we're more likely to recognize them because there are various places in InstCombine that don't use matchSelectPattern or m_SMax and friends. The backend fixups referenced in the now deleted TODO comment were added with: https://reviews.llvm.org/rL291392 https://reviews.llvm.org/rL289738 If there's any codegen fallout from this change, we should be able to address it in DAGCombiner or target-specific lowering. llvm-svn: 295758
* [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
* [ValueTracking] recognize a 'not' of an assumed condition as falseSanjay Patel2017-01-171-3/+2
| | | | | | | | Also, add the corresponding match to the AssumptionCache's 'Affected Values' list. Differential Revision: https://reviews.llvm.org/D28485 llvm-svn: 292239
* [InstCombine] if the condition of a select may be known via assumes, ↵Sanjay Patel2017-01-131-0/+27
| | | | | | | | | | | | | | | | | | | | 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
* [InstCombine] auto-generate checks for select+bitwise logic tests; NFCSanjay Patel2016-11-301-259/+0
| | | | llvm-svn: 288254
* [InstCombine] move min/max tests to min/max test file; NFCSanjay Patel2016-11-081-142/+0
| | | | llvm-svn: 286256
* [InstCombine] move/fix tests for adjusted min/maxSanjay Patel2016-11-011-104/+0
| | | | | | | I think the former 'test50' had a typo making it functionally equivalent to the former 'test49'; changed the predicate to provide more coverage. llvm-svn: 285706
* [ValueTracking] recognize more variants of smin/smaxSanjay Patel2016-10-291-7/+7
| | | | | | | | | | | | | Try harder to detect obfuscated min/max patterns: the initial pattern was added with D9352 / rL236202. There was a bug fix for PR27137 at rL264996, but I think we can do better by folding the corresponding smax pattern and commuted variants. The codegen tests demonstrate the effect of ValueTracking on the backend via SelectionDAGBuilder. We can't expose these differences minimally in IR because we don't have smin/smax intrinsics for IR. Differential Revision: https://reviews.llvm.org/D26091 llvm-svn: 285499
* [InstCombine] move/add tests for smin/smax foldsSanjay Patel2016-10-281-25/+0
| | | | llvm-svn: 285414
* [InstCombine] fix foldSPFofSPF() to handle vector splatsSanjay Patel2016-10-271-8/+6
| | | | llvm-svn: 285345
* [InstCombine] add vector tests for foldSPFofSPF to show missing foldsSanjay Patel2016-10-271-0/+33
| | | | llvm-svn: 285340
* [InstCombine] auto-generate checks for min/max testsSanjay Patel2016-10-271-28/+40
| | | | llvm-svn: 285336
* [ValueTracking] fix matchSelectPattern to allow vector splat folds of ↵Sanjay Patel2016-10-271-8/+1
| | | | | | min/max/abs/nabs llvm-svn: 285303
* [InstCombine] add tests for missing folds of vector abs/nabs/min/maxSanjay Patel2016-10-271-3/+20
| | | | llvm-svn: 285299
* [InstCombine] regenerate some checksSanjay Patel2016-10-241-75/+86
| | | | llvm-svn: 285036
* [InstCombine] canonicalize vector select with constant vector condition to ↵Sanjay Patel2016-09-161-0/+33
| | | | | | | | | | | | | | | | | | | | shuffle As discussed on llvm-dev ( http://lists.llvm.org/pipermail/llvm-dev/2016-August/104210.html ): turn a vector select with constant condition operand into a shuffle as a canonicalization step. Shuffles may be easier to reason about in conjunction with other shuffles and insert/extract. Possible known (minor?) regressions from this change are filed as: https://llvm.org/bugs/show_bug.cgi?id=28530 https://llvm.org/bugs/show_bug.cgi?id=28531 https://llvm.org/bugs/show_bug.cgi?id=30371 If something terrible happens to perf after this commit, feel free to revert until a backend fix is in place. Differential Revision: https://reviews.llvm.org/D24279 llvm-svn: 281787
* [InstCombine] LogicOpc (zext X), C --> zext (LogicOpc X, C) (PR28476)Sanjay Patel2016-07-211-4/+4
| | | | | | | | | | | | | | | | The benefits of this change include: 1. Remove DeMorgan-matching code that was added specifically to work-around the missing transform in http://reviews.llvm.org/rL248634. 2. Makes the DeMorgan transform work for vectors too. 3. Fix PR28476: https://llvm.org/bugs/show_bug.cgi?id=28476 Extending this transform to other casts and other associative operators may be useful too. See https://reviews.llvm.org/D22421 for a prerequisite for doing that though. Differential Revision: https://reviews.llvm.org/D22271 llvm-svn: 276221
* [InstSimplify][InstCombine] don't crash when folding vector selects of icmpSanjay Patel2016-07-201-0/+23
| | | | | | Differential Revision: https://reviews.llvm.org/D22602 llvm-svn: 276209
* regenerate checksSanjay Patel2016-07-191-10/+15
| | | | llvm-svn: 276042
* [InstCombine] enable vector select of bools -> logic foldsSanjay Patel2016-07-031-8/+11
| | | | llvm-svn: 274465
OpenPOWER on IntegriCloud