summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Improve instcombine's handling of integer min and max in two ways:Dan Gohman2008-09-161-29/+115
| | | | | | | | | | | | | | | | - Recognize expressions like "x > -1 ? x : 0" as min/max and turn them into expressions like "x < 0 ? 0 : x", which is easily recognizable as a min/max operation. - Refrain from folding expression like "y/2 < 1" to "y < 2" when the comparison is being used as part of a min or max idiom, like "y/2 < 1 ? 1 : y/2". In that case, the division has another use, so folding doesn't eliminate it, and obfuscates the min/max, making it harder to recognize as a min/max operation. These benefit ScalarEvolution, CodeGen, and anything else that wants to recognize integer min and max. llvm-svn: 56246
* On 64-bit targets, change 32-bit getelementptr indices to be 64-bitDan Gohman2008-09-111-1/+12
| | | | | | | getelementptr indices, inserting an explicit cast if necessary. This helps expose the sign-extension operation to other optimizations. llvm-svn: 56133
* Fix a vectorshuffle instcombine bug introduced by r55995.Dan Gohman2008-09-111-1/+4
| | | | | | Patch by Nicolas Capens! llvm-svn: 56129
* Fix a copy+paste bug that Duncan spotted. For severalDan Gohman2008-09-111-1/+1
| | | | | | | cases it was still getting lucky and detecting overflow but it was clearly incorrect. llvm-svn: 56113
* In my analysis for r56076 I missed the case where the originalDan Gohman2008-09-111-1/+2
| | | | | | multiplication overflows. llvm-svn: 56082
* Fix an icmp+sdiv optimization to check for and handle an overflowDan Gohman2008-09-101-1/+16
| | | | | | condition. This fixes PR2740. llvm-svn: 56076
* Fix a warning about comparing signed and unsigned values.Dan Gohman2008-09-101-1/+1
| | | | llvm-svn: 56040
* Make SimplifyDemandedVectorElts simplify vectors with multipleDan Gohman2008-09-091-34/+82
| | | | | | | | | | | | users, and teach it about shufflevector instructions. Also, fix a subtle bug in SimplifyDemandedVectorElts' insertelement code. This is a patch that was originally written by Eli Friedman, with some fixes and cleanup by me. llvm-svn: 55995
* Tidy up several unbeseeming casts from pointer to intptr_t.Dan Gohman2008-09-041-1/+1
| | | | llvm-svn: 55779
* Don't apply this transform to vectors. Fixes PR2756.Nick Lewycky2008-09-031-3/+4
| | | | llvm-svn: 55690
* Revert r54876 r54877 r54906 and r54907. Evan found that these caused a 20%Nick Lewycky2008-08-211-68/+22
| | | | | | slowdown in bzip2. llvm-svn: 55113
* Silence a compiler warning.Evan Cheng2008-08-201-1/+2
| | | | llvm-svn: 55087
* Fixed shuffle optimizations to handle non power of 2 vectorsMon P Wang2008-08-201-4/+4
| | | | llvm-svn: 55035
* Make this comment clearer. Instead of using an ambiguous ~ (not) on an icmpNick Lewycky2008-08-171-1/+1
| | | | | | predicate, swap the order of the operands. llvm-svn: 54907
* Consider the case where xor by -1 and xor by 128 have been combined already toNick Lewycky2008-08-171-1/+23
| | | | | | produce an xor by 127. llvm-svn: 54906
* I found a better place for this optz'n.Nick Lewycky2008-08-171-14/+10
| | | | llvm-svn: 54877
* Xor'ing both sides of icmp by sign-bit is equivalent to swapping signedness ofNick Lewycky2008-08-171-22/+50
| | | | | | | | the predicate. Also, make this optz'n apply in more cases where it's safe to do so. llvm-svn: 54876
* use smallvector instead of vector for a couple worklists. This speeds up ↵Chris Lattner2008-08-151-2/+2
| | | | | | | | instcombine by ~10% on some testcases. llvm-svn: 54811
* Fix a bogus srem rule - a negative value srem'd by a power-of-2Dan Gohman2008-08-131-3/+0
| | | | | | | can have a non-negative result; for example, -16%16 is 0. Also, clarify the related comments. This fixes PR2670. llvm-svn: 54767
* Implement support for simplifying vector comparisons by 0.0 and 1.0 like weChris Lattner2008-08-111-4/+12
| | | | | | | | | do for scalars. Patch contributed by Nicolas Capens This also generalizes the previous xforms to work on long double, now that isExactlyValue works for long double. llvm-svn: 54653
* Fix a shufflevector instcombine that was emitting invalid masks indicesDan Gohman2008-08-061-3/+5
| | | | | | when it meant to be emitting undef indices. llvm-svn: 54417
* optimize a common idiom generated by clang for bitfield access, PR2638.Chris Lattner2008-08-061-1/+31
| | | | llvm-svn: 54408
* Zap sitofp/fptoui pairs. In all cases when the sign difference Chris Lattner2008-08-061-16/+30
| | | | | | matters, the result is undefined anyway. llvm-svn: 54396
* Reinstate this optimization, but without the miscompile. Thanks to Bill forNick Lewycky2008-08-061-0/+15
| | | | | | tracking down that this was breaking llvm-gcc bootstrap on Linux. llvm-svn: 54394
* Revert r53282. This was causing a miscompile on Linux. Also, the transformationBill Wendling2008-08-051-16/+0
| | | | | | looks bogus. Please see PR2629 for details on why this is breaking things. llvm-svn: 54372
* Add vector shifts to the IR, patch by Eli Friedman.Nate Begeman2008-07-291-1/+2
| | | | | | CodeGen & Clang work coming next. llvm-svn: 54161
* Enable first-class aggregates support.Dan Gohman2008-07-231-3/+1
| | | | | | | | | | | | Remove the GetResultInst instruction. It is still accepted in LLVM assembly and bitcode, where it is now auto-upgraded to ExtractValueInst. Also, remove support for return instructions with multiple values. These are auto-upgraded to use InsertValueInst instructions. The IRBuilder still accepts multiple-value returns, and auto-upgrades them to InsertValueInst instructions. llvm-svn: 53941
* Fix PR2553Chris Lattner2008-07-171-1/+2
| | | | llvm-svn: 53715
* Redo InstCombiner::visitExtractValueInst. Instead of using the (complicate)Matthijs Kooijman2008-07-161-5/+80
| | | | | | | FindInsertedValue, it now performs a number of simple transformations that should result in the same effect when applied iteratively. llvm-svn: 53673
* Fix PR2296. Do not transform x86_sse2_storel_dq into a full-width store.Evan Cheng2008-07-161-1/+0
| | | | llvm-svn: 53666
* Fix PR2506 by being a bit more careful about reverse fact propagation whenChris Lattner2008-07-141-64/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | disproving a condition. This actually compiles the existing testcase (udiv_select_to_select_shift) to: define i64 @test(i64 %X, i1 %Cond) { entry: %divisor1.t = lshr i64 %X, 3 ; <i64> [#uses=1] %quotient2 = lshr i64 %X, 3 ; <i64> [#uses=1] %sum = add i64 %divisor1.t, %quotient2 ; <i64> [#uses=1] ret i64 %sum } instead of: define i64 @test(i64 %X, i1 %Cond) { entry: %quotient1.v = select i1 %Cond, i64 3, i64 4 ; <i64> [#uses=1] %quotient1 = lshr i64 %X, %quotient1.v ; <i64> [#uses=1] %quotient2 = lshr i64 %X, 3 ; <i64> [#uses=1] %sum = add i64 %quotient1, %quotient2 ; <i64> [#uses=1] ret i64 %sum } llvm-svn: 53534
* Enhance analysis of srem.Nick Lewycky2008-07-121-15/+3
| | | | | | | Remove dead code analyzing urem. 'urem' of power-of-2 is canonicalized to an 'and' instruction. llvm-svn: 53506
* Document 'mask' in this calculation.Nick Lewycky2008-07-111-0/+1
| | | | llvm-svn: 53454
* Remove misleading constant from comment.Nick Lewycky2008-07-111-1/+1
| | | | llvm-svn: 53452
* Add another optimization from PR2330. Also catch some missing cases that areNick Lewycky2008-07-111-0/+39
| | | | | | similar. llvm-svn: 53451
* a missed optimization that Eli spottedChris Lattner2008-07-111-1/+1
| | | | llvm-svn: 53449
* another bug in the same line.Chris Lattner2008-07-111-1/+1
| | | | llvm-svn: 53448
* fix a bug spotted by Eli's eagle eyesChris Lattner2008-07-111-2/+2
| | | | llvm-svn: 53447
* simplify and merge a bunch of code. Instead of comparing againstChris Lattner2008-07-111-81/+52
| | | | | | | | the min/max values for an integer type, compare against the min/max values we can prove contain the input. This might be a tighter bound, so this is general goodness. llvm-svn: 53446
* fold away (x <= cst) earlier, allowing us to not have to Chris Lattner2008-07-111-103/+68
| | | | | | handle them in some code. llvm-svn: 53445
* Fix folding of icmp's of i1 where the comparison is signed. The codeChris Lattner2008-07-111-10/+22
| | | | | | | was using the algorithm for folding unsigned comparisons which is completely wrong. This has been broken since the signless types change. llvm-svn: 53444
* Fix a bogus optimization: folding (slt (zext i1 A to i32), 1) -> (slt i1 A, ↵Chris Lattner2008-07-111-16/+15
| | | | | | | | | | | true) This cause a regression in InstCombine/JavaCompare, which was doing the right thing on accident. To handle the missed case, generalize the comparisons based on masked bits a little bit to handle comparisons against the max value. For example, we can now xform (slt i32 (and X, 4), 4) -> (setne i32 (and X, 4), 4) llvm-svn: 53443
* Fix overzealous optimization. Thanks to Duncan Sands for pointing out my error!Nick Lewycky2008-07-101-4/+9
| | | | llvm-svn: 53393
* Simplify, suggested by Chris Lattner.Nick Lewycky2008-07-091-1/+1
| | | | llvm-svn: 53283
* Fold (a < 8) && (b < 8) into (a|b) < 8 for unsigned less or greater than.Nick Lewycky2008-07-091-0/+16
| | | | llvm-svn: 53282
* Fold ((1 << a) & 1) to (a == 0).Nick Lewycky2008-07-091-0/+12
| | | | llvm-svn: 53276
* Reduce x - y to -y when we know the 'x' part will get masked off anyways.Nick Lewycky2008-07-091-1/+12
| | | | llvm-svn: 53271
* Fix PR2496, a really nasty bug which involved sinking volatile loads Chris Lattner2008-07-081-3/+11
| | | | | | | | | into phis. This is actually the same bug as PR2262 / 2008-04-29-VolatileLoadDontMerge.ll, but I missed checking the first predecessor for multiple successors. Testcase here: InstCombine/2008-07-08-VolatileLoadMerge.ll llvm-svn: 53240
* Make DenseMap's insert return a pair, to more closely resemble std::map.Dan Gohman2008-07-071-1/+1
| | | | llvm-svn: 53177
* Fix missed optimization opportunity when analyzing cast of mul and select.Nick Lewycky2008-07-051-9/+14
| | | | llvm-svn: 53151
OpenPOWER on IntegriCloud